4 Replies Latest reply: Oct 20, 2008 4:31 AM by Llerd
Llerd Level 1 Level 1
When XCode bundles an iPhone application, it converts all .PNG resources into a non-standard format. This compression seems to be reduce precision of the alpha-channel of my .PNGs which causes artifacts in my application. Does anyone know if there is any way to get control over this behavior?

MacBook, Mac OS X (10.5.3)
Solved by zenja on Oct 19, 2008 7:14 PM Solved
I have the exact same problem. XCode will convert PNG images so that the header chunk is CgBI (instead of IHDR), and that confuses 3rd party libs like libpng, since a character in Apple's header indicates that the data is in a private format. This operation only takes place for the target device - the simulator is unaffected. There are 4 ways to work around the issue (from easiest to hardest).

1) Rename your images to something else (eg. .ppng), and the XCode packaging tool will ignore your file.
2) According to the following link (http://www.imgtec.com/powervr/insider/sdk/KhronosOpenGLES1xMBX.asp), you need to add the following build settings defintion for each target. IPHONEOPTIMIZEOPTIONS=-skip-PNGs I'm embaressed to say that I still haven't figured out where in XCode project settings to add this.
3) Teach your PNG decoder to handle Apple's CgBI format.
4) Use the Cocoa UIImage classes or the Texture2D.m class.
  • zenja Level 1 Level 1
    I have the exact same problem. XCode will convert PNG images so that the header chunk is CgBI (instead of IHDR), and that confuses 3rd party libs like libpng, since a character in Apple's header indicates that the data is in a private format. This operation only takes place for the target device - the simulator is unaffected. There are 4 ways to work around the issue (from easiest to hardest).

    1) Rename your images to something else (eg. .ppng), and the XCode packaging tool will ignore your file.
    2) According to the following link (http://www.imgtec.com/powervr/insider/sdk/KhronosOpenGLES1xMBX.asp), you need to add the following build settings defintion for each target. IPHONEOPTIMIZEOPTIONS=-skip-PNGs I'm embaressed to say that I still haven't figured out where in XCode project settings to add this.
    3) Teach your PNG decoder to handle Apple's CgBI format.
    4) Use the Cocoa UIImage classes or the Texture2D.m class.
  • zenja Level 1 Level 1
    Sorry for double post - cannot edit previous post for some reason.

    The correct link is: http://plaidworld.com/iphonefaq.txt
  • zenja Level 1 Level 1
    I've contacted Chris (owner of http://plaidworld.com/iphonefaq.txt), and he has now added instructions on how to disable png-conversion. This effectively overrides point 1 in the list above. Just use the IPHONEOPTIMIZEOPTIONS=-skip-PNGs option, and you're set to play.
  • Llerd Level 1 Level 1
    Thanks. This solved the alpha-problems I had as well.