我正在尝试创建一个CIColorClampFilter https://developer.apple.com/library/mac/documentation/GraphicsImaging/Reference/CoreImageFilterReference/index.html#//apple_ref/doc/filter/ci/CIColorClamp
它说我可以为" inputMinComponents"设置密钥。作为[0,0,0,0]或我想要的任何RGB值。
但是这段代码:
filter = CIFilter(name:"CIColorClamp")
filter.setValue(ciImage, forKey: kCIInputImageKey)
filter.setValue([0,0,0,0], forKey: "inputMinComponents")
导致此错误:
CI internal error, type mismatch between kernel parameter 1 and argument
我已经四处查看其他CIColorClamp示例,但一无所获。
你知道我试图通过" inputMinComponents"的价值是怎么回事?键?
答案 0 :(得分:2)
显然,快速的智能投射不起作用你必须创造一个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")