这真让我烦恼。当我将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
}
答案 0 :(得分:5)
将滤镜图像的图像方向和比例设置回原始值:
let newImage = UIImage(CIImage:filter.outputImage, scale:self.image.scale, orientation:self.image.imageOrientation)