Function

vImageBuffer_Init(_:_:_:_:_:)

Initializes a vImage buffer of a specified size.

Declaration

func vImageBuffer_Init(_ buf: UnsafeMutablePointer<vImage_Buffer>, _ height: vImagePixelCount, _ width: vImagePixelCount, _ pixelBits: UInt32, _ flags: vImage_Flags) -> vImage_Error

Parameters

buf

A valid empty vImage_Buffer structure. On return, all fields are initialized.

height

The height of the image.

width

The width of the image.

pixelBits

The number of bits in a pixel of image data. If pixelBits isn't divisible by 8, vImage pads the scanline out to a multiple of a byte so that two scanlines can't share the same byte, and all scanlines start at the beginning of a byte.

flags

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

kvImageNoFlags

Default behavior.

kvImageNoAllocate

On return, buf->data is initialized to NULL. A preferred alignment suitable for use with posix_memalign(_:_:_:) is returned and buf->rowBytes is set to the preferred rowBytes. A negative value returned by the function represents an error code, not a size.

kvImagePrintDiagnosticsToConsole

Prints a debug message if the operation fails.

Return Value

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

Discussion

This function is a convenience method to help you initialize a vImage_Buffer structure with a buffer sized and is aligned for best performance. It initializes the height, width, and rowBytes fields, and allocates the pixel storage for you. You're responsible for releasing the memory pointed to by buf->data back to the system when you're done with it, using free().

See Also

Initializing vImage Buffers

struct vImage_Buffer

The basic data structure used by vImage functions for passing image data.