Ejemplo n.º 1
0
        public ScreenRecorder(int fps, float durationSeconds, Rectangle captureRectangle, string cachePath, ScreenRecordOutput outputType)
        {
            if (string.IsNullOrEmpty(cachePath))
            {
                throw new Exception("Screen recorder cache path is empty.");
            }

            FPS = fps;
            DurationSeconds = durationSeconds;
            CaptureRectangle = captureRectangle;
            CachePath = cachePath;
            OutputType = outputType;

            if (OutputType == ScreenRecordOutput.AVI || OutputType == ScreenRecordOutput.AVICommandLine)
            {
                bool showOptions = OutputType == ScreenRecordOutput.AVI;
                aviCache = new AVICache(CachePath, FPS, CaptureRectangle.Size, showOptions);
            }
            else if (OutputType == ScreenRecordOutput.GIF)
            {
                hdCache = new HardDiskCache(CachePath);
            }
        }
Ejemplo n.º 2
0
        public ScreenRecorder(int fps, float durationSeconds, Rectangle captureRectangle, string cachePath, ScreenRecordOutput outputType)
        {
            if (string.IsNullOrEmpty(cachePath))
            {
                throw new Exception("Screen recorder cache path is empty.");
            }

            FPS              = fps;
            DurationSeconds  = durationSeconds;
            CaptureRectangle = captureRectangle;
            CachePath        = cachePath;
            OutputType       = outputType;

            if (OutputType == ScreenRecordOutput.AVI || OutputType == ScreenRecordOutput.AVICommandLine)
            {
                bool showOptions = OutputType == ScreenRecordOutput.AVI;
                aviCache = new AVICache(CachePath, FPS, CaptureRectangle.Size, showOptions);
            }
            else if (OutputType == ScreenRecordOutput.GIF)
            {
                hdCache = new HardDiskCache(CachePath);
            }
        }
Ejemplo n.º 3
0
        public void SaveAsGIF(string path, GIFQuality quality)
        {
            if (imgCache != null && imgCache is HardDiskCache && !IsRecording)
            {
                HardDiskCache hdCache = imgCache as HardDiskCache;

                using (AnimatedGifCreator gifEncoder = new AnimatedGifCreator(path, delay))
                {
                    int i     = 0;
                    int count = hdCache.Count;

                    foreach (Image img in hdCache.GetImageEnumerator())
                    {
                        i++;
                        OnEncodingProgressChanged((int)((float)i / count * 100));

                        using (img)
                        {
                            gifEncoder.AddFrame(img, quality);
                        }
                    }
                }
            }
        }