public void RenderToGIF(Image[] images)
        {
            string outPath = "";
            Start:
            if (!String.IsNullOrEmpty(ScreenCapBgLocText.Text))
            {
                try
                {
                    outPath = ScreenCapBgLocText.Text;
                    if (!Directory.Exists(outPath))
                        Directory.CreateDirectory(outPath);

                    DirectoryInfo dir = new DirectoryInfo(outPath);
                    FileInfo[] files = dir.GetFiles();
                    int i = 0;
                    string name = "Animation";
                Top:
                    foreach (FileInfo f in files)
                        if (f.Name == name + i + ".gif")
                        {
                            i++;
                            goto Top;
                        }
                    outPath += "\\" + name + i + ".gif";
                }
                catch { }
            }
            else
            {
                ScreenCapBgLocText.Text = Application.StartupPath + "\\ScreenCaptures";
                goto Start;
            }

            AnimatedGifEncoder e = new AnimatedGifEncoder();
            e.Start(outPath);
            e.SetDelay(1000 / (int)pnlPlayback.numFPS.Value);
            e.SetRepeat(0);
            e.SetQuality(1);
            using (ProgressWindow progress = new ProgressWindow(this, "GIF Encoder", "Encoding, please wait...", true))
            {
                progress.TopMost = true;
                progress.Begin(0, images.Length, 0);
                for (int i = 0, count = images.Length; i < count; i++)
                {
                    if (progress.Cancelled)
                        break;

                    e.AddFrame(images[i]);
                    progress.Update(progress.CurrentValue + 1);
                }
                progress.Finish();
                e.Finish();
            }

            if (InterpolationEditor != null)
                InterpolationEditor.Enabled = true;
            ModelPanel.Enabled = true;
            Enabled = true;

            MessageBox.Show("GIF successfully saved to " + outPath.Replace("\\", "/"));
        }
Example #2
0
        private void RenderToGIF(Image[] images)
        {
            string outPath = "";

Start:
            if (!String.IsNullOrEmpty(ScreenCapBgLocText.Text))
            {
                try
                {
                    outPath = ScreenCapBgLocText.Text;
                    if (!Directory.Exists(outPath))
                    {
                        Directory.CreateDirectory(outPath);
                    }

                    DirectoryInfo dir   = new DirectoryInfo(outPath);
                    FileInfo[]    files = dir.GetFiles();
                    int           i     = 0;
                    string        name  = "BrawlboxAnimation";
Top:
                    foreach (FileInfo f in files)
                    {
                        if (f.Name == name + i + ".gif")
                        {
                            i++;
                            goto Top;
                        }
                    }
                    outPath += "\\" + name + i + ".gif";
                }
                catch { }
            }
            else
            {
                ScreenCapBgLocText.Text = Application.StartupPath + "\\ScreenCaptures";
                goto Start;
            }

            AnimatedGifEncoder e = new AnimatedGifEncoder();

            e.Start(outPath);
            e.SetDelay(1000 / (int)pnlPlayback.numFPS.Value);
            e.SetRepeat(0);
            e.SetQuality(1);
            using (ProgressWindow progress = new ProgressWindow(this, "GIF Encoder", "Encoding, please wait...", true))
            {
                progress.TopMost = true;
                progress.Begin(0, images.Length, 0);
                for (int i = 0, count = images.Length; i < count; i++)
                {
                    if (progress.Cancelled)
                    {
                        break;
                    }

                    e.AddFrame(images[i]);
                    progress.Update(progress.CurrentValue + 1);
                }
                progress.Finish();
                e.Finish();
            }

            if (InterpolationEditor != null)
            {
                InterpolationEditor.Enabled = true;
            }
            ModelPanel.Enabled = true;
            Enabled            = true;

            MessageBox.Show("GIF successfully saved to " + outPath.Replace("\\", "/"));
        }
Example #3
0
        private void RenderToGIF(List <Image> images, string path)
        {
            if (string.IsNullOrEmpty(path))
            {
                return;
            }

            string outPath = "";

            try
            {
                outPath = path;
                if (!Directory.Exists(outPath))
                {
                    Directory.CreateDirectory(outPath);
                }

                DirectoryInfo dir   = new DirectoryInfo(outPath);
                FileInfo[]    files = dir.GetFiles();
                int           i     = 0;
                string        name  = "Animation";
Top:
                foreach (FileInfo f in files)
                {
                    if (f.Name == name + i + ".gif")
                    {
                        i++;
                        goto Top;
                    }
                }

                outPath += "\\" + name + i + ".gif";
            }
            catch
            {
            }

            AnimatedGifEncoder e = new AnimatedGifEncoder();

            e.Start(outPath);
            e.SetDelay(1000 / (int)PlaybackPanel.numFPS.Value);
            e.SetRepeat(0);
            e.SetQuality(10);
            using (ProgressWindow progress = new ProgressWindow(this, "GIF Encoder", "Encoding, please wait...", true))
            {
                progress.TopMost = true;
                progress.Begin(0, images.Count, 0);
                for (int i = 0, count = images.Count; i < count; i++)
                {
                    if (progress.Cancelled)
                    {
                        break;
                    }

                    //GIF transparency support is pretty poor, flickers a lot
                    //e.SetTransparent(ModelPanel.CurrentViewport.BackgroundColor);

                    e.AddFrame(images[i]);
                    progress.Update(progress.CurrentValue + 1);
                }

                progress.Finish();
                e.Finish();
            }

            if (MessageBox.Show(this,
                                "Animated GIF successfully saved to \"" + outPath.Replace("\\", "/") + "\".\nOpen the folder now?",
                                "GIF saved", MessageBoxButtons.YesNo) == DialogResult.Yes)
            {
                Process.Start("explorer.exe", path);
            }
        }