lib/chunky_png/canvas/png_decoding.rb
# Decodes a scanline in a pixelstream that was encoded using AVERAGE filtering.
# This will change the pixelstream to have unfiltered values.
# @params (see #decode_png_str_scanline)
# @return [void]
Decodes a scanline in a pixelstream that was encoded using AVERAGE filtering.
This will change the pixelstream to have unfiltered values.
Decodes a scanline in a pixelstream that was encoded using AVERAGE filtering . This will change the pixelstream to have unfiltered values .
def decode_png_str_scanline_average(stream, pos, prev_pos, line_length, pixel_size)
        for i in 1..line_length do
          a = i > pixel_size ? stream.getbyte(pos + i - pixel_size) : 0
          b = prev_pos ? stream.getbyte(prev_pos + i) : 0
          stream.setbyte(pos + i, (stream.getbyte(pos + i) + ((a + b) >> 1)) & 0xff)
        end
      end
def decode_png_str_scanline_average ( stream , pos , prev_pos , line_length , pixel_size ) for i in 1 .. line_length do a = i > pixel_size ? stream . getbyte ( pos + i - pixel_size ) : 0 b = prev_pos ? stream . getbyte ( prev_pos + i ) : 0 stream . setbyte ( pos + i , ( stream . getbyte ( pos + i ) + ( ( a + b ) >> 1 ) ) & 0xff ) end end
Decodes a scanline in a pixelstream that was encoded using AVERAGE filtering.
Decodes a scanline in a pixelstream that was encoded using AVERAGE filtering .
None
void
stream
<not_specific>
pos
<not_specific>
prev_pos
<not_specific>
line_length
<not_specific>
pixel_size
<not_specific>
params
None