Solution to Blurred Image Browsing under ios9 (ALAsset. thumbnail fuzzy)

Source: Internet
Author: User

Solution to Blurred Image Browsing under ios9 (ALAsset. thumbnail fuzzy)

In ios9, photo browsers implemented using the ALAsset method all have the problem of photo blurring. However, most open-source photo browsers can be found using this framework.

We usually use the following method to obtain the thumbnail:

 

self.image = [UIImage imageWithCGImage:self.asset.thumbnail];

 


Debugging found that on ios8, the size of the photo is 150*150, and on ios9, the size is 75*75.

 

Check the apple documentation and find that ALAsset has been deprecated. We recommend that you use the new Photos framework.

 

 

However, rewriting the photo browser is time-consuming. If the project is tight, you can use the following method to transition:

 

self.image = [UIImage imageWithCGImage:self.asset.aspectRatioThumbnail];

 


AspectRatioThumbnail is the thumbnail of the original photo. Note that it is not a square image, so the view of this photo needs to be

 

[imageView setContentMode:UIViewContentModeScaleAspectFill];

 


 

This method brings about an additional problem: performance. AspectRatioThumbnail is relatively large, so the display is not very smooth (iPhone5). asynchronous cropping can solve this problem.

 

_ Weak typeof (self) weakself = self; dispatch_async (dispatch_get_global_queue (DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^ {// crop weakself. image = [weakself. image imageCroppedToFitSize :( CGSize) {150,150}]; dispatch_async (dispatch_get_main_queue (), ^ {// complete, set to view [weakself. imageView setImage: weakself. image] ;});

Now you can replace it with the Photos framework. However, if you want to continue to support ios7, it seems that ALAsset still needs to be retained (that is, two sets of Image Library Reading interfaces are required ).

 

 

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.