Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

[iPhone] XCode png-compression messes with alpha

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)

Posted on Oct 14, 2008 10:02 AM

Reply
Question marked as Best reply

Posted on Oct 19, 2008 7:14 PM

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. IPHONE OPTIMIZEOPTIONS=-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.
4 replies
Question marked as Best reply

Oct 19, 2008 7:14 PM in response to Llerd

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. IPHONE OPTIMIZEOPTIONS=-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.

[iPhone] XCode png-compression messes with alpha

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.