BLENDFUNCTION

[This is preliminary documentation and subject to change.]

The BLENDFUNCTION structure controls blending by specifying the blending functions for source and destination bitmaps.

typedef struct _BLENDFUNCTION
{
    BYTE     BlendOp;
    BYTE     BlendFlags;
    BYTE     SourceConstantAlpha;
    BYTE     AlphaFormat;
}BLENDFUNCTION, *PBLENDFUNCTION, *LPBLENDFUNCTION;
 

Members

BlendOp
Specifies the source blend operation. Currently, the only source and destination blend operation that has been defined is AC_SRC_OVER. For details, see the following Remarks section.
BlendFlags
Must be zero.
SourceConstantAlpha
Specifies an alpha transparency value to be used on the entire source bitmap. The SourceConstantAlpha value is combined with any per-pixel alpha values in the source bitmap. If you set SourceConstantAlpha to 0, it is assumed that your image is transparent. Set the SourceConstantAlpha value to 255 (opaque) when you only want to use per-pixel alpha values.
AlphaFormat
This member controls the way the source and destination bitmaps are interpreted. AlphaFormat has the following value:
Value Meaning
AC_SRC_ALPHA This flag is set when the bitmap has an Alpha channel.

Remarks

When the AC_SRC_OVER operation is used, the source bitmap is placed over the destination bitmap based on the alpha values of the source pixels.

If the source bitmap has no per-pixel alpha value, the blend is based on a constant source alpha value as shown in the following table.

Dst.Red  
= Src.Red
* ConstantAlpha + (1 - ConstantAlpha) * Dst.Red
Dst.Green  
= Src.Green  
* ConstantAlpha + (1 - ConstantAlpha) * Dst.Green
Dst.Blue  
= Src.Blue
* ConstantAlpha + (1 - ConstantAlpha) * Dst.Blue

If the source bitmap has per-pixel alpha, the constant alpha is not used (0xff) as shown in the following table.

Dst.Red
= Src.Red
+ (1 - Src.Alpha) * Dst.Red
Dst.Green  
= Src.Green  
+ (1 - Src.Alpha) * Dst.Green
Dst.Blue
= Src.Blue
+ (1 - Src.Alpha) * Dst.Blue

If the destination bitmap has an alpha channel, then:

Dest.alpha  
= Src.Alpha  
+ (1 - SrcAlpha) * Dst.Alpha

If the source has pixel per alpha, the constant alpha is not 0xff.

Dst.Red  
= Src.Red 
- Src.Red = Src.Red * ConstantAlpha; 
Dst.Red
= Src.Red 
- Src.Green = Src.Green * ConstantAlpha ;
Dst.Red  
= Src.Red 
- Src.Blue = Src.Blue * ConstantAlpha ;
Dst.Red 
=  Src.Red
+ (1 - Src.Alpha) * Dst.Red
Dst.Red 
=  Src.Green   
+ (1 - Src.Alpha) * Dst.Green
Dst.Red 
=  Src.Blue
+ (1 - Src.Alpha) * Dst.Blue

QuickInfo

  Windows NT: Requires version 5.0 or later.
  Windows: Requires Windows 98 or later.
  Windows CE: Unsupported.
  Header: Declared in wingdi.h.

See Also

Bitmaps Overview, Bitmap Structures