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

拟墨画扇 提交于 2019-12-11 13:53:46

问题


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?


回答1:


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



来源:https://stackoverflow.com/questions/2469659/iphone-images-on-the-simulator-and-the-actual-device-different-bitsperpixel-va

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!