IceCold
IceCold

Reputation: 21231

How to copy part of a BMP to a canvas?

I have a large bitmap (pf24bit). I want to copy only a part (small rectangle) of that image to a canvas. The canvas is double buffered.

frmTester.Canvas.CopyRect() will do the trick, but it has two problems:

  1. the copied image is a bit corrupted
  2. it is damn slow.

BitBlt is super fast, but it will copy the entire bitmap.

Upvotes: 0

Views: 1053

Answers (1)

Andreas Rejbrand
Andreas Rejbrand

Reputation: 109158

BitBlt is super fast, but it will copy the entire bitmap.

Actually, no: BitBlt allows you to copy only a rectangular part of the source, specified using the x1, y1, cx, and cy parameters.

However, the same width and height are used for the source and the destination rectangles, so BitBlt cannot be used to stretch (or scale) the part you copy.

StretchBlt lets you do this, though.

Upvotes: 3

Related Questions