WORD StretchDIBits(hDC,DestX,DestY,wDestWidth,wDestHeight,SrcX,SrcY,wSrcWidth,wSrcHeight,lpBits,lpBitsInfo,wUsage,dwRop)
This function moves a device-independent bitmap (DIB) from a source rectangle into a destination rectangle, stretching or compressing the bitmap if necessary to fit the dimensions of the destination rectangle. The StretchDIBits function uses the stretching mode of the destination device context (set by the SetStretchBltMode function) to determine how to stretch or compress the bitmap.
StretchDIBits moves the bitmap from the device-independent bitmap specified by the lpBits, lpBitsInfo, and wUsage parameters to the destination device specified by the hDC parameter. The XSrc, YSrc, wSrcWidth, and wSrcHeight parameters define the origin and dimensions of the source rectangle. The origin of coordinate system of the device-independent bitmap is the lower-left corner. The DestX, DestY, wDestWidth, and wDest-Height parameters give the origin and dimensions of the destination rectangle. The origin of the coordinates of the destination depends on the current mapping mode of the device context. See the SetMapMode function earlier in this chapter for more information on mapping modes.
The raster operation specified by the dwRop parameter defines how the source bitmap and the bits already on the destination device are combined.
StretchDIBits creates a mirror image of a bitmap if the signs of the wSrcWidth and wDestWidth or wSrcHeight and wDestHeight parameters differ. If wSrcWidth and nWidth have different signs, the function creates a mirror image of the bitmap along the x-axis. If wSrcHeight and nHeight have different signs, the function creates a mirror image of the bitmap along the y-axis.
Parameter | Type/Description |
hDC | HDC Identifies the destination device context for a display surface or memory bitmap. | |
DestX | WORD Specifies the x-coordinate (in logical units) of the origin of the destination rectangle. | |
DestY | WORD Specifies the y-coordinate (in logical units) of the origin of the destination rectangle. | |
wDestWidth | WORD Specifies the x-extent (in logical units) of the destination rectangle. | |
wDestHeight | WORD Specifies the y-extent (in logical units) of the destination rectangle. | |
SrcX | WORD Specifies the x-coordinate (in pixels) of the source in the DIB. | |
SrcY | WORD Specifies the y-coordinate (in pixels) of the source in the DIB. | |
wSrcWidth | WORD Specifies the width (in pixels) of the source rectangle in the DIB. | |
wSrcHeight | WORD Specifies the height (in pixels) of the source rectangle in the DIB. | |
lpBits | LPSTR Points to the DIB bits that are stored as an array of bytes. | |
lpBitsInfo | LPBITMAPINFO Points to a BITMAPINFO data structure that contains information about the DIB. | |
wUsage | WORD Specifies whether the bmiColors[ ] fields of the lpBitsInfo parameter contain explicit RGB values or indexes into the currently realized logical palette. The wUsage parameter must be one of the following values: |
Value | Meaning | ||
DIB_PAL_COLORS | The color table consists of an array of 16-bit indexes into the currently realized logical palette. | ||
DIB_RGB_COLORS | The color table contains literal RGB values. | ||
dwRop | DWORD Specifies the raster operation to be performed. Raster operation codes define how GDI combines colors in output operations that involve a current brush, a possible source bitmap, and a destination bitmap. For a list of raster-operation codes, see the BitBlt function, earlier in this chapter. |
The return value is the number of scan lines copied.
This function also accepts a device-independent bitmap specification formatted for Microsoft OS/2 Presentation Manager versions 1.1 and 1.2 if the lpBitsInfo parameter points to a BITMAPCOREINFO data structure.