473,397 Members | 2,077 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

video edit in c++

Hello,

I'd appreciate your suggestions about this drafted application for video editing. It is just the first idea, it is (barely) working but can be improved a lot! Find the code attached below. The main goal is to play an avi, averlap an annotation/image and save the new avi.

Thank you very much for your help and comments :-)

Expand|Select|Wrap|Line Numbers
  1. // Avi PostEdit - Annotation Re-capture
  2. // Initial drafted code developed by giulio8  - 22/6/2009
  3.  
  4. // Play an AVI using the MSvfw32.lib 
  5. // in the case of Dev-C++ link with libmsvfw32.a via
  6. // Project>>Project Options>>Parameters>>Add Lib>>libmsvfw32.a
  7.  
  8.  
  9.  
  10. #include <cstdio>
  11. #include <fstream>
  12. using namespace std;
  13.  
  14. #include <windows.h>
  15.  
  16.  
  17. #include <vfw.h>
  18.  
  19.  
  20.  
  21. #include "avi_utils.h"
  22.  
  23.  
  24. #include <shlwapi.h>
  25. //Nota: perché questo codice funzioni va linkato anche con shlwapi.lib; in VC++ si può ottenere tale effetto anche con un #pragma non standard
  26. #ifdef _MSC_VER
  27. #pragma comment(lib,"shlwapi.lib")
  28. #endif
  29. //...
  30.  
  31.  
  32. #define ID_MCIFrame 0
  33. #define ID_MENU1 9001
  34. #define ID_MENU2 9002
  35. #define ID_MENU3 9003
  36. #define ID_MENU4 9004
  37. #define ID_MENU5 9005
  38. #define ID_MENU6 9006
  39. #define ID_MENU7 9007
  40.  
  41. static HINSTANCE BCX_hInstance;
  42. static int     BCX_ScaleX;
  43. static int     BCX_ScaleY;
  44. static char    BCX_ClassName[2048];
  45. static HANDLE  ghInst;
  46. static HWND    Form1;
  47. static HWND    MCIFrame;
  48. static HMENU   MainMenu;
  49. static HMENU   FileMenu;
  50. static OPENFILENAME OpenFileName;
  51. static char    szFile[2048];
  52. static char    szFileTitle[2048];
  53. static char    szFileBmp[2048];
  54. static char    szFileTitleBmp[2048];
  55. static char    szFileBmpC[2048];
  56. static char    szFileTitleBmpC[2048];
  57.  
  58. #define Show(Window)  RedrawWindow(Window,0,0,0);ShowWindow(Window,SW_SHOW);
  59.  
  60. HWND    BCX_Form(char*,int=0,int=0,int=250,int=150,int=0,int=0);
  61. void    BCX_Set_Form_Color (HWND,COLORREF);
  62. void    Center (HWND,HWND=0,HWND=0);
  63. char*   BCX_TmpStr(size_t);
  64. char*   str (double);
  65. char*   curdir (void);
  66.  
  67. void    FormLoad (void);
  68. LRESULT CALLBACK WndProc (HWND, UINT, WPARAM, LPARAM);
  69. int     InitOpenFileName (void);
  70. int     PopFileOpenDlg (HWND, char *, char *);
  71. BOOL    AddMenu (HWND);
  72.  
  73. LONG lFrame_start;
  74. LONG lFrame_end;
  75.  
  76. // standard Windows Graphical User Interface main
  77. int WINAPI WinMain(HINSTANCE hInst,HINSTANCE hPrev,LPSTR CmdLine,int CmdShow)
  78. {
  79.  WNDCLASS Wc;
  80.  MSG      Msg;
  81.  // *****************************
  82.  strcpy(BCX_ClassName,"ApiEdit");
  83.  // ************************************
  84.  // Scale Dialog Units To Screen Units
  85.  // ************************************
  86.  RECT rc          =  {0,0,4,8};
  87.  MapDialogRect       (NULL,&rc);
  88.  BCX_ScaleX       =  rc.right/2;
  89.  BCX_ScaleY       =  rc.bottom/4;
  90.  BCX_hInstance    =  hInst;
  91.  // ******************************************************
  92.  Wc.style         =  CS_HREDRAW | CS_VREDRAW | CS_OWNDC;
  93.  Wc.lpfnWndProc   =  WndProc;
  94.  Wc.cbClsExtra    =  0;
  95.  Wc.cbWndExtra    =  0;
  96.  Wc.hInstance     =  hInst;
  97.  Wc.hIcon         =  LoadIcon(NULL,IDI_WINLOGO);
  98.  Wc.hCursor       =  LoadCursor(NULL,IDC_ARROW);
  99.  Wc.hbrBackground =  (HBRUSH)(COLOR_BTNFACE+1);
  100.  Wc.lpszMenuName  =  NULL;
  101.  Wc.lpszClassName =  BCX_ClassName;
  102.  RegisterClass(&Wc);
  103.  
  104.  FormLoad();
  105.  // event message loop 
  106.  while(GetMessage(&Msg,NULL,0,0))
  107.  {
  108.     HWND hActiveWindow = GetActiveWindow();
  109.     if (!IsWindow(hActiveWindow) || !IsDialogMessage(hActiveWindow,&Msg))
  110.       {
  111.         TranslateMessage(&Msg);
  112.         DispatchMessage(&Msg);
  113.       }
  114.  }
  115.  return Msg.wParam;
  116. }
  117.  
  118.  
  119. // circular storage, hold the memory leaks to a minimum
  120. char *BCX_TmpStr (size_t Bites)
  121. {
  122.   static int   StrCnt;
  123.   static char *StrFunc[2048];
  124.   StrCnt=(StrCnt + 1) & 2047;
  125.   if(StrFunc[StrCnt]) free (StrFunc[StrCnt]);
  126.   return StrFunc[StrCnt]=(char*)calloc(Bites+128,sizeof(char));
  127. }
  128.  
  129.  
  130. char *str (double d)
  131. {
  132.   register char *strtmp = BCX_TmpStr(16);
  133.   sprintf(strtmp,"% .15G",d);
  134.   return strtmp;
  135. }
  136.  
  137.  
  138. char *curdir (void)
  139. {
  140.   register char *strtmp = BCX_TmpStr(2048);
  141.   GetCurrentDirectory (1024,strtmp);
  142.   return strtmp;
  143. }
  144.  
  145.  
  146. // center the window form on the screen, optional, for looks
  147. void Center (HWND hwnd, HWND Xhwnd, HWND Yhwnd)
  148. {
  149.   RECT rect, rectP;
  150.   int  x, y, width, height;
  151.   int  screenwidth, screenheight;
  152.   if(Xhwnd==0)
  153.     {
  154.       RECT  DesktopArea;
  155.       RECT  rc;
  156.       SystemParametersInfo(SPI_GETWORKAREA,0,&DesktopArea,0);
  157.       GetWindowRect(hwnd,&rc);
  158.       SetWindowPos(hwnd,HWND_TOP,
  159.         ((DesktopArea.right-DesktopArea.left)-(rc.right-rc.left))/2+
  160.           DesktopArea.left,((DesktopArea.bottom-DesktopArea.top)-
  161.          (rc.bottom-rc.top))/2 + DesktopArea.top,0,0,SWP_NOSIZE);
  162.       return;
  163.     }
  164.   GetWindowRect (hwnd,&rect);
  165.   GetWindowRect (Xhwnd,&rectP);
  166.   width = rect.right-rect.left;
  167.   x = ((rectP.right-rectP.left)-width)/2 + rectP.left;
  168.   if (Yhwnd==NULL)
  169.   {
  170.       height = rect.bottom-rect.top;
  171.       y = ((rectP.bottom-rectP.top)-height)/2 + rectP.top;
  172.   }
  173.   else
  174.   {
  175.       GetWindowRect(Yhwnd,&rectP);
  176.       height = rect.bottom-rect.top;
  177.       y = ((rectP.bottom-rectP.top)-height)/2+rectP.top;
  178.   }
  179.   screenwidth = GetSystemMetrics(SM_CXSCREEN);
  180.   screenheight = GetSystemMetrics(SM_CYSCREEN);
  181.   if ((x<0)) 
  182.     x=0;
  183.   if ((y<0)) 
  184.     y=0;
  185.   if ((x+width>screenwidth))   
  186.     x = screenwidth-width;
  187.   if ((y+height>screenheight)) 
  188.     y = screenheight-height;
  189.   MoveWindow (hwnd, x, y, width, height, FALSE);
  190. }
  191.  
  192.  
  193. // create the windows form
  194. HWND BCX_Form(char *Caption, int X, int Y, int W, int H, int Style, int Exstyle)
  195. {
  196.    HWND  A;
  197.    // assigne default style if none given
  198.    if (!Style)
  199.    {
  200.         Style= WS_MINIMIZEBOX  |
  201.         WS_SIZEBOX      |
  202.         WS_CAPTION      |
  203.         WS_MAXIMIZEBOX  |
  204.         WS_POPUP        |
  205.         WS_SYSMENU;
  206.    }
  207.    A = CreateWindowEx(Exstyle,BCX_ClassName,Caption,
  208.    Style,
  209.    X*BCX_ScaleX,
  210.    Y*BCX_ScaleY,
  211.    (4+W)*BCX_ScaleX,
  212.    (12+H)*BCX_ScaleY,
  213.    NULL,(HMENU)NULL,BCX_hInstance,NULL);
  214.    SendMessage(A,(UINT)WM_SETFONT,(WPARAM)GetStockObject(DEFAULT_GUI_FONT),
  215.      (LPARAM)MAKELPARAM(FALSE,0));
  216.    return A;
  217. }
  218.  
  219.  
  220. // color, why not
  221. void BCX_Set_Form_Color (HWND hWnd, COLORREF Kolor)
  222. {
  223.   HBRUSH hbr=CreateSolidBrush(Kolor);
  224.   DeleteObject((HBRUSH)SetClassLong(hWnd,GCL_HBRBACKGROUND,(DWORD)hbr));
  225.   InvalidateRect (hWnd,NULL,TRUE);
  226. }
  227.  
  228.  
  229. // the details - corner coordinates,width,height,title
  230. void FormLoad (void)
  231. {
  232.     Form1=BCX_Form("PostEdit Capture",0,0,197,170);
  233.     SetClassLong(Form1,GCL_STYLE,GetClassLong(Form1,GCL_STYLE)|CS_DBLCLKS);
  234.     BCX_Set_Form_Color(Form1,RGB(0,0,0));
  235.     //  Now create the MCIWnd 
  236.     MCIFrame=MCIWndCreate(Form1,(HINSTANCE)ghInst,WS_CHILD|WS_VISIBLE|MCIWNDF_NOPLAYBAR|MCIWNDF_NOTIFYALL,"");
  237.     AddMenu(Form1);
  238.     Center(Form1);
  239.     Show(Form1);
  240.  
  241. }
  242.  
  243. int InitSaveFileName (void)
  244. {
  245.   *szFile=0;
  246.   *szFileTitle=0;
  247.   OpenFileName.lStructSize=sizeof(OPENFILENAME);
  248.   OpenFileName.hwndOwner=MCIFrame;
  249.   OpenFileName.hInstance=(HINSTANCE)ghInst;
  250.   OpenFileName.lpstrFilter =
  251.     "Bmp Files (*.BMP)\0*.bmp\0All Files(*.*)\0*.*\0\0";
  252.   OpenFileName.lpstrCustomFilter=NULL;
  253.   OpenFileName.nMaxCustFilter=0;
  254.   OpenFileName.nFilterIndex=0;
  255.   OpenFileName.lpstrFile=szFile;
  256.   OpenFileName.nMaxFile=MAX_PATH;
  257.   OpenFileName.lpstrFileTitle=szFileTitle;
  258.   OpenFileName.nMaxFileTitle=MAX_PATH;
  259.   OpenFileName.lpstrInitialDir=curdir();
  260.   OpenFileName.lpstrTitle=NULL;
  261.   OpenFileName.nFileOffset=0;
  262.   OpenFileName.nFileExtension=0;
  263.   OpenFileName.lpstrDefExt="*.bmp";
  264.   OpenFileName.lCustData=0L;
  265.   OpenFileName.Flags=OFN_SHOWHELP|OFN_PATHMUSTEXIST|OFN_HIDEREADONLY;
  266.   OpenFileName.lpfnHook=NULL;
  267.   OpenFileName.lpTemplateName=NULL;
  268.   return 0;
  269. }
  270.  
  271. int PopFileSaveDlg (HWND Form1, char *szFileBmp, char *szFileTitleBmp)
  272. {
  273.   OpenFileName.lpstrTitle="Save bitmap";
  274.   OpenFileName.hwndOwner=MCIFrame;
  275.   OpenFileName.lpstrFile=szFileBmp;
  276.   OpenFileName.lpstrFileTitle=szFileTitleBmp;
  277.   OpenFileName.Flags=OFN_EXPLORER|OFN_CREATEPROMPT;
  278.   return GetOpenFileNamePreview(&OpenFileName);
  279. }
  280.  
  281.  
  282.  
  283. /* 
  284. Funzione per scrivere l'handle di una bitmap su file 
  285. Thanks to http://www.geocities.com/krishnapg/bitmap.html#SaveBitmap 
  286. */ 
  287. void SaveBitmap(char *szFilename,HBITMAP hBitmap){ 
  288.       HDC        hdc=NULL; 
  289.       FILE*      fp=NULL; 
  290.       LPVOID     pBuf=NULL; 
  291.       BITMAPINFO bmpInfo; 
  292.       BITMAPFILEHEADER  bmpFileHeader; 
  293.       do{ 
  294.             hdc=GetDC(NULL); 
  295.             ZeroMemory(&bmpInfo,sizeof(BITMAPINFO)); 
  296.             bmpInfo.bmiHeader.biSize=sizeof(BITMAPINFOHEADER); 
  297.             GetDIBits(hdc,hBitmap,0,0,NULL,&bmpInfo,DIB_RGB_COLORS); 
  298.             if(bmpInfo.bmiHeader.biSizeImage<=0) 
  299.             bmpInfo.bmiHeader.biSizeImage=bmpInfo.bmiHeader.biWidth*abs(bmpInfo.bmiHeader.biHeight)*(bmpInfo.bmiHeader.biBitCount+7)/8; 
  300.             if((pBuf = malloc(bmpInfo.bmiHeader.biSizeImage))==NULL) 
  301.             { 
  302.                   //MessageBox( NULL, "Unable to Allocate Bitmap Memory", "Error", MB_OK|MB_ICONERROR); 
  303.                   break; 
  304.             }           
  305.             bmpInfo.bmiHeader.biCompression=BI_RGB; 
  306.             GetDIBits(hdc,hBitmap,0,bmpInfo.bmiHeader.biHeight,pBuf, &bmpInfo, DIB_RGB_COLORS);       
  307.             if((fp = fopen(szFilename,"wb"))==NULL) 
  308.             { 
  309.                   //MessageBox( NULL, "Unable to Create Bitmap File", "Error", MB_OK|MB_ICONERROR); 
  310.                   break; 
  311.             } 
  312.             bmpFileHeader.bfReserved1=0; 
  313.             bmpFileHeader.bfReserved2=0; 
  314.             bmpFileHeader.bfSize=sizeof(BITMAPFILEHEADER)+sizeof(BITMAPINFOHEADER)+bmpInfo.bmiHeader.biSizeImage; 
  315.             bmpFileHeader.bfType='MB'; 
  316.             bmpFileHeader.bfOffBits=sizeof(BITMAPFILEHEADER)+sizeof(BITMAPINFOHEADER); 
  317.             fwrite(&bmpFileHeader,sizeof(BITMAPFILEHEADER),1,fp); 
  318.             fwrite(&bmpInfo.bmiHeader,sizeof(BITMAPINFOHEADER),1,fp); 
  319.             fwrite(pBuf,bmpInfo.bmiHeader.biSizeImage,1,fp); 
  320.       }while(false); 
  321.             if(hdc)     ReleaseDC(NULL,hdc); 
  322.             if(pBuf)    free(pBuf); 
  323.             if(fp)      fclose(fp); 
  324.  
  325.  
  326. // event message handler
  327. LRESULT CALLBACK WndProc (HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
  328. {
  329.   static char s[2048];
  330.   memset(&s,0,sizeof(s));
  331.   static char mstr[2048];
  332.   memset(&mstr,0,sizeof(mstr));
  333.   static char mstr1[2048];
  334.   memset(&mstr1,0,sizeof(mstr1));
  335.   while(1)
  336.   {
  337.     if (Msg==WM_CREATE)
  338.     {
  339.       return 0;
  340.       break;
  341.     }
  342.     if (Msg==WM_COMMAND)
  343.     {
  344.       if (LOWORD(wParam)==ID_MENU2)
  345.       {
  346.           MCIWndClose(MCIFrame);
  347.           InitOpenFileName();
  348.          PopFileOpenDlg(Form1,szFile,szFileTitle);
  349. //           strcpy(szFile,"d:\\dati\\amss\\cam_guida2.avi");
  350.           if(strlen(szFile)>0)
  351.           {
  352.               MCIWndOpen(MCIFrame,szFile,0);
  353.   AppendMenu(FileMenu,MF_STRING,ID_MENU6,"&Start frame");
  354.  
  355.  
  356.           }
  357.           return 0;
  358.       }
  359.       if(LOWORD(wParam)==ID_MENU3)
  360.       {
  361.           MCIWndClose(MCIFrame);
  362.           ExitProcess(0);
  363.       }
  364.       //break;
  365.       // if(LOWORD(wParam)==ID_MENU4)
  366.       //{
  367.  
  368.       //}
  369.  
  370.  
  371.        if(LOWORD(wParam)==ID_MENU5)
  372.       {
  373. HDC hDc = CreateCompatibleDC(GetDC(MCIFrame));
  374. RECT rcWind;
  375. GetClientRect(MCIFrame, &rcWind);
  376. int width = rcWind.right - rcWind.left;
  377. int height = rcWind.bottom - rcWind.top;
  378.  
  379. static char    szFileAvi[2048];
  380. static char    szFileTitleAvi[2048];
  381.           InitOpenFileName();
  382.          PopFileOpenDlg(Form1,szFileAvi,szFileTitleAvi);
  383. HAVI avi = CreateAvi(szFileAvi,5,NULL);
  384.  
  385. static  char  bmptemp[2048];
  386.     BROWSEINFO bi = { 0 };
  387.     TCHAR path[MAX_PATH];
  388.     bi.lpszTitle = "Pick a Temp Directory";
  389.     bi.pszDisplayName = path;
  390.     LPITEMIDLIST pidl = SHBrowseForFolder ( &bi );
  391.     if ( pidl != 0 )
  392.     {
  393.         // get the name of the folder
  394.  
  395.  
  396.         sprintf(bmptemp, "%s", path);
  397.         // free memory used
  398.         IMalloc * imalloc = 0;
  399.         if ( SUCCEEDED( SHGetMalloc ( &imalloc )) )
  400.         {
  401.             imalloc->Free ( pidl );
  402.             imalloc->Release ( );
  403.         }
  404.     }
  405.  
  406.  
  407.  
  408. char buffer[100]; 
  409. LONG lFrame;
  410. lFrame = MCIWndGetPosition(MCIFrame); 
  411.  
  412. for (LONG i=lFrame_start; i<=lFrame_end; i++)
  413.     MCIWndSeek(MCIFrame,i);
  414.   HBITMAP hBmp = CreateCompatibleBitmap(GetDC(MCIFrame), width, height);   
  415.  
  416.    // join em up
  417.    SelectObject(hDc, hBmp);   
  418.  
  419.    // copy from the screen to my bitmap
  420.    BitBlt(hDc, 0, 0, width, height, GetDC(MCIFrame), 0, 0, SRCCOPY);  
  421.  
  422.       // avifile.appendNewFrame(hBitmap);
  423.  
  424.  
  425.  
  426.   //sprintf(buffer, "%s%i.bmp", bmptemp, i); // image a rajouter
  427.   sprintf(buffer, "%s.bmp", bmptemp);
  428.   SaveBitmap(buffer,hBmp);
  429.  
  430.   HBITMAP hBmpDIB =(HBITMAP)LoadImage(NULL,buffer,IMAGE_BITMAP,0,0,LR_LOADFROMFILE|LR_CREATEDIBSECTION);
  431.  
  432. if (i==lFrame_start) // Set up compression just before the first frame
  433.   {  AVICOMPRESSOPTIONS opts; 
  434.     ZeroMemory(&opts,sizeof(opts));
  435.     opts.fccHandler=mmioFOURCC('D','I','V','X');
  436.     SetAviVideoCompression(avi,hBmpDIB,&opts,true,Form1);
  437. }
  438.     AddAviFrame(avi,hBmpDIB);
  439.   DeleteObject(hBmp); 
  440.     DeleteObject(hBmpDIB); 
  441. }
  442. CloseAvi(avi);
  443. MessageBox(NULL,"Avi saved.","COMPLETED",MB_OK | MB_ICONINFORMATION);
  444.  
  445.  
  446.       }
  447.  
  448.  
  449.        if(LOWORD(wParam)==ID_MENU6)
  450.       {
  451.  
  452. lFrame_start = MCIWndGetPosition(MCIFrame);                                   
  453.   AppendMenu(FileMenu,MF_STRING,ID_MENU7,"&End Frame");
  454.             }
  455.        if(LOWORD(wParam)==ID_MENU7)
  456.       {
  457. lFrame_end = MCIWndGetPosition(MCIFrame);                                   
  458.             // AppendMenu(FileMenu,MF_STRING,ID_MENU4,"&Save bmp");
  459.   AppendMenu(FileMenu,MF_STRING,ID_MENU5,"&Save capture");
  460.             }
  461. break;
  462.     }
  463.  
  464.     if (Msg==MCIWNDM_NOTIFYMODE)
  465.     {
  466.       while(1)
  467.       {
  468.         if ((long)lParam==MCI_MODE_NOT_READY)
  469.         {
  470.           SetWindowText(Form1,"Not Ready");
  471.           break;
  472.         }
  473.         if ((long)lParam==MCI_MODE_PAUSE)
  474.         {
  475.           SetWindowText(Form1,"Paused");
  476.           break;
  477.         }
  478.         if ((long)lParam==MCI_MODE_PLAY)
  479.         {
  480.           SetWindowText(Form1,"Playing");
  481.           break;
  482.         }
  483.         if ((long)lParam==MCI_MODE_STOP)
  484.         {
  485.           SetWindowText(Form1,"Stopped");
  486.           break;
  487.         }
  488.         if ((long)lParam==MCI_MODE_OPEN)
  489.         {
  490.           SetWindowText(Form1,"Opening");
  491.           break;
  492.         }
  493.         if ((long)lParam==MCI_MODE_RECORD)
  494.         {
  495.           SetWindowText(Form1,"Recording");
  496.           break;
  497.         }
  498.         if ((long)lParam==MCI_MODE_SEEK)
  499.         {
  500.           SetWindowText(Form1,"Seeking");
  501.         }
  502.         break;
  503.       }
  504.       break;
  505.     }
  506.     if (Msg==MCIWNDM_NOTIFYMEDIA)
  507.     {
  508.       SetWindowText(Form1,(LPSTR)lParam);
  509.       break;
  510.     }
  511.     if (Msg==MCIWNDM_NOTIFYPOS)
  512.     {
  513.       SetWindowText(Form1,str(MCIWndGetPosition(MCIFrame)));
  514.       break;
  515.     }
  516.     if (Msg==MCIWNDM_NOTIFYERROR)
  517.     {
  518.       SetWindowText(Form1,"MCI ERROR");
  519.       break;
  520.     }
  521.     if (Msg==WM_PAINT)
  522.     {
  523.       //  The VideoWindow is restricted to a ratio of 4:3 here 
  524.       break;
  525.     }
  526.     if (Msg==WM_SIZE)
  527.     {
  528.       static  WORD  Basedsp;
  529.       memset(&Basedsp,0,sizeof(Basedsp));
  530.       static  WORD  Cntr;
  531.       memset(&Cntr,0,sizeof(Cntr));
  532.       Basedsp=(HIWORD(lParam)-20)/3;
  533.       Cntr=(LOWORD(lParam)-(Basedsp*4))/2;
  534.       // MoveWindow(MCIFrame,Cntr,0,(Basedsp*4),HIWORD(lParam),TRUE);
  535.       //  Don't forget to close opened Files 
  536.       break;
  537.     }
  538.     if (Msg==WM_CLOSE)
  539.     {
  540.       MCIWndClose(MCIFrame);
  541.       DestroyWindow(Form1);
  542.       return 0;
  543.       break;
  544.     }
  545.     if (Msg==WM_DESTROY)
  546.     {
  547.       MCIWndClose(MCIFrame);
  548.       PostQuitMessage(0);
  549.       return 0;
  550.     }
  551.     break;
  552.   }
  553.   // tidy up and exit program
  554.   if (Msg==WM_DESTROY)
  555.   {
  556.        UnregisterClass(BCX_ClassName,BCX_hInstance);
  557.        PostQuitMessage(0);
  558.   }
  559.   return DefWindowProc(hWnd,Msg,wParam,lParam);
  560. }
  561.  
  562.  
  563. // tons of options for the neat file dialog box
  564. int InitOpenFileName (void)
  565. {
  566.   *szFile=0;
  567.   *szFileTitle=0;
  568.   OpenFileName.lStructSize=sizeof(OPENFILENAME);
  569.   OpenFileName.hwndOwner=MCIFrame;
  570.   OpenFileName.hInstance=(HINSTANCE)ghInst;
  571.   OpenFileName.lpstrFilter =
  572.     "Avi Files (*.AVI)\0*.avi\0All Files(*.*)\0*.*\0\0";
  573.   OpenFileName.lpstrCustomFilter=NULL;
  574.   OpenFileName.nMaxCustFilter=0;
  575.   OpenFileName.nFilterIndex=0;
  576.   OpenFileName.lpstrFile=szFile;
  577.   OpenFileName.nMaxFile=MAX_PATH;
  578.   OpenFileName.lpstrFileTitle=szFileTitle;
  579.   OpenFileName.nMaxFileTitle=MAX_PATH;
  580.   OpenFileName.lpstrInitialDir=curdir();
  581.   OpenFileName.lpstrTitle=NULL;
  582.   OpenFileName.nFileOffset=0;
  583.   OpenFileName.nFileExtension=0;
  584.   OpenFileName.lpstrDefExt="*.avi";
  585.   OpenFileName.lCustData=0L;
  586.   OpenFileName.Flags=OFN_SHOWHELP|OFN_PATHMUSTEXIST|OFN_FILEMUSTEXIST|OFN_HIDEREADONLY;
  587.   OpenFileName.lpfnHook=NULL;
  588.   OpenFileName.lpTemplateName=NULL;
  589.   return 0;
  590. }
  591.  
  592. int PopFileOpenDlg (HWND Form1, char *szFile, char *szFileTitle)
  593. {
  594.   OpenFileName.lpstrTitle="Open File";
  595.   OpenFileName.hwndOwner=MCIFrame;
  596.   OpenFileName.lpstrFile=szFile;
  597.   OpenFileName.lpstrFileTitle=szFileTitle;
  598.   OpenFileName.Flags=OFN_EXPLORER|OFN_CREATEPROMPT;
  599.   return GetOpenFileNamePreview(&OpenFileName);
  600. }
  601.  
  602.  
  603. BOOL AddMenu (HWND hwndOwner)
  604. {
  605.   MainMenu=CreateMenu();
  606.   FileMenu=CreateMenu();
  607.   InsertMenu(MainMenu,0,MF_POPUP,(UINT)FileMenu,"&File");
  608.   AppendMenu(FileMenu,MF_STRING,ID_MENU2,"&Open");
  609.   AppendMenu(FileMenu,MF_STRING,ID_MENU3,"&Exit");
  610. //  AppendMenu(FileMenu,MF_STRING,ID_MENU4,"&Save bmp");
  611. //  AppendMenu(FileMenu,MF_STRING,ID_MENU5,"&Save capture");
  612.   // activate the menu 
  613.   if (!SetMenu(hwndOwner,MainMenu))
  614.   {
  615.       return FALSE;
  616.   }
  617.   return TRUE;
  618. }
  619.  
Just some clarification...

The first issue I noticed is related to the size of the new edited avi saved, that is too big as compared to the original one. I assume that is due to some wrong settings in my code. But also anything else about performance and quality is welcome! :-)

