我正在用 Swift 编写一个函数,它vImage_CGImageFormat从 a创建 aCGImage如下:
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))
Run Code Online (Sandbox Code Playgroud)
然而,这不会编译。这是因为CGImageGetColorSpace(image)回报CGColorSpace!与上述构造只需要Unmanaged<CGColorSpace>为colorSpace参数。
有没有另一种方法可以做到这一点?也许转换CGColorSpace成Unmanaged<CGColorSpace>?