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:
|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.
Color Types, CopyComponents, CreateBitmask, Invert, TCustomBitmap32, TLogicalOperator, Rectangle Types
Copyright ©2000-2012 Alex Denisov and the Graphics32 Team - Graphics32 v1.9.1 - Build on 28-August-2012