---
title: "vImageSelectChannels_ARGB8888(_:_:_:_:_:)"
framework: accelerate
role: symbol
role_heading: Function
path: "accelerate/vimageselectchannels_argb8888(_:_:_:_:_:)"
---

# vImageSelectChannels_ARGB8888(_:_:_:_:_:)

Overwrites the channels of an 8-bit-per-channel, 4-channel interleaved buffer with the specified channels of the corresponding pixels of a second buffer.

## Declaration

```swift
func vImageSelectChannels_ARGB8888(_ newSrc: UnsafePointer<vImage_Buffer>, _ origSrc: UnsafePointer<vImage_Buffer>, _ dest: UnsafePointer<vImage_Buffer>, _ copyMask: UInt8, _ flags: vImage_Flags) -> vImage_Error
```

## Parameters

- `newSrc`: The source vImage buffer that provides the new channel values.
- `origSrc`: 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 doc://com.apple.accelerate/documentation/Accelerate/vImage_Buffer/height, doc://com.apple.accelerate/documentation/Accelerate/vImage_Buffer/width, and doc://com.apple.accelerate/documentation/Accelerate/vImage_Buffer/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 corresponding channel in the newSrc parameter. The value 0x8 represents channel 0, the value 0x4 represents channel 1, the value 0x2 represents channel 2, and the value 0x1 represents channel 3.
- `flags`: The options to use when performing the operation. If your code implements its own tiling or its own multithreading, pass doc://com.apple.accelerate/documentation/Accelerate/kvImageDoNotTile; otherwise, pass doc://com.apple.accelerate/documentation/Accelerate/kvImageNoFlags.

## Return Value

Return Value kvImageNoError; otherwise, one of the error codes in Data Types and Constants.

## Discussion

Discussion The following code overwrites channel 0 of the source pixels in pixelBuffer with channel 0 of the corresponding source pixels from newSource: let pixelBuffer = vImage.PixelBuffer<vImage.Interleaved8x4>(     pixelValues: [10, 20, 30, 40,                   50, 60, 70, 80],     size: .init(width: 1, height: 2))

let newSource = vImage.PixelBuffer<vImage.Interleaved8x4>(     pixelValues: [101, 102, 103, 104,                   105, 106, 107, 108],     size: .init(width: 1, height: 2))

pixelBuffer.withUnsafePointerToVImageBuffer { buf in     newSource.withUnsafePointerToVImageBuffer { new in         _ = vImageSelectChannels_ARGB8888(new,                                           buf,                                           buf,                                           0x8,                                           vImage_Flags(kvImageNoFlags))     } }

// Prints: //      "[101, 20, 30, 40, //        105, 60, 70, 80]" print(pixelBuffer.array)

## See Also

### Overwriting with another buffer

- [vImageSelectChannels_ARGBFFFF(_:_:_:_:_:)](accelerate/vimageselectchannels_argbffff(_:_:_:_:_:).md)
- [vImageOverwriteChannels_ARGB8888(_:_:_:_:_:)](accelerate/vimageoverwritechannels_argb8888(_:_:_:_:_:).md)
- [vImageOverwriteChannels_ARGBFFFF(_:_:_:_:_:)](accelerate/vimageoverwritechannels_argbffff(_:_:_:_:_:).md)
