Skip to content

Instantly share code, notes, and snippets.

@bartolsthoorn
Created January 26, 2011 11:40
Show Gist options
  • Save bartolsthoorn/796590 to your computer and use it in GitHub Desktop.
Save bartolsthoorn/796590 to your computer and use it in GitHub Desktop.
# Looping pixels!
Win = Gosu::Window.new(500, 500, false)
img = Gosu::Image.new(Win, filename)
# Show info of 1 pixel
p = img.get_pixel(100,100);
puts p.to_s
# loop and make grey
img.each{ |pixel|
averageG = ((pixel[0]+pixel[1]+pixel[2])/3)
if (averageG)
pixel[0]=averageG
pixel[1]=averageG
pixel[2]=averageG
}
img.save("output.png")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment