From 3999262cf8af4ff8fc4c8d9ebd0b8294aef98155 Mon Sep 17 00:00:00 2001 From: Jason Nelson Date: Wed, 3 Apr 2019 15:30:35 -0700 Subject: [PATCH 01/16] Update to vs2019 --- README.md | 2 +- appveyor.yml | 2 +- src/ImageSharp/ImageSharp.csproj | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index ceb28564b9..4bbad956b4 100644 --- a/README.md +++ b/README.md @@ -108,7 +108,7 @@ For more examples check out: If you prefer, you can compile ImageSharp yourself (please do and help!) -- Using [Visual Studio 2017](https://visualstudio.microsoft.com/vs/) +- Using [Visual Studio 2019](https://visualstudio.microsoft.com/vs/) - Make sure you have the latest version installed - Make sure you have [the .NET Core 2.1 SDK](https://www.microsoft.com/net/core#windows) installed diff --git a/appveyor.yml b/appveyor.yml index 2cc5182d39..dd0a4b09ab 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,5 +1,5 @@ version: 1.0.0.{build} -image: Visual Studio 2017 +image: Visual Studio 2019 # prevent the double build when a branch has an active PR skip_branch_with_pr: true diff --git a/src/ImageSharp/ImageSharp.csproj b/src/ImageSharp/ImageSharp.csproj index f7f9e1d5f4..2eb17ac3ad 100644 --- a/src/ImageSharp/ImageSharp.csproj +++ b/src/ImageSharp/ImageSharp.csproj @@ -25,7 +25,7 @@ portable True IOperation - 7.3 + preview From 5251ead6828fdf2eac211c86404a255855f9c2fe Mon Sep 17 00:00:00 2001 From: Jason Nelson Date: Wed, 3 Apr 2019 16:00:43 -0700 Subject: [PATCH 02/16] Use new switch syntax --- .../ICC/DataReader/IccDataReader.Curves.cs | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/ImageSharp/MetaData/Profiles/ICC/DataReader/IccDataReader.Curves.cs b/src/ImageSharp/MetaData/Profiles/ICC/DataReader/IccDataReader.Curves.cs index b27083dc49..6a6e590bad 100644 --- a/src/ImageSharp/MetaData/Profiles/ICC/DataReader/IccDataReader.Curves.cs +++ b/src/ImageSharp/MetaData/Profiles/ICC/DataReader/IccDataReader.Curves.cs @@ -24,7 +24,7 @@ public IccOneDimensionalCurve ReadOneDimensionalCurve() breakPoints[i] = this.ReadSingle(); } - IccCurveSegment[] segments = new IccCurveSegment[segmentCount]; + var segments = new IccCurveSegment[segmentCount]; for (int i = 0; i < segmentCount; i++) { segments[i] = this.ReadCurveSegment(); @@ -47,7 +47,7 @@ public IccResponseCurve ReadResponseCurve(int channelCount) measurement[i] = this.ReadUInt32(); } - Vector3[] xyzValues = new Vector3[channelCount]; + var xyzValues = new Vector3[channelCount]; for (int i = 0; i < channelCount; i++) { xyzValues[i] = this.ReadXyzNumber(); @@ -67,9 +67,9 @@ public IccResponseCurve ReadResponseCurve(int channelCount) } /// - /// Reads a + /// Reads a / /// - /// The read curve + /// The read curve. public IccParametricCurve ReadParametricCurve() { ushort type = this.ReadUInt16(); @@ -104,15 +104,15 @@ public IccParametricCurve ReadParametricCurve() f = this.ReadFix16(); } - switch (type) + return type switch { - case 0: return new IccParametricCurve(gamma); - case 1: return new IccParametricCurve(gamma, a, b); - case 2: return new IccParametricCurve(gamma, a, b, c); - case 3: return new IccParametricCurve(gamma, a, b, c, d); - case 4: return new IccParametricCurve(gamma, a, b, c, d, e, f); - default: throw new InvalidIccProfileException($"Invalid parametric curve type of {type}"); - } + 0 => new IccParametricCurve(gamma), + 1 => new IccParametricCurve(gamma, a, b), + 2 => new IccParametricCurve(gamma, a, b, c), + 3 => new IccParametricCurve(gamma, a, b, c, d), + 4 => new IccParametricCurve(gamma, a, b, c, d, e, f), + _ => throw new InvalidIccProfileException($"Invalid parametric curve type of {type}") + }; } /// From 06cb951689342e61871fdb1a21d4e6ca7810e2fb Mon Sep 17 00:00:00 2001 From: Jason Nelson Date: Wed, 3 Apr 2019 20:48:26 -0700 Subject: [PATCH 03/16] Update SDK --- .travis.yml | 2 +- src/ImageSharp.Drawing/ImageSharp.Drawing.csproj | 2 +- src/ImageSharp/ImageSharp.csproj | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 2515ca82a9..e54d98b17a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,7 +6,7 @@ matrix: - os: linux # Ubuntu 14.04 dist: trusty sudo: required - dotnet: 2.1.401 + dotnet: 2.1.602 mono: latest # - os: osx # OSX 10.11 # osx_image: xcode7.3.1 diff --git a/src/ImageSharp.Drawing/ImageSharp.Drawing.csproj b/src/ImageSharp.Drawing/ImageSharp.Drawing.csproj index 638687ae55..b3a1e95038 100644 --- a/src/ImageSharp.Drawing/ImageSharp.Drawing.csproj +++ b/src/ImageSharp.Drawing/ImageSharp.Drawing.csproj @@ -11,7 +11,7 @@ $(packageversion) 0.0.1 netcoreapp2.1;netstandard1.3;netstandard2.0 - 7.3 + 8.0 true true SixLabors.ImageSharp.Drawing diff --git a/src/ImageSharp/ImageSharp.csproj b/src/ImageSharp/ImageSharp.csproj index 2eb17ac3ad..e97d67d1fd 100644 --- a/src/ImageSharp/ImageSharp.csproj +++ b/src/ImageSharp/ImageSharp.csproj @@ -25,7 +25,7 @@ portable True IOperation - preview + 8.0 From 1358f9ccf6f61e2a8e742cb0a77ebb4987d1b5db Mon Sep 17 00:00:00 2001 From: Jason Nelson Date: Wed, 3 Apr 2019 20:59:13 -0700 Subject: [PATCH 04/16] Use switch expression --- src/ImageSharp/Formats/Bmp/BmpInfoHeader.cs | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/src/ImageSharp/Formats/Bmp/BmpInfoHeader.cs b/src/ImageSharp/Formats/Bmp/BmpInfoHeader.cs index 6da5f73e3f..b64f190ee2 100644 --- a/src/ImageSharp/Formats/Bmp/BmpInfoHeader.cs +++ b/src/ImageSharp/Formats/Bmp/BmpInfoHeader.cs @@ -372,21 +372,13 @@ public static BmpInfoHeader ParseOs2Version2(ReadOnlySpan data) // The compression value in OS/2 bitmap has a different meaning than in windows bitmaps. // Map the OS/2 value to the windows values. - switch (compression) + infoHeader.Compression = compression switch { - case 0: - infoHeader.Compression = BmpCompression.RGB; - break; - case 1: - infoHeader.Compression = BmpCompression.RLE8; - break; - case 2: - infoHeader.Compression = BmpCompression.RLE4; - break; - default: - BmpThrowHelper.ThrowImageFormatException($"Compression type is not supported. ImageSharp only supports uncompressed, RLE4 and RLE8."); - break; - } + 0 => BmpCompression.RGB, + 1 => BmpCompression.RLE8, + 2 => BmpCompression.RLE4, + _ => throw new ImageFormatException($"Compression type is not supported. ImageSharp only supports uncompressed, RLE4 and RLE8.") + }; infoHeader.ImageSize = BinaryPrimitives.ReadInt32LittleEndian(data.Slice(20, 4)); infoHeader.XPelsPerMeter = BinaryPrimitives.ReadInt32LittleEndian(data.Slice(24, 4)); From 5f2143d37a88a9d1000db56e20f807e413a8e654 Mon Sep 17 00:00:00 2001 From: Jason Nelson Date: Wed, 3 Apr 2019 21:02:10 -0700 Subject: [PATCH 05/16] Use preview image --- appveyor.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/appveyor.yml b/appveyor.yml index dd0a4b09ab..1fe0ff8714 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,5 +1,5 @@ version: 1.0.0.{build} -image: Visual Studio 2019 +image: Visual Studio 2019 Preview # prevent the double build when a branch has an active PR skip_branch_with_pr: true From 409011a9e36c734ed641486935faee3562c87f21 Mon Sep 17 00:00:00 2001 From: Jason Nelson Date: Mon, 8 Apr 2019 20:36:58 -0700 Subject: [PATCH 06/16] Manually install .NET SDK --- appveyor.yml | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/appveyor.yml b/appveyor.yml index 1fe0ff8714..3e6d298fdf 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,5 +1,5 @@ version: 1.0.0.{build} -image: Visual Studio 2019 Preview +image: Visual Studio 2017 # prevent the double build when a branch has an active PR skip_branch_with_pr: true @@ -43,6 +43,14 @@ install: } } + $sdkUrl = "https://dotnetcli.blob.core.windows.net/dotnet/Sdk/2.2.105/dotnet-sdk-2.2.105-win-x64.zi" + Write-Host "Installing .NET Core" + $env:DOTNET_INSTALL_DIR = "$path/.dotnetsdk" + New-Item -Type Directory $env:DOTNET_INSTALL_DIR -Force | Out-Null + (New-Object System.Net.WebClient).DownloadFile($urlCurrent, "dotnet.zip") + Write-Host "Unzipping to $env:DOTNET_INSTALL_DIR" + Add-Type -AssemblyName System.IO.Compression.FileSystem; [System.IO.Compression.ZipFile]::ExtractToDirectory("dotnet.zip", $env:DOTNET_INSTALL_DIR) + before_build: - git submodule -q update --init - cmd: dotnet --info From 0599a9f3e4cf3e496ce0db8ad03bb5597001e8fe Mon Sep 17 00:00:00 2001 From: Jason Nelson Date: Mon, 8 Apr 2019 20:38:49 -0700 Subject: [PATCH 07/16] Take 2 --- appveyor.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index 3e6d298fdf..65fa963645 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -43,11 +43,11 @@ install: } } - $sdkUrl = "https://dotnetcli.blob.core.windows.net/dotnet/Sdk/2.2.105/dotnet-sdk-2.2.105-win-x64.zi" + $sdkUrl = "https://dotnetcli.blob.core.windows.net/dotnet/Sdk/2.2.105/dotnet-sdk-2.2.105-win-x64.zip" Write-Host "Installing .NET Core" $env:DOTNET_INSTALL_DIR = "$path/.dotnetsdk" New-Item -Type Directory $env:DOTNET_INSTALL_DIR -Force | Out-Null - (New-Object System.Net.WebClient).DownloadFile($urlCurrent, "dotnet.zip") + (New-Object System.Net.WebClient).DownloadFile($sdkUrl, "dotnet.zip") Write-Host "Unzipping to $env:DOTNET_INSTALL_DIR" Add-Type -AssemblyName System.IO.Compression.FileSystem; [System.IO.Compression.ZipFile]::ExtractToDirectory("dotnet.zip", $env:DOTNET_INSTALL_DIR) From 1921873f9c0fe4c6092131c6a0ad16839145d9d6 Mon Sep 17 00:00:00 2001 From: Jason Nelson Date: Sat, 13 Apr 2019 15:39:00 -0700 Subject: [PATCH 08/16] Simplify ComputeColumns --- src/ImageSharp/Formats/Png/Adam7.cs | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/ImageSharp/Formats/Png/Adam7.cs b/src/ImageSharp/Formats/Png/Adam7.cs index 4e6485b55f..d1b2e03ef7 100644 --- a/src/ImageSharp/Formats/Png/Adam7.cs +++ b/src/ImageSharp/Formats/Png/Adam7.cs @@ -40,17 +40,17 @@ internal static class Adam7 [MethodImpl(MethodImplOptions.AggressiveInlining)] public static int ComputeColumns(int width, int passIndex) { - switch (passIndex) + return passIndex switch { - case 0: return (width + 7) / 8; - case 1: return (width + 3) / 8; - case 2: return (width + 3) / 4; - case 3: return (width + 1) / 4; - case 4: return (width + 1) / 2; - case 5: return width / 2; - case 6: return width; - default: throw new ArgumentException($"Not a valid pass index: {passIndex}"); - } + 0 => (width + 7) / 8, + 1 => (width + 3) / 8, + 2 => (width + 3) / 4, + 3 => (width + 1) / 4, + 4 => (width + 1) / 2, + 5 => width / 2, + 6 => width, + _ => throw new ArgumentException($"Not a valid pass index: {passIndex}") + }; } } } \ No newline at end of file From 438ec8c652993697141c0815383dd67a8b250560 Mon Sep 17 00:00:00 2001 From: Jason Nelson Date: Thu, 18 Apr 2019 19:50:09 -0700 Subject: [PATCH 09/16] Update appveyor.yml --- appveyor.yml | 8 -------- 1 file changed, 8 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index 65fa963645..2cc5182d39 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -43,14 +43,6 @@ install: } } - $sdkUrl = "https://dotnetcli.blob.core.windows.net/dotnet/Sdk/2.2.105/dotnet-sdk-2.2.105-win-x64.zip" - Write-Host "Installing .NET Core" - $env:DOTNET_INSTALL_DIR = "$path/.dotnetsdk" - New-Item -Type Directory $env:DOTNET_INSTALL_DIR -Force | Out-Null - (New-Object System.Net.WebClient).DownloadFile($sdkUrl, "dotnet.zip") - Write-Host "Unzipping to $env:DOTNET_INSTALL_DIR" - Add-Type -AssemblyName System.IO.Compression.FileSystem; [System.IO.Compression.ZipFile]::ExtractToDirectory("dotnet.zip", $env:DOTNET_INSTALL_DIR) - before_build: - git submodule -q update --init - cmd: dotnet --info From ee49808d0809955ec99aea38e654fad63ca79feb Mon Sep 17 00:00:00 2001 From: Jason Nelson Date: Thu, 18 Apr 2019 20:03:02 -0700 Subject: [PATCH 10/16] Use new compound assignment operator --- src/ImageSharp/Formats/Jpeg/JpegEncoderCore.cs | 2 +- src/ImageSharp/Formats/Png/PngEncoderCore.cs | 6 +++--- src/ImageSharp/Image.FromFile.cs | 2 +- src/ImageSharp/Image.FromStream.cs | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/ImageSharp/Formats/Jpeg/JpegEncoderCore.cs b/src/ImageSharp/Formats/Jpeg/JpegEncoderCore.cs index d4ce28107f..8b9c6d093e 100644 --- a/src/ImageSharp/Formats/Jpeg/JpegEncoderCore.cs +++ b/src/ImageSharp/Formats/Jpeg/JpegEncoderCore.cs @@ -208,7 +208,7 @@ public void Encode(Image image, Stream stream) // System.Drawing produces identical output for jpegs with a quality parameter of 0 and 1. int qlty = (this.quality ?? metadata.GetFormatMetadata(JpegFormat.Instance).Quality).Clamp(1, 100); - this.subsample = this.subsample ?? (qlty >= 91 ? JpegSubsample.Ratio444 : JpegSubsample.Ratio420); + this.subsample ??= qlty >= 91 ? JpegSubsample.Ratio444 : JpegSubsample.Ratio420; // Convert from a quality rating to a scaling factor. int scale; diff --git a/src/ImageSharp/Formats/Png/PngEncoderCore.cs b/src/ImageSharp/Formats/Png/PngEncoderCore.cs index 7415b07532..61f917a928 100644 --- a/src/ImageSharp/Formats/Png/PngEncoderCore.cs +++ b/src/ImageSharp/Formats/Png/PngEncoderCore.cs @@ -213,10 +213,10 @@ public void Encode(Image image, Stream stream) // Always take the encoder options over the metadata values. ImageMetadata metadata = image.Metadata; PngMetadata pngMetadata = metadata.GetFormatMetadata(PngFormat.Instance); - this.gamma = this.gamma ?? pngMetadata.Gamma; + this.gamma ??= pngMetadata.Gamma; this.writeGamma = this.gamma > 0; - this.pngColorType = this.pngColorType ?? pngMetadata.ColorType; - this.pngBitDepth = this.pngBitDepth ?? pngMetadata.BitDepth; + this.pngColorType ??= pngMetadata.ColorType; + this.pngBitDepth ??= pngMetadata.BitDepth; this.use16Bit = this.pngBitDepth == PngBitDepth.Bit16; // Ensure we are not allowing impossible combinations. diff --git a/src/ImageSharp/Image.FromFile.cs b/src/ImageSharp/Image.FromFile.cs index b13cef4824..37cc2eeafd 100644 --- a/src/ImageSharp/Image.FromFile.cs +++ b/src/ImageSharp/Image.FromFile.cs @@ -31,7 +31,7 @@ public static IImageFormat DetectFormat(string filePath) /// The mime type or null if none found. public static IImageFormat DetectFormat(Configuration config, string filePath) { - config = config ?? Configuration.Default; + config ??= Configuration.Default; using (Stream file = config.FileSystem.OpenRead(filePath)) { return DetectFormat(config, file); diff --git a/src/ImageSharp/Image.FromStream.cs b/src/ImageSharp/Image.FromStream.cs index 3236e00072..239da763b7 100644 --- a/src/ImageSharp/Image.FromStream.cs +++ b/src/ImageSharp/Image.FromStream.cs @@ -173,7 +173,7 @@ public static Image Load(Configuration config, Stream stream) public static Image Load(Configuration config, Stream stream, out IImageFormat format) where TPixel : struct, IPixel { - config = config ?? Configuration.Default; + config ??= Configuration.Default; (Image img, IImageFormat format) data = WithSeekableStream(config, stream, s => Decode(s, config)); format = data.format; From bb4957071efe9d629bc1bf284b117b6ef3d0837c Mon Sep 17 00:00:00 2001 From: Jason Nelson Date: Thu, 18 Apr 2019 20:03:10 -0700 Subject: [PATCH 11/16] Update .travis.yml --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index e54d98b17a..1482307063 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,7 +6,7 @@ matrix: - os: linux # Ubuntu 14.04 dist: trusty sudo: required - dotnet: 2.1.602 + dotnet: 2.2.203 mono: latest # - os: osx # OSX 10.11 # osx_image: xcode7.3.1 From 2a10d540b1d6d48b255f5baa9ec26c5b1b147963 Mon Sep 17 00:00:00 2001 From: Jason Nelson Date: Thu, 18 Apr 2019 20:30:25 -0700 Subject: [PATCH 12/16] Travis take 2 --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 1482307063..190446245d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,7 +6,7 @@ matrix: - os: linux # Ubuntu 14.04 dist: trusty sudo: required - dotnet: 2.2.203 + dotnet: 2.2 mono: latest # - os: osx # OSX 10.11 # osx_image: xcode7.3.1 From d241d963b085f830008ada4c522b3af52cc1b384 Mon Sep 17 00:00:00 2001 From: Jason Nelson Date: Thu, 18 Apr 2019 20:44:31 -0700 Subject: [PATCH 13/16] Take 3 --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 190446245d..22d70643a0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,7 +6,7 @@ matrix: - os: linux # Ubuntu 14.04 dist: trusty sudo: required - dotnet: 2.2 + dotnet: 2.2.4 mono: latest # - os: osx # OSX 10.11 # osx_image: xcode7.3.1 From 0622914f2583cb5a9ee649059c1e8d03b7620c87 Mon Sep 17 00:00:00 2001 From: Jason Nelson Date: Thu, 18 Apr 2019 20:48:23 -0700 Subject: [PATCH 14/16] Take 4 --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 22d70643a0..c6efd79cb3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,7 +6,7 @@ matrix: - os: linux # Ubuntu 14.04 dist: trusty sudo: required - dotnet: 2.2.4 + dotnet: 2.2.106 mono: latest # - os: osx # OSX 10.11 # osx_image: xcode7.3.1 From 02ddecd52846f1b857075a77e2a9fe69d474b5b4 Mon Sep 17 00:00:00 2001 From: Jason Nelson Date: Fri, 19 Apr 2019 14:05:28 -0700 Subject: [PATCH 15/16] [Travis] Try dotnet 2.1.603 SDK --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index c6efd79cb3..743cf011cd 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,7 +6,7 @@ matrix: - os: linux # Ubuntu 14.04 dist: trusty sudo: required - dotnet: 2.2.106 + dotnet: 2.1.603 mono: latest # - os: osx # OSX 10.11 # osx_image: xcode7.3.1 From 57ab2d8e374d5620510089f0334a6d41236f0bd0 Mon Sep 17 00:00:00 2001 From: Jason Nelson Date: Fri, 19 Apr 2019 19:52:15 -0700 Subject: [PATCH 16/16] Update travis build to use Ubuntu 16.04 --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 743cf011cd..6fd38484dd 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,8 +3,8 @@ solution: ImageSharp.sln matrix: include: - - os: linux # Ubuntu 14.04 - dist: trusty + - os: linux # Ubuntu 16.04 + dist: xenial sudo: required dotnet: 2.1.603 mono: latest