lib/chunky_png/canvas/resampling.rb
# Resamples the canvas using nearest neighbor interpolation.
# @param [Integer] new_width The width of the resampled canvas.
# @param [Integer] new_height The height of the resampled canvas.
# @return [ChunkyPNG::Canvas] A new canvas instance with the resampled pixels.
Resamples the canvas using nearest neighbor interpolation.
Resamples the canvas using nearest neighbor interpolation .
def resample_nearest_neighbor!(new_width, new_height)
        steps_x = steps(width, new_width)
        steps_y = steps(height, new_height)
        pixels = Array.new(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
def resample_nearest_neighbor! ( new_width , new_height ) steps_x = steps ( width , new_width ) steps_y = steps ( height , new_height ) pixels = Array . new ( 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
Resamples the canvas using nearest neighbor interpolation.
Resamples the canvas using nearest neighbor interpolation .
A new canvas instance with the resampled pixels.
A new canvas instance with the resampled pixels .
ChunkyPNG::Canvas
new_width
<not_specific>
new_height
<not_specific>
<not_specific>
new_height The height of the resampled canvas.
new_height The height of the resampled canvas .