1 fblend(s, d, a) = (d * (255.0 - a) + s * a) / 255.0
This equation is adapted from the one used by the Python Image Library (PIL).
2 The earlier 1.8 function is:
blend(s, d, sA, dA) = (((s - d) * a) >> 8) + d, dA > 0
= s, dA == 0
This function has the unexpected behavior of:
blend(c, d, 255, dA) = c - 1, 1 <= c < 255, 1 <= dA <= 255
It also breaks on computer hardware where the right shift operator does not preserve the sign of its target (propagate the left most bit), as (s - d) can go negative, but the eight bit shift returns a positive.