Browse Source

Fix warnings

pull/1567/head
Brian Popow 5 years ago
parent
commit
081208574d
  1. 10
      tests/ImageSharp.Tests/Colorspaces/CieLabTests.cs
  2. 8
      tests/ImageSharp.Tests/Colorspaces/CieLchTests.cs
  3. 8
      tests/ImageSharp.Tests/Colorspaces/CieLchuvTests.cs
  4. 8
      tests/ImageSharp.Tests/Colorspaces/CieLuvTests.cs
  5. 10
      tests/ImageSharp.Tests/Colorspaces/CieXyChromaticityCoordinatesTests.cs
  6. 8
      tests/ImageSharp.Tests/Colorspaces/CieXyyTests.cs
  7. 8
      tests/ImageSharp.Tests/Colorspaces/CieXyzTests.cs
  8. 10
      tests/ImageSharp.Tests/Colorspaces/CmykTests.cs
  9. 75
      tests/ImageSharp.Tests/Colorspaces/Conversion/ApproximateColorspaceComparer.cs
  10. 10
      tests/ImageSharp.Tests/Colorspaces/HslTests.cs
  11. 10
      tests/ImageSharp.Tests/Colorspaces/HsvTests.cs
  12. 8
      tests/ImageSharp.Tests/Colorspaces/HunterLabTests.cs
  13. 5
      tests/ImageSharp.Tests/Colorspaces/Icc/Calculators/ClutCalculatorTests.cs
  14. 5
      tests/ImageSharp.Tests/Colorspaces/Icc/Calculators/CurveCalculatorTests.cs
  15. 5
      tests/ImageSharp.Tests/Colorspaces/Icc/Calculators/LutABCalculatorTests.cs
  16. 5
      tests/ImageSharp.Tests/Colorspaces/Icc/Calculators/LutCalculatorTests.cs
  17. 5
      tests/ImageSharp.Tests/Colorspaces/Icc/Calculators/LutEntryCalculatorTests.cs
  18. 5
      tests/ImageSharp.Tests/Colorspaces/Icc/Calculators/MatrixCalculatorTests.cs
  19. 5
      tests/ImageSharp.Tests/Colorspaces/Icc/Calculators/ParametricCurveCalculatorTests.cs
  20. 5
      tests/ImageSharp.Tests/Colorspaces/Icc/Calculators/TrcCalculatorTests.cs
  21. 10
      tests/ImageSharp.Tests/Colorspaces/LinearRgbTests.cs
  22. 8
      tests/ImageSharp.Tests/Colorspaces/LmsTests.cs
  23. 8
      tests/ImageSharp.Tests/Colorspaces/YCbCrTests.cs
  24. 163
      tests/ImageSharp.Tests/TestDataIcc/Conversion/IccConversionData.Clut.cs
  25. 76
      tests/ImageSharp.Tests/TestDataIcc/Conversion/IccConversionData.MultiProcessElement.cs
  26. 163
      tests/ImageSharp.Tests/TestDataIcc/Conversion/IccConversionDataClut.cs
  27. 9
      tests/ImageSharp.Tests/TestDataIcc/Conversion/IccConversionDataLut.cs
  28. 25
      tests/ImageSharp.Tests/TestDataIcc/Conversion/IccConversionDataLutAB.cs
  29. 23
      tests/ImageSharp.Tests/TestDataIcc/Conversion/IccConversionDataLutEntry.cs
  30. 29
      tests/ImageSharp.Tests/TestDataIcc/Conversion/IccConversionDataMatrix.cs
  31. 78
      tests/ImageSharp.Tests/TestDataIcc/Conversion/IccConversionDataMultiProcessElement.cs
  32. 4
      tests/ImageSharp.Tests/TestDataIcc/Conversion/IccConversionDataTrc.cs

10
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()));
}

8
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));

8
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));

8
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));

10
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()));
}

8
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));

8
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));

