From 081208574d55535caa70e90bc1bce3227a512581 Mon Sep 17 00:00:00 2001 From: Brian Popow Date: Mon, 12 Jul 2021 19:35:37 +0200 Subject: [PATCH] Fix warnings --- .../Colorspaces/CieLabTests.cs | 10 +- .../Colorspaces/CieLchTests.cs | 8 +- .../Colorspaces/CieLchuvTests.cs | 8 +- .../Colorspaces/CieLuvTests.cs | 8 +- .../CieXyChromaticityCoordinatesTests.cs | 10 +- .../Colorspaces/CieXyyTests.cs | 8 +- .../Colorspaces/CieXyzTests.cs | 8 +- .../ImageSharp.Tests/Colorspaces/CmykTests.cs | 10 +- .../ApproximateColorspaceComparer.cs | 75 ++------ .../ImageSharp.Tests/Colorspaces/HslTests.cs | 10 +- .../ImageSharp.Tests/Colorspaces/HsvTests.cs | 10 +- .../Colorspaces/HunterLabTests.cs | 8 +- .../Icc/Calculators/ClutCalculatorTests.cs | 5 +- .../Icc/Calculators/CurveCalculatorTests.cs | 5 +- .../Icc/Calculators/LutABCalculatorTests.cs | 5 +- .../Icc/Calculators/LutCalculatorTests.cs | 5 +- .../Calculators/LutEntryCalculatorTests.cs | 5 +- .../Icc/Calculators/MatrixCalculatorTests.cs | 5 +- .../ParametricCurveCalculatorTests.cs | 5 +- .../Icc/Calculators/TrcCalculatorTests.cs | 5 +- .../Colorspaces/LinearRgbTests.cs | 10 +- .../ImageSharp.Tests/Colorspaces/LmsTests.cs | 8 +- .../Colorspaces/YCbCrTests.cs | 8 +- .../Conversion/IccConversionData.Clut.cs | 163 ------------------ .../IccConversionData.MultiProcessElement.cs | 76 -------- .../Conversion/IccConversionDataClut.cs | 163 ++++++++++++++++++ ...ionData.Lut.cs => IccConversionDataLut.cs} | 9 +- ...ata.LutAB.cs => IccConversionDataLutAB.cs} | 25 ++- ...tEntry.cs => IccConversionDataLutEntry.cs} | 23 ++- ...a.Matrix.cs => IccConversionDataMatrix.cs} | 29 ++-- .../IccConversionDataMultiProcessElement.cs | 78 +++++++++ ...ionData.Trc.cs => IccConversionDataTrc.cs} | 4 +- 32 files changed, 393 insertions(+), 416 deletions(-) delete mode 100644 tests/ImageSharp.Tests/TestDataIcc/Conversion/IccConversionData.Clut.cs delete mode 100644 tests/ImageSharp.Tests/TestDataIcc/Conversion/IccConversionData.MultiProcessElement.cs create mode 100644 tests/ImageSharp.Tests/TestDataIcc/Conversion/IccConversionDataClut.cs rename tests/ImageSharp.Tests/TestDataIcc/Conversion/{IccConversionData.Lut.cs => IccConversionDataLut.cs} (79%) rename tests/ImageSharp.Tests/TestDataIcc/Conversion/{IccConversionData.LutAB.cs => IccConversionDataLutAB.cs} (56%) rename tests/ImageSharp.Tests/TestDataIcc/Conversion/{IccConversionData.LutEntry.cs => IccConversionDataLutEntry.cs} (80%) rename tests/ImageSharp.Tests/TestDataIcc/Conversion/{IccConversionData.Matrix.cs => IccConversionDataMatrix.cs} (76%) create mode 100644 tests/ImageSharp.Tests/TestDataIcc/Conversion/IccConversionDataMultiProcessElement.cs rename tests/ImageSharp.Tests/TestDataIcc/Conversion/{IccConversionData.Trc.cs => IccConversionDataTrc.cs} (97%) diff --git a/tests/ImageSharp.Tests/Colorspaces/CieLabTests.cs b/tests/ImageSharp.Tests/Colorspaces/CieLabTests.cs index 90d804b411..cd0745cc9f 100644 --- a/tests/ImageSharp.Tests/Colorspaces/CieLabTests.cs +++ b/tests/ImageSharp.Tests/Colorspaces/CieLabTests.cs @@ -31,14 +31,14 @@ namespace SixLabors.ImageSharp.Tests.Colorspaces var x = default(CieLab); var y = new CieLab(Vector3.One); - Assert.True(default(CieLab) == default(CieLab)); - Assert.True(new CieLab(1, 0, 1) != default(CieLab)); - Assert.False(new CieLab(1, 0, 1) == default(CieLab)); - Assert.Equal(default(CieLab), default(CieLab)); + Assert.True(default == default(CieLab)); + Assert.True(new CieLab(1, 0, 1) != default); + Assert.False(new CieLab(1, 0, 1) == default); + Assert.Equal(default(CieLab), default); Assert.Equal(new CieLab(1, 0, 1), new CieLab(1, 0, 1)); Assert.Equal(new CieLab(Vector3.One), new CieLab(Vector3.One)); Assert.False(x.Equals(y)); - Assert.False(new CieLab(1, 0, 1) == default(CieLab)); + Assert.False(new CieLab(1, 0, 1) == default); Assert.False(x.Equals((object)y)); Assert.False(x.GetHashCode().Equals(y.GetHashCode())); } diff --git a/tests/ImageSharp.Tests/Colorspaces/CieLchTests.cs b/tests/ImageSharp.Tests/Colorspaces/CieLchTests.cs index f0e97f614f..6aa9fac867 100644 --- a/tests/ImageSharp.Tests/Colorspaces/CieLchTests.cs +++ b/tests/ImageSharp.Tests/Colorspaces/CieLchTests.cs @@ -1,4 +1,4 @@ -// Copyright (c) Six Labors. +// Copyright (c) Six Labors. // Licensed under the Apache License, Version 2.0. using System.Numerics; @@ -31,9 +31,9 @@ namespace SixLabors.ImageSharp.Tests.Colorspaces var x = default(CieLch); var y = new CieLch(Vector3.One); - Assert.True(default(CieLch) == default(CieLch)); - Assert.False(default(CieLch) != default(CieLch)); - Assert.Equal(default(CieLch), default(CieLch)); + Assert.True(default(CieLch) == default); + Assert.False(default(CieLch) != default); + Assert.Equal(default(CieLch), default); Assert.Equal(new CieLch(1, 0, 1), new CieLch(1, 0, 1)); Assert.Equal(new CieLch(Vector3.One), new CieLch(Vector3.One)); Assert.False(x.Equals(y)); diff --git a/tests/ImageSharp.Tests/Colorspaces/CieLchuvTests.cs b/tests/ImageSharp.Tests/Colorspaces/CieLchuvTests.cs index d69eac50e5..0d32192731 100644 --- a/tests/ImageSharp.Tests/Colorspaces/CieLchuvTests.cs +++ b/tests/ImageSharp.Tests/Colorspaces/CieLchuvTests.cs @@ -1,4 +1,4 @@ -// Copyright (c) Six Labors. +// Copyright (c) Six Labors. // Licensed under the Apache License, Version 2.0. using System.Numerics; @@ -31,9 +31,9 @@ namespace SixLabors.ImageSharp.Tests.Colorspaces var x = default(CieLchuv); var y = new CieLchuv(Vector3.One); - Assert.True(default(CieLchuv) == default(CieLchuv)); - Assert.False(default(CieLchuv) != default(CieLchuv)); - Assert.Equal(default(CieLchuv), default(CieLchuv)); + Assert.True(default(CieLchuv) == default); + Assert.False(default(CieLchuv) != default); + Assert.Equal(default(CieLchuv), default); Assert.Equal(new CieLchuv(1, 0, 1), new CieLchuv(1, 0, 1)); Assert.Equal(new CieLchuv(Vector3.One), new CieLchuv(Vector3.One)); Assert.False(x.Equals(y)); diff --git a/tests/ImageSharp.Tests/Colorspaces/CieLuvTests.cs b/tests/ImageSharp.Tests/Colorspaces/CieLuvTests.cs index c76626a0e8..a3af9fd733 100644 --- a/tests/ImageSharp.Tests/Colorspaces/CieLuvTests.cs +++ b/tests/ImageSharp.Tests/Colorspaces/CieLuvTests.cs @@ -1,4 +1,4 @@ -// Copyright (c) Six Labors. +// Copyright (c) Six Labors. // Licensed under the Apache License, Version 2.0. using System.Numerics; @@ -31,9 +31,9 @@ namespace SixLabors.ImageSharp.Tests.Colorspaces var x = default(CieLuv); var y = new CieLuv(Vector3.One); - Assert.True(default(CieLuv) == default(CieLuv)); - Assert.False(default(CieLuv) != default(CieLuv)); - Assert.Equal(default(CieLuv), default(CieLuv)); + Assert.True(default(CieLuv) == default); + Assert.False(default(CieLuv) != default); + Assert.Equal(default(CieLuv), default); Assert.Equal(new CieLuv(1, 0, 1), new CieLuv(1, 0, 1)); Assert.Equal(new CieLuv(Vector3.One), new CieLuv(Vector3.One)); Assert.False(x.Equals(y)); diff --git a/tests/ImageSharp.Tests/Colorspaces/CieXyChromaticityCoordinatesTests.cs b/tests/ImageSharp.Tests/Colorspaces/CieXyChromaticityCoordinatesTests.cs index 31ad79b3d9..8f06b91871 100644 --- a/tests/ImageSharp.Tests/Colorspaces/CieXyChromaticityCoordinatesTests.cs +++ b/tests/ImageSharp.Tests/Colorspaces/CieXyChromaticityCoordinatesTests.cs @@ -28,14 +28,14 @@ namespace SixLabors.ImageSharp.Tests.Colorspaces var x = default(CieXyChromaticityCoordinates); var y = new CieXyChromaticityCoordinates(1, 1); - Assert.True(default(CieXyChromaticityCoordinates) == default(CieXyChromaticityCoordinates)); - Assert.True(new CieXyChromaticityCoordinates(1, 0) != default(CieXyChromaticityCoordinates)); - Assert.False(new CieXyChromaticityCoordinates(1, 0) == default(CieXyChromaticityCoordinates)); - Assert.Equal(default(CieXyChromaticityCoordinates), default(CieXyChromaticityCoordinates)); + Assert.True(default(CieXyChromaticityCoordinates) == default); + Assert.True(new CieXyChromaticityCoordinates(1, 0) != default); + Assert.False(new CieXyChromaticityCoordinates(1, 0) == default); + Assert.Equal(default(CieXyChromaticityCoordinates), default); Assert.Equal(new CieXyChromaticityCoordinates(1, 0), new CieXyChromaticityCoordinates(1, 0)); Assert.Equal(new CieXyChromaticityCoordinates(1, 1), new CieXyChromaticityCoordinates(1, 1)); Assert.False(x.Equals(y)); - Assert.False(new CieXyChromaticityCoordinates(1, 0) == default(CieXyChromaticityCoordinates)); + Assert.False(new CieXyChromaticityCoordinates(1, 0) == default); Assert.False(x.Equals((object)y)); Assert.False(x.GetHashCode().Equals(y.GetHashCode())); } diff --git a/tests/ImageSharp.Tests/Colorspaces/CieXyyTests.cs b/tests/ImageSharp.Tests/Colorspaces/CieXyyTests.cs index a2549e41ec..000e8d9c7e 100644 --- a/tests/ImageSharp.Tests/Colorspaces/CieXyyTests.cs +++ b/tests/ImageSharp.Tests/Colorspaces/CieXyyTests.cs @@ -1,4 +1,4 @@ -// Copyright (c) Six Labors. +// Copyright (c) Six Labors. // Licensed under the Apache License, Version 2.0. using System.Numerics; @@ -31,9 +31,9 @@ namespace SixLabors.ImageSharp.Tests.Colorspaces var x = default(CieXyy); var y = new CieXyy(Vector3.One); - Assert.True(default(CieXyy) == default(CieXyy)); - Assert.False(default(CieXyy) != default(CieXyy)); - Assert.Equal(default(CieXyy), default(CieXyy)); + Assert.True(default(CieXyy) == default); + Assert.False(default(CieXyy) != default); + Assert.Equal(default(CieXyy), default); Assert.Equal(new CieXyy(1, 0, 1), new CieXyy(1, 0, 1)); Assert.Equal(new CieXyy(Vector3.One), new CieXyy(Vector3.One)); Assert.False(x.Equals(y)); diff --git a/tests/ImageSharp.Tests/Colorspaces/CieXyzTests.cs b/tests/ImageSharp.Tests/Colorspaces/CieXyzTests.cs index d5166cc83a..cb89f5bd71 100644 --- a/tests/ImageSharp.Tests/Colorspaces/CieXyzTests.cs +++ b/tests/ImageSharp.Tests/Colorspaces/CieXyzTests.cs @@ -1,4 +1,4 @@ -// Copyright (c) Six Labors. +// Copyright (c) Six Labors. // Licensed under the Apache License, Version 2.0. using System.Numerics; @@ -31,9 +31,9 @@ namespace SixLabors.ImageSharp.Tests.Colorspaces var x = default(CieXyz); var y = new CieXyz(Vector3.One); - Assert.True(default(CieXyz) == default(CieXyz)); - Assert.False(default(CieXyz) != default(CieXyz)); - Assert.Equal(default(CieXyz), default(CieXyz)); + Assert.True(default(CieXyz) == default); + Assert.False(default(CieXyz) != default); + Assert.Equal(default(CieXyz), default); Assert.Equal(new CieXyz(1, 0, 1), new CieXyz(1, 0, 1)); Assert.Equal(new CieXyz(Vector3.One), new CieXyz(Vector3.One)); Assert.False(x.Equals(y)); diff --git a/tests/ImageSharp.Tests/Colorspaces/CmykTests.cs b/tests/ImageSharp.Tests/Colorspaces/CmykTests.cs index 76f5bb5487..261048df12 100644 --- a/tests/ImageSharp.Tests/Colorspaces/CmykTests.cs +++ b/tests/ImageSharp.Tests/Colorspaces/CmykTests.cs @@ -1,4 +1,4 @@ -// Copyright (c) Six Labors. +// Copyright (c) Six Labors. // Licensed under the Apache License, Version 2.0. using System.Numerics; @@ -33,9 +33,9 @@ namespace SixLabors.ImageSharp.Tests.Colorspaces var x = default(Cmyk); var y = new Cmyk(Vector4.One); - Assert.True(default(Cmyk) == default(Cmyk)); - Assert.False(default(Cmyk) != default(Cmyk)); - Assert.Equal(default(Cmyk), default(Cmyk)); + Assert.True(default(Cmyk) == default); + Assert.False(default(Cmyk) != default); + Assert.Equal(default(Cmyk), default); Assert.Equal(new Cmyk(1, 0, 1, 0), new Cmyk(1, 0, 1, 0)); Assert.Equal(new Cmyk(Vector4.One), new Cmyk(Vector4.One)); Assert.False(x.Equals(y)); @@ -43,4 +43,4 @@ namespace SixLabors.ImageSharp.Tests.Colorspaces Assert.False(x.GetHashCode().Equals(y.GetHashCode())); } } -} \ No newline at end of file +} diff --git a/tests/ImageSharp.Tests/Colorspaces/Conversion/ApproximateColorspaceComparer.cs b/tests/ImageSharp.Tests/Colorspaces/Conversion/ApproximateColorspaceComparer.cs index f0a6923627..5902f6c5b2 100644 --- a/tests/ImageSharp.Tests/Colorspaces/Conversion/ApproximateColorspaceComparer.cs +++ b/tests/ImageSharp.Tests/Colorspaces/Conversion/ApproximateColorspaceComparer.cs @@ -39,156 +39,114 @@ namespace SixLabors.ImageSharp.Tests.Colorspaces.Conversion public ApproximateColorSpaceComparer(float epsilon = 1F) => this.epsilon = epsilon; /// - public bool Equals(Rgb x, Rgb y) - { - return this.Equals(x.R, y.R) + public bool Equals(Rgb x, Rgb y) => this.Equals(x.R, y.R) && this.Equals(x.G, y.G) && this.Equals(x.B, y.B); - } /// public int GetHashCode(Rgb obj) => obj.GetHashCode(); /// - public bool Equals(LinearRgb x, LinearRgb y) - { - return this.Equals(x.R, y.R) + public bool Equals(LinearRgb x, LinearRgb y) => this.Equals(x.R, y.R) && this.Equals(x.G, y.G) && this.Equals(x.B, y.B); - } /// public int GetHashCode(LinearRgb obj) => obj.GetHashCode(); /// - public bool Equals(CieLab x, CieLab y) - { - return this.Equals(x.L, y.L) + public bool Equals(CieLab x, CieLab y) => this.Equals(x.L, y.L) && this.Equals(x.A, y.A) && this.Equals(x.B, y.B); - } /// public int GetHashCode(CieLab obj) => obj.GetHashCode(); /// - public bool Equals(CieLch x, CieLch y) - { - return this.Equals(x.L, y.L) + public bool Equals(CieLch x, CieLch y) => this.Equals(x.L, y.L) && this.Equals(x.C, y.C) && this.Equals(x.H, y.H); - } /// public int GetHashCode(CieLch obj) => obj.GetHashCode(); /// - public bool Equals(CieLchuv x, CieLchuv y) - { - return this.Equals(x.L, y.L) + public bool Equals(CieLchuv x, CieLchuv y) => this.Equals(x.L, y.L) && this.Equals(x.C, y.C) && this.Equals(x.H, y.H); - } /// public int GetHashCode(CieLchuv obj) => obj.GetHashCode(); /// - public bool Equals(CieLuv x, CieLuv y) - { - return this.Equals(x.L, y.L) + public bool Equals(CieLuv x, CieLuv y) => this.Equals(x.L, y.L) && this.Equals(x.U, y.U) && this.Equals(x.V, y.V); - } /// public int GetHashCode(CieLuv obj) => obj.GetHashCode(); /// - public bool Equals(CieXyz x, CieXyz y) - { - return this.Equals(x.X, y.X) + public bool Equals(CieXyz x, CieXyz y) => this.Equals(x.X, y.X) && this.Equals(x.Y, y.Y) && this.Equals(x.Z, y.Z); - } /// public int GetHashCode(CieXyz obj) => obj.GetHashCode(); /// - public bool Equals(CieXyy x, CieXyy y) - { - return this.Equals(x.X, y.X) + public bool Equals(CieXyy x, CieXyy y) => this.Equals(x.X, y.X) && this.Equals(x.Y, y.Y) && this.Equals(x.Yl, y.Yl); - } /// public int GetHashCode(CieXyy obj) => obj.GetHashCode(); /// - public bool Equals(Cmyk x, Cmyk y) - { - return this.Equals(x.C, y.C) + public bool Equals(Cmyk x, Cmyk y) => this.Equals(x.C, y.C) && this.Equals(x.M, y.M) && this.Equals(x.Y, y.Y) && this.Equals(x.K, y.K); - } /// public int GetHashCode(Cmyk obj) => obj.GetHashCode(); /// - public bool Equals(HunterLab x, HunterLab y) - { - return this.Equals(x.L, y.L) + public bool Equals(HunterLab x, HunterLab y) => this.Equals(x.L, y.L) && this.Equals(x.A, y.A) && this.Equals(x.B, y.B); - } /// public int GetHashCode(HunterLab obj) => obj.GetHashCode(); /// - public bool Equals(Hsl x, Hsl y) - { - return this.Equals(x.H, y.H) + public bool Equals(Hsl x, Hsl y) => this.Equals(x.H, y.H) && this.Equals(x.S, y.S) && this.Equals(x.L, y.L); - } /// public int GetHashCode(Hsl obj) => obj.GetHashCode(); /// - public bool Equals(Hsv x, Hsv y) - { - return this.Equals(x.H, y.H) + public bool Equals(Hsv x, Hsv y) => this.Equals(x.H, y.H) && this.Equals(x.S, y.S) && this.Equals(x.V, y.V); - } /// public int GetHashCode(Hsv obj) => obj.GetHashCode(); /// - public bool Equals(Lms x, Lms y) - { - return this.Equals(x.L, y.L) + public bool Equals(Lms x, Lms y) => this.Equals(x.L, y.L) && this.Equals(x.M, y.M) && this.Equals(x.S, y.S); - } /// public int GetHashCode(Lms obj) => obj.GetHashCode(); /// - public bool Equals(YCbCr x, YCbCr y) - { - return this.Equals(x.Y, y.Y) + public bool Equals(YCbCr x, YCbCr y) => this.Equals(x.Y, y.Y) && this.Equals(x.Cb, y.Cb) && this.Equals(x.Cr, y.Cr); - } /// public int GetHashCode(YCbCr obj) => obj.GetHashCode(); @@ -222,11 +180,8 @@ namespace SixLabors.ImageSharp.Tests.Colorspaces.Conversion public int GetHashCode(GammaWorkingSpace obj) => obj.GetHashCode(); /// - public bool Equals(RgbWorkingSpace x, RgbWorkingSpace y) - { - return this.Equals(x.WhitePoint, y.WhitePoint) + public bool Equals(RgbWorkingSpace x, RgbWorkingSpace y) => this.Equals(x.WhitePoint, y.WhitePoint) && this.Equals(x.ChromaticityCoordinates, y.ChromaticityCoordinates); - } /// public int GetHashCode(RgbWorkingSpace obj) => obj.GetHashCode(); diff --git a/tests/ImageSharp.Tests/Colorspaces/HslTests.cs b/tests/ImageSharp.Tests/Colorspaces/HslTests.cs index 84fca1ac29..9df33c37d1 100644 --- a/tests/ImageSharp.Tests/Colorspaces/HslTests.cs +++ b/tests/ImageSharp.Tests/Colorspaces/HslTests.cs @@ -1,4 +1,4 @@ -// Copyright (c) Six Labors. +// Copyright (c) Six Labors. // Licensed under the Apache License, Version 2.0. using System.Numerics; @@ -31,9 +31,9 @@ namespace SixLabors.ImageSharp.Tests.Colorspaces var x = default(Hsl); var y = new Hsl(Vector3.One); - Assert.True(default(Hsl) == default(Hsl)); - Assert.False(default(Hsl) != default(Hsl)); - Assert.Equal(default(Hsl), default(Hsl)); + Assert.True(default(Hsl) == default); + Assert.False(default(Hsl) != default); + Assert.Equal(default(Hsl), default); Assert.Equal(new Hsl(1, 0, 1), new Hsl(1, 0, 1)); Assert.Equal(new Hsl(Vector3.One), new Hsl(Vector3.One)); Assert.False(x.Equals(y)); @@ -41,4 +41,4 @@ namespace SixLabors.ImageSharp.Tests.Colorspaces Assert.False(x.GetHashCode().Equals(y.GetHashCode())); } } -} \ No newline at end of file +} diff --git a/tests/ImageSharp.Tests/Colorspaces/HsvTests.cs b/tests/ImageSharp.Tests/Colorspaces/HsvTests.cs index 6bb07867e7..d6e7fc85e9 100644 --- a/tests/ImageSharp.Tests/Colorspaces/HsvTests.cs +++ b/tests/ImageSharp.Tests/Colorspaces/HsvTests.cs @@ -1,4 +1,4 @@ -// Copyright (c) Six Labors. +// Copyright (c) Six Labors. // Licensed under the Apache License, Version 2.0. using System.Numerics; @@ -31,9 +31,9 @@ namespace SixLabors.ImageSharp.Tests.Colorspaces var x = default(Hsv); var y = new Hsv(Vector3.One); - Assert.True(default(Hsv) == default(Hsv)); - Assert.False(default(Hsv) != default(Hsv)); - Assert.Equal(default(Hsv), default(Hsv)); + Assert.True(default == default(Hsv)); + Assert.False(default(Hsv) != default); + Assert.Equal(default(Hsv), default); Assert.Equal(new Hsv(1, 0, 1), new Hsv(1, 0, 1)); Assert.Equal(new Hsv(Vector3.One), new Hsv(Vector3.One)); Assert.False(x.Equals(y)); @@ -41,4 +41,4 @@ namespace SixLabors.ImageSharp.Tests.Colorspaces Assert.False(x.GetHashCode().Equals(y.GetHashCode())); } } -} \ No newline at end of file +} diff --git a/tests/ImageSharp.Tests/Colorspaces/HunterLabTests.cs b/tests/ImageSharp.Tests/Colorspaces/HunterLabTests.cs index 2f97207db0..5b47f8c9b9 100644 --- a/tests/ImageSharp.Tests/Colorspaces/HunterLabTests.cs +++ b/tests/ImageSharp.Tests/Colorspaces/HunterLabTests.cs @@ -31,10 +31,10 @@ namespace SixLabors.ImageSharp.Tests.Colorspaces var x = default(HunterLab); var y = new HunterLab(Vector3.One); - Assert.True(default(HunterLab) == default(HunterLab)); - Assert.True(new HunterLab(1, 0, 1) != default(HunterLab)); - Assert.False(new HunterLab(1, 0, 1) == default(HunterLab)); - Assert.Equal(default(HunterLab), default(HunterLab)); + Assert.True(default(HunterLab) == default); + Assert.True(new HunterLab(1, 0, 1) != default); + Assert.False(new HunterLab(1, 0, 1) == default); + Assert.Equal(default(HunterLab), default); Assert.Equal(new HunterLab(1, 0, 1), new HunterLab(1, 0, 1)); Assert.Equal(new HunterLab(Vector3.One), new HunterLab(Vector3.One)); Assert.False(x.Equals(y)); diff --git a/tests/ImageSharp.Tests/Colorspaces/Icc/Calculators/ClutCalculatorTests.cs b/tests/ImageSharp.Tests/Colorspaces/Icc/Calculators/ClutCalculatorTests.cs index a03bdceaf6..a43ac906be 100644 --- a/tests/ImageSharp.Tests/Colorspaces/Icc/Calculators/ClutCalculatorTests.cs +++ b/tests/ImageSharp.Tests/Colorspaces/Icc/Calculators/ClutCalculatorTests.cs @@ -1,9 +1,10 @@ -// Copyright (c) Six Labors. +// Copyright (c) Six Labors. // Licensed under the Apache License, Version 2.0. using System.Numerics; using SixLabors.ImageSharp.ColorSpaces.Conversion.Icc; using SixLabors.ImageSharp.Metadata.Profiles.Icc; +using SixLabors.ImageSharp.Tests.TestDataIcc.Conversion; using Xunit; namespace SixLabors.ImageSharp.Tests.Colorspaces.Icc.Calculators @@ -24,4 +25,4 @@ namespace SixLabors.ImageSharp.Tests.Colorspaces.Icc.Calculators VectorAssert.Equal(expected, result, 4); } } -} \ No newline at end of file +} diff --git a/tests/ImageSharp.Tests/Colorspaces/Icc/Calculators/CurveCalculatorTests.cs b/tests/ImageSharp.Tests/Colorspaces/Icc/Calculators/CurveCalculatorTests.cs index 800a752e4c..b3f06e8b0b 100644 --- a/tests/ImageSharp.Tests/Colorspaces/Icc/Calculators/CurveCalculatorTests.cs +++ b/tests/ImageSharp.Tests/Colorspaces/Icc/Calculators/CurveCalculatorTests.cs @@ -1,8 +1,9 @@ -// Copyright (c) Six Labors. +// Copyright (c) Six Labors. // Licensed under the Apache License, Version 2.0. using SixLabors.ImageSharp.ColorSpaces.Conversion.Icc; using SixLabors.ImageSharp.Metadata.Profiles.Icc; +using SixLabors.ImageSharp.Tests.TestDataIcc.Conversion; using Xunit; namespace SixLabors.ImageSharp.Tests.Colorspaces.Icc.Calculators @@ -23,4 +24,4 @@ namespace SixLabors.ImageSharp.Tests.Colorspaces.Icc.Calculators Assert.Equal(expected, result, 4); } } -} \ No newline at end of file +} diff --git a/tests/ImageSharp.Tests/Colorspaces/Icc/Calculators/LutABCalculatorTests.cs b/tests/ImageSharp.Tests/Colorspaces/Icc/Calculators/LutABCalculatorTests.cs index 0581d88718..831603f5cb 100644 --- a/tests/ImageSharp.Tests/Colorspaces/Icc/Calculators/LutABCalculatorTests.cs +++ b/tests/ImageSharp.Tests/Colorspaces/Icc/Calculators/LutABCalculatorTests.cs @@ -1,9 +1,10 @@ -// Copyright (c) Six Labors. +// Copyright (c) Six Labors. // Licensed under the Apache License, Version 2.0. using System.Numerics; using SixLabors.ImageSharp.ColorSpaces.Conversion.Icc; using SixLabors.ImageSharp.Metadata.Profiles.Icc; +using SixLabors.ImageSharp.Tests.TestDataIcc.Conversion; using Xunit; namespace SixLabors.ImageSharp.Tests.Colorspaces.Icc.Calculators @@ -35,4 +36,4 @@ namespace SixLabors.ImageSharp.Tests.Colorspaces.Icc.Calculators VectorAssert.Equal(expected, result, 4); } } -} \ No newline at end of file +} diff --git a/tests/ImageSharp.Tests/Colorspaces/Icc/Calculators/LutCalculatorTests.cs b/tests/ImageSharp.Tests/Colorspaces/Icc/Calculators/LutCalculatorTests.cs index c86d2a563d..1fdb449669 100644 --- a/tests/ImageSharp.Tests/Colorspaces/Icc/Calculators/LutCalculatorTests.cs +++ b/tests/ImageSharp.Tests/Colorspaces/Icc/Calculators/LutCalculatorTests.cs @@ -1,7 +1,8 @@ -// Copyright (c) Six Labors. +// Copyright (c) Six Labors. // Licensed under the Apache License, Version 2.0. using SixLabors.ImageSharp.ColorSpaces.Conversion.Icc; +using SixLabors.ImageSharp.Tests.TestDataIcc.Conversion; using Xunit; namespace SixLabors.ImageSharp.Tests.Colorspaces.Icc.Calculators @@ -22,4 +23,4 @@ namespace SixLabors.ImageSharp.Tests.Colorspaces.Icc.Calculators Assert.Equal(expected, result, 4); } } -} \ No newline at end of file +} diff --git a/tests/ImageSharp.Tests/Colorspaces/Icc/Calculators/LutEntryCalculatorTests.cs b/tests/ImageSharp.Tests/Colorspaces/Icc/Calculators/LutEntryCalculatorTests.cs index 9cda497954..ef4f25a535 100644 --- a/tests/ImageSharp.Tests/Colorspaces/Icc/Calculators/LutEntryCalculatorTests.cs +++ b/tests/ImageSharp.Tests/Colorspaces/Icc/Calculators/LutEntryCalculatorTests.cs @@ -1,9 +1,10 @@ -// Copyright (c) Six Labors. +// Copyright (c) Six Labors. // Licensed under the Apache License, Version 2.0. using System.Numerics; using SixLabors.ImageSharp.ColorSpaces.Conversion.Icc; using SixLabors.ImageSharp.Metadata.Profiles.Icc; +using SixLabors.ImageSharp.Tests.TestDataIcc.Conversion; using Xunit; namespace SixLabors.ImageSharp.Tests.Colorspaces.Icc.Calculators @@ -35,4 +36,4 @@ namespace SixLabors.ImageSharp.Tests.Colorspaces.Icc.Calculators VectorAssert.Equal(expected, result, 4); } } -} \ No newline at end of file +} diff --git a/tests/ImageSharp.Tests/Colorspaces/Icc/Calculators/MatrixCalculatorTests.cs b/tests/ImageSharp.Tests/Colorspaces/Icc/Calculators/MatrixCalculatorTests.cs index d1c1512812..68e4891299 100644 --- a/tests/ImageSharp.Tests/Colorspaces/Icc/Calculators/MatrixCalculatorTests.cs +++ b/tests/ImageSharp.Tests/Colorspaces/Icc/Calculators/MatrixCalculatorTests.cs @@ -1,8 +1,9 @@ -// Copyright (c) Six Labors. +// Copyright (c) Six Labors. // Licensed under the Apache License, Version 2.0. using System.Numerics; using SixLabors.ImageSharp.ColorSpaces.Conversion.Icc; +using SixLabors.ImageSharp.Tests.TestDataIcc.Conversion; using Xunit; namespace SixLabors.ImageSharp.Tests.Colorspaces.Icc.Calculators @@ -23,4 +24,4 @@ namespace SixLabors.ImageSharp.Tests.Colorspaces.Icc.Calculators VectorAssert.Equal(expected, result, 4); } } -} \ No newline at end of file +} diff --git a/tests/ImageSharp.Tests/Colorspaces/Icc/Calculators/ParametricCurveCalculatorTests.cs b/tests/ImageSharp.Tests/Colorspaces/Icc/Calculators/ParametricCurveCalculatorTests.cs index 2e7f942641..f5a7f7bb72 100644 --- a/tests/ImageSharp.Tests/Colorspaces/Icc/Calculators/ParametricCurveCalculatorTests.cs +++ b/tests/ImageSharp.Tests/Colorspaces/Icc/Calculators/ParametricCurveCalculatorTests.cs @@ -1,8 +1,9 @@ -// Copyright (c) Six Labors. +// Copyright (c) Six Labors. // Licensed under the Apache License, Version 2.0. using SixLabors.ImageSharp.ColorSpaces.Conversion.Icc; using SixLabors.ImageSharp.Metadata.Profiles.Icc; +using SixLabors.ImageSharp.Tests.TestDataIcc.Conversion; using Xunit; namespace SixLabors.ImageSharp.Tests.Colorspaces.Icc.Calculators @@ -23,4 +24,4 @@ namespace SixLabors.ImageSharp.Tests.Colorspaces.Icc.Calculators Assert.Equal(expected, result, 4); } } -} \ No newline at end of file +} diff --git a/tests/ImageSharp.Tests/Colorspaces/Icc/Calculators/TrcCalculatorTests.cs b/tests/ImageSharp.Tests/Colorspaces/Icc/Calculators/TrcCalculatorTests.cs index d2d2da9e79..7099e12686 100644 --- a/tests/ImageSharp.Tests/Colorspaces/Icc/Calculators/TrcCalculatorTests.cs +++ b/tests/ImageSharp.Tests/Colorspaces/Icc/Calculators/TrcCalculatorTests.cs @@ -1,9 +1,10 @@ -// Copyright (c) Six Labors. +// Copyright (c) Six Labors. // Licensed under the Apache License, Version 2.0. using System.Numerics; using SixLabors.ImageSharp.ColorSpaces.Conversion.Icc; using SixLabors.ImageSharp.Metadata.Profiles.Icc; +using SixLabors.ImageSharp.Tests.TestDataIcc.Conversion; using Xunit; namespace SixLabors.ImageSharp.Tests.Colorspaces.Icc.Calculators @@ -24,4 +25,4 @@ namespace SixLabors.ImageSharp.Tests.Colorspaces.Icc.Calculators VectorAssert.Equal(expected, result, 4); } } -} \ No newline at end of file +} diff --git a/tests/ImageSharp.Tests/Colorspaces/LinearRgbTests.cs b/tests/ImageSharp.Tests/Colorspaces/LinearRgbTests.cs index 4639195b6d..24ce6052e3 100644 --- a/tests/ImageSharp.Tests/Colorspaces/LinearRgbTests.cs +++ b/tests/ImageSharp.Tests/Colorspaces/LinearRgbTests.cs @@ -1,4 +1,4 @@ -// Copyright (c) Six Labors. +// Copyright (c) Six Labors. // Licensed under the Apache License, Version 2.0. using System.Numerics; @@ -31,9 +31,9 @@ namespace SixLabors.ImageSharp.Tests.Colorspaces var x = default(LinearRgb); var y = new LinearRgb(Vector3.One); - Assert.True(default(LinearRgb) == default(LinearRgb)); - Assert.False(default(LinearRgb) != default(LinearRgb)); - Assert.Equal(default(LinearRgb), default(LinearRgb)); + Assert.True(default(LinearRgb) == default); + Assert.False(default(LinearRgb) != default); + Assert.Equal(default(LinearRgb), default); Assert.Equal(new LinearRgb(1, 0, 1), new LinearRgb(1, 0, 1)); Assert.Equal(new LinearRgb(Vector3.One), new LinearRgb(Vector3.One)); Assert.False(x.Equals(y)); @@ -41,4 +41,4 @@ namespace SixLabors.ImageSharp.Tests.Colorspaces Assert.False(x.GetHashCode().Equals(y.GetHashCode())); } } -} \ No newline at end of file +} diff --git a/tests/ImageSharp.Tests/Colorspaces/LmsTests.cs b/tests/ImageSharp.Tests/Colorspaces/LmsTests.cs index a1c3081c6b..2a89e62eb5 100644 --- a/tests/ImageSharp.Tests/Colorspaces/LmsTests.cs +++ b/tests/ImageSharp.Tests/Colorspaces/LmsTests.cs @@ -31,10 +31,10 @@ namespace SixLabors.ImageSharp.Tests.Colorspaces var x = default(Lms); var y = new Lms(Vector3.One); - Assert.True(default(Lms) == default(Lms)); - Assert.True(new Lms(1, 0, 1) != default(Lms)); - Assert.False(new Lms(1, 0, 1) == default(Lms)); - Assert.Equal(default(Lms), default(Lms)); + Assert.True(default(Lms) == default); + Assert.True(new Lms(1, 0, 1) != default); + Assert.False(new Lms(1, 0, 1) == default); + Assert.Equal(default(Lms), default); Assert.Equal(new Lms(1, 0, 1), new Lms(1, 0, 1)); Assert.Equal(new Lms(Vector3.One), new Lms(Vector3.One)); Assert.False(x.Equals(y)); diff --git a/tests/ImageSharp.Tests/Colorspaces/YCbCrTests.cs b/tests/ImageSharp.Tests/Colorspaces/YCbCrTests.cs index d6a87a7311..ae3a63ef34 100644 --- a/tests/ImageSharp.Tests/Colorspaces/YCbCrTests.cs +++ b/tests/ImageSharp.Tests/Colorspaces/YCbCrTests.cs @@ -1,4 +1,4 @@ -// Copyright (c) Six Labors. +// Copyright (c) Six Labors. // Licensed under the Apache License, Version 2.0. using System.Numerics; @@ -31,9 +31,9 @@ namespace SixLabors.ImageSharp.Tests.Colorspaces var x = default(YCbCr); var y = new YCbCr(Vector3.One); - Assert.True(default(YCbCr) == default(YCbCr)); - Assert.False(default(YCbCr) != default(YCbCr)); - Assert.Equal(default(YCbCr), default(YCbCr)); + Assert.True(default == default(YCbCr)); + Assert.False(default != default(YCbCr)); + Assert.Equal(default, default(YCbCr)); Assert.Equal(new YCbCr(1, 0, 1), new YCbCr(1, 0, 1)); Assert.Equal(new YCbCr(Vector3.One), new YCbCr(Vector3.One)); Assert.False(x.Equals(y)); diff --git a/tests/ImageSharp.Tests/TestDataIcc/Conversion/IccConversionData.Clut.cs b/tests/ImageSharp.Tests/TestDataIcc/Conversion/IccConversionData.Clut.cs deleted file mode 100644 index deb327164b..0000000000 --- a/tests/ImageSharp.Tests/TestDataIcc/Conversion/IccConversionData.Clut.cs +++ /dev/null @@ -1,163 +0,0 @@ -// Copyright (c) Six Labors. -// Licensed under the Apache License, Version 2.0. - -using System.Numerics; -using SixLabors.ImageSharp.Metadata.Profiles.Icc; - -namespace SixLabors.ImageSharp.Tests.Colorspaces.Icc -{ - public class IccConversionDataClut - { - internal static IccClut Clut3x2 = new IccClut( - new float[][] - { - new float[] { 0.1f, 0.1f }, - new float[] { 0.2f, 0.2f }, - new float[] { 0.3f, 0.3f }, - - new float[] { 0.11f, 0.11f }, - new float[] { 0.21f, 0.21f }, - new float[] { 0.31f, 0.31f }, - - new float[] { 0.12f, 0.12f }, - new float[] { 0.22f, 0.22f }, - new float[] { 0.32f, 0.32f }, - - new float[] { 0.13f, 0.13f }, - new float[] { 0.23f, 0.23f }, - new float[] { 0.33f, 0.33f }, - - new float[] { 0.14f, 0.14f }, - new float[] { 0.24f, 0.24f }, - new float[] { 0.34f, 0.34f }, - - new float[] { 0.15f, 0.15f }, - new float[] { 0.25f, 0.25f }, - new float[] { 0.35f, 0.35f }, - - new float[] { 0.16f, 0.16f }, - new float[] { 0.26f, 0.26f }, - new float[] { 0.36f, 0.36f }, - - new float[] { 0.17f, 0.17f }, - new float[] { 0.27f, 0.27f }, - new float[] { 0.37f, 0.37f }, - - new float[] { 0.18f, 0.18f }, - new float[] { 0.28f, 0.28f }, - new float[] { 0.38f, 0.38f }, - }, - new byte[] { 3, 3, 3 }, - IccClutDataType.Float); - - internal static IccClut Clut3x1 = new IccClut( - new float[][] - { - new float[] { 0.10f }, - new float[] { 0.20f }, - new float[] { 0.30f }, - - new float[] { 0.11f }, - new float[] { 0.21f }, - new float[] { 0.31f }, - - new float[] { 0.12f }, - new float[] { 0.22f }, - new float[] { 0.32f }, - - new float[] { 0.13f }, - new float[] { 0.23f }, - new float[] { 0.33f }, - - new float[] { 0.14f }, - new float[] { 0.24f }, - new float[] { 0.34f }, - - new float[] { 0.15f }, - new float[] { 0.25f }, - new float[] { 0.35f }, - - new float[] { 0.16f }, - new float[] { 0.26f }, - new float[] { 0.36f }, - - new float[] { 0.17f }, - new float[] { 0.27f }, - new float[] { 0.37f }, - - new float[] { 0.18f }, - new float[] { 0.28f }, - new float[] { 0.38f }, - }, - new byte[] { 3, 3, 3 }, - IccClutDataType.Float); - - internal static IccClut Clut2x2 = new IccClut( - new float[][] - { - new float[] { 0.1f, 0.9f }, - new float[] { 0.2f, 0.8f }, - new float[] { 0.3f, 0.7f }, - - new float[] { 0.4f, 0.6f }, - new float[] { 0.5f, 0.5f }, - new float[] { 0.6f, 0.4f }, - - new float[] { 0.7f, 0.3f }, - new float[] { 0.8f, 0.2f }, - new float[] { 0.9f, 0.1f }, - }, - new byte[] { 3, 3 }, - IccClutDataType.Float); - - internal static IccClut Clut2x1 = new IccClut( - new float[][] - { - new float[] { 0.1f }, - new float[] { 0.2f }, - new float[] { 0.3f }, - - new float[] { 0.4f }, - new float[] { 0.5f }, - new float[] { 0.6f }, - - new float[] { 0.7f }, - new float[] { 0.8f }, - new float[] { 0.9f }, - }, - new byte[] { 3, 3 }, - IccClutDataType.Float); - - internal static IccClut Clut1x2 = new IccClut( - new float[][] - { - new float[] { 0f, 0.5f }, - new float[] { 0.25f, 0.75f, }, - new float[] { 0.5f, 1f }, - }, - new byte[] { 3 }, - IccClutDataType.Float); - - internal static IccClut Clut1x1 = new IccClut( - new float[][] - { - new float[] { 0f }, - new float[] { 0.5f }, - new float[] { 1f }, - }, - new byte[] { 3 }, - IccClutDataType.Float); - - public static object[][] ClutConversionTestData = - { - new object[] { Clut3x2, new Vector4(0.75f, 0.75f, 0.75f, 0), new Vector4(0.31f, 0.31f, 0, 0) }, - new object[] { Clut3x1, new Vector4(0.2f, 0.6f, 0.8f, 0), new Vector4(0.276f, 0, 0, 0) }, - new object[] { Clut3x1, new Vector4(0.75f, 0.75f, 0.75f, 0), new Vector4(0.31f, 0, 0, 0) }, - new object[] { Clut2x2, new Vector4(0.2f, 0.6f, 0, 0), new Vector4(0.46f, 0.54f, 0, 0) }, - new object[] { Clut2x2, new Vector4(0.25f, 0.75f, 0, 0), new Vector4(0.4f, 0.6f, 0, 0) }, - new object[] { Clut2x1, new Vector4(0.25f, 0.75f, 0, 0), new Vector4(0.4f, 0, 0, 0) }, - new object[] { Clut1x2, new Vector4(0.25f, 0, 0, 0), new Vector4(0.125f, 0.625f, 0, 0) }, - new object[] { Clut1x1, new Vector4(0.25f, 0, 0, 0), new Vector4(0.25f, 0, 0, 0) }, - }; - } -} diff --git a/tests/ImageSharp.Tests/TestDataIcc/Conversion/IccConversionData.MultiProcessElement.cs b/tests/ImageSharp.Tests/TestDataIcc/Conversion/IccConversionData.MultiProcessElement.cs deleted file mode 100644 index 696cec6d59..0000000000 --- a/tests/ImageSharp.Tests/TestDataIcc/Conversion/IccConversionData.MultiProcessElement.cs +++ /dev/null @@ -1,76 +0,0 @@ -// Copyright (c) Six Labors. -// Licensed under the Apache License, Version 2.0. - -using SixLabors.ImageSharp.Metadata.Profiles.Icc; - -namespace SixLabors.ImageSharp.Tests.Colorspaces.Icc -{ - public class IccConversionDataMultiProcessElement - { - private static IccMatrixProcessElement Matrix = new IccMatrixProcessElement(new float[,] - { - { 2, 4, 6 }, - { 3, 5, 7 }, - }, new float[] { 3, 4, 5 }); - - private static IccClut Clut = new IccClut(new float[][] - { - new float[] { 0.2f, 0.3f }, - new float[] { 0.4f, 0.5f }, - - new float[] { 0.21f, 0.31f }, - new float[] { 0.41f, 0.51f }, - - new float[] { 0.22f, 0.32f }, - new float[] { 0.42f, 0.52f }, - - new float[] { 0.23f, 0.33f }, - new float[] { 0.43f, 0.53f }, - }, new byte[] { 2, 2, 2 }, IccClutDataType.Float); - - private static IccFormulaCurveElement FormulaCurveElement1 = new IccFormulaCurveElement(IccFormulaCurveType.Type1, 2.2f, 0.7f, 0.2f, 0.3f, 0, 0); - private static IccFormulaCurveElement FormulaCurveElement2 = new IccFormulaCurveElement(IccFormulaCurveType.Type2, 2.2f, 0.9f, 0.9f, 0.02f, 0.1f, 0); - private static IccFormulaCurveElement FormulaCurveElement3 = new IccFormulaCurveElement(IccFormulaCurveType.Type3, 0, 0.9f, 0.9f, 1.02f, 0.1f, 0.02f); - - private static IccCurveSetProcessElement CurveSet1DFormula1 = Create1DSingleCurveSet(FormulaCurveElement1); - private static IccCurveSetProcessElement CurveSet1DFormula2 = Create1DSingleCurveSet(FormulaCurveElement2); - private static IccCurveSetProcessElement CurveSet1DFormula3 = Create1DSingleCurveSet(FormulaCurveElement3); - - private static IccCurveSetProcessElement CurveSet1DFormula1And2 = Create1DMultiCurveSet(new float[] { 0.5f }, FormulaCurveElement1, FormulaCurveElement2); - - private static IccClutProcessElement ClutElement = new IccClutProcessElement(Clut); - - private static IccCurveSetProcessElement Create1DSingleCurveSet(IccCurveSegment segment) - { - var curve = new IccOneDimensionalCurve(new float[0], new IccCurveSegment[] { segment }); - return new IccCurveSetProcessElement(new IccOneDimensionalCurve[] { curve }); - } - - private static IccCurveSetProcessElement Create1DMultiCurveSet(float[] breakPoints, params IccCurveSegment[] segments) - { - var curve = new IccOneDimensionalCurve(breakPoints, segments); - return new IccCurveSetProcessElement(new IccOneDimensionalCurve[] { curve }); - } - - - public static object[][] MpeCurveConversionTestData = - { - new object[] { CurveSet1DFormula1, new float[] { 0.51f }, new float[] { 0.575982451f } }, - new object[] { CurveSet1DFormula2, new float[] { 0.52f }, new float[] { -0.4684991f } }, - new object[] { CurveSet1DFormula3, new float[] { 0.53f }, new float[] { 0.86126f } }, - - new object[] { CurveSet1DFormula1And2, new float[] { 0.31f }, new float[] { 0.445982f } }, - new object[] { CurveSet1DFormula1And2, new float[] { 0.61f }, new float[] { -0.341274023f } }, - }; - - public static object[][] MpeMatrixConversionTestData = - { - new object[] { Matrix, new float[] { 2, 4 }, new float[] { 19, 32, 45 } } - }; - - public static object[][] MpeClutConversionTestData = - { - new object[] { ClutElement, new float[] { 0.5f, 0.5f, 0.5f }, new float[] { 0.5f, 0.5f } } - }; - } -} diff --git a/tests/ImageSharp.Tests/TestDataIcc/Conversion/IccConversionDataClut.cs b/tests/ImageSharp.Tests/TestDataIcc/Conversion/IccConversionDataClut.cs new file mode 100644 index 0000000000..29474187b4 --- /dev/null +++ b/tests/ImageSharp.Tests/TestDataIcc/Conversion/IccConversionDataClut.cs @@ -0,0 +1,163 @@ +// Copyright (c) Six Labors. +// Licensed under the Apache License, Version 2.0. + +using System.Numerics; +using SixLabors.ImageSharp.Metadata.Profiles.Icc; + +namespace SixLabors.ImageSharp.Tests.TestDataIcc.Conversion +{ + public class IccConversionDataClut + { + internal static IccClut Clut3x2 = new IccClut( + new[] + { + new[] { 0.1f, 0.1f }, + new[] { 0.2f, 0.2f }, + new[] { 0.3f, 0.3f }, + + new[] { 0.11f, 0.11f }, + new[] { 0.21f, 0.21f }, + new[] { 0.31f, 0.31f }, + + new[] { 0.12f, 0.12f }, + new[] { 0.22f, 0.22f }, + new[] { 0.32f, 0.32f }, + + new[] { 0.13f, 0.13f }, + new[] { 0.23f, 0.23f }, + new[] { 0.33f, 0.33f }, + + new[] { 0.14f, 0.14f }, + new[] { 0.24f, 0.24f }, + new[] { 0.34f, 0.34f }, + + new[] { 0.15f, 0.15f }, + new[] { 0.25f, 0.25f }, + new[] { 0.35f, 0.35f }, + + new[] { 0.16f, 0.16f }, + new[] { 0.26f, 0.26f }, + new[] { 0.36f, 0.36f }, + + new[] { 0.17f, 0.17f }, + new[] { 0.27f, 0.27f }, + new[] { 0.37f, 0.37f }, + + new[] { 0.18f, 0.18f }, + new[] { 0.28f, 0.28f }, + new[] { 0.38f, 0.38f }, + }, + new byte[] { 3, 3, 3 }, + IccClutDataType.Float); + + internal static IccClut Clut3x1 = new IccClut( + new[] + { + new[] { 0.10f }, + new[] { 0.20f }, + new[] { 0.30f }, + + new[] { 0.11f }, + new[] { 0.21f }, + new[] { 0.31f }, + + new[] { 0.12f }, + new[] { 0.22f }, + new[] { 0.32f }, + + new[] { 0.13f }, + new[] { 0.23f }, + new[] { 0.33f }, + + new[] { 0.14f }, + new[] { 0.24f }, + new[] { 0.34f }, + + new[] { 0.15f }, + new[] { 0.25f }, + new[] { 0.35f }, + + new[] { 0.16f }, + new[] { 0.26f }, + new[] { 0.36f }, + + new[] { 0.17f }, + new[] { 0.27f }, + new[] { 0.37f }, + + new[] { 0.18f }, + new[] { 0.28f }, + new[] { 0.38f }, + }, + new byte[] { 3, 3, 3 }, + IccClutDataType.Float); + + internal static IccClut Clut2x2 = new IccClut( + new[] + { + new[] { 0.1f, 0.9f }, + new[] { 0.2f, 0.8f }, + new[] { 0.3f, 0.7f }, + + new[] { 0.4f, 0.6f }, + new[] { 0.5f, 0.5f }, + new[] { 0.6f, 0.4f }, + + new[] { 0.7f, 0.3f }, + new[] { 0.8f, 0.2f }, + new[] { 0.9f, 0.1f }, + }, + new byte[] { 3, 3 }, + IccClutDataType.Float); + + internal static IccClut Clut2x1 = new IccClut( + new[] + { + new[] { 0.1f }, + new[] { 0.2f }, + new[] { 0.3f }, + + new[] { 0.4f }, + new[] { 0.5f }, + new[] { 0.6f }, + + new[] { 0.7f }, + new[] { 0.8f }, + new[] { 0.9f }, + }, + new byte[] { 3, 3 }, + IccClutDataType.Float); + + internal static IccClut Clut1x2 = new IccClut( + new[] + { + new[] { 0f, 0.5f }, + new[] { 0.25f, 0.75f, }, + new[] { 0.5f, 1f }, + }, + new byte[] { 3 }, + IccClutDataType.Float); + + internal static IccClut Clut1x1 = new IccClut( + new[] + { + new[] { 0f }, + new[] { 0.5f }, + new[] { 1f }, + }, + new byte[] { 3 }, + IccClutDataType.Float); + + public static object[][] ClutConversionTestData = + { + new object[] { Clut3x2, new Vector4(0.75f, 0.75f, 0.75f, 0), new Vector4(0.31f, 0.31f, 0, 0) }, + new object[] { Clut3x1, new Vector4(0.2f, 0.6f, 0.8f, 0), new Vector4(0.276f, 0, 0, 0) }, + new object[] { Clut3x1, new Vector4(0.75f, 0.75f, 0.75f, 0), new Vector4(0.31f, 0, 0, 0) }, + new object[] { Clut2x2, new Vector4(0.2f, 0.6f, 0, 0), new Vector4(0.46f, 0.54f, 0, 0) }, + new object[] { Clut2x2, new Vector4(0.25f, 0.75f, 0, 0), new Vector4(0.4f, 0.6f, 0, 0) }, + new object[] { Clut2x1, new Vector4(0.25f, 0.75f, 0, 0), new Vector4(0.4f, 0, 0, 0) }, + new object[] { Clut1x2, new Vector4(0.25f, 0, 0, 0), new Vector4(0.125f, 0.625f, 0, 0) }, + new object[] { Clut1x1, new Vector4(0.25f, 0, 0, 0), new Vector4(0.25f, 0, 0, 0) }, + }; + } +} diff --git a/tests/ImageSharp.Tests/TestDataIcc/Conversion/IccConversionData.Lut.cs b/tests/ImageSharp.Tests/TestDataIcc/Conversion/IccConversionDataLut.cs similarity index 79% rename from tests/ImageSharp.Tests/TestDataIcc/Conversion/IccConversionData.Lut.cs rename to tests/ImageSharp.Tests/TestDataIcc/Conversion/IccConversionDataLut.cs index 0c96b2777c..f9e5bafd11 100644 --- a/tests/ImageSharp.Tests/TestDataIcc/Conversion/IccConversionData.Lut.cs +++ b/tests/ImageSharp.Tests/TestDataIcc/Conversion/IccConversionDataLut.cs @@ -1,12 +1,13 @@ -// Copyright (c) Six Labors. +// Copyright (c) Six Labors. // Licensed under the Apache License, Version 2.0. -namespace SixLabors.ImageSharp.Tests.Colorspaces.Icc +namespace SixLabors.ImageSharp.Tests.TestDataIcc.Conversion { public class IccConversionDataLut { - private static float[] LutEven = { 0, 0.5f, 1 }; - private static float[] LutUneven = { 0, 0.7f, 1 }; + private static readonly float[] LutEven = { 0, 0.5f, 1 }; + + private static readonly float[] LutUneven = { 0, 0.7f, 1 }; public static object[][] LutConversionTestData = { diff --git a/tests/ImageSharp.Tests/TestDataIcc/Conversion/IccConversionData.LutAB.cs b/tests/ImageSharp.Tests/TestDataIcc/Conversion/IccConversionDataLutAB.cs similarity index 56% rename from tests/ImageSharp.Tests/TestDataIcc/Conversion/IccConversionData.LutAB.cs rename to tests/ImageSharp.Tests/TestDataIcc/Conversion/IccConversionDataLutAB.cs index f989117522..aca6599c27 100644 --- a/tests/ImageSharp.Tests/TestDataIcc/Conversion/IccConversionData.LutAB.cs +++ b/tests/ImageSharp.Tests/TestDataIcc/Conversion/IccConversionDataLutAB.cs @@ -1,44 +1,51 @@ -// Copyright (c) Six Labors. +// Copyright (c) Six Labors. // Licensed under the Apache License, Version 2.0. using System.Numerics; using SixLabors.ImageSharp.Metadata.Profiles.Icc; -namespace SixLabors.ImageSharp.Tests.Colorspaces.Icc +namespace SixLabors.ImageSharp.Tests.TestDataIcc.Conversion { public class IccConversionDataLutAB { - private static IccLutAToBTagDataEntry lutAtoB_SingleCurve = new IccLutAToBTagDataEntry( + private static readonly IccLutAToBTagDataEntry LutAtoBSingleCurve = new IccLutAToBTagDataEntry( new IccTagDataEntry[] { IccConversionDataTrc.IdentityCurve, IccConversionDataTrc.IdentityCurve, IccConversionDataTrc.IdentityCurve }, - null, null, null, null, null); + null, + null, + null, + null, + null); // also need: // # CurveM + matrix // # CurveA + CLUT + CurveB // # CurveA + CLUT + CurveM + Matrix + CurveB - - private static IccLutBToATagDataEntry lutBtoA_SingleCurve = new IccLutBToATagDataEntry( + private static readonly IccLutBToATagDataEntry LutBtoASingleCurve = new IccLutBToATagDataEntry( new IccTagDataEntry[] { IccConversionDataTrc.IdentityCurve, IccConversionDataTrc.IdentityCurve, IccConversionDataTrc.IdentityCurve }, - null, null, null, null, null); + null, + null, + null, + null, + null); public static object[][] LutAToBConversionTestData = { - new object[] { lutAtoB_SingleCurve, new Vector4(0.2f, 0.3f, 0.4f, 0), new Vector4(0.2f, 0.3f, 0.4f, 0) }, + new object[] { LutAtoBSingleCurve, new Vector4(0.2f, 0.3f, 0.4f, 0), new Vector4(0.2f, 0.3f, 0.4f, 0) }, }; public static object[][] LutBToAConversionTestData = { - new object[] { lutBtoA_SingleCurve, new Vector4(0.2f, 0.3f, 0.4f, 0), new Vector4(0.2f, 0.3f, 0.4f, 0) }, + new object[] { LutBtoASingleCurve, new Vector4(0.2f, 0.3f, 0.4f, 0), new Vector4(0.2f, 0.3f, 0.4f, 0) }, }; } } diff --git a/tests/ImageSharp.Tests/TestDataIcc/Conversion/IccConversionData.LutEntry.cs b/tests/ImageSharp.Tests/TestDataIcc/Conversion/IccConversionDataLutEntry.cs similarity index 80% rename from tests/ImageSharp.Tests/TestDataIcc/Conversion/IccConversionData.LutEntry.cs rename to tests/ImageSharp.Tests/TestDataIcc/Conversion/IccConversionDataLutEntry.cs index f676490f1d..95b94793b9 100644 --- a/tests/ImageSharp.Tests/TestDataIcc/Conversion/IccConversionData.LutEntry.cs +++ b/tests/ImageSharp.Tests/TestDataIcc/Conversion/IccConversionDataLutEntry.cs @@ -4,7 +4,7 @@ using System.Numerics; using SixLabors.ImageSharp.Metadata.Profiles.Icc; -namespace SixLabors.ImageSharp.Tests.Colorspaces.Icc +namespace SixLabors.ImageSharp.Tests.TestDataIcc.Conversion { public class IccConversionDataLutEntry { @@ -13,26 +13,26 @@ namespace SixLabors.ImageSharp.Tests.Colorspaces.Icc private static readonly IccLut LutIdentity = CreateIdentityLut(0, 1); private static readonly IccLut8TagDataEntry Lut8 = new IccLut8TagDataEntry( - new IccLut[] { Lut256, Lut256 }, + new[] { Lut256, Lut256 }, IccConversionDataClut.Clut2x1, - new IccLut[] { Lut256 }); + new[] { Lut256 }); private static readonly IccLut16TagDataEntry Lut16 = new IccLut16TagDataEntry( - new IccLut[] { Lut32, Lut32 }, + new[] { Lut32, Lut32 }, IccConversionDataClut.Clut2x1, - new IccLut[] { LutIdentity }); + new[] { LutIdentity }); private static readonly IccLut8TagDataEntry Lut8Matrix = new IccLut8TagDataEntry( IccConversionDataMatrix.Matrix3x3Random, - new IccLut[] { Lut256, Lut256, Lut256 }, + new[] { Lut256, Lut256, Lut256 }, IccConversionDataClut.Clut3x1, - new IccLut[] { Lut256 }); + new[] { Lut256 }); private static readonly IccLut16TagDataEntry Lut16Matrix = new IccLut16TagDataEntry( IccConversionDataMatrix.Matrix3x3Random, - new IccLut[] { Lut32, Lut32, Lut32 }, + new[] { Lut32, Lut32, Lut32 }, IccConversionDataClut.Clut3x1, - new IccLut[] { LutIdentity }); + new[] { LutIdentity }); private static IccLut CreateLut(int length) { @@ -45,10 +45,7 @@ namespace SixLabors.ImageSharp.Tests.Colorspaces.Icc return new IccLut(values); } - private static IccLut CreateIdentityLut(float min, float max) - { - return new IccLut(new float[] { min, max }); - } + private static IccLut CreateIdentityLut(float min, float max) => new IccLut(new[] { min, max }); public static object[][] Lut8ConversionTestData = { diff --git a/tests/ImageSharp.Tests/TestDataIcc/Conversion/IccConversionData.Matrix.cs b/tests/ImageSharp.Tests/TestDataIcc/Conversion/IccConversionDataMatrix.cs similarity index 76% rename from tests/ImageSharp.Tests/TestDataIcc/Conversion/IccConversionData.Matrix.cs rename to tests/ImageSharp.Tests/TestDataIcc/Conversion/IccConversionDataMatrix.cs index 42b8f2bceb..ec397d6658 100644 --- a/tests/ImageSharp.Tests/TestDataIcc/Conversion/IccConversionData.Matrix.cs +++ b/tests/ImageSharp.Tests/TestDataIcc/Conversion/IccConversionDataMatrix.cs @@ -1,16 +1,26 @@ -// Copyright (c) Six Labors. +// Copyright (c) Six Labors. // Licensed under the Apache License, Version 2.0. using System.Numerics; -using SixLabors.ImageSharp.Metadata.Profiles.Icc; -namespace SixLabors.ImageSharp.Tests.Colorspaces.Icc +namespace SixLabors.ImageSharp.Tests.TestDataIcc.Conversion { public class IccConversionDataMatrix { - public static float[,] Matrix3x3Random = { { 0.1f, 0.2f, 0.3f }, { 0.4f, 0.5f, 0.6f }, { 0.7f, 0.8f, 0.9f } }; - public static float[,] Matrix3x3Identity = { { 1, 0, 0 }, { 0, 1, 0 }, { 0, 0, 1 } }; - + public static float[,] Matrix3x3Random = + { + { 0.1f, 0.2f, 0.3f }, + { 0.4f, 0.5f, 0.6f }, + { 0.7f, 0.8f, 0.9f } + }; + + public static float[,] Matrix3x3Identity = + { + { 1, 0, 0 }, + { 0, 1, 0 }, + { 0, 0, 1 } + }; + public static object[][] MatrixConversionTestData = { new object[] { CreateMatrix(Matrix3x3Identity), Vector3.Zero, new Vector4(0.5f, 0.5f, 0.5f, 0), new Vector4(0.5f, 0.5f, 0.5f, 0) }, @@ -20,10 +30,8 @@ namespace SixLabors.ImageSharp.Tests.Colorspaces.Icc new object[] { CreateMatrix(Matrix3x3Random), Vector3.Zero, new Vector4(0.2f, 0.4f, 0.7f, 0), new Vector4(0.67f, 0.8f, 0.93f, 0) }, new object[] { CreateMatrix(Matrix3x3Random), new Vector3(0.1f, 0.2f, 0.3f), new Vector4(0.2f, 0.4f, 0.7f, 0), new Vector4(0.77f, 1, 1.23f, 0) }, }; - - private static Matrix4x4 CreateMatrix(float[,] matrix) - { - return new Matrix4x4( + + private static Matrix4x4 CreateMatrix(float[,] matrix) => new Matrix4x4( matrix[0, 0], matrix[0, 1], matrix[0, 2], @@ -40,6 +48,5 @@ namespace SixLabors.ImageSharp.Tests.Colorspaces.Icc 0, 0, 1); - } } } diff --git a/tests/ImageSharp.Tests/TestDataIcc/Conversion/IccConversionDataMultiProcessElement.cs b/tests/ImageSharp.Tests/TestDataIcc/Conversion/IccConversionDataMultiProcessElement.cs new file mode 100644 index 0000000000..8848576efa --- /dev/null +++ b/tests/ImageSharp.Tests/TestDataIcc/Conversion/IccConversionDataMultiProcessElement.cs @@ -0,0 +1,78 @@ +// Copyright (c) Six Labors. +// Licensed under the Apache License, Version 2.0. + +using SixLabors.ImageSharp.Metadata.Profiles.Icc; + +namespace SixLabors.ImageSharp.Tests.TestDataIcc.Conversion +{ + public class IccConversionDataMultiProcessElement + { + private static readonly IccMatrixProcessElement Matrix = new IccMatrixProcessElement( + new float[,] + { + { 2, 4, 6 }, + { 3, 5, 7 }, + }, new float[] { 3, 4, 5 }); + + private static readonly IccClut Clut = new IccClut( + new[] + { + new[] { 0.2f, 0.3f }, + new[] { 0.4f, 0.5f }, + + new[] { 0.21f, 0.31f }, + new[] { 0.41f, 0.51f }, + + new[] { 0.22f, 0.32f }, + new[] { 0.42f, 0.52f }, + + new[] { 0.23f, 0.33f }, + new[] { 0.43f, 0.53f }, + }, new byte[] { 2, 2, 2 }, + IccClutDataType.Float); + + private static readonly IccFormulaCurveElement FormulaCurveElement1 = new IccFormulaCurveElement(IccFormulaCurveType.Type1, 2.2f, 0.7f, 0.2f, 0.3f, 0, 0); + private static readonly IccFormulaCurveElement FormulaCurveElement2 = new IccFormulaCurveElement(IccFormulaCurveType.Type2, 2.2f, 0.9f, 0.9f, 0.02f, 0.1f, 0); + private static readonly IccFormulaCurveElement FormulaCurveElement3 = new IccFormulaCurveElement(IccFormulaCurveType.Type3, 0, 0.9f, 0.9f, 1.02f, 0.1f, 0.02f); + + private static readonly IccCurveSetProcessElement CurveSet1DFormula1 = Create1DSingleCurveSet(FormulaCurveElement1); + private static readonly IccCurveSetProcessElement CurveSet1DFormula2 = Create1DSingleCurveSet(FormulaCurveElement2); + private static readonly IccCurveSetProcessElement CurveSet1DFormula3 = Create1DSingleCurveSet(FormulaCurveElement3); + + private static readonly IccCurveSetProcessElement CurveSet1DFormula1And2 = Create1DMultiCurveSet(new[] { 0.5f }, FormulaCurveElement1, FormulaCurveElement2); + + private static readonly IccClutProcessElement ClutElement = new IccClutProcessElement(Clut); + + private static IccCurveSetProcessElement Create1DSingleCurveSet(IccCurveSegment segment) + { + var curve = new IccOneDimensionalCurve(new float[0], new[] { segment }); + return new IccCurveSetProcessElement(new[] { curve }); + } + + private static IccCurveSetProcessElement Create1DMultiCurveSet(float[] breakPoints, params IccCurveSegment[] segments) + { + var curve = new IccOneDimensionalCurve(breakPoints, segments); + return new IccCurveSetProcessElement(new[] { curve }); + } + + public static object[][] MpeCurveConversionTestData = + { + new object[] { CurveSet1DFormula1, new[] { 0.51f }, new[] { 0.575982451f } }, + new object[] { CurveSet1DFormula2, new[] { 0.52f }, new[] { -0.4684991f } }, + new object[] { CurveSet1DFormula3, new[] { 0.53f }, new[] { 0.86126f } }, + + new object[] { CurveSet1DFormula1And2, new[] { 0.31f }, new[] { 0.445982f } }, + new object[] { CurveSet1DFormula1And2, new[] { 0.61f }, new[] { -0.341274023f } }, + }; + + public static object[][] MpeMatrixConversionTestData = + { + new object[] { Matrix, new float[] { 2, 4 }, new float[] { 19, 32, 45 } } + }; + + public static object[][] MpeClutConversionTestData = + { + new object[] { ClutElement, new[] { 0.5f, 0.5f, 0.5f }, new[] { 0.5f, 0.5f } } + }; + } +} diff --git a/tests/ImageSharp.Tests/TestDataIcc/Conversion/IccConversionData.Trc.cs b/tests/ImageSharp.Tests/TestDataIcc/Conversion/IccConversionDataTrc.cs similarity index 97% rename from tests/ImageSharp.Tests/TestDataIcc/Conversion/IccConversionData.Trc.cs rename to tests/ImageSharp.Tests/TestDataIcc/Conversion/IccConversionDataTrc.cs index 5bf745be42..4d813bd2b7 100644 --- a/tests/ImageSharp.Tests/TestDataIcc/Conversion/IccConversionData.Trc.cs +++ b/tests/ImageSharp.Tests/TestDataIcc/Conversion/IccConversionDataTrc.cs @@ -1,10 +1,10 @@ -// Copyright (c) Six Labors. +// Copyright (c) Six Labors. // Licensed under the Apache License, Version 2.0. using System.Numerics; using SixLabors.ImageSharp.Metadata.Profiles.Icc; -namespace SixLabors.ImageSharp.Tests.Colorspaces.Icc +namespace SixLabors.ImageSharp.Tests.TestDataIcc.Conversion { public class IccConversionDataTrc {