diff --git a/GreenshotPlugin/Controls/GreenshotForm.cs b/GreenshotPlugin/Controls/GreenshotForm.cs index 2fb0b2095..cde1d310b 100644 --- a/GreenshotPlugin/Controls/GreenshotForm.cs +++ b/GreenshotPlugin/Controls/GreenshotForm.cs @@ -128,6 +128,7 @@ namespace GreenshotPlugin.Controls { /// Store all GreenshotControl values to the configuration /// protected void StoreFields() { + bool iniDirty = false; foreach (FieldInfo field in this.GetType().GetFields(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance)) { if (!field.FieldType.IsSubclassOf(typeof(Control))) { continue; @@ -137,7 +138,6 @@ namespace GreenshotPlugin.Controls { } Object controlObject = field.GetValue(this); IGreenshotConfigBindable configBindable = controlObject as IGreenshotConfigBindable; - bool iniDirty = false; if (!string.IsNullOrEmpty(configBindable.SectionName) && !string.IsNullOrEmpty(configBindable.PropertyName)) { IniSection section = IniConfig.GetIniSection(configBindable.SectionName); @@ -160,9 +160,9 @@ namespace GreenshotPlugin.Controls { } } } - if (iniDirty) { - IniConfig.Save(); - } + } + if (iniDirty) { + IniConfig.Save(); } } } diff --git a/GreenshotPlugin/Core/ImageHelper.cs b/GreenshotPlugin/Core/ImageHelper.cs index bed26efe1..e170bd60e 100644 --- a/GreenshotPlugin/Core/ImageHelper.cs +++ b/GreenshotPlugin/Core/ImageHelper.cs @@ -1066,16 +1066,29 @@ namespace GreenshotPlugin.Core { return newBitmap; } + /// + /// Wrapper for the more complex Resize, this resize could be used for e.g. Thumbnails + /// + /// + /// true to maintain the aspect ratio + /// + /// + /// + public static Bitmap ResizeBitmap(Bitmap sourceBitmap, bool maintainAspectRatio, int newWidth, int newHeight) { + Point throwAway; + return ResizeBitmap(sourceBitmap, maintainAspectRatio, false, Color.Empty, newWidth, newHeight, out throwAway); + } + /// /// Scale the bitmap, keeping aspect ratio, but the canvas will always have the specified size. /// /// Bitmap to scale - /// true to lock aspect ratio + /// true to maintain the aspect ratio /// The color to fill with, or Color.Empty to take the default depending on the pixel format /// new width /// new height /// a new bitmap with the specified size, the source-bitmap scaled to fit with aspect ratio locked - public static Bitmap ResizeBitmap(Bitmap sourceBitmap, bool lockAspectRatio, bool canvasUseNewSize, Color backgroundColor, int newWidth, int newHeight, out Point offset) { + public static Bitmap ResizeBitmap(Bitmap sourceBitmap, bool maintainAspectRatio, bool canvasUseNewSize, Color backgroundColor, int newWidth, int newHeight, out Point offset) { int destX = 0; int destY = 0; @@ -1084,7 +1097,7 @@ namespace GreenshotPlugin.Core { nPercentW = ((float)newWidth / (float)sourceBitmap.Width); nPercentH = ((float)newHeight / (float)sourceBitmap.Height); - if (lockAspectRatio) { + if (maintainAspectRatio) { if (nPercentH != 0 && nPercentH < nPercentW) { nPercentW = nPercentH; if (canvasUseNewSize) { @@ -1109,7 +1122,7 @@ namespace GreenshotPlugin.Core { newHeight = destHeight; } Bitmap newBitmap = null; - if (lockAspectRatio && canvasUseNewSize) { + if (maintainAspectRatio && canvasUseNewSize) { newBitmap = CreateEmpty(newWidth, newHeight, sourceBitmap.PixelFormat, backgroundColor, sourceBitmap.HorizontalResolution, sourceBitmap.VerticalResolution); } else { newBitmap = CreateEmpty(destWidth, destHeight, sourceBitmap.PixelFormat, backgroundColor, sourceBitmap.HorizontalResolution, sourceBitmap.VerticalResolution); diff --git a/GreenshotPlugin/IniFile/IniConfig.cs b/GreenshotPlugin/IniFile/IniConfig.cs index 5a524cfd3..261eac567 100644 --- a/GreenshotPlugin/IniFile/IniConfig.cs +++ b/GreenshotPlugin/IniFile/IniConfig.cs @@ -338,7 +338,7 @@ namespace Greenshot.IniFile { private static void SaveInternally(string iniLocation) { WatchConfigFile(false); - //LOG.Info("Saving configuration to: " + iniLocation); + LOG.Info("Saving configuration to: " + iniLocation); if (!Directory.Exists(Path.GetDirectoryName(iniLocation))) { Directory.CreateDirectory(Path.GetDirectoryName(iniLocation)); }