【问题标题】:CIFilter Rotates UIImage in SwiftCIFilter 在 Swift 中旋转 UIImage
【发布时间】:2015-05-12 14:08:53
【问题描述】:

应用 CIFilter 后,UIImage 正在旋转 90 度。我很惊讶这个问题在这么多年后仍然发生。是否有这些修复的快速版本:

更好的修复: iOS UIImagePickerController result image orientation after upload

原始修复: Using CoreImage to filter an image results in image rotation

【问题讨论】:

标签: 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
    }
}

【讨论】:

  • 苹果是如何让这种质量进入他们的库的。我很惊讶!
猜你喜欢
  • 1970-01-01
  • 2017-01-04
  • 2017-08-18
  • 1970-01-01
  • 2021-08-04
  • 2016-08-24
  • 2018-01-29
  • 2016-04-01
  • 1970-01-01
相关资源
最近更新 更多