I have to display multiple kinds of images (not just JPG or PNG) for a photo app.
The problem I am facing is while convert the NSData downloaded for a few high resolution image (around 6900*6900 and 6999 * 6999 px) to UIImage
the application crashes due to memory issue.
I have used multiple Async Image downloading and caching third parties like AsyncImageView
, SDWebImageCache
, Haneke
and EGOImageView
. They all crash.
Here is the code where I pinpointed the crash for AsyncImageView
UIGraphicsBeginImageContextWithOptions(image.size, NO, image.scale);
[image drawAtPoint:CGPointZero];
image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
If I just change the image.size
to CGSizeMake(400, 400)
and [image drawAtPoint:CGPointZero];
to [image drawInRect:CGRectMake(0,0,400,400)];
It won't crash, but the size quality reduces.
I would like to know how do I display the image without reducing its quality.
Note : Image format can be any kind of format and not just PNG or JPG
Thanks