[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [pygame] .png saving



I've been playing with the latest pygame source code, and it looks
like this is the situation with openGL display surfaces and saving
pngs...

the image module source has a c function in it "opengltosdl" in it
that was written to use glReadPixels from the pyOpenGL package to get
a surface from the openGL display. It looks like it is used with the
basic image save function and with image.tostring so it should work
with those 2 things - however with PyOpenGL 3.0, glReadPixels now
returns a "OpenGL.arrays.ctypesarrays" instead of a python string, so
"opengltosdl" segfaults when trying to copy data from the array into a
surface.

the imagext module has a c function to save a surface to a png, but
it's not in pygame 1.7. it appears to use libpng directly, so it seems
pygame should be able to save a png. However the function uses a blit
in order to convert the surface to a format that is appropriate for
png saving (24 or 32 bit), so the current version of that function
will fail with an opengl display because openGL display surfaces are
created with "dummy" surface contents, which can be passed to blit
functions, but will not work (apparently they crash in such
instances).

So with PyOpenGL 3.0 and pygame svn as it is, all options to get at
the openGL display will crash...

----
so does anybody know how to get a string from a ctypes sized array in
python or how to get the void * to a ctypes sized array in extension
source code?

On Oct 26, 2007 12:47 PM, Ian Mallett <geometrian@xxxxxxxxx> wrote:
> Hi,
>   Saving a surface with "pygame.image.save()" with file extension ".png" is
> broken.
> Ian
>