我想採取屏幕的特定部分的屏幕截圖。這裏是來「切割」我想在屏幕部分的座標:採取屏幕的特定部分的屏幕截圖
左:442 上衣:440 右:792 底部:520
也就是說,寬度爲350像素和高度的矩形80px。但我不知道如何使用CopyRect來實現這個任務,而是我得到一個空白圖像。這裏是我的代碼:
function screenshot: boolean;
var
Bild : TBitmap;
c: TCanvas;
rect_source, rect_destination : TRect;
begin
c := TCanvas.Create;
bild := tbitmap.Create;
c.Handle := GetWindowDC(GetDesktopWindow);
try
rect_source := Rect(0, 0, Screen.Width, Screen.Height);
rect_destination := Rect(442,440,792,520);
Bild.Width := 350;
Bild.Height := 80;
Bild.Canvas.CopyRect(rect_destination, c, rect_source);
Bild.savetofile('c:\users\admin\desktop\screen.bmp');
finally
ReleaseDC(0, c.Handle);
Bild.free;
c.Free;
end;
end;
http://stackoverflow.com/questions/8360368/how-to-use-copyrect-method-in-delphi – fantaghirocco