module ChunkyPNG::Canvas::PNGEncoding
def determine_png_encoding(constraints = {})
-
(Hash)
- A hash with encoding options for {ChunkyPNG::Canvas::PNGEncoding#to_datastream}
Parameters:
-
constraints
(Hash
) -- The constraints for the encoding.
def determine_png_encoding(constraints = {}) if constraints == :fast_rgb encoding = { :color_mode => ChunkyPNG::COLOR_TRUECOLOR } elsif constraints == :fast_rgba encoding = { :color_mode => ChunkyPNG::COLOR_TRUECOLOR_ALPHA } else encoding = constraints end # Do not create a pallete when the encoding is given and does not require a palette. if encoding[:color_mode] if encoding[:color_mode] == ChunkyPNG::COLOR_INDEXED self.encoding_palette = self.palette end else self.encoding_palette = self.palette encoding[:color_mode] ||= encoding_palette.best_colormode end encoding[:interlace] = case encoding[:interlace] when nil, false, ChunkyPNG::INTERLACING_NONE then ChunkyPNG::INTERLACING_NONE when true, ChunkyPNG::INTERLACING_ADAM7 then ChunkyPNG::INTERLACING_ADAM7 else encoding[:interlace] end return encoding end