📄 videopos.cpp
字号:
// VideoPos.cpp : implementation file
//
#include "stdafx.h"
#include "gtmpeg.h"
#include "VideoPos.h"
#include "GtMpegWnd.h"
#include "ImageObject.h"
#include "DataMsg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
#define _NET_TRAN 100
#define _NET_FRAME 40
/////////////////////////////////////////////////////////////////////////////
//
/////////////////////////////////////////////////////////////////////////////
CVideoPos::CVideoPos()
{
m_pObject=NULL;
m_bBitmap=FALSE;
m_pSocket=NULL;
m_nFrame=0;
}
CVideoPos::~CVideoPos()
{
if(m_pObject!=NULL)
delete m_pObject;
m_pSocket=NULL;
#ifdef _DEBUG
KillTimer(0);
#endif
}
/////////////////////////////////////////////////////////////////////////////
//
/////////////////////////////////////////////////////////////////////////////
BEGIN_MESSAGE_MAP(CVideoPos, CStatic)
//{{AFX_MSG_MAP(CVideoPos)
ON_WM_LBUTTONDBLCLK()
ON_WM_LBUTTONDOWN()
ON_WM_LBUTTONUP()
ON_WM_MOUSEMOVE()
ON_WM_TIMER()
ON_WM_PAINT()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
//
/////////////////////////////////////////////////////////////////////////////
void CVideoPos::OnLButtonDblClk(UINT nFlags, CPoint point)
{
CGtMpegWnd *pParent=(CGtMpegWnd*)GetParent();
pParent->DblkVideoPos(this);
CStatic::OnLButtonDblClk(nFlags, point);
}
/////////////////////////////////////////////////////////////////////////////
//
/////////////////////////////////////////////////////////////////////////////
void CVideoPos::OnLButtonDown(UINT nFlags, CPoint point)
{
/*HCURSOR hCursor;
hCursor = AfxGetApp()->LoadCursor(IDC_MPEG_DOWN);
::SetCursor(hCursor);*/
CStatic::OnLButtonDown(nFlags, point);
}
/////////////////////////////////////////////////////////////////////////////
//
/////////////////////////////////////////////////////////////////////////////
void CVideoPos::OnLButtonUp(UINT nFlags, CPoint point)
{
/*HCURSOR hCursor;
hCursor = AfxGetApp()->LoadCursor(IDC_MPEG_MOVE);
::SetCursor(hCursor);*/
CStatic::OnLButtonUp(nFlags, point);
}
/////////////////////////////////////////////////////////////////////////////
//
/////////////////////////////////////////////////////////////////////////////
void CVideoPos::OnMouseMove(UINT nFlags, CPoint point)
{
/* HCURSOR hCursor;
//SetCapture();
hCursor = AfxGetApp()->LoadCursor(IDC_MPEG_MOVE);
::SetCursor(hCursor);*/
CStatic::OnMouseMove(nFlags, point);
}
/////////////////////////////////////////////////////////////////////////////
// CString sPath=GetAppPath()+"FacePlug\\Video.jpg";
/////////////////////////////////////////////////////////////////////////////
void CVideoPos::SetBkBitmap(CString sBitmapFile)
{
if(m_pObject!=NULL)
{
delete m_pObject;
m_pObject=NULL;
}
m_pObject=new CImageObject(sBitmapFile);
}
/////////////////////////////////////////////////////////////////////////////
//
/////////////////////////////////////////////////////////////////////////////
void CVideoPos::OnTimer(UINT nIDEvent)
{
CGtMpegWnd *pWnd=(CGtMpegWnd *)theApp.m_pMainWnd;
if(nIDEvent==_NET_TRAN)
{
CClientDC dc(this);
int nTmp=0;
for(int j=0;j<219;j++)
{
for(int i=0;i<237;i++)
{
pWnd->m_PixelMsg.m_Pixel[nTmp]=dc.GetPixel(i,j);
nTmp++;
}
}
//传送数据
if(m_pSocket!=NULL)
{
m_nFrame++;
if(!pWnd->SendMsg(m_pSocket,&(pWnd->m_PixelMsg)))
StopNetTran();
}
}
else
{
#ifdef _DEBUG
CString sTmp;
sTmp.Format("%d",m_nFrame);
pWnd->m_cMsgListBox.AddString(sTmp);
m_nFrame=0;
#endif
}
CStatic::OnTimer(nIDEvent);
}
/////////////////////////////////////////////////////////////////////////////
//
/////////////////////////////////////////////////////////////////////////////
void CVideoPos::SetNetTran(CClientSocket* pSocket)
{
if(pSocket==NULL)
return;
m_pSocket=pSocket;
SetTimer(_NET_TRAN,_NET_FRAME,NULL);
#ifdef _DEBUG
m_nFrame=0;
SetTimer(0,1000,NULL);
#endif
}
/////////////////////////////////////////////////////////////////////////////
//
/////////////////////////////////////////////////////////////////////////////
void CVideoPos::StopNetTran()
{
KillTimer(_NET_TRAN);
#ifdef _DEBUG
KillTimer(0);
#endif
}
/////////////////////////////////////////////////////////////////////////////
//
/////////////////////////////////////////////////////////////////////////////
void CVideoPos::OnPaint()
{
CPaintDC dc(this); // device context for painting
if(m_pObject!=NULL)
{
CRect rect;
GetClientRect(rect);
m_pObject->DrawInRect(&dc,rect);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -