开发者

Memory warning level 1 due to UIImage

I am working on one component where I need to scale and rotate image. following is flow of the component

Select the image from photo library -> show that image in UIImageView -> do the scaling -> save this image in document.

This works fine with image having low resolution.

but once I select the image with high resolution I first get Memory Warning level 1. but I cann't release that image, as I need to proceed further with same image.

I come to know image is unpacked by ( width * height * 4 ) so if I select image of 1800 * 1200 memory consumed is 8.6 MB [ Also check开发者_如何学编程ed with instrument ] .

Can any one help me to come over this issue? This creates 2 queuestion

  1. can we use images with high resolution ?
  2. what about 2 UIImageview with two high resolution images?

Thanks,

Sagar


You could change your order of operations a bit.

Select the image from the photo library -> scale the image -> save the scaled image to the Documents directory -> show the scaled image in the UIImageView.

Scaling and saving the image takes time, so your user will have a bit of a wait before they see the image in your UIImageView. Displaying an activity indicator with a cancel option is a good idea.

I've used this technique with pretty large images and it worked on older devices without incurring memory warnings.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