Issue with UIImagePickerControllerEditedImage

前端 未结 4 1803
野的像风
野的像风 2021-01-01 02:32

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:(UI         


        
相关标签:
4条回答
  • 2021-01-01 02:39

    You can crop UIImagePickerControllerOriginalImage manually by using the value provided via 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);
    
        // …
    }    
    
    0 讨论(0)
  • 2021-01-01 02:49

    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.

    0 讨论(0)
  • 2021-01-01 02:54
    - (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!

    0 讨论(0)
  • 2021-01-01 02:59

    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?

    0 讨论(0)
提交回复
热议问题