⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sshowcenter.cpp

📁 此代码使用bmp图作为主要界面
💻 CPP
📖 第 1 页 / 共 4 页
字号:
		rectlist[0].bottom=rectHeight/4 - 5;
		
		rectlist[1].left=6;
		rectlist[1].top=rectHeight/4+6;
		rectlist[1].right=rectWidth/4 - 5;
		rectlist[1].bottom=rectHeight/2 - 5;
		
		rectlist[2].left=6;
		rectlist[2].top= rectHeight/2+6;
		rectlist[2].right=rectWidth/4 - 5;
		rectlist[2].bottom=rectHeight/2+rectHeight/4 - 5;
		
		//---------------------------------------------------------
		rectlist[3].left=6;
		rectlist[3].top=rectHeight/2+rectHeight/4+6;
		rectlist[3].right=rectWidth/4 - 5;
		rectlist[3].bottom=rectHeight - 7;
		
		rectlist[4].left=rectWidth/4+1;
		rectlist[4].top=rectHeight/2+rectHeight/4+1 ;
		rectlist[4].right=rectWidth/2;
		rectlist[4].bottom=rectHeight;
		
		rectlist[5].left=rectWidth/2+1;
		rectlist[5].top=rectHeight/2+rectHeight/4+1 ;
		rectlist[5].right=rectWidth/2+rectWidth/4;
		rectlist[5].bottom=rectHeight;
		
		rectlist[6].left=rectWidth/2+rectWidth/4+1;
		rectlist[6].top=rectHeight/2+rectHeight/4+1  ;
		rectlist[6].right=rectWidth;
		rectlist[6].bottom=rectHeight;
		
		rectlist[7].left=rectWidth/2+rectWidth/4+1;
		rectlist[7].top= rectHeight/2+1 ;
		rectlist[7].right=rectWidth;
		rectlist[7].bottom=rectHeight/2+rectHeight/4;
		
		//---------------------------------------------------------
		rectlist[8].left=rectWidth/2+rectWidth/4+1;
		rectlist[8].top=rectHeight/4+1 ;
		rectlist[8].right=rectWidth;
		rectlist[8].bottom=rectHeight/2;
		
		rectlist[9].left=rectWidth/2+rectWidth/4+1;
		rectlist[9].top=0 ;
		rectlist[9].right=rectWidth;
		rectlist[9].bottom=rectHeight/4-1;
		
		rectlist[10].left=rectWidth/2+1;
		rectlist[10].top=0 ;
		rectlist[10].right=rectWidth/2+rectWidth/4;
		rectlist[10].bottom=rectHeight/4-1;
		
		rectlist[11].left=rectWidth/4+1;
		rectlist[11].top=0 ;
		rectlist[11].right=rectWidth/2;
		rectlist[11].bottom=rectHeight/4-1;
		
		rectlist[12].left=rectWidth/4+1;
		rectlist[12].top=rectHeight/4 ;
		rectlist[12].right=rectWidth/2+rectWidth/4;
		rectlist[12].bottom=rectHeight/2+rectHeight/4;

		DistrictCoorDinate(num, rectWidth,rectHeight);
		break;
	case 11:
		break;
	}
}


