开发者

iPhone images on the simulator and the actual device - different bitsPerPixel values?

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 contr开发者_C百科ol?


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