Pergunta

I initialize engine with resolution 1000x1000 and want to save the whole scene in file. If i take screenshots with ScreenCapture class the maximum resolution of the picture is 800x480 (because my device (htc desire) is 800x480 and it's impossible to have more pixels from screen). But scene is bigger, maybe there is a way to iterate through all of the pixels on scene and save 1000x1000 picture ?

I've tried the following code to save picture from 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);

                }

        };
}
Foi útil?

Solução

You cannot take a screenshot of what is not being rendered!

But when using the GLES2 branch, you can render your Scene into a RenderTexture, which can be of arbitrary size. This example should help: https://github.com/nicolasgramlich/AndEngineExamples/blob/GLES2/src/org/andengine/examples/MotionStreakExample.java

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top