Class: ChunkyPNG::Chunk
- Inherits:
-
Object
- Object
- ChunkyPNG::Chunk
- Defined in:
- lib/chunky_png/chunk.rb
Defined Under Namespace
Classes: Base, End, Generic, Header, ImageData, Palette, Transparency
Constant Summary collapse
- CHUNK_TYPES =
Maps chunk types to classes. If a chunk type is not given in this hash, a generic chunk type will be used.
{ 'IHDR' => Header, 'IEND' => End, 'IDAT' => ImageData, 'PLTE' => Palette, 'tRNS' => Transparency }
Class Method Summary collapse
Class Method Details
.read(io) ⇒ Object
4 5 6 7 8 9 10 11 12 13 |
# File 'lib/chunky_png/chunk.rb', line 4 def self.read(io) length, type = io.read(8).unpack('Na4') content = io.read(length) crc = io.read(4).unpack('N').first # verify_crc!(type, content, crc) CHUNK_TYPES.fetch(type, Generic).read(type, content) end |