---
title: "vImageFlatten_RGBAFFFF(_:_:_:_:_:)"
framework: accelerate
role: symbol
role_heading: Function
path: "accelerate/vimageflatten_rgbaffff(_:_:_:_:_:)"
---

# vImageFlatten_RGBAFFFF(_:_:_:_:_:)

Performs an alpha composite of a 32-bit-per-channel, 4-channel RGBA buffer over a solid background color.

## Declaration

```swift
func vImageFlatten_RGBAFFFF(_ rgbaSrc: UnsafePointer<vImage_Buffer>, _ rgbaDst: UnsafePointer<vImage_Buffer>, _ rgbaBackgroundColorPtr: UnsafePointer<Float>, _ isImagePremultiplied: Bool, _ flags: vImage_Flags) -> vImage_Error
```

## Parameters

- `rgbaSrc`: The source vImage buffer.
- `rgbaDst`: 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.
- `rgbaBackgroundColorPtr`: A pixel value that defines the solid background color.
- `isImagePremultiplied`: A Boolean value that specifes whether the source image has premultiplied alpha.
- `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 flatten the source image:  resultAlpha = pixelAlpha + (1 - pixelAlpha) * backgroundAlpha    if(isImagePremultiplied)      resultColor = pixelColor + (1 - pixelAlpha) * backgroundColor  else      resultColor = pixelColor * pixelAlpha + (1 - pixelAlpha) * backgroundColor

## See Also

### Flattening 4-channel, 32-bit images

- [vImageFlatten_ARGBFFFF(_:_:_:_:_:)](accelerate/vimageflatten_argbffff(_:_:_:_:_:).md)
