예제 #1
0
        public override void PerformRender(RectangleF rectangle, IEnumerable <BrushRenderTarget> renderTargets)
        {
            ScreenPixelData = ScreenCapture.CaptureScreen();

            SourceWidth  = ScreenCapture.Width;
            SourceHeight = ScreenCapture.Height;

            OffsetLeft = Settings.OffsetLeft + (Settings.BlackBarDetectionMode.HasFlag(BlackBarDetectionMode.Left)
                                 ? ScreenPixelData.DetectBlackBarLeft(SourceWidth, SourceHeight, Settings.OffsetLeft, Settings.OffsetRight, Settings.OffsetTop, Settings.OffsetBottom)
                                 : 0);
            OffsetRight = Settings.OffsetRight + (Settings.BlackBarDetectionMode.HasFlag(BlackBarDetectionMode.Right)
                                  ? ScreenPixelData.DetectBlackBarRight(SourceWidth, SourceHeight, Settings.OffsetLeft, Settings.OffsetRight, Settings.OffsetTop, Settings.OffsetBottom)
                                  : 0);
            OffsetTop = Settings.OffsetTop + (Settings.BlackBarDetectionMode.HasFlag(BlackBarDetectionMode.Top)
                                ? ScreenPixelData.DetectBlackBarTop(SourceWidth, SourceHeight, Settings.OffsetLeft, Settings.OffsetRight, Settings.OffsetTop, Settings.OffsetBottom)
                                : 0);
            OffsetBottom = Settings.OffsetBottom + (Settings.BlackBarDetectionMode.HasFlag(BlackBarDetectionMode.Bottom)
                                   ? ScreenPixelData.DetectBlackBarBottom(SourceWidth, SourceHeight, Settings.OffsetLeft, Settings.OffsetRight, Settings.OffsetTop, Settings.OffsetBottom)
                                   : 0);

            EffectiveSourceWidth  = SourceWidth - OffsetLeft - OffsetRight;
            EffectiveSourceHeight = (int)Math.Round((SourceHeight - OffsetTop - OffsetBottom) * (Settings.MirroredAmount / 100.0));

            Increment = Math.Max(1, Math.Min(20, Settings.Downsampling));

            KeyWidthProportion  = EffectiveSourceWidth / rectangle.Width;
            KeyHeightProportion = EffectiveSourceHeight / rectangle.Height;

            Opacity = Settings.SmoothMode == SmoothMode.Low ? 0.25f : (Settings.SmoothMode == SmoothMode.Medium ? 0.075f : (Settings.SmoothMode == SmoothMode.High ? 0.025f : 1f /*None*/));

            base.PerformRender(rectangle, renderTargets);
        }
예제 #2
0
 private void UpdateLoop()
 {
     while (true)
     {
         _cancellationToken.ThrowIfCancellationRequested();
         bool success = _screenCapture.CaptureScreen();
         Updated?.Invoke(this, new ScreenCaptureUpdatedEventArgs(success));
     }
 }
예제 #3
0
        private BitmapContainer CaptureBitmap()
        {
            lock (this.bitmapLock)
            {
                var fileBytes  = screenCapture.CaptureScreen();
                var fileString = Convert.ToBase64String(fileBytes);

                return(new BitmapContainer()
                {
                    EncodedBitmap = fileString
                });
            }
        }