lib/chunky_png/canvas/png_decoding.rb
# Decodes a scanline in a pixelstream that was encoded using PAETH 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 PAETH filtering.
This will change the pixelstream to have unfiltered values.
Decodes a scanline in a pixelstream that was encoded using PAETH filtering . This will change the pixelstream to have unfiltered values .
def decode_png_str_scanline_paeth(stream, pos, prev_pos, line_length, pixel_size)
        for i in 1..line_length do
          cur_pos = pos + i
          a = i > pixel_size ? stream.getbyte(cur_pos - pixel_size) : 0
          b = prev_pos ? stream.getbyte(prev_pos + i) : 0
          c = prev_pos && i > pixel_size ? stream.getbyte(prev_pos + i - pixel_size) : 0
          p = a + b - c
          pa = (p - a).abs
          pb = (p - b).abs
          pc = (p - c).abs
          pr = if pa <= pb
            pa <= pc ? a : c
          else
            pb <= pc ? b : c
          end
          stream.setbyte(cur_pos, (stream.getbyte(cur_pos) + pr) & 0xff)
        end
      end
def decode_png_str_scanline_paeth ( stream , pos , prev_pos , line_length , pixel_size ) for i in 1 .. line_length do cur_pos = pos + i a = i > pixel_size ? stream . getbyte ( cur_pos - pixel_size ) : 0 b = prev_pos ? stream . getbyte ( prev_pos + i ) : 0 c = prev_pos && i > pixel_size ? stream . getbyte ( prev_pos + i - pixel_size ) : 0 p = a + b - c pa = ( p - a ) . abs pb = ( p - b ) . abs pc = ( p - c ) . abs pr = if pa <= pb pa <= pc ? a : c else pb <= pc ? b : c end stream . setbyte ( cur_pos , ( stream . getbyte ( cur_pos ) + pr ) & 0xff ) end end
Decodes a scanline in a pixelstream that was encoded using PAETH filtering.
Decodes a scanline in a pixelstream that was encoded using PAETH filtering .
None
void
stream
<not_specific>
pos
<not_specific>
prev_pos
<not_specific>
line_length
<not_specific>
pixel_size
<not_specific>
params
None