Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

AVI to BMP??

Status
Not open for further replies.

snounours

Technical User
May 22, 2004
1
FR
Can you help me to found the code source in VC++ to convert an AVI file into Bitmaps files

Thanks
 
The following will dump frames into a window called m_imgView. Find the comment for where you can save to disk instead.
With this way, you are using VideoForWindows.

Code:
PAVIFILE pfile;
AVIFILEINFO pfi;
PAVISTREAM pavi;
LPBITMAPINFOHEADER lpbi;
PGETFRAME pgf;
HDRAWDIB hdd;
CDC *pDC = m_imgView.GetDC();
HDC hdc = pDC->GetSafeHdc();
CRect r;
int frameInMsecs = 0, samples = 0, result = 0;

AVIFileInit();
//m_strFile = name of AVI file
result = AVIFileOpen(&pfile, m_strFile, OF_READ, NULL);
result = AVIFileInfo(pfile, &pfi, sizeof(pfi));
result = AVIFileGetStream(pfile, &pavi, streamtypeVIDEO, 0);
pgf = AVIStreamGetFrameOpen(pavi, NULL);
hdd = DrawDibOpen();

//loop here for all m_nFrame
//calculate frame rate
frameInMsecs = (int)((float)m_nFrame * 33.33f);
samples = AVIStreamTimeToSample(pavi, frameInMsecs);
lpbi = (LPBITMAPINFOHEADER)AVIStreamGetFrame(pgf, samples);
//lpbi now holds bitmap header, color palletes, and rgb data
//you'll probably want to save the lpbi stuff to disk here
//the following just draws to the screen
DrawDibDraw(hdd, hdc,
0, 0, m_rView.right, m_rView.bottom,
lpbi, (LPVOID)((DWORD)lpbi + (DWORD)(lpbi->biSize) + (DWORD)(lpbi->biClrUsed)),
0, 0, lpbi->biWidth, lpbi->biHeight,
DDF_DONTDRAW | DDF_SAME_HDC);
DrawDibDraw(hdd, hdc,
0, 0, m_rView.right, m_rView.bottom,
lpbi, (LPVOID)((DWORD)lpbi + (DWORD)(lpbi->biSize) + (DWORD)(lpbi->biClrUsed)),
0, 0, lpbi->biWidth, lpbi->biHeight,
DDF_UPDATE | DDF_SAME_HDC);
//end loop
DrawDibClose(hdd);
result = AVIStreamGetFrameClose(pgf);
AVIStreamRelease(pavi);
AVIFileRelease(pfile);
AVIFileExit();

Standa K.
 
I know you have include vfw.h and the vfw32.lib -- but you get lots of linker errors in VC++ .NET 2003. What else do you need to link to get this to work?

THANKS
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top