可否创建一个MemDC,再得到Desktop或你要的窗口的WndDC,从WndDC BitBlt 到 MemDC,就可以通过访问MemDC联系着的Bitmap的内容(是一个数组来的)来知道你要的颜色了。
希望能帮得上你,
如果你用这个方法解决了问题,请告知我。
如果有另外的方法,也请你告诉我。

解决方案 »

  1.   

    如果你是在MS Windows下,可以这样做://在24位真彩模式下
    //把屏幕上的0,0,100,100的点信息抓下来
    UINT cx=100,cy=100;//cx=width,cy=height
    UINT x=0,y=0;//x=startX,y=startYBITMAPINFO bitmapInfo;
    unsigned char * pBuffer=new unsigned char[cx*cy*3];
    memset(pBuffer,0,sizeof(char)*(cx*cy*3));
    memset(&bitmapInfo,0,sizeof(BITMAPINFO));HDC hScreenDC = ::GetDC(NULL);
    HDC hMemDC = ::CreateCompatibleDC(hScreenDC);
    HBITMAP hBitmap = ::CreateCompatibleBitmap(hScreenDC,cx,cy);
    ::SelectObject(hMemDC,hBitmap);
    ::BitBlt(hMemDC,0,0,cx,cy,hScreenDC,x,y,SRCCOPY);bitmapInfo.bmiHeader.biWidth=cx;
    bitmapInfo.bmiHeader.biHeight=cy;
    bitmapInfo.bmiHeader.biBitCount=24;
    bitmapInfo.bmiHeader.biPlanes=1;
    bitmapInfo.bmiHeader.biSizeImage=cx*cy*3;
    bitmapInfo.bmiHeader.biSize=sizeof(BITMAPINFOHEADER);::GetDIBits(hMemDC,hBitmap,0,cy,pBuffer,&bitmapInfo,DIB_RGB_COLORS);
    //... you do here
    delete []pBuffer;
    ::ReleaseDC(NULL,hScreenDC);
    ::DeleteDC(hMemDC);
    ::DeleteObject(hBitmap);