void CSshowCenter::VideoDrow(CDC *pDC, int i)
{
	
	for(int count = 0; count< GetTotalDSPs(); count++)
	{
		::StopVideoPreview(ChannelHandle[count]);
		::ChannelClose(ChannelHandle[count]);
	}
				
	RECT previewWnd;
	CRect rect;
	
				
	GetClientRect(&previewWnd);
	
	CBrush *oldBrush = pDC->SelectObject(&tempBrush);
	pDC->Rectangle(&previewWnd);
	pDC->SelectObject(oldBrush);
	
	int rectWidth = previewWnd.right - previewWnd.left;
	int rectHeight = previewWnd.bottom - previewWnd.top;
	
	
	rect = m_rcWnd;
	rect.right = m_rcWnd.right-2;
	rect.bottom = m_rcWnd.bottom -2;
	
	CString str;
	
	switch(i) 
	{
	case 0:
		break;
	case 1:
		break;
	case 2:
		break;
	case 3:
		break;
	case 4:
		break;
		
	case 5://---7P
		{
			nSplitCount = 7;
			VideoCoorDinate(i,rectWidth,rectHeight);
			
			for(count = 0; count < nSplitCount; count++)
			{	
				::ChannelOpen(count);
				::StartVideoPreview(ChannelHandle[count], m_hWnd, &rectlist[count], FALSE, vdfYUV422Planar, 25);		
			
				m_BackgroundDC.BitBlt(0, 0, m_rcWnd.Width(), m_rcWnd.Height(), GetDC() , 0, 0, SRCCOPY);
				CPen pen,*pOldPen;
				pen.CreatePen(PS_SOLID, 1, RGB(0,255,0));
				pOldPen = m_BackgroundDC.SelectObject(&pen);
				
				CBrush* oldbrush;
				oldbrush=(CBrush *)m_BackgroundDC.SelectStockObject(NULL_BRUSH);
				m_BackgroundDC.Rectangle(rect);
				m_BackgroundDC.SelectObject(oldbrush);
				
				CBrush brush(RGB(0,255,0)); // 绿色
				//----------------------------
				DrowPicture7(&m_BackgroundDC,rect,rectHeight,rectWidth);
				//----------------------------
				m_BackgroundDC.SelectObject(pOldPen);	
				
				GetDC()->BitBlt(0, 0, m_rcWnd.Width(), m_rcWnd.Height(), &m_BackgroundDC , 0, 0, SRCCOPY);
				str.Format(strArray1[i]);
				
				pDC->SetTextColor(RGB(255,0,0));
				pDC->SetBkMode(TRANSPARENT);	
				pDC->TextOut(rectList1[i].left+5,rectList1[i].top+10,str);

			}
			break;
		}
	case 6: //---10p
		{	
			nSplitCount = 10;
			VideoCoorDinate(i,rectWidth,rectHeight);
			
			for(count = 0; count <= nSplitCount; count++)
			{	
				::ChannelOpen(count);
				::StartVideoPreview(ChannelHandle[count], m_hWnd, &rectlist[count], FALSE, vdfYUV422Planar, 25);		
			
				m_BackgroundDC.BitBlt(0, 0, m_rcWnd.Width(), m_rcWnd.Height(), GetDC() , 0, 0, SRCCOPY);
				CPen pen,*pOldPen;
				pen.CreatePen(PS_SOLID, 1, RGB(0,255,0));
				pOldPen = m_BackgroundDC.SelectObject(&pen);
				
				CBrush* oldbrush;
				oldbrush=(CBrush *)m_BackgroundDC.SelectStockObject(NULL_BRUSH);
				m_BackgroundDC.Rectangle(rect);
				m_BackgroundDC.SelectObject(oldbrush);
				
				CBrush brush(RGB(0,255,0)); // 绿色
				//----------------------------
				DrowPicture10(&m_BackgroundDC,rect,rectHeight,rectWidth);
				//----------------------------
				m_BackgroundDC.SelectObject(pOldPen);	
				
				GetDC()->BitBlt(0, 0, m_rcWnd.Width(), m_rcWnd.Height(), &m_BackgroundDC , 0, 0, SRCCOPY);
				str.Format(strArray1[i]);
				
				pDC->SetTextColor(RGB(255,0,0));
				pDC->SetBkMode(TRANSPARENT);	
				pDC->TextOut(rectList1[i].left+5,rectList1[i].top+10,str);

			}	
			break;
		}
	case 7:
		break;
	case 8: //---8p				
		{
			nSplitCount = 8;
			VideoCoorDinate(i,rectWidth,rectHeight);
			
			for(count = 0; count <= nSplitCount; count++)
			{	
				::ChannelOpen(count);
				::StartVideoPreview(ChannelHandle[count], m_hWnd, &rectlist[count], FALSE, vdfYUV422Planar, 25);
							
				m_BackgroundDC.BitBlt(0, 0, m_rcWnd.Width(), m_rcWnd.Height(), GetDC() , 0, 0, SRCCOPY);
				CPen pen,*pOldPen;
				pen.CreatePen(PS_SOLID, 1, RGB(0,255,0));
				pOldPen = m_BackgroundDC.SelectObject(&pen);
				
				CBrush* oldbrush;
				oldbrush=(CBrush *)m_BackgroundDC.SelectStockObject(NULL_BRUSH);
				m_BackgroundDC.Rectangle(rect);
				m_BackgroundDC.SelectObject(oldbrush);
				
				CBrush brush(RGB(0,255,0)); // 绿色
				//----------------------------
				DrowPicture8(&m_BackgroundDC,rect,rectHeight,rectWidth);
				//----------------------------
				m_BackgroundDC.SelectObject(pOldPen);	
				
				GetDC()->BitBlt(0, 0, m_rcWnd.Width(), m_rcWnd.Height(), &m_BackgroundDC , 0, 0, SRCCOPY);
				str.Format(strArray1[i]);

				pDC->SetTextColor(RGB(255,0,0));
				pDC->SetBkMode(TRANSPARENT);	
				pDC->TextOut(rectList1[i].left+5,rectList1[i].top+10,str);
			}					
			
			break;
		}
	case 9: //---6p
		{	
	//--------------
			nSplitCount = 6;
			VideoCoorDinate(i,rectWidth,rectHeight);
	//--------------		
			for(count = 0; count < nSplitCount; count++)
			{	
				::ChannelOpen(count);
				::StartVideoPreview(ChannelHandle[count], m_hWnd, &rectlist[count], FALSE, vdfYUV422Planar, 25);		
			
				m_BackgroundDC.BitBlt(0, 0, m_rcWnd.Width(), m_rcWnd.Height(), GetDC() , 0, 0, SRCCOPY);
				CPen pen,*pOldPen;
				pen.CreatePen(PS_SOLID, 1, RGB(0,255,0));
				pOldPen = m_BackgroundDC.SelectObject(&pen);
				
				CBrush* oldbrush;
				oldbrush=(CBrush *)m_BackgroundDC.SelectStockObject(NULL_BRUSH);
				m_BackgroundDC.Rectangle(rect);
				m_BackgroundDC.SelectObject(oldbrush);
				
				CBrush brush(RGB(0,255,0)); // 绿色
				//----------------------------
				DrowPicture6(&m_BackgroundDC,rect,rectHeight,rectWidth);
				//----------------------------
				m_BackgroundDC.SelectObject(pOldPen);	
				
				GetDC()->BitBlt(0, 0, m_rcWnd.Width(), m_rcWnd.Height(), &m_BackgroundDC , 0, 0, SRCCOPY);
				str.Format(strArray1[i]);
				
				pDC->SetTextColor(RGB(255,0,0));
				pDC->SetBkMode(TRANSPARENT);	
				pDC->TextOut(rectList1[i].left+5,rectList1[i].top+10,str);

			}					
			break;
		}
	case 10: //---13p
		{
			nSplitCount = 13;
			VideoCoorDinate(i,rectWidth,rectHeight);
			
			for(count = 0; count <= nSplitCount; count++)
			{	
				::ChannelOpen(count);
				::StartVideoPreview(ChannelHandle[count], m_hWnd, &rectlist[count], FALSE, vdfYUV422Planar, 25);		
			
				m_BackgroundDC.BitBlt(0, 0, m_rcWnd.Width(), m_rcWnd.Height(), GetDC() , 0, 0, SRCCOPY);
				CPen pen,*pOldPen;
				pen.CreatePen(PS_SOLID, 1, RGB(0,255,0));
				pOldPen = m_BackgroundDC.SelectObject(&pen);
				
				CBrush* oldbrush;
				oldbrush=(CBrush *)m_BackgroundDC.SelectStockObject(NULL_BRUSH);
				m_BackgroundDC.Rectangle(rect);
				m_BackgroundDC.SelectObject(oldbrush);
				
				CBrush brush(RGB(0,255,0)); // 绿色
				//----------------------------
				DrowPicture13(&m_BackgroundDC,rect,rectHeight,rectWidth);
				//----------------------------
				
				m_BackgroundDC.SelectObject(pOldPen);	
				
				GetDC()->BitBlt(0, 0, m_rcWnd.Width(), m_rcWnd.Height(), &m_BackgroundDC , 0, 0, SRCCOPY);
				str.Format(strArray1[i]);
				
				pDC->SetTextColor(RGB(255,0,0));
				pDC->SetBkMode(TRANSPARENT);	
				pDC->TextOut(rectList1[i].left+5,rectList1[i].top+10,str);
			}		
			break;
		}
	case 11:
		break;
	default:

		break;
	}
}


