PIL Image to PyOpengl glDrawPixels
Pete Shinners
pete at shinners.org
Fri Jan 4 03:34:03 EST 2002
Joe Connellan wrote:
> I'm opening an image using
>
> import Image
>
> im = Image.open("/tmp/image.bmp")
> imgData = im.getData()
>
> which returns a nested list of integers like this
> imgData[width*height][3]
>
> How do I go about formating this for the following glDrawPixels?
you'll want to use the 'tostring' function from PIL. this will convert
the image into a string of byte-data. that is what you pass to
glDrawPixels. also be sure to use the vertical-flip option for tostring,
since opengl looks at images bottom to top :]
More information about the Python-list
mailing list