Images are not being resized automatically on Galaxy SII

Well, everybody seems to have their own approach to Android (and to iOS too). I use a content size of 704x1024, but many people go with 640x960 (iPhone4) and just adapt to Android, iPhone5, iPad, etc.

Here’s an article you might find useful:

http://www.coronalabs.com/blog/2012/12/04/the-ultimate-config-lua-file/

Brent

Adding on to what Brent said, the reason that I use 1.5x and 3x is to cover the wide variety of shapes.  Corona SDK works by saying "Is my screen bigger than 1.5x of my base size.   Lets say you use a 320x480 base for your screen size (which is reasonable.  You wouldn’t get @2x images, if we used 2.0 as the value until the device was 640px wide.  So those 1024x600 tablets would use the lower resolution graphics.  By using 1.5x, the bigger images get used on anything wider than 480px and those get scaled down instead of stretching up.  This gives you the best image for the screen shape.

Then by using images who’s areas can be bigger than which ever screen is in use, you can use one set of backgrounds.  Then your core images can simply be based on your 320px for 1x, 640px for @2x and 1280px for @4x and it all kind of magically works.

“newImageRect()” has not solved the problem…

Hi @WilerJr,

Can you post a few lines of code, showing how you’re placing one of these images?

Thanks,

Brent

background = display.newImage("images/background\_game.png", 320, 480);  

But this is using “newImage()”, not “newImageRect()”… is this a typo?

lol. Big mistake. I’ll change that and bring some news later.

Anyway, the code I posted above is an exception; the others are being called like

background = display.newImage("images/background\_pause.png", image\_width, image\_height);  

where is the exception?
this is still using “newImage()”, not “newImageRect()”. :wink:

Damn it! hahaha

I forgot to change to “newImageRect” on the post. Sorry. But the exception is:

background = display.newImageRect("images/background\_pause.png", image\_width, image\_height);  

Hi @WilerJr,

This is a “duh!” observation this late in the thread… did you actually configure your image suffix values in “config.lua”? I don’t see them there, unless you just didn’t paste that part in…

Brent

I don’t use image suffix…

Hi @WilerJr,

Dynamic image selection goes hand-in-hand with image suffix. You can’t do one without the other. Please read through the guide on how to set all of this up:

http://docs.coronalabs.com/guide/basics/configSettings/index.html#dynamicimages

Take care,

Brent

I think I’ve read somewhere that the images are resized automatically by Corona… But as soon as I can I’ll take a look at the link you posted. Thank you.

Yes, they are resized (well, selected) automatically, but you need to set up the suffix config first, and then name your images properly. It’s all there in the guide. :slight_smile:

What you can about the variety of Android devices’ screen sizes? How can I do image suffix for them? ^^

Well, everybody seems to have their own approach to Android (and to iOS too). I use a content size of 704x1024, but many people go with 640x960 (iPhone4) and just adapt to Android, iPhone5, iPad, etc.

Here’s an article you might find useful:

http://www.coronalabs.com/blog/2012/12/04/the-ultimate-config-lua-file/

Brent

Adding on to what Brent said, the reason that I use 1.5x and 3x is to cover the wide variety of shapes.  Corona SDK works by saying "Is my screen bigger than 1.5x of my base size.   Lets say you use a 320x480 base for your screen size (which is reasonable.  You wouldn’t get @2x images, if we used 2.0 as the value until the device was 640px wide.  So those 1024x600 tablets would use the lower resolution graphics.  By using 1.5x, the bigger images get used on anything wider than 480px and those get scaled down instead of stretching up.  This gives you the best image for the screen shape.

Then by using images who’s areas can be bigger than which ever screen is in use, you can use one set of backgrounds.  Then your core images can simply be based on your 320px for 1x, 640px for @2x and 1280px for @4x and it all kind of magically works.