iPhone images on the simulator and the actual devi

2019-08-14 07:32发布

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条回答
女痞
2楼-- · 2019-08-14 08:16

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

查看更多
登录 后发表回答