Introduction
This is a very small console program to convert video in AVI format into a BMP file or files. I guess that's all that I can tell about this program. Oh, one thing more. I use some pragma directives to reduce the size of the program. That's all.
Using the code
OK! In my program, I use the standard way to extract a frame from an AVI file and save it into a BMP file. There's nothing special or secret in it. Just the standard Win32 API and VFW API. That's all!
char AVIFileName[_SIZE]={0};
AVIFILE aviFile;
PAVISTREAM aviStream;
AVISTREAMINFO aviStreamInfo;
AVIFileInit();
AVIFileOpen(&aviFile,AVIFileName,OF_READ,NULL);
AVIFileGetStream(aviFile,&aviStream,streamtypeVIDEO,0);
AVIFileRelease(aviFile);
AVIStreamInfo(aviStream,&aviStreamInfo,sizeof(aviStreamInfo));
BITMAPFILEHEADER BMPFileHeader;
LPBITMAPINFOHEADER lpbi;
PGETFRAME pgf;
pgf=AVIStreamGetFrameOpen(aviStream,NULL);
lpbi=(LPBITMAPINFOHEADER)AVIStreamGetFrame(pgf,fr);
BMPFileHeader.bfType=0x4d42;
BMPFileHeader.bfSize=(DWORD)(sizeof(BITMAPFILEHEADER)+lpbi->biSize+
lpbi->biClrUsed*sizeof(RGBQUAD)+lpbi->biSizeImage);
BMPFileHeader.bfReserved1=0;
BMPFileHeader.bfReserved2=0;
BMPFileHeader.bfOffBits=(DWORD)sizeof(BITMAPFILEHEADER)+lpbi->biSize+
lpbi->biClrUsed*sizeof(RGBQUAD);
WriteFile(hFile,(LPVOID)&BMPFileHeader,sizeof(BITMAPFILEHEADER),
(LPDWORD)&lpNumberOfBytesWritten,NULL);
WriteFile(hFile,(LPVOID)lpbi,sizeof(BITMAPFILEHEADER)+lpbi->biSize+
lpbi->biClrUsed*sizeof(RGBQUAD)+lpbi->biSizeImage,
(LPDWORD)&lpNumberOfBytesWritten,NULL);
AVIStreamGetFrameClose(pgf);
AVIFileExit();
History
OK! I want to correct some error handlers, but may be next time.