Bitmaps to videos
Written by Harry Fairhead   
Tuesday, 21 July 2009
Article Index
Bitmaps to videos
Bitmap Class
Making the video
Compression
Action

 

Using it

With the class fully defined we can now use it to create a video. Add a button to the form and in its click event handler write:

 

BmpToAVI movie=new BmpToAVI(this.Handle);
movie.FirstFrame(
@"c:\test.avi", @"c:\1.bmp");
for (int i = 2; i <= 10; i++)
{
movie.NextFrame(
@"c:\" + i.ToString() + ".bmp");
}
movie.closeAll();

Prepare 10 bitmaps called 1.bmp, 2.bmp .. to 10.bmp containing the digits 0 to 9. These should be 24-bit uncompressed .BMP format files – you can use Paint to create them. Compressed .BMP files don’t work with VfW unless you explicitly uncompress them first. Palette 256 colour bitmaps also don’t seem to work but they don’t generate an error message.

 

bitmaps

The raw material

 

You also need to be aware that some graphics programs don’t write all of the fields in the bitmap headers and this can cause problems. None of the example code has any error checking included so that you can see more clearly how it all works. Using this and your first generated video you should be able to use the rest of the VfW API to do things like extract frames, recompress video data, add sound tracks and so on.

If you would like the code for this project then register and click on CodeBin.

play

The test video in action

<ASIN:0240808312>

<ASIN:0321514696>

<ASIN:0470131136>



Last Updated ( Tuesday, 21 July 2009 )