商务合作:179001057@qq.com

个人写的双缓冲 CDC绘图函数

技术2022-05-11  1


某平台价值19860元的编程课程资料免费领取【点我领取】


void CDRImageStatic::ShowImg(CDC *dc, CRect rect){ CBitmap bmp;    bmp.CreateCompatibleBitmap(dc, m_nWidth, m_nHeight);    CBitmap* pOld=NULL;

 CDC memDC; memDC.CreateCompatibleDC( dc ); if (m_nColor!=NULL) {    EnterCriticalSection(&csImgCriticalSection);  bmp.SetBitmapBits(sizeof(*m_nColor)*m_nHeight*m_nWidth, m_nColor);  LeaveCriticalSection(&csImgCriticalSection);   pOld = memDC.SelectObject( &bmp );   } if((m_nDXA==0)) {  EnterCriticalSection(&csMyCriticalSection);

  int oldmode=memDC.SetBkMode(TRANSPARENT);  CPen * pOldPen=memDC.SelectObject(&m_Pen);  

  memDC.MoveTo(rect.right-m_nCurPosX,0);  memDC.LineTo(rect.right-m_nCurPosX,rect.bottom); 

  memDC.SelectObject(pOldPen);  memDC.SetBkMode(oldmode);

  BOOL bbR=m_nCurPosX!=m_nOldPosX;

  if (!this->m_blCreateLine || bbR)  {   this->m_blCreateLine=TRUE;   m_nOldPosX=m_nCurPosX;   InvalidateRect(rect,FALSE);  }  memDC.MoveTo(CPoint(0,0));  LeaveCriticalSection(&csMyCriticalSection); }

 dc->BitBlt( rect.left, rect.top, rect.Width(), rect.Height(), &memDC, 0, 0, SRCCOPY ); if (pOld!=NULL) {  memDC.SelectObject(pOld); }  memDC.DeleteDC(); bmp.DeleteObject(); }


最新回复(0)