I am writing a function in Swift that creates a vImage_CGImageFormat
from a CGImage
as follows:
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))
This doesn't compile however. That's because CGImageGetColorSpace(image)
returns CGColorSpace!
and the above constructor only takes Unmanaged<CGColorSpace>
for the colorSpace
parameter.
Is there another way to do this? Perhaps converting CGColorSpace
into Unmanaged<CGColorSpace>
?