手机
当前位置:查字典教程网 >编程开发 >Delphi >Delphi实现截屏存盘的方法
Delphi实现截屏存盘的方法
摘要:本文实例讲述了Delphi实现截屏存盘的方法。分享给大家供大家参考。具体分析如下:该实例可实现截取屏幕,并保存为JPEG文件格式的功能。pr...

本文实例讲述了Delphi实现截屏存盘的方法。分享给大家供大家参考。具体分析如下:

该实例可实现截取屏幕,并保存为JPEG文件格式的功能。

procedure TForm1.ScreenCap(LeftPos,TopPos,RightPos,BottomPos:integer); var RectWidth,RectHeight:integer; SourceDC,DestDC,Bhandle:integer; Bitmap:TBitmap; MyJpeg: TJpegImage; Stream:TMemoryStream; begin MyJpeg:= TJpegImage.Create; RectWidth:=RightPos-LeftPos; RectHeight:=BottomPos-TopPos; SourceDC:=CreateDC('DISPLAY','','',nil); DestDC:=CreateCompatibleDC(SourceDC); Bhandle:=CreateCompatibleBitmap(SourceDC, RectWidth,RectHeight); SelectObject(DestDC,Bhandle); BitBlt(DestDC,0,0,RectWidth,RectHeight,SourceDC, LeftPos,TopPos,SRCCOPY); Bitmap:=TBitmap.Create; Bitmap.Handle:=BHandle; Stream := TMemoryStream.Create; Bitmap.SaveToStream(Stream); Stream.Free; try MyJpeg.Assign(Bitmap); MyJpeg.CompressionQuality:=70; MyJpeg.Compress; MyJpeg.SaveToFile('C:MyJPEGImage.JPG'); finally MyJpeg.Free; Bitmap.Free; DeleteDC(DestDC); ReleaseDC(Bhandle,SourceDC); end; end;

希望本文所述对大家的Delphi程序设计有所帮助。

【Delphi实现截屏存盘的方法】相关文章:

在Delphi实现在数据库中存取图像的图文演示无错

Delphi中设置条件断点的方法讲解

Delphi中对时间操作方法汇总

Delphi实现判断网址是否存在及是否可以打开的方法

Delphi实现木马文件传输代码实例

delphi建立、读取、存贮INI文件的方法《三》

Delphi实现图像文本旋转特效完整实例代码

Delphi实现树型结构具体实例

Delphi实现毫秒级别的倒计时实例代码

Delphi下OpenGL2d绘图之画四边形的方法

精品推荐
分类导航