module ChunkyPNG::Canvas::PNGEncoding

def encode_png_pixels_to_scanline_method(color_mode, depth)

Raises:
  • (ChunkyPNG::NotSupported) - when the color_mode and/or bit depth is not supported.

Returns:
  • (Symbol) - The method name to use for decoding, to be called on the canvas class.

Parameters:
  • depth (Integer) -- The bit depth of the image.
  • color_mode (Integer) -- The color mode of the image.
def encode_png_pixels_to_scanline_method(color_mode, depth)
  encoder_method = case color_mode
    when ChunkyPNG::COLOR_TRUECOLOR;       :"encode_png_pixels_to_scanline_truecolor_#{depth}bit"
    when ChunkyPNG::COLOR_TRUECOLOR_ALPHA; :"encode_png_pixels_to_scanline_truecolor_alpha_#{depth}bit"
    when ChunkyPNG::COLOR_INDEXED;         :"encode_png_pixels_to_scanline_indexed_#{depth}bit"
    when ChunkyPNG::COLOR_GRAYSCALE;       :"encode_png_pixels_to_scanline_grayscale_#{depth}bit"
    when ChunkyPNG::COLOR_GRAYSCALE_ALPHA; :"encode_png_pixels_to_scanline_grayscale_alpha_#{depth}bit"
    else nil
  end
  
  raise ChunkyPNG::NotSupported, "No encoder found for color mode #{color_mode} and #{depth}-bit depth!" unless respond_to?(encoder_method, true)
  encoder_method
end