Exemplo n.º 1
0
            public Bitmap ReadFrameBitmap(int position)
            {
                Bitmap bmp = new Bitmap(width, height, System.Drawing.Imaging.PixelFormat.Format24bppRgb);

                try
                {
                    // 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
                        clip.ReadFrame(ptr, bmpData.Stride, position);
                    }
                    finally
                    {
                        // Unlock the bits.
                        bmp.UnlockBits(bmpData);
                    }
                    bmp.RotateFlip(RotateFlipType.Rotate180FlipX);
                    return(bmp);
                }
                catch (Exception)
                {
                    bmp.Dispose();
                    throw;
                }
            }
Exemplo n.º 2
0
            public Bitmap ReadFrameBitmap(int position)
            {
                Bitmap bmp = new Bitmap(width, height, System.Drawing.Imaging.PixelFormat.Format24bppRgb);

                try
                {
                    // 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
                        clip.ReadFrame(ptr, bmpData.Stride, position);
                    }
                    finally
                    {
                        // Unlock the bits.
                        bmp.UnlockBits(bmpData);
                    }
                    bmp.RotateFlip(RotateFlipType.Rotate180FlipX);
                    return(bmp);
                }
                catch (System.Runtime.InteropServices.SEHException ex)
                {
                    bmp.Dispose();

                    MeGUI.core.util.LogItem _oLog = MainForm.Instance.AVSScriptCreatorLog;
                    if (_oLog == null)
                    {
                        _oLog = MainForm.Instance.Log.Info("AVS Script Creator");
                        MainForm.Instance.AVSScriptCreatorLog = _oLog;
                    }
                    _oLog.LogValue("Could not read frame", ex.Message, MeGUI.core.util.ImageType.Warning, true);

                    throw;
                }
                catch (Exception ex)
                {
                    bmp.Dispose();

                    MeGUI.core.util.LogItem _oLog = MainForm.Instance.AVSScriptCreatorLog;
                    if (_oLog == null)
                    {
                        _oLog = MainForm.Instance.Log.Info("AVS Script Creator");
                        MainForm.Instance.AVSScriptCreatorLog = _oLog;
                    }
                    _oLog.LogValue("Could not read frame", ex.Message, MeGUI.core.util.ImageType.Warning, true);

                    throw;
                }
            }
Exemplo n.º 3
0
            public Bitmap ReadFrameBitmap(int position)
            {
                Bitmap bmp = new Bitmap(width, height, System.Drawing.Imaging.PixelFormat.Format24bppRgb);

                try
                {
                    // 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
                        clip.ReadFrame(ptr, bmpData.Stride, position);
                    }
                    finally
                    {
                        // Unlock the bits.
                        bmp.UnlockBits(bmpData);
                    }
                    bmp.RotateFlip(RotateFlipType.Rotate180FlipX);
                    return(bmp);
                }
                catch (System.Runtime.InteropServices.SEHException)
                {
                    bmp.Dispose();
                    if (MainForm.Instance.Settings.OpenAVSInThreadDuringSession)
                    {
                        MainForm.Instance.Settings.OpenAVSInThreadDuringSession = false;
                        MessageBox.Show("External AviSynth Error. As a result during this session the option \"Improved AVS opening\" in the settings is now disabled. Please disable it there completly if necessary.", "AviSynth Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                    throw;
                }
                catch (Exception)
                {
                    bmp.Dispose();
                    throw;
                }
            }