Skip to main content

alpha_merge

Function alpha_merge 

Source
pub fn alpha_merge(dest: u8, src: u8, alpha: u8) -> u8
Expand description

AlphaMerge(d, s, a) = (d*(255-a) + s*a) / 255, truncating and unclamped.

use pdfrum_render::pixmap::alpha_merge;

// Full alpha takes the source; none of it keeps the destination.
assert_eq!(alpha_merge(0, 255, 255), 255);
assert_eq!(alpha_merge(0, 255, 0), 0);