Board index » delphi » Canvas With Bitmap

Canvas With Bitmap


2005-11-04 06:20:04 AM
delphi57
hi
How I can transfer the canvas of a component to Bitmap for save the imagen
 
 

Re:Canvas With Bitmap

well you have to create TBitmap first then copyrect from your canvas
example
var
Bitmap: TBitmap;
R: TRect;
begin
R := Rect(10, 10, 100, 100);
Bitmap := TBitmap.Create;
try
Bitmap.Width := R.Right - R.Left;
Bitmap.Height := R.Bottom - R.Top;
Bitmap.Canvas.CopyRect(Rect(0, 0, Bitmap.Width, Bitmap.Height),
YourCanvas.Handle, R);
Bitmap.SaveToFile('c:\hello.bmp');
finally
Bitmap.Free;
end;
end;
see help file for more detail what the procedure do :)
cheers,