module ChunkyPNG::Canvas::Resampling
def resample_nearest_neighbor!(new_width, new_height)
-
(ChunkyPNG::Canvas)
- A new canvas instance with the resampled pixels.
Parameters:
-
new_height
(Integer
) -- The height of the resampled canvas. -
new_width
(Integer
) -- The width of the resampled canvas.
def resample_nearest_neighbor!(new_width, new_height) steps_x = steps(width, new_width) steps_y = steps(height, new_height) pixels = Array(size=new_width*new_height) i = 0 for y in steps_y for x in steps_x pixels[i] = get_pixel(x, y) i += 1 end end replace_canvas!(new_width.to_i, new_height.to_i, pixels) end