Home

BitBlt

BitBlt, short for bit-block transfer, is a function in the Windows Graphics Device Interface (GDI) used to copy a rectangular block of pixels from a source device context (DC) to a destination DC. The operation can copy pixels directly or combine them with the destination using a raster-operation code (ROP). BitBlt is a fundamental Blitting primitive in Win32 programming and is commonly used for tasks such as image rendering, scrolling, double buffering, and basic image compositing.

Prototype and behavior: BOOL BitBlt(HDC hdcDest, int nXDest, int nYDest, int nWidth, int nHeight, HDC hdcSrc,

Rasters and codes: The dwRop parameter encodes the raster operation to apply. Common examples include SRCCOPY

Notes: BitBlt supports both monochrome and color bitmaps and can handle overlapping source and destination if

int
nXSrc,
int
nYSrc,
DWORD
dwRop);
The
function
returns
a
nonzero
value
on
success
and
zero
on
failure
(use
GetLastError
for
details).
hdcDest
is
the
destination
DC;
nXDest/nYDest
specify
the
upper-left
corner
in
the
destination;
nWidth/nHeight
define
the
size
of
the
rectangle
to
transfer.
hdcSrc
is
the
source
DC;
nXSrc/nYSrc
specify
the
upper-left
corner
in
the
source.
dwRop
selects
how
the
source
and
destination
pixels
are
combined
during
the
transfer.
(copy
source
to
destination),
SRCINVERT,
SRCAND,
SRCPAINT,
and
DSTINVERT.
There
are
numerous
other
codes,
enabling
various
ways
to
blend
or
mask
pixels.
drawn
within
the
same
DC.
For
scaling,
stretching,
or
more
complex
masking,
other
functions
such
as
StretchBlt,
MaskBlt,
and
TransparentBlt
are
available.