本文整理自网络,侵删。
/////////////////抓屏函数
use jpeg;
function CaptureScreen(AFileName:String;pressvalue: integer):string;
var
VBmp: TBitmap;
MyJPEG:TJPEGImage;
begin
VBmp := TBitmap.Create;
try
VBmp.Width := Screen.Width;
VBmp.Height := Screen.Height;
BitBlt(VBmp.Canvas.Handle, 0, 0, Screen.Width, Screen.Height, GetDC(0), 0,0, SRCCOPY); //www.delphitop.com
MyJPEG:=TJPEGImage.Create;
MyJPEG.Assign(VBmp);
MyJPEG.CompressionQuality:=pressvalue;
MyJPEG.Compress;
MyJPEG.SaveToFile(AFileName);
//VBmp.SaveToFile(AFileName);
finally
MyJPEG.Free;
VBmp.Free;
end;
end;
调用格式:CaptureScreen(文件名称,压缩比例(数值越大约清晰))
CaptureScreen('5.jpg',30)
相关阅读 >>
Delphi readprocessmemory 输入进程id 输入读取地址
Delphi idhttp http.get 获取json数据
Delphi getmimetype 查询文件mime类型函数
Delphi tstringlist indexof find 查找字符串
更多相关阅读请进入《Delphi》频道 >>