views:

58

answers:

1

Hi there,

I have code running in an iPhone application I am developing. Basically, the code needs to load an images and calls:

size_t bitsPerPixel             = CGImageGetBitsPerPixel(imageRef);

I noticed that on the iPhone simulator this call returns 24 and the device itself it returns 32.

Is this behavior by design? Is it something I can control?

Thanks!

A: 

I think it comes down to the image format.

When using PNGs in an iPhone app, part of the build process when building for device puts PNG images through the pngcrush utility, which optimises the images for use with the iPhone's graphics processor. It has something to do with the fact that the iPhone's graphic processor doesn't natively handle alpha, so it relys on pre-multiplied alpha values.

This could be the difference you are seeing. And the reason you don't see it in the simulator is that the simulator uses the Mac's grahics processor, and therefore can natively handle alpha in PNGs, which means the PNGs aren't 'crushed' during the build process.

I think...

Jasarien