Drawing a 640x480 Raw Image
Marc 'BlackJack' Rintsch
bj_666 at gmx.net
Fri Sep 21 02:14:26 EDT 2007
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
More information about the Python-list
mailing list