UIImagePickerControllerEditedImage问题

我需要在导入到应用程序之前编辑我的图像但是在编辑图像后降低了一些质量如何避免这种情况?

- (void) imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info { [self dismissModalViewControllerAnimated:YES]; imgEdited.image = [info objectForKey:UIImagePickerControllerEditedImage]; } 

 - (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info { [picker dismissModalViewControllerAnimated:YES]; [picker release]; // Edited image works great (if you allowed editing) myUIImageView.image = [info objectForKey:UIImagePickerControllerEditedImage]; // AND the original image works great myUIImageView.image = [info objectForKey:UIImagePickerControllerOriginalImage]; // AND do whatever you want with it, (NSDictionary *)info is fine now UIImage *myImage = [info objectForKey:UIImagePickerControllerEditedImage]; } 

你可以编辑你的图像。 试试这个它可能适用于您的应用程序。谢谢!

您可以使用通过UIImagePickerControllerCropRect提供的值手动裁剪UIImagePickerControllerCropRect

未经测试的快速和肮脏的例子:

 static UIImage *my_croppedImage(UIImage *image, CGRect cropRect) { UIGraphicsBeginImageContext(cropRect.size); [image drawAtPoint:CGPointMake(-cropRect.origin.x, -cropRect.origin.y)]; UIImage *cropped = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); return cropped; } - (void) imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info { // … UIImage *originalImage = info[UIImagePickerControllerOriginalImage]; CGRect cropRect = [info[UIImagePickerControllerCropRect] CGRectValue]; UIImage *croppedImage = my_croppedImage(originalImage, cropRect); // … } 

质量的降低与您上面提到的代码没有任何关系。 图像质量取决于您在编辑期间对图像执行的操作。 您是否放大并裁剪图像?

好。 这听起来很糟糕。 但是图像质量是否真的很低还是仅仅显示为低质量?

您可能希望将此图像导出到PC并检查其实际质量较低,而不仅仅是将图像显示为低质量。