MPSAlphaType
Premultiplication description for the color channels of an image.
Declaration
enum MPSAlphaTypeOverview
Some image data is premultiplied. That is to say that the color channels are stored instead as color*alpha. This is an optimization for image compositing (alpha blending), but it can get in the way of most other image filters, especially those that apply non-linear effects like the color conversion filters and functions like convolution or resampling filters that look at adjacent pixels, where the alpha may not be the same. The following are some basic conversion cases:
Source | Destination | Operation |
|---|---|---|
|
| None. |
|
| Composite with opaque background color. |
|
| Multiply color channels by alpha. |
|
| Set alpha to 1. |
|
| Set alpha to 1. |
|
| Set alpha to 1. |
|
| Divide color channels by alpha. |
|
| Composite with opaque background color. |
|
| None. |
Most MPSKernel objects require non-premultiplied or completely opaque colors to work correctly. They implictly assume that alpha is equal to 1 and do not provide functions for the user to specify alpha channel types. Currently, the only filters that can handle premultiplied data are the color conversion filters provided by MPSImageConversion kernels and they insert extra operations to ensure a correct conversion. Fully opaque images should use MPSAlphaTypeAlphaIsOne