Important:
This is retired content. This content is outdated and is no longer being maintained. It is provided as a courtesy for individuals who are still using these technologies. This content may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist.
A version of this page is also available for
4/8/2010

This function transfers a bitmap, omitting the portions drawn in a specified color.

Syntax

BOOL TransparentImage(
  HDC
 hdcDest, 
  LONG
 DstX, 
  LONG
 DstY, 
  LONG
 DstCx, 
  LONG
 DstCy,
  HANDLE
 hSrc, 
  LONG
 SrcX, 
  LONG
 SrcY, 
  LONG
 SrcCx, 
  LONG
 SrcCy, 
  COLORREF
 TransparentColor
);

Parameters

hdcDest

[in] Handle to a device context.

DstX

[in] Specifies the x-coordinate, in logical units, of the upper left corner of the destination rectangle.

DstY

[in] Specifies the y-coordinate, in logical units, of the upper left corner of the destination rectangle.

DstCx

[in] Specifies the width, in logical units, of the destination rectangle.

DstCy

[in] Specifies the height, in logical units, of the destination rectangle.

hSrc

[in] Specifies a source device context or a source bitmap.

SrcX

[in] Specifies the x-coordinate, in logical units, of the upper left corner of the source rectangle.

SrcY

[in] Specifies the y-coordinate, in logical units, of the upper left corner of the source rectangle.

SrcCx

[in] Specifies the width, in logical units, of the source rectangle.

SrcCy

[in] Specifies the height, in logical units, of the source rectangle.

TransparentColor

[in] Indicates the color in the bitmap that will be rendered transparent.

Return Value

Nonzero indicates success.

Zero indicates failure.

To get extended error information, call GetLastError.

Remarks

If the hSrcparameter is a HBITMAP, then that bitmap must not be selected into a device context at the time TransparentImageis called.

The TransparentImagefunction supports all formats of source bitmaps. However, for 32-bpp bitmaps, it just copies the alpha value over.

If the source and destination rectangles are not the same size, the source bitmap is stretched to match the destination rectangle.

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

Requirements

Header windows.h
Library coredll.lib
Windows Embedded CE Windows CE 2.0 and later
Windows Mobile Windows Mobile Version 5.0 and later

See Also