# How to create a Pixmap from an OrthographicCamera in LibGDX

I am trying to create a picture based on what one of my OrthographicCamera can see. LibGDX has a ScreenUtils class that has a getFrameBufferPixels method, but it does not what I want as I want to get only what one camera sees, not the whole screen.

You need to render what the camera sees to an FBO and then get the pixmap from the FBO itself.

// Construct an FBO and keep a reference to it. Remember to dispose of it.
final FrameBuffer fbo = new FrameBuffer(Format.RGB565, width, height, false);

//Start rendering to the fbo.
fbo.begin();
//From the camera's perspective.
batch.setProjectionMatrix(camera.combined);
batch.begin();

//Draw whatever you want to draw with the camera.

batch.end();
// Finished drawing, get pixmap.
Pixmap pixmap = ScreenUtils.getFrameBufferPixmap(0, 0, width, height);

• What is the utility of ScreenUtils.getFrameBufferPixels(flipY); if I will get the Texture with fbo.getColorBufferTexture(); – Cedric Martens Jun 22 '17 at 18:14
• Yeah and I can't seem to get it into a Pixmap from since it gives me a GdxRuntimeException This TextureData implementation does not return a Pixmap and when I try by doing byte[] bytes = ScreenUtils.getFrameBufferPixels(false); Pixmap pixmap = new Pixmap(bytes, 0, bytes.length); I'll get another GdxRuntimeException saying Couldn't load pixmap from image data – Cedric Martens Jun 22 '17 at 19:45
• @CedricMartens That might be the cause. Try changing the frame buffer to RGBA8888 instead. Editing the buffer should edit the pixmap since the buffer is the data of the pixmap. PixmapIO also uses this buffer to get the pixel data if you look at the source code. – Charanor Jun 22 '17 at 21:05