void CScreenViewWnd::OnLButtonDblClk(UINT nFlags, CPoint point) { CDialog::OnLButtonDblClk(nFlags, point); if (!valid_camera(_selectCamera)) { return; } _sync_drawing.Lock(); _frameQueue.clear(); // frame_buffer clear CClientDC dc(this); CMemDC MemDC; MemDC.CreateDC(&dc, &_bmpCanvas); MemDC->FillSolidRect(_rectScreen, RGB(0, 0, 0)); MemDC.DeleteDC(); UINT32 cameraList = 0; if (_fuse1x1Mode == false) { // 1x1 mode setting _fuse1x1Mode = true; setScreenLayout(ScreenFormatter::LAYOUT_1X1, _selectCamera, _rectScreen); // watch for only selected camera cameraList |= 1 << _selectCamera; } else { _fuse1x1Mode = false; setScreenLayout(_countLiveCamera); for (int i = 0; i < _countLiveCamera; ++i) { CameraView& rcamera = _cameraView[i]; if (rcamera.is_visible()) { cameraList |= 1 << i; } } } _sync_drawing.Unlock(); CWnd* lpParent = GetParent(); if (lpParent != NULL && lpParent->GetSafeHwnd()) { lpParent->PostMessage(UM_SCREEN_DBLCLICK, static_cast<WPARAM>(cameraList), static_cast<LPARAM>(MAX_CAMERA_COUNTS)); } Invalidate(FALSE); }
BOOL CScreenViewWnd::OnEraseBkgnd(CDC* pDC) { CRect rctClip; CMemDC MemDC; MemDC.CreateDC(pDC, &_bmpCanvas); pDC->GetClipBox(rctClip); pDC->BitBlt(rctClip.left, rctClip.top, rctClip.Width(), rctClip.Height(), &MemDC, rctClip.left, rctClip.top, SRCCOPY); return TRUE; }
void CScreenViewWnd::OnPaint() { CRect rctClip, rctClient, rctDraw; { CPaintDC dc(this); dc.GetClipBox(rctClip); } GetClientRect(rctClient); rctClip.InflateRect(100, 100); rctDraw.IntersectRect(rctClip, rctClient); ASSERT(_bmpCanvas.GetSafeHandle() != NULL); CDC* pDC = GetDC(); CMemDC MemDC; MemDC.CreateDC(pDC, &_bmpCanvas); _sync_drawing.Lock(); if (_fuse1x1Mode == false) { COLORREF clrBorder; for (int i = 0; i < _countCamera; i++) { if (!_cameraView[i].is_visible()) { continue; } clrBorder = (_selectCamera == i) ? RGB(0, 255, 0) : RGB(255, 255, 255); MemDC->Draw3dRect(_cameraView[i].rect(), clrBorder, clrBorder); } } else { MemDC->Draw3dRect(_cameraView[_selectCamera].rect(), RGB(0, 255, 0), RGB(0, 255, 0)); } _sync_drawing.Unlock(); pDC->BitBlt(rctDraw.left, rctDraw.top, rctDraw.Width(), rctDraw.Height(), &MemDC, rctDraw.left, rctDraw.top, SRCCOPY); ReleaseDC(pDC); pDC = NULL; }
bool CScreenViewWnd::drawReferImage() { CDC* parentDC = GetDC(); CMemDC MemDC; ASSERT(_bmpReferCanvas.m_hObject); MemDC.CreateDC(parentDC, &_bmpReferCanvas); CDC* pDC = &MemDC; pDC->PatBlt(0, 0, _imageWidth, _imageHeight, WHITENESS); if (_shapeManager) { Gdiplus::Graphics graphics(*pDC); _shapeManager->fillAllShapes(&graphics); } return true; }
void CScreenViewWnd::clearScreen() { _sync_drawing.Lock(); for (int i = 0; i < _countCamera; i++) { _cameraView[i].resetCamera(); } _selectCamera = -1; _countLiveCamera = __min(_countCamera, 16); CDC* pDC = GetDC(); CMemDC MemDC; MemDC.CreateDC(pDC, &_bmpCanvas); MemDC->FillSolidRect(_rectScreen, RGB(0, 0, 0)); MemDC.DeleteDC(); ReleaseDC(pDC); _sync_drawing.Unlock(); Invalidate(TRUE); }
void CScreenViewWnd::updateStatus(int camera) { if (GetSafeHwnd() == NULL) { return; } _sync_drawing.Lock(); if (_fuse1x1Mode == true && _selectCamera != camera) { _sync_drawing.Unlock(); return; } if (!_cameraView[camera].is_visible()) { _sync_drawing.Unlock(); return; } int camstatus = getCameraState(camera); CClientDC dc(this); CMemDC MemDC; MemDC.CreateDC(&dc, &_bmpCanvas); const CRect& rctcamera = _cameraView[camera].rect(); if (camstatus != CameraView::ENABLED) { MemDC->FillSolidRect(rctcamera, (camstatus == CameraView::NO_VIDEO) ? RGB(0, 0, 255) : RGB(0, 0, 0)); } CString strStatus = _T(""); switch (camstatus) { case CameraView::NO_VIDEO : strStatus = _T("No Video"); break; case CameraView::NOT_CONNECTED: strStatus = _T("Not Connected"); break; case CameraView::COVERT_LEVEL1 : strStatus = _T("Covert"); break; case CameraView::COVERT_LEVEL2 : strStatus = _T(""); break; } CRect rctosd = rctcamera; rctosd.DeflateRect(5, 2, 5, 3); CFont* lpFontPrev = MemDC->SelectObject(&_fontText); drawText(&MemDC, strStatus, rctosd, DT_CENTER | DT_VCENTER | DT_SINGLELINE); drawText(&MemDC, getCameraTitle(camera), rctosd, DT_LEFT | DT_TOP | DT_SINGLELINE); MemDC->SelectObject(lpFontPrev); MemDC->Draw3dRect(rctcamera, RGB(255, 255, 255), RGB(255, 255, 255)); dc.BitBlt(rctcamera.left, rctcamera.top, rctcamera.Width(), rctcamera.Height(), &MemDC, rctcamera.left, rctcamera.top, SRCCOPY); _sync_drawing.Unlock(); }
void CScreenViewWnd::drawImage(int camera, LPBYTE pImage, const CSize& size, SDK_TIME_T time) { CameraView& rcamView = _cameraView[camera]; _sync_drawing.Lock(); if (!rcamView.is_visible() || !rcamView.is_enable()) { _sync_drawing.Unlock(); return; } _bmpInfohead.biWidth = size.cx; _bmpInfohead.biHeight = size.cy; _bmpInfohead.biSizeImage = size.cx * size.cy * _bmpInfohead.biBitCount >> 3; CDC* pDC = GetDC(); if ((size.cx > 0) && (size.cy > 0)) { CMemDC MemDC; ASSERT(_bmpCanvas.m_hObject); MemDC.CreateDC(pDC, &_bmpCanvas); CRect rctDest = rcamView.rect(); CRect rctImage = rctDest; if (_fuseAspectRatio) { imageAspectRatio(size.cx, size.cy, rctImage, rctImage); if (rcamView.rectImage() != rctImage) { MemDC->FillSolidRect(rctDest, RGB(0, 0, 0)); } else { const int letter_t = rctImage.top - rctDest.top; const int letter_b = rctDest.bottom - rctImage.bottom; const int letter_l = rctImage.left - rctDest.left; const int letter_r = rctDest.right - rctImage.right; if (letter_t > 1 || letter_b > 1 || letter_l > 1 || letter_r > 1) { if (letter_t > 0) { MemDC->FillSolidRect(rctDest.left + 1, rctDest.top, rctDest.Width() - 2, letter_t, RGB(0, 0, 0)); } if (letter_b > 0) { MemDC->FillSolidRect(rctDest.left + 1, rctImage.bottom, rctDest.Width() - 2, letter_b, RGB(0, 0, 0)); } if (letter_l > 0) { MemDC->FillSolidRect(rctDest.left + 1, rctImage.top, letter_l, rctImage.Height(), RGB(0, 0, 0)); } if (letter_r > 0) { MemDC->FillSolidRect(rctImage.right, rctImage.top, letter_r, rctImage.Height(), RGB(0, 0, 0)); } } } } rcamView.setRectImage(rctImage); ::DrawDibDraw(_hDrawDib, MemDC, rctImage.left, rctImage.top, rctImage.Width(), rctImage.Height(), &_bmpInfohead, pImage, 0, 0, size.cx, size.cy, 0); drawReferLines(&MemDC); CRect rctOSD = rctDest; rctOSD.DeflateRect(5, 2, 5, 3); CTime tmFrame(time); CString strTime = (rctOSD.Width() < 140) ? tmFrame.Format(_T("%H:%M:%S")) : tmFrame.Format(_T("%y-%m-%d %H:%M:%S")); CString strTitle = getCameraTitle(camera); /* CFont* lpFontPrev = MemDC->SelectObject(&_fontText); drawText(&MemDC, strTitle, rctOSD, DT_TOP | DT_LEFT | DT_SINGLELINE); drawText(&MemDC, strTime, rctOSD, DT_BOTTOM | DT_CENTER | DT_SINGLELINE); MemDC->SelectObject(lpFontPrev); */ COLORREF clrBorder = (_selectCamera == camera) ? RGB(0, 255, 0) : RGB(255, 255, 255); MemDC->Draw3dRect(rctDest, clrBorder, clrBorder); pDC->BitBlt(rctDest.left, rctDest.top, rctDest.Width(), rctDest.Height(), &MemDC, rctDest.left, rctDest.top, SRCCOPY); } ReleaseDC(pDC); _sync_drawing.Unlock(); }