lib/chunky_png/canvas/png_encoding.rb
def encode_png_pixels_to_scanline_indexed_4bit(pixels)
        chars = []
        pixels.each_slice(2) do |p1, p2|
          chars << ((encoding_palette.index(p1) << 4) | encoding_palette.index(p2))
        end
        chars.pack("xC*")
      end
# Encodes a line of pixels using 4-bit indexed mode.
# @param [Array<Integer>] pixels A row of pixels of the original image.
# @return [String] The encoded scanline as binary string
Encodes a line of pixels using 4-bit indexed mode.
Encodes a line of pixels using 4 - bit indexed mode .
def encode_png_pixels_to_scanline_indexed_4bit(pixels)
        chars = []
        pixels.each_slice(2) do |p1, p2|
          chars << ((encoding_palette.index(p1) << 4) | encoding_palette.index(p2))
        end
        chars.pack("xC*")
      end
def encode_png_pixels_to_scanline_indexed_4bit ( pixels ) chars = [ ] pixels . each_slice ( 2 ) do | p1 , p2 | chars << ( ( encoding_palette . index ( p1 ) << 4 ) | encoding_palette . index ( p2 ) ) end chars . pack ( "xC*" ) end
Encodes a line of pixels using 4-bit indexed mode.
Encodes a line of pixels using 4 - bit indexed mode .
The encoded scanline as binary string
The encoded scanline as binary string
String
pixels
pixels A row of pixels of the original image.
pixels A row of pixels of the original image .