CRect rc;
HWND hDesktopWnd= ::GetDesktopWindow();
::GetWindowRect(hDesktopWnd, &rc);
int width=rc.Width();
int height=rc.Height();
HDC hdc = ::GetDC(hDesktopWnd);
HBITMAP hBmp = CreateCompatibleBitmap(hdc, width,height);
HBITMAP holdBmp=(HBITMAP)::SelectObject(MemoDC,hBmp);
BitBlt(MemoDC, 0 , 0,width, height, hdc, 0, 0, SRCCOPY);         LPBITMAPINFO    pbmi;
pbmi->bmiHeader.biWidth =width;
pbmi->bmiHeader.biHeight =height;
         //
GetDIBits(MemoDC,hBmp,0,height,m_plbits,pbmi,DIB_RGB_COLORS);
         有没有更好的方法

解决方案 »

  1.   

    用DirectDraw看看
    不过如果硬件不支持DirectDraw,那么DirectDraw会比GDI慢Command what is yours
    Conquer what is not
      

  2.   

    转换成dib,太花时间了,有没有其他的方法
      

  3.   

    GetDIBits是个相当耗时的函数!
    我觉得这里无论如何不能用这个函数.
    可以用GetObject试试.(肯定会快,但不知道是否能达到你要求的速度)
    BITMAP bmp;
    ::GetObject(hBmp, sizeof(BITMAP), &bmp);
    其中BITMAP::bmBits就是图像数据部分,读取其中的数据,你就要关心一下位图的格式了(BITMAP中其他项).
    还有一点很关键:
    这个hBmp并不需要每次都创建,所以,GetObject也不是每次都创建的.
      

  4.   

    用汇编,直接从显存取数据是最快的办法,其次是DirectDraw
    不要使用CDC或者HDC,而是用其它的,例如VFW的函数,画图快,失真少,内存使用小,类似于DrawDibDraw的一组函数,就是Video For Windows的API函数。
    DirectDraw是DirectX的一部分,从微软的网站上下载DirectX SDK开发包,然后研究DirectDraw部分。