【发布时间】:2019-01-31 12:11:02
【问题描述】:
我正在尝试制作基于金属的 CIFilter,因为 Apple 似乎更喜欢您使用它,但我遇到了问题,因为我需要合并多个可能大小不同的图像。这意味着我必须使用标准化坐标和采样器来“拉伸”各种输入图像。
这是一个内核示例:
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
就好像采样器在内核函数中被视为四个单独的参数,但我只能将它们作为一个传递。我是否使用正确的类将图像传递到内核?内核声明有问题吗?我是否可以使用其他方法为我的各种图像获取归一化坐标和采样器?
【问题讨论】: