CI内部错误,内核参数1和参数之间的类型不匹配

时间:2014-11-03 22:42:33

标签: xcode uiimage core-graphics core-image cifilter

我正在尝试创建一个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"的价值是怎么回事?键?

1 个答案:

答案 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")