【问题标题】:CIFilter Rotates UIImage in SwiftCIFilter 在 Swift 中旋转 UIImage
【发布时间】:2015-05-12 14:08:53
【问题描述】:
【问题讨论】:
标签:
objective-c
swift
cifilter
【解决方案1】:
这个怎么样(image 是你的UIImage):
let ciImage = CIImage(image: image)?.imageByApplyingOrientation(imageOrientationToTiffOrientation(image.imageOrientation))
func imageOrientationToTiffOrientation(value: UIImageOrientation) -> Int32
{
switch (value)
{
case UIImageOrientation.Up:
return 1
case UIImageOrientation.Down:
return 3
case UIImageOrientation.Left:
return 8
case UIImageOrientation.Right:
return 6
case UIImageOrientation.UpMirrored:
return 2
case UIImageOrientation.DownMirrored:
return 4
case UIImageOrientation.LeftMirrored:
return 5
case UIImageOrientation.RightMirrored:
return 7
}
}