以下的抓图,来源于网上。

function dlGetDesktopRect(nLeft,nTop,nWidth,nHeight:integer;pixel:TPixelFormat):TBitmap;
var
   dcDesk:hdc;
   bmp:TBitmap;
begin
  bmp:=TBitmap.Create;
  bmp.PixelFormat := pixel;
  bmp.Width:=nWidth;
  bmp.Height:=nHeigth;
  dcDesk:=GetDC(GetDesktopWindow);
  BitBlt(bmp.Canvas.Handle,0,0,nWidth,nHeigth,dcDesk,nLeft,nTop,SRCCOPY) ;
  result:=bmp;
  DeleteDC(deskdc);
end;

抓全屏

bmp:=dlGetDesktopRect(0,0,screen.Width,screen.Height,pixel);

抓游戏窗口

GetWindowRect(hGame,rect);
bmp:=dlGetDesktopRect(rect.Left,rect.Top,rect.Right-rect.Left,rect.Bottom-rect.Top,pixel);

抓游戏Client窗口

ClientToScreen(hGame,rect);

bmp:=dlGetDesktopRect(rect.Left,rect.Top,rect.Right-rect.Left,rect.Bottom-rect.Top,pixel);

这样抓的是在前台活动的窗口图像,不管是普通的还是用DX画的。

相关文章:

  • 2021-12-19
  • 2022-12-23
  • 2021-10-28
  • 2021-12-24
  • 2021-12-24
  • 2021-06-10
  • 2021-05-16
猜你喜欢
  • 2021-09-10
  • 2021-05-28
  • 2021-08-17
  • 2022-01-13
  • 2022-12-23
  • 2021-12-03
  • 2021-07-12
相关资源
相似解决方案