在MSDN上说StretchBlt是内存拷贝,不过我调试程序时发现无论是StretchBlt还是BitBlt执行后内存都不好增加,下面的代码只有在LoadBitmap时内存才增加,void CjiemiantestDlg::InitMemDC()
{
CRect rect;
GetClientRect(&rect);
CDC *pdc=GetDC();
m_memDC.CreateCompatibleDC(pdc);
CBitmap memBitmap;
memBitmap.CreateCompatibleBitmap(pdc,rect.Width(),rect.Height());
m_memDC.SelectObject(&memBitmap);
CBitmap bitmap;
bitmap.LoadBitmap(IDB_BACKGROUND);
BITMAP bmpInfo;
bitmap.GetBitmap(&bmpInfo);
CDC tempDC;
tempDC.CreateCompatibleDC(&m_memDC);
tempDC.SelectObject(&bitmap);
m_memDC.StretchBlt(0,0,rect.Width(),rect.Height(),&tempDC,0,0,bmpInfo.bmWidth,bmpInfo.bmHeight,SRCCOPY);
bitmap.DeleteObject();
tempDC.DeleteDC();
}

解决方案 »

  1.   

    MSDN什么地方说这两个函数是内存拷贝啊。
      

  2.   

    Copies a bitmap from a source rectangle into a destination rectangle, stretching or compressing the bitmap if necessary to fit the dimensions of the destination rectangle. 
      

  3.   

    StretchBlt还是BitBlt是从内存拷贝到显卡上,当然内存不增加.
      

  4.   

    bitmap.LoadBitmap(IDB_BACKGROUND);
    是从静态内存中拷贝一份量到memroy
      

  5.   

    如果目标DC是显示DC的话应该是考到显存上,如果目标DC是自己创建的内存DC话也是一样吗