将滤镜应用于UIImage时,结果颠倒了 [英] When applying a filter to a UIImage the result is upside down
本文介绍了将滤镜应用于UIImage时,结果颠倒了的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这真让我讨厌。当我将UIImage转换为CIImage时,应用过滤器,然后将图像上下颠倒(对于风景)或逆时针旋转90度(对于肖像)。
This is really annoying me. When I convert a UIImage to a CIImage, apply a filter then convert back the image is upside down (for landscape) or rotated anticlockwise 90 degrees (for portrait).
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
}
推荐答案
将已过滤图像的图像方向和比例设置回原始值:
Set the image orientation and scale of the filtered image back to the original values:
let newImage = UIImage(CIImage:filter.outputImage, scale:self.image.scale, orientation:self.image.imageOrientation)
这篇关于将滤镜应用于UIImage时,结果颠倒了的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文