通过使用UIImagePickerController,我可以裁剪图片,并将其保存在iPhone目录中?

时间:2011-02-01 06:35:45

标签: iphone

任何人都能告诉我UIIMAGEPICKER如何裁剪图片,并将此裁剪图片保存在iphone目录中,以便在数据库中保存图像的路径并重新使用它?

1 个答案:

答案 0 :(得分:1)

试试这个:

- (void)imagePickerController:(UIImagePickerController *)picker 
didFinishPickingMediaWithInfo:(NSDictionary *)info{ UIImage *img = [info objectForKey:UIImagePickerView.UIImagePickerControllerEditedImage]; //I think that's how you're supposed to get the image. Fiddle with it. img.size = CGSizeMake(x, y); img.scale = 0.75; //scale the image to 75 percent of it's original size. UIImageWriteToSavedPhotosAlbum (*img, self, @selector(photoSaved), nil); } -(void)photoSaved image: (UIImage *) image
didFinishSavingWithError: (NSError *) error
contextInfo: (void *) contextInfo;{ if(!error){ NSLog(@"Photo saved to library!"); } else{ NSLog(@"Saving failed :("); } }