def to_plte_chunk
      @encoding_map = {}
      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 = {}
      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.

 @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?