Declaration ​
pascal
function MergeReg(F, B: TColor32): TColor32;
procedure MergeMem(F: TColor32; var B: TColor32);
procedure MergeMems(F: TColor32; Dst: PColor32; Count: Integer);
function MergeRegEx(F, B: TColor32; M: Cardinal): TColor32;
procedure MergeMemEx(F: TColor32; var B: TColor32; M: Cardinal);
procedure MergeLine(Src, Dst: PColor32; Count: Integer);
procedure MergeLineEx(Src, Dst: PColor32; Count: Integer; M: Cardinal);Parameters ​
| Parameter | Type | Description |
|---|---|---|
F | TColor32 | Foreground pixel color. |
B | TColor32 | Background pixel color. |
M | Cardinal | Master alpha weight or mask value (0..255). |
Src | PColor32 | Pointer to the first source foreground pixel in memory. |
Dst | PColor32 | Pointer to the first destination background pixel in memory. |
Count | Integer | Number of contiguous background pixels to blend. |
Returns ​
| Type | Description |
|---|---|
TColor32 | The blended 32-bit ARGB result color. |
Description ​
The Merge* family of functions performs associative alpha merging based on Bruce Wallace's 1981 compositing formulation:
Unlike standard alpha blending (Blend), Merge handles semi-transparent background colors accurately, maintaining associativity:
Variant Summary ​
| Variant | Signature | Description |
|---|---|---|
MergeReg | function(F, B: TColor32): TColor32; | Merges foreground |
MergeMem | procedure(F: TColor32; var B: TColor32); | Merges foreground |
MergeMems | procedure(F: TColor32; B: PColor32; Count: Integer); | Merges uniform foreground Count background pixels starting at |
MergeRegEx | function(F, B: TColor32; M: Cardinal): TColor32; | Register merging with master alpha / mask factor |
MergeMemEx | procedure(F: TColor32; var B: TColor32; M: Cardinal); | In-memory merging with master alpha / mask factor |
MergeLine | procedure(Src, Dst: PColor32; Count: Integer); | Scanline merging of Count source pixels onto destination pixels. |
MergeLineEx | procedure(Src, Dst: PColor32; Count: Integer; M: Cardinal); | Scanline merging with master alpha factor |
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.