pub fn composite_solid(
dest: [u8; 4],
src_rgb: [u8; 3],
src_a: u8,
coverage: u8,
mode: BlendMode,
) -> [u8; 4]Expand description
Composite a straight RGBA8 source pixel over a premultiplied
destination pixel, blending with mode and scaling the source by
coverage.
The same composite as composite_premultiplied, entered one step
earlier — and that step is not free: premultiplying a straight colour and
un-premultiplying it back quantises it, because a premultiplied byte
at alpha a can only express a + 1 of the 256 straight values. Every
caller holding a straight colour — every
Brush::Solid — must use this; a source already
premultiplied (an image sample, a composited layer) has no straight
colour to preserve and uses composite_premultiplied.
use pdfrum_page::BlendMode;
use pdfrum_render::blend::composite_solid;
let dest = [0, 0, 255, 255];
// A straight colour, entered one step earlier so the round trip
// through premultiplication cannot quantise it.
assert_eq!(
composite_solid(dest, [221, 0, 0], 255, 255, BlendMode::default()),
[221, 0, 0, 255],
);