Function

vImageFlatten_RGBA16Q12(_:_:_:_:_:)

Performs an alpha composite of an RGBA16Q12 image over a solid background color.

Declaration

func vImageFlatten_RGBA16Q12(_ argbSrc: UnsafePointer<vImage_Buffer>, _ argbDst: UnsafePointer<vImage_Buffer>, _ argbBackgroundColorPtr: UnsafePointer<Int16>, _ isImagePremultiplied: Bool, _ flags: vImage_Flags) -> vImage_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, 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, you must deallocate the memory.

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 kvImageDoNotTile.

Return Value

kvImageNoError; 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 |resultColor| >= 8.0 is undefined.

The source and destination buffers must have the same height and width.

Beta Software

This documentation contains preliminary information about an API or technology in development. This information is subject to change, and software implemented according to this documentation should be tested with final operating system software.

Learn more about using Apple's beta software