我使用以下代码从相册中获取图片:
-(IBAction) getPhoto:(id) sender {
UIImagePickerController * picker = [[UIImagePickerController alloc] init];
picker.delegate = self;
picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
[self presentViewController:picker animated:YES completion:nil];}
-(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
[picker dismissViewControllerAnimated:YES completion:nil];
imageView.image = [info objectForKey:@"UIImagePickerControllerOriginalImage"];}
请有人帮我分配这个图像到变量吗?我想稍后使用stackblur来模糊它:
UIImage *newIma=[oldIma stackBlur:radius];
提前致谢!
答案 0 :(得分:1)
在您获取用户选择的图像时设置UIImage
。
-(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
[picker dismissViewControllerAnimated:YES completion:nil];
// Create the UIImage in your @implementation and set it here
myImage = [info objectForKey:@"UIImagePickerControllerOriginalImage"];
myImageView.image = myImage;
}