module ChunkyPNG::Canvas::PNGDecoding

def from_datastream(ds)

def from_datastream(ds)
  raise "Only 8-bit color depth is currently supported by ChunkyPNG!" unless ds.header_chunk.depth == 8
  width      = ds.header_chunk.width
  height     = ds.header_chunk.height
  color_mode = ds.header_chunk.color
  interlace  = ds.header_chunk.interlace
  palette    = ChunkyPNG::Palette.from_chunks(ds.palette_chunk, ds.transparency_chunk)
  stream     = ChunkyPNG::Chunk::ImageData.combine_chunks(ds.data_chunks)
  decode_png_pixelstream(stream, width, height, color_mode, palette, interlace)
end