0

我正在尝试管理图像旋转imagePickerController: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°。

任何想法?

4

2 回答 2

1

看看这个: http: //www.catamount.com/blog/1015/uiimage-extensions-for-cutting-scaling-and-rotating-uiimages/

打电话

UIImage *rotatedImage = [originalImage imageRotatedByDegrees:180.0];

资源

于 2013-05-07T09:24:05.897 回答
0

UploadView.DataToUpload = [UIImage imageWithCGImage:[image CGImage] scale:1.0orientation : UIImageOrientationDown];

用于 180 度旋转。

于 2013-05-07T08:52:59.587 回答