vImageFlatten_BGRAFFFFToRGBFFF(_:_:_:_:_:)
Flattens a 32-bit-per-channel BGRA buffer against a solid background to produce a 32-bit-per-channel RGB result.
Declaration
func vImageFlatten_BGRAFFFFToRGBFFF(_: UnsafePointer<vImage_Buffer>, _: UnsafePointer<vImage_Buffer>, _: UnsafePointer<Float>, _: Bool, _: vImage_Flags) -> vImage_ErrorReturn Value
kvImageNoError; otherwise, one of the error codes in Data Types and Constants.
Discussion
Parameters
- bgraFFFFSrc
The source vImage buffer.
- rgbFFFdest
A pointer to the destination vImage buffer structure. You’re responsible for filling out the height, width, and 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.
- backgroundColor
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 kvImageDoNotTile; otherwise, pass kvImageNoFlags.
The function uses the following calculation to flatten the source image:
if( isImagePremultiplied )
color = color + (1.0f - alpha) * backgroundColor
else
color = color * alpha + (1.0f - alpha) * backgroundColor