From d3295a412a2b3b3867508adb18ae7ef5776f1123 Mon Sep 17 00:00:00 2001 From: Jaex Date: Tue, 14 Nov 2017 15:15:28 +0300 Subject: [PATCH] Fix OnDrawFinal issues --- .../Shapes/Effect/BlurEffectShape.cs | 12 +++++++----- .../Shapes/Effect/HighlightEffectShape.cs | 12 +++++++----- .../Shapes/Effect/PixelateEffectShape.cs | 12 +++++++----- 3 files changed, 21 insertions(+), 15 deletions(-) diff --git a/ShareX.ScreenCaptureLib/Shapes/Effect/BlurEffectShape.cs b/ShareX.ScreenCaptureLib/Shapes/Effect/BlurEffectShape.cs index f4d1be9ef..ee6883b0f 100644 --- a/ShareX.ScreenCaptureLib/Shapes/Effect/BlurEffectShape.cs +++ b/ShareX.ScreenCaptureLib/Shapes/Effect/BlurEffectShape.cs @@ -77,14 +77,16 @@ public override void OnDrawFinal(Graphics g, Bitmap bmp) { if (BlurRadius > 1) { - Rectangle rect = new Rectangle(0, 0, bmp.Width, bmp.Height); - rect.Intersect(Rectangle); + Rectangle rect = Rectangle.Intersect(new Rectangle(0, 0, bmp.Width, bmp.Height), Rectangle); - using (Bitmap croppedImage = ImageHelpers.CropBitmap(bmp, rect)) + if (!rect.IsEmpty) { - ApplyEffect(croppedImage); + using (Bitmap croppedImage = ImageHelpers.CropBitmap(bmp, rect)) + { + ApplyEffect(croppedImage); - g.DrawImage(croppedImage, rect); + g.DrawImage(croppedImage, rect); + } } } } diff --git a/ShareX.ScreenCaptureLib/Shapes/Effect/HighlightEffectShape.cs b/ShareX.ScreenCaptureLib/Shapes/Effect/HighlightEffectShape.cs index 700751dcb..4f6212cfd 100644 --- a/ShareX.ScreenCaptureLib/Shapes/Effect/HighlightEffectShape.cs +++ b/ShareX.ScreenCaptureLib/Shapes/Effect/HighlightEffectShape.cs @@ -75,14 +75,16 @@ public override void OnDrawOverlay(Graphics g) public override void OnDrawFinal(Graphics g, Bitmap bmp) { - Rectangle rect = new Rectangle(0, 0, bmp.Width, bmp.Height); - rect.Intersect(Rectangle); + Rectangle rect = Rectangle.Intersect(new Rectangle(0, 0, bmp.Width, bmp.Height), Rectangle); - using (Bitmap croppedImage = ImageHelpers.CropBitmap(bmp, rect)) + if (!rect.IsEmpty) { - ApplyEffect(croppedImage); + using (Bitmap croppedImage = ImageHelpers.CropBitmap(bmp, rect)) + { + ApplyEffect(croppedImage); - g.DrawImage(croppedImage, rect); + g.DrawImage(croppedImage, rect); + } } } } diff --git a/ShareX.ScreenCaptureLib/Shapes/Effect/PixelateEffectShape.cs b/ShareX.ScreenCaptureLib/Shapes/Effect/PixelateEffectShape.cs index 0bf70535b..9edb6048d 100644 --- a/ShareX.ScreenCaptureLib/Shapes/Effect/PixelateEffectShape.cs +++ b/ShareX.ScreenCaptureLib/Shapes/Effect/PixelateEffectShape.cs @@ -77,14 +77,16 @@ public override void OnDrawFinal(Graphics g, Bitmap bmp) { if (PixelSize > 1) { - Rectangle rect = new Rectangle(0, 0, bmp.Width, bmp.Height); - rect.Intersect(Rectangle); + Rectangle rect = Rectangle.Intersect(new Rectangle(0, 0, bmp.Width, bmp.Height), Rectangle); - using (Bitmap croppedImage = ImageHelpers.CropBitmap(bmp, rect)) + if (!rect.IsEmpty) { - ApplyEffect(croppedImage); + using (Bitmap croppedImage = ImageHelpers.CropBitmap(bmp, rect)) + { + ApplyEffect(croppedImage); - g.DrawImage(croppedImage, rect); + g.DrawImage(croppedImage, rect); + } } } }