2011-05-18 39 views
0

製作一個應用程序,我們希望將照片發送到服務器以及一些表單數據。圖片非常龐大,需要上傳,我們確實不需要網站上的像素信息。有什麼方法可以調整圖像大小(來自相機或圖庫),以便我們只將更小的圖像發送到網絡空間?這在Android中很容易實現,但我們正在努力爲iPhone尋找簡單的解決方案。在發送到服務器之前調整iPhone中的照片大小

回答

1

請參閱Resize a UIImage the right way調整代碼和討論。要選擇圖像,你可以做

// select image 
UIImagePickerController *picker = [UIImagePickerController new]; 
picker.delegate = self; 
picker.allowsEditing = YES; 
[yourViewController presentModalViewController:picker]; 

// delegate method 
- (void) imagePickerController:(UIImagePickerController *)picker 
didFinishPickingMediaWithInfo:(NSDictionary *)info { 
    UIImage *image = [info objectForKey:UIImagePickerControllerEditedImage]; 
} 
+0

+1 「調整一個UIImage正確的方式」。這是一個真正的圖像調整大小教程,完成與(優秀)代碼來採取和使用。 – 2011-05-18 20:38:20

0

WWDC 2010會話N104涵蓋了大部分問題。有一個滾動視圖,但是其中描述的方法可以在你的任務中使用。

0

在的UIImage:

+ (UIImage *)imageWithCGImage:(CGImageRef)imageRef scale:(CGFloat)scale orientation:(UIImageOrientation)orientation 

只是皮毛出了個主意......

UIImage smallerImage = [[ UIImage imageWithCGImage: biggerImage.CGImage scale: 0.1 orientation: orient 
相關問題