void CSshowCenter::DrowPicture7(CDC *m_BackgroundDC, CRect rect,int rectHeight, int rectWidth)
{
	m_BackgroundDC->MoveTo(rect.left, rectHeight/2);
	m_BackgroundDC->LineTo(rect.right, rectHeight/2);
	m_BackgroundDC->MoveTo(rectWidth/2, rect.top);
	m_BackgroundDC->LineTo(rectWidth/2, rect.bottom);
	m_BackgroundDC->MoveTo(rectWidth/2, rectHeight/4);
	m_BackgroundDC->LineTo(rect.right, rectHeight/4);
    m_BackgroundDC->MoveTo(rectWidth/2+rectWidth/4, rect.top);
	m_BackgroundDC->LineTo(rectWidth/2+rectWidth/4, rectHeight/2);
}

void CSshowCenter::DrowPicture10(CDC *m_BackgroundDC, CRect rect, int rectHeight, int rectWidth)
{
	   m_BackgroundDC->MoveTo(rect.left, rectHeight/2);
	   m_BackgroundDC->LineTo(rect.right, rectHeight/2);
	   m_BackgroundDC->MoveTo(rectWidth/2, rect.top);
	   m_BackgroundDC->LineTo(rectWidth/2, rect.bottom);
	   m_BackgroundDC->MoveTo(rect.left, rectHeight/2+rectHeight/4);
	   m_BackgroundDC->LineTo(rectWidth/2, rectHeight/2+rectHeight/4);
	   m_BackgroundDC->MoveTo(rectWidth/4,  rectHeight/2);
	   m_BackgroundDC->LineTo(rectWidth/4, rect.bottom);
	   m_BackgroundDC->MoveTo(rectWidth/2, rectHeight/2+rectHeight/4);
	   m_BackgroundDC->LineTo(rect.right, rectHeight/2+rectHeight/4);
	   m_BackgroundDC->MoveTo(rectWidth/4+rectWidth/2,  rectHeight/2);
	   m_BackgroundDC->LineTo(rectWidth/4+rectWidth/2, rect.bottom);
}

