diff --git a/Greenshot/Drawing/SpeechbubbleContainer.cs b/Greenshot/Drawing/SpeechbubbleContainer.cs index d157d1eee..197c93223 100644 --- a/Greenshot/Drawing/SpeechbubbleContainer.cs +++ b/Greenshot/Drawing/SpeechbubbleContainer.cs @@ -148,9 +148,10 @@ namespace Greenshot.Drawing { state = graphics.Save(); // Draw bubble where the Tail is not visible. using (Region clipRegion = new Region(tail)) { - Matrix transformMatrix = new Matrix(); - transformMatrix.Rotate(tailAngle); - clipRegion.Transform(transformMatrix); + using (Matrix transformMatrix = new Matrix()) { + transformMatrix.Rotate(tailAngle); + clipRegion.Transform(transformMatrix); + } clipRegion.Translate(rect.Left + (rect.Width / 2), rect.Top + (rect.Height / 2)); graphics.SetClip(clipRegion, CombineMode.Exclude); graphics.TranslateTransform(rect.Left, rect.Top); diff --git a/Greenshot/Drawing/Surface.cs b/Greenshot/Drawing/Surface.cs index 338a918d1..b3f7c9fd2 100644 --- a/Greenshot/Drawing/Surface.cs +++ b/Greenshot/Drawing/Surface.cs @@ -879,6 +879,9 @@ namespace Greenshot.Drawing { if (_surfaceSizeChanged != null && !imageRectangle.Equals(new Rectangle(Point.Empty, newImage.Size))) { _surfaceSizeChanged(this, null); } + } else { + // clean up matrix, as it hasn't been used in the undo stack. + matrix.Dispose(); } } finally { // Always close the background form diff --git a/GreenshotPlugin/Core/ImageOutput.cs b/GreenshotPlugin/Core/ImageOutput.cs index ba54b560d..d4a8deb14 100644 --- a/GreenshotPlugin/Core/ImageOutput.cs +++ b/GreenshotPlugin/Core/ImageOutput.cs @@ -303,7 +303,9 @@ namespace GreenshotPlugin.Core { Image tmpImage; if (outputSettings.Effects != null && outputSettings.Effects.Count > 0) { // apply effects, if there are any - tmpImage = ImageHelper.ApplyEffects(imageToSave, outputSettings.Effects, new Matrix()); + using (Matrix matrix = new Matrix()) { + tmpImage = ImageHelper.ApplyEffects(imageToSave, outputSettings.Effects, matrix); + } if (tmpImage != null) { if (disposeImage) { imageToSave.Dispose();