예제 #1
0
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;
}
예제 #2
0
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();
}
예제 #3
0
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();
}