//DEL void CRussiaView::OnPaint() 
//DEL {
//DEL     CPaintDC dc(this); // device context for painting
//DEL     OnPrepareDC(&dc);
//DEL     CDC memdc;
//DEL     memdc.CreateCompatibleDC(&dc);
//DEL     CBitmap bitmap;
//DEL     CRect rc;
//DEL     GetClientRect(rc);
//DEL     bitmap.CreateCompatibleBitmap(&dc,rc.left-rc.right,rc.bottom-rc.top);
//DEL     CBitmap * poldBitmap=memdc.SelectObject(&bitmap);
//DEL //    memdc.SelectClipRgn(NULL);
//DEL     memdc.PatBlt(0,0,rc.Width(),rc.Height(),PATCOPY);
//DEL     OnDraw(&memdc);
//DEL     dc.BitBlt(0,0,rc.Width(),rc.Height(),&memdc,0,0,SRCCOPY);
//DEL }

解决方案 »

  1.   

    void CIllpcView::Showbmp(CString m_strBRoute)//参数是图片路径
    {
    CDC* pDC;
    pDC=GetDC();
    HBITMAP hBmpOri=(HBITMAP)LoadImage(::AfxGetInstanceHandle(),m_strBRoute,IMAGE_BITMAP,0,0,LR_LOADFROMFILE);
    BITMAP bmpOrigin;
    ::GetObject(hBmpOri,sizeof(BITMAP),&bmpOrigin);
    BITMAPINFOHEADER BmpInfoHeader;
    BYTE* pBits;
        BmpInfoHeader.biSize=sizeof(BITMAPINFOHEADER);
    BmpInfoHeader.biWidth=bmpOrigin.bmWidth;
    BmpInfoHeader.biHeight=bmpOrigin.bmHeight;
    BmpInfoHeader.biPlanes=1;
    BmpInfoHeader.biBitCount=24;
    BmpInfoHeader.biCompression=BI_RGB;
    BmpInfoHeader.biSizeImage=0;
    BmpInfoHeader.biXPelsPerMeter=0;
    BmpInfoHeader.biYPelsPerMeter=0;
    BmpInfoHeader.biClrUsed=0;
    BmpInfoHeader.biClrImportant=0;
    HBITMAP hBmp=::CreateDIBSection(NULL,(BITMAPINFO*)&BmpInfoHeader,0,(void**)&pBits,NULL,0);
    int nResult=::GetDIBits(pDC->GetSafeHdc(),hBmpOri,0,bmpOrigin.bmHeight,pBits,(BITMAPINFO*)&BmpInfoHeader,DIB_RGB_COLORS);
    StretchDIBits(pDC->GetSafeHdc(),0,0,800,600,0,0,bmpOrigin.bmWidth,bmpOrigin.bmHeight,pBits,(BITMAPINFO*)&BmpInfoHeader,DIB_RGB_COLORS,SRCCOPY);
    ::DeleteObject(hBmp);
    ::DeleteObject(hBmpOri);
    }