FrameViewerDlg.cpp
上传用户:hxb_1234
上传日期:2010-03-30
资源大小:8328k
文件大小:3k
源码类别:

VC书籍

开发平台:

Visual C++

  1. // FrameViewerDlg.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "XvidQuantsParser.h"
  5. #include "FrameViewerDlg.h"
  6. #ifdef _DEBUG
  7. #define new DEBUG_NEW
  8. #undef THIS_FILE
  9. static char THIS_FILE[] = __FILE__;
  10. #endif
  11. /////////////////////////////////////////////////////////////////////////////
  12. // CFrameViewerDlg dialog
  13. CFrameViewerDlg::CFrameViewerDlg(CWnd* pParent /*=NULL*/)
  14. : CDialog(CFrameViewerDlg::IDD, pParent)
  15. {
  16. //{{AFX_DATA_INIT(CFrameViewerDlg)
  17. // NOTE: the ClassWizard will add member initialization here
  18. //}}AFX_DATA_INIT
  19. }
  20. void CFrameViewerDlg::DoDataExchange(CDataExchange* pDX)
  21. {
  22. CDialog::DoDataExchange(pDX);
  23. //{{AFX_DATA_MAP(CFrameViewerDlg)
  24. // NOTE: the ClassWizard will add DDX and DDV calls here
  25. //}}AFX_DATA_MAP
  26. }
  27. BEGIN_MESSAGE_MAP(CFrameViewerDlg, CDialog)
  28. //{{AFX_MSG_MAP(CFrameViewerDlg)
  29. //}}AFX_MSG_MAP
  30. END_MESSAGE_MAP()
  31. /////////////////////////////////////////////////////////////////////////////
  32. // CFrameViewerDlg message handlers
  33. //-------------------------------------------------------------------------------------------
  34. void CFrameViewerDlg::Init(int num, CString path)
  35. {
  36. frame = num;
  37. avipath = path;
  38. }
  39. //-------------------------------------------------------------------------------------------
  40. BOOL CFrameViewerDlg::OnInitDialog() 
  41. {
  42. CDialog::OnInitDialog();
  43. DrawFrame();
  44. return TRUE;  // return TRUE unless you set the focus to a control
  45.               // EXCEPTION: OCX Property Pages should return FALSE
  46. }
  47. //-------------------------------------------------------------------------------------------
  48. void CFrameViewerDlg::DrawFrame(void)
  49. {
  50. LPBITMAPINFOHEADER bmihdr;
  51. LPBITMAPINFOHEADER bmihdrd;
  52. LONG lActualBytes;
  53. LPVOID b;
  54. LPVOID bdec = NULL;
  55. HDRAWDIB hddib;
  56. CDC* cdc;
  57. HDC hdc;
  58. HIC hic;
  59. cdc = GetDC();
  60. hdc = cdc->m_hDC;
  61. InputFileAVI *inputAVI = new InputFileAVI(false);
  62. inputAVI->Init((char*)(LPCTSTR)avipath);
  63. VideoSourceAVI *inputVideoAVI;
  64. inputVideoAVI = (VideoSourceAVI*) inputAVI->videoSrc;
  65. //Get Frame size/data...
  66. inputVideoAVI->read(frame, 1, NULL, 0, &lActualBytes, NULL);
  67. b = new char[lActualBytes];
  68. inputVideoAVI->read(frame, 1, b, lActualBytes, &lActualBytes, NULL);
  69. //b = inputVideoAVI->getFrameBuffer();
  70. //b = inputVideoAVI->getFrame(frame);
  71. bmihdr  = inputVideoAVI->getImageFormat();
  72. inputVideoAVI->setDecompressedFormat(24);
  73. bmihdrd = inputVideoAVI->getDecompressedFormat();
  74. width = bmihdr->biWidth;
  75. height = bmihdr->biHeight;
  76. hic = inputVideoAVI->getDecompressorHandle();
  77. //bdec = inputVideoAVI->getFrameBuffer();
  78. bdec = new char[bmihdrd->biSizeImage];
  79. if (ICDecompressBegin(hic, bmihdr, bmihdrd) == ICERR_OK)
  80. ICDecompress(hic, 0, bmihdr, b, bmihdrd, bdec);
  81. ICDecompressEnd(hic); 
  82. }
  83. SizeToFrame();
  84. hddib = DrawDibOpen();
  85. //DrawDibDraw(hddib, hdc, 0, 0, width, height, bmihdrd, bdec, 0, 0, width, height, DDF_JUSTDRAWIT);
  86. DrawDibClose(hddib);
  87. //All good
  88. delete inputAVI;
  89. delete[] b;
  90. delete[] bdec;
  91. }
  92. //-------------------------------------------------------------------------------------------
  93. void CFrameViewerDlg::SizeToFrame(void)
  94. {
  95. CRect rect;
  96. GetWindowRect(&rect);
  97. SetWindowPos(&wndTopMost , rect.left, rect.top, width, height, SWP_DRAWFRAME);
  98. UpdateData(FALSE);
  99. }