newImageRect and TopLeftReferencePoint

There is a math rule to use on newImageRect for image_size_width and image_size_height depend on config.lua defined sizes? If I use exact dimensions of file image - it remain black margins left/right. I need to use on file image a different size that from scalling Corona fill the screen
Now I have
* file image on 1140x720 pixel ( base - @1x ) and 2280x1140 as @2x
* load Images with

background = display.newImageRect(group,“background.jpg”,1280,720)

* and config.lua :

content =
{
width = 720,
height = 1140,
scale = “letterBox”,
xAlign = “center”,
yAlign = “center”,
imageSuffix =
{
["@2x"] = 1.6,
["@3x"] = 2.4 ,
["@4x"] = 3.2,
},
},

It seems to work ok and display fine background on Android.
If i use 1280x800 image file - through scalling - I will see black bars.

The question is : when load with newImageRect it’s ok to use main target resolution ? ( for main targeted display )

Thank you
Radu [import]uid: 157691 topic_id: 35212 reply_id: 141157[/import]

I want to make a self-correction: to display backgrounds I use
background = display.newImageRect(group,“BGS/bg_tren.jpg”,1280,720)
background.x, background.y = display.contentWidth/2, display.contentHeight/2
All other I written are correct.
I used 1280x720 after effective tests, not based on logical - math deduction - that is why ask if there is a formula (I saw that there are several conventions, but it seems to be obtained through tests too)

Because I have image parts/elements for objects in the scene built on initial 1280x800 I calculated a scale factor x, y as display.contentWidth/1280, display.contentHeight/1280 on createScene and I multiplied elements ( actors) coordinates with scale factor to re-arrange them. I don’t know if it’s the best method - but I could reassembly the scenes ok - based on screen and background resolution.
[import]uid: 157691 topic_id: 35212 reply_id: 141230[/import]

Hi All,

Rob, Develephant - you was right - my misunderstanding came from the fact that I said no scalling, but in fact when i put"letterbox" in config.lua I scaled images.
Thanks for previous explanations

I have read several times articles about scaling dynamic, I understand better now and I will use them, but still have two additional questions

* If the main target are tablet devices with 1280x800 px - I have to use 1140 x720 basis, but I also want the application work fine with dynamic resolution to 800 x 480 and 2560 x 1600 for example.
When upload images is it correct to use newImageRect (“image” , 1280,800)?

* I am not yet very clear how to do if I have partial images - not all background.
If I have images created with different sizes, but not as full screen, how Corona will decide which resolution to choose? It is possible to fit in tablet screen resolution more element image resolutions.

Thank you very much,
Radu [import]uid: 157691 topic_id: 35212 reply_id: 141027[/import]

This is where your config.lua comes into play. Most people will base their game scale based on the small image, like 800x400 and you would name your assets like:

background.jpg
avatar.png
zombie.png
playbutton.png

etc. Your background.jpg would be 800x400, but your playbutton.png might be 64x48. Then you would need to provide larger assets by putting a suffix on the filename. The normal “standard” is to use @2x and @4x, so you would provide:

background.jpg 800x480
background@2x.jpg 1280x800
background@4x.jpg 2560x1600

In your config.lua you would have a block of code that looks like:

 width = 480,  
 height = 800,  
 scale = "letterBox",  
 imageSuffix =   
 {  
 ["@2x"] = 1.5,  
 ["@4x"] = 3.0,  
 },  

Any device that’s greater than 1.5x of your base, in this case 480 * 1.5 = 720. Your 1280x800 device is greater than 1.5x, but less than 3x, so Corona goes and grabs the @2x assets and scales them to the size of your device. If you’re on a big device with greater than 1440px wide, then it will grab your @4x assets.

But you want to scale your images to the middle sized devices, you have to approach your config.lua differently and do something like:

 width = 800,  
 height = 1280,  
 scale = "letterBox",  
 imageSuffix =   
 {  
 ["@0\_5x"] = 0.1,  
 ["@2x"] = 1.8,  
 },  

You can make up your own suffix and could do @small and @large if that made better sense to you. In the example above, if the device is smaller than me use images with the @0_5x images. If it’s 1440 or larger (in this case, the math worked out to 1.8x) to load the larger assets.

[import]uid: 199310 topic_id: 35212 reply_id: 141127[/import]

Thank you very much, Rob!
[import]uid: 157691 topic_id: 35212 reply_id: 141147[/import]

There is a math rule to use on newImageRect for image_size_width and image_size_height depend on config.lua defined sizes? If I use exact dimensions of file image - it remain black margins left/right. I need to use on file image a different size that from scalling Corona fill the screen
Now I have
* file image on 1140x720 pixel ( base - @1x ) and 2280x1140 as @2x
* load Images with

background = display.newImageRect(group,“background.jpg”,1280,720)

* and config.lua :

content =
{
width = 720,
height = 1140,
scale = “letterBox”,
xAlign = “center”,
yAlign = “center”,
imageSuffix =
{
["@2x"] = 1.6,
["@3x"] = 2.4 ,
["@4x"] = 3.2,
},
},

It seems to work ok and display fine background on Android.
If i use 1280x800 image file - through scalling - I will see black bars.

The question is : when load with newImageRect it’s ok to use main target resolution ? ( for main targeted display )

Thank you
Radu [import]uid: 157691 topic_id: 35212 reply_id: 141157[/import]

I want to make a self-correction: to display backgrounds I use
background = display.newImageRect(group,“BGS/bg_tren.jpg”,1280,720)
background.x, background.y = display.contentWidth/2, display.contentHeight/2
All other I written are correct.
I used 1280x720 after effective tests, not based on logical - math deduction - that is why ask if there is a formula (I saw that there are several conventions, but it seems to be obtained through tests too)

Because I have image parts/elements for objects in the scene built on initial 1280x800 I calculated a scale factor x, y as display.contentWidth/1280, display.contentHeight/1280 on createScene and I multiplied elements ( actors) coordinates with scale factor to re-arrange them. I don’t know if it’s the best method - but I could reassembly the scenes ok - based on screen and background resolution.
[import]uid: 157691 topic_id: 35212 reply_id: 141230[/import]