#[non_exhaustive]#[repr(u32)]pub enum AlphaPolicy {
Reject = 0,
Drop = 1,
CompositeOver = 2,
}Expand description
What to do when the source carries an alpha channel the target layout cannot hold.
Only consulted when alpha would actually be lost. Adding an opaque alpha channel to a target that has one is lossless and always permitted, whatever this is set to.
Discriminants are explicit and permanent — they are C ABI values; new variants append.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Reject = 0
Refuse the conversion with Error::Unsupported. The default.
Drop = 1
Discard the alpha channel, keeping the unassociated colour samples untouched.
The transparent parts of the image keep whatever colour was stored under them, which for an unassociated-alpha buffer may be arbitrary. Cheap and exactly reversible for opaque images.
CompositeOver = 2
Composite the image over ConvertPolicy::background and keep the result.
Treats the source as unassociated alpha (which is what ColorModel::Rgba and
ColorModel::GrayAlpha specify) and computes src * a + background * (1 - a).