PIL Image to PyOpengl glDrawPixels
Joe Connellan
joe at al.com.au
Thu Jan 3 20:40:36 EST 2002
Hi,
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?
glDrawPixels(self.im.size[0], self.im.size[1], GL_RGB, GL_INT, imgData)
according to the docs this particular glDrawPixels is suppose to take a
sequence of ints but the following code does not work
width = 100
height = 100
numChannels = 3
imgData = [100, ] * width * height * numChannels
glDrawPixels(100, 100, GL_RGB, GL_INT, imgData)
I'm pretty sure glDrawPixels is working ok as the following code works
fine (using chars).
width = 100
height = 100
numChannels = 3
imgData = chr(100) * width * height * numChannels
glDrawPixels(100, 100, GL_RGB, GL_UNSIGNED_BYTE, imgData)
Any help would be greatly appreciated.
Thanks
Joe
More information about the Python-list
mailing list