From 89ae9489d23d42d7b4ed85081150081fee5e216b Mon Sep 17 00:00:00 2001 From: Robin Date: Mon, 16 Jan 2017 17:06:50 +0100 Subject: [PATCH] BUG-2056: A better fix for the issue, there was already something build in. [skip ci] --- .../ExternalCommandDestination.cs | 8 +------- GreenshotPlugin/Core/ImageOutput.cs | 2 +- GreenshotPlugin/Interfaces/Plugin/PluginInterfaces.cs | 11 +++++++++-- GreenshotWin10Plugin/Win10ShareDestination.cs | 9 ++++++--- 4 files changed, 17 insertions(+), 13 deletions(-) diff --git a/GreenshotExternalCommandPlugin/ExternalCommandDestination.cs b/GreenshotExternalCommandPlugin/ExternalCommandDestination.cs index a262bd86e..93c0e8096 100644 --- a/GreenshotExternalCommandPlugin/ExternalCommandDestination.cs +++ b/GreenshotExternalCommandPlugin/ExternalCommandDestination.cs @@ -56,14 +56,8 @@ namespace ExternalCommand { public override ExportInformation ExportCapture(bool manuallyInitiated, ISurface surface, ICaptureDetails captureDetails) { ExportInformation exportInformation = new ExportInformation(Designation, Description); SurfaceOutputSettings outputSettings = new SurfaceOutputSettings(); + outputSettings.PreventGreenshotFormat(); - // BUG-2056 reported a logical issue, using greenshot format as the default causes issues with the external commands. - // If OutputFormat is Greenshot, use PNG instead. - if (outputSettings.Format == OutputFormat.greenshot) - { - outputSettings.Format = OutputFormat.png; - } - if (_presetCommand != null) { if (!config.RunInbackground.ContainsKey(_presetCommand)) { config.RunInbackground.Add(_presetCommand, true); diff --git a/GreenshotPlugin/Core/ImageOutput.cs b/GreenshotPlugin/Core/ImageOutput.cs index 7a2e40f37..cbd4cec9b 100644 --- a/GreenshotPlugin/Core/ImageOutput.cs +++ b/GreenshotPlugin/Core/ImageOutput.cs @@ -105,7 +105,7 @@ namespace GreenshotPlugin.Core { bool useMemoryStream = false; MemoryStream memoryStream = null; if (outputSettings.Format == OutputFormat.greenshot && surface == null) { - throw new ArgumentException("Surface needs to be se when using OutputFormat.Greenshot"); + throw new ArgumentException("Surface needs to be set when using OutputFormat.Greenshot"); } try { diff --git a/GreenshotPlugin/Interfaces/Plugin/PluginInterfaces.cs b/GreenshotPlugin/Interfaces/Plugin/PluginInterfaces.cs index 63ad027cb..4eb8c918d 100644 --- a/GreenshotPlugin/Interfaces/Plugin/PluginInterfaces.cs +++ b/GreenshotPlugin/Interfaces/Plugin/PluginInterfaces.cs @@ -98,8 +98,15 @@ namespace Greenshot.Plugin { ReduceColors = reduceColors; } - public SurfaceOutputSettings PreventGreenshotFormat() { - if (Format == OutputFormat.greenshot) { + /// + /// BUG-2056 reported a logical issue, using greenshot format as the default causes issues with the external commands. + /// + /// this for fluent API usage + public SurfaceOutputSettings PreventGreenshotFormat() + { + // If OutputFormat is Greenshot, use PNG instead. + if (Format == OutputFormat.greenshot) + { Format = OutputFormat.png; } return this; diff --git a/GreenshotWin10Plugin/Win10ShareDestination.cs b/GreenshotWin10Plugin/Win10ShareDestination.cs index 780f568cd..8933b9b7a 100644 --- a/GreenshotWin10Plugin/Win10ShareDestination.cs +++ b/GreenshotWin10Plugin/Win10ShareDestination.cs @@ -70,8 +70,11 @@ namespace GreenshotWin10Plugin using (var logoStream = new MemoryRandomAccessStream()) using (var thumbnailStream = new MemoryRandomAccessStream()) { + var outputSettings = new SurfaceOutputSettings(); + outputSettings.PreventGreenshotFormat(); + // Create capture for export - ImageOutput.SaveToStream(surface, imageStream, new SurfaceOutputSettings()); + ImageOutput.SaveToStream(surface, imageStream, outputSettings); imageStream.Position = 0; Log.Info("Created RandomAccessStreamReference for the image"); var imageRandomAccessStreamReference = RandomAccessStreamReference.CreateFromStream(imageStream); @@ -83,7 +86,7 @@ namespace GreenshotWin10Plugin { using (var thumbnail = ImageHelper.CreateThumbnail(tmpImageForThumbnail, 240, 160)) { - ImageOutput.SaveToStream(thumbnail, null, thumbnailStream, new SurfaceOutputSettings()); + ImageOutput.SaveToStream(thumbnail, null, thumbnailStream, outputSettings); thumbnailStream.Position = 0; thumbnailRandomAccessStreamReference = RandomAccessStreamReference.CreateFromStream(thumbnailStream); Log.Info("Created RandomAccessStreamReference for the thumbnail"); @@ -94,7 +97,7 @@ namespace GreenshotWin10Plugin { using (var logoThumbnail = ImageHelper.CreateThumbnail(logo, 30, 30)) { - ImageOutput.SaveToStream(logoThumbnail, null, logoStream, new SurfaceOutputSettings()); + ImageOutput.SaveToStream(logoThumbnail, null, logoStream, outputSettings); logoStream.Position = 0; logoRandomAccessStreamReference = RandomAccessStreamReference.CreateFromStream(logoStream); Log.Info("Created RandomAccessStreamReference for the logo");