10
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()));
}
}
}
}

75
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;
/// <inheritdoc/>
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);
}
/// <inheritdoc/>
public int GetHashCode(Rgb obj) => obj.GetHashCode();
/// <inheritdoc/>
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);
}
/// <inheritdoc/>
public int GetHashCode(LinearRgb obj) => obj.GetHashCode();
/// <inheritdoc/>
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);
}
/// <inheritdoc/>
public int GetHashCode(CieLab obj) => obj.GetHashCode();
/// <inheritdoc/>
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);
}
/// <inheritdoc/>
public int GetHashCode(CieLch obj) => obj.GetHashCode();
/// <inheritdoc/>
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);
}
/// <inheritdoc/>
public int GetHashCode(CieLchuv obj) => obj.GetHashCode();
/// <inheritdoc/>
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);
}
/// <inheritdoc/>
public int GetHashCode(CieLuv obj) => obj.GetHashCode();
/// <inheritdoc/>
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);
}
/// <inheritdoc/>
public int GetHashCode(CieXyz obj) => obj.GetHashCode();
/// <inheritdoc/>
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);
}
/// <inheritdoc/>
public int GetHashCode(CieXyy obj) => obj.GetHashCode();
/// <inheritdoc/>
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);
}
/// <inheritdoc/>
public int GetHashCode(Cmyk obj) => obj.GetHashCode();
/// <inheritdoc/>
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);
}
/// <inheritdoc/>
public int GetHashCode(HunterLab obj) => obj.GetHashCode();
/// <inheritdoc/>
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);
}
/// <inheritdoc/>
public int GetHashCode(Hsl obj) => obj.GetHashCode();
/// <inheritdoc/>
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);
}
/// <inheritdoc/>
public int GetHashCode(Hsv obj) => obj.GetHashCode();
/// <inheritdoc/>
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);
}
/// <inheritdoc/>
public int GetHashCode(Lms obj) => obj.GetHashCode();
/// <inheritdoc/>
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);
}
/// <inheritdoc/>
public int GetHashCode(YCbCr obj) => obj.GetHashCode();
@ -222,11 +180,8 @@ namespace SixLabors.ImageSharp.Tests.Colorspaces.Conversion
public int GetHashCode(GammaWorkingSpace obj) => obj.GetHashCode();
/// <inheritdoc/>
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);
}
/// <inheritdoc/>
public int GetHashCode(RgbWorkingSpace obj) => obj.GetHashCode();

10
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()));
}
}
}
}

10
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()));
}
}
}
}

8
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));

5
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);
}
}
}
}

5
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);
}
}
}
}

5
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);
}
}
}
}

5
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);
}
}
}
}

5
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);
}
}
}
}

5
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);
}
}
}
}

5
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);
}
}
}
}

5
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);
}
}
}
}

10
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()));
}
}
}
}

8
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));

8
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));

163
tests/ImageSharp.Tests/TestDataIcc/Conversion/IccConversionData.Clut.cs

@ -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) },
};
}
}

76
tests/ImageSharp.Tests/TestDataIcc/Conversion/IccConversionData.MultiProcessElement.cs

@ -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 } }
};
}
}

163
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) },
};
}
}

9
tests/ImageSharp.Tests/TestDataIcc/Conversion/IccConversionData.Lut.cs → 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 =
{

25
tests/ImageSharp.Tests/TestDataIcc/Conversion/IccConversionData.LutAB.cs → 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) },
};
}
}

23
tests/ImageSharp.Tests/TestDataIcc/Conversion/IccConversionData.LutEntry.cs → 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 =
{

29
tests/ImageSharp.Tests/TestDataIcc/Conversion/IccConversionData.Matrix.cs → 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);
}
}
}

78
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 } }
};
}
}

4
tests/ImageSharp.Tests/TestDataIcc/Conversion/IccConversionData.Trc.cs → 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
{
Loading…
Cancel
Save