应用CIFilter后图像旋转



我对图像应用了一个CIFilter,但是在应用过滤器后它会旋转。我在objective-c中找到了解决方案,如何在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)

下面的代码对我来说很好:

    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)

相关内容

  • 没有找到相关文章

最新更新