, 安康;(空白)p_w_picpathPickerController:(UIImagePickerController *) picker didFinishPickingMediaWithInfo: (NSDictionary *) info { ,,,(picker dismissViewControllerAnimated: YES 完成:NULL]; ,,,NSString * mediaType =, [info valueForKey UIImagePickerControllerMediaType):; ,,,UIImage * newImage; ,,,WS (weakSelf); ,,,if ([mediaType isEqualToString: @ " public.p_w_picpath "]), { ,,,,,,,UIImage * originImage =, [info objectForKey UIImagePickerControllerOriginalImage):; ,,,,,,,dispatch_sync (dispatch_get_global_queue (0, 0),, ^ { ,,,,,,,,,,,[weakSelf saveImageToPhotos originImage):; ,,,,,,,}); ,,,,,,,newImage =, (self scaleImage: originImage toScale: 0.1); ,,,} ,,,(_p_w_picpathArray addObject newImage):; }
, ——(UIImage *) scaleImage:(UIImage *) p_w_picpath toScale:(浮动)scaleSize { ,,,UIGraphicsBeginImageContext (CGSizeMake (p_w_picpath.size.width * scaleSize p_w_picpath.size.height * scaleSize)); ,,,(p_w_picpath 图形:CGRectMake (0, 0, p_w_picpath.size.width *, scaleSize,, p_w_picpath.size.height * scaleSize)]; ,,,UIImage * scaledImage =, UIGraphicsGetImageFromCurrentImageContext (); ,,,UIGraphicsEndImageContext (); ,,,, ,,,return scaledImage; }
, 安康;(空白)saveImageToPhotos:(UIImage *) savedImage { ,,,UIImageWriteToSavedPhotosAlbum (savedImage,自我,,@ selector (p_w_picpath: didFinishSavingWithError: contextInfo:), nil); } 安康;(空白)p_w_picpath:(UIImage *) p_w_picpath didFinishSavingWithError: (NSError *) error contextInfo: (void *) contextInfo { ,,,NSString * message =,零; ,,,if (错误),{ ,,,,,,,message =, @“保存失败”; ,,,},{else ,,,,,,,message =, @“保存成功”; ,,,,,,,(self getAssetsLastPhoto); ,,,} ,,,NSLog(@ % @,,消息); }
, 安康;(空白)loadAssets { ,,,, ,,,//初始化 ,,,_assets =, (NSMutableArray 新); ,,,_assetLibrary =, [[ALAssetsLibrary alloc], init); ,,,, ,,,//,Run 拷贝,background as it takes a while 用get all assets 得到,图书馆 ,,,设置(dispatch_get_global_queue (DISPATCH_QUEUE_PRIORITY_DEFAULT, 0),, ^ { ,,,,,,, ,,,,,,,NSMutableArray * assetGroups =, [[NSMutableArray alloc], init); ,,,,,,,NSMutableArray * assetURLDictionaries =, [[NSMutableArray alloc], init); ,,,,,,, ,,,,,,,//,Process 资产 ,,,,,,,void (^ assetEnumerator) (*, ALAsset 拖延了NSUInteger, BOOL *),=, ^ (ALAsset *结果,NSUInteger 指数,BOOL *停止),{ ,,,,,,,,,,,if (result !=, nil), { ,,,,,,,,,,,,,,,if ([[result valueForProperty: ALAssetPropertyType], isEqualToString: ALAssetTypePhoto]), { ,,,,,,,,,,,,,,,,,,,(assetURLDictionaries addObject: [result valueForProperty: ALAssetPropertyURLs]]; ,,,,,,,,,,,,,,,,,,,NSURL * url =, result.defaultRepresentation.url; null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null进阶篇第九期:相册与拍照的后处理