2
如何爲照片添加多種效果?我有以下代碼,增加了一張照片的效果:爲照片添加多種效果
func applyEffects(name: String, n: Float) {
filter.setValue(self.cImage, forKeyPath: kCIInputImageKey)
filter.setValue(n, forKeyPath: name)
let result = filter.value(forKey: kCIOutputImageKey) as! CIImage
let cgImage = CIContext.init(options: nil).createCGImage(result, from: result.extent)
self.customImage = UIImage.init(cgImage: cgImage!)
}
func brightness(n: Float) {
self.applyEffects(name: kCIInputBrightnessKey, n: n)
}
func contrast(n: Float) {
self.applyEffects(name: kCIInputContrastKey, n: n)
}
func saturation(n: Float) {
self.applyEffects(name: kCIInputSaturationKey, n: n)
}
但是,當我想應用第二個效果,第一個消失。我如何疊加兩個或更多的效果?
謝謝。我可以在UIViewController中使用GLKView嗎? – nik3212
我這樣做。 GLKViews是UIView的一個子類。 https://www.objc.io/issues/21-camera-and-photos/core-image-intro/ CoreImage上的這篇文章的頂部是指向使用它的GitHub的鏈接。大約一半(使用OpenGL提高性能)對於如何使用它來說是一個很好的解釋。 – dfd