|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
|
Announcements
Want a new Job?
Chapters
Services
Feature Zones
|
Introduction
The class main features are:
The class CAVIGenerator: A AVI Video wrapperA simple class that make creation of AVI video easy. AttributesEach object contains general characteristics of the movie such as
It contains also private members that are used to handle the "Video for Windows" AVI engine. ConstructorsCAVIGenerator(); Default constructor, default file name is "Untitled.avi", frame rate is 30 fps. CAVIGenerator(LPCTSTR sFileName, CView* pView, DWORD dwRate); In-place constructor with CView. See CAVIGenerator(LPCTSTR sFileName, LPBITMAPINFOHEADER lpbih, DWORD dwRate); In-place constructor with Setters and Gettersvoid SetFileName(const CString& _sFileName)
void SetRate(DWORD dwRate)
void SetBitmapHeader(CView* pView);
void SetBitmapHeader(LPBITMAPINFOHEADER lpbih);
LPBITMAPINFOHEADER GetBitmapHeader()
AVI creation FunctionsHRESULT InitEngine();
CAviGenerator avi;
HRESULT hr;
hr=avi.InitEngine();
if (FAILED(hr))
{
AfxMessageBox(avi.GetLastErrorMessage());
...
}
HRESULT AddFrame(BYTE* bmBits);
void ReleaseEngine();
Using CAVIGeneratorYou have to follow these steps:
And you're are done! Here's some demo pseudo-code: CAVIGenerator AviGen; // generator BYTE* bmBits; // image buffer HRESULT hr; AviGen.SetRate(20); // set 20fps AviGen.SetBitmapHeader(GetActiveView()); // get bitmap info out of the view hr=AviGen.InitEngine() // start engine if (FAILED(hr)) { AfxMessageBox(avi.GetLastErrorMessage()); goto Cleaning; } LPBITMAPINFOHEADER lpbih=AviGen.GetBitmapInfo(); // getting bitmap info // allocating memory for bmBits bmBits=new BYTE[3 /* BRG*/ * lpbih->biWidth* lpbih->biHeight]; for (int i=0;i<100;i++) // make 100 frames { // TODO pust your draw code here. /* Draw code where bmBits is filled. For example, to read OpenGL buffer, put glReadPixels(0,0,lpbih->biWidth,lpbih->biHeight, GL_BGR_EXT,GL_UNSIGNED_BYTE,bmBits); */ // adding frame and continue if OK hr=AviGen.AddFrame(bmBits); if (FAILED(hr)) { AfxMessageBox(avi.GetLastErrorMessage()); goto Cleaning; } } // cleaning memory Cleaning: AviGen.ReleaseEngine(); // releasing ressources delete[] bmBits; // release ressources Adding CAVIGenerator to your project
Non-MFC ApplicationsIf you want to use CAviGenerator without MFC, undefine _AVIGENERATOR_MFC in AviGenerator.h. It will disable MFC function calls.Demo projectA simple MFC SDI application that shows a cube and triangle rotating using OpenGL. When selecting the menu item Avi Generation->Generate..., you start to create a 100 frames AVI movie. OpenGL drawing code is copy-pasted from lesson 5 of NeHe Productions. Update History
|
||||||||||||||||||||||