Esempio n. 1
0
        public static Bitmap getBitmapFromFrame(AviSynthClip avs, int clp, int frame)
        {
            Bitmap bmp;
            if (avs.PixelType == AviSynthColorspace.RGB24) bmp = new Bitmap(avs.VideoWidth, avs.VideoHeight, System.Drawing.Imaging.PixelFormat.Format24bppRgb);
            else if (avs.PixelType == AviSynthColorspace.RGB32) bmp = new Bitmap(avs.VideoWidth, avs.VideoHeight, System.Drawing.Imaging.PixelFormat.Format32bppRgb);
            else
                bmp = new Bitmap(avs.VideoWidth, avs.VideoHeight, System.Drawing.Imaging.PixelFormat.Format32bppRgb);

            try
            {
                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
                {
                    IntPtr ptr = bmpData.Scan0;
                    avs.ReadFrame(ptr, clp, bmpData.Stride, frame);
                }
                finally
                {
                    bmp.UnlockBits(bmpData);
                }
            }
            catch
            {
            }
            bmp.RotateFlip(RotateFlipType.Rotate180FlipX);
            return bmp;
        }