From 862c939a3a2da3f0d218d0fc2ef9eacaf39a6b30 Mon Sep 17 00:00:00 2001 From: Stefan Nikolei Date: Sat, 23 Jan 2021 14:15:32 +0100 Subject: [PATCH 01/11] Add net5.0 target * add it in ImageSharp.csproj * update Buildscript --- .github/workflows/build-and-test.yml | 12 ++++++++++++ src/ImageSharp/ImageSharp.csproj | 2 +- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index 9e760c4b23..778e27e51f 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -14,6 +14,18 @@ jobs: strategy: matrix: options: + - os: ubuntu-latest + framework: net5.0 + runtime: -x64 + codecov: true + - os: macos-latest + framework: net5.0 + runtime: -x64 + codecov: false + - os: windows-latest + framework: net5.0 + runtime: -x64 + codecov: false - os: ubuntu-latest framework: netcoreapp3.1 runtime: -x64 diff --git a/src/ImageSharp/ImageSharp.csproj b/src/ImageSharp/ImageSharp.csproj index a90aaf715a..ea32661ddb 100644 --- a/src/ImageSharp/ImageSharp.csproj +++ b/src/ImageSharp/ImageSharp.csproj @@ -12,7 +12,7 @@ $(RepositoryUrl) Image Resize Crop Gif Jpg Jpeg Bitmap Png Tga NetCore A new, fully featured, fully managed, cross-platform, 2D graphics API for .NET - netcoreapp3.1;netcoreapp2.1;netstandard2.1;netstandard2.0;netstandard1.3;net472 + net5.0;netcoreapp3.1;netcoreapp2.1;netstandard2.1;netstandard2.0;netstandard1.3;net472 From 72037f46f80781fb99e3906da61f3f7196b1a97e Mon Sep 17 00:00:00 2001 From: Stefan Nikolei Date: Sat, 23 Jan 2021 14:19:16 +0100 Subject: [PATCH 02/11] add .net5.0 targetframework in tests --- tests/ImageSharp.Benchmarks/ImageSharp.Benchmarks.csproj | 2 +- .../ImageSharp.Tests.ProfilingSandbox.csproj | 2 +- tests/ImageSharp.Tests/ImageSharp.Tests.csproj | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/ImageSharp.Benchmarks/ImageSharp.Benchmarks.csproj b/tests/ImageSharp.Benchmarks/ImageSharp.Benchmarks.csproj index 2a209683ba..d89cf79fc9 100644 --- a/tests/ImageSharp.Benchmarks/ImageSharp.Benchmarks.csproj +++ b/tests/ImageSharp.Benchmarks/ImageSharp.Benchmarks.csproj @@ -5,7 +5,7 @@ ImageSharp.Benchmarks Exe SixLabors.ImageSharp.Benchmarks - netcoreapp3.1;netcoreapp2.1;net472 + net5.0;netcoreapp3.1;netcoreapp2.1;net472 false false diff --git a/tests/ImageSharp.Tests.ProfilingSandbox/ImageSharp.Tests.ProfilingSandbox.csproj b/tests/ImageSharp.Tests.ProfilingSandbox/ImageSharp.Tests.ProfilingSandbox.csproj index b71b5ebf2f..220780c58e 100644 --- a/tests/ImageSharp.Tests.ProfilingSandbox/ImageSharp.Tests.ProfilingSandbox.csproj +++ b/tests/ImageSharp.Tests.ProfilingSandbox/ImageSharp.Tests.ProfilingSandbox.csproj @@ -8,7 +8,7 @@ false SixLabors.ImageSharp.Tests.ProfilingSandbox win7-x64 - netcoreapp3.1;netcoreapp2.1;net472 + net5.0;netcoreapp3.1;netcoreapp2.1;net472 SixLabors.ImageSharp.Tests.ProfilingSandbox.Program false diff --git a/tests/ImageSharp.Tests/ImageSharp.Tests.csproj b/tests/ImageSharp.Tests/ImageSharp.Tests.csproj index 5426144401..ebbe2cbdfa 100644 --- a/tests/ImageSharp.Tests/ImageSharp.Tests.csproj +++ b/tests/ImageSharp.Tests/ImageSharp.Tests.csproj @@ -2,7 +2,7 @@ - netcoreapp3.1;netcoreapp2.1;net472 + net5.0;netcoreapp3.1;netcoreapp2.1;net472 True SixLabors.ImageSharp.Tests AnyCPU;x64;x86 From 58491c9c12fa2ee44c2fb976b2465ea6936a4d1f Mon Sep 17 00:00:00 2001 From: Stefan Nikolei Date: Sat, 23 Jan 2021 16:38:18 +0100 Subject: [PATCH 03/11] remove .net50 target framework --- src/ImageSharp/ImageSharp.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ImageSharp/ImageSharp.csproj b/src/ImageSharp/ImageSharp.csproj index ea32661ddb..a90aaf715a 100644 --- a/src/ImageSharp/ImageSharp.csproj +++ b/src/ImageSharp/ImageSharp.csproj @@ -12,7 +12,7 @@ $(RepositoryUrl) Image Resize Crop Gif Jpg Jpeg Bitmap Png Tga NetCore A new, fully featured, fully managed, cross-platform, 2D graphics API for .NET - net5.0;netcoreapp3.1;netcoreapp2.1;netstandard2.1;netstandard2.0;netstandard1.3;net472 + netcoreapp3.1;netcoreapp2.1;netstandard2.1;netstandard2.0;netstandard1.3;net472 From 3fad302539a178a72703fb425f7d845dd92c95a2 Mon Sep 17 00:00:00 2001 From: Stefan Nikolei Date: Sat, 23 Jan 2021 16:42:54 +0100 Subject: [PATCH 04/11] codecov only on one target --- .github/workflows/build-and-test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index 778e27e51f..4da7813a8a 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -17,7 +17,7 @@ jobs: - os: ubuntu-latest framework: net5.0 runtime: -x64 - codecov: true + codecov: false - os: macos-latest framework: net5.0 runtime: -x64 From 37709f941e4371cb3d99dd16f5739c9e1b9d7d55 Mon Sep 17 00:00:00 2001 From: Stefan Nikolei Date: Mon, 25 Jan 2021 15:34:41 +0100 Subject: [PATCH 05/11] test and build framework can be different --- .github/workflows/build-and-test.yml | 31 ++++++++++++++++++---------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index 4da7813a8a..579a547ea6 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -15,39 +15,48 @@ jobs: matrix: options: - os: ubuntu-latest - framework: net5.0 + framework-build: netcoreapp3.1 + framework-test: net5.0 runtime: -x64 codecov: false - os: macos-latest - framework: net5.0 + framework-build: netcoreapp3.1 + framework-test: net5.0 runtime: -x64 codecov: false - os: windows-latest - framework: net5.0 + framework-build: netcoreapp3.1 + framework-test: net5.0 runtime: -x64 codecov: false - os: ubuntu-latest - framework: netcoreapp3.1 + framework-build: netcoreapp3.1 + framework-test: netcoreapp3.1 runtime: -x64 codecov: true - os: macos-latest - framework: netcoreapp3.1 + framework-build: netcoreapp3.1 + framework-test: netcoreapp3.1 runtime: -x64 codecov: false - os: windows-latest - framework: netcoreapp3.1 + framework-build: netcoreapp3.1 + framework-test: netcoreapp3.1 runtime: -x64 codecov: false - os: windows-latest - framework: netcoreapp2.1 + framework-build: netcoreapp2.1 + framework-test: netcoreapp2.1 runtime: -x64 codecov: false - os: windows-latest - framework: net472 + framework-build: net472 + framework-test: net472 runtime: -x64 codecov: false - os: windows-latest - framework: net472 + framework-build: net472 + framework-test: net472 runtime: -x86 codecov: false @@ -78,11 +87,11 @@ jobs: - name: Build shell: pwsh - run: ./ci-build.ps1 "${{matrix.options.framework}}" + run: ./ci-build.ps1 "${{matrix.options.framework-build}}" - name: Test shell: pwsh - run: ./ci-test.ps1 "${{matrix.options.os}}" "${{matrix.options.framework}}" "${{matrix.options.runtime}}" "${{matrix.options.codecov}}" + run: ./ci-test.ps1 "${{matrix.options.os}}" "${{matrix.options.framework-test}}" "${{matrix.options.runtime}}" "${{matrix.options.codecov}}" env: CI: True XUNIT_PATH: .\tests\ImageSharp.Tests # Required for xunit From e5f640182c692cf7030669c3fe65fcdad5782a1b Mon Sep 17 00:00:00 2001 From: Stefan Nikolei Date: Wed, 27 Jan 2021 21:52:01 +0100 Subject: [PATCH 06/11] use CI environment variable to also build on .net5.0 --- .github/workflows/build-and-test.yml | 31 ++++++++++------------------ src/ImageSharp/ImageSharp.csproj | 7 +++++++ 2 files changed, 18 insertions(+), 20 deletions(-) diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index 579a547ea6..4da7813a8a 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -15,48 +15,39 @@ jobs: matrix: options: - os: ubuntu-latest - framework-build: netcoreapp3.1 - framework-test: net5.0 + framework: net5.0 runtime: -x64 codecov: false - os: macos-latest - framework-build: netcoreapp3.1 - framework-test: net5.0 + framework: net5.0 runtime: -x64 codecov: false - os: windows-latest - framework-build: netcoreapp3.1 - framework-test: net5.0 + framework: net5.0 runtime: -x64 codecov: false - os: ubuntu-latest - framework-build: netcoreapp3.1 - framework-test: netcoreapp3.1 + framework: netcoreapp3.1 runtime: -x64 codecov: true - os: macos-latest - framework-build: netcoreapp3.1 - framework-test: netcoreapp3.1 + framework: netcoreapp3.1 runtime: -x64 codecov: false - os: windows-latest - framework-build: netcoreapp3.1 - framework-test: netcoreapp3.1 + framework: netcoreapp3.1 runtime: -x64 codecov: false - os: windows-latest - framework-build: netcoreapp2.1 - framework-test: netcoreapp2.1 + framework: netcoreapp2.1 runtime: -x64 codecov: false - os: windows-latest - framework-build: net472 - framework-test: net472 + framework: net472 runtime: -x64 codecov: false - os: windows-latest - framework-build: net472 - framework-test: net472 + framework: net472 runtime: -x86 codecov: false @@ -87,11 +78,11 @@ jobs: - name: Build shell: pwsh - run: ./ci-build.ps1 "${{matrix.options.framework-build}}" + run: ./ci-build.ps1 "${{matrix.options.framework}}" - name: Test shell: pwsh - run: ./ci-test.ps1 "${{matrix.options.os}}" "${{matrix.options.framework-test}}" "${{matrix.options.runtime}}" "${{matrix.options.codecov}}" + run: ./ci-test.ps1 "${{matrix.options.os}}" "${{matrix.options.framework}}" "${{matrix.options.runtime}}" "${{matrix.options.codecov}}" env: CI: True XUNIT_PATH: .\tests\ImageSharp.Tests # Required for xunit diff --git a/src/ImageSharp/ImageSharp.csproj b/src/ImageSharp/ImageSharp.csproj index a90aaf715a..e0da2abf0d 100644 --- a/src/ImageSharp/ImageSharp.csproj +++ b/src/ImageSharp/ImageSharp.csproj @@ -12,9 +12,16 @@ $(RepositoryUrl) Image Resize Crop Gif Jpg Jpeg Bitmap Png Tga NetCore A new, fully featured, fully managed, cross-platform, 2D graphics API for .NET + + + netcoreapp3.1;netcoreapp2.1;netstandard2.1;netstandard2.0;netstandard1.3;net472 + + net5.0;netcoreapp3.1;netcoreapp2.1;netstandard2.1;netstandard2.0;netstandard1.3;net472 + + From fb508475ebe20057391c88006b02489470050fa7 Mon Sep 17 00:00:00 2001 From: Jeff Skaistis Date: Sat, 30 Jan 2021 11:49:47 -0600 Subject: [PATCH 07/11] Change size guards for WrapMemory to allow Memory/IMemoryOwner blocks larger than the required image size. --- src/ImageSharp/Image.WrapMemory.cs | 30 ++++++------ .../Image/ImageTests.WrapMemory.cs | 48 ++++++++++++++++--- 2 files changed, 57 insertions(+), 21 deletions(-) diff --git a/src/ImageSharp/Image.WrapMemory.cs b/src/ImageSharp/Image.WrapMemory.cs index 383f643969..b0efdb60db 100644 --- a/src/ImageSharp/Image.WrapMemory.cs +++ b/src/ImageSharp/Image.WrapMemory.cs @@ -17,7 +17,7 @@ namespace SixLabors.ImageSharp { /// /// - /// Wraps an existing contiguous memory area of 'width' x 'height' pixels allowing viewing/manipulation as + /// Wraps an existing contiguous memory area of at least 'width' x 'height' pixels allowing viewing/manipulation as /// an instance. /// /// @@ -52,7 +52,7 @@ namespace SixLabors.ImageSharp { Guard.NotNull(configuration, nameof(configuration)); Guard.NotNull(metadata, nameof(metadata)); - Guard.IsTrue(pixelMemory.Length == width * height, nameof(pixelMemory), "The length of the input memory doesn't match the specified image size"); + Guard.IsTrue(pixelMemory.Length >= width * height, nameof(pixelMemory), "The length of the input memory is less than the specified image size"); var memorySource = MemoryGroup.Wrap(pixelMemory); return new Image(configuration, memorySource, width, height, metadata); @@ -60,7 +60,7 @@ namespace SixLabors.ImageSharp /// /// - /// Wraps an existing contiguous memory area of 'width' x 'height' pixels allowing viewing/manipulation as + /// Wraps an existing contiguous memory area of at least 'width' x 'height' pixels allowing viewing/manipulation as /// an instance. /// /// @@ -93,7 +93,7 @@ namespace SixLabors.ImageSharp /// /// - /// Wraps an existing contiguous memory area of 'width' x 'height' pixels allowing viewing/manipulation as + /// Wraps an existing contiguous memory area of at least 'width' x 'height' pixels allowing viewing/manipulation as /// an instance. /// /// @@ -122,7 +122,7 @@ namespace SixLabors.ImageSharp => WrapMemory(Configuration.Default, pixelMemory, width, height); /// - /// Wraps an existing contiguous memory area of 'width' x 'height' pixels, + /// Wraps an existing contiguous memory area of at least 'width' x 'height' pixels, /// allowing to view/manipulate it as an instance. /// The ownership of the is being transferred to the new instance, /// meaning that the caller is not allowed to dispose . @@ -147,14 +147,14 @@ namespace SixLabors.ImageSharp { Guard.NotNull(configuration, nameof(configuration)); Guard.NotNull(metadata, nameof(metadata)); - Guard.IsTrue(pixelMemoryOwner.Memory.Length == width * height, nameof(pixelMemoryOwner), "The length of the input memory doesn't match the specified image size"); + Guard.IsTrue(pixelMemoryOwner.Memory.Length >= width * height, nameof(pixelMemoryOwner), "The length of the input memory is less than the specified image size"); var memorySource = MemoryGroup.Wrap(pixelMemoryOwner); return new Image(configuration, memorySource, width, height, metadata); } /// - /// Wraps an existing contiguous memory area of 'width' x 'height' pixels, + /// Wraps an existing contiguous memory area of at least 'width' x 'height' pixels, /// allowing to view/manipulate it as an instance. /// The ownership of the is being transferred to the new instance, /// meaning that the caller is not allowed to dispose . @@ -176,7 +176,7 @@ namespace SixLabors.ImageSharp => WrapMemory(configuration, pixelMemoryOwner, width, height, new ImageMetadata()); /// - /// Wraps an existing contiguous memory area of 'width' x 'height' pixels, + /// Wraps an existing contiguous memory area of at least 'width' x 'height' pixels, /// allowing to view/manipulate it as an instance. /// The ownership of the is being transferred to the new instance, /// meaning that the caller is not allowed to dispose . @@ -196,7 +196,7 @@ namespace SixLabors.ImageSharp /// /// - /// Wraps an existing contiguous memory area of 'width' x 'height' pixels allowing viewing/manipulation as + /// Wraps an existing contiguous memory area of at least 'width' x 'height' pixels allowing viewing/manipulation as /// an instance. /// /// @@ -234,7 +234,7 @@ namespace SixLabors.ImageSharp var memoryManager = new ByteMemoryManager(byteMemory); - Guard.IsTrue(memoryManager.Memory.Length == width * height, nameof(byteMemory), "The length of the input memory doesn't match the specified image size"); + Guard.IsTrue(memoryManager.Memory.Length >= width * height, nameof(byteMemory), "The length of the input memory is less than the specified image size"); var memorySource = MemoryGroup.Wrap(memoryManager.Memory); return new Image(configuration, memorySource, width, height, metadata); @@ -242,7 +242,7 @@ namespace SixLabors.ImageSharp /// /// - /// Wraps an existing contiguous memory area of 'width' x 'height' pixels allowing viewing/manipulation as + /// Wraps an existing contiguous memory area of at least 'width' x 'height' pixels allowing viewing/manipulation as /// an instance. /// /// @@ -275,7 +275,7 @@ namespace SixLabors.ImageSharp /// /// - /// Wraps an existing contiguous memory area of 'width' x 'height' pixels allowing viewing/manipulation as + /// Wraps an existing contiguous memory area of at least 'width' x 'height' pixels allowing viewing/manipulation as /// an instance. /// /// @@ -305,7 +305,7 @@ namespace SixLabors.ImageSharp /// /// - /// Wraps an existing contiguous memory area of 'width' x 'height' pixels allowing viewing/manipulation as + /// Wraps an existing contiguous memory area of at least 'width' x 'height' pixels allowing viewing/manipulation as /// an instance. /// /// @@ -355,7 +355,7 @@ namespace SixLabors.ImageSharp /// /// - /// Wraps an existing contiguous memory area of 'width' x 'height' pixels allowing viewing/manipulation as + /// Wraps an existing contiguous memory area of at least 'width' x 'height' pixels allowing viewing/manipulation as /// an instance. /// /// @@ -393,7 +393,7 @@ namespace SixLabors.ImageSharp /// /// - /// Wraps an existing contiguous memory area of 'width' x 'height' pixels allowing viewing/manipulation as + /// Wraps an existing contiguous memory area of at least 'width' x 'height' pixels allowing viewing/manipulation as /// an instance. /// /// diff --git a/tests/ImageSharp.Tests/Image/ImageTests.WrapMemory.cs b/tests/ImageSharp.Tests/Image/ImageTests.WrapMemory.cs index 02a8381808..16d0baff39 100644 --- a/tests/ImageSharp.Tests/Image/ImageTests.WrapMemory.cs +++ b/tests/ImageSharp.Tests/Image/ImageTests.WrapMemory.cs @@ -355,8 +355,6 @@ namespace SixLabors.ImageSharp.Tests [Theory] [InlineData(0, 5, 5)] [InlineData(20, 5, 5)] - [InlineData(26, 5, 5)] - [InlineData(2, 1, 1)] [InlineData(1023, 32, 32)] public void WrapMemory_MemoryOfT_InvalidSize(int size, int height, int width) { @@ -366,6 +364,20 @@ namespace SixLabors.ImageSharp.Tests Assert.Throws(() => Image.WrapMemory(memory, height, width)); } + [Theory] + [InlineData(25, 5, 5)] + [InlineData(26, 5, 5)] + [InlineData(2, 1, 1)] + [InlineData(1024, 32, 32)] + [InlineData(2048, 32, 32)] + public void WrapMemory_MemoryOfT_ValidSize(int size, int height, int width) + { + var array = new Rgba32[size]; + var memory = new Memory(array); + + Image.WrapMemory(memory, height, width); + } + private class TestMemoryOwner : IMemoryOwner { public Memory Memory { get; set; } @@ -378,8 +390,6 @@ namespace SixLabors.ImageSharp.Tests [Theory] [InlineData(0, 5, 5)] [InlineData(20, 5, 5)] - [InlineData(26, 5, 5)] - [InlineData(2, 1, 1)] [InlineData(1023, 32, 32)] public void WrapMemory_IMemoryOwnerOfT_InvalidSize(int size, int height, int width) { @@ -390,10 +400,22 @@ namespace SixLabors.ImageSharp.Tests } [Theory] - [InlineData(0, 5, 5)] - [InlineData(20, 5, 5)] + [InlineData(25, 5, 5)] [InlineData(26, 5, 5)] [InlineData(2, 1, 1)] + [InlineData(1024, 32, 32)] + [InlineData(2048, 32, 32)] + public void WrapMemory_IMemoryOwnerOfT_ValidSize(int size, int height, int width) + { + var array = new Rgba32[size]; + var memory = new TestMemoryOwner { Memory = array }; + + Image.WrapMemory(memory, height, width); + } + + [Theory] + [InlineData(0, 5, 5)] + [InlineData(20, 5, 5)] [InlineData(1023, 32, 32)] public void WrapMemory_MemoryOfByte_InvalidSize(int size, int height, int width) { @@ -403,6 +425,20 @@ namespace SixLabors.ImageSharp.Tests Assert.Throws(() => Image.WrapMemory(memory, height, width)); } + [Theory] + [InlineData(25, 5, 5)] + [InlineData(26, 5, 5)] + [InlineData(2, 1, 1)] + [InlineData(1024, 32, 32)] + [InlineData(2048, 32, 32)] + public void WrapMemory_MemoryOfByte_ValidSize(int size, int height, int width) + { + var array = new byte[size * Unsafe.SizeOf()]; + var memory = new Memory(array); + + Image.WrapMemory(memory, height, width); + } + [Theory] [InlineData(0, 5, 5)] [InlineData(20, 5, 5)] From fd22d81c7661515c7c7af977b4e9c4ee59ef740b Mon Sep 17 00:00:00 2001 From: Stefan Nikolei Date: Mon, 1 Feb 2021 06:42:06 +0100 Subject: [PATCH 08/11] update submodule shared-infrastructure --- shared-infrastructure | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shared-infrastructure b/shared-infrastructure index b7b9a2755e..af824b8bad 160000 --- a/shared-infrastructure +++ b/shared-infrastructure @@ -1 +1 @@ -Subproject commit b7b9a2755e456a96acbf103494228226d92eddf3 +Subproject commit af824b8bad7307b735662e3eeab39d401c41741c From cf63cd22186707fdc2e2474982dba50ab3a1d6f0 Mon Sep 17 00:00:00 2001 From: Stefan Nikolei Date: Mon, 1 Feb 2021 06:42:52 +0100 Subject: [PATCH 09/11] use when and otherwise in csproj --- src/ImageSharp/ImageSharp.csproj | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/src/ImageSharp/ImageSharp.csproj b/src/ImageSharp/ImageSharp.csproj index e0da2abf0d..6a7f7a600d 100644 --- a/src/ImageSharp/ImageSharp.csproj +++ b/src/ImageSharp/ImageSharp.csproj @@ -14,13 +14,18 @@ A new, fully featured, fully managed, cross-platform, 2D graphics API for .NET - - netcoreapp3.1;netcoreapp2.1;netstandard2.1;netstandard2.0;netstandard1.3;net472 - - - - net5.0;netcoreapp3.1;netcoreapp2.1;netstandard2.1;netstandard2.0;netstandard1.3;net472 - + + + + net5.0;netcoreapp3.1;netcoreapp2.1;netstandard2.1;netstandard2.0;netstandard1.3;net472 + + + + + netcoreapp3.1;netcoreapp2.1;netstandard2.1;netstandard2.0;netstandard1.3;net472 + + + From a060d5c37e9c1f83a26186d62749d58a8fd72a01 Mon Sep 17 00:00:00 2001 From: Stefan Nikolei Date: Mon, 1 Feb 2021 07:36:05 +0100 Subject: [PATCH 10/11] USE SIXLABORS_TESTING instead of CI Env var --- .github/workflows/build-and-test.yml | 4 +++- src/ImageSharp/ImageSharp.csproj | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index 4da7813a8a..67259c04f7 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -79,12 +79,14 @@ jobs: - name: Build shell: pwsh run: ./ci-build.ps1 "${{matrix.options.framework}}" + env: + SIXLABORS_TESTING: True - name: Test shell: pwsh run: ./ci-test.ps1 "${{matrix.options.os}}" "${{matrix.options.framework}}" "${{matrix.options.runtime}}" "${{matrix.options.codecov}}" env: - CI: True + SIXLABORS_TESTING: True XUNIT_PATH: .\tests\ImageSharp.Tests # Required for xunit - name: Export Failed Output diff --git a/src/ImageSharp/ImageSharp.csproj b/src/ImageSharp/ImageSharp.csproj index 6a7f7a600d..ca6ca16898 100644 --- a/src/ImageSharp/ImageSharp.csproj +++ b/src/ImageSharp/ImageSharp.csproj @@ -15,7 +15,7 @@ - + net5.0;netcoreapp3.1;netcoreapp2.1;netstandard2.1;netstandard2.0;netstandard1.3;net472 From f1a8e6e76339e017406fb7d725ced83540a4540d Mon Sep 17 00:00:00 2001 From: James Jackson-South Date: Tue, 2 Feb 2021 17:25:40 +0000 Subject: [PATCH 11/11] Santize descriptor bounds. Fixes #1530 --- src/ImageSharp/Formats/Gif/GifDecoderCore.cs | 3 ++- .../ImageSharp.Tests/Formats/Gif/GifDecoderTests.cs | 12 ++++++++++++ tests/ImageSharp.Tests/TestImages.cs | 1 + tests/Images/External | 2 +- tests/Images/Input/Gif/issues/issue1530.gif | 3 +++ 5 files changed, 19 insertions(+), 2 deletions(-) create mode 100644 tests/Images/Input/Gif/issues/issue1530.gif diff --git a/src/ImageSharp/Formats/Gif/GifDecoderCore.cs b/src/ImageSharp/Formats/Gif/GifDecoderCore.cs index 8f5cc3b5c8..2f6b45aff9 100644 --- a/src/ImageSharp/Formats/Gif/GifDecoderCore.cs +++ b/src/ImageSharp/Formats/Gif/GifDecoderCore.cs @@ -535,7 +535,8 @@ namespace SixLabors.ImageSharp.Formats.Gif return; } - Buffer2DRegion pixelRegion = frame.PixelBuffer.GetRegion(this.restoreArea.Value); + var interest = Rectangle.Intersect(frame.Bounds(), this.restoreArea.Value); + Buffer2DRegion pixelRegion = frame.PixelBuffer.GetRegion(interest); pixelRegion.Clear(); this.restoreArea = null; diff --git a/tests/ImageSharp.Tests/Formats/Gif/GifDecoderTests.cs b/tests/ImageSharp.Tests/Formats/Gif/GifDecoderTests.cs index a115b12109..058d669d40 100644 --- a/tests/ImageSharp.Tests/Formats/Gif/GifDecoderTests.cs +++ b/tests/ImageSharp.Tests/Formats/Gif/GifDecoderTests.cs @@ -171,6 +171,17 @@ namespace SixLabors.ImageSharp.Tests.Formats.Gif } } + // https://github.com/SixLabors/ImageSharp/issues/1503 + [Theory] + [WithFile(TestImages.Gif.Issues.Issue1530, PixelTypes.Rgba32)] + public void Issue1530_BadDescriptorDimensions(TestImageProvider provider) + where TPixel : unmanaged, IPixel + { + using Image image = provider.GetImage(); + image.DebugSaveMultiFrame(provider); + image.CompareToReferenceOutputMultiFrame(provider, ImageComparer.Exact); + } + // https://github.com/SixLabors/ImageSharp/issues/405 [Theory] [WithFile(TestImages.Gif.Issues.BadAppExtLength, PixelTypes.Rgba32)] @@ -181,6 +192,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Gif using (Image image = provider.GetImage()) { image.DebugSave(provider); + image.CompareFirstFrameToReferenceOutput(ImageComparer.Exact, provider); } } diff --git a/tests/ImageSharp.Tests/TestImages.cs b/tests/ImageSharp.Tests/TestImages.cs index b5dd5b2bb1..ac9d6422aa 100644 --- a/tests/ImageSharp.Tests/TestImages.cs +++ b/tests/ImageSharp.Tests/TestImages.cs @@ -416,6 +416,7 @@ namespace SixLabors.ImageSharp.Tests public const string BadAppExtLength_2 = "Gif/issues/issue405_badappextlength252-2.gif"; public const string BadDescriptorWidth = "Gif/issues/issue403_baddescriptorwidth.gif"; public const string Issue1505 = "Gif/issues/issue1505_argumentoutofrange.png"; + public const string Issue1530 = "Gif/issues/issue1530.gif"; } public static readonly string[] All = { Rings, Giphy, Cheers, Trans, Kumin, Leo, Ratio4x1, Ratio1x4 }; diff --git a/tests/Images/External b/tests/Images/External index 346070e5ba..1df6516244 160000 --- a/tests/Images/External +++ b/tests/Images/External @@ -1 +1 @@ -Subproject commit 346070e5ba538f1a3bbafc0ea7367404c5f8c9ab +Subproject commit 1df65162448996332449387a46da942e181043c8 diff --git a/tests/Images/Input/Gif/issues/issue1530.gif b/tests/Images/Input/Gif/issues/issue1530.gif new file mode 100644 index 0000000000..ce8bf4905e --- /dev/null +++ b/tests/Images/Input/Gif/issues/issue1530.gif @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:08b33cab34de2622a7d22edff25fe479a5018c2e0fbc65870b2f21ea7901fc61 +size 1844876