我想采取屏幕的特定部分的屏幕截图。这里是来“切割”我想在屏幕部分的坐标:采取屏幕的特定部分的屏幕截图
左: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