lib/chunky_png/datastream.rb
# Reads a PNG datastream from an input stream
# @param [IO] io The stream to read from.
# @return [ChunkyPNG::Datastream] The loaded datastream instance.
Reads a PNG datastream from an input stream
Reads a PNG datastream from an input stream
def from_io(io)
        io.set_encoding(::Encoding::BINARY)
        verify_signature!(io)
        ds = new
        while ds.end_chunk.nil?
          chunk = ChunkyPNG::Chunk.read(io)
          case chunk
            when ChunkyPNG::Chunk::Header       then ds.header_chunk = chunk
            when ChunkyPNG::Chunk::Palette      then ds.palette_chunk = chunk
            when ChunkyPNG::Chunk::Transparency then ds.transparency_chunk = chunk
            when ChunkyPNG::Chunk::ImageData    then ds.data_chunks << chunk
            when ChunkyPNG::Chunk::Physical     then ds.physical_chunk = chunk
            when ChunkyPNG::Chunk::End          then ds.end_chunk = chunk
            else ds.other_chunks << chunk
          end
        end
        ds
      end
def from_io ( io ) io . set_encoding ( :: Encoding :: BINARY ) verify_signature! ( io ) ds = new while ds . end_chunk . nil? chunk = ChunkyPNG :: Chunk . read ( io ) case chunk when ChunkyPNG :: Chunk :: Header then ds . header_chunk = chunk when ChunkyPNG :: Chunk :: Palette then ds . palette_chunk = chunk when ChunkyPNG :: Chunk :: Transparency then ds . transparency_chunk = chunk when ChunkyPNG :: Chunk :: ImageData then ds . data_chunks << chunk when ChunkyPNG :: Chunk :: Physical then ds . physical_chunk = chunk when ChunkyPNG :: Chunk :: End then ds . end_chunk = chunk else ds . other_chunks << chunk end end ds end
Reads a PNG datastream from an input stream
Reads a PNG datastream from an input stream
The loaded datastream instance.
The loaded datastream instance .
ChunkyPNG::Datastream
io
<not_specific>
<not_specific>
io The stream to read from.
io The stream to read from .