Delphi 抓取屏幕图象遇到了一点小问题,高人解答一下

来源:百度知道 编辑:UC知道 时间:2024/05/24 13:58:27
具体代码如下:

var
C:TCanvas;
B:TBitmap;
begin
B :=TBitmap.Create;
C :=TCanvas.Create;
// 设置Bitmap的大小
B.Width := 600;
B.Height := 600;
C.Handle:=GetDC(0);
B.Canvas.CopyRect(Rect(0,0,screen.Width,Screen.Height),
C,Rect(0,0,screen.Width,Screen.Height));
B.SaveToFile('d:\test.bmp');

这样截取到的图象总是从屏幕坐标0,0的位置开始抓取height,width为600的图象,我想请问一下,如何让它从屏幕坐标100,100的位置开始抓取600×600的图象呢

var
C:TCanvas;
B:TBitmap;
begin
B :=TBitmap.Create;
C :=TCanvas.Create;
// 设置Bitmap的大小
B.Width := 600;
B.Height := 600;
C.Handle:=GetDC(0);
B.Canvas.CopyRect(Rect(0,0,screen.Width,Screen.Height),
C,Rect(100,100,screen.Width,Screen.Height));
B.SaveToFile('d:\test.bmp');