module ChunkyPNG::Canvas::Adam7Interlacing
def adam7_merge_pass(pass, canvas, subcanvas)
-
subcanvas
(ChunkyPNG::Canvas
) -- The pass image that should be merged -
canvas
(ChunkyPNG::Canvas
) -- The image that is being constructed. -
pass
(Integer
) -- The pass number, should be in 0..6.
def adam7_merge_pass(pass, canvas, subcanvas) x_shift, x_offset, y_shift, y_offset = adam7_multiplier_offset(pass) for y in 0...subcanvas.height do for x in 0...subcanvas.width do new_x = (x << x_shift) | x_offset new_y = (y << y_shift) | y_offset canvas[new_x, new_y] = subcanvas[x, y] end end end