Imagination PowerVR SDK Blog

How to save framebuffer as an image


#1

Hi

I have found few functions (PVRShellScreenCaptureBuffer, PVRShellScreenSave and PVRShellWriteBMPFile)

that could probably be used to do this, but I don’t know how to use them. The documentation is quite poor and I didn’t find any examples from the tutorials so could somebody please explain with as much detail as possible how to use them. And as you might have guessed, I’m a complete newbie :).


#2

Well, what you’ll want to do is create a buffer of data, copy the frame buffer into it, then save that to a file.





GLubyte data = new GLuint[widthheight3]; //size of image multiplied by 3 for the red, the green and the blue


glReadPixels(0, 0, width, height, GL_RGB, GL_UNSIGNED_BYTE,data); //copies the data from the frame buffer to your pointer


PVRShellWriteBMPFile(“testscreen.bmp”, width, height, data); //creates the bitmap file


delete [] data; //free the memory after





So you’ll need to put that code somewhere after the drawing of the scene, like at the end of a render function.


#3

Thanks for the swift answer :).