void CSshowCenter::DrowPicture8(CDC *m_BackgroundDC, CRect rect, int rectHeight, int rectWidth)
{
	   m_BackgroundDC->MoveTo(rect.left, rectHeight/2+rectHeight/4);
	   m_BackgroundDC->LineTo(rect.right, rectHeight/2+rectHeight/4);
	   m_BackgroundDC->MoveTo(rectWidth/2+rectWidth/4, rect.top);
	   m_BackgroundDC->LineTo(rectWidth/2+rectWidth/4, rect.bottom);
	   m_BackgroundDC->MoveTo(rectWidth/4, rectHeight/2+rectHeight/4);
	   m_BackgroundDC->LineTo(rectWidth/4, rect.bottom);
	   m_BackgroundDC->MoveTo(rectWidth/2,  rectHeight/2+rectHeight/4);
	   m_BackgroundDC->LineTo(rectWidth/2, rect.bottom);
	   m_BackgroundDC->MoveTo(rectWidth/2+rectWidth/4, rectHeight/4);
	   m_BackgroundDC->LineTo(rect.right, rectHeight/4);
	   m_BackgroundDC->MoveTo(rectWidth/4+rectWidth/2,  rectHeight/2);
	   m_BackgroundDC->LineTo(rect.right,rectHeight/2 );
}

