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

.combine_chunks(data_chunks) ⇒ Object



229
230
231
# File 'lib/chunky_png/chunk.rb', line 229

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

.read(type, content) ⇒ Object

Raises:



224
225
226
227
# File 'lib/chunky_png/chunk.rb', line 224

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

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



233
234
235
236
237
# File 'lib/chunky_png/chunk.rb', line 233

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