vImageOverwriteChannelsWithScalar_Planar16S(_:_:_:)
Overwrites a signed 16-bit planar buffer with the specified scalar value in place.
Declaration
func vImageOverwriteChannelsWithScalar_Planar16S(_ scalar: Pixel_16S, _ dest: UnsafePointer<vImage_Buffer>, _ flags: vImage_Flags) -> vImage_ErrorParameters
- scalar:
The scalar value that provides the new pixel values.
- 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.
- 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 pixelBuffer with scalar:
var buffer = vImage_Buffer()
vImageBuffer_Init(&buffer,
1, 4,
16,
vImage_Flags(kvImageNoFlags))
defer {
buffer.data.deallocate()
}
let scalar: Pixel_16S = 101
vImageOverwriteChannelsWithScalar_Planar16S(scalar,
&buffer,
vImage_Flags(kvImageNoFlags))
let pixelValues = UnsafeMutableBufferPointer(
start: buffer.data.assumingMemoryBound(to: Pixel_16S.self),
count: 4)
// Prints "[101, 101, 101, 101]".
print(Array(pixelValues))See Also
Overwriting with scalar values
vImageOverwriteChannelsWithScalar_Planar8(_:_:_:)vImageOverwriteChannelsWithScalar_Planar16U(_:_:_:)vImageOverwriteChannelsWithScalar_Planar16F(_:_:_:)vImageOverwriteChannelsWithScalar_PlanarF(_:_:_:)vImageOverwriteChannelsWithScalar_ARGB8888(_:_:_:_:_:)vImageOverwriteChannelsWithScalar_ARGBFFFF(_:_:_:_:_:)