display.save() and isFullResolution param issue

Hello! 

I noticed that, when i change isFullResolution param in method display.save() NOTHING happens…

As far as i know, when flag is set on true, saved image should be exactly the same as displayed in Corona. But it doesn’t. 

Looks like Corona ignores that flag and always saves image in device resolution.  

How to save image with exactly the same dimensions as displayed in Corona? I need this to generate dynamically masks.
 

Here is my sample main.lua code, where i make 4 rects, saving them with different isFullResolution param then i create image of saved rect via display.newImage(), again with diffrent values on isFullResolution param. 

I attach graphics output of that code.

timer.performWithDelay( 1000, function() local green = display.newRect( 50, 50, 25, 25) green:setFillColor( 0,1,0 ) display.save( green, {filename = "green.png", baseDir = system.TemporaryDirectory, isFullResolution = false} ) display.newImage( "green.png", system.TemporaryDirectory, 100, 50, false ) local red = display.newRect( 50, 100, 25, 25) red:setFillColor( 1,0,0 ) display.save( red, {filename = "red.png", baseDir = system.TemporaryDirectory, isFullResolution = false} ) display.newImage( "red.png", system.TemporaryDirectory, 100, 100, true ) local blue = display.newRect( 50, 150, 25, 25) blue:setFillColor( 0,0,1 ) display.save( blue, {filename = "blue.png", baseDir = system.TemporaryDirectory, isFullResolution = true} ) display.newImage( "blue.png", system.TemporaryDirectory, 100, 150, false ) local yellow = display.newRect( 50, 200, 25, 25) yellow:setFillColor( 1,1,0 ) display.save( yellow, {filename = "yellow.png", baseDir = system.TemporaryDirectory, isFullResolution = true} ) display.newImage( "yellow.png", system.TemporaryDirectory, 100, 200, true ) end )

Simulator is set on android device(hdpi), the same result i got on xperia m2. 

and here is mine build.settings and config.lua
 

settings = { orientation = { default = "landscapeRight", supported = { "landscapeLeft", "landscapeRight" }, }, }

application = { content = { scale = "adaptive", fps = 60, imageSuffix = { ["@2x"] = 1.5, ["@3x"] = 2.6, } }, }

Thanks for your advice.

This problem is similar to: https://forums.coronalabs.com/topic/59155-corona-bug-displaycapture-does-not-work-on-images-larger-than-screen-size/

I’ve sent bug report with that problem. And i think that something is wrong with core function of saving pictures, because you got similar issue.
 

Hi @p.kanarek,

I apologize for the confusion.

Part of the problem is that we improperly named the “isFullResolution” flag… this, in fact, is something that goes far back in time. In fact, that flag does not do anything in regards to the “resolution” of the saved image/object. Merely, it allows you to save content which exists outside of the screen bounds.

The second issue is that we did not document it properly. I have updated this point in recent documentation:

https://docs.coronalabs.com/daily/api/library/display/save.html

In your case, all of your images are on screen, so setting that flag will do nothing different in all four cases.

This being said, at some point we will probably need to change the flag name to something that describes its purpose accurately. However, we can’t just blindly or quickly make that change as it would affect all users who have used it previously. For the time being, all I can suggest is that you read the updated documentation (link above) and use that as a basis for what the flag actually does, not what its name leads you to believe it does (again, we accept responsibility for naming it poorly and will do our best to correct this in the future).

Best regards,

Brent

Brent, my image is 5-10 times longer than what is visible on screen - it is still a BUG as I stated before - there is NO WAY to capture or save any object or group that is larger than the current screen resolution - please FIX IT.

Hi @troylyndon,

With all due respect, how can it be a bug if we’ve just tested it – and provided you with working code in the post where Rob responded – and it works as expected?

Brent

Hi Brent, please join Joshua and Rob with me regarding this issue on an almost identical post: https://forums.coronalabs.com/topic/59155-corona-bug-displaycapture-does-not-work-on-images-larger-than-screen-size/

