private void makeScreenshot(){
int w = Gdx.graphics.getWidth();
int h = Gdx.graphics.getHeight();
Gdx.gl.glPixelStorei(GL10.GL_PACK_ALIGNMENT, 1);
final Pixmap pixmap = new Pixmap(w, h, Format.RGBA8888);
ByteBuffer pixels = pixmap.getPixels();
Gdx.gl.glReadPixels(0, 0, w, h, GL10.GL_RGBA, GL10.GL_UNSIGNED_BYTE, pixels);
final int numBytes = w * h * 4;
byte[] lines = new byte[numBytes];
pixels.clear();
pixels.get(lines);
String stamp = new SimpleDateFormat("yyyy-MM-dd_HH-mm-ss").format(Calendar.getInstance().getTime());
PixmapIO.writePNG(Gdx.files.local("Screenshot-" + stamp + ".png"), pixmap);
pixmap.dispose();
}
TemplateMain.java 文件源码
java
阅读 27
收藏 0
点赞 0
评论 0
项目:libgdx-lwp-template
作者:
评论列表
文章目录