Function

vImageCreateCGImageFromBuffer(_:_:_:_:_:_:)

Creates a Core Graphics image from a vImage buffer.

Declaration

func vImageCreateCGImageFromBuffer(_ buf: UnsafePointer<vImage_Buffer>, _ format: UnsafePointer<vImage_CGImageFormat>, _ callback: ((UnsafeMutableRawPointer?, UnsafeMutableRawPointer?) -> Void)!, _ userData: UnsafeMutableRawPointer!, _ flags: vImage_Flags, _ error: UnsafeMutablePointer<vImage_Error>!) -> Unmanaged<CGImage>!

Parameters

buf

The source vImage_Buffer structure.

format

The image format of buf. If format->colorspace is NULL, sRGB is used. The colorspace is retained as needed by the new Core Graphics image.

callback

A callback that destorys the buf->data when the returned image no longer needs it. This callback is used in no-copy mode; that is, when kvImageNoAllocate is passed to flags. It can be called at any time, from any thread, and can be called before vImageCreateCGImageFromBuffer(_:_:_:_:_:_:) returns.

userData

The value to pass to the callback function's userData parameter.

flags

The options to use when performing this operation. The following flags are supported:

kvImageNoAllocate

Instructs the function to run in no-copy mode. Ownership of the memory that buf->data points to is transferred to the returned CGImage. In this mode, you need to specify the callback and userData parameters.

kvImagePrintDiagnosticsToConsole

Prints a debug message if the operation fails.

kvImageHighQualityResampling

Determines whether Lanczos3 or Lanczos5 resampling is used if the image is resampled during creation.

kvImageDoNotTile

Disables multithreading in any conversions needed.

Return Value

kvImageNoError; otherwise, one of the error codes described in Data Types and Constants.

Beta Software

This documentation contains preliminary information about an API or technology in development. This information is subject to change, and software implemented according to this documentation should be tested with final operating system software.

Learn more about using Apple's beta software