TransparentBlt function

The TransparentBlt function performs a bit-block transfer of the color data corresponding to a rectangle of pixels from the specified source device context into a destination device context.

Syntax

BOOL TransparentBlt(
  HDC  hdcDest,
  int  xoriginDest,
  int  yoriginDest,
  int  wDest,
  int  hDest,
  HDC  hdcSrc,
  int  xoriginSrc,
  int  yoriginSrc,
  int  wSrc,
  int  hSrc,
  UINT crTransparent
);

Parameters

hdcDest

A handle to the destination device context.

xoriginDest

The x-coordinate, in logical units, of the upper-left corner of the destination rectangle.

yoriginDest

The y-coordinate, in logical units, of the upper-left corner of the destination rectangle.

wDest

The width, in logical units, of the destination rectangle.

hDest

The height, in logical units, of the destination rectangle.

hdcSrc

A handle to the source device context.

xoriginSrc

The x-coordinate, in logical units, of the source rectangle.

yoriginSrc

The y-coordinate, in logical units, of the source rectangle.

wSrc

The width, in logical units, of the source rectangle.

hSrc

The height, in logical units, of the source rectangle.

crTransparent

The RGB color in the source bitmap to treat as transparent.

Return Value

If the function succeeds, the return value is TRUE.

If the function fails, the return value is FALSE.

Remarks

The TransparentBlt function works with compatible bitmaps (DDBs).

The TransparentBlt function supports all formats of source bitmaps. However, for 32 bpp bitmaps, it just copies the alpha value over. Use AlphaBlend to specify 32 bits-per-pixel bitmaps with transparency.

If the source and destination rectangles are not the same size, the source bitmap is stretched to match the destination rectangle. When the SetStretchBltMode function is used, the iStretchMode modes of BLACKONWHITE and WHITEONBLACK are converted to COLORONCOLOR for the TransparentBlt function.

The destination device context specifies the transformation type for the destination coordinates. The source device context specifies the transformation type for the source coordinates.

TransparentBlt does not mirror a bitmap if either the width or height, of either the source or destination, is negative.

When used in a multiple monitor system, both hdcSrc and hdcDest must refer to the same device or the function will fail. To transfer data between DCs for different devices, convert the memory bitmap to a DIB by calling GetDIBits. To display the DIB to the second device, call SetDIBits or StretchDIBits.

Requirements

   
Minimum supported client Windows 2000 Professional [desktop apps only]
Minimum supported server Windows 2000 Server [desktop apps only]
Target Platform Windows
Header wingdi.h (include Windows.h)
Library Msimg32.lib
DLL Msimg32.dll

See Also

AlphaBlend

Bitmap Functions

Bitmaps Overview

GetDIBits

SetDIBits

SetStretchBltMode

StretchDIBits