0

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);

                }

        };
}
Zoe
  • 27,060
  • 21
  • 118
  • 148
dilix
  • 3,761
  • 3
  • 31
  • 55

1 Answers1

1

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

Nicolas Gramlich
  • 2,790
  • 19
  • 19
  • I've tried this sample, but cant understand how to save the whole scene by button press. There is a getBitmap(GLState), i've tried to save GLState and write bitmap from RenderTexture into the file. – dilix Apr 13 '12 at 14:00