diff --git a/GreenshotPlugin/Core/ClipboardHelper.cs b/GreenshotPlugin/Core/ClipboardHelper.cs index e79d5b942..7a1777d7f 100644 --- a/GreenshotPlugin/Core/ClipboardHelper.cs +++ b/GreenshotPlugin/Core/ClipboardHelper.cs @@ -385,15 +385,12 @@ EndSelection:<<<<<<<4 MemoryStream pngStream = null; try { // Create PNG stream - if (config.ClipboardFormats.Contains(ClipboardFormat.PNG) || config.ClipboardFormats.Contains(ClipboardFormat.HTMLDATAURL)) { + if (config.ClipboardFormats.Contains(ClipboardFormat.PNG)) { pngStream = new MemoryStream(); - // PNG works for Powerpoint + // PNG works for e.g. Powerpoint SurfaceOutputSettings pngOutputSettings = new SurfaceOutputSettings(OutputFormat.png, 100, false); ImageOutput.SaveToStream(surface, pngStream, pngOutputSettings); pngStream.Seek(0, SeekOrigin.Begin); - } - - if (config.ClipboardFormats.Contains(ClipboardFormat.PNG)) { // Set the PNG stream ido.SetData("PNG", false, pngStream); } @@ -414,11 +411,19 @@ EndSelection:<<<<<<<4 // Set the HTML if (config.ClipboardFormats.Contains(ClipboardFormat.HTML)) { - string tmpFile = ImageOutput.SaveToTmpFile(surface, new SurfaceOutputSettings(OutputFormat.png), null); + string tmpFile = ImageOutput.SaveToTmpFile(surface, new SurfaceOutputSettings(OutputFormat.png, 100, false), null); string html = getHTMLString(surface, tmpFile); ido.SetText(html, TextDataFormat.Html); } else if (config.ClipboardFormats.Contains(ClipboardFormat.HTMLDATAURL)) { - string html = getHTMLDataURLString(surface, pngStream); + string html; + using (MemoryStream tmpPNGStream = new MemoryStream()) { + SurfaceOutputSettings pngOutputSettings = new SurfaceOutputSettings(OutputFormat.png, 100, false); + // Do not allow to reduce the colors, some applications dislike 256 color images + // reported with bug #3594681 + pngOutputSettings.DisableReduceColors = true; + ImageOutput.SaveToStream(surface, tmpPNGStream, pngOutputSettings); + html = getHTMLDataURLString(surface, tmpPNGStream); + } ido.SetText(html, TextDataFormat.Html); } } finally { diff --git a/GreenshotPlugin/Core/ImageOutput.cs b/GreenshotPlugin/Core/ImageOutput.cs index dcbd3bc5a..f964caba8 100644 --- a/GreenshotPlugin/Core/ImageOutput.cs +++ b/GreenshotPlugin/Core/ImageOutput.cs @@ -147,8 +147,8 @@ namespace GreenshotPlugin.Core { imageToSave = nonAlphaImage; } - // check for color reduction, forced or automatically - if (conf.OutputFileAutoReduceColors || outputSettings.ReduceColors) { + // check for color reduction, forced or automatically, only when the DisableReduceColors is false + if (!outputSettings.DisableReduceColors && (conf.OutputFileAutoReduceColors || outputSettings.ReduceColors)) { WuQuantizer quantizer = new WuQuantizer((Bitmap)imageToSave); int colorCount = quantizer.GetColorCount(); LOG.InfoFormat("Image with format {0} has {1} colors", imageToSave.PixelFormat, colorCount); diff --git a/GreenshotPlugin/Interfaces/Plugin/PluginInterfaces.cs b/GreenshotPlugin/Interfaces/Plugin/PluginInterfaces.cs index d6c9d7e91..c1dc9d1ec 100644 --- a/GreenshotPlugin/Interfaces/Plugin/PluginInterfaces.cs +++ b/GreenshotPlugin/Interfaces/Plugin/PluginInterfaces.cs @@ -78,9 +78,11 @@ namespace Greenshot.Plugin { public class SurfaceOutputSettings { private static CoreConfiguration conf = IniConfig.GetIniSection(); private bool reduceColors; + private bool disableReduceColors; private List effects = new List(); public SurfaceOutputSettings() { + disableReduceColors = false; Format = conf.OutputFileFormat; JPGQuality = conf.OutputFileJpegQuality; ReduceColors = conf.OutputFileReduceColors; @@ -120,15 +122,30 @@ namespace Greenshot.Plugin { } public bool ReduceColors { - get { - // Fix for Bug #3468436, force quantizing when output format is gif as this has only 256 colors! - if (OutputFormat.gif.Equals(Format)) { - return true; + get { + // Fix for Bug #3468436, force quantizing when output format is gif as this has only 256 colors! + if (OutputFormat.gif.Equals(Format)) { + return true; + } + return reduceColors; } - return reduceColors; + set { + reduceColors = value; + } + } + + /// + /// Disable the reduce colors option, this overrules the enabling + /// + public bool DisableReduceColors { + get { + return disableReduceColors; } set { - reduceColors = value; + // Quantizing os needed when output format is gif as this has only 256 colors! + if (!OutputFormat.gif.Equals(Format)) { + disableReduceColors = value; + } } } }