makePixelBufferAndCGImageFormat(cgImage:pixelFormat:)
Returns a new pixel buffer and Core Graphics image format structure from a Core Graphics image.
Declaration
static func makePixelBufferAndCGImageFormat(cgImage: CGImage, pixelFormat: Format.Type = Format.self) throws -> (pixelBuffer: vImage.PixelBuffer<Format>, cgImageFormat: vImage_CGImageFormat)Parameters
- cgImage:
The source Core Graphics image.
- pixelFormat:
The pixel format of the initialized buffer.
Return Value
A new pixel buffer of type vImage.DynamicPixelFormat and a vImage_CGImageFormat that describes the ordering and number of the color channels, the size and type of the data in the color channels, and whether or not the data is premultiplied by alpha.
Discussion
Use this function where you know the bits per component and bits per pixel of the CGImage instance. These must match those of the buffer’s pixelFormat, otherwise this function returns nil.