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

📄 frameviewerdlg.cpp

📁 《Visual C++视频/音频开发实用工程案例精选》一书的源代码
💻 CPP
字号:
// FrameViewerDlg.cpp : implementation file
//

#include "stdafx.h"
#include "XvidQuantsParser.h"
#include "FrameViewerDlg.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CFrameViewerDlg dialog


CFrameViewerDlg::CFrameViewerDlg(CWnd* pParent /*=NULL*/)
	: CDialog(CFrameViewerDlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(CFrameViewerDlg)
		// NOTE: the ClassWizard will add member initialization here
	//}}AFX_DATA_INIT
}


void CFrameViewerDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CFrameViewerDlg)
		// NOTE: the ClassWizard will add DDX and DDV calls here
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CFrameViewerDlg, CDialog)
	//{{AFX_MSG_MAP(CFrameViewerDlg)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CFrameViewerDlg message handlers

//-------------------------------------------------------------------------------------------
void CFrameViewerDlg::Init(int num, CString path)
{
	frame	= num;
	avipath	= path;
}

//-------------------------------------------------------------------------------------------
BOOL CFrameViewerDlg::OnInitDialog() 
{
	CDialog::OnInitDialog();
	
	DrawFrame();
	
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}

//-------------------------------------------------------------------------------------------
void CFrameViewerDlg::DrawFrame(void)
{
	LPBITMAPINFOHEADER	bmihdr;
	LPBITMAPINFOHEADER	bmihdrd;
	LONG				lActualBytes;
	LPVOID				b;
	LPVOID				bdec = NULL;
	HDRAWDIB			hddib;
	CDC*				cdc;
	HDC					hdc;
	HIC					hic;

	cdc = GetDC();
	hdc = cdc->m_hDC;

	InputFileAVI *inputAVI = new InputFileAVI(false);
	inputAVI->Init((char*)(LPCTSTR)avipath);
	
	VideoSourceAVI *inputVideoAVI;
	inputVideoAVI = (VideoSourceAVI*) inputAVI->videoSrc;

	//Get Frame size/data...
	inputVideoAVI->read(frame, 1, NULL, 0, &lActualBytes, NULL);
	b = new char[lActualBytes];
	inputVideoAVI->read(frame, 1, b, lActualBytes, &lActualBytes, NULL);

	//b = inputVideoAVI->getFrameBuffer();
	//b = inputVideoAVI->getFrame(frame);

	bmihdr  = inputVideoAVI->getImageFormat();
	inputVideoAVI->setDecompressedFormat(24);
	bmihdrd = inputVideoAVI->getDecompressedFormat();

	width = bmihdr->biWidth;
	height = bmihdr->biHeight;


	hic = inputVideoAVI->getDecompressorHandle();

	//bdec = inputVideoAVI->getFrameBuffer();
	bdec = new char[bmihdrd->biSizeImage];
	
	if (ICDecompressBegin(hic, bmihdr, bmihdrd) == ICERR_OK)
	{ 
		ICDecompress(hic, 0, bmihdr, b, bmihdrd, bdec);
		ICDecompressEnd(hic); 
	}
	
	SizeToFrame();

	hddib = DrawDibOpen();
	//DrawDibDraw(hddib, hdc, 0, 0, width, height, bmihdrd, bdec, 0, 0, width, height, DDF_JUSTDRAWIT);
	DrawDibClose(hddib);

	//All good
	delete inputAVI;
	delete[] b;
	delete[] bdec;
}

//-------------------------------------------------------------------------------------------
void CFrameViewerDlg::SizeToFrame(void)
{
	CRect rect;

	GetWindowRect(&rect);
	SetWindowPos(&wndTopMost , rect.left, rect.top, width, height, SWP_DRAWFRAME);
	UpdateData(FALSE);
}

⌨️ 快捷键说明

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