delphi实现抓屏压缩并保存桌面图片


/////////////////抓屏函数
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)
联系电话:
020-00000000
联系电话:
020-00000000
联系电话:
020-12345678