GetDIBits用法
int GetBitmapFromScreen(char *lpFileName)
{
char *lpBuf;
HBITMAP hBitmap,hOld ;
HDC hDC,hcDC;
BITMAP bb;BITMAPINFO b;
HANDLE hp,fh=NULL;
DWORD dwX,dwY;
//***************
//dwX=GetSystemMetrics(SM_CXSCREEN);
//dwY=GetSystemMetrics(SM_CYSCREEN);
dwX=800;
dwY=600;
hDC=GetDC(0);
hcDC=CreateCompatibleDC(hDC);
hBitmap=CreateCompatibleBitmap(hDC,dwX,dwY);
hOld=(HBITMAP)SelectObject(hcDC,hBitmap);
BitBlt(hcDC,0, 0,dwX,dwY, hDC, 0, 0, SRCCOPY);
bb.bmWidth=dwX;
bb.bmHeight =dwY;
bb.bmPlanes = 1;
bb.bmWidthBytes=bb.bmWidth*3;
bb.bmBitsPixel=3;
bb.bmType=0;
b.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
b.bmiHeader.biWidth=dwX;
b.bmiHeader.biHeight =dwY;
b.bmiHeader.biPlanes = 1;
b.bmiHeader.biBitCount =24;
b.bmiHeader.biCompression = BI_RGB;
b.bmiHeader.biSizeImage = 0;
b.bmiHeader.biXPelsPerMeter = 0;
b.bmiHeader.biYPelsPerMeter = 0;
b.bmiHeader.biClrUsed = 0;
b.bmiHeader.biClrImportant = 0;
b.bmiColors[0].rgbBlue=8;
b.bmiColors[0].rgbGreen=8;
b.bmiColors[0].rgbRed=8;
b.bmiColors[0].rgbReserved=0;
hp=GetProcessHeap();
lpBuf=(char *)HeapAlloc(hp,HEAP_ZERO_MEMORY,bb.bmHeight*bb.bmWidth*4);
GetDIBits(hcDC,hBitmap,0,dwY,lpBuf,&b,DIB_RGB_COLORS);
ReleaseDC(NULL,hDC);
DeleteDC(hcDC);
DeleteObject(hBitmap);
DeleteObject(hOld);
HeapFree(hp,0,lpBuf);
return true;
}
请问各位牛人,用上面的办法,我得到一张图的数据,
那如果我要查该图(150,300)座标的颜色值,要怎么lpBuf查才可以?希望有详细的算法