2012-03-28 25 views
5

我需要編輯我的圖像之前,他們導入到應用程序,但編輯後的圖像降低一些質量如何可以避免這種情況?問題與UIImagePickerControllerEditedImage

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

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


} 
+0

你找到如何解決降低圖像的質量對其進行編輯後的問題? – Sawsan 2013-06-04 14:04:36

回答

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

您可以編輯烏爾圖像。試試這可能適用於您的應用程序。謝謝!

+2

謝謝,但並沒有解決我的問題!我認爲你不明白我的問題 – 2012-03-28 10:22:51

0

質量的降低沒有任何與你在上面給出的代碼。圖像的質量取決於您在編輯過程中對圖像所做的操作。你是否在放大和裁剪圖像?

+1

沒有任何裁剪或縮放結果是一樣的! – 2012-03-28 13:52:36

0

好的。這聽起來很愚蠢。但是,圖像是否真的低質量,還是隻是低質量顯示?

你可能想這個圖像導出到PC,並檢查其實際的低質量,而不是僅僅顯示它爲低質量的ImageView的。

4

您可以使用通過UIImagePickerControllerCropRect提供的值手動裁剪UIImagePickerControllerOriginalImage

未經測試的快速和骯髒的例子:

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

    // … 
}