mirror of
https://github.com/greenshot/greenshot
synced 2025-08-20 13:33:27 -07:00
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
This commit is contained in:
parent
7b8575f2a0
commit
eb07468219
2 changed files with 9 additions and 3 deletions
|
@ -28,6 +28,8 @@ using System.Xml;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using System.Drawing.Imaging;
|
using System.Drawing.Imaging;
|
||||||
|
using Greenshot.Plugin;
|
||||||
|
using GreenshotPlugin.Core;
|
||||||
|
|
||||||
namespace Greenshot.Interop.Office {
|
namespace Greenshot.Interop.Office {
|
||||||
public class OneNotePage {
|
public class OneNotePage {
|
||||||
|
@ -43,7 +45,8 @@ namespace Greenshot.Interop.Office {
|
||||||
|
|
||||||
public static void ExportToPage(Bitmap imageToExport, OneNotePage page) {
|
public static void ExportToPage(Bitmap imageToExport, OneNotePage page) {
|
||||||
using (MemoryStream pngStream = new MemoryStream()) {
|
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 base64String = Convert.ToBase64String(pngStream.GetBuffer());
|
||||||
string imageXmlStr = string.Format(XML_IMAGE_CONTENT, base64String, imageToExport.Width, imageToExport.Height);
|
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 });
|
string pageChangesXml = string.Format(XML_OUTLINE, new object[] { imageXmlStr, page.PageID, ONENOTE_NAMESPACE_2010, page.PageName });
|
||||||
|
|
|
@ -355,7 +355,8 @@ EndSelection:<<<<<<<4
|
||||||
if (config.ClipboardFormats.Contains(ClipboardFormat.PNG) || config.ClipboardFormats.Contains(ClipboardFormat.HTMLDATAURL)) {
|
if (config.ClipboardFormats.Contains(ClipboardFormat.PNG) || config.ClipboardFormats.Contains(ClipboardFormat.HTMLDATAURL)) {
|
||||||
pngStream = new MemoryStream();
|
pngStream = new MemoryStream();
|
||||||
// PNG works for Powerpoint
|
// 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);
|
pngStream.Seek(0, SeekOrigin.Begin);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -367,7 +368,9 @@ EndSelection:<<<<<<<4
|
||||||
if (config.ClipboardFormats.Contains(ClipboardFormat.DIB)) {
|
if (config.ClipboardFormats.Contains(ClipboardFormat.DIB)) {
|
||||||
bmpStream = new MemoryStream();
|
bmpStream = new MemoryStream();
|
||||||
// Save image as BMP
|
// 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();
|
imageStream = new MemoryStream();
|
||||||
// Copy the source, but skip the "BITMAPFILEHEADER" which has a size of 14
|
// Copy the source, but skip the "BITMAPFILEHEADER" which has a size of 14
|
||||||
imageStream.Write(bmpStream.GetBuffer(), BITMAPFILEHEADER_LENGTH, (int) bmpStream.Length - BITMAPFILEHEADER_LENGTH);
|
imageStream.Write(bmpStream.GetBuffer(), BITMAPFILEHEADER_LENGTH, (int) bmpStream.Length - BITMAPFILEHEADER_LENGTH);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue