Class: ChunkyPNG::Chunk::ImageData

Inherits:
Generic show all
Defined in:
lib/chunky_png/chunk.rb

Instance Attribute Summary

Attributes inherited from Generic

#content

Attributes inherited from Base

#type

Class Method Summary collapse

Methods inherited from Generic

#initialize, read

Methods inherited from Base

#initialize, #write, #write_with_crc

Constructor Details

This class inherits a constructor from ChunkyPNG::Chunk::Generic

Class Method Details

.combine_chunks(data_chunks) ⇒ Object


247
248
249
250
251
252
253
# File 'lib/chunky_png/chunk.rb', line 247

def self.combine_chunks(data_chunks)
  zstream = Zlib::Inflate.new
  data_chunks.each { |c| zstream << c.content }
  inflated = zstream.finish
  zstream.close
  inflated
end

.split_in_chunks(data, level = Zlib::DEFAULT_COMPRESSION, chunk_size = 2147483647) ⇒ Object


255
256
257
258
259
# File 'lib/chunky_png/chunk.rb', line 255

def self.split_in_chunks(data, level = Zlib::DEFAULT_COMPRESSION, chunk_size = 2147483647)
  streamdata = Zlib::Deflate.deflate(data, level)
  # TODO: Split long streamdata over multiple chunks
  [ ChunkyPNG::Chunk::ImageData.new('IDAT', streamdata) ]
end