permuteChannels(to:destination:)
Permutes the channels of an 32-bit-per-channel, 4-channel interleaved pixel buffer.
Declaration
func permuteChannels(to permuteMap: (UInt8, UInt8, UInt8, UInt8), destination: vImage.PixelBuffer<Format>)Parameters
- permuteMap:
A tuple of four 8-bit integers with the values 0, 1, 2, and 3, in some order.
- destination:
The destination pixel buffer.
Discussion
For example, the following code reverses the channel ordering of a pixel buffer:
let buffer = vImage.PixelBuffer<vImage.InterleavedFx4>(
pixelValues: [0.1, 0.2, 0.3, 0.4],
size: vImage.Size(width: 1,
height: 1))
buffer.permuteChannels(to: (3, 2, 1, 0),
destination: buffer)
// Prints "[0.4, 0.3, 0.2, 0.1]"
print(buffer.array)