【发布时间】:2016-08-01 13:27:25
【问题描述】:
我正在尝试截取屏幕特定部分的屏幕截图。这是我要“剪切”的屏幕部分的坐标:
左:442 顶部:440 右:792 底部:520
也就是一个宽350px,高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;
【问题讨论】:
标签: delphi delphi-xe delphi-2007