我正在尝试制作基于 Metal 的 CIFilter,因为 Apple 似乎更喜欢您使用它,但我遇到了问题,因为我需要合并多个可能大小不同的图像。这意味着我必须使用标准化坐标和采样器来“拉伸(stretch)”各种输入图像。
这是一个示例内核:
extern "C" { namespace coreimage {
float4 stretchKernel(
sampler image
) {
return image.sample(image.coord());
}
}}
...我像这样实现它:
let arguments: [Any] = [
CISampler(image: startingImage, options: samplerOptions)
]
return kernel.apply(extent: startingImage.extent, arguments: arguments)
现在奇怪的一点。如果我运行它,我会收到以下错误:
Argument info count 1 for function composition does not match argument count 4 in declaration of function
就好像采样器在内核函数中被视为四个单独的参数,但我只能将它们作为一个传递。我是否使用正确的类将图像传递到内核?内核声明有问题吗?我是否可以使用其他方法为我的各种图像获取标准化坐标和采样器?
最佳答案
好吧,我不知道为什么我无法从文档中找到这个,但原因似乎是 filter
类型与 CIColorKernel
不兼容.我敢说有一个很好的理由,但我不知道为什么没有更明确地说明。解决方法是使用普通的CIKernel
反而。
关于ios - 如何将 CISampler 传递给基于 Metal 的 CIColorKernel?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54460317/