vImageOverwriteChannelsWithScalar_ARGBFFFF(_:_:_:_:_:)
Overwrites the selected channels of a 32-bit-per-channel, 4-channel interleaved buffer with the specified scalar value.
Declaration
func vImageOverwriteChannelsWithScalar_ARGBFFFF(_ scalar: Pixel_F, _ src: UnsafePointer<vImage_Buffer>, _ dest: UnsafePointer<vImage_Buffer>, _ copyMask: UInt8, _ flags: vImage_Flags) -> vImage_ErrorParameters
- scalar:
The scalar value that provides the new channel values.
- src:
The source vImage buffer that provides the original 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.
- copyMask:
A bitmask that specifies the channel or channels that the function overwrites with the scalar value. The value
0x8represents channel0, the value0x4represents channel1, the value0x2represents channel2, and the value0x1represents channel3. - 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 overwrites channel 0 of the source pixels in pixelBuffer with the scalar value:
let pixelBuffer = vImage.PixelBuffer<vImage.InterleavedFx4>(
pixelValues: [10, 20, 30, 40,
50, 60, 70, 80],
size: .init(width: 1, height: 2))
let scalar: Pixel_F = 101
pixelBuffer.withUnsafePointerToVImageBuffer { buf in
_ = vImageOverwriteChannelsWithScalar_ARGBFFFF(scalar,
buf,
buf,
0x8,
vImage_Flags(kvImageNoFlags))
}
// Prints:
// "[101.0, 20.0, 30.0, 40.0,
// 101.0, 60.0, 70.0, 80.0]"
print(pixelBuffer.array)See Also
Overwriting with scalar values
vImageOverwriteChannelsWithScalar_Planar8(_:_:_:)vImageOverwriteChannelsWithScalar_Planar16U(_:_:_:)vImageOverwriteChannelsWithScalar_Planar16S(_:_:_:)vImageOverwriteChannelsWithScalar_Planar16F(_:_:_:)vImageOverwriteChannelsWithScalar_PlanarF(_:_:_:)vImageOverwriteChannelsWithScalar_ARGB8888(_:_:_:_:_:)