vImageCVImageFormat_GetColorSpace(_:)
Returns the color space of a Core Video image format.
Declaration
func vImageCVImageFormat_GetColorSpace(_ format: vImageConstCVImageFormat) -> Unmanaged<CGColorSpace>!Parameters
- format:
The Core Video image format to query.
Return Value
The color space of the specified image format.
Discussion
For RGB, indexed, and grayscale images, the color space of a Core Video image format describes the image encoding.
For YpCbCr images, the color space describes the image encoding of the RGB image that’s the result of unapplying the RGB-to-YpCbCr conversion matrix.
The functions that create Core Video image formats, such as vImageCVImageFormat_CreateWithCVPixelBuffer(_:), return a vImageCVImageFormat. The following code shows how you create a vImageConstCVImageFormat representation of a vImageCVImageFormat instance to pass to vImageCVImageFormat_GetColorSpace(_:):
let colorSpace = withUnsafeBytes(of: cvImageFormat) { bytes in
let format = bytes.assumingMemoryBound(
to: vImageConstCVImageFormat.self).first!
return vImageCVImageFormat_GetColorSpace(format)
}