zoukankan      html  css  js  c++  java
  • PHImageManager 获取图片模糊

        PHImageRequestOptions *options = [[PHImageRequestOptions alloc] init];
        options.synchronous = true;
        options.deliveryMode = PHImageRequestOptionsDeliveryModeHighQualityFormat;
        options.networkAccessAllowed = YES;
        options.progressHandler = ^(double progress, NSError *error, BOOL *stop, NSDictionary *info) {
            /*
             Progress callbacks may not be on the main thread. Since we're updating
             the UI, dispatch to the main queue.
             */
            dispatch_async(dispatch_get_main_queue(), ^{
                if(handler) handler(progress);
            });
        };
        
        [[PHImageManager defaultManager] requestImageForAsset:asset targetSize:PHImageManagerMaximumSize contentMode:self.view.bounds.size options:options resultHandler:^(UIImage *result, NSDictionary *info) {
            // Hide the progress view now the request has completed.
    
            // Check if the request was successful.
    
            if(manager) manager(result);
    
        }];
    

     用以上的代码去获取图片会出现模糊,不清晰的状况。(明明options.deliveryMode = PHImageRequestOptionsDeliveryModeHighQualityFormat 设置为高清了)

       其实坑就在于contentMode 写成了self.view.bounds.size,如果需要获取清晰的请设置为:PHImageManagerMaximumSize。或者换一种读取图片的方法:

        [[PHImageManager defaultManager] requestImageDataForAsset:asset options:options resultHandler:^(NSData * _Nullable imageData, NSString * _Nullable dataUTI, UIImageOrientation orientation, NSDictionary * _Nullable info) {
            UIImage * result = [UIImage imageWithData:imageData];
            if(manager) manager(result);
        }];
    

      

  • 相关阅读:
    hdu 4027 Can you answer these queries? 线段树
    ZOJ1610 Count the Colors 线段树
    poj 2528 Mayor's posters 离散化 线段树
    hdu 1599 find the mincost route floyd求最小环
    POJ 2686 Traveling by Stagecoach 状压DP
    POJ 1990 MooFest 树状数组
    POJ 2955 Brackets 区间DP
    lightoj 1422 Halloween Costumes 区间DP
    模板 有源汇上下界最小流 loj117
    模板 有源汇上下界最大流 loj116
  • 原文地址:https://www.cnblogs.com/qiyer/p/9316163.html
Copyright © 2011-2022 走看看