# Capture a partial screenshot in the BGE

I am looking for a way to capture just a portion of the screen in the game engine. I was using the built-in render.makeScreenshot(path), which only captures a full-screen PNG.

I am exploring the following approach but have no idea how to save the list data into an image format. Any help would be appreciated.

from bgl import *
def captureCropped(posX, posY, sizeX, sizeY):
buf = Buffer(GL_BYTE, [sizeX,sizeY,3])
... #now what do I do with buf?

• Using this answer, you should be able to write an image: blender.stackexchange.com/questions/643/… Oct 4 '13 at 0:58
• I want to avoid using bpy if possible. My understanding is that it is not (or should not be) available in the game engine/blenderplayer. Oct 4 '13 at 2:20
• in that case Im not sure how you would do this besides writing the raw data directly, which - I should add, is not as hard as you might expect - see: stackoverflow.com/questions/902761/… Oct 4 '13 at 6:33
• Could you answer this with the patch you wrote. Thanks. Nov 10 '13 at 1:06

Another solution is to extend render.makescreenshot(filename) to accept additional optional argument in the form of render.makescreenshot(filename, x, y, width, height) The work-in-progress patch is here: http://www.pasteall.org/47215/diff