Composite images together.
Alpha compositing (also known as alpha blending) is the process of layering multiple images, with the alpha value for a pixel in a given layer indicating what fraction of the colors from lower layers are seen through the color at the given level. The functions described in this reference operate on the alpha values of pixels either by blending alpha values or clipping them.
Most of the alpha compositing functions blend two input images—a top image and a bottom image—to create a composite image. The vImage framework computes the alpha values of the composite image from the alpha values of the input images. Some functions operate on interleaved formats (ARGB8888, ARGBFFFF, RGBA8888, RGBAFFFF) while others operate on planar formats. Interleaved formats contain an alpha value for each pixel, but planar formats do not. To perform alpha compositing with planar images, you need to supply the alpha information separately.
Alpha compositing functions by default perform tiling internally and may multithread internally as well. If you plan to perform your own tiling or multithreading, you must turn off vImage internal tiling and multithreading by supplying the
kv flag as an option to the functions you use.
The vImage framework provides functions for alpha compositing for both the premultiplied alpha case and the nonpremultiplied alpha case, and includes alpha compositing functions for common mixed cases. Premultiplying pixel color values by the associated alpha value results in greater computational efficiency than providing nonpremultiplied data, especially when you composite more than two images. When you use premultiplied alpha, you still need to maintain the original alpha information, so that you can retrieve the original, nonpremultiplied values of the pixels when you need them. You also need to supply the original alpha value for the bottom layer in a compositing operation.
For floating-point formats, you can multiply the color value by the alpha value directly. For integer formats in which both values are in the range of 0 to 255, you multiply the color and alpha values, then you must scale the result so that it is in the 0 to 255 range. The scaling calculation is:
Alpha compositing functions use a vImage buffer structure (
v—see Data Types and Constants) to receive and supply image data. This buffer contains a pointer to image data, the height and width (in pixels) of the image data, and the number of row bytes. You actually pass a pointer to a vImage buffer structure. You can provide a pointer to the same vImage buffer structure for one of the source images and the destination image because alpha compositing functions “work in place”. That is , the source and destination images can occupy the same memory if the they are strictly aligned pixel for pixel.