雙緩衝顯示問題以及圖片

來源:互聯網
上載者:User

標籤:color   io   ar   問題   cti   amp   line   size   

void OnDraw(CDC* pdc, const CRect& rcBounds, const CRect& rcInvalid){if (!pdc)return;CClientDC dc(this);CRect rect; GetClientRect(rect); CDC MemDC;MemDC.CreateCompatibleDC(&dc); CBitmap MemBitmap; if(GetFileAttributes(m_strFileName) == INVALID_FILE_ATTRIBUTES)//顯示文字{MemBitmap.CreateCompatibleBitmap(pdc,rect.right,rect.bottom); CBitmap* pOldBitmap = (CBitmap*)MemDC.SelectObject(&MemBitmap);MemDC.FillSolidRect(&rect,RGB(0xFA, 0xFA, 0xFA)); static CBrush brFrame(RGB(202, 202, 202));MemDC.FrameRect(rcBounds, &brFrame);MemDC.SetTextColor(RGB(128, 128, 128));MemDC.SetBkMode(TRANSPARENT);CString sTextOut(_T("未掃描到圖片"));CRect rcTextOut(rect);const int iTextHeight = MemDC.DrawText(sTextOut, CRect(rcTextOut), DT_CALCRECT | DT_CENTER | DT_WORDBREAK | DT_EDITCONTROL);rcTextOut.DeflateRect(0, (rcTextOut.Height() - iTextHeight) / 2);MemDC.DrawText(sTextOut, rcTextOut, DT_CENTER | DT_SINGLELINE|DT_WORDBREAK | DT_EDITCONTROL);pdc->BitBlt(0, 0, rect.Width(), rect.Height(), &MemDC, 0, 0, SRCCOPY);MemDC.SelectObject(pOldBitmap);MemDC.DeleteDC();DeleteObject(MemBitmap); return;}//顯示圖片         /*HBITMAP hbmp;//LoadImage載入png圖片hbmp = (HBITMAP)::LoadImage(AfxGetInstanceHandle(), m_strFileName, IMAGE_BITMAP, 0, 0, LR_CREATEDIBSECTION|LR_LOADFROMFILE); if( hbmp == NULL ) {return;}*/CImage imgTemp;imgTemp.Load(m_strFileName);if ( MemBitmap.m_hObject ) MemBitmap.Detach();MemBitmap.Attach(imgTemp.Detach());//MemBitmap.Attach( hbmp );DIBSECTION ds;BITMAPINFOHEADER &bminfo = ds.dsBmih; MemBitmap.GetObject( sizeof(ds), &ds );MemDC.SelectObject(&MemBitmap);    //串連位元影像pdc->SetStretchBltMode(HALFTONE);pdc->StretchBlt(0,0,rect.Width(),rect.Height(),&MemDC,0,0,bminfo.biWidth,bminfo.biHeight,SRCCOPY);MemDC.DeleteDC();DeleteObject(imgTemp);}

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.