【发布时间】:2015-03-27 09:50:42
【问题描述】:
我正在尝试更改图像的方向 (CIImage *myImage),但它看起来没有任何效果。
CIImage *myImage2 = [myImage imageByApplyingOrientation:kCGImagePropertyOrientationUp];
我还尝试了其他方法:
CIImage *myImage2 = [myImage imageByApplyingOrientation:[@"1" intValue]];
CIImage *myImage2 = [myImage imageByApplyingTransform:[myImage imageTransformForOrientation:[@"5" intValue]]];
当我试图找出方向是否改变时:
NSLog(@"Image orientation %@",[[myImage properties] valueForKey:kCGImagePropertyOrientation]);
我得到“空”。也尝试将“myImage2”保存到新图像,但打开后没有效果。看来“imageByApplyingOrientation”方法根本不起作用。
【问题讨论】:
-
有问题的图像是否附加到 UIImageView?否则,将难以跟踪方向。我也许会检查宽度和高度;如果宽度 > 高度,您可以假设图像是横向的,反之亦然。
-
它没有附加到 UIImageView。方向是图像的一个属性,因此,也许它应该与图像本身绑定。
标签: objective-c macos ciimage