From d3246b43683db95f98899c674adfaf760d06ec51 Mon Sep 17 00:00:00 2001 From: RKrom Date: Tue, 20 Mar 2012 17:04:41 +0000 Subject: [PATCH] Added auto reduction test as a property, so we can turn it off if the results are contra productive. Updated the readme.txt git-svn-id: http://svn.code.sf.net/p/greenshot/code/trunk@1714 7dccd23d-a4a3-4e1f-8c07-b4c1b4018ab4 --- Greenshot/Helpers/ImageOutput.cs | 28 +++++++++++-------- .../releases/additional_files/readme.txt | 4 +-- GreenshotPlugin/Core/CoreConfiguration.cs | 2 ++ 3 files changed, 20 insertions(+), 14 deletions(-) diff --git a/Greenshot/Helpers/ImageOutput.cs b/Greenshot/Helpers/ImageOutput.cs index a153ea201..262218afc 100644 --- a/Greenshot/Helpers/ImageOutput.cs +++ b/Greenshot/Helpers/ImageOutput.cs @@ -100,19 +100,23 @@ namespace Greenshot.Helpers { break; } - // If Quantizing is enable, overwrite the image to save with a 256 - color version - IColorQuantizer quantizer = ImageHelper.PrepareQuantize((Bitmap)imageToSave); - int colorCount = quantizer.GetColorCount(); - LOG.InfoFormat("Image with format {0} has {1} colors", imageToSave.PixelFormat, colorCount); - if (reduceColors || colorCount < 256) { - try { - LOG.Info("Reducing colors on bitmap to 255."); - imageToSave = ImageHelper.Quantize((Bitmap)imageToSave, quantizer, 255); - // Make sure the "new" image is disposed - disposeImage = true; - } catch(Exception e) { - LOG.Warn("Error occurred while Quantizing the image, ignoring and using original. Error: ", e); + // check for color reduction, forced or automatically + if (conf.OutputFileAutoReduceColors || reduceColors) { + IColorQuantizer quantizer = ImageHelper.PrepareQuantize((Bitmap)imageToSave); + int colorCount = quantizer.GetColorCount(); + LOG.InfoFormat("Image with format {0} has {1} colors", imageToSave.PixelFormat, colorCount); + if (reduceColors || colorCount < 256) { + try { + LOG.Info("Reducing colors on bitmap to 255."); + imageToSave = ImageHelper.Quantize((Bitmap)imageToSave, quantizer, 255); + // Make sure the "new" image is disposed + disposeImage = true; + } catch (Exception e) { + LOG.Warn("Error occurred while Quantizing the image, ignoring and using original. Error: ", e); + } } + } else { + LOG.Info("Skipping color reduction test, OutputFileAutoReduceColors is set to false."); } try { diff --git a/Greenshot/releases/additional_files/readme.txt b/Greenshot/releases/additional_files/readme.txt index 1f3509da4..54555fb7f 100644 --- a/Greenshot/releases/additional_files/readme.txt +++ b/Greenshot/releases/additional_files/readme.txt @@ -3,7 +3,7 @@ Greenshot: A screenshot tool optimized for productivity. Save a screenshot or a CHANGE LOG: -0.9.0 Build 1667 +0.9.0 Build 1714 We changed the version to 0.9.0 as the amount of features in 0.8.1 was more than planned. @@ -25,7 +25,7 @@ Features added: * Added Ctrl/shift logic to the editor, hard to explain (see help) but hold one of the keys down and draw.. * Added a color picker in the color dialog. * Added shadow & torn edges - +* Added color reduction as an option and auto detection for image with less than 256 color. When using reduction this results in smaller files. 0.8.1 Build 1483 diff --git a/GreenshotPlugin/Core/CoreConfiguration.cs b/GreenshotPlugin/Core/CoreConfiguration.cs index bd1f31397..8d5c50e3a 100644 --- a/GreenshotPlugin/Core/CoreConfiguration.cs +++ b/GreenshotPlugin/Core/CoreConfiguration.cs @@ -92,6 +92,8 @@ namespace GreenshotPlugin.Core { public OutputFormat OutputFileFormat = OutputFormat.png; [IniProperty("OutputFileReduceColors", Description="If set to true, than the colors of the output file are reduced to 256 (8-bit) colors", DefaultValue="false")] public bool OutputFileReduceColors; + [IniProperty("OutputFileAutoReduceColors", Description = "If set to true the amount of colors is counted and if smaller than 256 the color reduction is automatically used.", DefaultValue = "true")] + public bool OutputFileAutoReduceColors; [IniProperty("OutlookEmailFormat", Description = "Default type for emails. (Text, HTML)", DefaultValue="HTML")] public EmailFormat OutlookEmailFormat;