display save and capturescreen

My app has 2 buttons to save and share an image. One calls display.captureScreen(true) to store a user’s creation in their photo library. A second button calls display.save(stage,“somefile.png”,system.TemporaryDirectory) - where stage = display.getCurrentStage().

The captured image is 720x1184px but the one taken from display.save() is only 720x1080.

This is my config.lua file:

application = {  
 content = {  
 width = 320,  
 height = 480,  
 scale = "letterbox",  
 xAlign = "center",  
 yAlign = "center",  
  
 imageSuffix = {  
 ["@2x"] = 2  
 },  
 },  
}  

All of my content is positioned within this 320x480 area, apart from an image watermark which is set to display at the bottom of the screen. This image gets cut in half as the screenshot is cropped shorter compared with display.captureScreen(true).

Can anyone help explain why, and also how I can prevent this cropped image.

Thanks [import]uid: 140429 topic_id: 28332 reply_id: 328332[/import]

The [lua]display.captureScreen()[/lua] function captures the “entire” screen, including the letterbox area. The [lua]display.save(display.currentStage)[/lua] only captures the stage; the part between the letterbox bars. That is why the screen capture is bigger than your stage capture.

Now, the resulting capture image is bigger than your stage’s content bounds because it is captured in pixels. In fact, the capture image in pixels will be even bigger on a higher resolution display, such as a retina display. This is by design. The capture image will be in pixels and it will be a different size on different resolution displays.

There is a simple solution to this problem. Use the display.newImageRect() function and give it the width and height that you want Corona to size the image to in “content coordinates”. For example…
[lua]display.save(display.currentStage, “MyScreenshot.jpg”, system.DocumentsDirectory)
display.newImageRect(“MyScreenshot.jpg”, system.DocumentsDirectory, display.currentStage.width, display.currentStage.height)[/lua]
[import]uid: 32256 topic_id: 28332 reply_id: 114508[/import]