Never been to DZone Snippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

get pixel colors of an image (See related posts)

I wrote a hack to get the color of a pixel.
Now pys60 1.2 has support for getpixel (though undocumented).
Cyke64 has shown me in an example.
   1  
   2  >>> from graphics import Image
   3  >>> im = Image.new((10,10))   # create a new 10x10 image
   4  >>> im.clear(0xff0000)        # make it all red
   5  >>> im.getpixel((0,0))   # top-left is red
   6  [(255, 0, 0)]
   7  >>> im.getpixel([(0,0), (10,10)])  # you can get multiple points
   8  [(255, 0, 0), (255, 0, 0)]
   9  >>> 

You need to create an account or log in to post comments to this site.


Click here to browse all 5827 code snippets

Related Posts