Esempio n. 1
0
 protected override void OnClosed(EventArgs e)
 {
     if (_disposed)
     {
         return;
     }
     _disposed = true;
     if (_outputFile != null)
     {
         _outputFile.Dispose();
     }
     base.OnClosed(e);
 }
Esempio n. 2
0
    private void ConvertCaptureToGif(string path)
    {
        string outputPath = Path.Combine(path, "capture.gif");

        session.Video = Path.Combine(session.Video, "capture.gif");
        DataService.Instance.UpdateSession(session);

        var gifWriter = new GifWriter(outputPath);

        // Find capture files
        var imageFiles = Directory.GetFiles(path).Where(file => file.Substring(file.Length - 4) == ".png").ToList();

        imageFiles.Sort();

        foreach (var imageFile in imageFiles)
        {
            var image = Image.FromFile(imageFile);
            gifWriter.WriteFrame(image);

            // Delete the file
            image.Dispose();
            File.Delete(imageFile);
        }

        gifWriter.Dispose();
    }
        /// <summary>
        /// HelmsDeepButton is a Static method that resets the etire GIF drawing process,
        /// resets all cells, redraws each cell, and prints a specified ammount of frames,
        /// both to a form passed and to an output 'Output.gif' file.
        /// </summary>
        /// <param name="f">The form to draw the new frames to</param>
        /// <param name="frames">The ammount of frames to print</param>
        public static void HelmsDeepButton(Form1 f, int frames = 20)
        {
            Stream       s    = File.Create("Output.gif");
            StreamWriter sw   = new StreamWriter(s);
            GifWriter    gw   = new GifWriter(s, 350, 1);
            Random       rand = new Random();

            FillCells();
            Bitmap m = new Bitmap(400, 400);

            //Graphics g = Graphics.FromImage(m);
            DisplayCells(f, rand, m);
            Graphics gg = f.CreateGraphics();

            gg.DrawImage(new Bitmap("Help.png"), 400, 50);
            gg.Dispose();
            for (int i = 0; i < frames; i++)
            {
                Debug.WriteLine(" I is " + i);
                Globals.PrintCells();
                SetUpSiegeAnimation(rand);
                RunAnimation();
                DisplayCells(f, rand, m, i);
                m.Save("temp.png", ImageFormat.Png);
                Globals.PrintCells();
                gw.WriteFrame(m);
                Thread.Sleep(1000);
            }
            //g.Dispose();
            m.Dispose();
            gw.Dispose();
            s.Close();
        }
Esempio n. 4
0
    private static void CreateGif(IEnumerable <int[, ]> boards, Func <int[, ], Image> BoardToImage)
    {
        var stream    = new FileStream("./test.gif", FileMode.OpenOrCreate);
        var gifWriter = new GifWriter(stream);

        foreach (var b in boards)
        {
            gifWriter.WriteFrame(BoardToImage(b), 100);
        }

        gifWriter.Dispose();
        stream.Dispose();
    }
Esempio n. 5
0
        private void Dispose(bool errorOccurred)
        {
            // Resume if Paused
            _continueCapturing.Set();

            _stopCapturing.Set();

            if (!errorOccurred)
            {
                _recordTask.Wait();
            }

            _continueCapturing.Dispose();
            _stopCapturing.Dispose();

            _timing.Stop();

            _imageProvider.Dispose();

            _videoEncoder.Dispose();
        }