vImageBufferFill_ARGB16F(_:_:_:)
Fills a floating-point 16-bit-per-channel, 4-channel interleaved buffer with a specified color.
Declaration
func vImageBufferFill_ARGB16F(_ dest: UnsafePointer<vImage_Buffer>, _ color: UnsafePointer<UInt16>, _ flags: vImage_Flags) -> vImage_ErrorParameters
- dest:
A pointer to the destination vImage buffer structure. You’re responsible for filling out the Height, Width, and Rowbytes fields of this structure, and for allocating a data buffer of the appropriate size. On return, the data buffer this structure points to contains the destination image data. When you no longer need the data buffer, deallocate the memory to prevent memory leaks.
- color:
The fill color.
- flags:
The options to use when performing the operation. If your code implements its own tiling or its own multithreading, pass Kvimagedonottile; otherwise, pass Kvimagenoflags.
Return Value
kvImageNoError; otherwise, one of the error codes in Data Types and Constants.
Discussion
The following code fills the buffer with the specified color:
let pixelBuffer = vImage.PixelBuffer<vImage.Interleaved16Fx4>(
size: .init(width: 1, height: 2))
let fillColor: [Pixel_16F] = [64, 127, 192, 255]
pixelBuffer.withUnsafePointerToVImageBuffer { buf in
_ = vImageBufferFill_ARGB16F(buf,
fillColor,
vImage_Flags(kvImageNoFlags))
}
print(pixelBuffer.array)
// Prints:
// "[64, 127, 192, 255,
// 64, 127, 192, 255]"