Appendix A. Premultiplied Alpha

Premultiplied alpha is just a different way of representing alphified pixels. If the separate alpha pixel is (r, g, b, a), then the premultiplied alpha pixel is (ar, ag, ab, a).

The reason why it's interesting is that linear combinations of pixels (i.e. a1p1 + a2p2) work better in premultiplied alpha space than in separate alpha space.

For example, taking the 50/50 blend of white and transparent works like this: White is (1, 1, 1, 1) and transparent is (0, 0, 0, 0) in both spaces. So the 50/50 blend is (0.5, 0.5, 0.5, 0.5). In separated space, that's half-transparent gray, but in premultiplied space, that's half-transparent white, which is what you expect.

Linear combinations of pixels occur in a lot of contexts, including:

  1. layer compositing

  2. blurring and sharpening

  3. interpolation

  4. scaling

  5. rotation, perspective, and other transformations

and probably one or two others.

The symptom of getting alpha wrong is gray fringes when you work with transparent layers.