Retina images & newImageRect

Just been trying a few things out and seemed to have stumbled on to something genius or maybe something stupid... anyway:

If you create an image 960 x 640 (iPhone 4 landscape) and load it directly into a newImageRect with the dimensions 480 x 320 this seems to work perfectly and saves me the time in creating 2 sets of images with the @x2 extension. Not tried this beyond the simulator but I would assume everything would load ok on both iPhone and iPhone 4, with the benefit of automatic retina graphics on iPhone 4.

Is this an OK way forward do you think, with the only downside being a slight waste in memory?

-- Chris

Just to confirm I have tried this on an old iPod touch and an iPhone 4 and this works perfectly.

Retina graphics on the iPhone 4 and pretty sharp looking graphics on the iPod touch.

Not sure if this is officially supported but since it works I think I'll be using it since it saves so much time messing around with multiple versions of images.

Yeah you can do that no problem. However slower devices take longer to load images, especially on android and with images larger than their native resolution.

Test it on device, and if load time is acceptable go for it. I do something similar in my game so I don't need to create multiple graphics for iPhone, iPad, retina and all the android screen sizes.

Take a look at section 3 here:

http://www.base2solutions.com/walkabout/Corona%20Tips.html

You can pretty much choose the scale mode by being clever with the dimensions you pass to newImageRect. Its very useful! I basically stretch some image by a specified amount, and posibly even partial zoom them to lose bits off the top - to avoid an overstretched look.

Thats how my game supports iPad, iPhone, all android phones and tablets with one code and resource base and compiles to under 5mb on android and under 7 on iOS :)

views:1546 update:2011/10/1 9:04:19
corona forums © 2003-2011