AndEngine引擎提供了一个截图的类ScreenCapture
这个类的用法:ScreenCapture cap= new ScreenCapture();无参构造函数
然后添加到场景中,如果不添加到场景中就截不到任何数据
她有两个主要方法
capture(final int pCaptureWidth, final int pCaptureHeight, final String pFilePath, final IScreenCaptureCallback pScreenCaptureCallback)
和 capture(final int pCaptureX, final int pCaptureY, final int pCaptureWidth, final int pCaptureHeight, final String pFilePath, final IScreenCaptureCallback pScreencaptureCallback)
pScreenCaptureCallback回调接口是当截图成功或失败后调用的
用的是out = new FileOutputStream(pFilePath); pBitmap.compress(CompressFormat.PNG, 100, out);
还有就是AndEngine的***Activity有个方法runrunOnUiThread(runnable)能够在非UI线程中做一些UI操作,例如非UI线程不可以使用Toast,
但是runrunOnUiThread方法里面就可以使用
例如:
CaptureSampleActivity.this.runOnUiThread(new Runnable() { @Override public void run() { Toast.makeText(getApplication(), "截图成功", Toast.LENGTH_LONG).show(); } });
转载于:https://www.cnblogs.com/xushihai/p/4206631.html
相关资源:各显卡算力对照表!