Function

vImageFlatten_ARGB8888(_:_:_:_:_:)

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

Declaration

func vImageFlatten_ARGB8888(_ argbSrc: UnsafePointer<vImage_Buffer>, _ argbDst: UnsafePointer<vImage_Buffer>, _ argbBackgroundColorPtr: UnsafePointer<UInt8>, _ isImagePremultiplied: Bool, _ flags: vImage_Flags) -> vImage_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, 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_FFFF that references floating-point ARGB 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:

if( isImagePremultiplied )
    color = (color * 255 + (255 - alpha) * backgroundColor + 127) / 255
else
    color = (color * alpha + (255 - alpha) * backgroundColor + 127) / 255

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

See Also

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