lib/chunky_png/canvas/png_decoding.rb
# Decodes a canvas from a PNG encoded pixelstream, using a given width, height,
# color mode and interlacing mode.
# @param [String] stream The pixelstream to read from.
# @param [Integer] width The width of the image.
# @param [Integer] height The height of the image.
# @param [Integer] color_mode The color mode of the encoded pixelstream.
# @param [Integer] depth The bit depth of the pixel samples.
# @param [Integer] interlace The interlace method of the encoded pixelstream.
# @param [ChunkyPNG::Palette] decoding_palette The palette to use to decode colors.
# @param [Integer] transparent_color The color that should be considered fully transparent.
# @return [ChunkyPNG::Canvas] The decoded Canvas instance.
Decodes a canvas from a PNG encoded pixelstream, using a given width, height,
color mode and interlacing mode.
Decodes a canvas from a PNG encoded pixelstream using a given width height color mode and interlacing mode .
def decode_png_pixelstream(stream, width, height, color_mode, depth, interlace, decoding_palette, transparent_color)
        raise ChunkyPNG::ExpectationFailed, "This palette is not suitable for decoding!" if decoding_palette && !decoding_palette.can_decode?
        image = case interlace
          when ChunkyPNG::INTERLACING_NONE  then decode_png_without_interlacing(stream, width, height, color_mode, depth, decoding_palette)
          when ChunkyPNG::INTERLACING_ADAM7 then decode_png_with_adam7_interlacing(stream, width, height, color_mode, depth, decoding_palette)
          else raise ChunkyPNG::NotSupported, "Don't know how the handle interlacing method #{interlace}!"
        end
        image.pixels.map! { |c| c == transparent_color ? ChunkyPNG::Color::TRANSPARENT : c } if transparent_color
        image
      end
def decode_png_pixelstream ( stream , width , height , color_mode , depth , interlace , decoding_palette , transparent_color ) raise ChunkyPNG :: ExpectationFailed , "This palette is not suitable for decoding!" if decoding_palette && ! decoding_palette . can_decode? image = case interlace when ChunkyPNG :: INTERLACING_NONE then decode_png_without_interlacing ( stream , width , height , color_mode , depth , decoding_palette ) when ChunkyPNG :: INTERLACING_ADAM7 then decode_png_with_adam7_interlacing ( stream , width , height , color_mode , depth , decoding_palette ) else raise ChunkyPNG :: NotSupported , "Don't know how the handle interlacing method #{interlace}!" end image . pixels . map! { | c | c == transparent_color ? ChunkyPNG :: Color :: TRANSPARENT : c } if transparent_color image end
Decodes a canvas from a PNG encoded pixelstream, using a given width, height,
color mode and interlacing mode.
Decodes a canvas from a PNG encoded pixelstream using a given width height color mode and interlacing mode .
The decoded Canvas instance.
The decoded Canvas instance .
ChunkyPNG::Canvas
stream
<not_specific>
width
<not_specific>
height
<not_specific>
color_mode
<not_specific>
depth
<not_specific>
interlace
<not_specific>
decoding_palette
<not_specific>
transparent_color
<not_specific>
<not_specific>
transparent_color The color that should be considered fully transparent.
transparent_color The color that should be considered fully transparent .