void CSshowCenter::DrowPicture13(CDC *m_BackgroundDC, CRect rect, int rectHeight, int rectWidth)
{
	   m_BackgroundDC->MoveTo(rect.left, rectHeight/4);
	   m_BackgroundDC->LineTo(rect.right, rectHeight/4);

	   m_BackgroundDC->MoveTo(rectWidth/2, rect.top);
	   m_BackgroundDC->LineTo(rectWidth/2, rectHeight/4);

	   m_BackgroundDC->MoveTo(rect.left, rectHeight/2+rectHeight/4);
	   m_BackgroundDC->LineTo(rect.right, rectHeight/2+rectHeight/4);
	  
	   m_BackgroundDC->MoveTo(rectWidth/2,rectHeight/2+rectHeight/4);
	   m_BackgroundDC->LineTo(rectWidth/2, rect.bottom);
	   
	   m_BackgroundDC->MoveTo(rect.left, rectHeight/2);
	   m_BackgroundDC->LineTo(rectWidth/4, rectHeight/2);
	   
	   m_BackgroundDC->MoveTo(rectWidth/4,  rect.top);
	   m_BackgroundDC->LineTo(rectWidth/4, rect.bottom);
	   
	   m_BackgroundDC->MoveTo(rectWidth/4+rectWidth/2,  rect.top);
	   m_BackgroundDC->LineTo(rectWidth/4+rectWidth/2, rect.bottom);
	   
	   m_BackgroundDC->MoveTo(rectWidth/4+rectWidth/2, rectHeight/2);
	   m_BackgroundDC->LineTo(rect.right, rectHeight/2);
}

void CSshowCenter::DrowPicture6(CDC *m_BackgroundDC, CRect rect, int rectHeight, int rectWidth)
{
	   m_BackgroundDC->MoveTo(rect.left, 2*rectHeight/3);
	   m_BackgroundDC->LineTo(rect.right, 2*rectHeight/3);
	   m_BackgroundDC->MoveTo(2*rectWidth/3, rect.top);
	   m_BackgroundDC->LineTo(2*rectWidth/3, rect.bottom);
	   m_BackgroundDC->MoveTo(rectWidth/3, 2*rectHeight/3);
	   m_BackgroundDC->LineTo(rectWidth/3, rect.bottom);
	   m_BackgroundDC->MoveTo(2*rectWidth/3,  rectHeight/3);
	   m_BackgroundDC->LineTo(rect.right, rectHeight/3);
}

void CSshowCenter::StartVideo(CDC *dc)
{
	RECT previewWnd;
	GetClientRect(&previewWnd);
	
	CBrush *oldBrush = dc->SelectObject(&tempBrush);
	dc->Rectangle(&previewWnd);
	dc->SelectObject(oldBrush);
	
	int rectWidth = previewWnd.right - previewWnd.left;
	int rectHeight = previewWnd.bottom - previewWnd.top;
	
	int numRects = nSplitCount;
	CString str;

	ZeroMemory(rectList, sizeof(rectList));

//调用CacRects判断是做几行几列的视频切分,并且设置显示通道的坐标;
//---
	numRects = CacRects(nSplitCount);
//---
	for(int i = 0; i < numRects; i++)
	{	
		::StartVideoPreview(ChannelHandle[i], m_hWnd, &rectList[i], FALSE, vdfYUV422Planar, 25);	
		//-------------------------------		
		m_BackgroundDC.BitBlt(0, 0, m_rcWnd.Width(), m_rcWnd.Height(), GetDC() , 0, 0, SRCCOPY);
		CPen pen,*pOldPen;
		pen.CreatePen(PS_SOLID, 1, RGB(0,255,0));
		pOldPen = m_BackgroundDC.SelectObject(&pen);
		
		CRect rect;
		rect = m_rcWnd;
		rect.right = m_rcWnd.right-2;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -