2016-11-12 64 views

回答

1

最简单的方法是截取屏幕截图。完成这一步之后,你绘制的渲染图:

byte[] pixels = ScreenUtils.getFrameBufferPixels(0, 0, Gdx.graphics.getBackBufferWidth(), Gdx.graphics.getBackBufferHeight(), true); 

Pixmap pixmap = new Pixmap(Gdx.graphics.getBackBufferWidth(), Gdx.graphics.getBackBufferHeight(), Pixmap.Format.RGBA8888); 
BufferUtils.copy(pixels, 0, pixmap.getPixels(), pixels.length); 
PixmapIO.writePNG(Gdx.files.external("mypixmap.png"), pixmap); 
pixmap.dispose(); 

从维基摘自:https://github.com/libgdx/libgdx/wiki/Taking-a-Screenshot

如果你需要的东西票友,看看ScreenUtils#getFrameBufferPixels源代码。