views:

174

answers:

2

So I'm making a universal app (iphone3gs/iphone4/ipad/)... But I have a question about images.

Say we have an image of a smiley face... Would you have 3 separate images (each saved with a different width/heights) for all devices i.e.:
smiley-iPad.png (for ipad)
smiley.png (for iphone 3gs)
[email protected] (for iphone 4)

or would you just have one image: smiley.png (that is saved in high resolution i.e., large width/height and then scaled with interface builder)

seems like that latter would save alot of work, what are your thoughts on this, which is better?

+1  A: 

The latter would save work but would be slower on the 3GS as it would have to scale the image before displaying it. Depending on your application this may or may not be a problem. There may be other cases as well where you want a completely different image for ipad as with a larger screen space there is more room for detail.

skorulis
i'd assume that the latter calculation would be cached. also, the former would require more room on the device if we have always have triple the amount of images... my only concern really is that scaling in IB can sometimes make some images look bad...
Shnitzel
I'm not sure exactly what kind of caching UIImageView does. I know for one application I was writing that displayed thumbnails in a list I got a noticeable dip in performance if I didn't scale them first. Though for static images this is far less of a problem. As for scaling making images look bad, just supply the 3 sizes for those graphics. There's nothing to stop you using both solutions for different images.
skorulis
A: 

It's not just a problem about scaling images.

If you use "a lot" of images, the main problem will be the memory used. For an iPhone 4, using an image 640*960px to display a background won't be a problem. But using the same image for an iPhone 1 or iPhone 3G is a bit too much. Especially when you have more than one image ^^

So I advise the first solution (the one I'm using for my Apps ;-))

Vinzius