示例#1
0
        public override Task StartConvertingAsyncTask()
        {
            return Task.Run(() =>
            {
                Encoder = new AnimatedGifEncoder();
                _mediaDetector = new MediaDetector();
                _mediaDetector.LoadMedia(Path);

                ConvertingProgressBar.Dispatcher.Invoke(
                    DispatcherPriority.Normal,
                    new Action(() =>
                    {
                        ConvertingProgressBar.Value = 0;
                        ConvertingProgressBar.Maximum = (To - From) * Fps / 1000;
                    }));
                Encoder.Start(GifPath);
                Encoder.SetDelay(Ival);
                Encoder.SetRepeat(0);
                for (var i = From; i < To; i += Ival)
                {
                    var frame = GetFrame(TimeSpan.FromMilliseconds(i));
                    if (GifSize.Height != -1 && GifSize.Width != -1)
                        frame = ResizeImage(frame);
                    AddFrame(frame);
                    ConvertingProgressBar.Dispatcher.Invoke(
                        DispatcherPriority.Normal,
                        new Action(() =>
                        {
                            ConvertingProgressBar.Value++;
                        }));
                }
                Encoder.Finish();
            });
        }
示例#2
0
	public void BeginRendering()
	{
		if(rendering)
		{
			Debug.Log("Recording Error: attempt to begin recording while already recording");
			return;
        }

		gifEncoder = new AnimatedGifEncoder(currentPath + "output_" + DateTime.Now.ToString("yyyy-MM-dd_HH-mm-ss") + ".gif");
        
		gifEncoder.SetDelay(1000/60);
		//Invoke("Finish", lengthInSeconds);
		timespent = 0;
		rendering = true;
	}