Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- HRESULT AddAviFrame(HAVI avi, DIBSECTION *dibs)
- {
- if( avi == NULL ) return AVIERR_BADHANDLE;
- TAviUtil *au = (TAviUtil*)avi;
- if( au->iserr ) return AVIERR_ERROR;
- //
- if( au->ps == 0 ) // create the stream, if it wasn't there before
- {
- AVISTREAMINFO strhdr; ZeroMemory(&strhdr, sizeof(strhdr));
- strhdr.fccType = streamtypeVIDEO;// stream type
- strhdr.fccHandler = 0;
- strhdr.dwScale = au->period;
- strhdr.dwRate = 1000;
- strhdr.dwSuggestedBufferSize = dibs->dsBmih.biSizeImage;
- SetRect(&strhdr.rcFrame, 0, 0, dibs->dsBmih.biWidth, dibs->dsBmih.biHeight);
- HRESULT hr = AVIFileCreateStream(au->pfile, &au->ps, &strhdr);
- if( hr != AVIERR_OK ) { au->iserr = true; return hr; }
- }
- //
- // create an empty compression, if the user hasn't set any
- if( au->psCompressed == 0 ) {
- AVICOMPRESSOPTIONS opts; ZeroMemory(&opts, sizeof(opts));
- opts.fccHandler = mmioFOURCC('D', 'I', 'B', ' ');
- HRESULT hr = AVIMakeCompressedStream(&au->psCompressed, au->ps, &opts, NULL);
- if( hr != AVIERR_OK ) { au->iserr = true; return hr; }
- hr = AVIStreamSetFormat(au->psCompressed, 0, &dibs->dsBmih, dibs->dsBmih.biSize + dibs->dsBmih.biClrUsed*sizeof(RGBQUAD));
- if( hr != AVIERR_OK ) { au->iserr = true; return hr; }
- }
- //
- //Now we can add the frame
- HRESULT hr = AVIStreamWrite(au->psCompressed, au->nframe, 1, dibs->dsBm.bmBits, dibs->dsBmih.biSizeImage, AVIIF_KEYFRAME, NULL, NULL);
- if( hr != AVIERR_OK ) { au->iserr = true; return hr; }
- au->nframe++; return S_OK;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement