Skip to main content

extract_soft_mask

Function extract_soft_mask 

Source
pub fn extract_soft_mask<P: Pixel>(group: &GroupBitmap<P>) -> Vec<u8> 
Expand description

Convert a finished group bitmap into a single-channel soft mask.

Returns one byte per pixel (width × height bytes, row-major, top-down):

soft_mask_typeOutput
SoftMaskType::NoneAll 255 (fully opaque — no masking).
SoftMaskType::AlphaGroup alpha plane, verbatim.
SoftMaskType::LuminosityBT.709 luma (77R + 151G + 28B + 128) >> 8 per RGB pixel. Fallback to alpha for non-RGB groups.

For SoftMaskType::Luminosity, only 3-byte RGB groups compute a true luma value. All other pixel modes (gray, CMYK, DeviceN) fall back to the alpha plane because their channel bytes do not map to R, G, B.