Performs an alpha composite of an RGBA16Q12 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_RGBA16Q12(_ argbSrc: Unsafe Pointer<v Image _Buffer>, _ argbDst: Unsafe Pointer<v Image _Buffer>, _ argbBackgroundColorPtr: Unsafe Pointer<Int16>, _ isImagePremultiplied: Bool, _ flags: v Image _Flags) -> v Image _Error
Parameters
argbSrc
A pointer to a vImage buffer that references 16Q12 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_ARGB_16S that references 16-bit RGBA16Q12 premultiplied background color.
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:
pixelAlpha = CLAMP( 0, pixelAlpha, 4096);
resultAlpha = (pixelAlpha * 4096 + (4096 - pixelAlpha) * backgroundAlpha + 2048) >> 12;
if(isImagePremultiplied)
{
resultColor = (pixelColor * 4096 + (4096 - pixelAlpha) * backgroundColor + 2048) >> 12
}
else
{
resultColor = (pixelColor * pixelAlpha + (4096 - pixelAlpha) * backgroundColor + 2048) >> 12
}
Whether the function attempts to clamp the case when the |result
is undefined.
The source and destination buffers must have the same height and width.