Trying to save scaled down image, works on simulator not on android device

I have some images I’m trying to save after scaling them down using the following code:

local image = display.newImage("someimage.png", display.contentCenterX, display.contentCenterY) image:scale(.3,.3) display.save(image, { filename=fileName, baseDir=storeLocation })

The code works just fine on the simulator, but on my android device the images seem to still be full sized. It writes the images just fine it just doesn’t scale them. Am I missing something here?

Okay I found out when you do image:scale(.3,.3) it’s somehow based off of the actual device width / height and not what is set in the config.lua?

When I have my simulator set to 1280x720 it works fine, if I change my simulator to 2560x1440 my scaled images are much larger even though I have my config.lua set to a static 1280x720.

Is there anyway to fix this? Also isFullResolution doesn’t change anything. 

Here is a picture of what I mean

ZJiPDBD.png

Are you using dynamic image selection (“display.newImageRect()”) or non-dynamic (“display.newImage()”)?

Oh sorry, I see your original code. What happens when you don’t scale the image to .3? How does that look?

No problem…when I don’t scale it, just load in the image and save it the image goes from 128x128 to 128x128 when the device is 720x1280 and when the device is 1440x2560 they go to 256x256. 

So it seems like the image is being scaled based on the device resolution. So I should see what the difference between the actual device deimensions and what I have set in the config and save it as such maybe?

What does your config.lua look like?

It’s pretty much as plain as it gets
 

application = { content = { width = 720, height = 1280, fps = 60, }, showRuntimeErrors = true }

I figured it out, it’s confusing though and I’m not sure why it works the way it should. Every other API that I’ve used in corona is based on the contentWidth/Height I’m not sure why this is based on the actual device width/height. Anyways what I did was I found the actual device dimensions and divided the contentWidth/Height by that. I then took that new number and multiplied that by the .3 in the scale. 

What makes this even more confusing is I’m using landscape and display.pixelHeight is really the width of the device. 

local widthRatio = display.contentWidth/display.pixelHeight local heightRatio = display.contentHeight/display.pixelWidth local image = display.newImage("someimage.png", display.contentCenterX, display.contentCenterY) image:scale(.3\*widthRatio, .3\*heightRatio) display.save(image, { filename=fileName, baseDir=storeLocation })

Hi @dmglakewood,

An engineer commented to me on this topic. Basically, the “display.save()” and “display.capture()” APIs will capture the object on screen in pixels. That means an object you capture will have a different pixel width/height on different resolution screens. This actually makes sense if you consider it from the point of view of capturing the entire screen, specifically, that it makes perfect sense that the capture image will be the actual pixel width/height of the screen and not the Corona content width/height which is likely to be much smaller.

If you want to show the “display.save()” image at the same resolution it was before, then you need to load it via “display.newImageRect()” and specify the content width/height of the original object that was captured. This will force Corona to scale the captured image file to the appropriate Corona content coordinates.

Brent

Okay I found out when you do image:scale(.3,.3) it’s somehow based off of the actual device width / height and not what is set in the config.lua?

When I have my simulator set to 1280x720 it works fine, if I change my simulator to 2560x1440 my scaled images are much larger even though I have my config.lua set to a static 1280x720.

Is there anyway to fix this? Also isFullResolution doesn’t change anything. 

Here is a picture of what I mean

ZJiPDBD.png

Are you using dynamic image selection (“display.newImageRect()”) or non-dynamic (“display.newImage()”)?

Oh sorry, I see your original code. What happens when you don’t scale the image to .3? How does that look?

No problem…when I don’t scale it, just load in the image and save it the image goes from 128x128 to 128x128 when the device is 720x1280 and when the device is 1440x2560 they go to 256x256. 

So it seems like the image is being scaled based on the device resolution. So I should see what the difference between the actual device deimensions and what I have set in the config and save it as such maybe?

What does your config.lua look like?

It’s pretty much as plain as it gets
 

application = { content = { width = 720, height = 1280, fps = 60, }, showRuntimeErrors = true }

I figured it out, it’s confusing though and I’m not sure why it works the way it should. Every other API that I’ve used in corona is based on the contentWidth/Height I’m not sure why this is based on the actual device width/height. Anyways what I did was I found the actual device dimensions and divided the contentWidth/Height by that. I then took that new number and multiplied that by the .3 in the scale. 

What makes this even more confusing is I’m using landscape and display.pixelHeight is really the width of the device. 

local widthRatio = display.contentWidth/display.pixelHeight local heightRatio = display.contentHeight/display.pixelWidth local image = display.newImage("someimage.png", display.contentCenterX, display.contentCenterY) image:scale(.3\*widthRatio, .3\*heightRatio) display.save(image, { filename=fileName, baseDir=storeLocation })

Hi @dmglakewood,

An engineer commented to me on this topic. Basically, the “display.save()” and “display.capture()” APIs will capture the object on screen in pixels. That means an object you capture will have a different pixel width/height on different resolution screens. This actually makes sense if you consider it from the point of view of capturing the entire screen, specifically, that it makes perfect sense that the capture image will be the actual pixel width/height of the screen and not the Corona content width/height which is likely to be much smaller.

If you want to show the “display.save()” image at the same resolution it was before, then you need to load it via “display.newImageRect()” and specify the content width/height of the original object that was captured. This will force Corona to scale the captured image file to the appropriate Corona content coordinates.

Brent