int StretchDIBits(hdc, XDest, YDest, nDestWidth, nDestHeight, XSrc, YSrc, nSrcWidth, nSrcHeight, lpBits, lpBitsInfo, iUsage, Rop) | |||||
HDC hdc; | /* handle of device context | */ | |||
int XDest; | /* origin of destination rectangle | */ | |||
int YDest; | /* origin of destination rectangle | */ | |||
int nDestWidth; | /* width of destination rectangle | */ | |||
int nDestHeight; | /* height of destination rectangle | */ | |||
int XSrc; | /* origin of source rectangle | */ | |||
int YSrc; | /* origin of source rectangle | */ | |||
int nSrcWidth; | /* width of source rectangle | */ | |||
int nSrcHeight; | /* height of source rectangle | */ | |||
CONST VOID *lpBits; | /* address of bitmap bits | */ | |||
LPBITMAPINFO lpBitsInfo; | /* address of bitmap data | */ | |||
UINT iUsage; | /* usage flag | */ | |||
DWORD Rop; | /* raster operation | */ |
The StretchDIBits function copies the color data for a rectangle of pixels in a device-independent bitmap (DIB) to the given destination rectangle. If the destination rectangle is larger than the source rectangle, this function stretches the rows and columns of color data to fit the destination. If the destination rectangle is smaller than the source rectangle, this function compresses the rows and columns using the specified raster operation.
hdc
Identifies the destination device context.
XDest
Specifies the x-coordinate (in logical units) of the origin of the destination rectangle.
YDest
Specifies the y-coordinate (in logical units) of the origin of the destination rectangle.
nDestWidth
Specifies the x-extent (in logical units) of the destination rectangle.
nDestHeight
Specifies the y-extent (in logical units) of the destination rectangle.
XSrc
Specifies the x-coordinate (in pixels) of the source in the DIB.
YSrc
Specifies the y-coordinate (in pixels) of the source in the DIB.
nSrcWidth
Specifies the width (in pixels) of the source rectangle in the DIB.
nSrcHeight
Specifies the height (in pixels) of the source rectangle in the DIB.
lpBits
Points to the DIB bits that are stored as an array of bytes.
lpBitsInfo
Points to a BITMAPINFO data structure that contains information about the DIB. The BITMAPINFO structure has the following form:
typedef struct tagBITMAPINFO { /* bmi */
BITMAPINFOHEADER bmiHeader;
RGBQUAD bmiColors[1];
} BITMAPINFO;
iUsage
Specifies whether the bmiColors[ ] field of the lpBitsInfo data structure was provided and if so, whether bmiColors[ ] contains explicit RGB values or indices. The iUsage parameter must be one of the following values:
DIB_PAL_COLORS | ||
The array contains 16-bit indices into the logical palette of the source device context. | ||
DIB_RGB_COLORS | ||
The color table is provided and contains literal RGB values. | ||
DIB_PAL_INDICES | ||
No color table is provided. The DIB itself contains indices into the system palette. No color translation occurs. |
Rop
Specifies how the source pixels, the destination device context's current brush, and the destination pixels are to be combined to form the new image. For a complete list of the raster-operation codes, see Chapter 11, Binary and Ternary Raster-Operation Codes, in Reference, Volume 2.
The return value is the number of scanlines copied. If an error occurs, ERROR is returned.
The origin of a DIB is the lower-left corner.
StretchDIBits creates a mirror image of a bitmap if the signs of the nSrcWidth and nDestWidth or nSrcHeight and nDestHeight parameters differ. If nSrcWidth and nWidth have different signs, the function creates a mirror image of the bitmap along the x-axis. If nSrcHeight and nHeight have different signs, the function creates a mirror image of the bitmap along the y-axis.
BITMAPINFO, SetMapMode, SetStretchBltMode