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

Combine

Linear interpolation (Lerp) combining two colors across all channels given a weight.

Declaration ​

pascal
function CombineReg(F, B: TColor32): TColor32;
procedure CombineMem(F: TColor32; var B: TColor32);
procedure CombineLine(Src, Dst: PColor32; Count: Integer);

Parameters ​

ParameterTypeDescription
FTColor32Foreground pixel color.
BTColor32Background pixel color.
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 Combine* family of functions performs linear interpolation (Lerp) between two 32-bit ARGB colors (X and Y) given weight W∈[0,255]:

Z=W255⋅X+(1−W255)⋅Y=W⋅(X−Y)255+Y

All four channels (Alpha, Red, Green, Blue) are combined simultaneously.

Variant Summary ​

VariantSignatureDescription
CombineRegfunction(X, Y: TColor32; W: Cardinal): TColor32;Combines colors X and Y in registers with weight W.
CombineMemprocedure(X: TColor32; var Y: TColor32; W: Cardinal);Combines color X into memory location Y in-place with weight W.
CombineLineprocedure(Src, Dst: PColor32; Count: Integer; W: Cardinal);Combines Count pixels between Src and Dst scanline buffers with weight W.

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 ​