lib/chunky_png/palette.rb
# Creates a PLTE chunk that corresponds with this palette to store the r,
# g, and b channels of all colors.
#
# @note A PLTE chunk should only be included if the image is encoded using
#   index colors. After this chunk has been built, the palette becomes
#   suitable for encoding an image.
#
# @return [ChunkyPNG::Chunk::Palette] The PLTE chunk.
# @see ChunkyPNG::Palette#can_encode?
Creates a PLTE chunk that corresponds with this palette to store the r,
g, and b channels of all colors.
Creates a PLTE chunk that corresponds with this palette to store the r g and b channels of all colors .
def to_plte_chunk
      @encoding_map.clear
      colors = []
      each_with_index do |color, index|
        @encoding_map[color] = index
        colors += ChunkyPNG::Color.to_truecolor_bytes(color)
      end
      ChunkyPNG::Chunk::Palette.new("PLTE", colors.pack("C*"))
    end
def to_plte_chunk @encoding_map . clear colors = [ ] each_with_index do | color , index | @encoding_map [ color ] = index colors += ChunkyPNG :: Color . to_truecolor_bytes ( color ) end ChunkyPNG :: Chunk :: Palette . new ( "PLTE" , colors . pack ( "C*" ) ) end
Creates a PLTE chunk that corresponds with this palette to store the r,
g, and b channels of all colors.
Creates a PLTE chunk that corresponds with this palette to store the r g and b channels of all colors .
The PLTE chunk.
The PLTE chunk .
ChunkyPNG::Chunk::Palette
note
A PLTE chunk should only be included if the image is encoded using index colors. After this chunk has been built, the palette becomes suitable for encoding an image.
A PLTE chunk should only be included if the image is encoded using index colors . After this chunk has been built the palette becomes suitable for encoding an image .
see
None