0

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

Ganesh Somani
  • 2,280
  • 2
  • 28
  • 37
  • It is not the download, the problem is that a 6999 x 6999 * 4-bytes per pixel is 195MB and multiple that by "a few" and that is a lot of memory. Do you need images this large for display? When you reduce the size of an image pixels are discarded so the quality is going to be lower, there are fewer pixels. – zaph Oct 09 '15 at 17:44
  • I generally need to load only one image at a time. But what i had in mind is to load the image like the web browser does, from top to bottom. – Ganesh Somani Oct 09 '15 at 17:52
  • You will need to write your own image rendering engine to render partial downloads. – zaph Oct 09 '15 at 19:21

0 Answers0