BitBlt Command

Purpose

Copies a source raster (Bitmap) to a destination raster.

Syntax

BitBlt srcdc%,srcx%,srcy%,srcw%,srch%, dstdc%,dstx%,dsty%,mode%

Description

BitBlt performs a fast copy of a source raster to a destination raster. To do this it requires the Device Context (srcdc%) of the source raster , the coordinates of the upper left corner (srcx%,srcy%), the width (srcw%), the height (srch%) and the Device Context (dstdc%) of the destination raster. The source raster is then moved to the location dstx%, dsty% whereby the source and destination raster as well as the current pattern specified in mode% can logically be combined. mode% must assume one of the following values:

BLACKNESS $00000042 All bits are set to black
DSTINVERT $00550009 The destination raster bits are inverted.
MERGECOPY $00C000CA The fill pattern is logically "And-ed" with the source raster.
MERGEPAINT $00BB0226 The inverted source raster is logically "Or-ed" with the destination raster.
NOTSRCCOPY $00330008 The inverted source raster is copied to the destination raster.
NOTSRCERASE $001100A6 The source and destination raster are first "Or-ed". The resulting bit pattern is then inverted.
PATCOPY $00F00021 The fill pattern is copied to the destination raster.
PATINVERT $005A0049 The fill pattern is "Xor-ed" with the destination raster.
PATPAINT $00FB0A09 The inverted source raster is first "Or-ed" with the fill pattern. The resulting bit pattern is then "Or-ed" with the destination raster.
SCRAND $008800C6 The source and destination raster are "And-ed".
SRCCOPY $00CC0020 The source raster is copied to the destination raster.
SRCERASE $00440328 The source raster is "And-ed" with the inverted destination raster.
SRCINVERT $00660046 The source and destination raster are "Xor-ed".
SRCPAINT $00EE0086 The source and destination raster are "Or-ed".
WHITENESS $00FF0062 All "white" bits are set.

Example

OpenW 3, 600, 0, 300, 300

OpenW 2, 300, 0, 300, 300

OpenW 1, 0, 0, 300, 300

AutoRedraw = True

Local pic As Picture, x%, b%, bmp%

b% = 300

For x% = 0 To 500

Color Rand(_C)

Line Rand(b%), Rand(b%), Rand(b%), Rand(b%)

Next

BitBlt Win_1.hDC, 0, 0, 300, 300, Win_2.hDC, 0, 0, SRCCOPY

// An alternative method...

Get 0, 0, 300, 300, bmp%

Set pic = CreatePicture(bmp%, 1)

Win_3.Picture = pic

Do : Sleep : Until MouseK = 2 /* Right-click to close windows

CloseW 1

CloseW 2

CloseW 3

Remarks

BitBlt corresponds to Windows function BitBlt().

Warning: BitBlt gets the Source-DC first and then the Dest-DC. This order is different from the order in operating system calls BitBlt(), StretchBlt(), and PatBlt().

If you got problems with BitBlt on a PC under Windows 98, you can solve it with an empty loop to insert a small delay. This problem comes from the driver of your graphic adapter.

See Also

FreeBmp, Patblt, Stretch

{Created by Sjouke Hamstra; Last updated: 24/09/2014 by James Gaite}