BOOL BitBlt(hdcDest, nXDest, nYDest, nWidth, nHeight, hdcSrc, nXSrc, nYSrc, dwRop) | |||||
HDC hdcDest; | /* handle of destination device-context | */ | |||
int nXDest; | /* x-coordinate of destination rect upper-left corner | */ | |||
int nYDest; | /* y-coordinate of destination rect upper-left corner | */ | |||
int nWidth; | /* width of destination rect | */ | |||
int nHeight; | /* height of destination rect | */ | |||
HDC hdcSrc; | /* handle of source device-context | */ | |||
int nXSrc; | /* x-coordinate of source rect upper-left corner | */ | |||
int nYSrc; | /* y-coordinate of source rect upper-left corner | */ | |||
DWORD dwRop; |
The BitBlt function performs a bit-block transfer, transferring the color data corresponding to a rectangle of pixels from the given source device-context into the given destination device-context. The upper-left corner of each rectangle is identified by the given coordinates. The width and height of the rectangles are specified by the given dimensions. In addition, the raster operation that is used to combine color data for each pixel is specified by the given ROP.
hdcDest
Identifies the destination device context.
nXDest
Specifies the logical coordinate of the upper-left corner of the destination rectangle.
nYDest
Specifies the logical coordinate of the upper-left corner of the destination rectangle.
nWidth
Specifies the logical width of the source and destination rectangles.
nHeight
Specifies the logical height of the source and the destination rectangles.
hdcSrc
Identifies the source device context.
nXSrc
Specifies the logical coordinate of the upper-left corner of the source rectangle.
nYSrc
Specifies the logical coordinate of the upper-left corner of the source rectangle.
dwRop
Specifies a raster-operation code. These codes define how the the color data for the source-rectangle is combined with the color data for the target-rectangle to achieve the final color. The following list contains various raster-operation codes and their description:
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 is successful; otherwise it is FALSE.
If a rotation or shear transformation is in effect in the source device-context, BitBlt will return an error. If any other transforms exist in the source device-context (and a matching transform is not in effect in the destination device context), the rectangle in the destination device-context will be stretched, compressed, or rotated as necessary.
If the color formats of the source and destination device contexts do no match, the BitBlt function converts the source color-format to match the destination format.
When recording an enhanced metafile, it is an error if the source device context identifies the enhanced metafile device context.
Not all devices support the BitBlt function. For more information, see the RC_BITBLT raster capability in the GetDeviceCaps function.
BitBlt returns an error if the source and destination device contexts represent different devices.
GetDeviceCaps, PlgBlt, StretchBlt