我試圖管理圖像旋轉imagePickerController:didFinishPickingMediaWithInfo
,但經過多次嘗試,我沒有找到任何解決方案。我最後的嘗試是:didFinishPickingMediaWithInfo方向問題
-(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
// load the storyboard by name
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:[ApplicationSupport getStoryBoardName] bundle:nil];
UploadViewController *uploadView = [storyboard instantiateViewControllerWithIdentifier:@"ViewUploadFile"];
UIImage *image = [info valueForKey:UIImagePickerControllerOriginalImage];
NSDictionary *metadataImage = [info valueForKey:UIImagePickerControllerMediaMetadata];
uploadView.imageToUpload = image;
if([[metadataImage objectForKey:@"Orientation"] intValue] == 3) {
UIImage *imageRotated = [UIImage imageWithCGImage:[image CGImage] scale:[image scale] orientation:UIImageOrientationDown];
uploadView.dataToUpload = UIImagePNGRepresentation(imageRotated);
} else {
uploadView.dataToUpload = UIImagePNGRepresentation(image);
}
// ETC...
}
我不能和我不想使用JPEGRepresentation
。當iPad處於特定位置時,我需要將照片旋轉180°。
任何想法?
你嘗試使用UIImageOrientationLeft或UIImageOrientationRight代替的承。它旋轉嗎? – Bonnie 2013-05-07 08:45:15
經過幾次嘗試,我明白我不想改變方向「標誌」。我需要「物理」旋轉我的圖像。所以我試過這個: 'UIGraphicsBeginImageContext(image.size); CGContextRef context = UIGraphicsGetCurrentContext(); CGContextRotateCTM(context,(90 * M_PI/180)); [image drawAtPoint:CGPointMake(0,0)]; UIImage * imageRotated = UIGraphicsGetImageFromCurrentImageContext(); uploadView.dataToUpload = UIImagePNGRepresentation(imageRotated);' 但它回到我的空白圖像... – ApheX 2013-05-07 09:21:41