Skip to content
Member Filters
Show Inherited
Show Protected
Show abstract
GR32_Blend🞂BlendFunction

Blend

Alpha blending for single pixels, array memory buffers, and scanlines.

Declaration ​

pascal
function BlendReg(F, B: TColor32): TColor32;
procedure BlendMem(F: TColor32; var B: TColor32);
procedure BlendMems(F: TColor32; Dst: PColor32; Count: Integer);
function BlendRegEx(F, B: TColor32; M: Cardinal): TColor32;
procedure BlendMemEx(F: TColor32; var B: TColor32; M: Cardinal);
function BlendRegRGB(F, B: TColor32; W: Cardinal): TColor32;
procedure BlendMemRGB(F: TColor32; var B: TColor32; W: Cardinal);
procedure BlendLine(Src, Dst: PColor32; Count: Integer);
procedure BlendLineEx(Src, Dst: PColor32; Count: Integer; M: Cardinal);

Parameters ​

ParameterTypeDescription
FTColor32Foreground pixel color.
BTColor32Background pixel color.
MCardinalMaster alpha weight or mask value (0..255).
WCardinalExplicit blending weight (0..255).
SrcPColor32Pointer to the first source foreground pixel in memory.
DstPColor32Pointer to the first destination background pixel in memory.
CountIntegerNumber of contiguous background pixels to blend.

Returns ​

TypeDescription
TColor32The blended 32-bit ARGB result color.

Description ​

The Blend* family of functions performs standard alpha blending, compositing a foreground color F onto a background color B using F's alpha channel value Fa:

Zrgb=Fa⋅Frgb+(1−Fa)⋅Brgb

The background color B is assumed to be fully opaque (Ba=255). If B contains semi-transparent alpha, use Merge instead.

Variant Summary ​

VariantSignatureDescription
BlendRegfunction(F, B: TColor32): TColor32;Blends foreground F and background B in registers.
BlendMemprocedure(F: TColor32; var B: TColor32);Blends foreground F directly into memory location B.
BlendMemsprocedure(F: TColor32; B: PColor32; Count: Integer);Blends uniform foreground F into Count background pixels starting at B.
BlendRegExfunction(F, B: TColor32; M: Cardinal): TColor32;Register blending with master alpha / mask factor M (0…255).
BlendMemExprocedure(F: TColor32; var B: TColor32; M: Cardinal);In-memory blending with master alpha / mask factor M (0…255).
BlendRegRGBfunction(F, B: TColor32; W: Cardinal): TColor32;Register blending with explicit blend weight W (0…255).
BlendMemRGBprocedure(F: TColor32; var B: TColor32; W: Cardinal);In-memory blending with explicit blend weight W (0…255).
BlendLineprocedure(Src, Dst: PColor32; Count: Integer);Scanline blending of Count source pixels onto destination pixels.
BlendLineExprocedure(Src, Dst: PColor32; Count: Integer; M: Cardinal);Scanline blending with master alpha factor M.

INFO

All these functions are actually delegates; At startup, Graphics32 binds them to the optimal implementation (Pure Pascal, x86/x64 assembly, or SSE2 vector instructions) supported by the host CPU.

See also ​