简体   繁体   中英

How to store UIImage in NSMutableArray without loss of quality

I have a problem, I use the Photo framework, and when I do that (images is a NSMutableArray) :

[[PHImageManager defaultManager]requestImageForAsset:lastAsset targetSize:CGSizeMake(150, 300) contentMode:PHImageContentModeAspectFit options:nil resultHandler:^(UIImage *result, NSDictionary *info) {

        [images addObject:result];

    NSLog(@"%@ %@ %@",result,[images objectAtIndex:0],[images lastObject]);

 }];

I have these results for the size of my UIImages in my console :

700,700 60,40 700,700

I don't understand why, and when I add an image of my NSMutableArray which is named "images" :

view.image = [images objectAtIndex:index];

I have all my images in very bad quality (I think they are all stored in 60,40 in my images NSMutableArray). Or I want to recover theses in their original quality (700,700 not in 60,40) to display theses with a good quality.

Thanks a lot everyone !!

I have found the solution of my problem.

The solution is to add this option :

        PHImageRequestOptions* options = [[PHImageRequestOptions alloc]init];
        options.resizeMode = PHImageRequestOptionsResizeModeExact;
        options.deliveryMode = PHImageRequestOptionsDeliveryModeHighQualityFormat;
        options.version = PHImageRequestOptionsVersionUnadjusted;
        options.synchronous = YES;

to my request.

We can see the deliveryMode which is very important for keep a good image quality.

Thanks for help everyone !

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM