[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
Re: [pygame] PyOpenGL Screenshots
hi again,
note, you can convert a series of images with image magik, or the gimp
most easily I think...
convert -delay 20 -loop 0 bla*.tga animated.gif
Or opening them as gimp layers, then saving to an animated gif.
cu,
On Wed, May 7, 2008 at 2:44 PM, René Dudfield <renesd@xxxxxxxxx> wrote:
> looks like pyopengl 3.x returns a numpy array now instead of a string
> by default... which breaks pygame.image.save on gl with pyopengl 3.x.
>
> Here's a work around screenshot function for gl.
>
>
> def save_screen(screen, filename):
>
> def readScreen(x, y, width, height):
> """ Read in the screen information in the area specified """
> glFinish()
> glPixelStorei(GL_PACK_ALIGNMENT, 4)
> glPixelStorei(GL_PACK_ROW_LENGTH, 0)
> glPixelStorei(GL_PACK_SKIP_ROWS, 0)
> glPixelStorei(GL_PACK_SKIP_PIXELS, 0)
>
> data = glReadPixels(x, y, width, height, GL_RGB, GL_UNSIGNED_BYTE)
> if hasattr(data, "tostring"):
> data = data.tostring()
>
> return data
> def saveImageData(width, height, data, filename):
> """ Save image data """
> surface = pygame.image.fromstring(data, (width, height), 'RGB', 1)
> pygame.image.save(surface, filename)
>
> data = readScreen(0,0, screen.get_width(), screen.get_height())
> saveImageData(screen.get_width(), screen.get_height(), data, filename)
>
>
>
>
>
> On Wed, May 7, 2008 at 2:27 PM, René Dudfield <renesd@xxxxxxxxx> wrote:
> > hi,
> >
> > glReadPixels, make a surface, then use pygame.image.save()
> >
> > Then use ffmpeg, or vlc etc to make a movie out of still frames.
> >
> > cheers,
> >
>