我正在用 Swift 编写一个vImage_CGImageFormat
从 a创建 a 的函数,CGImage
如下所示:
vImage_CGImageFormat(
bitsPerComponent: UInt32(CGImageGetBitsPerComponent(image)),
bitsPerPixel: UInt32(CGImageGetBitsPerPixel(image)),
colorSpace: CGImageGetColorSpace(image),
bitmapInfo: CGImageGetBitmapInfo(image),
version: UInt32(0),
decode: CGImageGetDecode(image),
renderingIntent: CGImageGetRenderingIntent(image))
但是,这不会编译。那是因为CGImageGetColorSpace(image)
returnCGColorSpace!
和上面的构造函数只接受Unmanaged<CGColorSpace>
参数colorSpace
。
还有另一种方法可以做到这一点吗?也许转换CGColorSpace
成Unmanaged<CGColorSpace>
?