Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

Which is the best format or best technique to compress images without loss of quality for iPhone/iPad games?

share|improve this question
    
You might also want to use "imageWithContentsOfFile:" instead of "imageNamed:" when you load images if you are concerned with memory issues. But imageNamed: is faster when you REUSE an image. –  Jenn Eve Sep 7 '12 at 7:39
3  
Depends on if you're compressing for run-time memory usage or on-disk memory usage. –  Tetrad Sep 7 '12 at 20:15

2 Answers 2

up vote 8 down vote accepted

The commonly used formats are PNG and PVR.

The PNG (Portable Network Graphics) format is compressed but lossless. It's a commonly used format (basically any image-editing software can write to PNG).

The PVR (PowerVR) format is a format that is much closer to the native memory structure of images on the GPU of the iPhone. Therefore it also allows for some byte-orderings that are available on the GPU but not usually used in image-processing, such as RGBA4444 (4 bits instead of 8 bits per channel). Of course a reduction in bits per channel also means a quality-loss... it's highly dependent on your type of image if this quality loss will be noticeable or not.

The PVR format is faster to read to the GPU and it gives you more control over how much memory your texture will consume. PNG is ubiquitous and much easier to work with. Almost any image editing software can read/write it and there are tools like ImageOptim that allow even further compression/optimization of PNGs.

Update Just to clarify if that wasn't clear from what I have written above: Further optimizing and compressing a PNG will only result in smaller file-size, eg. less disk-space that's being used. That can be important if you aim for a small app-package size (eg. to stay below the 50mb limit to download over cellular networks). Usage of graphics-memory is also important and if you want to optimize graphics-memory consumption, then your only option is to use PVR (unless you load PNGs and convert them to other formats/byte-orderings dynamically... but that's another story).

As long as you aren't facing any texture memory issues, PNG is far easier to work with.

share|improve this answer
    
Thank you sir, ideally when to use PVR images in game? for large size image or small size? –  Raj Jul 18 '12 at 6:57
1  
@Raj You can use it for any size, but it makes more sense for large images (backdrops or sprite-atlas). You should first check if your images still look good if you reduce from 32 to 16 bits or similar. You should also consider PVR when you have several large images that have to be kept in the GPU memory as you can cut down GPU memory usage quite significantly by choosing the right PVR format. If you need true-color and full alpha I would personally stick with PNG as it's much easier to work with. –  bummzack Jul 18 '12 at 7:07
    
thanks a lot for the info sir. –  Raj Jul 18 '12 at 8:34
1  
PNG is only going to reduce the size on-disk (or equivalent), it needs to be expanded to full RGBA8 in texture memory so there isn't going to be any memory saving had from using it. If you want to save texture memory then all formats which are compressed in texture memory are going to be lossy. –  Darth Satan Sep 7 '12 at 9:11

You need to have a good eye so that you can get the most out of your textures.

  • I always compare RGBA4444 with RGBA8888. If the difference is not that noticeable, I use RGBA4444 instead. It saves a LOT of memory.
  • If quality seems to degrade RGBA4444, apply Dithering. See if it's workable.
  • If I need to compress the project's total filesize. I'm looking for any texture that can be in JPEG. JPEG's filesize is very small compared to PNG but tradeoff is you're gonna lose a lot of processing. It'll be slower. I'm using this for textures that do not have any alpha channel. Also, only use this for something that is seldom used or textures that are loaded once and it'll stay long on the screen (like splashscreen, background). Never use JPEG if you need to draw it frequently on the screen.

Anyway, only do this if you have problem with memory/filesize. In my case, we have tight schedule so we optimize beforehand as long as quality will not degrade.

share|improve this answer
    
thanks alot for ur response...But sometimes not only eyes r useful..even we can't see all single image..Game lik miniNinja..contains GB's of texture memory..So some time we need to go for brainy method that is good. –  Raj Oct 6 '12 at 18:13
1  
Yeah, there are more advanced techniques available (like in your example, occlusion culling) but you'll work that on your code and not on your assets. The game we've shipped contains different techniques just to get it running smoothly (most of them were very tricky that our codebase broke lol) –  Sylpheed Oct 6 '12 at 18:30

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.