diff --git a/src/Directory.Build.props b/src/Directory.Build.props index 335bf2671..e10935e7c 100644 --- a/src/Directory.Build.props +++ b/src/Directory.Build.props @@ -49,7 +49,7 @@ - + all runtime; build; native; contentfiles; analyzers @@ -59,7 +59,7 @@ - + + - + all runtime; build; native; contentfiles; analyzers diff --git a/src/Greenshot.Addon.Confluence/Greenshot.Addon.Confluence.csproj b/src/Greenshot.Addon.Confluence/Greenshot.Addon.Confluence.csproj index d60f46f02..0aff705ac 100644 --- a/src/Greenshot.Addon.Confluence/Greenshot.Addon.Confluence.csproj +++ b/src/Greenshot.Addon.Confluence/Greenshot.Addon.Confluence.csproj @@ -50,12 +50,12 @@ - + - + all diff --git a/src/Greenshot.Addon.Dropbox/Greenshot.Addon.Dropbox.csproj b/src/Greenshot.Addon.Dropbox/Greenshot.Addon.Dropbox.csproj index acbf70362..de81e0c9e 100644 --- a/src/Greenshot.Addon.Dropbox/Greenshot.Addon.Dropbox.csproj +++ b/src/Greenshot.Addon.Dropbox/Greenshot.Addon.Dropbox.csproj @@ -45,13 +45,13 @@ - + - + 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 b1f8167c8..3f2df9b4e 100644 --- a/src/Greenshot.Addon.ExternalCommand/Greenshot.Addon.ExternalCommand.csproj +++ b/src/Greenshot.Addon.ExternalCommand/Greenshot.Addon.ExternalCommand.csproj @@ -37,10 +37,10 @@ - + - + all diff --git a/src/Greenshot.Addon.Flickr/Greenshot.Addon.Flickr.csproj b/src/Greenshot.Addon.Flickr/Greenshot.Addon.Flickr.csproj index ef23f77bc..f8ce79a82 100644 --- a/src/Greenshot.Addon.Flickr/Greenshot.Addon.Flickr.csproj +++ b/src/Greenshot.Addon.Flickr/Greenshot.Addon.Flickr.csproj @@ -45,11 +45,11 @@ - + - + all runtime; build; native; contentfiles; analyzers diff --git a/src/Greenshot.Addon.GooglePhotos/Greenshot.Addon.GooglePhotos.csproj b/src/Greenshot.Addon.GooglePhotos/Greenshot.Addon.GooglePhotos.csproj index fcec8f722..bd1470cad 100644 --- a/src/Greenshot.Addon.GooglePhotos/Greenshot.Addon.GooglePhotos.csproj +++ b/src/Greenshot.Addon.GooglePhotos/Greenshot.Addon.GooglePhotos.csproj @@ -45,11 +45,11 @@ - + - + all runtime; build; native; contentfiles; analyzers diff --git a/src/Greenshot.Addon.Imgur/Greenshot.Addon.Imgur.csproj b/src/Greenshot.Addon.Imgur/Greenshot.Addon.Imgur.csproj index 209195ad6..0da2c38a7 100644 --- a/src/Greenshot.Addon.Imgur/Greenshot.Addon.Imgur.csproj +++ b/src/Greenshot.Addon.Imgur/Greenshot.Addon.Imgur.csproj @@ -45,12 +45,12 @@ - + - + all runtime; build; native; contentfiles; analyzers diff --git a/src/Greenshot.Addon.InternetExplorer/Greenshot.Addon.InternetExplorer.csproj b/src/Greenshot.Addon.InternetExplorer/Greenshot.Addon.InternetExplorer.csproj index 4e941d2a0..a57c06f79 100644 --- a/src/Greenshot.Addon.InternetExplorer/Greenshot.Addon.InternetExplorer.csproj +++ b/src/Greenshot.Addon.InternetExplorer/Greenshot.Addon.InternetExplorer.csproj @@ -30,10 +30,10 @@ - 0.8.9 + 0.8.17 - 0.8.9 + 0.8.17 diff --git a/src/Greenshot.Addon.Jira/Greenshot.Addon.Jira.csproj b/src/Greenshot.Addon.Jira/Greenshot.Addon.Jira.csproj index 879deab97..ff3de05f5 100644 --- a/src/Greenshot.Addon.Jira/Greenshot.Addon.Jira.csproj +++ b/src/Greenshot.Addon.Jira/Greenshot.Addon.Jira.csproj @@ -47,13 +47,13 @@ - + - + all diff --git a/src/Greenshot.Addon.LegacyEditor/Greenshot.Addon.LegacyEditor.csproj b/src/Greenshot.Addon.LegacyEditor/Greenshot.Addon.LegacyEditor.csproj index 4097f7c25..8bd8c0ced 100644 --- a/src/Greenshot.Addon.LegacyEditor/Greenshot.Addon.LegacyEditor.csproj +++ b/src/Greenshot.Addon.LegacyEditor/Greenshot.Addon.LegacyEditor.csproj @@ -131,13 +131,13 @@ - + - - + + all runtime; build; native; contentfiles; analyzers diff --git a/src/Greenshot.Addon.Lutim/Greenshot.Addon.Lutim.csproj b/src/Greenshot.Addon.Lutim/Greenshot.Addon.Lutim.csproj index 095ffae13..8100713a8 100644 --- a/src/Greenshot.Addon.Lutim/Greenshot.Addon.Lutim.csproj +++ b/src/Greenshot.Addon.Lutim/Greenshot.Addon.Lutim.csproj @@ -45,12 +45,12 @@ - + - + all diff --git a/src/Greenshot.Addon.OCR/Greenshot.Addon.OCR.csproj b/src/Greenshot.Addon.OCR/Greenshot.Addon.OCR.csproj index 809ffa3f0..11965a1c0 100644 --- a/src/Greenshot.Addon.OCR/Greenshot.Addon.OCR.csproj +++ b/src/Greenshot.Addon.OCR/Greenshot.Addon.OCR.csproj @@ -37,10 +37,10 @@ - + - + all runtime; build; native; contentfiles; analyzers diff --git a/src/Greenshot.Addon.Office/Greenshot.Addon.Office.csproj b/src/Greenshot.Addon.Office/Greenshot.Addon.Office.csproj index ab46aceed..c5bc70853 100644 --- a/src/Greenshot.Addon.Office/Greenshot.Addon.Office.csproj +++ b/src/Greenshot.Addon.Office/Greenshot.Addon.Office.csproj @@ -37,10 +37,10 @@ - + - + diff --git a/src/Greenshot.Addon.OneDrive/Greenshot.Addon.OneDrive.csproj b/src/Greenshot.Addon.OneDrive/Greenshot.Addon.OneDrive.csproj index 5f12f2bf9..6f03bf637 100644 --- a/src/Greenshot.Addon.OneDrive/Greenshot.Addon.OneDrive.csproj +++ b/src/Greenshot.Addon.OneDrive/Greenshot.Addon.OneDrive.csproj @@ -45,12 +45,12 @@ - + - + all diff --git a/src/Greenshot.Addon.Photobucket/Greenshot.Addon.Photobucket.csproj b/src/Greenshot.Addon.Photobucket/Greenshot.Addon.Photobucket.csproj index 89de1abf6..e03fbe464 100644 --- a/src/Greenshot.Addon.Photobucket/Greenshot.Addon.Photobucket.csproj +++ b/src/Greenshot.Addon.Photobucket/Greenshot.Addon.Photobucket.csproj @@ -45,11 +45,11 @@ - + - + all runtime; build; native; contentfiles; analyzers diff --git a/src/Greenshot.Addon.Tfs/Greenshot.Addon.Tfs.csproj b/src/Greenshot.Addon.Tfs/Greenshot.Addon.Tfs.csproj index 938edd845..1942d4750 100644 --- a/src/Greenshot.Addon.Tfs/Greenshot.Addon.Tfs.csproj +++ b/src/Greenshot.Addon.Tfs/Greenshot.Addon.Tfs.csproj @@ -45,12 +45,12 @@ - + - + all diff --git a/src/Greenshot.Addon.Win10/Greenshot.Addon.Win10.csproj b/src/Greenshot.Addon.Win10/Greenshot.Addon.Win10.csproj index 9130062f8..b62215dfd 100644 --- a/src/Greenshot.Addon.Win10/Greenshot.Addon.Win10.csproj +++ b/src/Greenshot.Addon.Win10/Greenshot.Addon.Win10.csproj @@ -1,4 +1,4 @@ - + Greenshot.Addon.Win10 @@ -55,7 +55,7 @@ - + diff --git a/src/Greenshot.Addons/Greenshot.Addons.csproj b/src/Greenshot.Addons/Greenshot.Addons.csproj index 1a3d2f8ab..224497432 100644 --- a/src/Greenshot.Addons/Greenshot.Addons.csproj +++ b/src/Greenshot.Addons/Greenshot.Addons.csproj @@ -42,7 +42,7 @@ - + 1.2.21 @@ -62,10 +62,10 @@ 0.9.18 - 0.8.9 + 0.8.17 - 0.8.9 + 0.8.17 all @@ -75,7 +75,7 @@ 3.0.0-alpha0103 - 2.4.1 + 2.4.2 diff --git a/src/Greenshot.Core/Greenshot.Core.csproj b/src/Greenshot.Core/Greenshot.Core.csproj index 1b596e401..0385185ae 100644 --- a/src/Greenshot.Core/Greenshot.Core.csproj +++ b/src/Greenshot.Core/Greenshot.Core.csproj @@ -29,7 +29,7 @@ - 0.8.9 + 0.8.17 diff --git a/src/Greenshot.Gfx.Experimental/BoxBlurSpan.cs b/src/Greenshot.Gfx.Experimental/BoxBlurSpan.cs deleted file mode 100644 index 8e71c503e..000000000 --- a/src/Greenshot.Gfx.Experimental/BoxBlurSpan.cs +++ /dev/null @@ -1,419 +0,0 @@ -#region Greenshot GNU General Public License - -// Greenshot - a free and open source screenshot tool -// Copyright (C) 2007-2018 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 . - -#endregion - -using System; -using System.Drawing; -using System.Drawing.Imaging; -using System.Threading.Tasks; -using Greenshot.Gfx.Experimental.Structs; - - -namespace Greenshot.Gfx.Experimental -{ - /// - /// Code to apply a box blur - /// - public static class BoxBlurSpan - { - /// - /// Apply BoxBlur to the destinationBitmap - /// - /// Bitmap to blur - /// Must be ODD, if not +1 is used - public static void ApplyBoxBlurSpan(this Bitmap destinationBitmap, int range) - { - var bitmapData = destinationBitmap.LockBits(new Rectangle(Point.Empty, destinationBitmap.Size), ImageLockMode.ReadWrite, destinationBitmap.PixelFormat); - try - { - var pixelStride = destinationBitmap.Width; - bool isAlpha = false; - switch (bitmapData.PixelFormat) - { - case PixelFormat.Format24bppRgb: - pixelStride = bitmapData.Stride / 3; - break; - case PixelFormat.Format32bppRgb: - pixelStride = bitmapData.Stride / 4; - break; - case PixelFormat.Format32bppArgb: - pixelStride = bitmapData.Stride / 4; - isAlpha = true; - break; - } - - var spanInfo = new SpanInfo - { - Width = destinationBitmap.Width, - Height = destinationBitmap.Height, - Left = 0, - Right = destinationBitmap.Width, - Top = 0, - Bottom = destinationBitmap.Height, - Pointer = bitmapData.Scan0, - PixelStride = pixelStride, - BitmapSize = destinationBitmap.Height * pixelStride - }; - - if (isAlpha) - { - ApplyBoxBlurSpanAlpha(spanInfo, range); - } - else - { - ApplyBoxBlurSpan(spanInfo, range); - } - - } - finally - { - destinationBitmap.UnlockBits(bitmapData); - } - } - - /// - /// Apply BoxBlur to the fastBitmap - /// - /// SpanInfo - /// Must be even! - private static void ApplyBoxBlurSpan(SpanInfo spanInfo, int range) - { - // Range must be odd! - if ((range & 1) == 0) - { - range++; - } - if (range <= 1) - { - return; - } - // Box blurs are frequently used to approximate a Gaussian blur. - // By the central limit theorem, if applied 3 times on the same image, a box blur approximates the Gaussian kernel to within about 3%, yielding the same result as a quadratic convolution kernel. - // This might be true, but the GDI+ BlurEffect doesn't look the same, a 2x blur is more simular and we only make 2x Box-Blur. - // (Might also be a mistake in our blur, but for now it looks great) - BoxBlurHorizontalSpan(spanInfo, range); - BoxBlurVerticalSpan(spanInfo, range); - BoxBlurHorizontalSpan(spanInfo, range); - BoxBlurVerticalSpan(spanInfo, range); - } - - - /// - /// Apply BoxBlur to the fastBitmap - /// - /// SpanInfo - /// Must be even! - private static void ApplyBoxBlurSpanAlpha(SpanInfo spanInfo, int range) - { - // Range must be odd! - if ((range & 1) == 0) - { - range++; - } - if (range <= 1) - { - return; - } - // Box blurs are frequently used to approximate a Gaussian blur. - // By the central limit theorem, if applied 3 times on the same image, a box blur approximates the Gaussian kernel to within about 3%, yielding the same result as a quadratic convolution kernel. - // This might be true, but the GDI+ BlurEffect doesn't look the same, a 2x blur is more simular and we only make 2x Box-Blur. - // (Might also be a mistake in our blur, but for now it looks great) - BoxBlurHorizontalSpanAlpha(spanInfo, range); - BoxBlurVerticalSpanAlpha(spanInfo, range); - BoxBlurHorizontalSpanAlpha(spanInfo, range); - BoxBlurVerticalSpanAlpha(spanInfo, range); - } - /// - /// BoxBlurHorizontal is a private helper method for the BoxBlur, only for IFastBitmaps with alpha channel - /// - /// - /// Range must be odd! - private static void BoxBlurHorizontalSpan(SpanInfo spanInfo, int range) - { - var halfRange = range / 2; - - Parallel.For(spanInfo.Top, spanInfo.Bottom, y => - { - unsafe { - var rgb24 = new Span((byte*)spanInfo.Pointer, spanInfo.BitmapSize); - Span averages = stackalloc Bgr32[range]; - var r = 0; - var g = 0; - var b = 0; - var hits = halfRange; - for (var x = spanInfo.Left; x < spanInfo.Left + halfRange; x++) - { - ref Bgr32 color = ref rgb24[x + (y * spanInfo.PixelStride)]; - - r += color.R; - g += color.G; - b += color.B; - } - for (var x = spanInfo.Left; x < spanInfo.Right; x++) - { - var leftSide = x - halfRange - 1; - if (leftSide >= spanInfo.Left) - { - // Get value at the left side of range - ref Bgr32 color = ref rgb24[leftSide + (y * spanInfo.PixelStride)]; - r -= color.R; - g -= color.G; - b -= color.B; - hits--; - } - - var rightSide = x + halfRange; - if (rightSide < spanInfo.Right) - { - ref Bgr32 color = ref rgb24[rightSide + (y * spanInfo.PixelStride)]; - r += color.R; - g += color.G; - b += color.B; - hits++; - } - - ref Bgr32 average = ref averages[(x % range)]; - average.R = (byte)(r / hits); - average.G = (byte)(g / hits); - average.B = (byte)(b / hits); - - if (leftSide >= spanInfo.Left) - { - // Now we can write the value from the calculated avarages - var readLocation = (leftSide % range); - - rgb24[leftSide + (y * spanInfo.PixelStride)] = averages[readLocation]; - } - } - } - }); - } - - /// - /// BoxBlurVertical is a private helper method for the BoxBlur - /// - /// - /// Range must be odd! - private static void BoxBlurVerticalSpan(SpanInfo spanInfo, int range) - { - var halfRange = range / 2; - Parallel.For(spanInfo.Left, spanInfo.Right, x => - { - unsafe { - var rgb24 = new Span((byte*)spanInfo.Pointer, spanInfo.BitmapSize); - Span averages = stackalloc Bgr32[range]; - var hits = 0; - var r = 0; - var g = 0; - var b = 0; - for (var y = spanInfo.Top; y < spanInfo.Top + halfRange; y++) - { - ref Bgr32 color = ref rgb24[(y * spanInfo.PixelStride) + x]; - r += color.R; - g += color.G; - b += color.B; - hits++; - } - for (var y = spanInfo.Top; y < spanInfo.Bottom; y++) - { - var topSide = y - halfRange - 1; - if (topSide >= spanInfo.Top) - { - // Get value at the top side of range - ref Bgr32 color = ref rgb24[x + (topSide * spanInfo.PixelStride)]; - r -= color.R; - g -= color.G; - b -= color.B; - hits--; - } - - var bottomSide = y + halfRange; - if (bottomSide < spanInfo.Bottom) - { - ref Bgr32 color = ref rgb24[x + (bottomSide * spanInfo.PixelStride)]; - r += color.R; - g += color.G; - b += color.B; - hits++; - } - - ref Bgr32 average = ref averages[y % range]; - average.R = (byte)(r / hits); - average.G = (byte)(g / hits); - average.B = (byte)(b / hits); - - if (topSide >= spanInfo.Top) - { - // Write the value from the calculated avarages - var readLocation = (topSide % range); - - rgb24[x + (topSide * spanInfo.PixelStride)] = averages[readLocation]; - } - } - } - }); - } - - /// - /// BoxBlurHorizontal is a private helper method for the BoxBlur, only for IFastBitmaps with alpha channel - /// - /// - /// Range must be odd! - private static void BoxBlurHorizontalSpanAlpha(SpanInfo spanInfo, int range) - { - var halfRange = range / 2; - - Parallel.For(spanInfo.Top, spanInfo.Bottom, y => - { - unsafe { - var argb32 = new Span((byte*)spanInfo.Pointer, spanInfo.BitmapSize); - Span averages = stackalloc Bgra32[range]; - var a = 0; - var r = 0; - var g = 0; - var b = 0; - var hits = halfRange; - var lineOffset = y * spanInfo.PixelStride; - for (var x = spanInfo.Left; x < spanInfo.Left + halfRange; x++) - { - ref Bgra32 color = ref argb32[x + lineOffset]; - a += color.A; - r += color.R; - g += color.G; - b += color.B; - } - for (var x = spanInfo.Left; x < spanInfo.Right; x++) - { - var leftSide = x - halfRange - 1; - if (leftSide >= spanInfo.Left) - { - // Get value at the left side of range - ref Bgra32 color = ref argb32[leftSide + lineOffset]; - a -= color.A; - r -= color.R; - g -= color.G; - b -= color.B; - hits--; - } - - var rightSide = x + halfRange; - if (rightSide < spanInfo.Right) - { - ref Bgra32 color = ref argb32[rightSide + lineOffset]; - a += color.A; - r += color.R; - g += color.G; - b += color.B; - hits++; - } - - ref Bgra32 average = ref averages[x % range]; - average.A = (byte)(a / hits); - average.R = (byte)(r / hits); - average.G = (byte)(g / hits); - average.B = (byte)(b / hits); - - if (leftSide >= spanInfo.Left) - { - // Now we can write the value from the calculated avarages - var readLocation = (leftSide % range); - - argb32[leftSide + lineOffset] = averages[readLocation]; - } - } - } - }); - } - - /// - /// BoxBlurVertical is a private helper method for the BoxBlur - /// - /// - /// Range must be odd! - private static void BoxBlurVerticalSpanAlpha(SpanInfo spanInfo, int range) - { - var halfRange = range / 2; - Parallel.For(spanInfo.Left, spanInfo.Right, x => - { - Span argb32; - unsafe { argb32 = new Span((byte*)spanInfo.Pointer, spanInfo.BitmapSize); } - unsafe - { - Span averages = stackalloc Bgra32[range]; - var hits = 0; - var a = 0; - var r = 0; - var g = 0; - var b = 0; - for (var y = spanInfo.Top; y < spanInfo.Top + halfRange; y++) - { - ref Bgra32 color = ref argb32[x + (y * spanInfo.PixelStride)]; - a += color.A; - r += color.R; - g += color.G; - b += color.B; - hits++; - } - for (var y = spanInfo.Top; y < spanInfo.Bottom; y++) - { - var topSide = y - halfRange - 1; - if (topSide >= spanInfo.Top) - { - // Get value at the top side of range - ref Bgra32 color = ref argb32[x + (topSide * spanInfo.PixelStride)]; - a -= color.A; - r -= color.R; - g -= color.G; - b -= color.B; - hits--; - } - - var bottomSide = y + halfRange; - if (bottomSide < spanInfo.Bottom) - { - ref Bgra32 color = ref argb32[x + (bottomSide * spanInfo.PixelStride)]; - a += color.A; - r += color.R; - g += color.G; - b += color.B; - hits++; - } - - ref Bgra32 average = ref averages[(y % range)]; - average.A = (byte)(a / hits); - average.R = (byte)(r / hits); - average.G = (byte)(g / hits); - average.B = (byte)(b / hits); - - if (topSide >= spanInfo.Top) - { - // Write the value from the calculated avarages - var readLocation = (topSide % range); - - argb32[x + (topSide * spanInfo.PixelStride)] = averages[readLocation]; - } - } - } - }); - } - } -} diff --git a/src/Greenshot.Gfx.Experimental/Greenshot.Gfx.Experimental.csproj b/src/Greenshot.Gfx.Experimental/Greenshot.Gfx.Experimental.csproj deleted file mode 100644 index a7e118396..000000000 --- a/src/Greenshot.Gfx.Experimental/Greenshot.Gfx.Experimental.csproj +++ /dev/null @@ -1,56 +0,0 @@ - - - - net472;netcoreapp3.0 - true - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 4.5.0 - - - 4.5.2 - - - 4.5.0 - - - 4.5.2 - - - - - - {f041c685-eb96-4ed1-9ace-0f5bd836610f} - Greenshot.Gfx - - - - \ No newline at end of file diff --git a/src/Greenshot.Gfx.Experimental/Structs/SpanInfo.cs b/src/Greenshot.Gfx.Experimental/Structs/SpanInfo.cs deleted file mode 100644 index 5fdddf020..000000000 --- a/src/Greenshot.Gfx.Experimental/Structs/SpanInfo.cs +++ /dev/null @@ -1,48 +0,0 @@ -using System; - -namespace Greenshot.Gfx.Experimental.Structs -{ - /// - /// - /// - public class SpanInfo - { - /// - /// Pointer to the memory - /// - public IntPtr Pointer; - /// - /// How many bytes are on a single line - /// - public int PixelStride; - /// - /// - /// - public int Height; - /// - /// - /// - public int Width; - /// - /// - /// - public int Left; - /// - /// - /// - public int Right; - /// - /// - /// - public int Top; - /// - /// - /// - public int Bottom; - /// - /// - /// - public int BitmapSize; - - } -} diff --git a/src/Greenshot.Gfx.Experimental/app.config b/src/Greenshot.Gfx.Experimental/app.config deleted file mode 100644 index b3e5dcbbe..000000000 --- a/src/Greenshot.Gfx.Experimental/app.config +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - - - diff --git a/src/Greenshot.Gfx.Experimental/BoxBlurUnmanaged.cs b/src/Greenshot.Gfx/BoxBlurUnmanaged.cs similarity index 97% rename from src/Greenshot.Gfx.Experimental/BoxBlurUnmanaged.cs rename to src/Greenshot.Gfx/BoxBlurUnmanaged.cs index 9800571ab..d65efe073 100644 --- a/src/Greenshot.Gfx.Experimental/BoxBlurUnmanaged.cs +++ b/src/Greenshot.Gfx/BoxBlurUnmanaged.cs @@ -23,10 +23,9 @@ using System; using System.Threading.Tasks; -using Greenshot.Gfx.Experimental.Structs; +using Greenshot.Gfx.Structs; - -namespace Greenshot.Gfx.Experimental +namespace Greenshot.Gfx { /// /// Code to apply a box blur diff --git a/src/Greenshot.Gfx/Greenshot.Gfx.csproj b/src/Greenshot.Gfx/Greenshot.Gfx.csproj index daab46aee..46cb9abd4 100644 --- a/src/Greenshot.Gfx/Greenshot.Gfx.csproj +++ b/src/Greenshot.Gfx/Greenshot.Gfx.csproj @@ -33,7 +33,7 @@ - 2.4.1 + 2.4.2 diff --git a/src/Greenshot.Gfx/Murmur3.cs b/src/Greenshot.Gfx/Murmur3.cs index 28957f65e..fb1085e5d 100644 --- a/src/Greenshot.Gfx/Murmur3.cs +++ b/src/Greenshot.Gfx/Murmur3.cs @@ -64,13 +64,16 @@ namespace Greenshot.Gfx [MethodImpl(MethodImplOptions.AggressiveInlining)] public void AddBytes(byte one, byte two, byte three, byte four) { - var k = (uint)(one | two << 8 | three << 16 | four << 24); - k *= C1; - k = RotateLeft(k, R1); - k *= C2; - _hash ^= k; - _hash = RotateLeft(_hash, R2); - _hash = _hash * M + N; + unchecked + { + var k = (uint)(one | two << 8 | three << 16 | four << 24); + k *= C1; + k = RotateLeft(k, R1); + k *= C2; + _hash ^= k; + _hash = RotateLeft(_hash, R2); + _hash = _hash * M + N; + } } /// @@ -81,11 +84,14 @@ namespace Greenshot.Gfx /// third byte public void AddTrailingBytes(byte one, byte two = 0, byte three = 0) { - var k = (uint)(one | two << 8 | three << 16); - k *= C1; - k = RotateLeft(k, R1); - k *= C2; - _hash ^= k; + unchecked + { + var k = (uint) (one | two << 8 | three << 16); + k *= C1; + k = RotateLeft(k, R1); + k *= C2; + _hash ^= k; + } } /// @@ -127,11 +133,14 @@ namespace Greenshot.Gfx get { var hash = _hash ^ _length; - hash ^= hash >> 16; - hash *= 0x85ebca6b; - hash ^= hash >> 13; - hash *= 0xc2b2ae35; - hash ^= hash >> 16; + unchecked + { + hash ^= hash >> 16; + hash *= 0x85ebca6b; + hash ^= hash >> 13; + hash *= 0xc2b2ae35; + hash ^= hash >> 16; + } return hash; } } diff --git a/src/Greenshot.Gfx.Experimental/ScaleXUnmanaged.cs b/src/Greenshot.Gfx/ScaleXUnmanaged.cs similarity index 97% rename from src/Greenshot.Gfx.Experimental/ScaleXUnmanaged.cs rename to src/Greenshot.Gfx/ScaleXUnmanaged.cs index c96b38c27..02c9714ff 100644 --- a/src/Greenshot.Gfx.Experimental/ScaleXUnmanaged.cs +++ b/src/Greenshot.Gfx/ScaleXUnmanaged.cs @@ -24,7 +24,7 @@ using System; using System.Runtime.InteropServices; -namespace Greenshot.Gfx.Experimental +namespace Greenshot.Gfx { /// /// This is the ScaleX code for the UnmanagedBitmap diff --git a/src/Greenshot.Gfx.Experimental/ScaleXUnmanagedReference.cs b/src/Greenshot.Gfx/ScaleXUnmanagedReference.cs similarity index 97% rename from src/Greenshot.Gfx.Experimental/ScaleXUnmanagedReference.cs rename to src/Greenshot.Gfx/ScaleXUnmanagedReference.cs index dd3cfd4f2..df7765e9d 100644 --- a/src/Greenshot.Gfx.Experimental/ScaleXUnmanagedReference.cs +++ b/src/Greenshot.Gfx/ScaleXUnmanagedReference.cs @@ -24,7 +24,7 @@ using System; using System.Runtime.InteropServices; -namespace Greenshot.Gfx.Experimental +namespace Greenshot.Gfx { /// /// This is the ScaleX code for the UnmanagedBitmap diff --git a/src/Greenshot.Gfx.Experimental/Structs/Bgr24.cs b/src/Greenshot.Gfx/Structs/Bgr24.cs similarity index 76% rename from src/Greenshot.Gfx.Experimental/Structs/Bgr24.cs rename to src/Greenshot.Gfx/Structs/Bgr24.cs index 536b44092..48376513a 100644 --- a/src/Greenshot.Gfx.Experimental/Structs/Bgr24.cs +++ b/src/Greenshot.Gfx/Structs/Bgr24.cs @@ -1,8 +1,11 @@ -namespace Greenshot.Gfx.Experimental.Structs +using System.Runtime.InteropServices; + +namespace Greenshot.Gfx.Structs { /// /// A struct with the BGR values for a 24bit pixel /// + [StructLayout(LayoutKind.Sequential)] public struct Bgr24 { /// diff --git a/src/Greenshot.Gfx.Experimental/Structs/Bgr32.cs b/src/Greenshot.Gfx/Structs/Bgr32.cs similarity index 92% rename from src/Greenshot.Gfx.Experimental/Structs/Bgr32.cs rename to src/Greenshot.Gfx/Structs/Bgr32.cs index 105811f54..48b8ed77f 100644 --- a/src/Greenshot.Gfx.Experimental/Structs/Bgr32.cs +++ b/src/Greenshot.Gfx/Structs/Bgr32.cs @@ -22,12 +22,14 @@ #endregion using System; +using System.Runtime.InteropServices; -namespace Greenshot.Gfx.Experimental.Structs +namespace Greenshot.Gfx.Structs { /// /// A struct with the BGR values for a 32bit pixel /// + [StructLayout(LayoutKind.Sequential)] public struct Bgr32 : IEquatable { /// diff --git a/src/Greenshot.Gfx.Experimental/Structs/Bgra32.cs b/src/Greenshot.Gfx/Structs/Bgra32.cs similarity index 92% rename from src/Greenshot.Gfx.Experimental/Structs/Bgra32.cs rename to src/Greenshot.Gfx/Structs/Bgra32.cs index 3481767e9..5e6e6f74b 100644 --- a/src/Greenshot.Gfx.Experimental/Structs/Bgra32.cs +++ b/src/Greenshot.Gfx/Structs/Bgra32.cs @@ -22,12 +22,14 @@ #endregion using System; +using System.Runtime.InteropServices; -namespace Greenshot.Gfx.Experimental.Structs +namespace Greenshot.Gfx.Structs { /// /// A struct with the BGR values for a 32bit pixel /// + [StructLayout(LayoutKind.Sequential)] public struct Bgra32 : IEquatable { /// diff --git a/src/Greenshot.Gfx.Experimental/UnmanagedBitmap.cs b/src/Greenshot.Gfx/UnmanagedBitmap.cs similarity index 95% rename from src/Greenshot.Gfx.Experimental/UnmanagedBitmap.cs rename to src/Greenshot.Gfx/UnmanagedBitmap.cs index cc49fdf3a..2b7dadbc8 100644 --- a/src/Greenshot.Gfx.Experimental/UnmanagedBitmap.cs +++ b/src/Greenshot.Gfx/UnmanagedBitmap.cs @@ -26,9 +26,9 @@ using System.Drawing; using System.Drawing.Imaging; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; -using Greenshot.Gfx.Experimental.Structs; +using Greenshot.Gfx.Structs; -namespace Greenshot.Gfx.Experimental +namespace Greenshot.Gfx { /// /// A bitmap wraper with memory from Marshal.AllocHGlobal diff --git a/src/Greenshot.PerformanceTests/GfxPerformance.cs b/src/Greenshot.PerformanceTests/GfxPerformance.cs index fc75280f4..403dc5ff9 100644 --- a/src/Greenshot.PerformanceTests/GfxPerformance.cs +++ b/src/Greenshot.PerformanceTests/GfxPerformance.cs @@ -2,9 +2,8 @@ using System.Drawing.Imaging; using BenchmarkDotNet.Attributes; using Greenshot.Gfx; -using Greenshot.Gfx.Experimental; -using Greenshot.Gfx.Experimental.Structs; using Greenshot.Gfx.Quantizer; +using Greenshot.Gfx.Structs; using Greenshot.Tests.Implementation; namespace Greenshot.PerformanceTests @@ -75,20 +74,6 @@ namespace Greenshot.PerformanceTests } } - //[Benchmark] - public void Blur_Span() - { - using (var bitmap = BitmapFactory.CreateEmpty(400, 400, PixelFormat.Format32bppRgb, Color.White)) - { - using (var graphics = Graphics.FromImage(bitmap)) - using (var pen = new SolidBrush(Color.Blue)) - { - graphics.FillRectangle(pen, new Rectangle(30, 30, 340, 340)); - } - bitmap.ApplyBoxBlurSpan(10); - } - } - //[Benchmark] public void Blur_UnmanagedBitmap() { diff --git a/src/Greenshot.PerformanceTests/GfxPerformanceShort.cs b/src/Greenshot.PerformanceTests/GfxPerformanceShort.cs index a986a5e14..25fe0f8ef 100644 --- a/src/Greenshot.PerformanceTests/GfxPerformanceShort.cs +++ b/src/Greenshot.PerformanceTests/GfxPerformanceShort.cs @@ -2,7 +2,6 @@ using System.Drawing.Imaging; using BenchmarkDotNet.Attributes; using Greenshot.Gfx; -using Greenshot.Gfx.Experimental; namespace Greenshot.PerformanceTests { @@ -28,22 +27,5 @@ namespace Greenshot.PerformanceTests bitmap.ApplyBoxBlur(10); } } - - [Benchmark] - [Arguments(PixelFormat.Format24bppRgb)] - [Arguments(PixelFormat.Format32bppRgb)] - [Arguments(PixelFormat.Format32bppArgb)] - public void BlurSpan(PixelFormat pixelFormat) - { - using (var bitmap = BitmapFactory.CreateEmpty(400, 400, pixelFormat, Color.White)) - { - using (var graphics = Graphics.FromImage(bitmap)) - using (var pen = new SolidBrush(Color.Blue)) - { - graphics.FillRectangle(pen, new Rectangle(30, 30, 340, 340)); - } - bitmap.ApplyBoxBlurSpan(10); - } - } } } diff --git a/src/Greenshot.PerformanceTests/Greenshot.PerformanceTests.csproj b/src/Greenshot.PerformanceTests/Greenshot.PerformanceTests.csproj index bd108bc9c..fad4b963d 100644 --- a/src/Greenshot.PerformanceTests/Greenshot.PerformanceTests.csproj +++ b/src/Greenshot.PerformanceTests/Greenshot.PerformanceTests.csproj @@ -7,6 +7,14 @@ net472;netcoreapp3.0 true + + + AnyCPU + + + + AnyCPU + @@ -50,13 +58,13 @@ - + diff --git a/src/Greenshot.Tests/BlurTests.cs b/src/Greenshot.Tests/BlurTests.cs index 428718e1a..baf9d8c34 100644 --- a/src/Greenshot.Tests/BlurTests.cs +++ b/src/Greenshot.Tests/BlurTests.cs @@ -23,10 +23,8 @@ using System.Drawing; using System.Drawing.Imaging; -using System.IO; using Greenshot.Gfx; -using Greenshot.Gfx.Experimental; -using Greenshot.Gfx.Experimental.Structs; +using Greenshot.Gfx.Structs; using Greenshot.Tests.Implementation; using Xunit; @@ -65,33 +63,6 @@ namespace Greenshot.Tests } } - [Theory] - [InlineData(PixelFormat.Format24bppRgb)] - [InlineData(PixelFormat.Format32bppRgb)] - [InlineData(PixelFormat.Format32bppArgb)] - public void Test_Blur_Span(PixelFormat pixelFormat) - { - using (var bitmapNew = BitmapFactory.CreateEmpty(400, 400, pixelFormat, Color.White)) - using (var bitmapOld = BitmapFactory.CreateEmpty(400, 400, pixelFormat, Color.White)) - { - using (var graphics = Graphics.FromImage(bitmapNew)) - using (var pen = new SolidBrush(Color.Blue)) - { - graphics.FillRectangle(pen, new Rectangle(30, 30, 340, 340)); - bitmapNew.ApplyBoxBlurSpan(10); - } - using (var graphics = Graphics.FromImage(bitmapOld)) - using (var pen = new SolidBrush(Color.Blue)) - { - graphics.FillRectangle(pen, new Rectangle(30, 30, 340, 340)); - bitmapOld.ApplyOldBoxBlur(10); - } - bitmapOld.Save(@"old.png", ImageFormat.Png); - bitmapNew.Save(@"new.png", ImageFormat.Png); - - Assert.True(bitmapOld.IsEqualTo(bitmapNew), "New blur doesn't compare to old."); - } - } [Fact] public void Test_Blur_UnmanagedBitmap() @@ -103,8 +74,7 @@ namespace Greenshot.Tests using (var pen = new SolidBrush(Color.Blue)) { graphics.FillRectangle(pen, new Rectangle(30, 30, 340, 340)); - //bitmapOld.ApplyOldBoxBlur(10); - bitmapOld.ApplyBoxBlurSpan(10); + bitmapOld.ApplyOldBoxBlur(10); } bitmapOld.Save(@"old.png", ImageFormat.Png); diff --git a/src/Greenshot.Tests/CaptureTests.cs b/src/Greenshot.Tests/CaptureTests.cs index d58e74073..0193c50fc 100644 --- a/src/Greenshot.Tests/CaptureTests.cs +++ b/src/Greenshot.Tests/CaptureTests.cs @@ -23,10 +23,13 @@ using System.IO; using System.Linq; +using System.Runtime.InteropServices; using System.Threading.Tasks; using System.Windows.Media.Imaging; using Dapplo.CaliburnMicro.Extensions; using Dapplo.Windows.Desktop; +using Dapplo.Windows.Icons; +using Dapplo.Windows.User32.Structs; using Greenshot.Addons.Config.Impl; using Greenshot.Addons.Core; using Greenshot.Core; diff --git a/src/Greenshot.Tests/CommandlineTests.cs b/src/Greenshot.Tests/CommandlineTests.cs index 52b2c4467..b63b49e77 100644 --- a/src/Greenshot.Tests/CommandlineTests.cs +++ b/src/Greenshot.Tests/CommandlineTests.cs @@ -51,7 +51,7 @@ namespace Greenshot.Tests [Fact] public void TestLanguageOption() { - var arguments = new[] { "-language", "de-DE" }; + var arguments = new[] { "--language", "de-DE" }; CommandlineCaptureOptions captureOptions = null; CommandlineOptions commandlineOptions = null; diff --git a/src/Greenshot.Tests/FilterTests.cs b/src/Greenshot.Tests/FilterTests.cs index 36905abe1..fb037554d 100644 --- a/src/Greenshot.Tests/FilterTests.cs +++ b/src/Greenshot.Tests/FilterTests.cs @@ -28,7 +28,7 @@ namespace Greenshot.Tests graphics.FillRectangle(pen, new Rectangle(30, 30, 340, 340)); } bitmap1.Save("bitmap0.png", ImageFormat.Png); - bitmap1.ApplyBoxBlur(20); + bitmap1.ApplyBoxBlur(10); bitmap1.Save("bitmap1.png", ImageFormat.Png); using (var graphics = Graphics.FromImage(bitmap2)) diff --git a/src/Greenshot.Tests/Greenshot.Tests.csproj b/src/Greenshot.Tests/Greenshot.Tests.csproj index b57b8ee94..aacbe2222 100644 --- a/src/Greenshot.Tests/Greenshot.Tests.csproj +++ b/src/Greenshot.Tests/Greenshot.Tests.csproj @@ -72,6 +72,7 @@ + runtime; build; native; contentfiles; analyzers all @@ -94,7 +95,6 @@ - diff --git a/src/Greenshot.Tests/ScaleXTests.cs b/src/Greenshot.Tests/ScaleXTests.cs index 3a809eb65..791e59782 100644 --- a/src/Greenshot.Tests/ScaleXTests.cs +++ b/src/Greenshot.Tests/ScaleXTests.cs @@ -26,8 +26,7 @@ using System.Drawing.Imaging; using Dapplo.Log; using Dapplo.Log.XUnit; using Greenshot.Gfx; -using Greenshot.Gfx.Experimental; -using Greenshot.Gfx.Experimental.Structs; +using Greenshot.Gfx.Structs; using Xunit; using Xunit.Abstractions; diff --git a/src/Greenshot.sln b/src/Greenshot.sln index d60b67bac..393f785b8 100644 --- a/src/Greenshot.sln +++ b/src/Greenshot.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 16 -VisualStudioVersion = 16.0.28407.52 +# Visual Studio 15 +VisualStudioVersion = 15.0.28307.421 MinimumVisualStudioVersion = 10.0.40219.1 Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Greenshot", "Greenshot\Greenshot.csproj", "{CD642BF4-D815-4D67-A0B5-C69F0B8231AF}" EndProject @@ -41,8 +41,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Greenshot.Tests", "Greensho EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Greenshot.Addon.LegacyEditor", "Greenshot.Addon.LegacyEditor\Greenshot.Addon.LegacyEditor.csproj", "{9F89C5A0-EB75-4F01-97EB-FBC0725733F2}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Greenshot.Gfx.Experimental", "Greenshot.Gfx.Experimental\Greenshot.Gfx.Experimental.csproj", "{14894A45-AA2C-4BC3-85A3-E388D0BDC1CA}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Greenshot.Addon.OneDrive", "Greenshot.Addon.OneDrive\Greenshot.Addon.OneDrive.csproj", "{B35272D3-4631-4FA5-9A3E-85D70ECA9A8D}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Greenshot.Addon.Tfs", "Greenshot.Addon.Tfs\Greenshot.Addon.Tfs.csproj", "{8B3643A5-AFED-49FF-8D66-6348FB102EB2}" @@ -213,14 +211,6 @@ Global {9F89C5A0-EB75-4F01-97EB-FBC0725733F2}.Release|Any CPU.Build.0 = Release|Any CPU {9F89C5A0-EB75-4F01-97EB-FBC0725733F2}.Release|x86.ActiveCfg = Release|Any CPU {9F89C5A0-EB75-4F01-97EB-FBC0725733F2}.Release|x86.Build.0 = Release|Any CPU - {14894A45-AA2C-4BC3-85A3-E388D0BDC1CA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {14894A45-AA2C-4BC3-85A3-E388D0BDC1CA}.Debug|Any CPU.Build.0 = Debug|Any CPU - {14894A45-AA2C-4BC3-85A3-E388D0BDC1CA}.Debug|x86.ActiveCfg = Debug|Any CPU - {14894A45-AA2C-4BC3-85A3-E388D0BDC1CA}.Debug|x86.Build.0 = Debug|Any CPU - {14894A45-AA2C-4BC3-85A3-E388D0BDC1CA}.Release|Any CPU.ActiveCfg = Release|Any CPU - {14894A45-AA2C-4BC3-85A3-E388D0BDC1CA}.Release|Any CPU.Build.0 = Release|Any CPU - {14894A45-AA2C-4BC3-85A3-E388D0BDC1CA}.Release|x86.ActiveCfg = Release|Any CPU - {14894A45-AA2C-4BC3-85A3-E388D0BDC1CA}.Release|x86.Build.0 = Release|Any CPU {B35272D3-4631-4FA5-9A3E-85D70ECA9A8D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {B35272D3-4631-4FA5-9A3E-85D70ECA9A8D}.Debug|Any CPU.Build.0 = Debug|Any CPU {B35272D3-4631-4FA5-9A3E-85D70ECA9A8D}.Debug|x86.ActiveCfg = Debug|Any CPU diff --git a/src/Greenshot/Components/UpdateService.cs b/src/Greenshot/Components/UpdateService.cs index 08fc8a50d..be929d027 100644 --- a/src/Greenshot/Components/UpdateService.cs +++ b/src/Greenshot/Components/UpdateService.cs @@ -51,7 +51,7 @@ namespace Greenshot.Components { private static readonly LogSource Log = new LogSource(); private static readonly Regex VersionRegex = new Regex(@"^.*[^-]-(?[0-9\.]+)\-(?(release|beta|rc[0-9]+))\.exe.*", RegexOptions.Compiled | RegexOptions.IgnoreCase); - private static readonly Uri UpdateFeed = new Uri("http://getgreenshot.org/project-feed/"); + private static readonly Uri UpdateFeed = new Uri("https://getgreenshot.org/project-feed/"); private readonly CancellationTokenSource _cancellationTokenSource = new CancellationTokenSource(); private readonly ICoreConfiguration _coreConfiguration; @@ -93,7 +93,10 @@ namespace Greenshot.Components _updateNotificationViewModelFactory = updateNotificationViewModelFactory; var version = FileVersionInfo.GetVersionInfo(GetType().Assembly.Location); LatestVersion = CurrentVersion = new Version(version.FileMajorPart, version.FileMinorPart, version.FileBuildPart); - _coreConfiguration.LastSaveWithVersion = CurrentVersion.ToString(); + if (_coreConfiguration != null) + { + _coreConfiguration.LastSaveWithVersion = CurrentVersion.ToString(); + } } /// @@ -175,7 +178,11 @@ namespace Greenshot.Components { return; } - _coreConfiguration.LastUpdateCheck = DateTime.Now; + + if (_coreConfiguration != null) + { + _coreConfiguration.LastUpdateCheck = DateTime.Now; + } ProcessFeed(updateFeed); @@ -236,7 +243,8 @@ namespace Greenshot.Components { BetaVersion = version; } - if ("rc".Equals(type, StringComparison.OrdinalIgnoreCase)) + + if (type.StartsWith("rc", StringComparison.OrdinalIgnoreCase)) { ReleaseCandidateVersion = version; } diff --git a/src/Greenshot/Greenshot.csproj b/src/Greenshot/Greenshot.csproj index f2ae38d72..5769a4702 100644 --- a/src/Greenshot/Greenshot.csproj +++ b/src/Greenshot/Greenshot.csproj @@ -77,7 +77,7 @@ - + @@ -89,16 +89,16 @@ - - - + + + all runtime; build; native; contentfiles; analyzers - + @@ -108,6 +108,5 @@ - \ No newline at end of file