diff --git a/azure-pipelines.yml b/azure-pipelines.yml
index 2584b4532..5b0720d5d 100644
--- a/azure-pipelines.yml
+++ b/azure-pipelines.yml
@@ -15,7 +15,7 @@ steps:
- task: DotNetCoreInstaller@0
displayName: 'Install .NET Core SDK 3.0'
inputs:
- version: '3.0.100-preview6-011809'
+ version: '3.0.100-preview6-012067'
- task: NuGetToolInstaller@0
displayName: 'Use NuGet 5.0.0'
diff --git a/src/Directory.Build.props b/src/Directory.Build.props
index eff42226b..b94870959 100644
--- a/src/Directory.Build.props
+++ b/src/Directory.Build.props
@@ -54,7 +54,7 @@
-
+
all
runtime; build; native; contentfiles; analyzers
diff --git a/src/Greenshot.Addon.ExternalCommand/Greenshot.Addon.ExternalCommand.csproj b/src/Greenshot.Addon.ExternalCommand/Greenshot.Addon.ExternalCommand.csproj
index 0af14dff1..96b8a89e0 100644
--- a/src/Greenshot.Addon.ExternalCommand/Greenshot.Addon.ExternalCommand.csproj
+++ b/src/Greenshot.Addon.ExternalCommand/Greenshot.Addon.ExternalCommand.csproj
@@ -24,7 +24,7 @@
-
+
all
runtime; build; native; contentfiles; analyzers
diff --git a/src/Greenshot.Addons/AddonsModule.cs b/src/Greenshot.Addons/AddonsModule.cs
index f6d88b465..c87a37824 100644
--- a/src/Greenshot.Addons/AddonsModule.cs
+++ b/src/Greenshot.Addons/AddonsModule.cs
@@ -105,7 +105,7 @@ namespace Greenshot.Addons
.AutoActivate()
.OnActivated(args =>
{
- BitmapHelper.StreamConverters["greenshot"] = args.Instance;
+ BitmapHelper.RegisterFormatReader(args.Instance);
});
base.Load(builder);
diff --git a/src/Greenshot.Core/Extensions/InteropWindowCaptureExtensions.cs b/src/Greenshot.Core/Extensions/InteropWindowCaptureExtensions.cs
index cbd2e2914..3508a0fef 100644
--- a/src/Greenshot.Core/Extensions/InteropWindowCaptureExtensions.cs
+++ b/src/Greenshot.Core/Extensions/InteropWindowCaptureExtensions.cs
@@ -160,7 +160,7 @@ namespace Greenshot.Core.Extensions
// Calculate the location of the temp form
var windowRectangle = interopWindow.GetInfo().Bounds;
var formLocation = windowRectangle.Location;
- var borderSize = new Size();
+ var borderSize = Size.Empty;
var doesCaptureFit = false;
if (!interopWindow.IsMaximized())
{
diff --git a/src/Greenshot.Gfx/BitmapHelper.cs b/src/Greenshot.Gfx/BitmapHelper.cs
index 079b7e42f..f659d6249 100644
--- a/src/Greenshot.Gfx/BitmapHelper.cs
+++ b/src/Greenshot.Gfx/BitmapHelper.cs
@@ -50,11 +50,33 @@ namespace Greenshot.Gfx
///
public static IDictionary StreamConverters { get; } = new Dictionary(StringComparer.OrdinalIgnoreCase);
- ///
- /// Make sure the image is orientated correctly
- ///
- /// Image
- public static void Orientate(this Image image)
+ ///
+ /// Register a IImageFormatReader by type
+ ///
+ /// Type which extends IImageFormatReader
+ public static void RegisterFormatReader() where TFormatReader : IImageFormatReader, new()
+ {
+ RegisterFormatReader(new TFormatReader());
+ }
+
+ ///
+ /// Register an instance of an IImageFormatReader
+ ///
+ /// Type which extends IImageFormatReader
+ /// IImageFormatReader
+ public static void RegisterFormatReader(TFormatReader formatReader) where TFormatReader : IImageFormatReader
+ {
+ foreach (var extension in formatReader.SupportedFormats)
+ {
+ StreamConverters[extension] = formatReader;
+ }
+ }
+
+ ///
+ /// Make sure the image is orientated correctly
+ ///
+ /// Image
+ public static void Orientate(this Image image)
{
try
{
diff --git a/src/Greenshot.Gfx/GfxModule.cs b/src/Greenshot.Gfx/GfxModule.cs
index 6db89f62d..cc330999f 100644
--- a/src/Greenshot.Gfx/GfxModule.cs
+++ b/src/Greenshot.Gfx/GfxModule.cs
@@ -27,14 +27,6 @@ namespace Greenshot.Gfx
///
public class GfxModule : AddonModule
{
- private void Register(IImageFormatReader reader)
- {
- foreach(var extension in reader.SupportedFormats)
- {
- BitmapHelper.StreamConverters[extension] = reader;
- }
- }
-
///
protected override void Load(ContainerBuilder builder)
{
@@ -46,7 +38,7 @@ namespace Greenshot.Gfx
.AutoActivate()
.OnActivated(args =>
{
- Register(args.Instance);
+ BitmapHelper.RegisterFormatReader(args.Instance);
});
builder
@@ -56,7 +48,7 @@ namespace Greenshot.Gfx
.AutoActivate()
.OnActivated(args =>
{
- Register(args.Instance);
+ BitmapHelper.RegisterFormatReader(args.Instance);
});
builder
@@ -66,7 +58,7 @@ namespace Greenshot.Gfx
.AutoActivate()
.OnActivated(args =>
{
- Register(args.Instance);
+ BitmapHelper.RegisterFormatReader(args.Instance);
});
base.Load(builder);
diff --git a/src/Greenshot.Gfx/Greenshot.Gfx.csproj b/src/Greenshot.Gfx/Greenshot.Gfx.csproj
index 846887daa..1ac55e391 100644
--- a/src/Greenshot.Gfx/Greenshot.Gfx.csproj
+++ b/src/Greenshot.Gfx/Greenshot.Gfx.csproj
@@ -15,7 +15,7 @@
2.4.3
- 4.5.2
+ 4.5.3
diff --git a/src/Greenshot.PerformanceTests/GfxPerformance.cs b/src/Greenshot.PerformanceTests/GfxPerformance.cs
index 51146d1fc..725572eb6 100644
--- a/src/Greenshot.PerformanceTests/GfxPerformance.cs
+++ b/src/Greenshot.PerformanceTests/GfxPerformance.cs
@@ -1,4 +1,23 @@
-using System.Drawing;
+// Greenshot - a free and open source screenshot tool
+// Copyright (C) 2007-2019 Thomas Braun, Jens Klingen, Robin Krom
+//
+// For more information see: http://getgreenshot.org/
+// The Greenshot project is hosted on GitHub https://github.com/greenshot/greenshot
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 1 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see .
+
+using System.Drawing;
using System.Drawing.Imaging;
using BenchmarkDotNet.Attributes;
using Greenshot.Gfx;
@@ -35,7 +54,7 @@ namespace Greenshot.PerformanceTests
}
- //[Benchmark]
+ [Benchmark]
[Arguments(PixelFormat.Format24bppRgb)]
[Arguments(PixelFormat.Format32bppRgb)]
[Arguments(PixelFormat.Format32bppArgb)]
@@ -57,9 +76,12 @@ namespace Greenshot.PerformanceTests
}
[Benchmark]
- public void Blur_FastBitmap()
+ [Arguments(PixelFormat.Format24bppRgb)]
+ [Arguments(PixelFormat.Format32bppRgb)]
+ [Arguments(PixelFormat.Format32bppArgb)]
+ public void Blur_FastBitmap(PixelFormat pixelFormat)
{
- using (var bitmap = BitmapFactory.CreateEmpty(400, 400, PixelFormat.Format32bppRgb, Color.White))
+ using (var bitmap = BitmapFactory.CreateEmpty(400, 400, pixelFormat, Color.White))
{
using (var graphics = Graphics.FromImage(bitmap.NativeBitmap))
using (var pen = new SolidBrush(Color.Blue))
@@ -101,37 +123,37 @@ namespace Greenshot.PerformanceTests
}
}
- //[Benchmark]
+ [Benchmark]
public void Scale2x_FastBitmap()
{
ScaleX.Scale2X(_unmanagedTestBitmap).Dispose();
}
- //[Benchmark]
+ [Benchmark]
public void Scale2x_Unmanaged()
{
_unmanagedTestBitmap.Scale2X().Dispose();
}
- //[Benchmark]
+ [Benchmark]
public void Scale2x_Unmanaged_Reference()
{
_unmanagedTestBitmap.Scale2XReference().Dispose();
}
- //[Benchmark]
+ [Benchmark]
public void Scale3x_FastBitmap()
{
ScaleX.Scale3X(_unmanagedTestBitmap).Dispose();
}
- //[Benchmark]
+ [Benchmark]
public void Scale3x_Unmanaged()
{
_unmanagedTestBitmap.Scale3X().Dispose();
}
- //[Benchmark]
+ [Benchmark]
public void Scale3x_Unmanaged_Reference()
{
_unmanagedTestBitmap.Scale3XReference().Dispose();
diff --git a/src/Greenshot.PerformanceTests/Greenshot.PerformanceTests.csproj b/src/Greenshot.PerformanceTests/Greenshot.PerformanceTests.csproj
index 77c71fd7e..e399dd198 100644
--- a/src/Greenshot.PerformanceTests/Greenshot.PerformanceTests.csproj
+++ b/src/Greenshot.PerformanceTests/Greenshot.PerformanceTests.csproj
@@ -33,7 +33,7 @@
-
+
diff --git a/src/Greenshot.Tests/CaptureTests.cs b/src/Greenshot.Tests/CaptureTests.cs
index fe555df8b..96cd27071 100644
--- a/src/Greenshot.Tests/CaptureTests.cs
+++ b/src/Greenshot.Tests/CaptureTests.cs
@@ -121,16 +121,16 @@ namespace Greenshot.Tests
var template = new SimpleTemplate();
var bitmapSource = template.Apply(capture).ToBitmapSource();
- Assert.Equal(bounds.Size, bitmapSource.Size());
using (var outputStream = bitmapSource.ToStream(OutputFormats.png))
using (var fileStream = File.Create("Test_CaptureFlow_DwmWindowSource.png"))
{
outputStream.Seek(0, SeekOrigin.Begin);
await outputStream.CopyToAsync(fileStream);
}
+ Assert.Equal(bounds.Size, bitmapSource.Size());
}
-
-
+
+
///
/// Test if capturing works
///
diff --git a/src/Greenshot.Tests/Greenshot.Tests.csproj b/src/Greenshot.Tests/Greenshot.Tests.csproj
index e1c307f0f..21909d7e2 100644
--- a/src/Greenshot.Tests/Greenshot.Tests.csproj
+++ b/src/Greenshot.Tests/Greenshot.Tests.csproj
@@ -20,19 +20,19 @@
- PreserveNewest
+ Always
- PreserveNewest
+ Always
- PreserveNewest
+ Always
- PreserveNewest
+ Always
- PreserveNewest
+ Always
PreserveNewest
diff --git a/src/Greenshot.Tests/StitchTests.cs b/src/Greenshot.Tests/StitchTests.cs
index f529af9af..e4aff2dfe 100644
--- a/src/Greenshot.Tests/StitchTests.cs
+++ b/src/Greenshot.Tests/StitchTests.cs
@@ -19,6 +19,7 @@
using System.Drawing.Imaging;
using Greenshot.Gfx;
+using Greenshot.Gfx.Formats;
using Greenshot.Gfx.Stitching;
using Xunit;
@@ -26,6 +27,11 @@ namespace Greenshot.Tests
{
public class StitchTests
{
+ public StitchTests()
+ {
+ BitmapHelper.RegisterFormatReader();
+ }
+
[Fact]
public void BitmapStitcher_Default()
{