BitBlt Function

Declare Function BitBlt Lib "gdi32.dll" (ByVal hdcDest As Long, ByVal nXDest As Long, ByVal nYDest As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hdcSrc As Long, ByVal nXSrc As Long, ByVal nYSrc As Long, ByVal dwRop As Long) As Long

Platforms

Description & Usage

BitBlt performs a bit-block transfer of a rectangular portion of an image from one device to another. The dimensions of the transfered rectangle are perfectly preserved. The function can perform a variety of raster operations to transfer the block from the source device to the target device.

Return Value

If an error occured, the function returns 0 (Windows NT, 2000: use GetLastError to get the error code). If successful, the function returns a non-zero value.

Visual Basic-Specific Issues

None.

Parameters

hdcDest
A handle to the device context of the device which receives the transfered image block.
nXDest
The x-coordinate of the point to position the upper-left corner of the transfered image block.
nYDest
The y-coordinate of the point to position the upper-left corner of the transfered image block.
nWidth
The width in pixels of the image block.
nHeight
The height in pixels of the image block.
hdcSrc
A handle to the device context of the device which contains the image block to transfer.
nXSrc
The x-coordinate of the upper-left corner of the image block to transfer.
nYSrc
The y-coordinate of the upper-left corner of the image block to transfer.
dwRop
One of the following flags identifying the raster operation to use to transfer the image block. Each raster operation uses the RGB color value of the source and/or target pixel to determine the new color of the target pixel.
BLACKNESS
Fill the destination rectangle with the color whose index is 0 in the physical palette (which is black by default).
CAPTUREBLT
Windows 98, 2000: Include any windows layered on top of the window being used in the resulting image.
DSTINVERT
Invert the colors in the destination rectangle.
MERGECOPY
Merge the colors of the source rectangle with the specified pattern using the bitwise AND operator.
MERGEPAINT
Merge the colors of the inverted source rectangle with the colors of the destination rectangle using the bitwise OR operator.
NOMIRRORBITMAP
Windows 98, 2000: Prevent the bitmap from being mirrored.
NOTSRCCOPY
Copy the inverted source rectangle to the destination rectangle.
NOTSRCERASE
Combine the colors of the source and destination rectangles using the bitwise OR operator and then invert the resulting color.
PATCOPY
Copy the specified pattern into the destination bitmap.
PATINVERT
Combine the colors of the specified pattern with the colors of the destination rectangle using the bitwise XOR operator.
PATPAINT
Combine the colors of the specified pattern with the colors of the inverted source rectangle using the bitwise OR operator. Combine the result of that operation with the colors of the destination rectangle using the bitwise OR operator.
SRCAND
Combine the colors of the source and destination rectangles using the bitwise AND operator.
SRCCOPY
Copy the source rectangle directly into the destination rectangle.
SRCERASE
Combine the inverted colors of the destination rectangle with the colors of the source rectange using the bitwise AND operator.
SRCINVERT
Combine the colors of the source and destination rectangles using the bitwise XOR operator.
SRCPAINT
Combine the colors of the source and destination rectangles using the bitwise OR operator.
WHITENESS
Fill the destination rectangle with the color whose index is 1 in the physical palette (which is white by default).

Constant Definitions

Const BLACKNESS = &H42
' Const CAPTUREBLT = ???
Const DSTINVERT = &H550009
Const MERGECOPY = &HC000CA
Const MERGEPAINT = &HBB0226
' Const NOMIRRORBITMAP = ???
Const NOTSRCCOPY = &H330008
Const NOTSRCERASE = &H1100A6
Const PATCOPY = &HF00021
Const PATINVERT = &H5A0049
Const PATPAINT = &HFB0A09
Const SRCAND = &H8800C6
Const SRCCOPY = &HCC0020
Const SRCERASE = &H440328
Const SRCINVERT = &H660046
Const SRCPAINT = &HEE0086
Const WHITENESS = &HFF0062

Example

' This code is licensed according to the terms and conditions listed here.

' Copy a rectanglular image from window Form1 to window Form2
' exactly (using SRCCOPY).  The rectangle has a width of 100 and a height of
' 50.  The upper-left corner of the source block is (350, 250); the block
' is placed at (0,0) in Form2.
Dim retval As Long  ' return value

' Transfer the image exactly as described above.
retval = BitBlt(Form2.hDC, 0, 0, 100, 50, Form1.hDC, 350, 250, SRCCOPY)

See Also

StretchBlt

Category

Bitmaps

Go back to the alphabetical Function listing.
Go back to the Reference section index.


Last Modified: August 13, 1999
This page is copyright © 1999 Paul Kuliniewicz. Copyright Information Revised October 29, 2000
Go back to the Windows API Guide home page.
E-mail: vbapi@vbapi.com Send Encrypted E-Mail
This page is at http://www.vbapi.com/ref/b/bitblt.html