2

这真的让我很烦。当我将 UIImage 转换为 CIImage 时,应用过滤器然后转换回图像是倒置的(对于横向)或逆时针旋转 90 度(对于纵向)。

var image:UIImage?
var index:Int?

@IBOutlet weak var photo: UIImageView!

@IBAction func editImage(sender: UIBarButtonItem) {
    println("editImage")
    let beginImage = CIImage(image: self.image)
    let filter = CIFilter(name: "CISepiaTone")
    filter.setValue(beginImage, forKey: kCIInputImageKey)
    filter.setValue(0.8, forKey: kCIInputIntensityKey)
    let newImage = UIImage(CIImage: filter.outputImage)
    self.photo.image = newImage
}
4

1 回答 1

5

将过滤后的图像的图像方向和比例设置回原始值:

let newImage = UIImage(CIImage:filter.outputImage, scale:self.image.scale, orientation:self.image.imageOrientation)
于 2014-11-04T21:25:27.667 回答