小编fye*_*ell的帖子

你如何从 CGColorSpace 获得 Unmanaged<CGColorSpace> ?

我正在用 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参数。

有没有另一种方法可以做到这一点?也许转换CGColorSpaceUnmanaged<CGColorSpace>?

core-graphics ios swift vimage

1
推荐指数
1
解决办法
758
查看次数

标签 统计

core-graphics ×1

ios ×1

swift ×1

vimage ×1