mirror of
https://github.com/greenshot/greenshot
synced 2025-08-19 13:10:00 -07:00
Fixed bug #3594681, do not use 256-color reducing when using inline dataurl for HTML.
git-svn-id: http://svn.code.sf.net/p/greenshot/code/trunk@2388 7dccd23d-a4a3-4e1f-8c07-b4c1b4018ab4
This commit is contained in:
parent
a57fa7086f
commit
cd3c8aeb0b
3 changed files with 37 additions and 15 deletions
|
@ -385,15 +385,12 @@ EndSelection:<<<<<<<4
|
||||||
MemoryStream pngStream = null;
|
MemoryStream pngStream = null;
|
||||||
try {
|
try {
|
||||||
// Create PNG stream
|
// Create PNG stream
|
||||||
if (config.ClipboardFormats.Contains(ClipboardFormat.PNG) || config.ClipboardFormats.Contains(ClipboardFormat.HTMLDATAURL)) {
|
if (config.ClipboardFormats.Contains(ClipboardFormat.PNG)) {
|
||||||
pngStream = new MemoryStream();
|
pngStream = new MemoryStream();
|
||||||
// PNG works for Powerpoint
|
// PNG works for e.g. Powerpoint
|
||||||
SurfaceOutputSettings pngOutputSettings = new SurfaceOutputSettings(OutputFormat.png, 100, false);
|
SurfaceOutputSettings pngOutputSettings = new SurfaceOutputSettings(OutputFormat.png, 100, false);
|
||||||
ImageOutput.SaveToStream(surface, pngStream, pngOutputSettings);
|
ImageOutput.SaveToStream(surface, pngStream, pngOutputSettings);
|
||||||
pngStream.Seek(0, SeekOrigin.Begin);
|
pngStream.Seek(0, SeekOrigin.Begin);
|
||||||
}
|
|
||||||
|
|
||||||
if (config.ClipboardFormats.Contains(ClipboardFormat.PNG)) {
|
|
||||||
// Set the PNG stream
|
// Set the PNG stream
|
||||||
ido.SetData("PNG", false, pngStream);
|
ido.SetData("PNG", false, pngStream);
|
||||||
}
|
}
|
||||||
|
@ -414,11 +411,19 @@ EndSelection:<<<<<<<4
|
||||||
|
|
||||||
// Set the HTML
|
// Set the HTML
|
||||||
if (config.ClipboardFormats.Contains(ClipboardFormat.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);
|
string html = getHTMLString(surface, tmpFile);
|
||||||
ido.SetText(html, TextDataFormat.Html);
|
ido.SetText(html, TextDataFormat.Html);
|
||||||
} else if (config.ClipboardFormats.Contains(ClipboardFormat.HTMLDATAURL)) {
|
} 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);
|
ido.SetText(html, TextDataFormat.Html);
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
|
|
|
@ -147,8 +147,8 @@ namespace GreenshotPlugin.Core {
|
||||||
imageToSave = nonAlphaImage;
|
imageToSave = nonAlphaImage;
|
||||||
}
|
}
|
||||||
|
|
||||||
// check for color reduction, forced or automatically
|
// check for color reduction, forced or automatically, only when the DisableReduceColors is false
|
||||||
if (conf.OutputFileAutoReduceColors || outputSettings.ReduceColors) {
|
if (!outputSettings.DisableReduceColors && (conf.OutputFileAutoReduceColors || outputSettings.ReduceColors)) {
|
||||||
WuQuantizer quantizer = new WuQuantizer((Bitmap)imageToSave);
|
WuQuantizer quantizer = new WuQuantizer((Bitmap)imageToSave);
|
||||||
int colorCount = quantizer.GetColorCount();
|
int colorCount = quantizer.GetColorCount();
|
||||||
LOG.InfoFormat("Image with format {0} has {1} colors", imageToSave.PixelFormat, colorCount);
|
LOG.InfoFormat("Image with format {0} has {1} colors", imageToSave.PixelFormat, colorCount);
|
||||||
|
|
|
@ -78,9 +78,11 @@ namespace Greenshot.Plugin {
|
||||||
public class SurfaceOutputSettings {
|
public class SurfaceOutputSettings {
|
||||||
private static CoreConfiguration conf = IniConfig.GetIniSection<CoreConfiguration>();
|
private static CoreConfiguration conf = IniConfig.GetIniSection<CoreConfiguration>();
|
||||||
private bool reduceColors;
|
private bool reduceColors;
|
||||||
|
private bool disableReduceColors;
|
||||||
private List<IEffect> effects = new List<IEffect>();
|
private List<IEffect> effects = new List<IEffect>();
|
||||||
|
|
||||||
public SurfaceOutputSettings() {
|
public SurfaceOutputSettings() {
|
||||||
|
disableReduceColors = false;
|
||||||
Format = conf.OutputFileFormat;
|
Format = conf.OutputFileFormat;
|
||||||
JPGQuality = conf.OutputFileJpegQuality;
|
JPGQuality = conf.OutputFileJpegQuality;
|
||||||
ReduceColors = conf.OutputFileReduceColors;
|
ReduceColors = conf.OutputFileReduceColors;
|
||||||
|
@ -131,6 +133,21 @@ namespace Greenshot.Plugin {
|
||||||
reduceColors = value;
|
reduceColors = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Disable the reduce colors option, this overrules the enabling
|
||||||
|
/// </summary>
|
||||||
|
public bool DisableReduceColors {
|
||||||
|
get {
|
||||||
|
return disableReduceColors;
|
||||||
|
}
|
||||||
|
set {
|
||||||
|
// Quantizing os needed when output format is gif as this has only 256 colors!
|
||||||
|
if (!OutputFormat.gif.Equals(Format)) {
|
||||||
|
disableReduceColors = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue