Link to home
Start Free TrialLog in
Avatar of Igor UL7AAjr
Igor UL7AAjrFlag for Kazakhstan

asked on

TCanvas to TBitmap.

I have a TBitmap and need to copy portion of TCanvas to it.
Something like this:

procedure CopyCanvas(aBitmap : TBitmap; aCanvas : TCanvas; aRect : TRect);
begin
   //  implementation wanted.
end;

PS: I can do it pixel by pixel, but it's incredible slow. There may be BitBlt function?
ASKER CERTIFIED SOLUTION
Avatar of Lischke
Lischke

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of TheNeil
TheNeil

aBitmap.Canvas.CopyRect(aRect, aCanvas, aRect);

This copies the section specified in aRect into exactly the same position on the destination (aBitmap in this case). If you want to copy it to another position then you'll need to modify your parameter list and the CopyRect call:

procedure CopyCanvas(aBitmap : TBitmap; aCanvas : TCanvas; srcRect, destRect : TRect);
BEGIN
  aBitmap.Canvas.CopyRect(destRect, aCanvas, srcRect);
END;

The Neil
Avatar of Igor UL7AAjr

ASKER

Thanx all, faster method, faster answer!
Yup, you are welcome :-)

Ciao, Mike