Your choice of variable names confused me. Screen is a well known
VCL management object and has no canvas property. It seems you have two bitmaps - one to hold a full image and one to hold an arbitrary rect cut out of the full image. CopyRect would be my choice to accomplish this. The code for ClipButtonClick is my test code:
Delphi-Quellcode:
procedure GetViewPort(bmFull, bmPart: TBitmap; TopLeft: TPoint);
var
r: TRect;
begin
with bmPart do
r := Bounds(TopLeft.X, TopLeft.Y, Width, Height);
with bmPart.Canvas do
CopyRect(ClipRect, bmFull.Canvas, r);
end;
procedure TDemoForm.ClipButtonClick(Sender: TObject);
var
bmFull: TBitMap;
begin
bmFull := GrabImage(GetDesktopWindow);
with Image.Picture.Bitmap do
begin
Width := Image.Width;
Height := Image.Height;
end;
GetViewPort(bmFull, Image.Picture.Bitmap, Point(100, 100));
bmFull.Free;
end;
marabu