Declare Function BitBlt Lib "gdi32.dll" (ByVal hDestDC As Long, ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hSrcDC As Long, ByVal xSrc As Long, ByVal ySrc As Long, ByVal dwRop As Long) As Long
BitBlt copies a piece of an image from one object to another. This function preserves the original size and dimensions of the image piece, unlike the related function StretchBlt. In addition to using the straight "copy" method, you can specify other ways of copying the image with the dwRop parameter. The point you specify to put the image in the target object will be the upper-left corner of the piece. The function returns 0 if the function failed and a non-zero value if it succeeded.
Example:
' Copy a 16x32 rectangle from the upper-left corner of one picture box to another
x = BitBlt(picTarget.hdc, 0, 0, 16, 32, picSource.hdc, 0, 0, SRCCOPY)
picTarget.Refresh ' show the updated image
Related Call: StretchBlt
Category: Graphics
Back to the index.