加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 大数据 > 正文

delphi截屏

发布时间:2020-12-15 09:58:12 所属栏目:大数据 来源:网络整理
导读:procedure ScreenCap(); const WW=256; HH=256;var BmpBits:Pointer; FDeskHWnd:Hwnd; SourceDC,DestDC,originHandel:integer; i:Integer; ABitmap:HBitmap; s:TBitmap; BmpInfHead:TBitmapInfoHeader; Info : TBitMapInfo; bits:Pointer; Apointer:Pointer;
procedure ScreenCap();
  const
 WW=256;
 HH=256;
var
 BmpBits:Pointer;
 FDeskHWnd:Hwnd;
 SourceDC,DestDC,originHandel:integer;
 i:Integer;
 ABitmap:HBitmap;
 s:TBitmap;
 BmpInfHead:TBitmapInfoHeader;
 Info : TBitMapInfo;
 bits:Pointer;
 Apointer:Pointer;

begin

 //Create DIB
 Info.bmiHeader.biSize := sizeof(BITMAPINFOHEADER);
 Info.bmiHeader.biWidth := WW; //width
 Info.bmiHeader.biHeight := HH; //height
 Info.bmiHeader.biPlanes := 1;
 Info.bmiHeader.biBitCount := 32;
 Info.bmiHeader.biClrUsed := 0;
 Info.bmiHeader.biCompression := BI_RGB;
 Info.bmiHeader.biClrImportant := 0;
 ABitmap := CreateDIBSection(SourceDC,Info,DIB_RGB_COLORS,APointer,0);
 SourceDC:= GetDC(0);
 DestDC:=CreateCompatibleDC(SourceDC);
 ABitmap:=CreateCompatibleBitmap(SourceDC,WW,HH);
 originHandel:=selectObject(DestDC,Abitmap);
 BitBlt(DestDC,HH,SourceDC,SRCCOPY);
 GetDIBits(DestDC,Abitmap,480,Apointer,info,DIB_RGB_COLORS);
 s :=TBitmap.Create;
 s.Handle :=ABitmap;
 selectObject(DestDC,originHandel);

 s.SaveToFile('d:q2.bmp');
 DeleteDC(DestDC);
 ReleaseDC(0,SourceDC);
end;

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读