23 if (_tcsstr((
char *)
m_sFile, _T(
"avi")) ==
nullptr)
24 m_sFile += _T(
".avi" );
39 bih.biSize =
sizeof(BITMAPINFOHEADER);
43 int imgSize = 3 * bih.biWidth * bih.biHeight;
45 bih.biCompression = BI_RGB;
46 bih.biSizeImage = imgSize;
48 bih.biClrImportant = 0;
54 memcpy(&
m_bih, &bih,
sizeof(BITMAPINFOHEADER));
62 AVICOMPRESSOPTIONS opts;
63 AVICOMPRESSOPTIONS FAR *aopts[1] = {&opts};
71 DWORD wVer = HIWORD(VideoForWindowsVersion());
75 m_sError = _T(
"Version of Video for Windows too old. Come on, join the 21th century!");
83 hr = AVIFileOpen(&m_pAVIFile,
91 _tprintf(szBuffer, _T(
"AVI Engine failed to initialize. Check filename %s."), m_sFile);
96 case AVIERR_BADFORMAT:
97 m_sError += _T(
"The file couldn't be read, indicating a corrupt file or an unrecognized format.");
100 m_sError += _T(
"The file could not be opened because of insufficient memory.");
102 case AVIERR_FILEREAD:
103 m_sError += _T(
"A disk error occurred while reading the file.");
105 case AVIERR_FILEOPEN:
106 m_sError += _T(
"A disk error occurred while opening the file.");
108 case REGDB_E_CLASSNOTREG:
109 m_sError += _T(
"According to the registry, the type of file specified in AVIFileOpen does not have a handler ")
118 memset(&strHdr, 0,
sizeof(strHdr));
119 strHdr.fccType = streamtypeVIDEO;
120 strHdr.fccHandler = 0;
123 strHdr.dwSuggestedBufferSize =
m_bih.biSizeImage;
124 SetRect(&strHdr.rcFrame,
128 (
int)
m_bih.biHeight);
131 hr = AVIFileCreateStream(m_pAVIFile,
138 m_sError = _T(
"AVI Stream creation failed. Check Bitmap info.");
139 if (hr == AVIERR_READONLY)
147 memset(&opts, 0,
sizeof(opts));
150 opts.fccType = streamtypeVIDEO;
153 opts.fccHandler = mmioFOURCC(
'M',
'S',
'V',
'C');
154 opts.dwQuality = 90000;
159 #if !(_MSC_VER >= 1400) 161 if (!AVISaveOptions(
nullptr, 0, 1, &m_pStream, (LPAVICOMPRESSOPTIONS FAR *)&aopts))
163 AVISaveOptionsFree(1, (LPAVICOMPRESSOPTIONS FAR *)&aopts);
170 hr = AVIMakeCompressedStream(&m_pStreamCompressed, m_pStream, &opts,
nullptr);
174 m_sError = _T(
"AVI Compressed Stream creation failed.");
178 case AVIERR_NOCOMPRESSOR:
179 m_sError += _T(
" A suitable compressor cannot be found.");
182 m_sError += _T(
" There is not enough memory to complete the operation.");
184 case AVIERR_UNSUPPORTED:
185 m_sError += _T(
"Compression is not supported for this type of data. This error might be returned if you try ")
186 _T(
"to compress data that is not audio or video.");
194 hr = AVISaveOptionsFree(1, (LPAVICOMPRESSOPTIONS FAR *)&aopts);
197 m_sError = _T(
"Error releasing memory");
202 hr = AVIStreamSetFormat(m_pStreamCompressed,
206 m_bih.biClrUsed *
sizeof(RGBQUAD));
210 m_sError = _T(
"AVI Compressed Stream format setting failed.");
222 HRESULT hr = AVIStreamWrite(m_pStreamCompressed,
243 AVIStreamRelease(m_pStream);
246 if (m_pStreamCompressed)
248 AVIStreamRelease(m_pStreamCompressed);
249 m_pStreamCompressed =
nullptr;
253 AVIFileRelease(m_pAVIFile);
254 m_pAVIFile =
nullptr;
virtual void SetFileName(const char *fileName)
filename under which movie is saved
virtual bool TerminateGenerator()
called after the last frame is added
void InitBitmapHeader()
reads out size of current OpenGL context and stores it
virtual bool AddFrame(void *data)
used to add a frame
BITMAPINFOHEADER m_bih
structure contains information for a single stream
_bstr_t m_sError
last error string
virtual bool InitGenerator()
called directly before the first frame is added
vtkRenderWindow * GetRenderWindow() const
Access the RenderWindow into which this renderer renders.
_bstr_t m_sFile
name of output file
int m_width
InitGenerator() stores movie size in those variables.
BaseRenderer * m_renderer
stores the uses renderer