BOOL StretchBlt(hdcDest, nXOriginDest, nYOriginDest, nWidthDest, nHeightDest, hdcSrc, nXOriginSrc, nYOriginSrc, nWidthSrc, nHeightSrc, fdwRop) | |||||
HDC hdcDest; | /* destination device-context handle | */ | |||
int nXOriginDest; | /* x-coordinate of origin of destination rectangle | */ | |||
int nYOriginDest; | /* y-coordinate of origin of destination rectangle | */ | |||
int nWidthDest; | /* width of destination rectangle | */ | |||
int nHeightDest; | /* height of destination rectangle | */ | |||
HDC hdcSrc; | /* source device-context handle | */ | |||
int nXOriginSrc; | /* x-coordinate of origin of source rectangle | */ | |||
int nYOriginSrc; | /* y-coordinate of origin of source rectangle | */ | |||
int nWidthSrc; | /* width of source rectangle | */ | |||
int nHeightSrc; | /* height of source rectangle | */ | |||
DWORD fdwRop; | /* raster operation | */ |
The StretchBlt function copies a bitmap from a source rectangle into a destination rectangle, stretching or compressing the bitmap if necessary to fit the dimensions of the destination rectangle. Windows stretches or compresses the bitmap according to the stretching mode that is currently set in the destination device context.
hdcDest
Identifies the destination device-context.
nXOriginDest
Specifies the logical x-coordinate of the upper-left corner of the destination rectangle.
nYOriginDest
Specifies the logical y-coordinate of the upper-left corner of the destination rectangle.
nWidthDest
Specifies the width, in logical units, of the destination rectangle.
nHeightDest
Specifies the height, in logical units, of the destination rectangle.
hdcSrc
Identifies the source device-context.
nXOriginSrc
Specifies the logical x-coordinate of the upper-left corner of the source rectangle.
nYOriginSrc
Specifies the logical y-coordinate of the upper-left corner of the source rectangle.
nWidthSrc
Specifies the width, in logical units, of the source rectangle.
nHeightSrc
Specifies the height, in logical units, of the source rectangle.
fdwRop
Specifies the raster operation to be performed. Raster-operation codes define how the Windows combines colors in output operations that involve a brush, a source bitmap, and a destination bitmap.
Raster-Operation (ROP) Code | Description |
BLACKNESS | ||
The destination rectangle is filled using the color associated with index 0 in the physical palette. (This color is black for the default physical palette.) | ||
DSTINVERT | ||
The destination rectangle is inverted. | ||
MERGECOPY | ||
The colors of the source rectangle are merged with the specified pattern using the Boolean AND operator. | ||
MERGEPAINT | ||
The colors of the inverted source-rectangle are merged with the colors of the destination rectangle using the Boolean OR operator. | ||
NOTSRCCOPY | ||
The inverted source rectangle is copied to the destination. | ||
NOTSRCERASE | ||
The colors of the source and destination rectangles are combined using the Boolean OR operator and then inverted. | ||
PATCOPY | ||
The specified pattern is copied into the destination bitmap. | ||
PATINVERT | ||
The colors of the specified pattern are combined with the colors of the destination rectangle using the Boolean XOR operator. | ||
PATPAINT | ||
The colors of the pattern are combined with the colors of the inverted source rectangle using the Boolean OR operator. The result of this operation is then combined with the colors of the destination rectangle using the Boolean OR operator. | ||
SRCAND | ||
The colors of the source and destination rectangles are combined using the Boolean AND operator. | ||
SRCCOPY | ||
The source rectangle is copied directly to the destination rectangle. | ||
SRCERASE | ||
The inverted colors of the destination rectangle are combined with the colors of the source rectangle using the Boolean AND operator. | ||
SRCINVERT | ||
The colors of the source and destination rectangles are combined using the Boolean XOR operator. | ||
SRCPAINT | ||
The colors of the source and destination rectangles are combined using the Boolean OR operator. | ||
WHITENESS | ||
The destination rectangle is filled using the color associated with index 1 in the physical palette. (This color is white for the default physical palette.) |
The return value is TRUE if the function was successful. Otherwise it is FALSE.
StretchBlt stretches or compresses the source in memory, then copies the result to the destination. The color data for pattern or destination pixels is merged after the stretching or compression occurs.
When recording an enhanced metafile, it is an error if the source device-context identifies the enhanced metafile device context.
If the specified raster operations requires a brush, Windows uses the brush that is currently selected into the destination device-context.
The destination coordinates are transformed using the transformation that is currently specified for the destination device context; the source coordinates are transformed using the transformation that is currently specified in the source device context.
An error will occur if the source transform has a rotation or shear.
If destination, source, and pattern bitmaps do not have the same color format, StretchBlt converts the source and pattern bitmaps to match the destination.
If StretchBlt must convert a monochrome bitmap to color, it sets white bits (1) to the background color and black bits (0) to the foreground color. To convert color to monochrome, it sets pixels that match the background color to white (1) and sets all other pixels to black (0). The foreground and background colors of the device context with color are used.
StretchBlt creates a mirror image of a bitmap if the signs of the nWidthSrc and nWidthDest or nHeightSrc and nHeightDest parameters differ. If nWidthSrc and nWidthDest have different signs, the function creates a mirror image of the bitmap along the x-axis. If nHeightSrc and nHeightDest have different signs, the function creates a mirror image of the bitmap along the y-axis.
Not all devices support the StretchBlt function. For more information, see the description of the GetDeviceCaps function.
BitBlt, GetDeviceCaps, SetStretchBltMode