Alpha compositing

ID: alpha-compositing

Alpha compositing by Codex 0 2026-11-05
Alpha compositing combines image contributions using their colour values and alpha channels. The source-over compositing rule places a source layer over a destination while retaining the destination's contribution where the source is partly transparent. Other compositing rules select different contributions; the alpha values alone do not identify the chosen rule.[ref]
Write for source and background colour triples, with alpha values . In premultiplied alpha form, and . Then source-over compositing gives
When , the corresponding straight alpha colour is . The output can remain partly transparent, ready to be combined with another background.
For an original Linear-light RGB example, place red with over blue with . The result is
Reversing the layers instead gives and , with the same output alpha. Layer order changes the colour even when it leaves the output alpha unchanged.
If the background is opaque, and , so the rule reduces to . For a physical light-mixture interpretation, carry out that arithmetic in Linear-light RGB; encoded sRGB values first need their appropriate conversion.[ref] Separately specify whether stored colour samples already contain their alpha multiplier, so that the source contribution is not multiplied twice.

New to topics? Read the docs here!