UIImage memory usage with png and jpg

I have two files in the Documents folder of the same image taken with the camera. One of them was saved using the UIImagePNGR presentation, and the other using the UIImageJPEGRepresentation. In other words, one is png and the other is jpg.

Now using the tool with a real device. if I download png (initWithContentOfFile :), the "Real memory" goes from 2.34 MB to 2.43 MB. But if I download jpeg instead, the memory goes from 2.34 MB to more than 23 MB !!! I had similar results loading any png against jpeg.

Can someone help me understand why?

+4
source share
2 answers

It is likely that it can map the memory used for the PNG file directly for storage, while it does not have the ability to do this with the help of JPG, which must be decoded.

If you think about it, for an 1600x1200 image from an iPhone camera, 23 MB is very realistic, and 0.9 MB is not enough space to store data for the image.

+4
source

Apple has a special custom format for png files, where the color bytes are in the same order as the color bars on the iPhone screen. Png Images Resources are overwritten when copied to the Xcode application bundle. I suspect png views are special covers when used as images on iPhone.

0
source

All Articles