Iphone 旋转具有UIImageOrientationRight方向的纵向UIImage

Iphone 旋转具有UIImageOrientationRight方向的纵向UIImage,iphone,objective-c,rotation,uiimage,uiimageorientation,Iphone,Objective C,Rotation,Uiimage,Uiimageorientation,大家好, 我在旋转方向等于UIImageOrientationRight的肖像UIImage(即WIDTH

大家好,

我在旋转方向等于
UIImageOrientationRight
的肖像
UIImage
(即
WIDTH
)时遇到问题。我不知道这是怎么回事,但我的图书馆里有一些用iPhone4拍摄的图片

这是我的代码(只有当方向等于UIImageOrientationUp时,才起作用):

UIGraphicsBeginImageContextWithOptions(rotatedScaledRect.size,NO,0.0);
CGContextRef myContext=UIGraphicsGetCurrentContext();
CGContextSetInterpolationQuality(myContext,kCGInterpolationHigh);
CGContextTranslateCm(myContext,
(旋转缩放截面尺寸宽度/2),
(旋转标度精确尺寸高度/2));
CGContextConcatCTM(myContext,转换);
CGContextScaleCTM(myContext,1.0,-1.0);
CGContextDrawImage(myContext,CGRectMake(-roundf(newImage.size.width/2)、-roundf(newImage.size.height/2)、newImage.size.width、newImage.size.height、[newImage-CGImage]);
newImage=UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsSendImageContext();
我需要应用
CGContextConcatCTM
,因为我对图像进行了几个串联转换

我试过几种不同的方法,但都没有用


首先,请原谅我的英语,因为它不是我的母语。我希望现在回答这个问题还不算太晚

由于这个原因,我在从图书馆下载用iPhone或iPod cammera拍摄的照片时遇到了类似的问题。如果是你的情况,你可以在这里找到一些信息:,特别是从一个回答中,回答是“苹果选择使用EXIF数据中的方向标志来通知显示图像的程序如何旋转图像,以便正确显示图像。”

因此,要从iPhone Cammera拍摄的照片库中加载照片,您必须执行以下操作:

ALAssetRepresentation *assetRep = [photo defaultRepresentation];
CGImageRef imageRef = [assetRep fullResolutionImage];
UIImage *image = [UIImage imageWithCGImage:imageRef scale:[assetRep scale] orientation:[assetRep orientation]];
其中photo是从库中获取的一个对象


嗯,我希望这有帮助

我也有同样的问题,如果图像方向不是euqal到0,这个脚本就不起作用。这个问题有一个解决方案,其中还包括对实际发生的情况的详细解释。