Disposing matrix in the new code, otherwise it would cause memory leaks

This commit is contained in:
RKrom 2014-06-02 10:25:47 +02:00
parent 4d6bf9f1ad
commit 4b8ec88aaf
3 changed files with 10 additions and 4 deletions

View file

@ -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);

View file

@ -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

View file

@ -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();