mirror of
https://github.com/greenshot/greenshot
synced 2025-08-20 21:43:24 -07:00
Fixed transparency issue: it wasn't removed before storing images without transparency support.
git-svn-id: http://svn.code.sf.net/p/greenshot/code/trunk@1760 7dccd23d-a4a3-4e1f-8c07-b4c1b4018ab4
This commit is contained in:
parent
bfd6cc902e
commit
abad0a2166
1 changed files with 12 additions and 2 deletions
|
@ -105,6 +105,12 @@ namespace Greenshot.Helpers {
|
||||||
reduceColors = true;
|
reduceColors = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Removing transparency if it's not supported
|
||||||
|
if (imageFormat != ImageFormat.Png) {
|
||||||
|
imageToSave = ImageHelper.Clone(imageToSave, PixelFormat.Format24bppRgb);
|
||||||
|
disposeImage = true;
|
||||||
|
}
|
||||||
|
|
||||||
// check for color reduction, forced or automatically
|
// check for color reduction, forced or automatically
|
||||||
if (conf.OutputFileAutoReduceColors || reduceColors) {
|
if (conf.OutputFileAutoReduceColors || reduceColors) {
|
||||||
WuQuantizer quantizer = new WuQuantizer((Bitmap)imageToSave);
|
WuQuantizer quantizer = new WuQuantizer((Bitmap)imageToSave);
|
||||||
|
@ -113,7 +119,11 @@ namespace Greenshot.Helpers {
|
||||||
if (reduceColors || colorCount < 256) {
|
if (reduceColors || colorCount < 256) {
|
||||||
try {
|
try {
|
||||||
LOG.Info("Reducing colors on bitmap to 255.");
|
LOG.Info("Reducing colors on bitmap to 255.");
|
||||||
imageToSave = quantizer.GetQuantizedImage(255);
|
Image tmpImage = quantizer.GetQuantizedImage(255);
|
||||||
|
if (disposeImage) {
|
||||||
|
imageToSave.Dispose();
|
||||||
|
}
|
||||||
|
imageToSave = tmpImage;
|
||||||
// Make sure the "new" image is disposed
|
// Make sure the "new" image is disposed
|
||||||
disposeImage = true;
|
disposeImage = true;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
@ -134,7 +144,7 @@ namespace Greenshot.Helpers {
|
||||||
LOG.WarnFormat("Image of type {0} do not support property {1}", imageFormat, softwareUsedPropertyItem.Id);
|
LOG.WarnFormat("Image of type {0} do not support property {1}", imageFormat, softwareUsedPropertyItem.Id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
LOG.DebugFormat("Saving image to stream with PixelFormat {0}", imageToSave.PixelFormat);
|
LOG.DebugFormat("Saving image to stream with Format {0} and PixelFormat {1}", imageFormat, imageToSave.PixelFormat);
|
||||||
if (imageFormat == ImageFormat.Jpeg) {
|
if (imageFormat == ImageFormat.Jpeg) {
|
||||||
EncoderParameters parameters = new EncoderParameters(1);
|
EncoderParameters parameters = new EncoderParameters(1);
|
||||||
parameters.Param[0] = new System.Drawing.Imaging.EncoderParameter(Encoder.Quality, quality);
|
parameters.Param[0] = new System.Drawing.Imaging.EncoderParameter(Encoder.Quality, quality);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue