RSS订阅 | 匿名投稿
您的位置:网站首页 > 图像 > 正文

Delphi实现屏幕截图、窗口截图、指定区域截图

作者:admin 来源:未知 日期:2010/5/22 19:35:15 人气: 标签:

Use Jpeg

procedure TForm1.snapscreen(a,b,c,d:Integer);
var
bmpscreen:Tbitmap;
jpegscreen:Tjpegimage;
FullscreenCanvas:TCanvas;
dc:HDC;
sourceRect, destRect: TRect;
begin
try
dc:=getdc(0);
fullscreencanvas:=Tcanvas.Create;
fullscreencanvas.Handle:=dc;
bmpscreen:=Tbitmap.create;
bmpscreen.Width :=c-a;
bmpscreen.Height :=d-b;
sourcerect:=rect(0,0,c-a ,d-b );
destrect:= rect(a,b,c,d);
bmpscreen.Canvas.CopyRect(sourcerect,fullscreenCanvas,destrect);
jpegscreen:=Tjpegimage.Create ;
jpegscreen.Assign (bmpscreen);
jpegscreen.CompressionQuality:=100;
jpegscreen.SaveToFile(ExtractFilePath(ParamStr(0))+'tmp.jpg');
FullscreenCanvas.Free;
bmpscreen.Free;
jpegscreen.Free ;
ReleaseDC(0, DC);
except
end;
end; // www.delphitop.com

procedure TForm1.Button1Click(Sender: TObject);
begin
snapscreen(self.Left,self.Top,Self.Left+self.Width,Self.Top+self.Height);
end;

读完这篇文章后,您心情如何?
0
0
0
0
0
0
0
0
本文网址: