平台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);