Performs an alpha composite of an ARGBFFFF image over a solid background color.
SDKs
- iOS 7.0+
- macOS 10.9+
- Mac Catalyst 13.0+
- tvOS 9.0+
- watchOS 2.0+
Framework
- Accelerate
Declaration
func vImageFlatten_ARGBFFFF(_ argbSrc: Unsafe Pointer<v Image _Buffer>, _ argbDst: Unsafe Pointer<v Image _Buffer>, _ argbBackgroundColorPtr: Unsafe Pointer<Float>, _ isImagePremultiplied: Bool, _ flags: v Image _Flags) -> v Image _Error
Parameters
argbSrc
A pointer to a vImage buffer that references floating-point ARGB interleaved source pixels.
argbDst
A pointer to a vImage buffer data structure. You're responsible for filling out the
height
,width
, androw
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, you must deallocate the memory.Bytes argbBackgroundColorPtr
A pointer to
Pixel
that references floating-point ARGB premultiplied background color._FFFF isImagePremultiplied
True
if the source image is premultiplied; otherwise,false
.flags
The options to use when performing the operation. If you plan to perform your own tiling or use multithreading, pass
kv
.Image Do Not Tile
Return Value
kv
; otherwise, one of the error codes described in Data Types and Constants.
Discussion
The per-pixel operation is:
resultAlpha = pixelAlpha + (1 - pixelAlpha) * backgroundAlpha
if(isImagePremultiplied)
{
resultColor = pixelColor + (1 - pixelAlpha) * backgroundColor
}
else
{
resultColor = pixelColor * pixelAlpha + (1 - pixelAlpha) * backgroundColor
}
The source and destination buffers must have the same height and width.