xcode UIImagePickerControllerEditedImage 的问题

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/9904940/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 23:48:23  来源:igfitidea点击:

Issue with UIImagePickerControllerEditedImage

iphoneobjective-ciosxcodeios5

提问by Mc.Lover

I need edit my Images before they import to the app but after editing the image reduces some quality how can avoid this ?

我需要在将图像导入应用程序之前对其进行编辑,但在编辑图像后会降低一些质量,如何避免这种情况?

- (void) imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {

    [self dismissModalViewControllerAnimated:YES];
    imgEdited.image = [info objectForKey:UIImagePickerControllerEditedImage];


}

采纳答案by Kiran

- (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];
}

You can edit ur image. Try this it may work for your application.Thanks!

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

回答by hasseg

You can crop UIImagePickerControllerOriginalImagemanually by using the value provided via UIImagePickerControllerCropRect.

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

Untested quick and dirty example:

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

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);

    // …
}    

回答by AdiTheExplorer

The lowering of quality does not have anything to do with the code you have presented above. The quality of the image depends on what you are doing with your image during editing. Are you zooming in and cropping the image?

质量的降低与您上面提供的代码没有任何关系。图像的质量取决于您在编辑过程中对图像的处理方式。您是否正在放大和裁剪图像?

回答by AdiTheExplorer

Ok. This is going to sound daft. But is the image really low quality or is it just being displayed as low quality?

好的。这听起来很愚蠢。但是图像质量真的很低还是只是显示为低质量?

You may want to export this image to your PC and check its actually low quality rather than just the imageview showing it as low quality.

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