我以 1000x1000 的分辨率初始化引擎,并希望将整个场景保存在文件中。如果我使用 ScreenCapture 类截屏,则图片的最大分辨率为 800x480(因为我的设备(htc 渴望)是 800x480,而且屏幕上不可能有更多像素)。但是场景更大,也许有一种方法可以遍历场景中的所有像素并保存 1000x1000 图片?
我尝试使用以下代码从 RenderTexture 保存图片:
@Override
public Engine onCreateEngine(EngineOptions pEngineOptions)
{
return new Engine(pEngineOptions) {
private boolean mRenderTextureInitialized;
int r[];
private RenderTexture mRenderTextures;
@Override
public void onDrawFrame(final GLState pGLState) throws InterruptedException {
final boolean firstFrame = !this.mRenderTextureInitialized;
if(firstFrame) {
this.initRenderTextures(pGLState);
this.mRenderTextureInitialized = true;
}
this.mRenderTextures.begin(pGLState);
super.onDrawFrame(pGLState);
this.mRenderTextures.end(pGLState);
if (needToSave)
{
needToSave = false;
final String location = SAVED_PATH + "/Screen_" + System.currentTimeMillis() + ".png";
FSHelper.saveBitmapToFile(mRenderTextures.getBitmap(pGLState), location);
}
}
private void initRenderTextures(final GLState pGLState) {
final int surfaceWidth = this.mCamera.getSurfaceWidth();
final int surfaceHeight = this.mCamera.getSurfaceHeight();
this.mRenderTextures = new RenderTexture(EnchantActivity.this.getTextureManager(), surfaceWidth, surfaceHeight);
this.mRenderTextures.init(pGLState);
}
};
}