views:

227

answers:

1

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 component.

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.

+2  A: 

It's 8 bits per component:

Red:8;
Green:8;
Blue:8;
Alpha:8;

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').

Jim Dovey
Very cool answer! Now I understand this 24-bit thing. Great!
Thanks