iOS UIImagePickerController result image orientation after upload

后端 未结 20 1997
长发绾君心
长发绾君心 2020-11-22 00:44

I am testing my iPhone application on an iOS 3.1.3 iPhone. I am selecting/capturing an image using a UIImagePickerController:

UIImagePickerCont         


        
20条回答
  •  挽巷
    挽巷 (楼主)
    2020-11-22 01:04

    I used this page when designing my app that takes pictures and I found that the following method will correct the orientation and use less memory and processor than previous answers:

    CGImageRef cgRef = image.CGImage;
    image = [[UIImage alloc] initWithCGImage:cgRef scale:1.0 orientation:UIImageOrientationUp];
    

    This basically just rewraps the actual image data with a new orientation. I was using @an0's code but it makes a new image in memory which can be taxing on a 3264x2448 image that you might get from a camera.

提交回复
热议问题