Skip to content

Instantly share code, notes, and snippets.

@anthonylewis
Created June 27, 2011 19:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anthonylewis/c9913668ab401d554e0f to your computer and use it in GitHub Desktop.
Save anthonylewis/c9913668ab401d554e0f to your computer and use it in GitHub Desktop.
Codebrawl #2
require 'chunky_png'
image = ChunkyPNG::Image.from_file('input.png')
# Not exactly elegant, but it gets the job done
sample_y = 0
while sample_y < image.height do
sample_x = 0
while sample_x < image.width do
sample_color = image.get_pixel(sample_x + 4, sample_y + 4)
(sample_x).upto(sample_x + 9) do |x|
(sample_y).upto(sample_y + 9) do |y|
image.set_pixel_if_within_bounds(x, y, sample_color)
end
end
sample_x += 10
end
sample_y += 10
end
image.save('output.png')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment