Corona - how to accommodate different device resolutions whilst retaining quality for hi-res devices? - iphone

How is it possible to accommodate lower resolutions from Corona but primarily target high resolution devices?
I know you can specifically set content width and height via Corona, and scale the content, but this seems to be for scaling upwards (method detailed here http://blog.anscamobile.com/2011/01/use-dynamic-layouts-in-universal-builds-with-corona-sdk/).
I've been creating an iPad app but I'd not targeted any resolution - my app appears fine on iPad 1 / 2 and on iPhone 4, but not on the original iPhone.

There are two terms you need to pay attention to: dynamic content scaling and dynamic image resolution. The former refers to scaling the stage in Corona to fit on different displays, and the latter refers to swapping different versions of images on different displays. Here's documentation about both:
http://blog.anscamobile.com/2010/11/content-scaling-made-easy/#more-3756
http://developer.anscamobile.com/content/configuring-projects#Dynamic_Image_Resolution
First setup dynamic content scaling in config.lua so that the display will scale on different devices.
Then setup dynamic image resolution (also set in config.lua) so that you can swap in higher resolution versions of your graphics on devices with higher resolution. This is done through naming of the image files; basically, when you call newImageRect("image.png") in your code, it'll load image.png on lower resolution devices and image#2x.png on higher res devices.
(incidentally, while the dynamic image resolution configuration on the linked page uses the suffix "#2" I would recommend "#2x" because that is the standard suffix Apple uses. That is, in Corona you don't have to use Apple's standard, but it's less confusing if you do.)

Related

Images for Retina display

If i want my application to be compatible with the Retina display, am i obliged to recreate all my images by doubling their sizes? even the icon?
if you will not use high resolution images your images will look pixelated/blurr.So better to use high res images as well.Some Key points are:
Displaying graphics depending on the device model can be done by duplicating image files and adding an ‘#2x’ suffix. So, when the normal image file is named ‘button.png’, the hi-res version should be ‘button#2x.png’.
You don’t need any additional code for this. In Interface Builder or your code, assign the normal version (without the suffix) to an object. The same goes for the application icon. The resolution of the 2x icon should be 114 by 114 pixels. You will need to add a separate ‘Icon’ property in the Info.plist file for this icon.
If for some reason you do want to perform a check in your code, you can do so by checking the scale factor of the display. Older models will return a scale factor of 1.0, while the iPhone 4 will return 2.0. You can check this with:
float factor = [UIScreen mainScreen].scale;
Depending on the type of application you’re developing further optimizations can be made to utilize the new retina display the best you can.
A very good information here
hope it help you :)
You're not obligated, it just will look very pixelated if you don't.
As for the icon, I believe you are obligated to provide multiple sizes when submitting to the AppStore.
Maybe you'll want to take a look at iRetiner.
You could also check this previous stackoverflow thread : how to set image for ipad application that support retina display
A summary of the icons and what is required can be found in the human interface guidelines. I highly recommend providing high resolution artwork for the retina display even though it is not required. Your default now should be to design artwork at the higher resolution, then scale down for older devices. I doubt Apple would choose to highlight an application as new and noteworthy if it looks pixelated on the latest devices.

Not including non-retina display images in an iPhone project

I have an iPhone Xcode project that currently only contains images for retina display (twice the size as normal and with a #2x.png suffix). When I run the app on the iPhone Simulator (non retina) the images are still being displayed. Does this mean I don't need to worry about including two sets of images: retina and non-retina?
This all seems a bit odd. I would assume that no images would appear on a non retina device if there are no non-#2x files included.
Note: I have not tested my app on a non retina device. Just the simulator.
I'm pretty sure that iOS will just use the #2x and scale it down if you don't have a non-retina graphic. Although that's sub-optimal since you're letting iOS do the scaling at runtime which will be slower than including the non-retina graphic and also iOS might not do as good a job as scaling as your graphics editor of choice.
Even if it works, it's not good practice, and if you have a media heavy app definitely it would impact performance and battery life and memory foot print and ....
By the way, is it just that you don't have the 1x graphics available to you or you are concerned about your apps (download size) or ...
If you are assigning the images in Interface Builder, and you set the image property on a UIImageView to image#2x.png, for example, iOS will not know that it's a high resolution "2x" image. In fact, on a retina display, iOS will look for an image named image#2x#2x.png. Since it won't find it, it will set the scale factor of the image to 1.0.
The contentMode property (just "mode" in XCode) will decide if any scaling of the image occurs to fit the constraints of the UIImageView. You may wish to set the mode to "Aspect Fit" to get the high resolution image to scale as needed for both retina and non-retina displays. In general, the image will display as seen in Interface Builder.
If you are using UIImage's imageNamed or similar function to load the image, and just specify image (where "image.png" doesn't exist, but "image#2x.png" does), then iOS will actually find the image on a non-retina display, though the scale factor will be 1.0. As previously, you'll need to scale it to fit your view. The image will work normally on a retina device, and the scale factor will be set to 2.0, since iOS looks for a "2x" image first, and it doesn't matter if the other file exists or not.
This is from Apple's documentation on imageNamed:
On a device running iOS 4 or later, the behavior is identical if the
device’s screen has a scale of 1.0. If the screen has a scale of 2.0,
this method first searches for an image file with the same filename
with an #2x suffix appended to it. For example, if the file’s name is
button, it first searches for button#2x. If it finds a 2x, it loads
that image and sets the scale property of the returned UIImage object
to 2.0. Otherwise, it loads the unmodified filename and sets the scale
property to 1.0. See iOS App Programming Guide for more information on
supporting images with different scale factors.
If at all possible, you really should include both retina and non-retina images. Using higher-resolution images than necessary negatively affects memory and performance.

Change TFT to Retina in iphone

There are people who insist that for changing design from TFT to Retina we should redesign all app.
But I have read that we can change only app's images ,and it's enough.
I want to know which is the best practice for it and which solution is acceptable??
Retina Display is just Apple's name for the high resolution display on some of its devices -- it's still a TFT (thin film transistor) LCD display, though.
The Retina Display has twice as many pixels in each direction as the non-Retina version. iOS features a mechanism for providing both high resolution and standard resolution images, so that the high-res versions will be used if needed. All you need to do is include high-res versions of your images with the same names and their standard-res counterparts and the "#2x" suffix. Of course, having that higher resolution available means that you might want to add detail to your images or otherwise redesign your app to take full advantage of the screen's capabilities, but it's not a requirement. In fact, you don't need to do anything at all -- your existing app will work just fine without any changes.
It depends on your app.
In many cases simply including the hi-res versions of your images will be all that you need to do.
However, if you have any custom drawing that could benefit from the extra resolution, then you'll need to considered updating that code too.

can the ui design for old iphone be used on iphone4?

I'm developing my software, all the ui is drawn based on 480x320 size screen, can my software run on iphone4 without any modification?
Yes it can run with no modification.
If you'd like to create "retina" assets you can create all of your images at the double resolution and include copies with '#2x' appended to the filename in your Application bundle. The iPhone will automatically load the correct images.
Example:
existing image - myImage.png
new up-sampled image - myImage#2x.png
Yes, but any images sized for the earlier iPhone models will look chunky compared to custom-designed iPhone 4 images.
Both the iPhone 4 and older devices are 320x480 points in size, which is the coordinate system that Core Graphics and UIKit uses. So your software will run the same.
Only the automatic scaling between your bitmaps and the display will be different. If you have bitmapped content or images, you can optionally provide #2x sized versions that will look somewhat smoother without the 2X scaling on iPhone 4 devices. This is nice, but optional.

question regarding retina display assets on older handsets running 4.x

So I'm building an app for 4.x devices and I'm wondering if I can just use one set of assets at double resolution instead of one set with a #2x id and another set without.
Basically im asking can the older 3g and 3gs just use the #2x assets? and do the right thing with them?
anyone have experience with this?
Thanks
You're better off using two sets of resources, one for the high resolution retina displays and one for the older displays. Downsizing #2x graphics won't look pretty and will impact performance, especially on 2G iPod Touches.
The older devices can use the #2x but as far as I understand you'll need to:
Set your UIImageViews to scale the images to fit.
Hardcode image references to the new images.
Expect poor image quality and slower performance on non-retina devices.
Overall, it's better to provide two copies of the images, "bob.png" and "bob#2x.png" then reference them in code as "bob.png".
NB. As of iOS4 you can reference the images without their file endings, so just "bob" would work; however this has compatibility implications with devices running pre-iOS4 : the images won't be found. So for maximum compatibility include the file endings if you intend on deploying to both iOS4 and iOS3.x.
They technically can, given you make sure they're scaling the right way (e.g. if it's an image view that it's set to scale up/down).
However it's not recommended in most situations, mainly because it'll be slower, uses more resources, and leads to shorter battery life. Also, depends on your resources but an artwork scaled down by a factor of 2 doesn't have the same quality as one that is resampled specifically for the new size.