📄 videocaptureview.cpp
字号:
// VideoCaptureView.cpp : implementation of the CVideoCaptureView class
//
#include "stdafx.h"
#include "VideoCapture.h"
#include "VideoCaptureDoc.h"
#include "VideoCaptureView.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
//--------------------------------------------------------
#include"mainFrm.h"
//--------------------------------------------------------
/////////////////////////////////////////////////////////////////////////////
// CVideoCaptureView
IMPLEMENT_DYNCREATE(CVideoCaptureView, CView)
BEGIN_MESSAGE_MAP(CVideoCaptureView, CView)
//{{AFX_MSG_MAP(CVideoCaptureView)
// NOTE - the ClassWizard will add and remove mapping macros here.
// DO NOT EDIT what you see in these blocks of generated code!
//}}AFX_MSG_MAP
// Standard printing commands
ON_COMMAND(ID_FILE_PRINT, CView::OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_DIRECT, CView::OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_PREVIEW, CView::OnFilePrintPreview)
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CVideoCaptureView construction/destruction
CVideoCaptureView::CVideoCaptureView()
{
// TODO: add construction code here
//-------------------------------------------------------
m_hdd=DrawDibOpen();
//-------------------------------------------------------
}
CVideoCaptureView::~CVideoCaptureView()
{
//-------------------------------------------------------
DrawDibClose(m_hdd);
//-------------------------------------------------------
}
BOOL CVideoCaptureView::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
return CView::PreCreateWindow(cs);
}
/////////////////////////////////////////////////////////////////////////////
// CVideoCaptureView drawing
void CVideoCaptureView::OnDraw(CDC* pDC)
{
CVideoCaptureDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
// TODO: add draw code for native data here
//---------------------------------------------------------
CWnd * p_CWnd=AfxGetMainWnd();
CMainFrame * p_CMainFrame=(CMainFrame*)p_CWnd;
// AfxMessageBox("第一次刷新主窗口",MB_OK,NULL);
if(p_CMainFrame->m_iscapture)
{
// AfxMessageBox("刷新主窗口",MB_OK,NULL);
RECT rect;
GetClientRect(&rect);
LPBITMAPINFOHEADER lpbi;
lpbi=&(p_CMainFrame->m_dibinfo.bitmapinfoheader);
// LPVOID p;
// p = DrawDibGetBuffer(m_hdd,lpbi,sizeof(BITMAPINFOHEADER ),0);
// memcpy(p,p_CMainFrame->m_dibinfo.buffer+p_CMainFrame->m_dibinfo.VideoFormatSize,
// lpbi->biSizeImage);
// DrawDibBegin(m_hdd,h123,100,100,lpbi,0,0,DDF_ANIMATE );
DrawDibDraw(m_hdd,pDC->GetSafeHdc(),
0,0,-1,-1,
lpbi,p_CMainFrame->m_dibinfo.buffer+p_CMainFrame->m_dibinfo.VideoFormatSize,
0,0,lpbi->biWidth,lpbi->biHeight,0);
// DrawDibDraw(m_hdd,h123,
// rect.left,rect.top,rect.right,rect.bottom,
// lpbi,NULL,0,0,lpbi->biWidth,lpbi->biHeight,DDF_SAME_DRAW |DDF_SAME_HDC );
//问题出现DrawDibDraw中,单步调试中出现
//“Unhandled exception in VideoCapture.exe(MSVFW32.DLL):0xc0000005:Access Violation.”
//出现的问题是,在给DrawDibDraw函数传参数时,没有把数据缓冲的地址传给函数。
}
if(p_CMainFrame->m_after_skindect)
{
LPBITMAPINFOHEADER lpbi;
// lpbi=&(p_CMainFrame->m_rgb_bitmapheader);
// unsigned char * lpb=p_CMainFrame->m_rgb_buffer;
lpbi=&(p_CMainFrame->m_bitmapheader);
unsigned char * lpb=p_CMainFrame->m_ycc_buffer;
DrawDibDraw(m_hdd,pDC->GetSafeHdc(),
0,0,-1,-1,
lpbi,lpb,
0,0,lpbi->biWidth,lpbi->biHeight,0);
// AfxMessageBox("after copy!",MB_OK,0);
}
}
/////////////////////////////////////////////////////////////////////////////
// CVideoCaptureView printing
BOOL CVideoCaptureView::OnPreparePrinting(CPrintInfo* pInfo)
{
// default preparation
return DoPreparePrinting(pInfo);
}
void CVideoCaptureView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add extra initialization before printing
}
void CVideoCaptureView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add cleanup after printing
}
/////////////////////////////////////////////////////////////////////////////
// CVideoCaptureView diagnostics
#ifdef _DEBUG
void CVideoCaptureView::AssertValid() const
{
CView::AssertValid();
}
void CVideoCaptureView::Dump(CDumpContext& dc) const
{
CView::Dump(dc);
}
CVideoCaptureDoc* CVideoCaptureView::GetDocument() // non-debug version is inline
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CVideoCaptureDoc)));
return (CVideoCaptureDoc*)m_pDocument;
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CVideoCaptureView message handlers
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -