Over a million developers have joined DZone.

Get Pixel Colors Of An Image

·
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.

>>> from graphics import Image
>>> im = Image.new((10,10))   # create a new 10x10 image
>>> im.clear(0xff0000)        # make it all red
>>> im.getpixel((0,0))   # top-left is red
[(255, 0, 0)]
>>> im.getpixel([(0,0), (10,10)])  # you can get multiple points
[(255, 0, 0), (255, 0, 0)]
>>> 
Topics:

Opinions expressed by DZone contributors are their own.

The best of DZone straight to your inbox.

SEE AN EXAMPLE
Please provide a valid email address.

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.
Subscribe

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}