Ios 如何从CGFloat数组创建CIVector?
我正在尝试在Swift中创建Cicross多项式过滤器类型 但是,我不确定如何创建语法来执行此操作 文档指定了一个具有浮点数组的CIVectorIos 如何从CGFloat数组创建CIVector?,ios,xcode,swift,cifilter,unsafe-pointers,Ios,Xcode,Swift,Cifilter,Unsafe Pointers,我正在尝试在Swift中创建Cicross多项式过滤器类型 但是,我不确定如何创建语法来执行此操作 文档指定了一个具有浮点数组的CIVector A CIVector object whose display name is RedCoefficients. Default value: [1 0 0 0 0 0 0 0 0 0] Identity: [1 0 0 0 0 0 0 0 0 0] 但我该如何声明这样一个CIVector呢?有一个构造函数具有此签名 CIVector(values
A CIVector object whose display name is RedCoefficients.
Default value: [1 0 0 0 0 0 0 0 0 0] Identity: [1 0 0 0 0 0 0 0 0 0]
但我该如何声明这样一个CIVector呢?有一个构造函数具有此签名
CIVector(values: <UnsafePointer<CGFloat>>, count: <UInt>)
CIVector(值:,计数:)
但是当我尝试的时候
var floatArr:Array<CGFloat> = [1,0,0,0,0,0,0,0,0]
var vector = CIVector(values: floatArr, count: floatArr.count)
var floatArr:Array=[1,0,0,0,0,0,0]
var vector=CIVector(值:floatArr,计数:floatArr.count)
我得到一个错误:
Cannot invoke 'init' with an argument list type (values: @lvaue Array<CGFloat>, count:Int)
无法使用参数列表类型调用“init”(值:@lvaue数组,计数:Int)
您知道如何正确地创建带有CGfloat数组的CIVector吗?
floatArr.count
的类型为Int
,但count:
参数的类型为UInt
,
因此,您需要显式转换它:
let floatArr: [CGFloat] = [1,0,0,0,0,0,0,0,0]
var vector = CIVector(values: floatArr, count: UInt(floatArr.count))