Beispiel #1
0
        private async Task PrepareNewCapture()
        {
            if (_capture != null)
            {
                await _capture.Dispose();
            }

            if (UserSettings.All.UseDesktopDuplication)
            {
                //Check if Windows 8 or newer.
                if (!Util.Other.IsWin8OrHigher())
                {
                    throw new Exception(LocalizationHelper.Get("S.Recorder.Warning.Windows8"));
                }

                //Check if SharpDx is available.
                if (!Util.Other.IsSharpDxPresent())
                {
                    throw new Exception(LocalizationHelper.Get("S.Recorder.Warning.MissingSharpDx"));
                }

                Util.Other.LoadSharpDx();

                _capture = GetDirectCapture();
            }
            else
            {
                //Capture with BitBlt.
                _capture = UserSettings.All.UseMemoryCache ? new CachedCapture() : new ImageCapture();
            }

            _capture.OnError += exception =>
            {
                Dispatcher?.Invoke(async() =>
                {
                    //Pause the recording and show the error.
                    await RecordPause();

                    ErrorDialog.Ok("ScreenToGif", LocalizationHelper.Get("S.Recorder.Warning.CaptureNotPossible"), exception.Message, exception);
                });
            };

            var dpi = Monitor.AllMonitors.FirstOrDefault(f => f.IsPrimary)?.Dpi ?? 96d;

            _capture.Start(1000 / FpsIntegerUpDown.Value, _left, _top, _width, _height, dpi / 96d, Project);
        }
Beispiel #2
0
        private void PrepareNewCapture()
        {
            _capture?.Dispose();

            if (UserSettings.All.UseDesktopDuplication)
            {
                //Check if Windows 8 or newer.
                if (!Util.Other.IsWin8OrHigher())
                {
                    throw new Exception(LocalizationHelper.Get("S.Recorder.Warning.Windows8"));
                }

                //Check if SharpDx is available.
                if (!Util.Other.IsSharpDxPresent())
                {
                    throw new Exception(LocalizationHelper.Get("S.Recorder.Warning.MissingSharpDx"));
                }

                _capture = UserSettings.All.UseMemoryCache ? new DirectCachedCapture() : new DirectImageCapture();
            }
            else
            {
                //Capture with BitBlt.
                _capture = UserSettings.All.UseMemoryCache ? new CachedCapture() : new ImageCapture();
            }

            _capture.OnError += exception =>
            {
                //Pause the recording and show the error.
                RecordPause();

                ErrorDialog.Ok("ScreenToGif", LocalizationHelper.Get("S.Recorder.Warning.CaptureNotPossible"), exception.Message, exception);
            };

            _capture.Start(1000 / FpsIntegerUpDown.Value, _left, _top, _width, _height, 96 * _scale, Project);
        }
Beispiel #3
0
 private void btnCapture_Click(object sender, EventArgs e)
 {
     videoCapture = new VideoCapture();
     videoCapture.ImageGrabbed += ProcessFrame;
     videoCapture.Start();
 }