R – How many bits per component do I have to specify for pngcrunch-optimized 24bit PNG files with alphatransparency


CGBitmapContextCreate takes an parameter that's not very obvious to me:

For example, for a 32-bit pixel format
and an RGB color space, you would
specify a value of 8 bits per

I have created 24-bit PNG files with alphatransparency, and added them to Xcode. At compile time, Xcode optimizes those PNG tiles with pngcrunch.

So, when trying to make an graphics context out of such an image file on iPhone-OS, I need to specify the bits per component.

In this case, I would say they're 4 bits per component, although I dont know if alpha counts as an component.

Best Solution

It's 8 bits per component:


That adds up to 32 bits per pixel. Your 24-bit png with transparency is 24-bits for RGB, plus 8 bits for transparency (the 'alpha channel').

Related Question