我正在将CIFilter应用于图像,但在应用滤镜后会旋转。我在objective-c中找到了一个解决方案here,我怎么能在swift中做到这一点?我的代码如下。
let originalImage = CIImage(image: cameraStill.image)
var filter = CIFilter(name: "CIPhotoEffect"+x)
filter.setDefaults()
filter.setValue(originalImage, forKey: kCIInputImageKey)
var outputImage = filter.outputImage
var newImage = UIImage(CIImage: outputImage)
v.setImage(newImage, forState: .Normal)
答案 0 :(得分:0)
以下代码对我来说很好:
var image = UIImage(named: "Turtle")
let ciImage = CIImage(image: image)
let filter = CIFilter(name: "CISepiaTone")
filter.setValue(ciImage, forKey: kCIInputImageKey)
filter.setValue(1.5, forKey: kCIInputIntensityKey)
let newImage = UIImage(CIImage: filter.outputImage)
let imageView = UIImageView(image: newImage)
self.view.addSubview(imageView)
让我知道你怎么走。