万分感谢!

解决方案 »

  1.   

    这里有一个保存成BMP的例子,不知是否有用
    http://expert.csdn.net/Expert/topic/1574/1574488.xml?temp=.560589
      

  2.   

    CDC dc;
    dc.CreateDC("DISPLAY",NULL,NULL,NULL);
    CBitmap bm;
    int Width=GetSystemMetrics(SM_CXSCREEN);//截取图形的宽度
    int Height=GetSystemMetrics(SM_CYSCREEN);//高度
    bm.CreateCompatibleBitmap(&dc,Width,Height);
    CDC tdc;
    tdc.CreateCompatibleDC(&dc);
    CBitmap*pOld=tdc.SelectObject(&bm);
        tdc.BitBlt(0,0,Width,Height,&dc,0,0,SRCCOPY);//前两个参数就是开始截取的左上角坐标
    tdc.SelectObject(pOld);
    BITMAP btm;
    bm.GetBitmap(&btm);
    DWORD size=btm.bmWidthBytes*btm.bmHeight;
    LPSTR lpData=(LPSTR)GlobalAlloc(GPTR,size);
    /////////////////////////////////////////////
    BITMAPINFOHEADER bih;
    bih.biBitCount=btm.bmBitsPixel;
    bih.biClrImportant=0;
    bih.biClrUsed=0;
    bih.biCompression=0;
    bih.biHeight=btm.bmHeight;
    bih.biPlanes=1;
    bih.biSize=sizeof(BITMAPINFOHEADER);
    bih.biSizeImage=size;
    bih.biWidth=btm.bmWidth;
    bih.biXPelsPerMeter=0;
    bih.biYPelsPerMeter=0;
    GetDIBits(dc,bm,0,bih.biHeight,lpData,(BITMAPINFO*)&bih,DIB_RGB_COLORS);
    static int filecount=0;

    BITMAPFILEHEADER bfh;
    bfh.bfReserved1=bfh.bfReserved2=0;
    bfh.bfType=((WORD)('M'<< 8)|'B');
    bfh.bfSize=54+size;
    bfh.bfOffBits=54;

    CString m_strTempBmp;
    m_strTempBmp.Format("%s%s","c:\\","temp.bmp");
    CFile bf;
    if(bf.Open(m_strTempBmp,CFile::modeCreate|CFile::modeWrite))
    {
    bf.WriteHuge(&bfh,sizeof(BITMAPFILEHEADER));
    bf.WriteHuge(&bih,sizeof(BITMAPINFOHEADER));
    bf.WriteHuge(lpData,size);
    bf.Close();
    }
    GlobalFree(lpData);