---
title: "vImageConvert_RGB16UtoRGBA16U(_:_:_:_:_:_:)"
framework: accelerate
role: symbol
role_heading: Function
path: "accelerate/vimageconvert_rgb16utorgba16u(_:_:_:_:_:_:)"
---

# vImageConvert_RGB16UtoRGBA16U(_:_:_:_:_:_:)

Combines an unsigned 16-bit-per-channel, 3-channel RGB buffer and either an unsigned 16-bit alpha buffer or constant alpha value to produce an RGBA result.

## Declaration

```swift
func vImageConvert_RGB16UtoRGBA16U(_ rgbSrc: UnsafePointer<vImage_Buffer>, _ aSrc: UnsafePointer<vImage_Buffer>!, _ alpha: Pixel_16U, _ rgbaDest: UnsafePointer<vImage_Buffer>, _ premultiply: Bool, _ flags: vImage_Flags) -> vImage_Error
```

## Parameters

- `rgbSrc`: The source vImage buffer that contains the red, green, and blue channels.
- `aSrc`: The source vImage buffer that contains the alpha channel. Set this value to nil to specify that the function sets the destination alpha as the constant destination alpha value.
- `alpha`: The constant destination alpha value. The function ignores this paramater if the aSrc parameter isn’t nil.
- `rgbaDest`: 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.
- `premultiply`: A Boolean value that specifes whether the function premultiplies the color channels by the alpha channel.
- `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 function uses the following calculation to perform the conversion: if (aSrc != NULL)  {     if (premultiply)     {         r = (aSrc[i] * rgb[i*3+0] + 32767) / 65535         g = (aSrc[i] * rgb[i*3+1] + 32767) / 65535         b = (aSrc[i] * rgb[i*3+2] + 32767) / 65535         rgbaDest[i*4+3] = aSrc[i];         rgbaDest[i*4+0] = r;         rgbaDest[i*4+1] = g;         rgbaDest[i*4+2] = b;     }     else     {         rgbaDest[i*4+3] = aSrc[i];         rgbaDest[i*4+0] = rgb[i*3+0];         rgbaDest[i*4+1] = rgb[i*3+1];         rgbaDest[i*4+2] = rgb[i*3+2];     }  }  else  {     if (premultiply)     {         r = (alpha * rgb[i*3+0] + 32767) / 65535         g = (alpha * rgb[i*3+1] + 32767) / 65535         b = (alpha * rgb[i*3+2] + 32767) / 65535         rgbaDest[i*4+3] = alpha;         rgbaDest[i*4+0] = r;         rgbaDest[i*4+1] = g;         rgbaDest[i*4+1] = b;     }     else     {         rgbaDest[i*4+3] = alpha;         rgbaDest[i*4+0] = rgb[i*3+0];         rgbaDest[i*4+1] = rgb[i*3+1];         rgbaDest[i*4+2] = rgb[i*3+2];     }  } This function doesn’t operate in place.

## See Also

### Conversion from unsigned 16-bit-per-channel, 3-channel interleaved buffers

- [vImageConvert_RGB16UToARGB8888(_:_:_:_:_:_:)](accelerate/vimageconvert_rgb16utoargb8888(_:_:_:_:_:_:).md)
- [vImageConvert_RGB16UtoARGB16U(_:_:_:_:_:_:)](accelerate/vimageconvert_rgb16utoargb16u(_:_:_:_:_:_:).md)
- [vImageConvert_RGB16UtoBGRA16U(_:_:_:_:_:_:)](accelerate/vimageconvert_rgb16utobgra16u(_:_:_:_:_:_:).md)
