0
这行代码没有效果。它不会改变图像的方向。我究竟做错了什么?UIImage不改变方向
// image is of type UIImage
UIImage * newImage = [UIImage imageWithCGImage:[image CGImage] scale:image.scale orientation:UIImageOrientationLeft];
这行代码没有效果。它不会改变图像的方向。我究竟做错了什么?UIImage不改变方向
// image is of type UIImage
UIImage * newImage = [UIImage imageWithCGImage:[image CGImage] scale:image.scale orientation:UIImageOrientationLeft];
请参考下面这个方法的定义,确保你的CGImage是一个CGImageRef类。 imageWithCGImage:[image CGImage]
+(UIImage的*)imageWithCGImage:(CGImageRef)imageRef规模:(CGFloat的)规模取向:(UIImageOrientation)定向
以下三行一些初始化调用方法之前。
CIContext * context = [CIContext contextWithOptions:nil]; //your choice
CIImage * OriginalImage = [CIImage imageWithContentsOfURL:fileNameAndPath]; //your own choice of source image file.
CGImageRef CGImage = [context createCGImage:OriginalImage fromRect:(CGRect)];
UIImage *newImage = [UIImage imageWithCGImage:CGImage scale:1.0 orientation:UIImageOrientationLeft]
希望这会有所帮助。
此答案对您有用:http://stackoverflow.com/questions/5427656/ios-uiimagepickercontroller-result-image-orientation-after-upload/5427890#5427890 它工作正常。 – kaspartus
谢谢,它有帮助。 – kal21