# BltBlt Function

`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.

hDestDC
  The device context of the target object (the one that receives the image piece).
x
  The x coordinate of the point to put the image inside the target.
y
  The y coordinate of the point to put the image inside the target.
nWidth
  The width of the image piece.
nHeight
  The height of the image piece.
xSrc
  The x coordinate of the upper-left corner of the image piece in the source.
ySrc
  The y coordinate of the upper-left corner of the image piece in the source.
dwRop
  Exactly one of the Blt flags specifying the method to use to copy the piece.

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.