Drawing a 640x480 Ras Image

W

W. Watson

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?
 
W

W. Watson

Corrected misspelling in Subject. The image here is nothing more than a
640x480 byte array. Each byte is a gra[e]yscale value.
 
M

Marc 'BlackJack' Rintsch

W. Watson said:
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
 
W

W. Watson

Very good. I'll give it a try.
W. Watson said:
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
 
W

W. Watson

Oops. What I think I'm looking for is a way to open a data file of records
that are 640x480 that are gray scaled. I probably need something like an
open and a read. Once I've got that, then I need to place the raw image into
a draw area on the canvas, so that I can draw on the image.

W. Watson said:
Very good. I'll give it a try.
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,756
Messages
2,569,533
Members
45,007
Latest member
OrderFitnessKetoCapsules

Latest Threads

Top