Convert dynamic BMP 24 to avi
BYTE tmp_buf [1024*768*4]; // Generate avivoid BMP toavi (CString szAVIName, CString strbmp dir) {CFileFind finder; strbmp Dir + = _ T ("\\*. bmp "); AVIFileInit (); AVISTREAMINFO strhdr; PAVIFILE pfile; PAVISTREAM ps; int nFrames = 0; HRESULT hr; BOOL bFind = finder. findFile (strbmp dir); while (bFind) {bFind = finder. findNextFile (); if (! Finder. IsDots ()&&! Finder. isDirectory () {CString str = finder. getFilePath (); // Retrieve The FILE * fp = fopen (str, "rb"); bitmapfileheader bmp filehdr; bitmapinfoheader bmp infohdr; fseek (fp, 0, SEEK_SET ); fread (& BMP filehdr, sizeof (BITMAPFILEHEADER), 1, fp); fread (& BMP infohdr, sizeof (BITMAPINFOHEADER), 1, fp ); // read the file header if (nFrames = 0) {AVIFileOpen (& pfile, szAVIName, OF_WRITE | OF_CREATE, NULL); memset (& strhdr, 0, sizeof (strhdr )); strhdr. fccType = s TreamtypeVIDEO; // stream typestrhdr. fccHandler = 0; strhdr. dwScale = 1; strhdr. dwRate = 25; // 15 fpsstrhdr. dwSuggestedBufferSize = BMP infohdr. biSizeImage; SetRect (& strhdr. rcFrame, 0, 0, BMP infohdr. biWidth, BMP infohdr. biHeight); // And create the stream; hr = AVIFileCreateStream (pfile, & ps, & strhdr); // hr = AVIStreamSetFormat (ps, nFrames, & BMP infohdr, sizeof (BMP infohdr);} // tmp_buf = new BYTE [BMP infohdr. B IWidth * BMP infohdr. biHeight * 4]; fread (tmp_buf, 1, BMP infohdr. biWidth * BMP infohdr. biHeight * 3, fp); // read file data hr = AVIStreamSetFormat (ps, nFrames, & BMP infohdr, sizeof (BMP infohdr); hr = AVIStreamWrite (ps, // stream pointernFrames, // time of this frame1, // number to write (LPBYTE) tmp_buf, BMP infohdr. biSizeImage, // size of this frameAVIIF_KEYFRAME, // flags .... NULL, NULL); nFrames ++; fclose (fp) ;}} AVI StreamClose (ps); if (pfile! = NULL) AVIFileRelease (pfile); AVIFileExit ();} void CTestaviDlg: OnButton2 () {BMP toavi ("f: \ ffoutput \ 1.avi"," f: \ ffoutput \ pic \ "); MessageBox (" over ");}
Convert continuous dynamic bmp to avi