/// <summary>Adds a new frame to the AVI stream</summary> /// <param name="bmp">The image to add</param> public void AddFrame(Bitmap bmp) { bmp.RotateFlip(RotateFlipType.RotateNoneFlipY); BitmapData bmpDat = bmp.LockBits( new Rectangle(0, 0, bmp.Width, bmp.Height), ImageLockMode.ReadOnly, bmp.PixelFormat); if (countFrames == 0) { //this is the first frame - get size and create a new stream this.stride = (UInt32)bmpDat.Stride; this.width = bmp.Width; this.height = bmp.Height; CreateStream(); } int result = Avi.AVIStreamWrite(aviStream, countFrames, 1, bmpDat.Scan0, //pointer to the beginning of the image data (Int32)(stride * height), 0, 0, 0); if (result != 0) { throw new Exception("Error in AVIStreamWrite: " + result.ToString()); } bmp.UnlockBits(bmpDat); bmp.Dispose(); countFrames++; }