Convert continuous dynamic bmp to avi

Source: Internet
Author: User
Tags fread
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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.