打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
delphi截屏
unit Unit2;interfaceuses  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,  Dialogs, StdCtrls, Buttons,jpeg;type  TForm2 = class(TForm)    BitBtn1: TBitBtn;    procedure BitBtn1Click(Sender: TObject);  private    procedure ScreenCap(LeftPos, TopPos, RightPos, BottomPos: integer);    { Private declarations }  public    { Public declarations }  end;var  Form2: TForm2;implementation{$R *.dfm}procedure TForm2.BitBtn1Click(Sender: TObject);begin  ScreenCap(0,0,Screen.Width,Screen.Height);end;procedure TForm2.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;end.

截屏并保存为JPG的话,推荐用FastDIB,而且转换为JPEG用的是Intel的ijl库

本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
Delphi中压缩流和解压流的应用说明
MFC 位图旋转
VB抓图
GDI C++(2) 位图的绘制
delphi adoquery 操作流
【新提醒】【C#指定图片添加文字(仅PC)】
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服