Contents

CVImageBufferCreateColorSpaceFromAttachments(_:)

Attempts to create a Core Graphics color space from the image buffer’s attachments that you specify.

Declaration

func CVImageBufferCreateColorSpaceFromAttachments(_ attachments: CFDictionary) -> Unmanaged<CGColorSpace>?

Parameters

  • attachments:

    The dictionary of attachments for an image buffer, which you can obtain by calling Cvbuffercopyattachments(_:_:) on the image buffer.

Return Value

A CGColorSpace object that represents the color space of the image buffer, or nil if the dictionary doesn’t contain the information required to create a CGColorSpace instance.

Discussion

To generate a CGColorSpace instance, the attachments dictionary needs to include values for either:

  1. kCVImageBufferICCProfileKey

  2. kCVImageBufferColorPrimariesKey, kCVImageBufferTransferFunctionKey, kCVImageBufferYCbCrMatrixKey, and possibly kCVImageBufferGammaLevelKey

Use CGColorSpaceRelease to release the color space when you’re done with it.