StretchBlt Function

Declare Function StretchBlt Lib "gdi32.dll" (ByVal hdc 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 hSrcWidth As Long, ByVal nSrcHeight As Long, ByVal dwRop As Long) As Long

StretchBlt copies a section of an image from one device to another. This function also allows you to change the original size and dimensions of the image section, unlike the related function BitBlt. In addition to using the straight "copy" method, you can specify other ways of copying the image with the dwRop parameter. What the function actually does is perform a binary operation on the color of the source and destination pixel to calculate the color of the pixel in the transfered image. The point you specify as the location of the copied image in the target object will be the upper-left corner of the image portion. The function returns 0 if the function failed and 1 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 in the target.
nHeight
The height of the image piece in the target.
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.
nSrcWidth
The width of the image piece in the source.
nSrcHeight
The height of the image piece in the source.
dwRop
Exactly one of the following flags specifying what method to use to copy the source image:
SRCAND = &H8800C6
Logically And the two color values (destination = source And destination).
SRCCOPY = &HCC0020
Copy the source image exactly (destination = source).
SRCERASE = &H440328
Logically And the source image and the destination's binary inverse (destination = source And (Not destination).
SRCINVERT = &H660046
Logically Xor the two color values (destination = source Xor destination).
SRCPAINT = &HEE0086
Logically Or the two color values (destination = source Or destination).

Example:

' Copy a portion of the image in PictureBox1 to PictureBox2 and
' stretch it to triple its original width.  The image's original dimensions are
' 16x32; its new ones are 48x32.
' Source image coordinates: (45,50)-(60,81)
' Target image coordinates: (0,0)-(47,31)

Dim retval As Long  ' function return value

retval = BitBlt(PictureBox2.hdc, 0, 0, 48, 32, PictureBox1.hdc, 45, 50, 16, 32, SRCCOPY)

See Also: BitBlt
Category: Bitmaps

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


This page is copyright © 2000 Paul Kuliniewicz. Copyright Information.
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/s/stretchblt.html