function BlendReg(F, B: TColor32): TColor32;

procedure BlendMem(F: TColor32; var B: TColor32);


Mixes a foregrownd (F) color with the background color (B) using the alpha component of the foreground color.

SRGB = FA * FRGB + (1 FA) * BRGB;

The blend mode is a simplification of the merge mode assuming that the background is fully opaque (with an alpha value A = 255). If the background is not opaque, the alpha values will get mixed linearly in the same way as the colors do. In that case the output transparency will be:

SA = FA * FA + (1 FA) * BA;

Typically this alpha calculation doesn't make much sense in most cases (other than the fully opaque background). It is the result of an optimisation (avoiding the division)

BlendReg takes parameters and produces the result operating on CPU registers.

BlendMem operates with the background color referenced by a memory address.

Using BlendMem is more efficient when blending/combining data to a bitmap, since it excludes writing operation for transparent pixels and reading operation for opaque ones.

Note, that after using the Blend function, you have to call EMMS. Otherwise CPU will be unable to handle floating point instructions.

See Also

Color Types, BlendEx, Combine, EMMS, Merge, MergeEx