Drawing a 640x480 Raw Image

W. Watson wolf_tracks at invalid.com
Fri Sep 21 08:34:01 EDT 2007


Very good. I'll give it a try.

Marc 'BlackJack' Rintsch wrote:
> On Thu, 20 Sep 2007 20:49:59 -0700, W. Watson wrote:
> 
>> W. Watson wrote:
>>> I'm getting a 640x480 greyscale image from a video device. I'd like to 
>>> place it on a canvas and then draw on the image. Does PIL or some image 
>>> facility allow me to do that?
>> Corrected misspelling in Subject. The image here is nothing more than a 
>> 640x480 byte array. Each byte is a gra[e]yscale value.
> 
> PIL can do this:
> 
> from PIL import Image
> 
> def main():
>     width = 640
>     height = 480
>     image = Image.new('L', (width, height))
>     data = [x * y % 256 for x in xrange(width) for y in xrange(height)]
>     image.putdata(data)
>     image.save('test.png')
> 
> `data` can be any iterable with byte values.
> 
> Ciao,
> 	Marc 'BlackJack' Rintsch

-- 
                          Wayne Watson (Nevada City, CA)

                        Web Page: <speckledwithStars.net>



More information about the Python-list mailing list