Hi @Brent Sorrentino,

I get it now why all images are the same. 

I know that there is no easy way to save picture with the same dimensions as displayed in Corona, maybe you got some tips how to do it? 

My task to do : Generate dynamically masks

My problem : I can’t calculate dimensions in Corona, to save picture with dimensions divisible by 4 on iphone 6+ with adaptive scaling.

I know that corona calculate dimensions that way, please confirm:

local AR = display.pixelWidth / display.actualContentWidth local savedPngWidth = math.round( math.floor( coronaWidth ) \* AR )

Tricky part is here: i have to guess coronaWidth ( it is always rounded down by corona when comes to saving ) then it is multiplied by constant float AR, and that result is rounded normally - voila! i got dimensions of saved image. ( Can anybody confirm that formula? )

So i have absolutely no idea how to resolve equation to get savedPngWidth % 4 == 0 

Maybe i went to deep into rabbit hole and solution is much easier than i presented here.

It would be great if flag isFullResolution worked as was described earlier in documentation!

Thanks for your advice!

This problem is similar to: https://forums.coronalabs.com/topic/59155-corona-bug-displaycapture-does-not-work-on-images-larger-than-screen-size/

I’ve sent bug report with that problem. And i think that something is wrong with core function of saving pictures, because you got similar issue.
 

Hi @p.kanarek,

I apologize for the confusion.

Part of the problem is that we improperly named the “isFullResolution” flag… this, in fact, is something that goes far back in time. In fact, that flag does not do anything in regards to the “resolution” of the saved image/object. Merely, it allows you to save content which exists outside of the screen bounds.

The second issue is that we did not document it properly. I have updated this point in recent documentation:

https://docs.coronalabs.com/daily/api/library/display/save.html

In your case, all of your images are on screen, so setting that flag will do nothing different in all four cases.

This being said, at some point we will probably need to change the flag name to something that describes its purpose accurately. However, we can’t just blindly or quickly make that change as it would affect all users who have used it previously. For the time being, all I can suggest is that you read the updated documentation (link above) and use that as a basis for what the flag actually does, not what its name leads you to believe it does (again, we accept responsibility for naming it poorly and will do our best to correct this in the future).

Best regards,

Brent

Brent, my image is 5-10 times longer than what is visible on screen - it is still a BUG as I stated before - there is NO WAY to capture or save any object or group that is larger than the current screen resolution - please FIX IT.

Hi @troylyndon,

With all due respect, how can it be a bug if we’ve just tested it – and provided you with working code in the post where Rob responded – and it works as expected?

Brent

Hi Brent, please join Joshua and Rob with me regarding this issue on an almost identical post: https://forums.coronalabs.com/topic/59155-corona-bug-displaycapture-does-not-work-on-images-larger-than-screen-size/

Hi @Brent Sorrentino,

I get it now why all images are the same. 

I know that there is no easy way to save picture with the same dimensions as displayed in Corona, maybe you got some tips how to do it? 

My task to do : Generate dynamically masks

My problem : I can’t calculate dimensions in Corona, to save picture with dimensions divisible by 4 on iphone 6+ with adaptive scaling.

I know that corona calculate dimensions that way, please confirm:

local AR = display.pixelWidth / display.actualContentWidth local savedPngWidth = math.round( math.floor( coronaWidth ) \* AR )

Tricky part is here: i have to guess coronaWidth ( it is always rounded down by corona when comes to saving ) then it is multiplied by constant float AR, and that result is rounded normally - voila! i got dimensions of saved image. ( Can anybody confirm that formula? )

So i have absolutely no idea how to resolve equation to get savedPngWidth % 4 == 0 

Maybe i went to deep into rabbit hole and solution is much easier than i presented here.

It would be great if flag isFullResolution worked as was described earlier in documentation!

Thanks for your advice!