procedure ApplyBitmask(
Dst: TCustomBitmap32;
DstX: Integer;
DstY: Integer;
Src: TCustomBitmap32;
SrcRect: TRect;
Bitmask: TColor32;
LogicalOperator: TLogicalOperator;
);
procedure ApplyBitmask(
ABitmap: TCustomBitmap32;
ARect: TRect;
Bitmask: TColor32;
LogicalOperator: TLogicalOperator;
);
ApplyBitmask performs a logical (bitwise) operation on a bitmap fragment specified by SrcRect into location (DstX, DstY) or directly in-place on ABitmap. The operation is carried out in the following manner: "Source Pixel [Logical Operation] Bitmask" regardless of present destination or in-place operation. The logical operation is defined by the provided Logical Operator.
Each byte in the bitmask will be used as component corresponding operand. The following combinations illustrates different applications:
Description | Parameter Values | Source | Result |
Zero out Red and Blue components, leave the rest untouched |
LogicalOperator = loAND Bitmask = $FF00FF00 |
||
Invertion of Blue component, leave the rest untouched | LogicalOperator = loXOR Bitmask = $000000FF |
||
Full power to Red component, leave the rest untouched | LogicalOperator = loOR Bitmask = $00FF0000 |
||
Weird filter | LogicalOperator = loOR Bitmask = $BABEC0DE |
As seen above, the bitmask does not necessarily have to contain 0 or $FF in each component segment - intermediate values can also be used however with limited realistic applications (read: weird filters).
You may use auxiliary function CreateBitmask to create bitmasks.
TCustomBitmap32, Color Types, Rectangle Types, CopyComponents, CreateBitmask, Invert, TLogicalOperator
Copyright ©2000-2024 Alex Denisov and the Graphics32 Team - Graphics32 2.0 - Help file built on 18 Feb 2024