码迷,mamicode.com
首页 > 其他好文 > 详细

不使用UIImagePickerControllerOriginalImage获取相册图片

时间:2015-05-07 11:58:07      阅读:124      评论:0      收藏:0      [点我收藏+]

标签:

?
?

一般用imagePickerController获取到dic以后常用的方法是使用

?

UIImage *image = [dic objectForKey:@"UIImagePickerControllerOriginalImage"];

来获取原图,但是我使用这个方法获取到得图片并不是原图,而是尺寸经过压缩后的,后来找到了一个新的方法来进行获取 直接贴代码

?

  1. ALAssetsLibrary?*library?=?[[ALAssetsLibrary?alloc]?init];??
  2. ?????[library?assetForURL:[dic?objectForKey:UIImagePickerControllerReferenceURL]??
  3. ??????????????resultBlock:^(ALAsset?*asset)??
  4. ??????{??
  5. ??????????ALAssetRepresentation?*representation?=?[asset?defaultRepresentation];??
  6. ??????????CGImageRef?imgRef?=?[representation?fullResolutionImage];??
  7. ??????????UIImage?*image?=?[UIImage?imageWithCGImage:imgRef??
  8. ?????????????????????????????????????????????scale:representation.scale??
  9. ???????????????????????????????????????orientation:(UIImageOrientation)representation.orientation];??
  10. ??????????NSData?*?data?=?UIImageJPEGRepresentation(image,?0.5);??????????????????
  11. ??
  12. ??????}failureBlock:^(NSError?*error){??
  13. ??????????NSLog(@"couldn‘t?get?asset:?%@",?error);??
  14. ??????}??
  15. ??????];??

不使用UIImagePickerControllerOriginalImage获取相册图片

标签:

原文地址:http://www.cnblogs.com/allen123/p/4484333.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!