FrameViewerDlg.cpp
上传用户:tuheem
上传日期:2007-05-01
资源大小:21889k
文件大小:3k
- // 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);
- }