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); + } } } }