funny return format of glGetTexImage
Patrick Dietrich <[email protected]> Mon, 28 Oct 2013 14:49:14 +0100
| Newsgroups | gmane.comp.python.opengl.user |
|---|---|
| Message-ID | <[email protected]> |
Hi all,
using glGetTexImageI have noticed two bugs:
1.
according to the documentation the return value should always be an
array if
OpenGL.UNSIGNED_BYTE_IMAGES_AS_STRING == False
which is not the case: OpenGL.UNSIGNED_BYTE_IMAGES_AS_STRING seems to be
ignored completely and
with type=GL_UNSIGNED_BYTE and the default for outputType a string is
returned. Setting outputType=None returns an array.
2.
image = glGetTexImage( GL_TEXTURE_RECTANGLE, level=0, format=GL_RGBA,
format, type=GL_UNSIGNED_BYTE, outputType=None )
print "\timage:", type(image), image.shape, image.dtype
prints
image: <type 'numpy.ndarray'> (472L, 575L, 1L, 4L) uint8
(for format=GL_RGB the shape is (472L, 575L, 1L, 3L) )
In addition to the unused dimension 2 of the array, width and height are
mixed up.
My workaround is:
image.shape = (image.shape[1], image.shape[0], image.shape[3])
which creates an image that looks fine apart from being mirrored along
the horizontal axis.
So to save it to disk, I do:
im = PIL.Image.fromarray(image_data)
im = im.transpose(PIL.Image.FLIP_TOP_BOTTOM)
im.save('test.png', format="PNG")
Regards,
Patrick
------------------------------------------------------------------------------
October Webinars: Code for Performance
Free Intel webinars can help you accelerate application performance.
Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from
the latest Intel processors and coprocessors. See abstracts and register >
http://pubads.g.doubleclick.net/gampad/clk?id=60135991&iu=/4140/ostg.clktrk
_______________________________________________
PyOpenGL Homepage
http://pyopengl.sourceforge.net