【发布时间】:2012-12-19 23:05:31
【问题描述】:
大家好,
我在旋转某个方向等于UIImageOrientationRight 的肖像UIImage(即WIDTH < HEIGHT)时遇到问题。我不确定这是怎么回事,但它发生在我的库中用 iPhone 4 拍摄的几张图片上。
这是我的代码(确实工作,但前提是方向等于UIImageOrientationUp):
UIGraphicsBeginImageContextWithOptions(rotatedScaledRect.size, NO, 0.0);
CGContextRef myContext = UIGraphicsGetCurrentContext();
CGContextSetInterpolationQuality(myContext, kCGInterpolationHigh);
CGContextTranslateCTM(myContext,
(rotatedScaledRect.size.width/2),
(rotatedScaledRect.size.height/2));
CGContextConcatCTM(myContext, transformation);
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();
UIGraphicsEndImageContext();
我需要申请CGContextConcatCTM,因为我对图像进行了多个级联转换。
我尝试了几种不同的方法都无济于事。
提前感谢您的帮助。
【问题讨论】:
-
我有同样的问题,如果图像方向不等于 0,则此脚本不起作用
-
这个问题的解决方案here 还包括对实际情况的冗长解释。
标签: iphone objective-c rotation uiimage uiimageorientation