public Bitmap ReadFrameBitmap(AviSynthClip asc, int position) { Bitmap bmp = null; try { bmp = new Bitmap(asc.VideoWidth, asc.VideoHeight, System.Drawing.Imaging.PixelFormat.Format24bppRgb); // Lock the bitmap's bits. Rectangle rect = new Rectangle(0, 0, bmp.Width, bmp.Height); System.Drawing.Imaging.BitmapData bmpData = bmp.LockBits(rect, System.Drawing.Imaging.ImageLockMode.ReadWrite, bmp.PixelFormat); try { // Get the address of the first line. IntPtr ptr = bmpData.Scan0; // Read data asc.ReadFrame(ptr, bmpData.Stride, position); } finally { // Unlock the bits. bmp.UnlockBits(bmpData); } bmp.RotateFlip(RotateFlipType.Rotate180FlipX); return bmp; } catch (Exception) { if(bmp != null) bmp.Dispose(); throw; } }