Delphi实现截屏存盘的方法
<p>本文实例讲述了Delphi实现截屏存盘的方法。分享给大家供大家参考。具体分析如下:</p><p>该实例可实现截取屏幕,并保存为JPEG文件格式的功能。</p>
<div class="jb51code">
<pre class="brush:delphi;">
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;</pre>
</div>
<p>希望本文所述对大家的Delphi程序设计有所帮助。</p>
<div class="art_xg">
<b>您可能感兴趣的文章:</b><ul><li>Delphi 用DLL实现插件的简单实例</li><li>Delphi 根据字符串找到函数并执行的实例</li><li>Delphi 中内存映射对于大文件的使用</li><li>Delphi提取PDF文本实例</li><li>Delphi XE5 为Android应用制作签名的方法(图文)</li><li>ListView 百分比进度条(delphi版)</li><li>Delphi实现窗体感知鼠标滑过并自动隐藏与显示窗口的方法</li><li>Delphi 实现软件自动升级的功能</li></ul>
</div>
</div>
<!--endmain-->
頁:
[1]