A second question I would ask is about overlapping an image on the bitmaps of the api. In my code the avi is played and recaptured one bitmap at a time. I wonder whether you could directly overlap an image on the bitmaps without playing/recapturing.

Eventually a third point could be the use of better library than shlwapi.lib or different avi_utils...
Sep 25 '09 #1
1 4530
@giulio8
Ok, I think I have to use:

Expand|Select|Wrap|Line Numbers
  1. graphic = Graphics.FromImage(bitmap);
  2. ...
  3. graphic.DrawLine... etc. 
Sep 28 '09 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: PeQuApItChEr310 | last post by:
Hey i was wondeirng if theres a code where you could have the video on your site automaticly fast foward to a certain point in the video or have the video automaticly start from a certain point??
2
by: ankul | last post by:
How can I make a video editing and playing program in vb
1
by: kate | last post by:
The site I do is getting video content and dinosaur that I am, I am not prepared. I need to edit the first video and I don't have a video editor.(I downloaded VideoREDO Plus shareware version but...
1
by: Michael A. Covington | last post by:
I asked about this several months ago and got some useful advice, but now that we've had 4 months of progress and turnover, let me ask again... What's involved in using DirectShow to edit video? ...
4
by: chrisdude911 | last post by:
look at this page http://www.acejs.com/scriptsfolder/110003/110003.html is has a custom web button for *audio* is it possible for me to edit the code to make it *video* Thanks Chris
12
by: Pallas | last post by:
Hi all, I've produced some high-def videos and I want people to be able to watch them on my website, but I may want to prevent downloads and I certainly want to prevent them from editing them....
0
by: google | last post by:
is it posable to let a user upload a video/audio file and then i edit it like you can with pictures? eg. change reselution, put a pre recorded introduction to it (branding it to a website) or even...
6
by: John Salerno | last post by:
Before I try this and destroy my computer :) I just wanted to see if this would even work at all. Is it possible to read a binary file such as an mp3 or an avi, put its contents into a new file,...
0
by: =?Utf-8?B?Sm9uYXRoYW4=?= | last post by:
Hi, we have a camera within a magnifier. What I would like to do is have my vb.net application play the s video feed and allow the user to take snapshots. The application will automatically save...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.