vc double buffer 无闪烁刷新

OnDraw()函数里面的代码,其中CvvImage使用的是opencv1.0开源库中的函数

 

int sourceWidth = sourceImage->width; int sourceHeight = sourceImage->height; CvvImage cimg; cimg.CopyOf(m_iplRGB, 1); // 复制后为单通道 // 图像居中显示 CRect clientRect; GetClientRect(&clientRect); CPoint center; center = clientRect.CenterPoint(); int offsetX = center.x - sourceWidth / 2; int offsetY = center.y - sourceHeight / 2; // double-buffer for no flashing refresh CDC dcMem; CBitmap bmp; dcMem.CreateCompatibleDC(pDC); bmp.CreateCompatibleBitmap(pDC, clientRect.Width(), clientRect.Height()); dcMem.SelectObject(&bmp); dcMem.FillSolidRect(clientRect, pDC->GetBkColor()); CRect rect(offsetX, offsetY, offsetX + sourceWidth, offsetY + sourceHeight); cimg.DrawToHDC(dcMem.m_hDC, &rect); pDC->SetBkColor(TRANSPARENT); pDC->BitBlt(0, 0, clientRect.Width(), clientRect.Height(), &dcMem, 0, 0, SRCCOPY); dcMem.DeleteDC(); bmp.DeleteObject();

你可能感兴趣的:(buffer)