简体   繁体   English

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

[英]by using UIImagePickerController, i can crop the picture and also save it in iphone directory?

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

Try this: 尝试这个:

- (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 :("); } }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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