Screen capture on Corona sdk

I tried many ways to capture the screen with corona sdk, I read   http://docs.coronalabs.com/api/library/display/captureScreen.html

Corona: how to capture the screen in the crown?

However, when I run the program, Corona sdk hangs and they have to close it. I use the Corona SDK for Windows, and sometimes I get the "Runtime R6025 PURE virtual function call", I tried many code examples that worked with others, here is my code

_W = display.viewableContentWidth
_H = display.viewableContentHeight
local background = display.newRect(0, 0, 320, 480);
background:setFillColor(255,255,255);
local foo = display.newImageRect("images/foo.png",100,100);
foo.anchorX=0.5
foo.anchorY=0.5
foo.x = _W * 0.5;
foo.y = _H * 0.5;
local screenShot = display.captureScreen(true);
foo:removeSelf();
background:removeSelf();
screenShot.xScale = 0.5;
screenShot.yScale = 0.5;
screenShot.rotation = 45;

this is my build.settings file

androidPermissions =    
{
    "android.permission.VIBRATE",
    "android.permission.WRITE_EXTERNAL_STORAGE"
},
+4
source share
1 answer

You can also try using display.saveto save the screen to a file.

Mark the Lerg code for this

's'

if app.isSimulator then
    Runtime:addEventListener('key', function (event)
        if event.keyName == 's' and event.phase == 'down' then
            local scene = storyboard.getScene(storyboard.getCurrentSceneName())
            if scene and scene.view then
                display.save(scene.view, display.pixelWidth .. 'x' .. display.pixelHeight .. '_' .. math.floor(system.getTimer()) .. '.png')
                return true
            end
         end
    end)
end
0

Source: https://habr.com/ru/post/1529412/


All Articles