TransparentBlt function (wingdi.h)

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(
  [in] HDC  hdcDest,
  [in] int  xoriginDest,
  [in] int  yoriginDest,
  [in] int  wDest,
  [in] int  hDest,
  [in] HDC  hdcSrc,
  [in] int  xoriginSrc,
  [in] int  yoriginSrc,
  [in] int  wSrc,
  [in] int  hSrc,
  [in] UINT crTransparent
);

Parameters

[in] hdcDest

A handle to the destination device context.

[in] xoriginDest

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

[in] yoriginDest

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

[in] wDest

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

[in] hDest

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

[in] hdcSrc

A handle to the source device context.

[in] xoriginSrc

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

[in] yoriginSrc

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

[in] wSrc

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

[in] hSrc

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

[in] 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

Requirement Value
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