AlphaBlend Function

Virtual Tree View

Snow earth.bmp
AlphaBlend Function

General purpose procedure to blend one bitmap to another.

Pascal
procedure AlphaBlend(Source: HDC; Destination: HDC; R: TRect; Target: TPoint; Mode: TBlendMode; ConstantAlpha: Integer; Bias: Integer);
Description

This is an optimized alpha blend procedure using MMX instructions to perform as quick as possible. For this procedure to work properly it is important that both source and target bitmap use the 32 bit color format (pf32Bit for TBitmap). R describes the source rectangle to work on, while Target is the place (upper left corner) in the target bitmap where to blend to. Note that source width + X offset must be less or equal to the target width. Similar for the height. 

 

If Mode is bmConstantAlpha then the blend operation uses the given ConstantAlpha value for all pixels. 

If Mode is bmPerPixelAlpha then each pixel is blended using its individual alpha value (the alpha value of the source). 

If Mode is bmMasterAlpha then each pixel is blended using its individual alpha value multiplied by ConstantAlpha. 

If Mode is bmConstantAlphaAndColor then each destination pixel is blended using ConstantAlpha but also a constant color which will be obtained from Bias. In this case no offset value is added, otherwise Bias is used as offset. 

 

Blending of a color into target only (bmConstantAlphaAndColor) ignores Source (the DC) and Target (the position). 

 

Notes

This procedure does not check whether MMX instructions are actually available! Call it only if MMX is really usable, 

otherwise a process exception for unknown op codes is thrown.

Group
File

VirtualTrees

Links
What do you think about this topic? Send feedback!