Wednesday, 24 July 2013

How to capture whole screen in Corona SDK

You can use the following lines of code to capture the device screen in Corona SDK. This will save the screenshot as: Picture 1.png, Picture 2.png, etc in the sandbox, and will show it on the screen with half size(if you do not need this, you can remove it by calling captured_image:removeSelf() and captured_image=nil). It can save upto 10000 files.

Syntax:

    local function captureDeviceScreen()
       local captured_image = display.captureScreen( true )
       captured_image:scale(.5,.5)
       local alert = native.showAlert( "Success", "Captured Image is Saved to Library", { "OK" } )
    end
    Runtime:addEventListener("tap",captureDeviceScreen)


And if you want to save the image with desired name, then you can refer the following post:

How to mail a screen captured image using corona SDK



No comments:

Post a Comment