平台VC++ 2010 Win7 32bit
我想抓取某個視窗的畫面
在網路上看到這段程式說可以用
想問一下
1.為什麼它用的陣列大小是width*height*4(要乘以四呢?)
2.這樣抓到的bitmap位元數是16bit的嗎?
::GetWindowRect(hwndAbout,&aRect);
int width = aRect.bottom;
int height = aRect.right;
HDC hdc;
hdc=::GetDC(hwndAbout);
HDC memDC = ::CreateCompatibleDC (hdc);
HBITMAP bitmap = ::CreateCompatibleBitmap(hdc,width,height);
//copy
HGDIOBJ old = ::SelectObject (memDC, bitmap);
::BitBlt(memDC,0,0,width,height,hdc,0,0,SRCCOPY);
unsigned char *pixels = new unsigned char[width*height*4];
::GetBitmapBits(bitmap,width*height*4,pixels);
::SelectObject (memDC, old);
DeleteObject(bitmap);
DeleteDC(memDC);
DeleteDC(hdc);