delphi抓全屏图,游戏窗口,游戏Client窗口

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

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画的。

 

posted @ 2010-08-23 17:13  devlyn  阅读(970)  评论(0编辑  收藏  举报