More fixes, the ClipboardDestination "should" now work again, mostly...

This commit is contained in:
Robin 2018-06-07 08:40:29 +02:00
commit 35ad8784f0
2 changed files with 29 additions and 8 deletions

View file

@ -152,16 +152,16 @@ EndSelection:<<<<<<<4
/// Place the bitmap as embedded HTML on the clipboard
/// </summary>
/// <param name="clipboardAccessToken">IClipboardAccessToken</param>
/// <param name="bitmap">Bitmap</param>
public static void SetAsEmbeddedHtml(this IClipboardAccessToken clipboardAccessToken, Bitmap bitmap)
/// <param name="surface">ISurface</param>
public static void SetAsEmbeddedHtml(this IClipboardAccessToken clipboardAccessToken, ISurface surface)
{
using (var pngStream = new MemoryStream())
{
var pngOutputSettings = new SurfaceOutputSettings(OutputFormats.png, 100, false);
ImageOutput.SaveToStream(bitmap, null, pngStream, pngOutputSettings);
ImageOutput.SaveToStream(surface, pngStream, pngOutputSettings);
pngStream.Seek(0, SeekOrigin.Begin);
// Set the PNG stream
var htmlText = GenerateHtmlDataUrlString(bitmap.Size, pngStream);
var htmlText = GenerateHtmlDataUrlString(new NativeSize(surface.Width, surface.Height), pngStream);
clipboardAccessToken.SetAsHtml(htmlText);
}
}

View file

@ -34,7 +34,6 @@ using Greenshot.Addons.Core.Enums;
using Greenshot.Addons.Extensions;
using Greenshot.Addons.Interfaces;
using Greenshot.Addons.Interfaces.Plugin;
using Greenshot.Configuration;
#endregion
@ -68,8 +67,30 @@ namespace Greenshot.Destinations
{
clipboardAccessToken.ClearContents();
//clipboardAccessToken.SetAsDeviceIndependendBitmap(surface);
foreach (var clipboardFormat in CoreConfiguration.ClipboardFormats)
{
switch (clipboardFormat)
{
case ClipboardFormats.DIB:
clipboardAccessToken.SetAsDeviceIndependendBitmap(surface);
break;
case ClipboardFormats.DIBV5:
clipboardAccessToken.SetAsFormat17(surface);
break;
case ClipboardFormats.PNG:
clipboardAccessToken.SetAsBitmap(surface, new SurfaceOutputSettings(OutputFormats.png));
break;
case ClipboardFormats.BITMAP:
clipboardAccessToken.SetAsBitmap(surface, new SurfaceOutputSettings(OutputFormats.bmp));
break;
case ClipboardFormats.HTML:
clipboardAccessToken.SetAsHtml(surface);
break;
case ClipboardFormats.HTMLDATAURL:
clipboardAccessToken.SetAsEmbeddedHtml(surface);
break;
}
}
}
exportInformation.ExportMade = true;
}