display.save() - pixel dimensions seem off, slightly

When I use display.save() to save a rectangle that is 480x320, the resulting png file has pixel dimensions of 405x270. It’s dimensions are off by a factor 1.185185… which turns out to be 32/27.

Is there something magic about that number? Can I count on the dimensions always being off by that factor? If so, maybe I’ll just do an object.width = object.width * 1.185 just before the save

  1. It is saving screen pixels, not content pixels.

  2. What resolution did you select in your config.lua file?

  3. Run at that resolution (in a simulated device) and make the capture.

That should fix the issue.

>> What resolution did you select in your config.lua file?

1280x1920

>> Run at that resolution (in a simulated device) and make the capture.

Not sure what you mean by that. That is, I don’t see that I can change the resolution of the Corona simulator in the File | Preferences command. The Help | About command says that the rev number is 2017.3184 (2017.12.8) and it pops a picture of a phone just labeled “SAMSUNG.”

Interestingly, if the resolution of the simulator were 1080x1620, then Corona would have to scale all my 1280x1920 images by that mystery number, 1.185… So, it sounds like that’s the problem but I don’t see that I can change the resolution of the simulator.

However, based on that scaling idea, I can use display.contentScaleX and display.contentScaleY to fix the problem. So now I just change the width and height before the save…

        background.width = 480 \* display.contentScaleX         background.height = 320 \* display.contentScaleY

…and things are good in the real device, and in the simulator.

Thanks!

Dan

‘View As’ (in one of the menus on the simulator)  changes the device you are simulating.

Simulate a device with the same resolution as you selected in config.lua

You’re going to run into this issue if the scaling is not 1:1.

You can get 1:1 scaling for some devices that don’t match your config.lua resolution, but the easiest way to ensure a 1:1 scaling and thus pixels match content area resolution is to simply simulate a device that is a direct match for your config.lua resolution.

In future posts, please let us know if you’re running on Windows or OS X.  The menus are a little different. 

Also, knowing this sometimes makes it easier to answer the question.

Can’t believe I missed the pull over menu on the “View as” command. I’m having lots of fun simulating the different devices now. :slight_smile:

Thanks again.

Isn’t Corona Awesome!  :slight_smile:

Warning… don’t play with ‘Custom Device’ or you’ll never stop. 

Really though, if you ever decide to make in-simulator tools, the ‘custom device’ option is a awesome helper for getting just the right size window.

I agree. Having all the devices _is_ great, but it did give me some more work to do.

I was happy with the way my app looked on the majority of the simulator devices. The graphics part of the app looked fine on all of them. However, I have some “settings screens” with radio buttons next to text and the text was way too small on quite a few of the devices. Custom device was one of the bad ones. The radio button text looked bad at 1280x1920 on custom device, but was fine on some other devices that were pretty close (like 1200x1920). 

I’ve been using system font and native.system font and since everything seemed good on the simulator and the device, I haven’t done a lot of reading about text sizes yet. I’m thinking that maybe a custom device doesn’t eve have a “native” system font. 

Anyway, now it looks like I’ll have to start reading about how font point size relates to screen pixels in the world of Corona. But it’s much better to be able to do it now than after the app is released. 

  1. It is saving screen pixels, not content pixels.

  2. What resolution did you select in your config.lua file?

  3. Run at that resolution (in a simulated device) and make the capture.

That should fix the issue.

>> What resolution did you select in your config.lua file?

1280x1920

>> Run at that resolution (in a simulated device) and make the capture.

Not sure what you mean by that. That is, I don’t see that I can change the resolution of the Corona simulator in the File | Preferences command. The Help | About command says that the rev number is 2017.3184 (2017.12.8) and it pops a picture of a phone just labeled “SAMSUNG.”

Interestingly, if the resolution of the simulator were 1080x1620, then Corona would have to scale all my 1280x1920 images by that mystery number, 1.185… So, it sounds like that’s the problem but I don’t see that I can change the resolution of the simulator.

However, based on that scaling idea, I can use display.contentScaleX and display.contentScaleY to fix the problem. So now I just change the width and height before the save…

        background.width = 480 \* display.contentScaleX         background.height = 320 \* display.contentScaleY

…and things are good in the real device, and in the simulator.

Thanks!

Dan

‘View As’ (in one of the menus on the simulator)  changes the device you are simulating.

Simulate a device with the same resolution as you selected in config.lua

You’re going to run into this issue if the scaling is not 1:1.

You can get 1:1 scaling for some devices that don’t match your config.lua resolution, but the easiest way to ensure a 1:1 scaling and thus pixels match content area resolution is to simply simulate a device that is a direct match for your config.lua resolution.

In future posts, please let us know if you’re running on Windows or OS X.  The menus are a little different. 

Also, knowing this sometimes makes it easier to answer the question.

Can’t believe I missed the pull over menu on the “View as” command. I’m having lots of fun simulating the different devices now. :slight_smile:

Thanks again.

Isn’t Corona Awesome!  :slight_smile:

Warning… don’t play with ‘Custom Device’ or you’ll never stop. 

Really though, if you ever decide to make in-simulator tools, the ‘custom device’ option is a awesome helper for getting just the right size window.

I agree. Having all the devices _is_ great, but it did give me some more work to do.

I was happy with the way my app looked on the majority of the simulator devices. The graphics part of the app looked fine on all of them. However, I have some “settings screens” with radio buttons next to text and the text was way too small on quite a few of the devices. Custom device was one of the bad ones. The radio button text looked bad at 1280x1920 on custom device, but was fine on some other devices that were pretty close (like 1200x1920). 

I’ve been using system font and native.system font and since everything seemed good on the simulator and the device, I haven’t done a lot of reading about text sizes yet. I’m thinking that maybe a custom device doesn’t eve have a “native” system font. 

Anyway, now it looks like I’ll have to start reading about how font point size relates to screen pixels in the world of Corona. But it’s much better to be able to do it now than after the app is released.