overwriteChannels(_:withScalar:destination:)
Overwrites the pixels of one or more channels of the pixel buffer with the provided 8-bit scalar value.
Declaration
func overwriteChannels(_ channels: [UInt8], withScalar scalar: Pixel_8, destination: vImage.PixelBuffer<Format>)Parameters
- channels:
An array that contains the indices of the channels that the function overwrites.
- scalar:
The value that the function writes to the channels.
- destination:
The destination pixel buffer.
Discussion
Use this function to overwrite one or more channels of an interleaved buffer with a scalar value. The following code overwrites channels 1 and 3 with the value 99:
let pixelValues: [Pixel_8] = [ 1, 2, 3, 4,
5, 6, 7, 8 ]
let buffer = vImage.PixelBuffer(pixelValues: pixelValues,
size: vImage.Size(width: 1,
height: 2),
pixelFormat: vImage.Interleaved8x4.self)
let destination = vImage.PixelBuffer(size: vImage.Size(width: 1,
height: 2),
pixelFormat: vImage.Interleaved8x4.self)
buffer.overwriteChannels([3, 1],
withScalar: 99,
destination: destination)On return, destination.array contains the following values:
[ 1, 99, 3, 99,
5, 99, 7, 99 ]See Also
Overwriting Channels
overwriteChannels(withScalar:)overwriteChannels(withScalar:)overwriteChannels(withScalar:)overwriteChannels(_:withScalar:destination:)overwriteChannels(_:withPixel:destination:)overwriteChannels(_:withPixel:destination:)overwriteChannels(_:withPixel:destination:)overwriteChannels(_:withPlanarBuffer:destination:)overwriteChannels(_:withPlanarBuffer:destination:)overwriteChannels(_:withInterleavedBuffer:destination:)overwriteChannels(_:withInterleavedBuffer:destination:)