简体   繁体   中英

Unable to Capture Screen shot In AndEngine

HI here is my Code.

public static void TakeScreenShot(String FileName)
{ 
         Log.d("Screen"," Path "+ FileName);

        scr.capture(CAMERA_WIDTH, CAMERA_HEIGHT, FileName, new IScreenCaptureCallback() {
            @Override
            public void onScreenCaptured(final String pFilePath) { 
                Log.d("Screen","Yes "+ pFilePath);

            }

            @Override
            public void onScreenCaptureFailed(final String pFilePath, final Exception pException) { 
                Log.d("Screen","NO "+ pFilePath+"    "+pException);

            }
        });
    }

The first log is working fine. But then no other log is working. Its not completing nor its failing. Can any one give me a solution?

The path where I am saving is "/mnt/sdcard/cmtdd.png"

The follwing might work..I have added scene.attachChild(screenCapture); to your code. It should used at the correct place.

public static void TakeScreenShot(String FileName)
{ 
         Log.d("Screen"," Path "+ FileName);

        scene.attachChild(screenCapture); // Attaching screen capture after all rendered.

        scr.capture(CAMERA_WIDTH, CAMERA_HEIGHT, FileName, new IScreenCaptureCallback() {
            @Override
            public void onScreenCaptured(final String pFilePath) { 
                Log.d("Screen","Yes "+ pFilePath);

            }

            @Override
            public void onScreenCaptureFailed(final String pFilePath, final Exception pException) { 
                Log.d("Screen","NO "+ pFilePath+"    "+pException);

            }
        });
    }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM