Skip to main content

blend_pixel_premultiplied

Function blend_pixel_premultiplied 

Source
pub(crate) fn blend_pixel_premultiplied(
    dst: &mut [u8],
    r: u8,
    g: u8,
    b: u8,
    a: u8,
)
Expand description

Source-over compositing for PREMULTIPLIED sources (XFixes/Xcursor pixels are premultiplied by format definition): dst = src + dst*(1-a). The straight-alpha blend_pixel on premultiplied input multiplies alpha in twice and darkens every translucent pixel (visible dark fringes on the composited cursor).

The sum saturates: some toolkits ship cursors whose color exceeds its alpha, and on those a wrapping cast would turn an over-bright pixel into a dark one.