[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
BUG: pygame.image.save(screen) with pyopengl 3.x Re: [pygame] PyOpenGL Screenshots
- To: pygame-users@xxxxxxxx
- Subject: BUG: pygame.image.save(screen) with pyopengl 3.x Re: [pygame] PyOpenGL Screenshots
- From: "René Dudfield" <renesd@xxxxxxxxx>
- Date: Wed, 7 May 2008 14:47:23 +1000
- Delivered-to: archiver@xxxxxxxx
- Delivered-to: pygame-users-outgoing@xxxxxxxx
- Delivered-to: pygame-users@xxxxxxxx
- Delivery-date: Wed, 07 May 2008 00:47:27 -0400
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to:subject:mime-version:content-type:content-transfer-encoding:content-disposition; bh=cuSjRqs/AbdiHLCF1uM86j6Qv2Sh2a8Ud7fXzeOrwpg=; b=Geys3ntO/Q5xAaQjjRXr6vRFcJ2TXp2pEKUvGFtdI/HReaonfDlYIIn088Nc4gX+6pL+swkhbXyrQ+C6zyaOTqb8mFzVrAqL+QoTLLa9fJwdledTk3x67qCy4ulPgevFQX2Yay6NHw8XwjCl/1ud6btKnax2xcCD121UEJMqUP8=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:mime-version:content-type:content-transfer-encoding:content-disposition; b=dI4qcuFCLihDgHofbihJgwZx8+le0CtKSDhmHodPuk14gZSQJ+WTmPo40m4v0hT8j5jhr99axtPYG7R8JeH/Efh6SRozVbXj8E4Pr1UvoqB6MYIS5hI+TcUHdynoNOlreDGY/l5M70N9rhZwvSdVOBsBeBxONiWA5b1atTpzEPs=
- Reply-to: pygame-users@xxxxxxxx
- Sender: owner-pygame-users@xxxxxxxx
Added a bug to the subject.
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,
> >
>