I am trying to create a CIColorClampFilter https://developer.apple.com/library/mac/documentation/GraphicsImaging/Reference/CoreImageFilterReference/index.html#//apple_ref/doc/filter/ci/CIColorClamp
It says I can set a key for "inputMinComponents" as a [0,0,0,0] or whatever RGB values I want.
But this code:
filter = CIFilter(name:"CIColorClamp")
filter.setValue(ciImage, forKey: kCIInputImageKey)
filter.setValue([0,0,0,0], forKey: "inputMinComponents")
Causes this error:
CI internal error, type mismatch between kernel parameter 1 and argument
I've look around for other CIColorClamp examples but found nothing.
Do you know whats wrong with the value I'm trying to pass for the "inputMinComponents" key?
Apparently swift's smart casting does not work you must explcitly create a CIVector
filter = CIFilter(name:"CIColorClamp")
filter.setValue(ciImage, forKey: kCIInputImageKey)
var lowerLevel = CIVector(x: 0.1, y: 0.1, z: 0.3, w: 0)
filter.setValue(lowerLevel, forKey: "inputMinComponents")
var upperLevel = CIVector(x: 0.5, y: 0.7, z: 0.9, w: 1)
filter.setValue(upperLevel, forKey: "inputMaxComponents")