From eb0746821975c955c043a4aaf1cb70f244dfd103 Mon Sep 17 00:00:00 2001 From: RKrom Date: Mon, 22 Oct 2012 15:43:40 +0000 Subject: [PATCH] Changed "Image.Save" to ImageOutput.SaveToStream, this fixes problems with the transparency and also reduces the size if the colors are <256 git-svn-id: http://svn.code.sf.net/p/greenshot/code/trunk@2189 7dccd23d-a4a3-4e1f-8c07-b4c1b4018ab4 --- GreenshotInterop/OfficeExport/OneNoteExporter.cs | 5 ++++- GreenshotPlugin/Core/ClipboardHelper.cs | 7 +++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/GreenshotInterop/OfficeExport/OneNoteExporter.cs b/GreenshotInterop/OfficeExport/OneNoteExporter.cs index 51a99bdba..6a6f14e0e 100644 --- a/GreenshotInterop/OfficeExport/OneNoteExporter.cs +++ b/GreenshotInterop/OfficeExport/OneNoteExporter.cs @@ -28,6 +28,8 @@ using System.Xml; using System.IO; using System.Drawing; using System.Drawing.Imaging; +using Greenshot.Plugin; +using GreenshotPlugin.Core; namespace Greenshot.Interop.Office { public class OneNotePage { @@ -43,7 +45,8 @@ namespace Greenshot.Interop.Office { public static void ExportToPage(Bitmap imageToExport, OneNotePage page) { using (MemoryStream pngStream = new MemoryStream()) { - imageToExport.Save(pngStream, ImageFormat.Png); + OutputSettings pngOutputSettings = new OutputSettings(OutputFormat.png, 100, false); + ImageOutput.SaveToStream(imageToExport, pngStream, pngOutputSettings); string base64String = Convert.ToBase64String(pngStream.GetBuffer()); string imageXmlStr = string.Format(XML_IMAGE_CONTENT, base64String, imageToExport.Width, imageToExport.Height); string pageChangesXml = string.Format(XML_OUTLINE, new object[] { imageXmlStr, page.PageID, ONENOTE_NAMESPACE_2010, page.PageName }); diff --git a/GreenshotPlugin/Core/ClipboardHelper.cs b/GreenshotPlugin/Core/ClipboardHelper.cs index 09afb891f..dcb0ae935 100644 --- a/GreenshotPlugin/Core/ClipboardHelper.cs +++ b/GreenshotPlugin/Core/ClipboardHelper.cs @@ -355,7 +355,8 @@ EndSelection:<<<<<<<4 if (config.ClipboardFormats.Contains(ClipboardFormat.PNG) || config.ClipboardFormats.Contains(ClipboardFormat.HTMLDATAURL)) { pngStream = new MemoryStream(); // PNG works for Powerpoint - image.Save(pngStream, ImageFormat.Png); + OutputSettings pngOutputSettings = new OutputSettings(OutputFormat.png, 100, false); + ImageOutput.SaveToStream(image, pngStream, pngOutputSettings); pngStream.Seek(0, SeekOrigin.Begin); } @@ -367,7 +368,9 @@ EndSelection:<<<<<<<4 if (config.ClipboardFormats.Contains(ClipboardFormat.DIB)) { bmpStream = new MemoryStream(); // Save image as BMP - image.Save(bmpStream, ImageFormat.Bmp); + OutputSettings bmpOutputSettings = new OutputSettings(OutputFormat.bmp, 100, false); + ImageOutput.SaveToStream(image, bmpStream, bmpOutputSettings); + imageStream = new MemoryStream(); // Copy the source, but skip the "BITMAPFILEHEADER" which has a size of 14 imageStream.Write(bmpStream.GetBuffer(), BITMAPFILEHEADER_LENGTH, (int) bmpStream.Length - BITMAPFILEHEADER_LENGTH);