Corona sdk display.captureScreen()稍后保存

时间:2014-04-11 20:34:19

标签: lua corona

我正在使用display.capureScreen()来拍摄用户最终得分。在那之后,会弹出一个窗口,显示他们的硬币,分数,高分以及刚拍摄的照片。当我这样做时:

 screenCap = display.captureScreen(true)

它将图片保存到照片库,因为它设置为true。我的问题是我怎么能不自动保存,但只有用户想要使用“保存图片”按钮?

1 个答案:

答案 0 :(得分:1)

您可以使用display.save(object, filename)保存captureScreen()返回的显示对象:

local image = display.captureScreen()
image:toBack() -- hide it 

... do stuff...

display.save( image, { filename="image.png", isFullResolution=true } )
image:removeSelf() -- no longer need it
image = nil

保存图像时,图像必须处于显示层次结构中。

如果您想稍后保存到相册,display.save没有为您提供该选项,则必须使用display.capturedisplay.captureBounds。示例:

local image = display.captureScreen()
image:toBack() -- hide it 

... do stuff...

local capture = display.capture( image, { saveToPhotoLibrary=true, isFullResolution=true } )
-- cleanup
capture:removeSelf()
capture = nil
image:removeSelf()
image = nil