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

Methods inherited from Base

#initialize, #write, #write_with_crc

Constructor Details

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

Class Method Details

+ (Object) combine_chunks(data_chunks)



252
253
254
# File 'lib/chunky_png/chunk.rb', line 252

def self.combine_chunks(data_chunks)
  Zlib::Inflate.inflate(data_chunks.map { |c| c.content }.join(''))
end

+ (Object) read(type, content)

Raises:



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

def self.read(type, content)
  raise ExpectationFailed, 'The IDAT chunk should not be empty!' if content.bytesize == 0
  super
end

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



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

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