12.3、Libgdx的图像之截屏
来源:互联网 发布:淘宝打电话怎么转人工 编辑:程序博客网 时间:2024/04/29 02:34
(官网:www.libgdx.cn)
接下来的示例说明怎样进行截屏并且保存为PNG格式。
public class ScreenshotFactory {private static int counter = 1;public static void saveScreenshot(){ try{ FileHandle fh; do{ fh = new FileHandle("screenshot" + counter++ + ".png"); }while (fh.exists()); Pixmap pixmap = getScreenshot(0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight(), false); PixmapIO.writePNG(fh, pixmap); pixmap.dispose(); }catch (Exception e){ }}private static Pixmap getScreenshot(int x, int y, int w, int h, boolean yDown){ final Pixmap pixmap = ScreenUtils.getFrameBufferPixmap(x, y, w, h); if (yDown) { ByteBuffer pixels = pixmap.getPixels(); int numBytes = w * h * 4; byte[] lines = new byte[numBytes]; int numBytesPerLine = w * 4; for (int i = 0; i < h; i++) { pixels.position((h - i - 1) * numBytesPerLine); pixels.get(lines, i * numBytesPerLine, numBytesPerLine); } pixels.clear(); pixels.put(lines); } return pixmap;}}
(www.libgdx.cn版权所有,如需转载,注明出处)
0 0
- 12.3、Libgdx的图像之截屏
- 12.2、Libgdx的图像之清屏
- 12、Libgdx的图像之全屏和垂直同步
- 12.1、Libgdx的图像之持续性和非持续性渲染
- libgdx 绘制图像
- Libgdx 桌面项目——图像的绘制1
- Libgdx Android项目——图像的绘制1
- 11.1、Libgdx的音频之音效
- 11.2、Libgdx的音频之音乐
- Libgdx 之 饱和度与色相的渲染
- libgdx之粒子特效
- libgdx之RevoluteJointDef关节
- libgdx之PrismaticJoint关节
- libgdx之FrictionJoint关节
- libgdx之WeldJointDef关节
- libgdx 之 tiled地图
- 9.6、Libgdx之罗盘
- 9.7、Libgdx之振动器
- IOS- 对GCD的理解
- PostgreSQL调出每一次sql执行所花的时间
- Redis中7种集合类型应用场景
- 解决eclipse导入程序后提示Target runtime Apache Tomcat v6.0 is not defined.
- 8 Support vector machine(3)
- 12.3、Libgdx的图像之截屏
- 试试需不需要验证
- 解决Android Activity切换时出现白屏问题
- Tomcat服务器配置
- Essential Studio for WinRT网格控件测评
- Android开发资料收集
- Java Base64、AES、SHA1、MD5加密算法
- 生活随笔:2014 这一年
- 解决线程的内存泄露的办法