dynamic scaling ratio - when to use alternate image(s)

Here is my code in windows:

main.lua
local myimage = display.newImageRect( "test.png", 480, 800);

myimage:setReferencePoint(display.CenterReferencePoint);
myimage.x = _W/2; myimage.y = _H/2;
_________________________________________
-- config.lua

application =
{
content =
{
width = 480,
height = 800,
scale = "zoomEven", imageSuffix =
{
["@2"] =.94,
},
},
}
________________________________________
Using the view options in the emulator
droid screen = 480 x 854
nexus one = 480 x 800
mytouch = 320 480
galaxy = 600 1024

I cannot understand how corona detremines when to use the "@2" image based upon the above values. There are no examples I have found that explain this logic.

corona uses the largest image that is SMALLER than the screen its trying to display on - if you set the ratios the same as what your images are. So for example:

Image.png - main image at 480x320
Image-medium - 800x480
Image-large.png -1024 x 768

For a mytouch or 480x320 screen it will use Image.png
for nexus it will use image-medium.png
for droid it will scale down image-large.png
for galaxy is will scale down Image-large.png

If you want different behaviour eg droid to upscale the medium image you can fix the ratio so that say anything below a multiple of 2 can use the medium one. You would then set its ratio to 2

The idea is that the ratio u set is what it matches against regardless of the image size.

I guess what remains unclear to me is what ratio is being compared to what other ratio?

For example,

in config.lua we have the folling scale (ratio)

application =
{
content =
{
width = 480,
height = 800,
scale = "zoomEven",

imageSuffix =
{
["@2"] = 1.2,
},
},
}

In the emulator view options (emulator) we have the following target screen ratios.

droid screen = 480 x 854 = 1.78
nexus one = 480 x 800 = 1.67
mytouch = 320 480 = 1.50
galaxy = 600 1024 = 1.71

and we have the following image ratios

Image.png -main image at 480x320 = 1.50
Image-medium- 800x480 = 1.67
Image-large.png-1024 x 768 = 1.33

Which ratios are corona comparing and what is the test?

I appreciate your help on this.

"The actual image chosen will depend on the current content scale determined by Corona, which is the ratio between the current screen and the base content dimensions defined in config.lua. "

http://developer.anscamobile.com/content/display-objects#Images_with_Dynamic_Resolution

"Corona will then choose the closest matching suffix, defined as the one whose scale is equal to or smaller than the current content scale factor, and then map that image file into the given [rect]".

http://developer.anscamobile.com/content/configuring-projects#Dynamic_Image_Resolution

Hth,

Tim

Thx's Tim. This really helped.

The articles do a good job, but your reply filled in the blanks.

I took some sample ratios based upon your explanation and ran them through.

Everything was consistent.

I do notice that keeeping all ratios the same, when I change the content scale from zoomEven to zoomStretch, corona does not choose the same image as before. I don't know if this is intentional, or a bug.

views:1878 update:2011/10/9 9:57:41
corona forums © 2003-2011