---
title: "vImageFlatten_RGBA8888ToRGB888(_:_:_:_:_:)"
framework: accelerate
role: symbol
role_heading: Function
path: "accelerate/vimageflatten_rgba8888torgb888(_:_:_:_:_:)"
---

# vImageFlatten_RGBA8888ToRGB888(_:_:_:_:_:)

Flattens an 8-bit-per-channel RGBA buffer against a solid background to produce an 8-bit-per-channel RGB result.

## Declaration

```swift
func vImageFlatten_RGBA8888ToRGB888(_: UnsafePointer<vImage_Buffer>, _: UnsafePointer<vImage_Buffer>, _: UnsafePointer<UInt8>, _: Bool, _: vImage_Flags) -> vImage_Error
```

## Return Value

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

## Discussion

Discussion Parameters The function uses the following calculation to flatten the source image:  if( isImagePremultiplied )      color = (color * 255 + (255 - alpha) * backgroundColor + 127) / 255  else      color = (color * alpha + (255 - alpha) * backgroundColor + 127) / 255

## See Also

### Flattening 4-channel, 8-bit images to three channels

- [vImageFlatten_ARGB8888ToRGB888(_:_:_:_:_:)](accelerate/vimageflatten_argb8888torgb888(_:_:_:_:_:).md)
- [vImageFlatten_BGRA8888ToRGB888(_:_:_:_:_:)](accelerate/vimageflatten_bgra8888torgb888(_:_:_:_:_:).md)
