class ChunkyPNG::Chunk::ImageData
@see www.w3.org/TR/PNG/#11IDAT<br><br>to decode, and {{.split_in_chunks}} for encoding a pixeldata stream into IDAT chunks.
and inflated in order to decode an image. See {{.combine_chunks}} to combine chunks
The data of an image can be split over multiple chunks, which will have to be combined
An image data (IDAT) chunk holds (part of) the compressed image pixel data.
def self.combine_chunks(data_chunks)
-
(String)
- The combined, inflated pixeldata as binary string
def self.combine_chunks(data_chunks) zstream = Zlib::Inflate.new data_chunks.each { |c| zstream << c.content } inflated = zstream.finish zstream.close inflated end
def self.split_in_chunks(data, level = Zlib::DEFAULT_COMPRESSION, chunk_size = 2147483647)
-
chunk_size
(Integer
) -- The maximum size of a chunk. -
level
(Integer
) -- The compression level to use. -
data
(String
) -- The binary string of pixeldata
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