From 16179b32113db9d1e5bba9013a8ec739ed00c00f Mon Sep 17 00:00:00 2001 From: James Jackson-South Date: Sat, 27 Feb 2021 18:40:40 +0000 Subject: [PATCH 01/42] Copy original PR changes. --- .../Icc/Calculators/ClutCalculator.cs | 105 +++++++++++ .../Icc/Calculators/ColorTrcCalculator.cs | 54 ++++++ .../CurveCalculator.CalculationType.cs | 15 ++ .../Icc/Calculators/CurveCalculator.cs | 56 ++++++ .../Icc/Calculators/GrayTrcCalculator.cs | 25 +++ .../Icc/Calculators/ISingleCalculator.cs | 18 ++ .../Icc/Calculators/IVector4Calculator.cs | 20 ++ .../LutABCalculator.CalculationType.cs | 19 ++ .../Icc/Calculators/LutABCalculator.cs | 135 ++++++++++++++ .../Icc/Calculators/LutCalculator.cs | 73 ++++++++ .../Icc/Calculators/LutEntryCalculator.cs | 75 ++++++++ .../Icc/Calculators/MatrixCalculator.cs | 27 +++ .../Calculators/ParametricCurveCalculator.cs | 168 +++++++++++++++++ .../Icc/Calculators/TrcCalculator.cs | 47 +++++ .../Icc/IccConverterBase.Checks.cs | 173 ++++++++++++++++++ .../Icc/IccConverterBase.ConversionMethod.cs | 67 +++++++ .../Icc/IccConverterbase.Conversions.cs | 150 +++++++++++++++ .../Implementation/Icc/IccConverterbase.cs | 37 ++++ .../Icc/IccDataToDataConverter.cs | 22 +++ .../Icc/IccDataToPcsConverter.cs | 22 +++ .../Icc/IccPcsToDataConverter.cs | 22 +++ .../Icc/IccPcsToPcsConverter.cs | 22 +++ .../ICC/DataWriter/IccDataWriter.Matrix.cs | 27 --- .../Profiles/ICC/Enums/IccFormulaCurveType.cs | 2 +- .../Exceptions/InvalidIccProfileException.cs | 4 +- .../Icc/Calculators/ClutCalculatorTests.cs | 27 +++ .../Icc/Calculators/CurveCalculatorTests.cs | 26 +++ .../Icc/Calculators/LutABCalculatorTests.cs | 38 ++++ .../Icc/Calculators/LutCalculatorTests.cs | 25 +++ .../Calculators/LutEntryCalculatorTests.cs | 38 ++++ .../Icc/Calculators/MatrixCalculatorTests.cs | 26 +++ .../ParametricCurveCalculatorTests.cs | 26 +++ .../Icc/Calculators/TrcCalculatorTests.cs | 27 +++ .../Conversion/IccConversionData.Clut.cs | 163 +++++++++++++++++ .../Conversion/IccConversionData.Lut.cs | 30 +++ .../Conversion/IccConversionData.LutAB.cs | 44 +++++ .../Conversion/IccConversionData.LutEntry.cs | 65 +++++++ .../Conversion/IccConversionData.Matrix.cs | 45 +++++ .../IccConversionData.MultiProcessElement.cs | 76 ++++++++ .../Conversion/IccConversionData.Trc.cs | 77 ++++++++ 40 files changed, 2088 insertions(+), 30 deletions(-) create mode 100644 src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/ClutCalculator.cs create mode 100644 src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/ColorTrcCalculator.cs create mode 100644 src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/CurveCalculator.CalculationType.cs create mode 100644 src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/CurveCalculator.cs create mode 100644 src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/GrayTrcCalculator.cs create mode 100644 src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/ISingleCalculator.cs create mode 100644 src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/IVector4Calculator.cs create mode 100644 src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/LutABCalculator.CalculationType.cs create mode 100644 src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/LutABCalculator.cs create mode 100644 src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/LutCalculator.cs create mode 100644 src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/LutEntryCalculator.cs create mode 100644 src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/MatrixCalculator.cs create mode 100644 src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/ParametricCurveCalculator.cs create mode 100644 src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/TrcCalculator.cs create mode 100644 src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/IccConverterBase.Checks.cs create mode 100644 src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/IccConverterBase.ConversionMethod.cs create mode 100644 src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/IccConverterbase.Conversions.cs create mode 100644 src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/IccConverterbase.cs create mode 100644 src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/IccDataToDataConverter.cs create mode 100644 src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/IccDataToPcsConverter.cs create mode 100644 src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/IccPcsToDataConverter.cs create mode 100644 src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/IccPcsToPcsConverter.cs create mode 100644 tests/ImageSharp.Tests/Colorspaces/Icc/Calculators/ClutCalculatorTests.cs create mode 100644 tests/ImageSharp.Tests/Colorspaces/Icc/Calculators/CurveCalculatorTests.cs create mode 100644 tests/ImageSharp.Tests/Colorspaces/Icc/Calculators/LutABCalculatorTests.cs create mode 100644 tests/ImageSharp.Tests/Colorspaces/Icc/Calculators/LutCalculatorTests.cs create mode 100644 tests/ImageSharp.Tests/Colorspaces/Icc/Calculators/LutEntryCalculatorTests.cs create mode 100644 tests/ImageSharp.Tests/Colorspaces/Icc/Calculators/MatrixCalculatorTests.cs create mode 100644 tests/ImageSharp.Tests/Colorspaces/Icc/Calculators/ParametricCurveCalculatorTests.cs create mode 100644 tests/ImageSharp.Tests/Colorspaces/Icc/Calculators/TrcCalculatorTests.cs create mode 100644 tests/ImageSharp.Tests/TestDataIcc/Conversion/IccConversionData.Clut.cs create mode 100644 tests/ImageSharp.Tests/TestDataIcc/Conversion/IccConversionData.Lut.cs create mode 100644 tests/ImageSharp.Tests/TestDataIcc/Conversion/IccConversionData.LutAB.cs create mode 100644 tests/ImageSharp.Tests/TestDataIcc/Conversion/IccConversionData.LutEntry.cs create mode 100644 tests/ImageSharp.Tests/TestDataIcc/Conversion/IccConversionData.Matrix.cs create mode 100644 tests/ImageSharp.Tests/TestDataIcc/Conversion/IccConversionData.MultiProcessElement.cs create mode 100644 tests/ImageSharp.Tests/TestDataIcc/Conversion/IccConversionData.Trc.cs diff --git a/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/ClutCalculator.cs b/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/ClutCalculator.cs new file mode 100644 index 0000000000..7f2b355cd8 --- /dev/null +++ b/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/ClutCalculator.cs @@ -0,0 +1,105 @@ +// Copyright (c) Six Labors. +// Licensed under the Apache License, Version 2.0. + +using System; +using System.Numerics; +using SixLabors.ImageSharp.Metadata.Profiles.Icc; + +namespace SixLabors.ImageSharp.ColorSpaces.Conversion.Icc +{ + internal class ClutCalculator : IVector4Calculator + { + private int inputCount; + private int outputCount; + private float[][] lut; + private byte[] gridPointCount; + private int[] indexFactor; + private int nodeCount; + + public ClutCalculator(IccClut clut) + { + Guard.NotNull(clut, nameof(clut)); + + this.inputCount = clut.InputChannelCount; + this.outputCount = clut.OutputChannelCount; + this.lut = clut.Values; + this.gridPointCount = clut.GridPointCount; + this.indexFactor = this.CalculateIndexFactor(clut.InputChannelCount, clut.GridPointCount); + this.nodeCount = (int)Math.Pow(2, clut.InputChannelCount); + } + + public unsafe Vector4 Calculate(Vector4 value) + { + value = Vector4.Clamp(value, Vector4.Zero, Vector4.One); + + Vector4 result = default; + this.Interpolate((float*)&value, this.inputCount, (float*)&result, this.outputCount); + + return result; + } + + private int[] CalculateIndexFactor(int inputCount, byte[] gridPointCount) + { + int[] factors = new int[inputCount]; + int gpc = 1; + for (int j = inputCount - 1; j >= 0; j--) + { + factors[j] = gpc * (gridPointCount[j] - 1); + gpc *= gridPointCount[j]; + } + + return factors; + } + + private unsafe void Interpolate(float* values, int valueLength, float* result, int resultLength) + { + float[][] nodes = new float[this.nodeCount][]; + for (int i = 0; i < nodes.Length; i++) + { + int index = 0; + for (int j = 0; j < valueLength; j++) + { + float fraction = 1f / (this.gridPointCount[j] - 1); + int position = (int)(values[j] / fraction) + ((i >> j) & 1); + index += (int)((this.indexFactor[j] * (position * fraction)) + 0.5f); + } + + nodes[i] = this.lut[index]; + } + + Span factors = stackalloc float[this.nodeCount]; + for (int i = 0; i < factors.Length; i++) + { + float factor = 1; + for (int j = 0; j < valueLength; j++) + { + float fraction = 1f / (this.gridPointCount[j] - 1); + int position = (int)(values[j] / fraction); + + float low = position * fraction; + float high = (position + 1) * fraction; + float percentage = (high - values[j]) / (high - low); + + if (((i >> j) & 1) == 1) + { + factor *= percentage; + } + else + { + factor *= 1 - percentage; + } + } + + factors[i] = factor; + } + + for (int i = 0; i < resultLength; i++) + { + for (int j = 0; j < nodes.Length; j++) + { + result[i] += nodes[j][i] * factors[j]; + } + } + } + } +} diff --git a/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/ColorTrcCalculator.cs b/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/ColorTrcCalculator.cs new file mode 100644 index 0000000000..1eacaf3feb --- /dev/null +++ b/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/ColorTrcCalculator.cs @@ -0,0 +1,54 @@ +// Copyright (c) Six Labors. +// Licensed under the Apache License, Version 2.0. + +using System.Numerics; +using System.Runtime.CompilerServices; +using SixLabors.ImageSharp.Metadata.Profiles.Icc; + +namespace SixLabors.ImageSharp.ColorSpaces.Conversion.Icc +{ + internal class ColorTrcCalculator : IVector4Calculator + { + private TrcCalculator curveCalculator; + private Matrix4x4 matrix; + private bool toPcs; + + public ColorTrcCalculator( + IccXyzTagDataEntry redMatrixColumn, + IccXyzTagDataEntry greenMatrixColumn, + IccXyzTagDataEntry blueMatrixColumn, + IccTagDataEntry redTrc, + IccTagDataEntry greenTrc, + IccTagDataEntry blueTrc, + bool toPcs) + { + this.toPcs = toPcs; + this.curveCalculator = new TrcCalculator(new IccTagDataEntry[] { redTrc, greenTrc, blueTrc }, !toPcs); + + Vector3 mr = redMatrixColumn.Data[0]; + Vector3 mg = greenMatrixColumn.Data[0]; + Vector3 mb = blueMatrixColumn.Data[0]; + this.matrix = new Matrix4x4(mr.X, mr.Y, mr.Z, 0, mg.X, mg.Y, mg.Z, 0, mb.X, mb.Y, mb.Z, 0, 0, 0, 0, 1); + + if (!toPcs) + { + Matrix4x4.Invert(this.matrix, out this.matrix); + } + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public Vector4 Calculate(Vector4 value) + { + if (this.toPcs) + { + value = this.curveCalculator.Calculate(value); + return Vector4.Transform(value, this.matrix); + } + else + { + value = Vector4.Transform(value, this.matrix); + return this.curveCalculator.Calculate(value); + } + } + } +} diff --git a/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/CurveCalculator.CalculationType.cs b/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/CurveCalculator.CalculationType.cs new file mode 100644 index 0000000000..1d892a1863 --- /dev/null +++ b/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/CurveCalculator.CalculationType.cs @@ -0,0 +1,15 @@ +// Copyright (c) Six Labors. +// Licensed under the Apache License, Version 2.0. + +namespace SixLabors.ImageSharp.ColorSpaces.Conversion.Icc +{ + internal partial class CurveCalculator + { + private enum CalculationType + { + Identity, + Gamma, + Lut, + } + } +} diff --git a/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/CurveCalculator.cs b/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/CurveCalculator.cs new file mode 100644 index 0000000000..ea8c014368 --- /dev/null +++ b/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/CurveCalculator.cs @@ -0,0 +1,56 @@ +// Copyright (c) Six Labors. +// Licensed under the Apache License, Version 2.0. + +using System; +using SixLabors.ImageSharp.Metadata.Profiles.Icc; + +namespace SixLabors.ImageSharp.ColorSpaces.Conversion.Icc +{ + internal partial class CurveCalculator : ISingleCalculator + { + private LutCalculator lutCalculator; + private float gamma; + private CalculationType type; + + public CurveCalculator(IccCurveTagDataEntry entry, bool inverted) + { + if (entry.IsIdentityResponse) + { + this.type = CalculationType.Identity; + } + else if (entry.IsGamma) + { + this.gamma = entry.Gamma; + if (inverted) + { + this.gamma = 1f / this.gamma; + } + + this.type = CalculationType.Gamma; + } + else + { + this.lutCalculator = new LutCalculator(entry.CurveData, inverted); + this.type = CalculationType.Lut; + } + } + + public float Calculate(float value) + { + switch (this.type) + { + case CalculationType.Identity: + return value; + + case CalculationType.Gamma: + return MathF.Pow(value, this.gamma); + + case CalculationType.Lut: + return this.lutCalculator.Calculate(value); + + default: + throw new InvalidOperationException("Invalid calculation type"); + } + } + } +} diff --git a/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/GrayTrcCalculator.cs b/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/GrayTrcCalculator.cs new file mode 100644 index 0000000000..01dae3ecba --- /dev/null +++ b/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/GrayTrcCalculator.cs @@ -0,0 +1,25 @@ +// Copyright (c) Six Labors. +// Licensed under the Apache License, Version 2.0. + +using System.Numerics; +using System.Runtime.CompilerServices; +using SixLabors.ImageSharp.Metadata.Profiles.Icc; + +namespace SixLabors.ImageSharp.ColorSpaces.Conversion.Icc +{ + internal class GrayTrcCalculator : IVector4Calculator + { + private TrcCalculator calculator; + + public GrayTrcCalculator(IccTagDataEntry grayTrc, bool toPcs) + { + this.calculator = new TrcCalculator(new IccTagDataEntry[] { grayTrc }, !toPcs); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public Vector4 Calculate(Vector4 value) + { + return this.calculator.Calculate(value); + } + } +} diff --git a/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/ISingleCalculator.cs b/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/ISingleCalculator.cs new file mode 100644 index 0000000000..923da13bd8 --- /dev/null +++ b/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/ISingleCalculator.cs @@ -0,0 +1,18 @@ +// Copyright (c) Six Labors. +// Licensed under the Apache License, Version 2.0. + +namespace SixLabors.ImageSharp.ColorSpaces.Conversion.Icc +{ + /// + /// Represents an ICC calculator with a single floating point value and result + /// + internal interface ISingleCalculator + { + /// + /// Calculates a result from the given value + /// + /// The input value + /// The calculated result + float Calculate(float value); + } +} diff --git a/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/IVector4Calculator.cs b/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/IVector4Calculator.cs new file mode 100644 index 0000000000..e931c38d81 --- /dev/null +++ b/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/IVector4Calculator.cs @@ -0,0 +1,20 @@ +// Copyright (c) Six Labors. +// Licensed under the Apache License, Version 2.0. + +using System.Numerics; + +namespace SixLabors.ImageSharp.ColorSpaces.Conversion.Icc +{ + /// + /// Represents an ICC calculator with values and results + /// + internal interface IVector4Calculator + { + /// + /// Calculates a result from the given values + /// + /// The input values + /// The calculated result + Vector4 Calculate(Vector4 value); + } +} diff --git a/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/LutABCalculator.CalculationType.cs b/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/LutABCalculator.CalculationType.cs new file mode 100644 index 0000000000..5f613270ad --- /dev/null +++ b/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/LutABCalculator.CalculationType.cs @@ -0,0 +1,19 @@ +// Copyright (c) Six Labors. +// Licensed under the Apache License, Version 2.0. + +namespace SixLabors.ImageSharp.ColorSpaces.Conversion.Icc +{ + internal partial class LutABCalculator + { + private enum CalculationType + { + AtoB = 1 << 3, + BtoA = 1 << 4, + + SingleCurve = 1, + CurveMatrix = 2, + CurveClut = 3, + Full = 4, + } + } +} diff --git a/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/LutABCalculator.cs b/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/LutABCalculator.cs new file mode 100644 index 0000000000..d203a65989 --- /dev/null +++ b/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/LutABCalculator.cs @@ -0,0 +1,135 @@ +// Copyright (c) Six Labors. +// Licensed under the Apache License, Version 2.0. + +using System; +using System.Numerics; +using SixLabors.ImageSharp.Metadata.Profiles.Icc; + +namespace SixLabors.ImageSharp.ColorSpaces.Conversion.Icc +{ + internal partial class LutABCalculator : IVector4Calculator + { + private CalculationType type; + private TrcCalculator curveACalculator; + private TrcCalculator curveBCalculator; + private TrcCalculator curveMCalculator; + private MatrixCalculator matrixCalculator; + private ClutCalculator clutCalculator; + + public LutABCalculator(IccLutAToBTagDataEntry entry) + { + Guard.NotNull(entry, nameof(entry)); + this.Init(entry.CurveA, entry.CurveB, entry.CurveM, entry.Matrix3x1, entry.Matrix3x3, entry.ClutValues); + this.type |= CalculationType.AtoB; + } + + public LutABCalculator(IccLutBToATagDataEntry entry) + { + Guard.NotNull(entry, nameof(entry)); + this.Init(entry.CurveA, entry.CurveB, entry.CurveM, entry.Matrix3x1, entry.Matrix3x3, entry.ClutValues); + this.type |= CalculationType.BtoA; + } + + public Vector4 Calculate(Vector4 value) + { + switch (this.type) + { + case CalculationType.Full | CalculationType.AtoB: + value = this.curveACalculator.Calculate(value); + value = this.clutCalculator.Calculate(value); + value = this.curveMCalculator.Calculate(value); + value = this.matrixCalculator.Calculate(value); + return this.curveBCalculator.Calculate(value); + + case CalculationType.Full | CalculationType.BtoA: + value = this.curveBCalculator.Calculate(value); + value = this.matrixCalculator.Calculate(value); + value = this.curveMCalculator.Calculate(value); + value = this.clutCalculator.Calculate(value); + return this.curveACalculator.Calculate(value); + + case CalculationType.CurveClut | CalculationType.AtoB: + value = this.curveACalculator.Calculate(value); + value = this.clutCalculator.Calculate(value); + return this.curveBCalculator.Calculate(value); + + case CalculationType.CurveClut | CalculationType.BtoA: + value = this.curveBCalculator.Calculate(value); + value = this.clutCalculator.Calculate(value); + return this.curveACalculator.Calculate(value); + + case CalculationType.CurveMatrix | CalculationType.AtoB: + value = this.curveMCalculator.Calculate(value); + value = this.matrixCalculator.Calculate(value); + return this.curveBCalculator.Calculate(value); + + case CalculationType.CurveMatrix | CalculationType.BtoA: + value = this.curveBCalculator.Calculate(value); + value = this.matrixCalculator.Calculate(value); + return this.curveMCalculator.Calculate(value); + + case CalculationType.SingleCurve | CalculationType.AtoB: + case CalculationType.SingleCurve | CalculationType.BtoA: + return this.curveBCalculator.Calculate(value); + + default: + throw new InvalidOperationException("Invalid calculation type"); + } + } + + private void Init(IccTagDataEntry[] curveA, IccTagDataEntry[] curveB, IccTagDataEntry[] curveM, Vector3? matrix3x1, Matrix4x4? matrix3x3, IccClut clut) + { + bool hasACurve = curveA != null; + bool hasBCurve = curveB != null; + bool hasMCurve = curveM != null; + bool hasMatrix = matrix3x1 != null && matrix3x3 != null; + bool hasClut = clut != null; + + if (hasBCurve && hasMatrix && hasMCurve && hasClut && hasACurve) + { + this.type = CalculationType.Full; + } + else if (hasBCurve && hasClut && hasACurve) + { + this.type = CalculationType.CurveClut; + } + else if (hasBCurve && hasMatrix && hasMCurve) + { + this.type = CalculationType.CurveMatrix; + } + else if (hasBCurve) + { + this.type = CalculationType.SingleCurve; + } + else + { + throw new InvalidIccProfileException("AToB or BToA tag has an invalid configuration"); + } + + if (hasACurve) + { + this.curveACalculator = new TrcCalculator(curveA, false); + } + + if (hasBCurve) + { + this.curveBCalculator = new TrcCalculator(curveB, false); + } + + if (hasMCurve) + { + this.curveMCalculator = new TrcCalculator(curveM, false); + } + + if (hasMatrix) + { + this.matrixCalculator = new MatrixCalculator(matrix3x3.Value, matrix3x1.Value); + } + + if (hasClut) + { + this.clutCalculator = new ClutCalculator(clut); + } + } + } +} diff --git a/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/LutCalculator.cs b/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/LutCalculator.cs new file mode 100644 index 0000000000..10b5023aaf --- /dev/null +++ b/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/LutCalculator.cs @@ -0,0 +1,73 @@ +// Copyright (c) Six Labors. +// Licensed under the Apache License, Version 2.0. + +using System; +using System.Runtime.CompilerServices; + +namespace SixLabors.ImageSharp.ColorSpaces.Conversion.Icc +{ + internal class LutCalculator : ISingleCalculator + { + private float[] lut; + private bool inverse; + + public LutCalculator(float[] lut, bool inverse) + { + Guard.NotNull(lut, nameof(lut)); + + this.lut = lut; + this.inverse = inverse; + } + + public float Calculate(float value) + { + if (this.inverse) + { + return this.LookupInverse(value); + } + else + { + return this.Lookup(value); + } + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + private float Lookup(float value) + { + float factor = value * (this.lut.Length - 1); + int index = (int)factor; + float low = this.lut[index]; + float high = this.lut[index + 1]; + return low + ((high - low) * (factor - index)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + private float LookupInverse(float value) + { + int index = Array.BinarySearch(this.lut, value); + if (index >= 0) + { + return index / (float)(this.lut.Length - 1); + } + + index = ~index; + if (index == 0) + { + return 0; + } + else if (index == this.lut.Length) + { + return 1; + } + + float high = this.lut[index]; + float low = this.lut[index - 1]; + + float valuePercent = (value - low) / (high - low); + float lutRange = 1 / (float)(this.lut.Length - 1); + float lutLow = (index - 1) / (float)(this.lut.Length - 1); + + return lutLow + (valuePercent * lutRange); + } + } +} diff --git a/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/LutEntryCalculator.cs b/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/LutEntryCalculator.cs new file mode 100644 index 0000000000..a2cc7c6645 --- /dev/null +++ b/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/LutEntryCalculator.cs @@ -0,0 +1,75 @@ +// Copyright (c) Six Labors. +// Licensed under the Apache License, Version 2.0. + +using System.Numerics; +using SixLabors.ImageSharp.Metadata.Profiles.Icc; + +namespace SixLabors.ImageSharp.ColorSpaces.Conversion.Icc +{ + internal class LutEntryCalculator : IVector4Calculator + { + private LutCalculator[] inputCurve; + private LutCalculator[] outputCurve; + private ClutCalculator clutCalculator; + private Matrix4x4 matrix; + private bool doTransform; + + public LutEntryCalculator(IccLut8TagDataEntry lut) + { + Guard.NotNull(lut, nameof(lut)); + this.Init(lut.InputValues, lut.OutputValues, lut.ClutValues, lut.Matrix); + } + + public LutEntryCalculator(IccLut16TagDataEntry lut) + { + Guard.NotNull(lut, nameof(lut)); + this.Init(lut.InputValues, lut.OutputValues, lut.ClutValues, lut.Matrix); + } + + public Vector4 Calculate(Vector4 value) + { + if (this.doTransform) + { + value = Vector4.Transform(value, this.matrix); + } + + value = this.CalculateLut(this.inputCurve, value); + value = this.clutCalculator.Calculate(value); + return this.CalculateLut(this.outputCurve, value); + } + + private unsafe Vector4 CalculateLut(LutCalculator[] lut, Vector4 value) + { + value = Vector4.Clamp(value, Vector4.Zero, Vector4.One); + + float* valuePointer = (float*)&value; + for (int i = 0; i < lut.Length; i++) + { + valuePointer[i] = lut[i].Calculate(valuePointer[i]); + } + + return value; + } + + private void Init(IccLut[] inputCurve, IccLut[] outputCurve, IccClut clut, Matrix4x4 matrix) + { + this.inputCurve = this.InitLut(inputCurve); + this.outputCurve = this.InitLut(outputCurve); + this.clutCalculator = new ClutCalculator(clut); + this.matrix = matrix; + + this.doTransform = !matrix.IsIdentity && inputCurve.Length == 3; + } + + private LutCalculator[] InitLut(IccLut[] curves) + { + var calculators = new LutCalculator[curves.Length]; + for (int i = 0; i < curves.Length; i++) + { + calculators[i] = new LutCalculator(curves[i].Values, false); + } + + return calculators; + } + } +} diff --git a/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/MatrixCalculator.cs b/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/MatrixCalculator.cs new file mode 100644 index 0000000000..a672347cc9 --- /dev/null +++ b/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/MatrixCalculator.cs @@ -0,0 +1,27 @@ +// Copyright (c) Six Labors. +// Licensed under the Apache License, Version 2.0. + +using System.Numerics; +using System.Runtime.CompilerServices; + +namespace SixLabors.ImageSharp.ColorSpaces.Conversion.Icc +{ + internal class MatrixCalculator : IVector4Calculator + { + private Matrix4x4 matrix2D; + private Vector4 matrix1D; + + public MatrixCalculator(Matrix4x4 matrix3x3, Vector3 matrix3x1) + { + this.matrix2D = matrix3x3; + this.matrix1D = new Vector4(matrix3x1, 0); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public Vector4 Calculate(Vector4 value) + { + var transformed = Vector4.Transform(value, this.matrix2D); + return Vector4.Add(this.matrix1D, transformed); + } + } +} diff --git a/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/ParametricCurveCalculator.cs b/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/ParametricCurveCalculator.cs new file mode 100644 index 0000000000..a53b32477d --- /dev/null +++ b/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/ParametricCurveCalculator.cs @@ -0,0 +1,168 @@ +// Copyright (c) Six Labors. +// Licensed under the Apache License, Version 2.0. + +using System; +using System.Runtime.CompilerServices; +using SixLabors.ImageSharp.Metadata.Profiles.Icc; + +namespace SixLabors.ImageSharp.ColorSpaces.Conversion.Icc +{ + internal class ParametricCurveCalculator : ISingleCalculator + { + private IccParametricCurve curve; + private IccParametricCurveType type; + private const IccParametricCurveType InvertedFlag = (IccParametricCurveType)(1 << 3); + + public ParametricCurveCalculator(IccParametricCurveTagDataEntry entry, bool inverted) + { + Guard.NotNull(entry, nameof(entry)); + this.curve = entry.Curve; + this.type = entry.Curve.Type; + + if (inverted) + { + this.type |= InvertedFlag; + } + } + + public float Calculate(float value) + { + switch (this.type) + { + case IccParametricCurveType.Type1: + return this.CalculateGamma(value); + case IccParametricCurveType.Cie122_1996: + return this.CalculateCie122(value); + case IccParametricCurveType.Iec61966_3: + return this.CalculateIec61966(value); + case IccParametricCurveType.SRgb: + return this.CalculateSRgb(value); + case IccParametricCurveType.Type5: + return this.CalculateType5(value); + + case IccParametricCurveType.Type1 | InvertedFlag: + return this.CalculateInvertedGamma(value); + case IccParametricCurveType.Cie122_1996 | InvertedFlag: + return this.CalculateInvertedCie122(value); + case IccParametricCurveType.Iec61966_3 | InvertedFlag: + return this.CalculateInvertedIec61966(value); + case IccParametricCurveType.SRgb | InvertedFlag: + return this.CalculateInvertedSRgb(value); + case IccParametricCurveType.Type5 | InvertedFlag: + return this.CalculateInvertedType5(value); + + default: + throw new InvalidIccProfileException("ParametricCurve"); + } + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + private float CalculateGamma(float value) + { + return MathF.Pow(value, this.curve.G); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + private float CalculateCie122(float value) + { + if (value >= -this.curve.B / this.curve.A) + { + return MathF.Pow((this.curve.A * value) + this.curve.B, this.curve.G); + } + else + { + return 0; + } + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + private float CalculateIec61966(float value) + { + if (value >= -this.curve.B / this.curve.A) + { + return MathF.Pow((this.curve.A * value) + this.curve.B, this.curve.G) + this.curve.C; + } + else + { + return this.curve.C; + } + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + private float CalculateSRgb(float value) + { + if (value >= this.curve.D) + { + return MathF.Pow((this.curve.A * value) + this.curve.B, this.curve.G); + } + else + { + return this.curve.C * value; + } + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + private float CalculateType5(float value) + { + if (value >= this.curve.D) + { + return MathF.Pow((this.curve.A * value) + this.curve.B, this.curve.G) + this.curve.E; + } + else + { + return (this.curve.C * value) + this.curve.F; + } + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + private float CalculateInvertedGamma(float value) + { + return MathF.Pow(value, 1 / this.curve.G); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + private float CalculateInvertedCie122(float value) + { + return (MathF.Pow(value, 1 / this.curve.G) - this.curve.B) / this.curve.A; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + private float CalculateInvertedIec61966(float value) + { + if (value >= this.curve.C) + { + return (MathF.Pow(value - this.curve.C, 1 / this.curve.G) - this.curve.B) / this.curve.A; + } + else + { + return -this.curve.B / this.curve.A; + } + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + private float CalculateInvertedSRgb(float value) + { + if (value >= MathF.Pow((this.curve.A * this.curve.D) + this.curve.B, this.curve.G)) + { + return (MathF.Pow(value, 1 / this.curve.G) - this.curve.B) / this.curve.A; + } + else + { + return value / this.curve.C; + } + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + private float CalculateInvertedType5(float value) + { + if (value >= (this.curve.C * this.curve.D) + this.curve.F) + { + return (MathF.Pow(value - this.curve.E, 1 / this.curve.G) - this.curve.B) / this.curve.A; + } + else + { + return (value - this.curve.F) / this.curve.C; + } + } + } +} diff --git a/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/TrcCalculator.cs b/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/TrcCalculator.cs new file mode 100644 index 0000000000..2eacf8f3e5 --- /dev/null +++ b/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/TrcCalculator.cs @@ -0,0 +1,47 @@ +// Copyright (c) Six Labors. +// Licensed under the Apache License, Version 2.0. + +using System.Numerics; +using SixLabors.ImageSharp.Metadata.Profiles.Icc; + +namespace SixLabors.ImageSharp.ColorSpaces.Conversion.Icc +{ + internal class TrcCalculator : IVector4Calculator + { + private ISingleCalculator[] calculators; + + public TrcCalculator(IccTagDataEntry[] entries, bool inverted) + { + Guard.NotNull(entries, nameof(entries)); + + this.calculators = new ISingleCalculator[entries.Length]; + for (int i = 0; i < entries.Length; i++) + { + switch (entries[i]) + { + case IccCurveTagDataEntry curve: + this.calculators[i] = new CurveCalculator(curve, inverted); + break; + + case IccParametricCurveTagDataEntry parametricCurve: + this.calculators[i] = new ParametricCurveCalculator(parametricCurve, inverted); + break; + + default: + throw new InvalidIccProfileException("Invalid Entry."); + } + } + } + + public unsafe Vector4 Calculate(Vector4 value) + { + float* valuePointer = (float*)&value; + for (int i = 0; i < this.calculators.Length; i++) + { + valuePointer[i] = this.calculators[i].Calculate(valuePointer[i]); + } + + return value; + } + } +} diff --git a/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/IccConverterBase.Checks.cs b/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/IccConverterBase.Checks.cs new file mode 100644 index 0000000000..42f6e45802 --- /dev/null +++ b/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/IccConverterBase.Checks.cs @@ -0,0 +1,173 @@ +// Copyright (c) Six Labors. +// Licensed under the Apache License, Version 2.0. + +using System.Linq; +using SixLabors.ImageSharp.Metadata.Profiles.Icc; + +namespace SixLabors.ImageSharp.ColorSpaces.Conversion.Icc +{ + /// + /// Color converter for ICC profiles + /// + internal abstract partial class IccConverterBase + { + private ConversionMethod GetConversionMethod(IccProfile profile, IccRenderingIntent renderingIntent) + { + switch (profile.Header.Class) + { + case IccProfileClass.InputDevice: + case IccProfileClass.DisplayDevice: + case IccProfileClass.OutputDevice: + case IccProfileClass.ColorSpace: + return this.CheckMethod1(profile, renderingIntent); + + case IccProfileClass.DeviceLink: + case IccProfileClass.Abstract: + return this.CheckMethod2(profile); + + default: + return ConversionMethod.Invalid; + } + } + + private ConversionMethod CheckMethod1(IccProfile profile, IccRenderingIntent renderingIntent) + { + ConversionMethod method = ConversionMethod.Invalid; + + method = this.CheckMethodD(profile, renderingIntent); + if (method != ConversionMethod.Invalid) + { + return method; + } + + method = this.CheckMethodA(profile, renderingIntent); + if (method != ConversionMethod.Invalid) + { + return method; + } + + method = this.CheckMethodA0(profile); + if (method != ConversionMethod.Invalid) + { + return method; + } + + method = this.CheckMethodTrc(profile); + if (method != ConversionMethod.Invalid) + { + return method; + } + + return ConversionMethod.Invalid; + } + + private ConversionMethod CheckMethodD(IccProfile profile, IccRenderingIntent renderingIntent) + { + if ((this.HasTag(profile, IccProfileTag.DToB0) || this.HasTag(profile, IccProfileTag.BToD0)) + && renderingIntent == IccRenderingIntent.Perceptual) + { + return ConversionMethod.D0; + } + + if ((this.HasTag(profile, IccProfileTag.DToB1) || this.HasTag(profile, IccProfileTag.BToD1)) + && renderingIntent == IccRenderingIntent.MediaRelativeColorimetric) + { + return ConversionMethod.D1; + } + + if ((this.HasTag(profile, IccProfileTag.DToB2) || this.HasTag(profile, IccProfileTag.BToD2)) + && renderingIntent == IccRenderingIntent.Saturation) + { + return ConversionMethod.D2; + } + + if ((this.HasTag(profile, IccProfileTag.DToB3) || this.HasTag(profile, IccProfileTag.BToD3)) + && renderingIntent == IccRenderingIntent.AbsoluteColorimetric) + { + return ConversionMethod.D3; + } + + return ConversionMethod.Invalid; + } + + private ConversionMethod CheckMethodA(IccProfile profile, IccRenderingIntent renderingIntent) + { + if ((this.HasTag(profile, IccProfileTag.AToB0) || this.HasTag(profile, IccProfileTag.BToA0)) + && renderingIntent == IccRenderingIntent.Perceptual) + { + return ConversionMethod.A0; + } + + if ((this.HasTag(profile, IccProfileTag.AToB1) || this.HasTag(profile, IccProfileTag.BToA1)) + && renderingIntent == IccRenderingIntent.MediaRelativeColorimetric) + { + return ConversionMethod.A1; + } + + if ((this.HasTag(profile, IccProfileTag.AToB2) || this.HasTag(profile, IccProfileTag.BToA2)) + && renderingIntent == IccRenderingIntent.Saturation) + { + return ConversionMethod.A2; + } + + return ConversionMethod.Invalid; + } + + private ConversionMethod CheckMethodA0(IccProfile profile) + { + bool valid = this.HasTag(profile, IccProfileTag.AToB0) || this.HasTag(profile, IccProfileTag.BToA0); + return valid ? ConversionMethod.A0 : ConversionMethod.Invalid; + } + + private ConversionMethod CheckMethodTrc(IccProfile profile) + { + if (this.HasTag(profile, IccProfileTag.RedMatrixColumn) + && this.HasTag(profile, IccProfileTag.GreenMatrixColumn) + && this.HasTag(profile, IccProfileTag.BlueMatrixColumn) + && this.HasTag(profile, IccProfileTag.RedTrc) + && this.HasTag(profile, IccProfileTag.GreenTrc) + && this.HasTag(profile, IccProfileTag.BlueTrc)) + { + return ConversionMethod.ColorTrc; + } + + if (this.HasTag(profile, IccProfileTag.GrayTrc)) + { + return ConversionMethod.GrayTrc; + } + + return ConversionMethod.Invalid; + } + + private ConversionMethod CheckMethod2(IccProfile profile) + { + if (this.HasTag(profile, IccProfileTag.DToB0) || this.HasTag(profile, IccProfileTag.BToD0)) + { + return ConversionMethod.D0; + } + + if (this.HasTag(profile, IccProfileTag.AToB0) || this.HasTag(profile, IccProfileTag.AToB0)) + { + return ConversionMethod.A0; + } + + return ConversionMethod.Invalid; + } + + private bool HasTag(IccProfile profile, IccProfileTag tag) + { + return profile.Entries.Any(t => t.TagSignature == tag); + } + + private IccTagDataEntry GetTag(IccProfile profile, IccProfileTag tag) + { + return profile.Entries.FirstOrDefault(t => t.TagSignature == tag); + } + + private T GetTag(IccProfile profile, IccProfileTag tag) + where T : IccTagDataEntry + { + return profile.Entries.OfType().FirstOrDefault(t => t.TagSignature == tag); + } + } +} diff --git a/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/IccConverterBase.ConversionMethod.cs b/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/IccConverterBase.ConversionMethod.cs new file mode 100644 index 0000000000..727dd1a682 --- /dev/null +++ b/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/IccConverterBase.ConversionMethod.cs @@ -0,0 +1,67 @@ +// Copyright (c) Six Labors. +// Licensed under the Apache License, Version 2.0. + +namespace SixLabors.ImageSharp.ColorSpaces.Conversion.Icc +{ + /// + /// Color converter for ICC profiles + /// + internal abstract partial class IccConverterBase + { + /// + /// Conversion methods with ICC profiles + /// + private enum ConversionMethod + { + /// + /// Conversion using anything but Multi Process Elements with perceptual rendering intent + /// + A0, + + /// + /// Conversion using anything but Multi Process Elements with relative colorimetric rendering intent + /// + A1, + + /// + /// Conversion using anything but Multi Process Elements with saturation rendering intent + /// + A2, + + /// + /// Conversion using Multi Process Elements with perceptual rendering intent + /// + D0, + + /// + /// Conversion using Multi Process Elements with relative colorimetric rendering intent + /// + D1, + + /// + /// Conversion using Multi Process Elements with saturation rendering intent + /// + D2, + + /// + /// Conversion using Multi Process Elements with absolute colorimetric rendering intent + /// + D3, + + /// + /// Conversion of more than one channel using tone reproduction curves + /// + ColorTrc, + + /// + /// Conversion of exactly one channel using a tone reproduction curve + /// + GrayTrc, + + /// + /// No valid conversion method available or found + /// + Invalid, + } + } +} diff --git a/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/IccConverterbase.Conversions.cs b/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/IccConverterbase.Conversions.cs new file mode 100644 index 0000000000..5391f13049 --- /dev/null +++ b/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/IccConverterbase.Conversions.cs @@ -0,0 +1,150 @@ +// Copyright (c) Six Labors. +// Licensed under the Apache License, Version 2.0. + +using System; +using SixLabors.ImageSharp.ColorSpaces.Conversion.Icc; +using SixLabors.ImageSharp.Metadata.Profiles.Icc; + +namespace SixLabors.ImageSharp.ColorSpaces.Conversion.Icc +{ + /// + /// Color converter for ICC profiles + /// + internal abstract partial class IccConverterBase + { + private IVector4Calculator calculator; + + /// + /// Checks the profile for available conversion methods and gathers all the informations necessary for it + /// + /// The profile to use for the conversion + /// True if the conversion is to the Profile Connection Space + /// The wanted rendering intent. Can be ignored if not available + protected void Init(IccProfile profile, bool toPcs, IccRenderingIntent renderingIntent) + { + ConversionMethod method = this.GetConversionMethod(profile, renderingIntent); + switch (method) + { + case ConversionMethod.D0: + this.calculator = toPcs ? + this.InitD(profile, IccProfileTag.DToB0) : + this.InitD(profile, IccProfileTag.BToD0); + break; + + case ConversionMethod.D1: + this.calculator = toPcs ? + this.InitD(profile, IccProfileTag.DToB1) : + this.InitD(profile, IccProfileTag.BToD1); + break; + + case ConversionMethod.D2: + this.calculator = toPcs ? + this.InitD(profile, IccProfileTag.DToB2) : + this.InitD(profile, IccProfileTag.BToD2); + break; + + case ConversionMethod.D3: + this.calculator = toPcs ? + this.InitD(profile, IccProfileTag.DToB3) : + this.InitD(profile, IccProfileTag.BToD3); + break; + + case ConversionMethod.A0: + this.calculator = toPcs ? + this.InitA(profile, IccProfileTag.AToB0) : + this.InitA(profile, IccProfileTag.BToA0); + break; + + case ConversionMethod.A1: + this.calculator = toPcs ? + this.InitA(profile, IccProfileTag.AToB1) : + this.InitA(profile, IccProfileTag.BToA1); + break; + + case ConversionMethod.A2: + this.calculator = toPcs ? + this.InitA(profile, IccProfileTag.AToB2) : + this.InitA(profile, IccProfileTag.BToA2); + break; + + case ConversionMethod.ColorTrc: + this.calculator = this.InitColorTrc(profile, toPcs); + break; + + case ConversionMethod.GrayTrc: + this.calculator = this.InitGrayTrc(profile, toPcs); + break; + + case ConversionMethod.Invalid: + default: + throw new InvalidIccProfileException("Invalid conversion method."); + } + } + + private IVector4Calculator InitA(IccProfile profile, IccProfileTag tag) + { + IccTagDataEntry entry = this.GetTag(profile, tag); + switch (entry) + { + case IccLut8TagDataEntry lut8: + return new LutEntryCalculator(lut8); + case IccLut16TagDataEntry lut16: + return new LutEntryCalculator(lut16); + case IccLutAToBTagDataEntry lutAtoB: + return new LutABCalculator(lutAtoB); + case IccLutBToATagDataEntry lutBtoA: + return new LutABCalculator(lutBtoA); + + default: + throw new InvalidIccProfileException("Invalid entry."); + } + } + + private IVector4Calculator InitD(IccProfile profile, IccProfileTag tag) + { + IccMultiProcessElementsTagDataEntry entry = this.GetTag(profile, tag); + if (entry == null) + { + throw new InvalidIccProfileException("Entry is null."); + } + + throw new NotImplementedException("Multi process elements are not supported"); + } + + private IVector4Calculator InitColorTrc(IccProfile profile, bool toPcs) + { + IccXyzTagDataEntry redMatrixColumn = this.GetTag(profile, IccProfileTag.RedMatrixColumn); + IccXyzTagDataEntry greenMatrixColumn = this.GetTag(profile, IccProfileTag.GreenMatrixColumn); + IccXyzTagDataEntry blueMatrixColumn = this.GetTag(profile, IccProfileTag.BlueMatrixColumn); + + IccTagDataEntry redTrc = this.GetTag(profile, IccProfileTag.RedTrc); + IccTagDataEntry greenTrc = this.GetTag(profile, IccProfileTag.GreenTrc); + IccTagDataEntry blueTrc = this.GetTag(profile, IccProfileTag.BlueTrc); + + if (redMatrixColumn == null || + greenMatrixColumn == null || + blueMatrixColumn == null || + redTrc == null || + greenTrc == null || + blueTrc == null) + { + throw new InvalidIccProfileException("Missing matrix column or channel."); + } + + return new ColorTrcCalculator( + redMatrixColumn, + greenMatrixColumn, + blueMatrixColumn, + redTrc, + greenTrc, + blueTrc, + toPcs); + } + + private IVector4Calculator InitGrayTrc(IccProfile profile, bool toPcs) + { + IccTagDataEntry entry = this.GetTag(profile, IccProfileTag.GrayTrc); + return new GrayTrcCalculator(entry, toPcs); + } + } +} diff --git a/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/IccConverterbase.cs b/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/IccConverterbase.cs new file mode 100644 index 0000000000..53605fb045 --- /dev/null +++ b/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/IccConverterbase.cs @@ -0,0 +1,37 @@ +// Copyright (c) Six Labors. +// Licensed under the Apache License, Version 2.0. + +using System.Numerics; +using System.Runtime.CompilerServices; +using SixLabors.ImageSharp.Metadata.Profiles.Icc; + +namespace SixLabors.ImageSharp.ColorSpaces.Conversion.Icc +{ + /// + /// Color converter for ICC profiles + /// + internal abstract partial class IccConverterBase + { + /// + /// Initializes a new instance of the class. + /// + /// The ICC profile to use for the conversions + /// True if the conversion is to the profile connection space (PCS); False if the conversion is to the data space + protected IccConverterBase(IccProfile profile, bool toPcs) + { + Guard.NotNull(profile, nameof(profile)); + this.Init(profile, toPcs, profile.Header.RenderingIntent); + } + + /// + /// Converts colors with the initially provided ICC profile + /// + /// The value to convert + /// The converted value + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public Vector4 Calculate(Vector4 value) + { + return this.calculator.Calculate(value); + } + } +} diff --git a/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/IccDataToDataConverter.cs b/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/IccDataToDataConverter.cs new file mode 100644 index 0000000000..2a911068f5 --- /dev/null +++ b/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/IccDataToDataConverter.cs @@ -0,0 +1,22 @@ +// Copyright (c) Six Labors. +// Licensed under the Apache License, Version 2.0. + +using SixLabors.ImageSharp.Metadata.Profiles.Icc; + +namespace SixLabors.ImageSharp.ColorSpaces.Conversion.Icc +{ + /// + /// Color converter for ICC profiles + /// + internal class IccDataToDataConverter : IccConverterBase + { + /// + /// Initializes a new instance of the class. + /// + /// The ICC profile to use for the conversions + public IccDataToDataConverter(IccProfile profile) + : base(profile, true) // toPCS is true because in this case the PCS space is also a data space + { + } + } +} diff --git a/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/IccDataToPcsConverter.cs b/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/IccDataToPcsConverter.cs new file mode 100644 index 0000000000..ae274936b2 --- /dev/null +++ b/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/IccDataToPcsConverter.cs @@ -0,0 +1,22 @@ +// Copyright (c) Six Labors. +// Licensed under the Apache License, Version 2.0. + +using SixLabors.ImageSharp.Metadata.Profiles.Icc; + +namespace SixLabors.ImageSharp.ColorSpaces.Conversion.Icc +{ + /// + /// Color converter for ICC profiles + /// + internal class IccDataToPcsConverter : IccConverterBase + { + /// + /// Initializes a new instance of the class. + /// + /// The ICC profile to use for the conversions + public IccDataToPcsConverter(IccProfile profile) + : base(profile, true) + { + } + } +} diff --git a/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/IccPcsToDataConverter.cs b/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/IccPcsToDataConverter.cs new file mode 100644 index 0000000000..c61642635b --- /dev/null +++ b/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/IccPcsToDataConverter.cs @@ -0,0 +1,22 @@ +// Copyright (c) Six Labors. +// Licensed under the Apache License, Version 2.0. + +using SixLabors.ImageSharp.Metadata.Profiles.Icc; + +namespace SixLabors.ImageSharp.ColorSpaces.Conversion.Icc +{ + /// + /// Color converter for ICC profiles + /// + internal class IccPcsToDataConverter : IccConverterBase + { + /// + /// Initializes a new instance of the class. + /// + /// The ICC profile to use for the conversions + public IccPcsToDataConverter(IccProfile profile) + : base(profile, false) + { + } + } +} diff --git a/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/IccPcsToPcsConverter.cs b/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/IccPcsToPcsConverter.cs new file mode 100644 index 0000000000..8cbeeff70d --- /dev/null +++ b/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/IccPcsToPcsConverter.cs @@ -0,0 +1,22 @@ +// Copyright (c) Six Labors. +// Licensed under the Apache License, Version 2.0. + +using SixLabors.ImageSharp.Metadata.Profiles.Icc; + +namespace SixLabors.ImageSharp.ColorSpaces.Conversion.Icc +{ + /// + /// Color converter for ICC profiles + /// + internal class IccPcsToPcsConverter : IccConverterBase + { + /// + /// Initializes a new instance of the class. + /// + /// The ICC profile to use for the conversions + public IccPcsToPcsConverter(IccProfile profile) + : base(profile, true) + { + } + } +} diff --git a/src/ImageSharp/Metadata/Profiles/ICC/DataWriter/IccDataWriter.Matrix.cs b/src/ImageSharp/Metadata/Profiles/ICC/DataWriter/IccDataWriter.Matrix.cs index aa28d25aae..eb6aa875b7 100644 --- a/src/ImageSharp/Metadata/Profiles/ICC/DataWriter/IccDataWriter.Matrix.cs +++ b/src/ImageSharp/Metadata/Profiles/ICC/DataWriter/IccDataWriter.Matrix.cs @@ -79,33 +79,6 @@ public int WriteMatrix(in DenseMatrix value, bool isSingle) return count; } - /// - /// Writes a two dimensional matrix - /// - /// The matrix to write - /// True if the values are encoded as Single; false if encoded as Fix16 - /// The number of bytes written - public int WriteMatrix(float[,] value, bool isSingle) - { - int count = 0; - for (int y = 0; y < value.GetLength(1); y++) - { - for (int x = 0; x < value.GetLength(0); x++) - { - if (isSingle) - { - count += this.WriteSingle(value[x, y]); - } - else - { - count += this.WriteFix16(value[x, y]); - } - } - } - - return count; - } - /// /// Writes a one dimensional matrix /// diff --git a/src/ImageSharp/Metadata/Profiles/ICC/Enums/IccFormulaCurveType.cs b/src/ImageSharp/Metadata/Profiles/ICC/Enums/IccFormulaCurveType.cs index 4372353213..561becf9c8 100644 --- a/src/ImageSharp/Metadata/Profiles/ICC/Enums/IccFormulaCurveType.cs +++ b/src/ImageSharp/Metadata/Profiles/ICC/Enums/IccFormulaCurveType.cs @@ -14,7 +14,7 @@ internal enum IccFormulaCurveType : ushort Type1 = 0, /// - /// Type 1: Y = a * log10 (b * X^γ + c) + d + /// Type 2: Y = a * log10 (b * X^γ + c) + d /// Type2 = 1, diff --git a/src/ImageSharp/Metadata/Profiles/ICC/Exceptions/InvalidIccProfileException.cs b/src/ImageSharp/Metadata/Profiles/ICC/Exceptions/InvalidIccProfileException.cs index cb08d116d1..ebf749174a 100644 --- a/src/ImageSharp/Metadata/Profiles/ICC/Exceptions/InvalidIccProfileException.cs +++ b/src/ImageSharp/Metadata/Profiles/ICC/Exceptions/InvalidIccProfileException.cs @@ -1,4 +1,4 @@ -// Copyright (c) Six Labors. +// Copyright (c) Six Labors. // Licensed under the Apache License, Version 2.0. using System; @@ -30,4 +30,4 @@ public InvalidIccProfileException(string message, Exception inner) { } } -} \ No newline at end of file +} diff --git a/tests/ImageSharp.Tests/Colorspaces/Icc/Calculators/ClutCalculatorTests.cs b/tests/ImageSharp.Tests/Colorspaces/Icc/Calculators/ClutCalculatorTests.cs new file mode 100644 index 0000000000..a03bdceaf6 --- /dev/null +++ b/tests/ImageSharp.Tests/Colorspaces/Icc/Calculators/ClutCalculatorTests.cs @@ -0,0 +1,27 @@ +// 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 Xunit; + +namespace SixLabors.ImageSharp.Tests.Colorspaces.Icc.Calculators +{ + /// + /// Tests ICC + /// + public class ClutCalculatorTests + { + [Theory] + [MemberData(nameof(IccConversionDataClut.ClutConversionTestData), MemberType = typeof(IccConversionDataClut))] + internal void ClutCalculator_WithClut_ReturnsResult(IccClut lut, Vector4 input, Vector4 expected) + { + var calculator = new ClutCalculator(lut); + + Vector4 result = calculator.Calculate(input); + + 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 new file mode 100644 index 0000000000..800a752e4c --- /dev/null +++ b/tests/ImageSharp.Tests/Colorspaces/Icc/Calculators/CurveCalculatorTests.cs @@ -0,0 +1,26 @@ +// 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 Xunit; + +namespace SixLabors.ImageSharp.Tests.Colorspaces.Icc.Calculators +{ + /// + /// Tests ICC + /// + public class CurveCalculatorTests + { + [Theory] + [MemberData(nameof(IccConversionDataTrc.CurveConversionTestData), MemberType = typeof(IccConversionDataTrc))] + internal void CurveCalculator_WithCurveEntry_ReturnsResult(IccCurveTagDataEntry curve, bool inverted, float input, float expected) + { + var calculator = new CurveCalculator(curve, inverted); + + float result = calculator.Calculate(input); + + 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 new file mode 100644 index 0000000000..0581d88718 --- /dev/null +++ b/tests/ImageSharp.Tests/Colorspaces/Icc/Calculators/LutABCalculatorTests.cs @@ -0,0 +1,38 @@ +// 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 Xunit; + +namespace SixLabors.ImageSharp.Tests.Colorspaces.Icc.Calculators +{ + /// + /// Tests ICC + /// + public class LutABCalculatorTests + { + [Theory] + [MemberData(nameof(IccConversionDataLutAB.LutAToBConversionTestData), MemberType = typeof(IccConversionDataLutAB))] + internal void LutABCalculator_WithLutAToB_ReturnsResult(IccLutAToBTagDataEntry lut, Vector4 input, Vector4 expected) + { + var calculator = new LutABCalculator(lut); + + Vector4 result = calculator.Calculate(input); + + VectorAssert.Equal(expected, result, 4); + } + + [Theory] + [MemberData(nameof(IccConversionDataLutAB.LutBToAConversionTestData), MemberType = typeof(IccConversionDataLutAB))] + internal void LutABCalculator_WithLutBToA_ReturnsResult(IccLutBToATagDataEntry lut, Vector4 input, Vector4 expected) + { + var calculator = new LutABCalculator(lut); + + Vector4 result = calculator.Calculate(input); + + 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 new file mode 100644 index 0000000000..c86d2a563d --- /dev/null +++ b/tests/ImageSharp.Tests/Colorspaces/Icc/Calculators/LutCalculatorTests.cs @@ -0,0 +1,25 @@ +// Copyright (c) Six Labors. +// Licensed under the Apache License, Version 2.0. + +using SixLabors.ImageSharp.ColorSpaces.Conversion.Icc; +using Xunit; + +namespace SixLabors.ImageSharp.Tests.Colorspaces.Icc.Calculators +{ + /// + /// Tests ICC + /// + public class LutCalculatorTests + { + [Theory] + [MemberData(nameof(IccConversionDataLut.LutConversionTestData), MemberType = typeof(IccConversionDataLut))] + internal void LutCalculator_WithLut_ReturnsResult(float[] lut, bool inverted, float input, float expected) + { + var calculator = new LutCalculator(lut, inverted); + + float result = calculator.Calculate(input); + + 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 new file mode 100644 index 0000000000..9cda497954 --- /dev/null +++ b/tests/ImageSharp.Tests/Colorspaces/Icc/Calculators/LutEntryCalculatorTests.cs @@ -0,0 +1,38 @@ +// 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 Xunit; + +namespace SixLabors.ImageSharp.Tests.Colorspaces.Icc.Calculators +{ + /// + /// Tests ICC + /// + public class LutEntryCalculatorTests + { + [Theory] + [MemberData(nameof(IccConversionDataLutEntry.Lut8ConversionTestData), MemberType = typeof(IccConversionDataLutEntry))] + internal void LutEntryCalculator_WithLut8_ReturnsResult(IccLut8TagDataEntry lut, Vector4 input, Vector4 expected) + { + var calculator = new LutEntryCalculator(lut); + + Vector4 result = calculator.Calculate(input); + + VectorAssert.Equal(expected, result, 4); + } + + [Theory] + [MemberData(nameof(IccConversionDataLutEntry.Lut16ConversionTestData), MemberType = typeof(IccConversionDataLutEntry))] + internal void LutEntryCalculator_WithLut16_ReturnsResult(IccLut16TagDataEntry lut, Vector4 input, Vector4 expected) + { + var calculator = new LutEntryCalculator(lut); + + Vector4 result = calculator.Calculate(input); + + 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 new file mode 100644 index 0000000000..d1c1512812 --- /dev/null +++ b/tests/ImageSharp.Tests/Colorspaces/Icc/Calculators/MatrixCalculatorTests.cs @@ -0,0 +1,26 @@ +// Copyright (c) Six Labors. +// Licensed under the Apache License, Version 2.0. + +using System.Numerics; +using SixLabors.ImageSharp.ColorSpaces.Conversion.Icc; +using Xunit; + +namespace SixLabors.ImageSharp.Tests.Colorspaces.Icc.Calculators +{ + /// + /// Tests ICC + /// + public class MatrixCalculatorTests + { + [Theory] + [MemberData(nameof(IccConversionDataMatrix.MatrixConversionTestData), MemberType = typeof(IccConversionDataMatrix))] + internal void MatrixCalculator_WithMatrix_ReturnsResult(Matrix4x4 matrix2D, Vector3 matrix1D, Vector4 input, Vector4 expected) + { + var calculator = new MatrixCalculator(matrix2D, matrix1D); + + Vector4 result = calculator.Calculate(input); + + 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 new file mode 100644 index 0000000000..2e7f942641 --- /dev/null +++ b/tests/ImageSharp.Tests/Colorspaces/Icc/Calculators/ParametricCurveCalculatorTests.cs @@ -0,0 +1,26 @@ +// 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 Xunit; + +namespace SixLabors.ImageSharp.Tests.Colorspaces.Icc.Calculators +{ + /// + /// Tests ICC + /// + public class ParametricCurveCalculatorTests + { + [Theory] + [MemberData(nameof(IccConversionDataTrc.ParametricCurveConversionTestData), MemberType = typeof(IccConversionDataTrc))] + internal void ParametricCurveCalculator_WithCurveEntry_ReturnsResult(IccParametricCurveTagDataEntry curve, bool inverted, float input, float expected) + { + var calculator = new ParametricCurveCalculator(curve, inverted); + + float result = calculator.Calculate(input); + + 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 new file mode 100644 index 0000000000..d2d2da9e79 --- /dev/null +++ b/tests/ImageSharp.Tests/Colorspaces/Icc/Calculators/TrcCalculatorTests.cs @@ -0,0 +1,27 @@ +// 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 Xunit; + +namespace SixLabors.ImageSharp.Tests.Colorspaces.Icc.Calculators +{ + /// + /// Tests ICC + /// + public class TrcCalculatorTests + { + [Theory] + [MemberData(nameof(IccConversionDataTrc.TrcArrayConversionTestData), MemberType = typeof(IccConversionDataTrc))] + internal void TrcCalculator_WithCurvesArray_ReturnsResult(IccTagDataEntry[] entries, bool inverted, Vector4 input, Vector4 expected) + { + var calculator = new TrcCalculator(entries, inverted); + + Vector4 result = calculator.Calculate(input); + + VectorAssert.Equal(expected, result, 4); + } + } +} \ No newline at end of file diff --git a/tests/ImageSharp.Tests/TestDataIcc/Conversion/IccConversionData.Clut.cs b/tests/ImageSharp.Tests/TestDataIcc/Conversion/IccConversionData.Clut.cs new file mode 100644 index 0000000000..deb327164b --- /dev/null +++ b/tests/ImageSharp.Tests/TestDataIcc/Conversion/IccConversionData.Clut.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.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.Lut.cs b/tests/ImageSharp.Tests/TestDataIcc/Conversion/IccConversionData.Lut.cs new file mode 100644 index 0000000000..0c96b2777c --- /dev/null +++ b/tests/ImageSharp.Tests/TestDataIcc/Conversion/IccConversionData.Lut.cs @@ -0,0 +1,30 @@ +// Copyright (c) Six Labors. +// Licensed under the Apache License, Version 2.0. + +namespace SixLabors.ImageSharp.Tests.Colorspaces.Icc +{ + public class IccConversionDataLut + { + private static float[] LutEven = { 0, 0.5f, 1 }; + private static float[] LutUneven = { 0, 0.7f, 1 }; + + public static object[][] LutConversionTestData = + { + new object[] { LutEven, false, 0.5f, 0.5f }, + new object[] { LutEven, false, 0.25f, 0.25f }, + new object[] { LutEven, false, 0.75f, 0.75f }, + + new object[] { LutEven, true, 0.5f, 0.5f }, + new object[] { LutEven, true, 0.25f, 0.25f }, + new object[] { LutEven, true, 0.75f, 0.75f }, + + new object[] { LutUneven, false, 0.1, 0.14 }, + new object[] { LutUneven, false, 0.5, 0.7 }, + new object[] { LutUneven, false, 0.75, 0.85 }, + + new object[] { LutUneven, true, 0.14, 0.1 }, + new object[] { LutUneven, true, 0.7, 0.5 }, + new object[] { LutUneven, true, 0.85, 0.75 }, + }; + } +} diff --git a/tests/ImageSharp.Tests/TestDataIcc/Conversion/IccConversionData.LutAB.cs b/tests/ImageSharp.Tests/TestDataIcc/Conversion/IccConversionData.LutAB.cs new file mode 100644 index 0000000000..f989117522 --- /dev/null +++ b/tests/ImageSharp.Tests/TestDataIcc/Conversion/IccConversionData.LutAB.cs @@ -0,0 +1,44 @@ +// 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 IccConversionDataLutAB + { + private static IccLutAToBTagDataEntry lutAtoB_SingleCurve = new IccLutAToBTagDataEntry( + new IccTagDataEntry[] + { + IccConversionDataTrc.IdentityCurve, + IccConversionDataTrc.IdentityCurve, + IccConversionDataTrc.IdentityCurve + }, + null, null, null, null, null); + + // also need: + // # CurveM + matrix + // # CurveA + CLUT + CurveB + // # CurveA + CLUT + CurveM + Matrix + CurveB + + private static IccLutBToATagDataEntry lutBtoA_SingleCurve = new IccLutBToATagDataEntry( + new IccTagDataEntry[] + { + IccConversionDataTrc.IdentityCurve, + IccConversionDataTrc.IdentityCurve, + IccConversionDataTrc.IdentityCurve + }, + 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) }, + }; + + 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) }, + }; + } +} diff --git a/tests/ImageSharp.Tests/TestDataIcc/Conversion/IccConversionData.LutEntry.cs b/tests/ImageSharp.Tests/TestDataIcc/Conversion/IccConversionData.LutEntry.cs new file mode 100644 index 0000000000..f676490f1d --- /dev/null +++ b/tests/ImageSharp.Tests/TestDataIcc/Conversion/IccConversionData.LutEntry.cs @@ -0,0 +1,65 @@ +// 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 IccConversionDataLutEntry + { + private static readonly IccLut Lut256 = CreateLut(256); + private static readonly IccLut Lut32 = CreateLut(32); + private static readonly IccLut LutIdentity = CreateIdentityLut(0, 1); + + private static readonly IccLut8TagDataEntry Lut8 = new IccLut8TagDataEntry( + new IccLut[] { Lut256, Lut256 }, + IccConversionDataClut.Clut2x1, + new IccLut[] { Lut256 }); + + private static readonly IccLut16TagDataEntry Lut16 = new IccLut16TagDataEntry( + new IccLut[] { Lut32, Lut32 }, + IccConversionDataClut.Clut2x1, + new IccLut[] { LutIdentity }); + + private static readonly IccLut8TagDataEntry Lut8Matrix = new IccLut8TagDataEntry( + IccConversionDataMatrix.Matrix3x3Random, + new IccLut[] { Lut256, Lut256, Lut256 }, + IccConversionDataClut.Clut3x1, + new IccLut[] { Lut256 }); + + private static readonly IccLut16TagDataEntry Lut16Matrix = new IccLut16TagDataEntry( + IccConversionDataMatrix.Matrix3x3Random, + new IccLut[] { Lut32, Lut32, Lut32 }, + IccConversionDataClut.Clut3x1, + new IccLut[] { LutIdentity }); + + private static IccLut CreateLut(int length) + { + float[] values = new float[length]; + for (int i = 0; i < values.Length; i++) + { + values[i] = 0.1f + (i / (float)length); + } + + return new IccLut(values); + } + + private static IccLut CreateIdentityLut(float min, float max) + { + return new IccLut(new float[] { min, max }); + } + + public static object[][] Lut8ConversionTestData = + { + new object[] { Lut8, new Vector4(0.2f, 0.3f, 0, 0), new Vector4(0.339762866f, 0, 0, 0) }, + new object[] { Lut8Matrix, new Vector4(0.21f, 0.31f, 0.41f, 0), new Vector4(0.431305826f, 0, 0, 0) }, + }; + + public static object[][] Lut16ConversionTestData = + { + new object[] { Lut16, new Vector4(0.2f, 0.3f, 0, 0), new Vector4(0.245625019f, 0, 0, 0) }, + new object[] { Lut16Matrix, new Vector4(0.21f, 0.31f, 0.41f, 0), new Vector4(0.336980581f, 0, 0, 0) }, + }; + } +} diff --git a/tests/ImageSharp.Tests/TestDataIcc/Conversion/IccConversionData.Matrix.cs b/tests/ImageSharp.Tests/TestDataIcc/Conversion/IccConversionData.Matrix.cs new file mode 100644 index 0000000000..42b8f2bceb --- /dev/null +++ b/tests/ImageSharp.Tests/TestDataIcc/Conversion/IccConversionData.Matrix.cs @@ -0,0 +1,45 @@ +// 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 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 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) }, + new object[] { CreateMatrix(Matrix3x3Identity), new Vector3(0.2f, 0.2f, 0.2f), new Vector4(0.5f, 0.5f, 0.5f, 0), new Vector4(0.7f, 0.7f, 0.7f, 0) }, + new object[] { CreateMatrix(Matrix3x3Random), Vector3.Zero, new Vector4(0.5f, 0.5f, 0.5f, 0), new Vector4(0.6f, 0.75f, 0.9f, 0) }, + new object[] { CreateMatrix(Matrix3x3Random), new Vector3(0.1f, 0.2f, 0.3f), new Vector4(0.5f, 0.5f, 0.5f, 0), new Vector4(0.7f, 0.95f, 1.2f, 0) }, + 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( + matrix[0, 0], + matrix[0, 1], + matrix[0, 2], + 0, + matrix[1, 0], + matrix[1, 1], + matrix[1, 2], + 0, + matrix[2, 0], + matrix[2, 1], + matrix[2, 2], + 0, + 0, + 0, + 0, + 1); + } + } +} diff --git a/tests/ImageSharp.Tests/TestDataIcc/Conversion/IccConversionData.MultiProcessElement.cs b/tests/ImageSharp.Tests/TestDataIcc/Conversion/IccConversionData.MultiProcessElement.cs new file mode 100644 index 0000000000..696cec6d59 --- /dev/null +++ b/tests/ImageSharp.Tests/TestDataIcc/Conversion/IccConversionData.MultiProcessElement.cs @@ -0,0 +1,76 @@ +// 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/IccConversionData.Trc.cs b/tests/ImageSharp.Tests/TestDataIcc/Conversion/IccConversionData.Trc.cs new file mode 100644 index 0000000000..5bf745be42 --- /dev/null +++ b/tests/ImageSharp.Tests/TestDataIcc/Conversion/IccConversionData.Trc.cs @@ -0,0 +1,77 @@ +// 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 IccConversionDataTrc + { + internal static IccCurveTagDataEntry IdentityCurve = new IccCurveTagDataEntry(); + internal static IccCurveTagDataEntry Gamma2Curve = new IccCurveTagDataEntry(2); + internal static IccCurveTagDataEntry LutCurve = new IccCurveTagDataEntry(new float[] { 0, 0.7f, 1 }); + + internal static IccParametricCurveTagDataEntry ParamCurve1 = new IccParametricCurveTagDataEntry(new IccParametricCurve(2.2f)); + internal static IccParametricCurveTagDataEntry ParamCurve2 = new IccParametricCurveTagDataEntry(new IccParametricCurve(2.2f, 1.5f, -0.5f)); + internal static IccParametricCurveTagDataEntry ParamCurve3 = new IccParametricCurveTagDataEntry(new IccParametricCurve(2.2f, 1.5f, -0.5f, 0.3f)); + internal static IccParametricCurveTagDataEntry ParamCurve4 = new IccParametricCurveTagDataEntry(new IccParametricCurve(2.4f, 1 / 1.055f, 0.055f / 1.055f, 1 / 12.92f, 0.04045f)); + internal static IccParametricCurveTagDataEntry ParamCurve5 = new IccParametricCurveTagDataEntry(new IccParametricCurve(2.2f, 0.7f, 0.2f, 0.3f, 0.1f, 0.5f, 0.2f)); + + public static object[][] TrcArrayConversionTestData = + { + new object[] + { + new IccTagDataEntry[] { IdentityCurve, Gamma2Curve, ParamCurve1 }, + false, + new Vector4(2, 2, 0.5f, 0), + new Vector4(2, 4, 0.217637628f, 0), + }, + new object[] + { + new IccTagDataEntry[] { IdentityCurve, Gamma2Curve, ParamCurve1 }, + true, + new Vector4(1, 4, 0.217637628f, 0), + new Vector4(1, 2, 0.5f, 0), + }, + }; + + public static object[][] CurveConversionTestData = + { + new object[] { IdentityCurve, false, 2, 2 }, + new object[] { Gamma2Curve, false, 2, 4 }, + new object[] { LutCurve, false, 0.1, 0.14 }, + new object[] { LutCurve, false, 0.5, 0.7 }, + new object[] { LutCurve, false, 0.75, 0.85 }, + + new object[] { IdentityCurve, true, 2, 2 }, + new object[] { Gamma2Curve, true, 4, 2 }, + new object[] { LutCurve, true, 0.14, 0.1 }, + new object[] { LutCurve, true, 0.7, 0.5 }, + new object[] { LutCurve, true, 0.85, 0.75 }, + }; + + public static object[][] ParametricCurveConversionTestData = + { + new object[] { ParamCurve1, false, 0.5f, 0.217637628f }, + new object[] { ParamCurve2, false, 0.6f, 0.133208528f }, + new object[] { ParamCurve2, false, 0.21f, 0 }, + new object[] { ParamCurve3, false, 0.61f, 0.444446117f }, + new object[] { ParamCurve3, false, 0.22f, 0.3f }, + new object[] { ParamCurve4, false, 0.3f, 0.0732389539f }, + new object[] { ParamCurve4, false, 0.03f, 0.00232198136f }, + new object[] { ParamCurve5, false, 0.2f, 0.593165159f }, + new object[] { ParamCurve5, false, 0.05f, 0.215f }, + + new object[] { ParamCurve1, true, 0.217637628f, 0.5f }, + new object[] { ParamCurve2, true, 0.133208528f, 0.6f }, + new object[] { ParamCurve2, true, 0, 1 / 3f }, + new object[] { ParamCurve3, true, 0.444446117f, 0.61f }, + new object[] { ParamCurve3, true, 0.3f, 1 / 3f }, + new object[] { ParamCurve4, true, 0.0732389539f, 0.3f }, + new object[] { ParamCurve4, true, 0.00232198136f, 0.03f }, + new object[] { ParamCurve5, true, 0.593165159f, 0.2f }, + new object[] { ParamCurve5, true, 0.215f, 0.05f }, + }; + } +} From 081208574d55535caa70e90bc1bce3227a512581 Mon Sep 17 00:00:00 2001 From: Brian Popow Date: Mon, 12 Jul 2021 19:35:37 +0200 Subject: [PATCH 02/42] 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 @@ public void CieLabEquality() 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 @@ public void CieLchEquality() 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 @@ public void CieLchuvEquality() 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 @@ public void CieLuvEquality() 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 @@ public void CieXyChromaticityCoordinatesEquality() 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 @@ public void CieXyyEquality() 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 @@ public void CieXyzEquality() 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 @@ public void CmykEquality() 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 @@ public void CmykEquality() 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 @@ public bool Equals(GammaWorkingSpace x, GammaWorkingSpace y) 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 @@ public void HslEquality() 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 @@ public void HslEquality() 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 @@ public void HsvEquality() 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 @@ public void HsvEquality() 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 @@ public void HunterLabEquality() 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 @@ internal void ClutCalculator_WithClut_ReturnsResult(IccClut lut, Vector4 input, 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 @@ internal void CurveCalculator_WithCurveEntry_ReturnsResult(IccCurveTagDataEntry 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 @@ internal void LutABCalculator_WithLutBToA_ReturnsResult(IccLutBToATagDataEntry l 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 @@ internal void LutCalculator_WithLut_ReturnsResult(float[] lut, bool inverted, fl 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 @@ internal void LutEntryCalculator_WithLut16_ReturnsResult(IccLut16TagDataEntry lu 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 @@ internal void MatrixCalculator_WithMatrix_ReturnsResult(Matrix4x4 matrix2D, Vect 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 @@ internal void ParametricCurveCalculator_WithCurveEntry_ReturnsResult(IccParametr 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 @@ internal void TrcCalculator_WithCurvesArray_ReturnsResult(IccTagDataEntry[] entr 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 @@ public void LinearRgbEquality() 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 @@ public void LinearRgbEquality() 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 @@ public void LmsEquality() 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 @@ public void YCbCrEquality() 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 @@ public class IccConversionDataLutEntry 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 @@ private static IccLut CreateLut(int length) 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 @@ public class IccConversionDataMatrix 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 @@ private static Matrix4x4 CreateMatrix(float[,] matrix) 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 { From 1094dc6e2c516f142322a55cd718bb1c818c80a6 Mon Sep 17 00:00:00 2001 From: Brian Popow Date: Mon, 12 Jul 2021 20:11:21 +0200 Subject: [PATCH 03/42] Add color conversion trait to be able to filter for those tests --- tests/ImageSharp.Tests/Colorspaces/CieLabTests.cs | 1 + tests/ImageSharp.Tests/Colorspaces/CieLchTests.cs | 1 + tests/ImageSharp.Tests/Colorspaces/CieLchuvTests.cs | 1 + tests/ImageSharp.Tests/Colorspaces/CieLuvTests.cs | 1 + .../Colorspaces/CieXyChromaticityCoordinatesTests.cs | 1 + tests/ImageSharp.Tests/Colorspaces/CieXyyTests.cs | 1 + tests/ImageSharp.Tests/Colorspaces/CieXyzTests.cs | 1 + tests/ImageSharp.Tests/Colorspaces/CmykTests.cs | 1 + .../Colorspaces/Companding/CompandingTests.cs | 5 +++-- .../Conversion/CieLabAndCieLchConversionTests.cs | 1 + .../Conversion/CieLabAndCieLchuvConversionTests.cs | 1 + .../Conversion/CieLabAndCieLuvConversionTests.cs | 5 +++-- .../Conversion/CieLabAndCieXyyConversionTests.cs | 1 + .../Colorspaces/Conversion/CieLabAndCmykConversionTests.cs | 5 +++-- .../Colorspaces/Conversion/CieLabAndHslConversionTests.cs | 5 +++-- .../Colorspaces/Conversion/CieLabAndHsvConversionTests.cs | 5 +++-- .../Conversion/CieLabAndHunterLabConversionTests.cs | 5 +++-- .../Conversion/CieLabAndLinearRgbConversionTests.cs | 5 +++-- .../Colorspaces/Conversion/CieLabAndLmsConversionTests.cs | 5 +++-- .../Colorspaces/Conversion/CieLabAndRgbConversionTests.cs | 5 +++-- .../Conversion/CieLabAndYCbCrConversionTests.cs | 5 +++-- .../Conversion/CieLchAndCieLuvConversionTests.cs | 5 +++-- .../Conversion/CieLchAndCieXyyConversionTests.cs | 1 + .../Colorspaces/Conversion/CieLchAndHslConversionTests.cs | 5 +++-- .../Colorspaces/Conversion/CieLchAndHsvConversionTests.cs | 5 +++-- .../Conversion/CieLchAndHunterLabConversionTests.cs | 5 +++-- .../Conversion/CieLchAndLinearRgbConversionTests.cs | 5 +++-- .../Colorspaces/Conversion/CieLchAndLmsConversionTests.cs | 5 +++-- .../Colorspaces/Conversion/CieLchAndRgbConversionTests.cs | 5 +++-- .../Conversion/CieLchAndYCbCrConversionTests.cs | 5 +++-- .../Conversion/CieLchuvAndCieLchConversionTests.cs | 5 +++-- .../Conversion/CieLchuvAndCieLuvConversionTests.cs | 1 + .../Conversion/CieLchuvAndCmykConversionTests.cs | 5 +++-- .../Conversion/CieLuvAndCieXyyConversionTests.cs | 1 + .../Colorspaces/Conversion/CieLuvAndHslConversionTests.cs | 1 + .../Colorspaces/Conversion/CieLuvAndHsvConversionTests.cs | 1 + .../Conversion/CieLuvAndHunterLabConversionTests.cs | 1 + .../Conversion/CieLuvAndLinearRgbConversionTests.cs | 1 + .../Colorspaces/Conversion/CieLuvAndLmsConversionTests.cs | 1 + .../Colorspaces/Conversion/CieLuvAndRgbConversionTests.cs | 1 + .../Conversion/CieLuvAndYCbCrConversionTests.cs | 1 + .../Colorspaces/Conversion/CieXyyAndHslConversionTests.cs | 1 + .../Colorspaces/Conversion/CieXyyAndHsvConversionTests.cs | 1 + .../Conversion/CieXyyAndHunterLabConversionTests.cs | 1 + .../Conversion/CieXyyAndLinearRgbConversionTests.cs | 1 + .../Colorspaces/Conversion/CieXyyAndLmsConversionTests.cs | 1 + .../Colorspaces/Conversion/CieXyyAndRgbConversionTests.cs | 1 + .../Conversion/CieXyyAndYCbCrConversionTests.cs | 1 + .../Conversion/CieXyzAndCieLabConversionTest.cs | 5 +++-- .../Conversion/CieXyzAndCieLchConversionTests.cs | 1 + .../Conversion/CieXyzAndCieLchuvConversionTests.cs | 1 + .../Conversion/CieXyzAndCieLuvConversionTest.cs | 5 +++-- .../Conversion/CieXyzAndCieXyyConversionTest.cs | 3 ++- .../Colorspaces/Conversion/CieXyzAndHslConversionTests.cs | 1 + .../Colorspaces/Conversion/CieXyzAndHsvConversionTests.cs | 1 + .../Conversion/CieXyzAndHunterLabConversionTest.cs | 5 +++-- .../Colorspaces/Conversion/CieXyzAndLmsConversionTest.cs | 5 +++-- .../Conversion/CieXyzAndYCbCrConversionTests.cs | 1 + .../Colorspaces/Conversion/CmykAndCieLchConversionTests.cs | 5 +++-- .../Colorspaces/Conversion/CmykAndCieLuvConversionTests.cs | 5 +++-- .../Colorspaces/Conversion/CmykAndCieXyyConversionTests.cs | 5 +++-- .../Colorspaces/Conversion/CmykAndCieXyzConversionTests.cs | 5 +++-- .../Colorspaces/Conversion/CmykAndHslConversionTests.cs | 5 +++-- .../Colorspaces/Conversion/CmykAndHsvConversionTests.cs | 5 +++-- .../Conversion/CmykAndHunterLabConversionTests.cs | 5 +++-- .../Colorspaces/Conversion/CmykAndYCbCrConversionTests.cs | 5 +++-- .../Colorspaces/Conversion/ColorConverterAdaptTest.cs | 1 + .../Colorspaces/Conversion/RgbAndCieXyzConversionTest.cs | 5 +++-- .../Colorspaces/Conversion/RgbAndCmykConversionTest.cs | 3 ++- .../Colorspaces/Conversion/RgbAndHslConversionTest.cs | 1 + .../Colorspaces/Conversion/RgbAndHsvConversionTest.cs | 3 ++- .../Colorspaces/Conversion/RgbAndYCbCrConversionTest.cs | 5 +++-- .../Conversion/VonKriesChromaticAdaptationTests.cs | 1 + tests/ImageSharp.Tests/Colorspaces/HslTests.cs | 1 + tests/ImageSharp.Tests/Colorspaces/HsvTests.cs | 1 + tests/ImageSharp.Tests/Colorspaces/HunterLabTests.cs | 1 + .../Colorspaces/Icc/Calculators/ClutCalculatorTests.cs | 1 + .../Colorspaces/Icc/Calculators/CurveCalculatorTests.cs | 1 + .../Colorspaces/Icc/Calculators/LutABCalculatorTests.cs | 1 + .../Colorspaces/Icc/Calculators/LutCalculatorTests.cs | 1 + .../Colorspaces/Icc/Calculators/LutEntryCalculatorTests.cs | 1 + .../Colorspaces/Icc/Calculators/MatrixCalculatorTests.cs | 1 + .../Icc/Calculators/ParametricCurveCalculatorTests.cs | 1 + .../Colorspaces/Icc/Calculators/TrcCalculatorTests.cs | 1 + tests/ImageSharp.Tests/Colorspaces/LinearRgbTests.cs | 1 + tests/ImageSharp.Tests/Colorspaces/LmsTests.cs | 1 + tests/ImageSharp.Tests/Colorspaces/RgbTests.cs | 7 ++++--- .../Colorspaces/StringRepresentationTests.cs | 1 + tests/ImageSharp.Tests/Colorspaces/YCbCrTests.cs | 1 + 89 files changed, 163 insertions(+), 74 deletions(-) diff --git a/tests/ImageSharp.Tests/Colorspaces/CieLabTests.cs b/tests/ImageSharp.Tests/Colorspaces/CieLabTests.cs index cd0745cc9f..7b917fb5e3 100644 --- a/tests/ImageSharp.Tests/Colorspaces/CieLabTests.cs +++ b/tests/ImageSharp.Tests/Colorspaces/CieLabTests.cs @@ -10,6 +10,7 @@ namespace SixLabors.ImageSharp.Tests.Colorspaces /// /// Tests the struct. /// + [Trait("Color", "Conversion")] public class CieLabTests { [Fact] diff --git a/tests/ImageSharp.Tests/Colorspaces/CieLchTests.cs b/tests/ImageSharp.Tests/Colorspaces/CieLchTests.cs index 6aa9fac867..b499f78338 100644 --- a/tests/ImageSharp.Tests/Colorspaces/CieLchTests.cs +++ b/tests/ImageSharp.Tests/Colorspaces/CieLchTests.cs @@ -10,6 +10,7 @@ namespace SixLabors.ImageSharp.Tests.Colorspaces /// /// Tests the struct. /// + [Trait("Color", "Conversion")] public class CieLchTests { [Fact] diff --git a/tests/ImageSharp.Tests/Colorspaces/CieLchuvTests.cs b/tests/ImageSharp.Tests/Colorspaces/CieLchuvTests.cs index 0d32192731..e1a5459f9f 100644 --- a/tests/ImageSharp.Tests/Colorspaces/CieLchuvTests.cs +++ b/tests/ImageSharp.Tests/Colorspaces/CieLchuvTests.cs @@ -10,6 +10,7 @@ namespace SixLabors.ImageSharp.Tests.Colorspaces /// /// Tests the struct. /// + [Trait("Color", "Conversion")] public class CieLchuvTests { [Fact] diff --git a/tests/ImageSharp.Tests/Colorspaces/CieLuvTests.cs b/tests/ImageSharp.Tests/Colorspaces/CieLuvTests.cs index a3af9fd733..6cfa7d348b 100644 --- a/tests/ImageSharp.Tests/Colorspaces/CieLuvTests.cs +++ b/tests/ImageSharp.Tests/Colorspaces/CieLuvTests.cs @@ -10,6 +10,7 @@ namespace SixLabors.ImageSharp.Tests.Colorspaces /// /// Tests the struct. /// + [Trait("Color", "Conversion")] public class CieLuvTests { [Fact] diff --git a/tests/ImageSharp.Tests/Colorspaces/CieXyChromaticityCoordinatesTests.cs b/tests/ImageSharp.Tests/Colorspaces/CieXyChromaticityCoordinatesTests.cs index 8f06b91871..42b2dedc6d 100644 --- a/tests/ImageSharp.Tests/Colorspaces/CieXyChromaticityCoordinatesTests.cs +++ b/tests/ImageSharp.Tests/Colorspaces/CieXyChromaticityCoordinatesTests.cs @@ -9,6 +9,7 @@ namespace SixLabors.ImageSharp.Tests.Colorspaces /// /// Tests the struct. /// + [Trait("Color", "Conversion")] public class CieXyChromaticityCoordinatesTests { [Fact] diff --git a/tests/ImageSharp.Tests/Colorspaces/CieXyyTests.cs b/tests/ImageSharp.Tests/Colorspaces/CieXyyTests.cs index 000e8d9c7e..7e633d6f1c 100644 --- a/tests/ImageSharp.Tests/Colorspaces/CieXyyTests.cs +++ b/tests/ImageSharp.Tests/Colorspaces/CieXyyTests.cs @@ -10,6 +10,7 @@ namespace SixLabors.ImageSharp.Tests.Colorspaces /// /// Tests the struct. /// + [Trait("Color", "Conversion")] public class CieXyyTests { [Fact] diff --git a/tests/ImageSharp.Tests/Colorspaces/CieXyzTests.cs b/tests/ImageSharp.Tests/Colorspaces/CieXyzTests.cs index cb89f5bd71..c6fd5440f5 100644 --- a/tests/ImageSharp.Tests/Colorspaces/CieXyzTests.cs +++ b/tests/ImageSharp.Tests/Colorspaces/CieXyzTests.cs @@ -10,6 +10,7 @@ namespace SixLabors.ImageSharp.Tests.Colorspaces /// /// Tests the struct. /// + [Trait("Color", "Conversion")] public class CieXyzTests { [Fact] diff --git a/tests/ImageSharp.Tests/Colorspaces/CmykTests.cs b/tests/ImageSharp.Tests/Colorspaces/CmykTests.cs index 261048df12..d8b3ad8f4c 100644 --- a/tests/ImageSharp.Tests/Colorspaces/CmykTests.cs +++ b/tests/ImageSharp.Tests/Colorspaces/CmykTests.cs @@ -10,6 +10,7 @@ namespace SixLabors.ImageSharp.Tests.Colorspaces /// /// Tests the struct. /// + [Trait("Color", "Conversion")] public class CmykTests { [Fact] diff --git a/tests/ImageSharp.Tests/Colorspaces/Companding/CompandingTests.cs b/tests/ImageSharp.Tests/Colorspaces/Companding/CompandingTests.cs index cff562e813..f57c4b3ce7 100644 --- a/tests/ImageSharp.Tests/Colorspaces/Companding/CompandingTests.cs +++ b/tests/ImageSharp.Tests/Colorspaces/Companding/CompandingTests.cs @@ -1,4 +1,4 @@ -// Copyright (c) Six Labors. +// Copyright (c) Six Labors. // Licensed under the Apache License, Version 2.0. using System; @@ -11,6 +11,7 @@ namespace SixLabors.ImageSharp.Tests.Colorspaces.Companding /// /// Tests various companding algorithms. Expanded numbers are hand calculated from formulas online. /// + [Trait("Color", "Conversion")] public class CompandingTests { private static readonly ApproximateFloatComparer FloatComparer = new ApproximateFloatComparer(.00001F); @@ -113,4 +114,4 @@ private static void CompandingIsCorrectImpl(float e, float c, float expanded, fl Assert.Equal(compressed, c, FloatComparer); } } -} \ No newline at end of file +} diff --git a/tests/ImageSharp.Tests/Colorspaces/Conversion/CieLabAndCieLchConversionTests.cs b/tests/ImageSharp.Tests/Colorspaces/Conversion/CieLabAndCieLchConversionTests.cs index 6e68155bd1..222d6ee2db 100644 --- a/tests/ImageSharp.Tests/Colorspaces/Conversion/CieLabAndCieLchConversionTests.cs +++ b/tests/ImageSharp.Tests/Colorspaces/Conversion/CieLabAndCieLchConversionTests.cs @@ -15,6 +15,7 @@ namespace SixLabors.ImageSharp.Tests.Colorspaces.Conversion /// Test data generated using: /// /// + [Trait("Color", "Conversion")] public class CieLabAndCieLchConversionTests { private static readonly ApproximateColorSpaceComparer ColorSpaceComparer = new ApproximateColorSpaceComparer(.0001F); diff --git a/tests/ImageSharp.Tests/Colorspaces/Conversion/CieLabAndCieLchuvConversionTests.cs b/tests/ImageSharp.Tests/Colorspaces/Conversion/CieLabAndCieLchuvConversionTests.cs index 0c5341fd6e..4276ae7df4 100644 --- a/tests/ImageSharp.Tests/Colorspaces/Conversion/CieLabAndCieLchuvConversionTests.cs +++ b/tests/ImageSharp.Tests/Colorspaces/Conversion/CieLabAndCieLchuvConversionTests.cs @@ -15,6 +15,7 @@ namespace SixLabors.ImageSharp.Tests.Colorspaces.Conversion /// Test data generated using: /// /// + [Trait("Color", "Conversion")] public class CieLabAndCieLchuvConversionTests { private static readonly ApproximateColorSpaceComparer ColorSpaceComparer = new ApproximateColorSpaceComparer(.0002F); diff --git a/tests/ImageSharp.Tests/Colorspaces/Conversion/CieLabAndCieLuvConversionTests.cs b/tests/ImageSharp.Tests/Colorspaces/Conversion/CieLabAndCieLuvConversionTests.cs index 956a249f75..79b55617dd 100644 --- a/tests/ImageSharp.Tests/Colorspaces/Conversion/CieLabAndCieLuvConversionTests.cs +++ b/tests/ImageSharp.Tests/Colorspaces/Conversion/CieLabAndCieLuvConversionTests.cs @@ -1,4 +1,4 @@ -// Copyright (c) Six Labors. +// Copyright (c) Six Labors. // Licensed under the Apache License, Version 2.0. using System; @@ -15,6 +15,7 @@ namespace SixLabors.ImageSharp.Tests.Colorspaces.Conversion /// Test data generated using: /// /// + [Trait("Color", "Conversion")] public class CieLabAndCieLuvConversionTests { private static readonly ApproximateColorSpaceComparer ColorSpaceComparer = new ApproximateColorSpaceComparer(.0002F); @@ -80,4 +81,4 @@ public void Convert_CieLab_to_CieLuv(float l, float a, float b, float l2, float } } } -} \ No newline at end of file +} diff --git a/tests/ImageSharp.Tests/Colorspaces/Conversion/CieLabAndCieXyyConversionTests.cs b/tests/ImageSharp.Tests/Colorspaces/Conversion/CieLabAndCieXyyConversionTests.cs index 9ecd7873d0..17a088d9ca 100644 --- a/tests/ImageSharp.Tests/Colorspaces/Conversion/CieLabAndCieXyyConversionTests.cs +++ b/tests/ImageSharp.Tests/Colorspaces/Conversion/CieLabAndCieXyyConversionTests.cs @@ -11,6 +11,7 @@ namespace SixLabors.ImageSharp.Tests.Colorspaces.Conversion /// /// Tests - conversions. /// + [Trait("Color", "Conversion")] public class CieLabAndCieXyyConversionTests { private static readonly ApproximateColorSpaceComparer ColorSpaceComparer = new ApproximateColorSpaceComparer(.0002F); diff --git a/tests/ImageSharp.Tests/Colorspaces/Conversion/CieLabAndCmykConversionTests.cs b/tests/ImageSharp.Tests/Colorspaces/Conversion/CieLabAndCmykConversionTests.cs index f6a25d07da..fb605f3b71 100644 --- a/tests/ImageSharp.Tests/Colorspaces/Conversion/CieLabAndCmykConversionTests.cs +++ b/tests/ImageSharp.Tests/Colorspaces/Conversion/CieLabAndCmykConversionTests.cs @@ -1,4 +1,4 @@ -// Copyright (c) Six Labors. +// Copyright (c) Six Labors. // Licensed under the Apache License, Version 2.0. using System; @@ -11,6 +11,7 @@ namespace SixLabors.ImageSharp.Tests.Colorspaces.Conversion /// /// Tests - conversions. /// + [Trait("Color", "Conversion")] public class CieLabAndCmykConversionTests { private static readonly ApproximateColorSpaceComparer ColorSpaceComparer = new ApproximateColorSpaceComparer(.0002F); @@ -76,4 +77,4 @@ public void Convert_CieLab_to_Cmyk(float l, float a, float b, float c, float m, } } } -} \ No newline at end of file +} diff --git a/tests/ImageSharp.Tests/Colorspaces/Conversion/CieLabAndHslConversionTests.cs b/tests/ImageSharp.Tests/Colorspaces/Conversion/CieLabAndHslConversionTests.cs index 4cda3a8f28..da338f7c8c 100644 --- a/tests/ImageSharp.Tests/Colorspaces/Conversion/CieLabAndHslConversionTests.cs +++ b/tests/ImageSharp.Tests/Colorspaces/Conversion/CieLabAndHslConversionTests.cs @@ -1,4 +1,4 @@ -// Copyright (c) Six Labors. +// Copyright (c) Six Labors. // Licensed under the Apache License, Version 2.0. using System; @@ -11,6 +11,7 @@ namespace SixLabors.ImageSharp.Tests.Colorspaces.Conversion /// /// Tests - conversions. /// + [Trait("Color", "Conversion")] public class CieLabAndHslConversionTests { private static readonly ApproximateColorSpaceComparer ColorSpaceComparer = new ApproximateColorSpaceComparer(.0002F); @@ -76,4 +77,4 @@ public void Convert_CieLab_to_Hsl(float l, float a, float b, float h, float s, f } } } -} \ No newline at end of file +} diff --git a/tests/ImageSharp.Tests/Colorspaces/Conversion/CieLabAndHsvConversionTests.cs b/tests/ImageSharp.Tests/Colorspaces/Conversion/CieLabAndHsvConversionTests.cs index 7269475b56..57055a0b4b 100644 --- a/tests/ImageSharp.Tests/Colorspaces/Conversion/CieLabAndHsvConversionTests.cs +++ b/tests/ImageSharp.Tests/Colorspaces/Conversion/CieLabAndHsvConversionTests.cs @@ -1,4 +1,4 @@ -// Copyright (c) Six Labors. +// Copyright (c) Six Labors. // Licensed under the Apache License, Version 2.0. using System; @@ -11,6 +11,7 @@ namespace SixLabors.ImageSharp.Tests.Colorspaces.Conversion /// /// Tests - conversions. /// + [Trait("Color", "Conversion")] public class CieLabAndHsvConversionTests { private static readonly ApproximateColorSpaceComparer ColorSpaceComparer = new ApproximateColorSpaceComparer(.0002F); @@ -76,4 +77,4 @@ public void Convert_CieLab_to_Hsv(float l, float a, float b, float h, float s, f } } } -} \ No newline at end of file +} diff --git a/tests/ImageSharp.Tests/Colorspaces/Conversion/CieLabAndHunterLabConversionTests.cs b/tests/ImageSharp.Tests/Colorspaces/Conversion/CieLabAndHunterLabConversionTests.cs index ab4a0f44f0..71a3c80b7c 100644 --- a/tests/ImageSharp.Tests/Colorspaces/Conversion/CieLabAndHunterLabConversionTests.cs +++ b/tests/ImageSharp.Tests/Colorspaces/Conversion/CieLabAndHunterLabConversionTests.cs @@ -1,4 +1,4 @@ -// Copyright (c) Six Labors. +// Copyright (c) Six Labors. // Licensed under the Apache License, Version 2.0. using System; @@ -11,6 +11,7 @@ namespace SixLabors.ImageSharp.Tests.Colorspaces.Conversion /// /// Tests - conversions. /// + [Trait("Color", "Conversion")] public class CieLabAndHunterLabConversionTests { private static readonly ApproximateColorSpaceComparer ColorSpaceComparer = new ApproximateColorSpaceComparer(.0002F); @@ -76,4 +77,4 @@ public void Convert_CieLab_to_HunterLab(float l, float a, float b, float l2, flo } } } -} \ No newline at end of file +} diff --git a/tests/ImageSharp.Tests/Colorspaces/Conversion/CieLabAndLinearRgbConversionTests.cs b/tests/ImageSharp.Tests/Colorspaces/Conversion/CieLabAndLinearRgbConversionTests.cs index 7038843d38..3da8da5aa6 100644 --- a/tests/ImageSharp.Tests/Colorspaces/Conversion/CieLabAndLinearRgbConversionTests.cs +++ b/tests/ImageSharp.Tests/Colorspaces/Conversion/CieLabAndLinearRgbConversionTests.cs @@ -1,4 +1,4 @@ -// Copyright (c) Six Labors. +// Copyright (c) Six Labors. // Licensed under the Apache License, Version 2.0. using System; @@ -11,6 +11,7 @@ namespace SixLabors.ImageSharp.Tests.Colorspaces.Conversion /// /// Tests - conversions. /// + [Trait("Color", "Conversion")] public class CieLabAndLinearRgbConversionTests { private static readonly ApproximateColorSpaceComparer ColorSpaceComparer = new ApproximateColorSpaceComparer(.0002F); @@ -76,4 +77,4 @@ public void Convert_CieLab_to_LinearRgb(float l, float a, float b, float r, floa } } } -} \ No newline at end of file +} diff --git a/tests/ImageSharp.Tests/Colorspaces/Conversion/CieLabAndLmsConversionTests.cs b/tests/ImageSharp.Tests/Colorspaces/Conversion/CieLabAndLmsConversionTests.cs index afce3e4135..f262c9ad38 100644 --- a/tests/ImageSharp.Tests/Colorspaces/Conversion/CieLabAndLmsConversionTests.cs +++ b/tests/ImageSharp.Tests/Colorspaces/Conversion/CieLabAndLmsConversionTests.cs @@ -1,4 +1,4 @@ -// Copyright (c) Six Labors. +// Copyright (c) Six Labors. // Licensed under the Apache License, Version 2.0. using System; @@ -11,6 +11,7 @@ namespace SixLabors.ImageSharp.Tests.Colorspaces.Conversion /// /// Tests - conversions. /// + [Trait("Color", "Conversion")] public class CieLabAndLmsConversionTests { private static readonly ApproximateColorSpaceComparer ColorSpaceComparer = new ApproximateColorSpaceComparer(.0002F); @@ -76,4 +77,4 @@ public void Convert_CieLab_to_Lms(float l, float a, float b, float l2, float m, } } } -} \ No newline at end of file +} diff --git a/tests/ImageSharp.Tests/Colorspaces/Conversion/CieLabAndRgbConversionTests.cs b/tests/ImageSharp.Tests/Colorspaces/Conversion/CieLabAndRgbConversionTests.cs index 5c7db62100..21d87e8c58 100644 --- a/tests/ImageSharp.Tests/Colorspaces/Conversion/CieLabAndRgbConversionTests.cs +++ b/tests/ImageSharp.Tests/Colorspaces/Conversion/CieLabAndRgbConversionTests.cs @@ -1,4 +1,4 @@ -// Copyright (c) Six Labors. +// Copyright (c) Six Labors. // Licensed under the Apache License, Version 2.0. using System; @@ -11,6 +11,7 @@ namespace SixLabors.ImageSharp.Tests.Colorspaces.Conversion /// /// Tests - conversions. /// + [Trait("Color", "Conversion")] public class CieLabAndRgbConversionTests { private static readonly ApproximateColorSpaceComparer ColorSpaceComparer = new ApproximateColorSpaceComparer(.0002F); @@ -76,4 +77,4 @@ public void Convert_CieLab_to_Rgb(float l, float a, float b, float r, float g, f } } } -} \ No newline at end of file +} diff --git a/tests/ImageSharp.Tests/Colorspaces/Conversion/CieLabAndYCbCrConversionTests.cs b/tests/ImageSharp.Tests/Colorspaces/Conversion/CieLabAndYCbCrConversionTests.cs index c9fe56d301..20f660284f 100644 --- a/tests/ImageSharp.Tests/Colorspaces/Conversion/CieLabAndYCbCrConversionTests.cs +++ b/tests/ImageSharp.Tests/Colorspaces/Conversion/CieLabAndYCbCrConversionTests.cs @@ -1,4 +1,4 @@ -// Copyright (c) Six Labors. +// Copyright (c) Six Labors. // Licensed under the Apache License, Version 2.0. using System; @@ -11,6 +11,7 @@ namespace SixLabors.ImageSharp.Tests.Colorspaces.Conversion /// /// Tests - conversions. /// + [Trait("Color", "Conversion")] public class CieLabAndYCbCrConversionTests { private static readonly ApproximateColorSpaceComparer ColorSpaceComparer = new ApproximateColorSpaceComparer(.0002F); @@ -76,4 +77,4 @@ public void Convert_CieLab_to_YCbCr(float l, float a, float b, float y, float cb } } } -} \ No newline at end of file +} diff --git a/tests/ImageSharp.Tests/Colorspaces/Conversion/CieLchAndCieLuvConversionTests.cs b/tests/ImageSharp.Tests/Colorspaces/Conversion/CieLchAndCieLuvConversionTests.cs index 9cf79e6a36..7185e223ff 100644 --- a/tests/ImageSharp.Tests/Colorspaces/Conversion/CieLchAndCieLuvConversionTests.cs +++ b/tests/ImageSharp.Tests/Colorspaces/Conversion/CieLchAndCieLuvConversionTests.cs @@ -1,4 +1,4 @@ -// Copyright (c) Six Labors. +// Copyright (c) Six Labors. // Licensed under the Apache License, Version 2.0. using System; @@ -11,6 +11,7 @@ namespace SixLabors.ImageSharp.Tests.Colorspaces.Conversion /// /// Tests - conversions. /// + [Trait("Color", "Conversion")] public class CieLchAndCieLuvConversionTests { private static readonly ApproximateColorSpaceComparer ColorSpaceComparer = new ApproximateColorSpaceComparer(.0002F); @@ -75,4 +76,4 @@ public void Convert_CieLuv_to_CieLch(float l2, float u, float v, float l, float } } } -} \ No newline at end of file +} diff --git a/tests/ImageSharp.Tests/Colorspaces/Conversion/CieLchAndCieXyyConversionTests.cs b/tests/ImageSharp.Tests/Colorspaces/Conversion/CieLchAndCieXyyConversionTests.cs index 087d39323b..486c7eb1ea 100644 --- a/tests/ImageSharp.Tests/Colorspaces/Conversion/CieLchAndCieXyyConversionTests.cs +++ b/tests/ImageSharp.Tests/Colorspaces/Conversion/CieLchAndCieXyyConversionTests.cs @@ -11,6 +11,7 @@ namespace SixLabors.ImageSharp.Tests.Colorspaces.Conversion /// /// Tests - conversions. /// + [Trait("Color", "Conversion")] public class CieLchAndCieXyyConversionTests { private static readonly ApproximateColorSpaceComparer ColorSpaceComparer = new ApproximateColorSpaceComparer(.0002F); diff --git a/tests/ImageSharp.Tests/Colorspaces/Conversion/CieLchAndHslConversionTests.cs b/tests/ImageSharp.Tests/Colorspaces/Conversion/CieLchAndHslConversionTests.cs index 3b9678b403..05a184afb3 100644 --- a/tests/ImageSharp.Tests/Colorspaces/Conversion/CieLchAndHslConversionTests.cs +++ b/tests/ImageSharp.Tests/Colorspaces/Conversion/CieLchAndHslConversionTests.cs @@ -1,4 +1,4 @@ -// Copyright (c) Six Labors. +// Copyright (c) Six Labors. // Licensed under the Apache License, Version 2.0. using System; @@ -11,6 +11,7 @@ namespace SixLabors.ImageSharp.Tests.Colorspaces.Conversion /// /// Tests - conversions. /// + [Trait("Color", "Conversion")] public class CieLchAndHslConversionTests { private static readonly ApproximateColorSpaceComparer ColorSpaceComparer = new ApproximateColorSpaceComparer(.0002F); @@ -75,4 +76,4 @@ public void Convert_Hsl_to_CieLch(float h2, float s, float l2, float l, float c, } } } -} \ No newline at end of file +} diff --git a/tests/ImageSharp.Tests/Colorspaces/Conversion/CieLchAndHsvConversionTests.cs b/tests/ImageSharp.Tests/Colorspaces/Conversion/CieLchAndHsvConversionTests.cs index 19a200af0e..d10aa6f9f7 100644 --- a/tests/ImageSharp.Tests/Colorspaces/Conversion/CieLchAndHsvConversionTests.cs +++ b/tests/ImageSharp.Tests/Colorspaces/Conversion/CieLchAndHsvConversionTests.cs @@ -1,4 +1,4 @@ -// Copyright (c) Six Labors. +// Copyright (c) Six Labors. // Licensed under the Apache License, Version 2.0. using System; @@ -11,6 +11,7 @@ namespace SixLabors.ImageSharp.Tests.Colorspaces.Conversion /// /// Tests - conversions. /// + [Trait("Color", "Conversion")] public class CieLchAndHsvConversionTests { private static readonly ApproximateColorSpaceComparer ColorSpaceComparer = new ApproximateColorSpaceComparer(.0002F); @@ -75,4 +76,4 @@ public void Convert_Hsv_to_CieLch(float h2, float s, float v, float l, float c, } } } -} \ No newline at end of file +} diff --git a/tests/ImageSharp.Tests/Colorspaces/Conversion/CieLchAndHunterLabConversionTests.cs b/tests/ImageSharp.Tests/Colorspaces/Conversion/CieLchAndHunterLabConversionTests.cs index 2b0338d2f5..7079fae79a 100644 --- a/tests/ImageSharp.Tests/Colorspaces/Conversion/CieLchAndHunterLabConversionTests.cs +++ b/tests/ImageSharp.Tests/Colorspaces/Conversion/CieLchAndHunterLabConversionTests.cs @@ -1,4 +1,4 @@ -// Copyright (c) Six Labors. +// Copyright (c) Six Labors. // Licensed under the Apache License, Version 2.0. using System; @@ -11,6 +11,7 @@ namespace SixLabors.ImageSharp.Tests.Colorspaces.Conversion /// /// Tests - conversions. /// + [Trait("Color", "Conversion")] public class CieLchAndHunterLabConversionTests { private static readonly ApproximateColorSpaceComparer ColorSpaceComparer = new ApproximateColorSpaceComparer(.0002F); @@ -75,4 +76,4 @@ public void Convert_HunterLab_to_CieLch(float l2, float a, float b, float l, flo } } } -} \ No newline at end of file +} diff --git a/tests/ImageSharp.Tests/Colorspaces/Conversion/CieLchAndLinearRgbConversionTests.cs b/tests/ImageSharp.Tests/Colorspaces/Conversion/CieLchAndLinearRgbConversionTests.cs index a1749097bc..acba6de5a8 100644 --- a/tests/ImageSharp.Tests/Colorspaces/Conversion/CieLchAndLinearRgbConversionTests.cs +++ b/tests/ImageSharp.Tests/Colorspaces/Conversion/CieLchAndLinearRgbConversionTests.cs @@ -1,4 +1,4 @@ -// Copyright (c) Six Labors. +// Copyright (c) Six Labors. // Licensed under the Apache License, Version 2.0. using System; @@ -11,6 +11,7 @@ namespace SixLabors.ImageSharp.Tests.Colorspaces.Conversion /// /// Tests - conversions. /// + [Trait("Color", "Conversion")] public class CieLchAndLinearRgbConversionTests { private static readonly ApproximateColorSpaceComparer ColorSpaceComparer = new ApproximateColorSpaceComparer(.0002F); @@ -75,4 +76,4 @@ public void Convert_LinearRgb_to_CieLch(float r, float g, float b, float l, floa } } } -} \ No newline at end of file +} diff --git a/tests/ImageSharp.Tests/Colorspaces/Conversion/CieLchAndLmsConversionTests.cs b/tests/ImageSharp.Tests/Colorspaces/Conversion/CieLchAndLmsConversionTests.cs index fa90e59855..ac7658397b 100644 --- a/tests/ImageSharp.Tests/Colorspaces/Conversion/CieLchAndLmsConversionTests.cs +++ b/tests/ImageSharp.Tests/Colorspaces/Conversion/CieLchAndLmsConversionTests.cs @@ -1,4 +1,4 @@ -// Copyright (c) Six Labors. +// Copyright (c) Six Labors. // Licensed under the Apache License, Version 2.0. using System; @@ -11,6 +11,7 @@ namespace SixLabors.ImageSharp.Tests.Colorspaces.Conversion /// /// Tests - conversions. /// + [Trait("Color", "Conversion")] public class CieLchAndLmsConversionTests { private static readonly ApproximateColorSpaceComparer ColorSpaceComparer = new ApproximateColorSpaceComparer(.0002F); @@ -75,4 +76,4 @@ public void Convert_Lms_to_CieLch(float l2, float m, float s, float l, float c, } } } -} \ No newline at end of file +} diff --git a/tests/ImageSharp.Tests/Colorspaces/Conversion/CieLchAndRgbConversionTests.cs b/tests/ImageSharp.Tests/Colorspaces/Conversion/CieLchAndRgbConversionTests.cs index 667e3d7a7d..f8b2ef50bf 100644 --- a/tests/ImageSharp.Tests/Colorspaces/Conversion/CieLchAndRgbConversionTests.cs +++ b/tests/ImageSharp.Tests/Colorspaces/Conversion/CieLchAndRgbConversionTests.cs @@ -1,4 +1,4 @@ -// Copyright (c) Six Labors. +// Copyright (c) Six Labors. // Licensed under the Apache License, Version 2.0. using System; @@ -11,6 +11,7 @@ namespace SixLabors.ImageSharp.Tests.Colorspaces.Conversion /// /// Tests - conversions. /// + [Trait("Color", "Conversion")] public class CieLchAndRgbConversionTests { private static readonly ApproximateColorSpaceComparer ColorSpaceComparer = new ApproximateColorSpaceComparer(.0002F); @@ -75,4 +76,4 @@ public void Convert_Rgb_to_CieLch(float r, float g, float b, float l, float c, f } } } -} \ No newline at end of file +} diff --git a/tests/ImageSharp.Tests/Colorspaces/Conversion/CieLchAndYCbCrConversionTests.cs b/tests/ImageSharp.Tests/Colorspaces/Conversion/CieLchAndYCbCrConversionTests.cs index 7c08da633f..46df2f4e3a 100644 --- a/tests/ImageSharp.Tests/Colorspaces/Conversion/CieLchAndYCbCrConversionTests.cs +++ b/tests/ImageSharp.Tests/Colorspaces/Conversion/CieLchAndYCbCrConversionTests.cs @@ -1,4 +1,4 @@ -// Copyright (c) Six Labors. +// Copyright (c) Six Labors. // Licensed under the Apache License, Version 2.0. using System; @@ -11,6 +11,7 @@ namespace SixLabors.ImageSharp.Tests.Colorspaces.Conversion /// /// Tests - conversions. /// + [Trait("Color", "Conversion")] public class CieLchAndYCbCrConversionTests { private static readonly ApproximateColorSpaceComparer ColorSpaceComparer = new ApproximateColorSpaceComparer(.0002F); @@ -75,4 +76,4 @@ public void Convert_YCbCr_to_CieLch(float y, float cb, float cr, float l, float } } } -} \ No newline at end of file +} diff --git a/tests/ImageSharp.Tests/Colorspaces/Conversion/CieLchuvAndCieLchConversionTests.cs b/tests/ImageSharp.Tests/Colorspaces/Conversion/CieLchuvAndCieLchConversionTests.cs index 1844026b0c..ae5566db57 100644 --- a/tests/ImageSharp.Tests/Colorspaces/Conversion/CieLchuvAndCieLchConversionTests.cs +++ b/tests/ImageSharp.Tests/Colorspaces/Conversion/CieLchuvAndCieLchConversionTests.cs @@ -1,4 +1,4 @@ -// Copyright (c) Six Labors. +// Copyright (c) Six Labors. // Licensed under the Apache License, Version 2.0. using System; @@ -11,6 +11,7 @@ namespace SixLabors.ImageSharp.Tests.Colorspaces.Conversion /// /// Tests - conversions. /// + [Trait("Color", "Conversion")] public class CieLchuvAndCieLchConversionTests { private static readonly ApproximateColorSpaceComparer ColorSpaceComparer = new ApproximateColorSpaceComparer(.0002F); @@ -75,4 +76,4 @@ public void Convert_CieLchuv_to_CieLch(float l, float c, float h, float l2, floa } } } -} \ No newline at end of file +} diff --git a/tests/ImageSharp.Tests/Colorspaces/Conversion/CieLchuvAndCieLuvConversionTests.cs b/tests/ImageSharp.Tests/Colorspaces/Conversion/CieLchuvAndCieLuvConversionTests.cs index ddbb09e85d..55c2c3124d 100644 --- a/tests/ImageSharp.Tests/Colorspaces/Conversion/CieLchuvAndCieLuvConversionTests.cs +++ b/tests/ImageSharp.Tests/Colorspaces/Conversion/CieLchuvAndCieLuvConversionTests.cs @@ -15,6 +15,7 @@ namespace SixLabors.ImageSharp.Tests.Colorspaces.Conversion /// Test data generated using: /// /// + [Trait("Color", "Conversion")] public class CieLchuvAndCieLuvConversionTests { private static readonly ApproximateColorSpaceComparer ColorSpaceComparer = new ApproximateColorSpaceComparer(.0001F); diff --git a/tests/ImageSharp.Tests/Colorspaces/Conversion/CieLchuvAndCmykConversionTests.cs b/tests/ImageSharp.Tests/Colorspaces/Conversion/CieLchuvAndCmykConversionTests.cs index 715b282d05..3ee3f7b18d 100644 --- a/tests/ImageSharp.Tests/Colorspaces/Conversion/CieLchuvAndCmykConversionTests.cs +++ b/tests/ImageSharp.Tests/Colorspaces/Conversion/CieLchuvAndCmykConversionTests.cs @@ -1,4 +1,4 @@ -// Copyright (c) Six Labors. +// Copyright (c) Six Labors. // Licensed under the Apache License, Version 2.0. using System; @@ -11,6 +11,7 @@ namespace SixLabors.ImageSharp.Tests.Colorspaces.Conversion /// /// Tests - conversions. /// + [Trait("Color", "Conversion")] public class CieLchuvAndCmykConversionTests { private static readonly ApproximateColorSpaceComparer ColorSpaceComparer = new ApproximateColorSpaceComparer(.0002F); @@ -76,4 +77,4 @@ public void Convert_CieLchuv_to_Cmyk(float l, float c, float h, float c2, float } } } -} \ No newline at end of file +} diff --git a/tests/ImageSharp.Tests/Colorspaces/Conversion/CieLuvAndCieXyyConversionTests.cs b/tests/ImageSharp.Tests/Colorspaces/Conversion/CieLuvAndCieXyyConversionTests.cs index b486c9614f..e15e9410e7 100644 --- a/tests/ImageSharp.Tests/Colorspaces/Conversion/CieLuvAndCieXyyConversionTests.cs +++ b/tests/ImageSharp.Tests/Colorspaces/Conversion/CieLuvAndCieXyyConversionTests.cs @@ -11,6 +11,7 @@ namespace SixLabors.ImageSharp.Tests.Colorspaces.Conversion /// /// Tests - conversions. /// + [Trait("Color", "Conversion")] public class CieLuvAndCieXyyConversionTests { private static readonly ApproximateColorSpaceComparer ColorSpaceComparer = new ApproximateColorSpaceComparer(.0002F); diff --git a/tests/ImageSharp.Tests/Colorspaces/Conversion/CieLuvAndHslConversionTests.cs b/tests/ImageSharp.Tests/Colorspaces/Conversion/CieLuvAndHslConversionTests.cs index b866b6c2cf..69b2fe1a2c 100644 --- a/tests/ImageSharp.Tests/Colorspaces/Conversion/CieLuvAndHslConversionTests.cs +++ b/tests/ImageSharp.Tests/Colorspaces/Conversion/CieLuvAndHslConversionTests.cs @@ -11,6 +11,7 @@ namespace SixLabors.ImageSharp.Tests.Colorspaces.Conversion /// /// Tests - conversions. /// + [Trait("Color", "Conversion")] public class CieLuvAndHslConversionTests { private static readonly ApproximateColorSpaceComparer ColorSpaceComparer = new ApproximateColorSpaceComparer(.0002F); diff --git a/tests/ImageSharp.Tests/Colorspaces/Conversion/CieLuvAndHsvConversionTests.cs b/tests/ImageSharp.Tests/Colorspaces/Conversion/CieLuvAndHsvConversionTests.cs index 681b295181..530841b183 100644 --- a/tests/ImageSharp.Tests/Colorspaces/Conversion/CieLuvAndHsvConversionTests.cs +++ b/tests/ImageSharp.Tests/Colorspaces/Conversion/CieLuvAndHsvConversionTests.cs @@ -11,6 +11,7 @@ namespace SixLabors.ImageSharp.Tests.Colorspaces.Conversion /// /// Tests - conversions. /// + [Trait("Color", "Conversion")] public class CieLuvAndHsvConversionTests { private static readonly ApproximateColorSpaceComparer ColorSpaceComparer = new ApproximateColorSpaceComparer(.0002F); diff --git a/tests/ImageSharp.Tests/Colorspaces/Conversion/CieLuvAndHunterLabConversionTests.cs b/tests/ImageSharp.Tests/Colorspaces/Conversion/CieLuvAndHunterLabConversionTests.cs index aa3d0424a1..0161cb44be 100644 --- a/tests/ImageSharp.Tests/Colorspaces/Conversion/CieLuvAndHunterLabConversionTests.cs +++ b/tests/ImageSharp.Tests/Colorspaces/Conversion/CieLuvAndHunterLabConversionTests.cs @@ -11,6 +11,7 @@ namespace SixLabors.ImageSharp.Tests.Colorspaces.Conversion /// /// Tests - conversions. /// + [Trait("Color", "Conversion")] public class CieLuvAndHunterLabConversionTests { private static readonly ApproximateColorSpaceComparer ColorSpaceComparer = new ApproximateColorSpaceComparer(.0002F); diff --git a/tests/ImageSharp.Tests/Colorspaces/Conversion/CieLuvAndLinearRgbConversionTests.cs b/tests/ImageSharp.Tests/Colorspaces/Conversion/CieLuvAndLinearRgbConversionTests.cs index 798b4612bf..d8e8d16ec0 100644 --- a/tests/ImageSharp.Tests/Colorspaces/Conversion/CieLuvAndLinearRgbConversionTests.cs +++ b/tests/ImageSharp.Tests/Colorspaces/Conversion/CieLuvAndLinearRgbConversionTests.cs @@ -11,6 +11,7 @@ namespace SixLabors.ImageSharp.Tests.Colorspaces.Conversion /// /// Tests - conversions. /// + [Trait("Color", "Conversion")] public class CieLuvAndLinearRgbConversionTests { private static readonly ApproximateColorSpaceComparer ColorSpaceComparer = new ApproximateColorSpaceComparer(.0002F); diff --git a/tests/ImageSharp.Tests/Colorspaces/Conversion/CieLuvAndLmsConversionTests.cs b/tests/ImageSharp.Tests/Colorspaces/Conversion/CieLuvAndLmsConversionTests.cs index 0e46c912c5..bd6dae2e3f 100644 --- a/tests/ImageSharp.Tests/Colorspaces/Conversion/CieLuvAndLmsConversionTests.cs +++ b/tests/ImageSharp.Tests/Colorspaces/Conversion/CieLuvAndLmsConversionTests.cs @@ -11,6 +11,7 @@ namespace SixLabors.ImageSharp.Tests.Colorspaces.Conversion /// /// Tests - conversions. /// + [Trait("Color", "Conversion")] public class CieLuvAndLmsConversionTests { private static readonly ApproximateColorSpaceComparer ColorSpaceComparer = new ApproximateColorSpaceComparer(.0002F); diff --git a/tests/ImageSharp.Tests/Colorspaces/Conversion/CieLuvAndRgbConversionTests.cs b/tests/ImageSharp.Tests/Colorspaces/Conversion/CieLuvAndRgbConversionTests.cs index 26417b7399..80999e5a41 100644 --- a/tests/ImageSharp.Tests/Colorspaces/Conversion/CieLuvAndRgbConversionTests.cs +++ b/tests/ImageSharp.Tests/Colorspaces/Conversion/CieLuvAndRgbConversionTests.cs @@ -11,6 +11,7 @@ namespace SixLabors.ImageSharp.Tests.Colorspaces.Conversion /// /// Tests - conversions. /// + [Trait("Color", "Conversion")] public class CieLuvAndRgbConversionTests { private static readonly ApproximateColorSpaceComparer ColorSpaceComparer = new ApproximateColorSpaceComparer(.0002F); diff --git a/tests/ImageSharp.Tests/Colorspaces/Conversion/CieLuvAndYCbCrConversionTests.cs b/tests/ImageSharp.Tests/Colorspaces/Conversion/CieLuvAndYCbCrConversionTests.cs index 07372aca87..17d9f984e2 100644 --- a/tests/ImageSharp.Tests/Colorspaces/Conversion/CieLuvAndYCbCrConversionTests.cs +++ b/tests/ImageSharp.Tests/Colorspaces/Conversion/CieLuvAndYCbCrConversionTests.cs @@ -11,6 +11,7 @@ namespace SixLabors.ImageSharp.Tests.Colorspaces.Conversion /// /// Tests - conversions. /// + [Trait("Color", "Conversion")] public class CieLuvAndYCbCrConversionTests { private static readonly ApproximateColorSpaceComparer ColorSpaceComparer = new ApproximateColorSpaceComparer(.0002F); diff --git a/tests/ImageSharp.Tests/Colorspaces/Conversion/CieXyyAndHslConversionTests.cs b/tests/ImageSharp.Tests/Colorspaces/Conversion/CieXyyAndHslConversionTests.cs index 818443ea50..d3474d7748 100644 --- a/tests/ImageSharp.Tests/Colorspaces/Conversion/CieXyyAndHslConversionTests.cs +++ b/tests/ImageSharp.Tests/Colorspaces/Conversion/CieXyyAndHslConversionTests.cs @@ -11,6 +11,7 @@ namespace SixLabors.ImageSharp.Tests.Colorspaces.Conversion /// /// Tests - conversions. /// + [Trait("Color", "Conversion")] public class CieXyyAndHslConversionTests { private static readonly ApproximateColorSpaceComparer ColorSpaceComparer = new ApproximateColorSpaceComparer(.0002F); diff --git a/tests/ImageSharp.Tests/Colorspaces/Conversion/CieXyyAndHsvConversionTests.cs b/tests/ImageSharp.Tests/Colorspaces/Conversion/CieXyyAndHsvConversionTests.cs index 18728d0c7d..fd33a75a22 100644 --- a/tests/ImageSharp.Tests/Colorspaces/Conversion/CieXyyAndHsvConversionTests.cs +++ b/tests/ImageSharp.Tests/Colorspaces/Conversion/CieXyyAndHsvConversionTests.cs @@ -11,6 +11,7 @@ namespace SixLabors.ImageSharp.Tests.Colorspaces.Conversion /// /// Tests - conversions. /// + [Trait("Color", "Conversion")] public class CieXyyAndHsvConversionTests { private static readonly ApproximateColorSpaceComparer ColorSpaceComparer = new ApproximateColorSpaceComparer(.0002F); diff --git a/tests/ImageSharp.Tests/Colorspaces/Conversion/CieXyyAndHunterLabConversionTests.cs b/tests/ImageSharp.Tests/Colorspaces/Conversion/CieXyyAndHunterLabConversionTests.cs index 015f95b656..1afbac8488 100644 --- a/tests/ImageSharp.Tests/Colorspaces/Conversion/CieXyyAndHunterLabConversionTests.cs +++ b/tests/ImageSharp.Tests/Colorspaces/Conversion/CieXyyAndHunterLabConversionTests.cs @@ -11,6 +11,7 @@ namespace SixLabors.ImageSharp.Tests.Colorspaces.Conversion /// /// Tests - conversions. /// + [Trait("Color", "Conversion")] public class CieXyyAndHunterLabConversionTests { private static readonly ApproximateColorSpaceComparer ColorSpaceComparer = new ApproximateColorSpaceComparer(.0002F); diff --git a/tests/ImageSharp.Tests/Colorspaces/Conversion/CieXyyAndLinearRgbConversionTests.cs b/tests/ImageSharp.Tests/Colorspaces/Conversion/CieXyyAndLinearRgbConversionTests.cs index 11f5fd516f..3c5134c4bb 100644 --- a/tests/ImageSharp.Tests/Colorspaces/Conversion/CieXyyAndLinearRgbConversionTests.cs +++ b/tests/ImageSharp.Tests/Colorspaces/Conversion/CieXyyAndLinearRgbConversionTests.cs @@ -11,6 +11,7 @@ namespace SixLabors.ImageSharp.Tests.Colorspaces.Conversion /// /// Tests - conversions. /// + [Trait("Color", "Conversion")] public class CieXyyAndLinearRgbConversionTests { private static readonly ApproximateColorSpaceComparer ColorSpaceComparer = new ApproximateColorSpaceComparer(.0002F); diff --git a/tests/ImageSharp.Tests/Colorspaces/Conversion/CieXyyAndLmsConversionTests.cs b/tests/ImageSharp.Tests/Colorspaces/Conversion/CieXyyAndLmsConversionTests.cs index 82a8478934..5864d9e00f 100644 --- a/tests/ImageSharp.Tests/Colorspaces/Conversion/CieXyyAndLmsConversionTests.cs +++ b/tests/ImageSharp.Tests/Colorspaces/Conversion/CieXyyAndLmsConversionTests.cs @@ -11,6 +11,7 @@ namespace SixLabors.ImageSharp.Tests.Colorspaces.Conversion /// /// Tests - conversions. /// + [Trait("Color", "Conversion")] public class CieXyyAndLmsConversionTests { private static readonly ApproximateColorSpaceComparer ColorSpaceComparer = new ApproximateColorSpaceComparer(.0002F); diff --git a/tests/ImageSharp.Tests/Colorspaces/Conversion/CieXyyAndRgbConversionTests.cs b/tests/ImageSharp.Tests/Colorspaces/Conversion/CieXyyAndRgbConversionTests.cs index 4249205939..df4b772edc 100644 --- a/tests/ImageSharp.Tests/Colorspaces/Conversion/CieXyyAndRgbConversionTests.cs +++ b/tests/ImageSharp.Tests/Colorspaces/Conversion/CieXyyAndRgbConversionTests.cs @@ -11,6 +11,7 @@ namespace SixLabors.ImageSharp.Tests.Colorspaces.Conversion /// /// Tests - conversions. /// + [Trait("Color", "Conversion")] public class CieXyyAndRgbConversionTests { private static readonly ApproximateColorSpaceComparer ColorSpaceComparer = new ApproximateColorSpaceComparer(.0002F); diff --git a/tests/ImageSharp.Tests/Colorspaces/Conversion/CieXyyAndYCbCrConversionTests.cs b/tests/ImageSharp.Tests/Colorspaces/Conversion/CieXyyAndYCbCrConversionTests.cs index 2c0a9a6025..3d45cdda14 100644 --- a/tests/ImageSharp.Tests/Colorspaces/Conversion/CieXyyAndYCbCrConversionTests.cs +++ b/tests/ImageSharp.Tests/Colorspaces/Conversion/CieXyyAndYCbCrConversionTests.cs @@ -11,6 +11,7 @@ namespace SixLabors.ImageSharp.Tests.Colorspaces.Conversion /// /// Tests - conversions. /// + [Trait("Color", "Conversion")] public class CieXyyAndYCbCrConversionTests { private static readonly ApproximateColorSpaceComparer ColorSpaceComparer = new ApproximateColorSpaceComparer(.0002F); diff --git a/tests/ImageSharp.Tests/Colorspaces/Conversion/CieXyzAndCieLabConversionTest.cs b/tests/ImageSharp.Tests/Colorspaces/Conversion/CieXyzAndCieLabConversionTest.cs index 40a60e47c6..0d4bf5e5ac 100644 --- a/tests/ImageSharp.Tests/Colorspaces/Conversion/CieXyzAndCieLabConversionTest.cs +++ b/tests/ImageSharp.Tests/Colorspaces/Conversion/CieXyzAndCieLabConversionTest.cs @@ -1,4 +1,4 @@ -// Copyright (c) Six Labors. +// Copyright (c) Six Labors. // Licensed under the Apache License, Version 2.0. using System; @@ -15,6 +15,7 @@ namespace SixLabors.ImageSharp.Tests.Colorspaces.Conversion /// Test data generated using: /// /// + [Trait("Color", "Conversion")] public class CieXyzAndCieLabConversionTest { private static readonly ApproximateColorSpaceComparer ColorSpaceComparer = new ApproximateColorSpaceComparer(.0001F); @@ -93,4 +94,4 @@ public void Convert_Xyz_to_Lab(float x, float y, float z, float l, float a, floa } } } -} \ No newline at end of file +} diff --git a/tests/ImageSharp.Tests/Colorspaces/Conversion/CieXyzAndCieLchConversionTests.cs b/tests/ImageSharp.Tests/Colorspaces/Conversion/CieXyzAndCieLchConversionTests.cs index 5bf463562f..2a534060f0 100644 --- a/tests/ImageSharp.Tests/Colorspaces/Conversion/CieXyzAndCieLchConversionTests.cs +++ b/tests/ImageSharp.Tests/Colorspaces/Conversion/CieXyzAndCieLchConversionTests.cs @@ -11,6 +11,7 @@ namespace SixLabors.ImageSharp.Tests.Colorspaces.Conversion /// /// Tests - conversions. /// + [Trait("Color", "Conversion")] public class CieXyzAndCieLchConversionTests { private static readonly ApproximateColorSpaceComparer ColorSpaceComparer = new ApproximateColorSpaceComparer(.0002F); diff --git a/tests/ImageSharp.Tests/Colorspaces/Conversion/CieXyzAndCieLchuvConversionTests.cs b/tests/ImageSharp.Tests/Colorspaces/Conversion/CieXyzAndCieLchuvConversionTests.cs index ae5df51304..047986a61b 100644 --- a/tests/ImageSharp.Tests/Colorspaces/Conversion/CieXyzAndCieLchuvConversionTests.cs +++ b/tests/ImageSharp.Tests/Colorspaces/Conversion/CieXyzAndCieLchuvConversionTests.cs @@ -11,6 +11,7 @@ namespace SixLabors.ImageSharp.Tests.Colorspaces.Conversion /// /// Tests - conversions. /// + [Trait("Color", "Conversion")] public class CieXyzAndCieLchuvConversionTests { private static readonly ApproximateColorSpaceComparer ColorSpaceComparer = new ApproximateColorSpaceComparer(.0002F); diff --git a/tests/ImageSharp.Tests/Colorspaces/Conversion/CieXyzAndCieLuvConversionTest.cs b/tests/ImageSharp.Tests/Colorspaces/Conversion/CieXyzAndCieLuvConversionTest.cs index 336d5a5082..f441595f42 100644 --- a/tests/ImageSharp.Tests/Colorspaces/Conversion/CieXyzAndCieLuvConversionTest.cs +++ b/tests/ImageSharp.Tests/Colorspaces/Conversion/CieXyzAndCieLuvConversionTest.cs @@ -1,4 +1,4 @@ -// Copyright (c) Six Labors. +// Copyright (c) Six Labors. // Licensed under the Apache License, Version 2.0. using System; @@ -15,6 +15,7 @@ namespace SixLabors.ImageSharp.Tests.Colorspaces.Conversion /// Test data generated using: /// /// + [Trait("Color", "Conversion")] public class CieXyzAndCieLuvConversionTest { private static readonly ApproximateColorSpaceComparer ColorSpaceComparer = new ApproximateColorSpaceComparer(.0001F); @@ -92,4 +93,4 @@ public void Convert_Xyz_to_Luv(float x, float y, float z, float l, float u, floa } } } -} \ No newline at end of file +} diff --git a/tests/ImageSharp.Tests/Colorspaces/Conversion/CieXyzAndCieXyyConversionTest.cs b/tests/ImageSharp.Tests/Colorspaces/Conversion/CieXyzAndCieXyyConversionTest.cs index 134a9529f1..78188450cb 100644 --- a/tests/ImageSharp.Tests/Colorspaces/Conversion/CieXyzAndCieXyyConversionTest.cs +++ b/tests/ImageSharp.Tests/Colorspaces/Conversion/CieXyzAndCieXyyConversionTest.cs @@ -1,4 +1,4 @@ -// Copyright (c) Six Labors. +// Copyright (c) Six Labors. // Licensed under the Apache License, Version 2.0. using System; @@ -15,6 +15,7 @@ namespace SixLabors.ImageSharp.Tests.Colorspaces.Conversion /// Test data generated using: /// /// + [Trait("Color", "Conversion")] public class CieXyzAndCieXyyConversionTest { private static readonly ApproximateColorSpaceComparer ColorSpaceComparer = new ApproximateColorSpaceComparer(.0001F); diff --git a/tests/ImageSharp.Tests/Colorspaces/Conversion/CieXyzAndHslConversionTests.cs b/tests/ImageSharp.Tests/Colorspaces/Conversion/CieXyzAndHslConversionTests.cs index 447856c637..f8f664a37e 100644 --- a/tests/ImageSharp.Tests/Colorspaces/Conversion/CieXyzAndHslConversionTests.cs +++ b/tests/ImageSharp.Tests/Colorspaces/Conversion/CieXyzAndHslConversionTests.cs @@ -11,6 +11,7 @@ namespace SixLabors.ImageSharp.Tests.Colorspaces.Conversion /// /// Tests - conversions. /// + [Trait("Color", "Conversion")] public class CieXyzAndHslConversionTests { private static readonly ApproximateColorSpaceComparer ColorSpaceComparer = new ApproximateColorSpaceComparer(.0002F); diff --git a/tests/ImageSharp.Tests/Colorspaces/Conversion/CieXyzAndHsvConversionTests.cs b/tests/ImageSharp.Tests/Colorspaces/Conversion/CieXyzAndHsvConversionTests.cs index 0591f60d2a..692b39f636 100644 --- a/tests/ImageSharp.Tests/Colorspaces/Conversion/CieXyzAndHsvConversionTests.cs +++ b/tests/ImageSharp.Tests/Colorspaces/Conversion/CieXyzAndHsvConversionTests.cs @@ -11,6 +11,7 @@ namespace SixLabors.ImageSharp.Tests.Colorspaces.Conversion /// /// Tests - conversions. /// + [Trait("Color", "Conversion")] public class CieXyzAndHsvConversionTests { private static readonly ApproximateColorSpaceComparer ColorSpaceComparer = new ApproximateColorSpaceComparer(.0002F); diff --git a/tests/ImageSharp.Tests/Colorspaces/Conversion/CieXyzAndHunterLabConversionTest.cs b/tests/ImageSharp.Tests/Colorspaces/Conversion/CieXyzAndHunterLabConversionTest.cs index 1ad329eab6..4c7c590399 100644 --- a/tests/ImageSharp.Tests/Colorspaces/Conversion/CieXyzAndHunterLabConversionTest.cs +++ b/tests/ImageSharp.Tests/Colorspaces/Conversion/CieXyzAndHunterLabConversionTest.cs @@ -1,4 +1,4 @@ -// Copyright (c) Six Labors. +// Copyright (c) Six Labors. // Licensed under the Apache License, Version 2.0. using System; @@ -15,6 +15,7 @@ namespace SixLabors.ImageSharp.Tests.Colorspaces.Conversion /// Test data generated using: /// /// + [Trait("Color", "Conversion")] public class CieXyzAndHunterLabConversionTest { private static readonly ApproximateColorSpaceComparer ColorSpaceComparer = new ApproximateColorSpaceComparer(.0001F); @@ -115,4 +116,4 @@ public void Convert_Xyz_D65_to_HunterLab(float x, float y, float z, float l, flo } } } -} \ No newline at end of file +} diff --git a/tests/ImageSharp.Tests/Colorspaces/Conversion/CieXyzAndLmsConversionTest.cs b/tests/ImageSharp.Tests/Colorspaces/Conversion/CieXyzAndLmsConversionTest.cs index 5f6a3030ba..df564a5180 100644 --- a/tests/ImageSharp.Tests/Colorspaces/Conversion/CieXyzAndLmsConversionTest.cs +++ b/tests/ImageSharp.Tests/Colorspaces/Conversion/CieXyzAndLmsConversionTest.cs @@ -1,4 +1,4 @@ -// Copyright (c) Six Labors. +// Copyright (c) Six Labors. // Licensed under the Apache License, Version 2.0. using System; @@ -14,6 +14,7 @@ namespace SixLabors.ImageSharp.Tests.Colorspaces.Conversion /// /// Test data generated using original colorful library. /// + [Trait("Color", "Conversion")] public class CieXyzAndLmsConversionTest { private static readonly ApproximateColorSpaceComparer ColorSpaceComparer = new ApproximateColorSpaceComparer(.0001F); @@ -88,4 +89,4 @@ public void Convert_CieXyz_to_Lms(float x, float y, float z, float l, float m, f } } } -} \ No newline at end of file +} diff --git a/tests/ImageSharp.Tests/Colorspaces/Conversion/CieXyzAndYCbCrConversionTests.cs b/tests/ImageSharp.Tests/Colorspaces/Conversion/CieXyzAndYCbCrConversionTests.cs index a255b9e242..4526bf60ec 100644 --- a/tests/ImageSharp.Tests/Colorspaces/Conversion/CieXyzAndYCbCrConversionTests.cs +++ b/tests/ImageSharp.Tests/Colorspaces/Conversion/CieXyzAndYCbCrConversionTests.cs @@ -11,6 +11,7 @@ namespace SixLabors.ImageSharp.Tests.Colorspaces.Conversion /// /// Tests - conversions. /// + [Trait("Color", "Conversion")] public class CieXyzAndYCbCrConversionTests { private static readonly ApproximateColorSpaceComparer ColorSpaceComparer = new ApproximateColorSpaceComparer(.0002F); diff --git a/tests/ImageSharp.Tests/Colorspaces/Conversion/CmykAndCieLchConversionTests.cs b/tests/ImageSharp.Tests/Colorspaces/Conversion/CmykAndCieLchConversionTests.cs index dcbaaf7e63..e7d579c32c 100644 --- a/tests/ImageSharp.Tests/Colorspaces/Conversion/CmykAndCieLchConversionTests.cs +++ b/tests/ImageSharp.Tests/Colorspaces/Conversion/CmykAndCieLchConversionTests.cs @@ -1,4 +1,4 @@ -// Copyright (c) Six Labors. +// Copyright (c) Six Labors. // Licensed under the Apache License, Version 2.0. using System; @@ -11,6 +11,7 @@ namespace SixLabors.ImageSharp.Tests.Colorspaces.Conversion /// /// Tests - conversions. /// + [Trait("Color", "Conversion")] public class CmykAndCieLchConversionTests { private static readonly ApproximateColorSpaceComparer ColorSpaceComparer = new ApproximateColorSpaceComparer(.0002F); @@ -75,4 +76,4 @@ public void Convert_CieLch_to_Cmyk(float l, float c2, float h, float c, float m, } } } -} \ No newline at end of file +} diff --git a/tests/ImageSharp.Tests/Colorspaces/Conversion/CmykAndCieLuvConversionTests.cs b/tests/ImageSharp.Tests/Colorspaces/Conversion/CmykAndCieLuvConversionTests.cs index cdb6c67bf6..ac19fcecd7 100644 --- a/tests/ImageSharp.Tests/Colorspaces/Conversion/CmykAndCieLuvConversionTests.cs +++ b/tests/ImageSharp.Tests/Colorspaces/Conversion/CmykAndCieLuvConversionTests.cs @@ -1,4 +1,4 @@ -// Copyright (c) Six Labors. +// Copyright (c) Six Labors. // Licensed under the Apache License, Version 2.0. using System; @@ -11,6 +11,7 @@ namespace SixLabors.ImageSharp.Tests.Colorspaces.Conversion /// /// Tests - conversions. /// + [Trait("Color", "Conversion")] public class CmykAndCieLuvConversionTests { private static readonly ApproximateColorSpaceComparer ColorSpaceComparer = new ApproximateColorSpaceComparer(.0002F); @@ -76,4 +77,4 @@ public void Convert_CieLuv_to_Cmyk(float l, float u, float v, float c, float m, } } } -} \ No newline at end of file +} diff --git a/tests/ImageSharp.Tests/Colorspaces/Conversion/CmykAndCieXyyConversionTests.cs b/tests/ImageSharp.Tests/Colorspaces/Conversion/CmykAndCieXyyConversionTests.cs index 54505428e4..4f599d1bd7 100644 --- a/tests/ImageSharp.Tests/Colorspaces/Conversion/CmykAndCieXyyConversionTests.cs +++ b/tests/ImageSharp.Tests/Colorspaces/Conversion/CmykAndCieXyyConversionTests.cs @@ -1,4 +1,4 @@ -// Copyright (c) Six Labors. +// Copyright (c) Six Labors. // Licensed under the Apache License, Version 2.0. using System; @@ -11,6 +11,7 @@ namespace SixLabors.ImageSharp.Tests.Colorspaces.Conversion /// /// Tests - conversions. /// + [Trait("Color", "Conversion")] public class CmykAndCieXyyConversionTests { private static readonly ApproximateColorSpaceComparer ColorSpaceComparer = new ApproximateColorSpaceComparer(.0002F); @@ -76,4 +77,4 @@ public void Convert_CieXyy_to_Cmyk(float x, float y2, float yl, float c, float m } } } -} \ No newline at end of file +} diff --git a/tests/ImageSharp.Tests/Colorspaces/Conversion/CmykAndCieXyzConversionTests.cs b/tests/ImageSharp.Tests/Colorspaces/Conversion/CmykAndCieXyzConversionTests.cs index de8ca44093..7308f60ad8 100644 --- a/tests/ImageSharp.Tests/Colorspaces/Conversion/CmykAndCieXyzConversionTests.cs +++ b/tests/ImageSharp.Tests/Colorspaces/Conversion/CmykAndCieXyzConversionTests.cs @@ -1,4 +1,4 @@ -// Copyright (c) Six Labors. +// Copyright (c) Six Labors. // Licensed under the Apache License, Version 2.0. using System; @@ -11,6 +11,7 @@ namespace SixLabors.ImageSharp.Tests.Colorspaces.Conversion /// /// Tests - conversions. /// + [Trait("Color", "Conversion")] public class CmykAndCieXyzConversionTests { private static readonly ApproximateColorSpaceComparer ColorSpaceComparer = new ApproximateColorSpaceComparer(.0002F); @@ -76,4 +77,4 @@ public void Convert_CieXyz_to_Cmyk(float x, float y2, float z, float c, float m, } } } -} \ No newline at end of file +} diff --git a/tests/ImageSharp.Tests/Colorspaces/Conversion/CmykAndHslConversionTests.cs b/tests/ImageSharp.Tests/Colorspaces/Conversion/CmykAndHslConversionTests.cs index 61f698a1ad..f0fef65a5a 100644 --- a/tests/ImageSharp.Tests/Colorspaces/Conversion/CmykAndHslConversionTests.cs +++ b/tests/ImageSharp.Tests/Colorspaces/Conversion/CmykAndHslConversionTests.cs @@ -1,4 +1,4 @@ -// Copyright (c) Six Labors. +// Copyright (c) Six Labors. // Licensed under the Apache License, Version 2.0. using System; @@ -11,6 +11,7 @@ namespace SixLabors.ImageSharp.Tests.Colorspaces.Conversion /// /// Tests - conversions. /// + [Trait("Color", "Conversion")] public class CmykAndHslConversionTests { private static readonly ApproximateColorSpaceComparer ColorSpaceComparer = new ApproximateColorSpaceComparer(.0002F); @@ -76,4 +77,4 @@ public void Convert_Hsl_to_Cmyk(float h, float s, float l, float c, float m, flo } } } -} \ No newline at end of file +} diff --git a/tests/ImageSharp.Tests/Colorspaces/Conversion/CmykAndHsvConversionTests.cs b/tests/ImageSharp.Tests/Colorspaces/Conversion/CmykAndHsvConversionTests.cs index b5d97f4425..49e772765d 100644 --- a/tests/ImageSharp.Tests/Colorspaces/Conversion/CmykAndHsvConversionTests.cs +++ b/tests/ImageSharp.Tests/Colorspaces/Conversion/CmykAndHsvConversionTests.cs @@ -1,4 +1,4 @@ -// Copyright (c) Six Labors. +// Copyright (c) Six Labors. // Licensed under the Apache License, Version 2.0. using System; @@ -11,6 +11,7 @@ namespace SixLabors.ImageSharp.Tests.Colorspaces.Conversion /// /// Tests - conversions. /// + [Trait("Color", "Conversion")] public class CmykAndHsvConversionTests { private static readonly ApproximateColorSpaceComparer ColorSpaceComparer = new ApproximateColorSpaceComparer(.0002F); @@ -76,4 +77,4 @@ public void Convert_Hsv_to_Cmyk(float h, float s, float v, float c, float m, flo } } } -} \ No newline at end of file +} diff --git a/tests/ImageSharp.Tests/Colorspaces/Conversion/CmykAndHunterLabConversionTests.cs b/tests/ImageSharp.Tests/Colorspaces/Conversion/CmykAndHunterLabConversionTests.cs index eaceae2297..ff9336748d 100644 --- a/tests/ImageSharp.Tests/Colorspaces/Conversion/CmykAndHunterLabConversionTests.cs +++ b/tests/ImageSharp.Tests/Colorspaces/Conversion/CmykAndHunterLabConversionTests.cs @@ -1,4 +1,4 @@ -// Copyright (c) Six Labors. +// Copyright (c) Six Labors. // Licensed under the Apache License, Version 2.0. using System; @@ -11,6 +11,7 @@ namespace SixLabors.ImageSharp.Tests.Colorspaces.Conversion /// /// Tests - conversions. /// + [Trait("Color", "Conversion")] public class CmykAndHunterLabConversionTests { private static readonly ApproximateColorSpaceComparer ColorSpaceComparer = new ApproximateColorSpaceComparer(.0002F); @@ -76,4 +77,4 @@ public void Convert_HunterLab_to_Cmyk(float l, float a, float b, float c, float } } } -} \ No newline at end of file +} diff --git a/tests/ImageSharp.Tests/Colorspaces/Conversion/CmykAndYCbCrConversionTests.cs b/tests/ImageSharp.Tests/Colorspaces/Conversion/CmykAndYCbCrConversionTests.cs index fabfea7e26..44b00708a5 100644 --- a/tests/ImageSharp.Tests/Colorspaces/Conversion/CmykAndYCbCrConversionTests.cs +++ b/tests/ImageSharp.Tests/Colorspaces/Conversion/CmykAndYCbCrConversionTests.cs @@ -1,4 +1,4 @@ -// Copyright (c) Six Labors. +// Copyright (c) Six Labors. // Licensed under the Apache License, Version 2.0. using System; @@ -11,6 +11,7 @@ namespace SixLabors.ImageSharp.Tests.Colorspaces.Conversion /// /// Tests - conversions. /// + [Trait("Color", "Conversion")] public class CmykAndYCbCrConversionTests { private static readonly ApproximateColorSpaceComparer ColorSpaceComparer = new ApproximateColorSpaceComparer(.0002F); @@ -76,4 +77,4 @@ public void Convert_YCbCr_to_Cmyk(float y2, float cb, float cr, float c, float m } } } -} \ No newline at end of file +} diff --git a/tests/ImageSharp.Tests/Colorspaces/Conversion/ColorConverterAdaptTest.cs b/tests/ImageSharp.Tests/Colorspaces/Conversion/ColorConverterAdaptTest.cs index 466b2d3c33..43df49f83f 100644 --- a/tests/ImageSharp.Tests/Colorspaces/Conversion/ColorConverterAdaptTest.cs +++ b/tests/ImageSharp.Tests/Colorspaces/Conversion/ColorConverterAdaptTest.cs @@ -13,6 +13,7 @@ namespace SixLabors.ImageSharp.Tests.Colorspaces.Conversion /// /// /// + [Trait("Color", "Conversion")] public class ColorConverterAdaptTest { private static readonly ApproximateColorSpaceComparer ColorSpaceComparer = new ApproximateColorSpaceComparer(.0001F); diff --git a/tests/ImageSharp.Tests/Colorspaces/Conversion/RgbAndCieXyzConversionTest.cs b/tests/ImageSharp.Tests/Colorspaces/Conversion/RgbAndCieXyzConversionTest.cs index d0b5cf99da..fbb3bb23d7 100644 --- a/tests/ImageSharp.Tests/Colorspaces/Conversion/RgbAndCieXyzConversionTest.cs +++ b/tests/ImageSharp.Tests/Colorspaces/Conversion/RgbAndCieXyzConversionTest.cs @@ -1,4 +1,4 @@ -// Copyright (c) Six Labors. +// Copyright (c) Six Labors. // Licensed under the Apache License, Version 2.0. using System; @@ -15,6 +15,7 @@ namespace SixLabors.ImageSharp.Tests.Colorspaces.Conversion /// Test data generated using: /// /// + [Trait("Color", "Conversion")] public class RgbAndCieXyzConversionTest { private static readonly ApproximateColorSpaceComparer ColorSpaceComparer = new ApproximateColorSpaceComparer(.0001F); @@ -170,4 +171,4 @@ public void Convert_SRGB_to_XYZ_D65(float r, float g, float b, float x, float y, } } } -} \ No newline at end of file +} diff --git a/tests/ImageSharp.Tests/Colorspaces/Conversion/RgbAndCmykConversionTest.cs b/tests/ImageSharp.Tests/Colorspaces/Conversion/RgbAndCmykConversionTest.cs index fed76101d1..d0218cd3f2 100644 --- a/tests/ImageSharp.Tests/Colorspaces/Conversion/RgbAndCmykConversionTest.cs +++ b/tests/ImageSharp.Tests/Colorspaces/Conversion/RgbAndCmykConversionTest.cs @@ -1,4 +1,4 @@ -// Copyright (c) Six Labors. +// Copyright (c) Six Labors. // Licensed under the Apache License, Version 2.0. using System; @@ -16,6 +16,7 @@ namespace SixLabors.ImageSharp.Tests.Colorspaces.Conversion /// /// /// + [Trait("Color", "Conversion")] public class RgbAndCmykConversionTest { private static readonly ColorSpaceConverter Converter = new ColorSpaceConverter(); diff --git a/tests/ImageSharp.Tests/Colorspaces/Conversion/RgbAndHslConversionTest.cs b/tests/ImageSharp.Tests/Colorspaces/Conversion/RgbAndHslConversionTest.cs index 279c57510c..d604a396b6 100644 --- a/tests/ImageSharp.Tests/Colorspaces/Conversion/RgbAndHslConversionTest.cs +++ b/tests/ImageSharp.Tests/Colorspaces/Conversion/RgbAndHslConversionTest.cs @@ -16,6 +16,7 @@ namespace SixLabors.ImageSharp.Tests.Colorspaces.Conversion /// /// /// + [Trait("Color", "Conversion")] public class RgbAndHslConversionTest { private static readonly ColorSpaceConverter Converter = new ColorSpaceConverter(); diff --git a/tests/ImageSharp.Tests/Colorspaces/Conversion/RgbAndHsvConversionTest.cs b/tests/ImageSharp.Tests/Colorspaces/Conversion/RgbAndHsvConversionTest.cs index abd190262a..5245c68419 100644 --- a/tests/ImageSharp.Tests/Colorspaces/Conversion/RgbAndHsvConversionTest.cs +++ b/tests/ImageSharp.Tests/Colorspaces/Conversion/RgbAndHsvConversionTest.cs @@ -1,4 +1,4 @@ -// Copyright (c) Six Labors. +// Copyright (c) Six Labors. // Licensed under the Apache License, Version 2.0. using System; @@ -15,6 +15,7 @@ namespace SixLabors.ImageSharp.Tests.Colorspaces.Conversion /// Test data generated using: /// /// + [Trait("Color", "Conversion")] public class RgbAndHsvConversionTest { private static readonly ColorSpaceConverter Converter = new ColorSpaceConverter(); diff --git a/tests/ImageSharp.Tests/Colorspaces/Conversion/RgbAndYCbCrConversionTest.cs b/tests/ImageSharp.Tests/Colorspaces/Conversion/RgbAndYCbCrConversionTest.cs index f2d1f49724..d3fa86aaca 100644 --- a/tests/ImageSharp.Tests/Colorspaces/Conversion/RgbAndYCbCrConversionTest.cs +++ b/tests/ImageSharp.Tests/Colorspaces/Conversion/RgbAndYCbCrConversionTest.cs @@ -1,4 +1,4 @@ -// Copyright (c) Six Labors. +// Copyright (c) Six Labors. // Licensed under the Apache License, Version 2.0. using System; @@ -14,6 +14,7 @@ namespace SixLabors.ImageSharp.Tests.Colorspaces.Conversion /// /// Test data generated mathematically /// + [Trait("Color", "Conversion")] public class RgbAndYCbCrConversionTest { private static readonly ColorSpaceConverter Converter = new ColorSpaceConverter(); @@ -83,4 +84,4 @@ public void Convert_Rgb_To_YCbCr(float r, float g, float b, float y, float cb, f } } } -} \ No newline at end of file +} diff --git a/tests/ImageSharp.Tests/Colorspaces/Conversion/VonKriesChromaticAdaptationTests.cs b/tests/ImageSharp.Tests/Colorspaces/Conversion/VonKriesChromaticAdaptationTests.cs index ae7711e55a..a8c52a83c7 100644 --- a/tests/ImageSharp.Tests/Colorspaces/Conversion/VonKriesChromaticAdaptationTests.cs +++ b/tests/ImageSharp.Tests/Colorspaces/Conversion/VonKriesChromaticAdaptationTests.cs @@ -8,6 +8,7 @@ namespace SixLabors.ImageSharp.Tests.Colorspaces.Conversion { + [Trait("Color", "Conversion")] public class VonKriesChromaticAdaptationTests { private static readonly ApproximateColorSpaceComparer ColorSpaceComparer = new ApproximateColorSpaceComparer(.0001F); diff --git a/tests/ImageSharp.Tests/Colorspaces/HslTests.cs b/tests/ImageSharp.Tests/Colorspaces/HslTests.cs index 9df33c37d1..d35bcab060 100644 --- a/tests/ImageSharp.Tests/Colorspaces/HslTests.cs +++ b/tests/ImageSharp.Tests/Colorspaces/HslTests.cs @@ -10,6 +10,7 @@ namespace SixLabors.ImageSharp.Tests.Colorspaces /// /// Tests the struct. /// + [Trait("Color", "Conversion")] public class HslTests { [Fact] diff --git a/tests/ImageSharp.Tests/Colorspaces/HsvTests.cs b/tests/ImageSharp.Tests/Colorspaces/HsvTests.cs index d6e7fc85e9..918a50965b 100644 --- a/tests/ImageSharp.Tests/Colorspaces/HsvTests.cs +++ b/tests/ImageSharp.Tests/Colorspaces/HsvTests.cs @@ -10,6 +10,7 @@ namespace SixLabors.ImageSharp.Tests.Colorspaces /// /// Tests the struct. /// + [Trait("Color", "Conversion")] public class HsvTests { [Fact] diff --git a/tests/ImageSharp.Tests/Colorspaces/HunterLabTests.cs b/tests/ImageSharp.Tests/Colorspaces/HunterLabTests.cs index 5b47f8c9b9..c0cf0ff4e0 100644 --- a/tests/ImageSharp.Tests/Colorspaces/HunterLabTests.cs +++ b/tests/ImageSharp.Tests/Colorspaces/HunterLabTests.cs @@ -10,6 +10,7 @@ namespace SixLabors.ImageSharp.Tests.Colorspaces /// /// Tests the struct. /// + [Trait("Color", "Conversion")] public class HunterLabTests { [Fact] diff --git a/tests/ImageSharp.Tests/Colorspaces/Icc/Calculators/ClutCalculatorTests.cs b/tests/ImageSharp.Tests/Colorspaces/Icc/Calculators/ClutCalculatorTests.cs index a43ac906be..8a0b4b2b0a 100644 --- a/tests/ImageSharp.Tests/Colorspaces/Icc/Calculators/ClutCalculatorTests.cs +++ b/tests/ImageSharp.Tests/Colorspaces/Icc/Calculators/ClutCalculatorTests.cs @@ -12,6 +12,7 @@ namespace SixLabors.ImageSharp.Tests.Colorspaces.Icc.Calculators /// /// Tests ICC /// + [Trait("Color", "Conversion")] public class ClutCalculatorTests { [Theory] diff --git a/tests/ImageSharp.Tests/Colorspaces/Icc/Calculators/CurveCalculatorTests.cs b/tests/ImageSharp.Tests/Colorspaces/Icc/Calculators/CurveCalculatorTests.cs index b3f06e8b0b..d52ec5de79 100644 --- a/tests/ImageSharp.Tests/Colorspaces/Icc/Calculators/CurveCalculatorTests.cs +++ b/tests/ImageSharp.Tests/Colorspaces/Icc/Calculators/CurveCalculatorTests.cs @@ -11,6 +11,7 @@ namespace SixLabors.ImageSharp.Tests.Colorspaces.Icc.Calculators /// /// Tests ICC /// + [Trait("Color", "Conversion")] public class CurveCalculatorTests { [Theory] diff --git a/tests/ImageSharp.Tests/Colorspaces/Icc/Calculators/LutABCalculatorTests.cs b/tests/ImageSharp.Tests/Colorspaces/Icc/Calculators/LutABCalculatorTests.cs index 831603f5cb..f4d3d0e76f 100644 --- a/tests/ImageSharp.Tests/Colorspaces/Icc/Calculators/LutABCalculatorTests.cs +++ b/tests/ImageSharp.Tests/Colorspaces/Icc/Calculators/LutABCalculatorTests.cs @@ -12,6 +12,7 @@ namespace SixLabors.ImageSharp.Tests.Colorspaces.Icc.Calculators /// /// Tests ICC /// + [Trait("Color", "Conversion")] public class LutABCalculatorTests { [Theory] diff --git a/tests/ImageSharp.Tests/Colorspaces/Icc/Calculators/LutCalculatorTests.cs b/tests/ImageSharp.Tests/Colorspaces/Icc/Calculators/LutCalculatorTests.cs index 1fdb449669..b371d3daa0 100644 --- a/tests/ImageSharp.Tests/Colorspaces/Icc/Calculators/LutCalculatorTests.cs +++ b/tests/ImageSharp.Tests/Colorspaces/Icc/Calculators/LutCalculatorTests.cs @@ -10,6 +10,7 @@ namespace SixLabors.ImageSharp.Tests.Colorspaces.Icc.Calculators /// /// Tests ICC /// + [Trait("Color", "Conversion")] public class LutCalculatorTests { [Theory] diff --git a/tests/ImageSharp.Tests/Colorspaces/Icc/Calculators/LutEntryCalculatorTests.cs b/tests/ImageSharp.Tests/Colorspaces/Icc/Calculators/LutEntryCalculatorTests.cs index ef4f25a535..a0558701c9 100644 --- a/tests/ImageSharp.Tests/Colorspaces/Icc/Calculators/LutEntryCalculatorTests.cs +++ b/tests/ImageSharp.Tests/Colorspaces/Icc/Calculators/LutEntryCalculatorTests.cs @@ -12,6 +12,7 @@ namespace SixLabors.ImageSharp.Tests.Colorspaces.Icc.Calculators /// /// Tests ICC /// + [Trait("Color", "Conversion")] public class LutEntryCalculatorTests { [Theory] diff --git a/tests/ImageSharp.Tests/Colorspaces/Icc/Calculators/MatrixCalculatorTests.cs b/tests/ImageSharp.Tests/Colorspaces/Icc/Calculators/MatrixCalculatorTests.cs index 68e4891299..a353e7df28 100644 --- a/tests/ImageSharp.Tests/Colorspaces/Icc/Calculators/MatrixCalculatorTests.cs +++ b/tests/ImageSharp.Tests/Colorspaces/Icc/Calculators/MatrixCalculatorTests.cs @@ -11,6 +11,7 @@ namespace SixLabors.ImageSharp.Tests.Colorspaces.Icc.Calculators /// /// Tests ICC /// + [Trait("Color", "Conversion")] public class MatrixCalculatorTests { [Theory] diff --git a/tests/ImageSharp.Tests/Colorspaces/Icc/Calculators/ParametricCurveCalculatorTests.cs b/tests/ImageSharp.Tests/Colorspaces/Icc/Calculators/ParametricCurveCalculatorTests.cs index f5a7f7bb72..e15867d9bf 100644 --- a/tests/ImageSharp.Tests/Colorspaces/Icc/Calculators/ParametricCurveCalculatorTests.cs +++ b/tests/ImageSharp.Tests/Colorspaces/Icc/Calculators/ParametricCurveCalculatorTests.cs @@ -11,6 +11,7 @@ namespace SixLabors.ImageSharp.Tests.Colorspaces.Icc.Calculators /// /// Tests ICC /// + [Trait("Color", "Conversion")] public class ParametricCurveCalculatorTests { [Theory] diff --git a/tests/ImageSharp.Tests/Colorspaces/Icc/Calculators/TrcCalculatorTests.cs b/tests/ImageSharp.Tests/Colorspaces/Icc/Calculators/TrcCalculatorTests.cs index 7099e12686..dcaebc9d34 100644 --- a/tests/ImageSharp.Tests/Colorspaces/Icc/Calculators/TrcCalculatorTests.cs +++ b/tests/ImageSharp.Tests/Colorspaces/Icc/Calculators/TrcCalculatorTests.cs @@ -12,6 +12,7 @@ namespace SixLabors.ImageSharp.Tests.Colorspaces.Icc.Calculators /// /// Tests ICC /// + [Trait("Color", "Conversion")] public class TrcCalculatorTests { [Theory] diff --git a/tests/ImageSharp.Tests/Colorspaces/LinearRgbTests.cs b/tests/ImageSharp.Tests/Colorspaces/LinearRgbTests.cs index 24ce6052e3..7d6dd7d63d 100644 --- a/tests/ImageSharp.Tests/Colorspaces/LinearRgbTests.cs +++ b/tests/ImageSharp.Tests/Colorspaces/LinearRgbTests.cs @@ -10,6 +10,7 @@ namespace SixLabors.ImageSharp.Tests.Colorspaces /// /// Tests the struct. /// + [Trait("Color", "Conversion")] public class LinearRgbTests { [Fact] diff --git a/tests/ImageSharp.Tests/Colorspaces/LmsTests.cs b/tests/ImageSharp.Tests/Colorspaces/LmsTests.cs index 2a89e62eb5..3cca5c5ab2 100644 --- a/tests/ImageSharp.Tests/Colorspaces/LmsTests.cs +++ b/tests/ImageSharp.Tests/Colorspaces/LmsTests.cs @@ -10,6 +10,7 @@ namespace SixLabors.ImageSharp.Tests.Colorspaces /// /// Tests the struct. /// + [Trait("Color", "Conversion")] public class LmsTests { [Fact] diff --git a/tests/ImageSharp.Tests/Colorspaces/RgbTests.cs b/tests/ImageSharp.Tests/Colorspaces/RgbTests.cs index 788976fbff..b6051d15ff 100644 --- a/tests/ImageSharp.Tests/Colorspaces/RgbTests.cs +++ b/tests/ImageSharp.Tests/Colorspaces/RgbTests.cs @@ -11,6 +11,7 @@ namespace SixLabors.ImageSharp.Tests.Colorspaces /// /// Tests the struct. /// + [Trait("Color", "Conversion")] public class RgbTests { [Fact] @@ -32,9 +33,9 @@ public void RgbEquality() var x = default(Rgb); var y = new Rgb(Vector3.One); - Assert.True(default(Rgb) == default(Rgb)); - Assert.False(default(Rgb) != default(Rgb)); - Assert.Equal(default(Rgb), default(Rgb)); + Assert.True(default(Rgb) == default); + Assert.False(default(Rgb) != default); + Assert.Equal(default(Rgb), default); Assert.Equal(new Rgb(1, 0, 1), new Rgb(1, 0, 1)); Assert.Equal(new Rgb(Vector3.One), new Rgb(Vector3.One)); Assert.False(x.Equals(y)); diff --git a/tests/ImageSharp.Tests/Colorspaces/StringRepresentationTests.cs b/tests/ImageSharp.Tests/Colorspaces/StringRepresentationTests.cs index ca50e4a74f..4f4d18c09a 100644 --- a/tests/ImageSharp.Tests/Colorspaces/StringRepresentationTests.cs +++ b/tests/ImageSharp.Tests/Colorspaces/StringRepresentationTests.cs @@ -8,6 +8,7 @@ namespace SixLabors.ImageSharp.Tests.Colorspaces { + [Trait("Color", "Conversion")] public class StringRepresentationTests { private static readonly Vector3 One = new Vector3(1); diff --git a/tests/ImageSharp.Tests/Colorspaces/YCbCrTests.cs b/tests/ImageSharp.Tests/Colorspaces/YCbCrTests.cs index ae3a63ef34..827f9d525a 100644 --- a/tests/ImageSharp.Tests/Colorspaces/YCbCrTests.cs +++ b/tests/ImageSharp.Tests/Colorspaces/YCbCrTests.cs @@ -10,6 +10,7 @@ namespace SixLabors.ImageSharp.Tests.Colorspaces /// /// Tests the struct. /// + [Trait("Color", "Conversion")] public class YCbCrTests { [Fact] From 759f053ac9263aac50c2199a4a164a88fab86523 Mon Sep 17 00:00:00 2001 From: Brian Popow Date: Tue, 13 Jul 2021 11:26:11 +0200 Subject: [PATCH 04/42] Fix failing MatrixCalculator test --- .../TestDataIcc/Conversion/IccConversionDataMatrix.cs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/tests/ImageSharp.Tests/TestDataIcc/Conversion/IccConversionDataMatrix.cs b/tests/ImageSharp.Tests/TestDataIcc/Conversion/IccConversionDataMatrix.cs index ec397d6658..b45607c2db 100644 --- a/tests/ImageSharp.Tests/TestDataIcc/Conversion/IccConversionDataMatrix.cs +++ b/tests/ImageSharp.Tests/TestDataIcc/Conversion/IccConversionDataMatrix.cs @@ -7,6 +7,8 @@ namespace SixLabors.ImageSharp.Tests.TestDataIcc.Conversion { public class IccConversionDataMatrix { + private static readonly Vector3 Vector3Zero = new Vector3(0.0f, 0.0f, 0.0f); + public static float[,] Matrix3x3Random = { { 0.1f, 0.2f, 0.3f }, @@ -23,11 +25,11 @@ public class IccConversionDataMatrix 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) }, + new object[] { CreateMatrix(Matrix3x3Identity), Vector3Zero, new Vector4(0.5f, 0.5f, 0.5f, 0), new Vector4(0.5f, 0.5f, 0.5f, 0) }, new object[] { CreateMatrix(Matrix3x3Identity), new Vector3(0.2f, 0.2f, 0.2f), new Vector4(0.5f, 0.5f, 0.5f, 0), new Vector4(0.7f, 0.7f, 0.7f, 0) }, - new object[] { CreateMatrix(Matrix3x3Random), Vector3.Zero, new Vector4(0.5f, 0.5f, 0.5f, 0), new Vector4(0.6f, 0.75f, 0.9f, 0) }, + new object[] { CreateMatrix(Matrix3x3Random), Vector3Zero, new Vector4(0.5f, 0.5f, 0.5f, 0), new Vector4(0.6f, 0.75f, 0.9f, 0) }, new object[] { CreateMatrix(Matrix3x3Random), new Vector3(0.1f, 0.2f, 0.3f), new Vector4(0.5f, 0.5f, 0.5f, 0), new Vector4(0.7f, 0.95f, 1.2f, 0) }, - 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), Vector3Zero, 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) }, }; From dc166a7804031a19e7ec25c6abdafddb8e134df7 Mon Sep 17 00:00:00 2001 From: James Jackson-South Date: Wed, 23 Nov 2022 18:16:19 +1000 Subject: [PATCH 05/42] Fix build --- .../Icc/Calculators/ClutCalculator.cs | 146 ++++++----- .../Icc/Calculators/ColorTrcCalculator.cs | 75 +++--- .../CurveCalculator.CalculationType.cs | 2 +- .../Icc/Calculators/CurveCalculator.cs | 2 +- .../Icc/Calculators/GrayTrcCalculator.cs | 2 +- .../Icc/Calculators/ISingleCalculator.cs | 2 +- .../Icc/Calculators/IVector4Calculator.cs | 4 +- .../LutABCalculator.CalculationType.cs | 2 +- .../Icc/Calculators/LutABCalculator.cs | 2 +- .../Icc/Calculators/LutCalculator.cs | 2 +- .../Icc/Calculators/LutEntryCalculator.cs | 10 +- .../Icc/Calculators/MatrixCalculator.cs | 2 +- .../Calculators/ParametricCurveCalculator.cs | 2 +- .../Icc/Calculators/TrcCalculator.cs | 2 +- .../Icc/IccConverterBase.Checks.cs | 244 +++++++++--------- .../Icc/IccConverterBase.ConversionMethod.cs | 2 +- .../Icc/IccConverterbase.Conversions.cs | 62 ++--- .../Implementation/Icc/IccConverterbase.cs | 2 +- .../Icc/IccDataToDataConverter.cs | 2 +- .../Icc/IccDataToPcsConverter.cs | 2 +- .../Icc/IccPcsToDataConverter.cs | 2 +- .../Icc/IccPcsToPcsConverter.cs | 2 +- .../Icc/Calculators/ClutCalculatorTests.cs | 30 +-- 23 files changed, 295 insertions(+), 308 deletions(-) diff --git a/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/ClutCalculator.cs b/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/ClutCalculator.cs index 7f2b355cd8..4b65f46a84 100644 --- a/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/ClutCalculator.cs +++ b/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/ClutCalculator.cs @@ -1,104 +1,102 @@ // Copyright (c) Six Labors. -// Licensed under the Apache License, Version 2.0. +// Licensed under the Six Labors Split License. -using System; using System.Numerics; using SixLabors.ImageSharp.Metadata.Profiles.Icc; -namespace SixLabors.ImageSharp.ColorSpaces.Conversion.Icc +namespace SixLabors.ImageSharp.ColorSpaces.Conversion.Icc; + +internal class ClutCalculator : IVector4Calculator { - internal class ClutCalculator : IVector4Calculator + private readonly int inputCount; + private readonly int outputCount; + private readonly float[][] lut; + private readonly byte[] gridPointCount; + private readonly int[] indexFactor; + private readonly int nodeCount; + + public ClutCalculator(IccClut clut) { - private int inputCount; - private int outputCount; - private float[][] lut; - private byte[] gridPointCount; - private int[] indexFactor; - private int nodeCount; - - public ClutCalculator(IccClut clut) - { - Guard.NotNull(clut, nameof(clut)); - - this.inputCount = clut.InputChannelCount; - this.outputCount = clut.OutputChannelCount; - this.lut = clut.Values; - this.gridPointCount = clut.GridPointCount; - this.indexFactor = this.CalculateIndexFactor(clut.InputChannelCount, clut.GridPointCount); - this.nodeCount = (int)Math.Pow(2, clut.InputChannelCount); - } + Guard.NotNull(clut, nameof(clut)); + + this.inputCount = clut.InputChannelCount; + this.outputCount = clut.OutputChannelCount; + this.lut = clut.Values; + this.gridPointCount = clut.GridPointCount; + this.indexFactor = CalculateIndexFactor(clut.InputChannelCount, clut.GridPointCount); + this.nodeCount = (int)Math.Pow(2, clut.InputChannelCount); + } - public unsafe Vector4 Calculate(Vector4 value) - { - value = Vector4.Clamp(value, Vector4.Zero, Vector4.One); + public unsafe Vector4 Calculate(Vector4 value) + { + value = Vector4.Clamp(value, Vector4.Zero, Vector4.One); - Vector4 result = default; - this.Interpolate((float*)&value, this.inputCount, (float*)&result, this.outputCount); + Vector4 result = default; + this.Interpolate((float*)&value, this.inputCount, (float*)&result, this.outputCount); - return result; + return result; + } + + private static int[] CalculateIndexFactor(int inputCount, byte[] gridPointCount) + { + int[] factors = new int[inputCount]; + int gpc = 1; + for (int j = inputCount - 1; j >= 0; j--) + { + factors[j] = gpc * (gridPointCount[j] - 1); + gpc *= gridPointCount[j]; } - private int[] CalculateIndexFactor(int inputCount, byte[] gridPointCount) + return factors; + } + + private unsafe void Interpolate(float* values, int valueLength, float* result, int resultLength) + { + float[][] nodes = new float[this.nodeCount][]; + for (int i = 0; i < nodes.Length; i++) { - int[] factors = new int[inputCount]; - int gpc = 1; - for (int j = inputCount - 1; j >= 0; j--) + int index = 0; + for (int j = 0; j < valueLength; j++) { - factors[j] = gpc * (gridPointCount[j] - 1); - gpc *= gridPointCount[j]; + float fraction = 1f / (this.gridPointCount[j] - 1); + int position = (int)(values[j] / fraction) + ((i >> j) & 1); + index += (int)((this.indexFactor[j] * (position * fraction)) + 0.5f); } - return factors; + nodes[i] = this.lut[index]; } - private unsafe void Interpolate(float* values, int valueLength, float* result, int resultLength) + Span factors = stackalloc float[this.nodeCount]; + for (int i = 0; i < factors.Length; i++) { - float[][] nodes = new float[this.nodeCount][]; - for (int i = 0; i < nodes.Length; i++) + float factor = 1; + for (int j = 0; j < valueLength; j++) { - int index = 0; - for (int j = 0; j < valueLength; j++) - { - float fraction = 1f / (this.gridPointCount[j] - 1); - int position = (int)(values[j] / fraction) + ((i >> j) & 1); - index += (int)((this.indexFactor[j] * (position * fraction)) + 0.5f); - } + float fraction = 1f / (this.gridPointCount[j] - 1); + int position = (int)(values[j] / fraction); - nodes[i] = this.lut[index]; - } + float low = position * fraction; + float high = (position + 1) * fraction; + float percentage = (high - values[j]) / (high - low); - Span factors = stackalloc float[this.nodeCount]; - for (int i = 0; i < factors.Length; i++) - { - float factor = 1; - for (int j = 0; j < valueLength; j++) + if (((i >> j) & 1) == 1) { - float fraction = 1f / (this.gridPointCount[j] - 1); - int position = (int)(values[j] / fraction); - - float low = position * fraction; - float high = (position + 1) * fraction; - float percentage = (high - values[j]) / (high - low); - - if (((i >> j) & 1) == 1) - { - factor *= percentage; - } - else - { - factor *= 1 - percentage; - } + factor *= percentage; + } + else + { + factor *= 1 - percentage; } - - factors[i] = factor; } - for (int i = 0; i < resultLength; i++) + factors[i] = factor; + } + + for (int i = 0; i < resultLength; i++) + { + for (int j = 0; j < nodes.Length; j++) { - for (int j = 0; j < nodes.Length; j++) - { - result[i] += nodes[j][i] * factors[j]; - } + result[i] += nodes[j][i] * factors[j]; } } } diff --git a/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/ColorTrcCalculator.cs b/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/ColorTrcCalculator.cs index 1eacaf3feb..eb6d06b5d0 100644 --- a/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/ColorTrcCalculator.cs +++ b/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/ColorTrcCalculator.cs @@ -1,54 +1,53 @@ // Copyright (c) Six Labors. -// Licensed under the Apache License, Version 2.0. +// Licensed under the Six Labors Split License. using System.Numerics; using System.Runtime.CompilerServices; using SixLabors.ImageSharp.Metadata.Profiles.Icc; -namespace SixLabors.ImageSharp.ColorSpaces.Conversion.Icc +namespace SixLabors.ImageSharp.ColorSpaces.Conversion.Icc; + +internal class ColorTrcCalculator : IVector4Calculator { - internal class ColorTrcCalculator : IVector4Calculator - { - private TrcCalculator curveCalculator; - private Matrix4x4 matrix; - private bool toPcs; + private TrcCalculator curveCalculator; + private Matrix4x4 matrix; + private bool toPcs; - public ColorTrcCalculator( - IccXyzTagDataEntry redMatrixColumn, - IccXyzTagDataEntry greenMatrixColumn, - IccXyzTagDataEntry blueMatrixColumn, - IccTagDataEntry redTrc, - IccTagDataEntry greenTrc, - IccTagDataEntry blueTrc, - bool toPcs) - { - this.toPcs = toPcs; - this.curveCalculator = new TrcCalculator(new IccTagDataEntry[] { redTrc, greenTrc, blueTrc }, !toPcs); + public ColorTrcCalculator( + IccXyzTagDataEntry redMatrixColumn, + IccXyzTagDataEntry greenMatrixColumn, + IccXyzTagDataEntry blueMatrixColumn, + IccTagDataEntry redTrc, + IccTagDataEntry greenTrc, + IccTagDataEntry blueTrc, + bool toPcs) + { + this.toPcs = toPcs; + this.curveCalculator = new TrcCalculator(new IccTagDataEntry[] { redTrc, greenTrc, blueTrc }, !toPcs); - Vector3 mr = redMatrixColumn.Data[0]; - Vector3 mg = greenMatrixColumn.Data[0]; - Vector3 mb = blueMatrixColumn.Data[0]; - this.matrix = new Matrix4x4(mr.X, mr.Y, mr.Z, 0, mg.X, mg.Y, mg.Z, 0, mb.X, mb.Y, mb.Z, 0, 0, 0, 0, 1); + Vector3 mr = redMatrixColumn.Data[0]; + Vector3 mg = greenMatrixColumn.Data[0]; + Vector3 mb = blueMatrixColumn.Data[0]; + this.matrix = new Matrix4x4(mr.X, mr.Y, mr.Z, 0, mg.X, mg.Y, mg.Z, 0, mb.X, mb.Y, mb.Z, 0, 0, 0, 0, 1); - if (!toPcs) - { - Matrix4x4.Invert(this.matrix, out this.matrix); - } + if (!toPcs) + { + Matrix4x4.Invert(this.matrix, out this.matrix); } + } - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public Vector4 Calculate(Vector4 value) + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public Vector4 Calculate(Vector4 value) + { + if (this.toPcs) + { + value = this.curveCalculator.Calculate(value); + return Vector4.Transform(value, this.matrix); + } + else { - if (this.toPcs) - { - value = this.curveCalculator.Calculate(value); - return Vector4.Transform(value, this.matrix); - } - else - { - value = Vector4.Transform(value, this.matrix); - return this.curveCalculator.Calculate(value); - } + value = Vector4.Transform(value, this.matrix); + return this.curveCalculator.Calculate(value); } } } diff --git a/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/CurveCalculator.CalculationType.cs b/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/CurveCalculator.CalculationType.cs index 1d892a1863..187b17866b 100644 --- a/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/CurveCalculator.CalculationType.cs +++ b/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/CurveCalculator.CalculationType.cs @@ -1,5 +1,5 @@ // Copyright (c) Six Labors. -// Licensed under the Apache License, Version 2.0. +// Licensed under the Six Labors Split License. namespace SixLabors.ImageSharp.ColorSpaces.Conversion.Icc { diff --git a/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/CurveCalculator.cs b/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/CurveCalculator.cs index ea8c014368..976ff2a85b 100644 --- a/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/CurveCalculator.cs +++ b/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/CurveCalculator.cs @@ -1,5 +1,5 @@ // Copyright (c) Six Labors. -// Licensed under the Apache License, Version 2.0. +// Licensed under the Six Labors Split License. using System; using SixLabors.ImageSharp.Metadata.Profiles.Icc; diff --git a/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/GrayTrcCalculator.cs b/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/GrayTrcCalculator.cs index 01dae3ecba..af1e24e20c 100644 --- a/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/GrayTrcCalculator.cs +++ b/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/GrayTrcCalculator.cs @@ -1,5 +1,5 @@ // Copyright (c) Six Labors. -// Licensed under the Apache License, Version 2.0. +// Licensed under the Six Labors Split License. using System.Numerics; using System.Runtime.CompilerServices; diff --git a/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/ISingleCalculator.cs b/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/ISingleCalculator.cs index 923da13bd8..570415a697 100644 --- a/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/ISingleCalculator.cs +++ b/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/ISingleCalculator.cs @@ -1,5 +1,5 @@ // Copyright (c) Six Labors. -// Licensed under the Apache License, Version 2.0. +// Licensed under the Six Labors Split License. namespace SixLabors.ImageSharp.ColorSpaces.Conversion.Icc { diff --git a/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/IVector4Calculator.cs b/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/IVector4Calculator.cs index e931c38d81..cf30c634c5 100644 --- a/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/IVector4Calculator.cs +++ b/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/IVector4Calculator.cs @@ -1,5 +1,5 @@ -// Copyright (c) Six Labors. -// Licensed under the Apache License, Version 2.0. +// Copyright (c) Six Labors. +// Licensed under the Six Labors Split License. using System.Numerics; diff --git a/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/LutABCalculator.CalculationType.cs b/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/LutABCalculator.CalculationType.cs index 5f613270ad..a2a060eb9f 100644 --- a/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/LutABCalculator.CalculationType.cs +++ b/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/LutABCalculator.CalculationType.cs @@ -1,5 +1,5 @@ // Copyright (c) Six Labors. -// Licensed under the Apache License, Version 2.0. +// Licensed under the Six Labors Split License. namespace SixLabors.ImageSharp.ColorSpaces.Conversion.Icc { diff --git a/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/LutABCalculator.cs b/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/LutABCalculator.cs index d203a65989..0a7c774a18 100644 --- a/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/LutABCalculator.cs +++ b/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/LutABCalculator.cs @@ -1,5 +1,5 @@ // Copyright (c) Six Labors. -// Licensed under the Apache License, Version 2.0. +// Licensed under the Six Labors Split License. using System; using System.Numerics; diff --git a/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/LutCalculator.cs b/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/LutCalculator.cs index 10b5023aaf..3e5717b1ff 100644 --- a/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/LutCalculator.cs +++ b/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/LutCalculator.cs @@ -1,5 +1,5 @@ // Copyright (c) Six Labors. -// Licensed under the Apache License, Version 2.0. +// Licensed under the Six Labors Split License. using System; using System.Runtime.CompilerServices; diff --git a/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/LutEntryCalculator.cs b/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/LutEntryCalculator.cs index a2cc7c6645..6005990cdf 100644 --- a/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/LutEntryCalculator.cs +++ b/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/LutEntryCalculator.cs @@ -1,5 +1,5 @@ // Copyright (c) Six Labors. -// Licensed under the Apache License, Version 2.0. +// Licensed under the Six Labors Split License. using System.Numerics; using SixLabors.ImageSharp.Metadata.Profiles.Icc; @@ -53,17 +53,17 @@ private unsafe Vector4 CalculateLut(LutCalculator[] lut, Vector4 value) private void Init(IccLut[] inputCurve, IccLut[] outputCurve, IccClut clut, Matrix4x4 matrix) { - this.inputCurve = this.InitLut(inputCurve); - this.outputCurve = this.InitLut(outputCurve); + this.inputCurve = InitLut(inputCurve); + this.outputCurve = InitLut(outputCurve); this.clutCalculator = new ClutCalculator(clut); this.matrix = matrix; this.doTransform = !matrix.IsIdentity && inputCurve.Length == 3; } - private LutCalculator[] InitLut(IccLut[] curves) + private static LutCalculator[] InitLut(IccLut[] curves) { - var calculators = new LutCalculator[curves.Length]; + LutCalculator[] calculators = new LutCalculator[curves.Length]; for (int i = 0; i < curves.Length; i++) { calculators[i] = new LutCalculator(curves[i].Values, false); diff --git a/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/MatrixCalculator.cs b/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/MatrixCalculator.cs index a672347cc9..570e02b819 100644 --- a/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/MatrixCalculator.cs +++ b/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/MatrixCalculator.cs @@ -1,5 +1,5 @@ // Copyright (c) Six Labors. -// Licensed under the Apache License, Version 2.0. +// Licensed under the Six Labors Split License. using System.Numerics; using System.Runtime.CompilerServices; diff --git a/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/ParametricCurveCalculator.cs b/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/ParametricCurveCalculator.cs index a53b32477d..53d783bb4c 100644 --- a/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/ParametricCurveCalculator.cs +++ b/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/ParametricCurveCalculator.cs @@ -1,5 +1,5 @@ // Copyright (c) Six Labors. -// Licensed under the Apache License, Version 2.0. +// Licensed under the Six Labors Split License. using System; using System.Runtime.CompilerServices; diff --git a/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/TrcCalculator.cs b/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/TrcCalculator.cs index 2eacf8f3e5..0a8042aa65 100644 --- a/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/TrcCalculator.cs +++ b/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/TrcCalculator.cs @@ -1,5 +1,5 @@ // Copyright (c) Six Labors. -// Licensed under the Apache License, Version 2.0. +// Licensed under the Six Labors Split License. using System.Numerics; using SixLabors.ImageSharp.Metadata.Profiles.Icc; diff --git a/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/IccConverterBase.Checks.cs b/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/IccConverterBase.Checks.cs index 42f6e45802..fac56c3b5d 100644 --- a/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/IccConverterBase.Checks.cs +++ b/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/IccConverterBase.Checks.cs @@ -1,173 +1,165 @@ // Copyright (c) Six Labors. -// Licensed under the Apache License, Version 2.0. +// Licensed under the Six Labors Split License. -using System.Linq; using SixLabors.ImageSharp.Metadata.Profiles.Icc; -namespace SixLabors.ImageSharp.ColorSpaces.Conversion.Icc +namespace SixLabors.ImageSharp.ColorSpaces.Conversion.Icc; + +/// +/// Color converter for ICC profiles +/// +internal abstract partial class IccConverterBase { - /// - /// Color converter for ICC profiles - /// - internal abstract partial class IccConverterBase + private static ConversionMethod GetConversionMethod(IccProfile profile, IccRenderingIntent renderingIntent) { - private ConversionMethod GetConversionMethod(IccProfile profile, IccRenderingIntent renderingIntent) + switch (profile.Header.Class) { - switch (profile.Header.Class) - { - case IccProfileClass.InputDevice: - case IccProfileClass.DisplayDevice: - case IccProfileClass.OutputDevice: - case IccProfileClass.ColorSpace: - return this.CheckMethod1(profile, renderingIntent); + case IccProfileClass.InputDevice: + case IccProfileClass.DisplayDevice: + case IccProfileClass.OutputDevice: + case IccProfileClass.ColorSpace: + return CheckMethod1(profile, renderingIntent); + + case IccProfileClass.DeviceLink: + case IccProfileClass.Abstract: + return CheckMethod2(profile); + + default: + return ConversionMethod.Invalid; + } + } - case IccProfileClass.DeviceLink: - case IccProfileClass.Abstract: - return this.CheckMethod2(profile); + private static ConversionMethod CheckMethod1(IccProfile profile, IccRenderingIntent renderingIntent) + { + ConversionMethod method = ConversionMethod.Invalid; - default: - return ConversionMethod.Invalid; - } + method = CheckMethodD(profile, renderingIntent); + if (method != ConversionMethod.Invalid) + { + return method; } - private ConversionMethod CheckMethod1(IccProfile profile, IccRenderingIntent renderingIntent) + method = CheckMethodA(profile, renderingIntent); + if (method != ConversionMethod.Invalid) { - ConversionMethod method = ConversionMethod.Invalid; - - method = this.CheckMethodD(profile, renderingIntent); - if (method != ConversionMethod.Invalid) - { - return method; - } - - method = this.CheckMethodA(profile, renderingIntent); - if (method != ConversionMethod.Invalid) - { - return method; - } - - method = this.CheckMethodA0(profile); - if (method != ConversionMethod.Invalid) - { - return method; - } - - method = this.CheckMethodTrc(profile); - if (method != ConversionMethod.Invalid) - { - return method; - } - - return ConversionMethod.Invalid; + return method; } - private ConversionMethod CheckMethodD(IccProfile profile, IccRenderingIntent renderingIntent) + method = CheckMethodA0(profile); + if (method != ConversionMethod.Invalid) { - if ((this.HasTag(profile, IccProfileTag.DToB0) || this.HasTag(profile, IccProfileTag.BToD0)) - && renderingIntent == IccRenderingIntent.Perceptual) - { - return ConversionMethod.D0; - } + return method; + } - if ((this.HasTag(profile, IccProfileTag.DToB1) || this.HasTag(profile, IccProfileTag.BToD1)) - && renderingIntent == IccRenderingIntent.MediaRelativeColorimetric) - { - return ConversionMethod.D1; - } + method = CheckMethodTrc(profile); + if (method != ConversionMethod.Invalid) + { + return method; + } - if ((this.HasTag(profile, IccProfileTag.DToB2) || this.HasTag(profile, IccProfileTag.BToD2)) - && renderingIntent == IccRenderingIntent.Saturation) - { - return ConversionMethod.D2; - } + return ConversionMethod.Invalid; + } - if ((this.HasTag(profile, IccProfileTag.DToB3) || this.HasTag(profile, IccProfileTag.BToD3)) - && renderingIntent == IccRenderingIntent.AbsoluteColorimetric) - { - return ConversionMethod.D3; - } + private static ConversionMethod CheckMethodD(IccProfile profile, IccRenderingIntent renderingIntent) + { + if ((HasTag(profile, IccProfileTag.DToB0) || HasTag(profile, IccProfileTag.BToD0)) + && renderingIntent == IccRenderingIntent.Perceptual) + { + return ConversionMethod.D0; + } - return ConversionMethod.Invalid; + if ((HasTag(profile, IccProfileTag.DToB1) || HasTag(profile, IccProfileTag.BToD1)) + && renderingIntent == IccRenderingIntent.MediaRelativeColorimetric) + { + return ConversionMethod.D1; } - private ConversionMethod CheckMethodA(IccProfile profile, IccRenderingIntent renderingIntent) + if ((HasTag(profile, IccProfileTag.DToB2) || HasTag(profile, IccProfileTag.BToD2)) + && renderingIntent == IccRenderingIntent.Saturation) { - if ((this.HasTag(profile, IccProfileTag.AToB0) || this.HasTag(profile, IccProfileTag.BToA0)) - && renderingIntent == IccRenderingIntent.Perceptual) - { - return ConversionMethod.A0; - } + return ConversionMethod.D2; + } - if ((this.HasTag(profile, IccProfileTag.AToB1) || this.HasTag(profile, IccProfileTag.BToA1)) - && renderingIntent == IccRenderingIntent.MediaRelativeColorimetric) - { - return ConversionMethod.A1; - } + if ((HasTag(profile, IccProfileTag.DToB3) || HasTag(profile, IccProfileTag.BToD3)) + && renderingIntent == IccRenderingIntent.AbsoluteColorimetric) + { + return ConversionMethod.D3; + } - if ((this.HasTag(profile, IccProfileTag.AToB2) || this.HasTag(profile, IccProfileTag.BToA2)) - && renderingIntent == IccRenderingIntent.Saturation) - { - return ConversionMethod.A2; - } + return ConversionMethod.Invalid; + } - return ConversionMethod.Invalid; + private static ConversionMethod CheckMethodA(IccProfile profile, IccRenderingIntent renderingIntent) + { + if ((HasTag(profile, IccProfileTag.AToB0) || HasTag(profile, IccProfileTag.BToA0)) + && renderingIntent == IccRenderingIntent.Perceptual) + { + return ConversionMethod.A0; } - private ConversionMethod CheckMethodA0(IccProfile profile) + if ((HasTag(profile, IccProfileTag.AToB1) || HasTag(profile, IccProfileTag.BToA1)) + && renderingIntent == IccRenderingIntent.MediaRelativeColorimetric) { - bool valid = this.HasTag(profile, IccProfileTag.AToB0) || this.HasTag(profile, IccProfileTag.BToA0); - return valid ? ConversionMethod.A0 : ConversionMethod.Invalid; + return ConversionMethod.A1; } - private ConversionMethod CheckMethodTrc(IccProfile profile) + if ((HasTag(profile, IccProfileTag.AToB2) || HasTag(profile, IccProfileTag.BToA2)) + && renderingIntent == IccRenderingIntent.Saturation) { - if (this.HasTag(profile, IccProfileTag.RedMatrixColumn) - && this.HasTag(profile, IccProfileTag.GreenMatrixColumn) - && this.HasTag(profile, IccProfileTag.BlueMatrixColumn) - && this.HasTag(profile, IccProfileTag.RedTrc) - && this.HasTag(profile, IccProfileTag.GreenTrc) - && this.HasTag(profile, IccProfileTag.BlueTrc)) - { - return ConversionMethod.ColorTrc; - } - - if (this.HasTag(profile, IccProfileTag.GrayTrc)) - { - return ConversionMethod.GrayTrc; - } - - return ConversionMethod.Invalid; + return ConversionMethod.A2; } - private ConversionMethod CheckMethod2(IccProfile profile) - { - if (this.HasTag(profile, IccProfileTag.DToB0) || this.HasTag(profile, IccProfileTag.BToD0)) - { - return ConversionMethod.D0; - } + return ConversionMethod.Invalid; + } - if (this.HasTag(profile, IccProfileTag.AToB0) || this.HasTag(profile, IccProfileTag.AToB0)) - { - return ConversionMethod.A0; - } + private static ConversionMethod CheckMethodA0(IccProfile profile) + { + bool valid = HasTag(profile, IccProfileTag.AToB0) || HasTag(profile, IccProfileTag.BToA0); + return valid ? ConversionMethod.A0 : ConversionMethod.Invalid; + } - return ConversionMethod.Invalid; + private static ConversionMethod CheckMethodTrc(IccProfile profile) + { + if (HasTag(profile, IccProfileTag.RedMatrixColumn) + && HasTag(profile, IccProfileTag.GreenMatrixColumn) + && HasTag(profile, IccProfileTag.BlueMatrixColumn) + && HasTag(profile, IccProfileTag.RedTrc) + && HasTag(profile, IccProfileTag.GreenTrc) + && HasTag(profile, IccProfileTag.BlueTrc)) + { + return ConversionMethod.ColorTrc; } - private bool HasTag(IccProfile profile, IccProfileTag tag) + if (HasTag(profile, IccProfileTag.GrayTrc)) { - return profile.Entries.Any(t => t.TagSignature == tag); + return ConversionMethod.GrayTrc; } - private IccTagDataEntry GetTag(IccProfile profile, IccProfileTag tag) + return ConversionMethod.Invalid; + } + + private static ConversionMethod CheckMethod2(IccProfile profile) + { + if (HasTag(profile, IccProfileTag.DToB0) || HasTag(profile, IccProfileTag.BToD0)) { - return profile.Entries.FirstOrDefault(t => t.TagSignature == tag); + return ConversionMethod.D0; } - private T GetTag(IccProfile profile, IccProfileTag tag) - where T : IccTagDataEntry + if (HasTag(profile, IccProfileTag.AToB0) || HasTag(profile, IccProfileTag.AToB0)) { - return profile.Entries.OfType().FirstOrDefault(t => t.TagSignature == tag); + return ConversionMethod.A0; } + + return ConversionMethod.Invalid; } + + private static bool HasTag(IccProfile profile, IccProfileTag tag) + => profile.Entries.Any(t => t.TagSignature == tag); + + private static IccTagDataEntry GetTag(IccProfile profile, IccProfileTag tag) + => profile.Entries.FirstOrDefault(t => t.TagSignature == tag); + + private static T GetTag(IccProfile profile, IccProfileTag tag) + where T : IccTagDataEntry + => profile.Entries.OfType().FirstOrDefault(t => t.TagSignature == tag); } diff --git a/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/IccConverterBase.ConversionMethod.cs b/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/IccConverterBase.ConversionMethod.cs index 727dd1a682..4a74434cc7 100644 --- a/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/IccConverterBase.ConversionMethod.cs +++ b/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/IccConverterBase.ConversionMethod.cs @@ -1,5 +1,5 @@ // Copyright (c) Six Labors. -// Licensed under the Apache License, Version 2.0. +// Licensed under the Six Labors Split License. namespace SixLabors.ImageSharp.ColorSpaces.Conversion.Icc { diff --git a/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/IccConverterbase.Conversions.cs b/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/IccConverterbase.Conversions.cs index 5391f13049..6e4c58e180 100644 --- a/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/IccConverterbase.Conversions.cs +++ b/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/IccConverterbase.Conversions.cs @@ -1,5 +1,5 @@ // Copyright (c) Six Labors. -// Licensed under the Apache License, Version 2.0. +// Licensed under the Six Labors Split License. using System; using SixLabors.ImageSharp.ColorSpaces.Conversion.Icc; @@ -22,57 +22,57 @@ internal abstract partial class IccConverterBase /// The wanted rendering intent. Can be ignored if not available protected void Init(IccProfile profile, bool toPcs, IccRenderingIntent renderingIntent) { - ConversionMethod method = this.GetConversionMethod(profile, renderingIntent); + ConversionMethod method = GetConversionMethod(profile, renderingIntent); switch (method) { case ConversionMethod.D0: this.calculator = toPcs ? - this.InitD(profile, IccProfileTag.DToB0) : - this.InitD(profile, IccProfileTag.BToD0); + InitD(profile, IccProfileTag.DToB0) : + InitD(profile, IccProfileTag.BToD0); break; case ConversionMethod.D1: this.calculator = toPcs ? - this.InitD(profile, IccProfileTag.DToB1) : - this.InitD(profile, IccProfileTag.BToD1); + InitD(profile, IccProfileTag.DToB1) : + InitD(profile, IccProfileTag.BToD1); break; case ConversionMethod.D2: this.calculator = toPcs ? - this.InitD(profile, IccProfileTag.DToB2) : - this.InitD(profile, IccProfileTag.BToD2); + InitD(profile, IccProfileTag.DToB2) : + InitD(profile, IccProfileTag.BToD2); break; case ConversionMethod.D3: this.calculator = toPcs ? - this.InitD(profile, IccProfileTag.DToB3) : - this.InitD(profile, IccProfileTag.BToD3); + InitD(profile, IccProfileTag.DToB3) : + InitD(profile, IccProfileTag.BToD3); break; case ConversionMethod.A0: this.calculator = toPcs ? - this.InitA(profile, IccProfileTag.AToB0) : - this.InitA(profile, IccProfileTag.BToA0); + InitA(profile, IccProfileTag.AToB0) : + InitA(profile, IccProfileTag.BToA0); break; case ConversionMethod.A1: this.calculator = toPcs ? - this.InitA(profile, IccProfileTag.AToB1) : - this.InitA(profile, IccProfileTag.BToA1); + InitA(profile, IccProfileTag.AToB1) : + InitA(profile, IccProfileTag.BToA1); break; case ConversionMethod.A2: this.calculator = toPcs ? - this.InitA(profile, IccProfileTag.AToB2) : - this.InitA(profile, IccProfileTag.BToA2); + InitA(profile, IccProfileTag.AToB2) : + InitA(profile, IccProfileTag.BToA2); break; case ConversionMethod.ColorTrc: - this.calculator = this.InitColorTrc(profile, toPcs); + this.calculator = InitColorTrc(profile, toPcs); break; case ConversionMethod.GrayTrc: - this.calculator = this.InitGrayTrc(profile, toPcs); + this.calculator = InitGrayTrc(profile, toPcs); break; case ConversionMethod.Invalid: @@ -81,9 +81,9 @@ protected void Init(IccProfile profile, bool toPcs, IccRenderingIntent rendering } } - private IVector4Calculator InitA(IccProfile profile, IccProfileTag tag) + private static IVector4Calculator InitA(IccProfile profile, IccProfileTag tag) { - IccTagDataEntry entry = this.GetTag(profile, tag); + IccTagDataEntry entry = GetTag(profile, tag); switch (entry) { case IccLut8TagDataEntry lut8: @@ -100,9 +100,9 @@ private IVector4Calculator InitA(IccProfile profile, IccProfileTag tag) } } - private IVector4Calculator InitD(IccProfile profile, IccProfileTag tag) + private static IVector4Calculator InitD(IccProfile profile, IccProfileTag tag) { - IccMultiProcessElementsTagDataEntry entry = this.GetTag(profile, tag); + IccMultiProcessElementsTagDataEntry entry = GetTag(profile, tag); if (entry == null) { throw new InvalidIccProfileException("Entry is null."); @@ -111,15 +111,15 @@ private IVector4Calculator InitD(IccProfile profile, IccProfileTag tag) throw new NotImplementedException("Multi process elements are not supported"); } - private IVector4Calculator InitColorTrc(IccProfile profile, bool toPcs) + private static IVector4Calculator InitColorTrc(IccProfile profile, bool toPcs) { - IccXyzTagDataEntry redMatrixColumn = this.GetTag(profile, IccProfileTag.RedMatrixColumn); - IccXyzTagDataEntry greenMatrixColumn = this.GetTag(profile, IccProfileTag.GreenMatrixColumn); - IccXyzTagDataEntry blueMatrixColumn = this.GetTag(profile, IccProfileTag.BlueMatrixColumn); + IccXyzTagDataEntry redMatrixColumn = GetTag(profile, IccProfileTag.RedMatrixColumn); + IccXyzTagDataEntry greenMatrixColumn = GetTag(profile, IccProfileTag.GreenMatrixColumn); + IccXyzTagDataEntry blueMatrixColumn = GetTag(profile, IccProfileTag.BlueMatrixColumn); - IccTagDataEntry redTrc = this.GetTag(profile, IccProfileTag.RedTrc); - IccTagDataEntry greenTrc = this.GetTag(profile, IccProfileTag.GreenTrc); - IccTagDataEntry blueTrc = this.GetTag(profile, IccProfileTag.BlueTrc); + IccTagDataEntry redTrc = GetTag(profile, IccProfileTag.RedTrc); + IccTagDataEntry greenTrc = GetTag(profile, IccProfileTag.GreenTrc); + IccTagDataEntry blueTrc = GetTag(profile, IccProfileTag.BlueTrc); if (redMatrixColumn == null || greenMatrixColumn == null || @@ -141,9 +141,9 @@ private IVector4Calculator InitColorTrc(IccProfile profile, bool toPcs) toPcs); } - private IVector4Calculator InitGrayTrc(IccProfile profile, bool toPcs) + private static IVector4Calculator InitGrayTrc(IccProfile profile, bool toPcs) { - IccTagDataEntry entry = this.GetTag(profile, IccProfileTag.GrayTrc); + IccTagDataEntry entry = GetTag(profile, IccProfileTag.GrayTrc); return new GrayTrcCalculator(entry, toPcs); } } diff --git a/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/IccConverterbase.cs b/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/IccConverterbase.cs index 53605fb045..d0e147c19b 100644 --- a/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/IccConverterbase.cs +++ b/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/IccConverterbase.cs @@ -1,5 +1,5 @@ // Copyright (c) Six Labors. -// Licensed under the Apache License, Version 2.0. +// Licensed under the Six Labors Split License. using System.Numerics; using System.Runtime.CompilerServices; diff --git a/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/IccDataToDataConverter.cs b/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/IccDataToDataConverter.cs index 2a911068f5..dccba51ccc 100644 --- a/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/IccDataToDataConverter.cs +++ b/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/IccDataToDataConverter.cs @@ -1,5 +1,5 @@ // Copyright (c) Six Labors. -// Licensed under the Apache License, Version 2.0. +// Licensed under the Six Labors Split License. using SixLabors.ImageSharp.Metadata.Profiles.Icc; diff --git a/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/IccDataToPcsConverter.cs b/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/IccDataToPcsConverter.cs index ae274936b2..6cec8695f6 100644 --- a/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/IccDataToPcsConverter.cs +++ b/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/IccDataToPcsConverter.cs @@ -1,5 +1,5 @@ // Copyright (c) Six Labors. -// Licensed under the Apache License, Version 2.0. +// Licensed under the Six Labors Split License. using SixLabors.ImageSharp.Metadata.Profiles.Icc; diff --git a/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/IccPcsToDataConverter.cs b/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/IccPcsToDataConverter.cs index c61642635b..5647c465cc 100644 --- a/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/IccPcsToDataConverter.cs +++ b/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/IccPcsToDataConverter.cs @@ -1,5 +1,5 @@ // Copyright (c) Six Labors. -// Licensed under the Apache License, Version 2.0. +// Licensed under the Six Labors Split License. using SixLabors.ImageSharp.Metadata.Profiles.Icc; diff --git a/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/IccPcsToPcsConverter.cs b/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/IccPcsToPcsConverter.cs index 8cbeeff70d..a40a81d5d2 100644 --- a/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/IccPcsToPcsConverter.cs +++ b/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/IccPcsToPcsConverter.cs @@ -1,5 +1,5 @@ // Copyright (c) Six Labors. -// Licensed under the Apache License, Version 2.0. +// Licensed under the Six Labors Split License. using SixLabors.ImageSharp.Metadata.Profiles.Icc; diff --git a/tests/ImageSharp.Tests/Colorspaces/Icc/Calculators/ClutCalculatorTests.cs b/tests/ImageSharp.Tests/Colorspaces/Icc/Calculators/ClutCalculatorTests.cs index 8a0b4b2b0a..9ca24f8b1d 100644 --- a/tests/ImageSharp.Tests/Colorspaces/Icc/Calculators/ClutCalculatorTests.cs +++ b/tests/ImageSharp.Tests/Colorspaces/Icc/Calculators/ClutCalculatorTests.cs @@ -1,29 +1,27 @@ // Copyright (c) Six Labors. -// Licensed under the Apache License, Version 2.0. +// Licensed under the Six Labors Split License. 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 +namespace SixLabors.ImageSharp.Tests.Colorspaces.Icc.Calculators; + +/// +/// Tests ICC +/// +[Trait("Color", "Conversion")] +public class ClutCalculatorTests { - /// - /// Tests ICC - /// - [Trait("Color", "Conversion")] - public class ClutCalculatorTests + [Theory] + [MemberData(nameof(IccConversionDataClut.ClutConversionTestData), MemberType = typeof(IccConversionDataClut))] + internal void ClutCalculator_WithClut_ReturnsResult(IccClut lut, Vector4 input, Vector4 expected) { - [Theory] - [MemberData(nameof(IccConversionDataClut.ClutConversionTestData), MemberType = typeof(IccConversionDataClut))] - internal void ClutCalculator_WithClut_ReturnsResult(IccClut lut, Vector4 input, Vector4 expected) - { - var calculator = new ClutCalculator(lut); + ClutCalculator calculator = new(lut); - Vector4 result = calculator.Calculate(input); + Vector4 result = calculator.Calculate(input); - VectorAssert.Equal(expected, result, 4); - } + VectorAssert.Equal(expected, result, 4); } } From dcc8147977f1337b06e231314d915f10df58a5ff Mon Sep 17 00:00:00 2001 From: Brian Popow Date: Thu, 24 Nov 2022 20:51:19 +0100 Subject: [PATCH 06/42] Cleanup icc tests --- .../Formats/Jpg/JpegEncoderTests.Metadata.cs | 2 +- .../DataReader/IccDataReaderMatrixTests.cs | 4 +- .../IccDataReaderTagDataEntryTests.cs | 2 +- .../DataWriter/IccDataWriterMatrixTests.cs | 10 +- .../IccDataWriterTagDataEntryTests.cs | 2 +- .../Metadata/Profiles/ICC/IccProfileTests.cs | 2 +- .../Metadata/Profiles/ICC/IccReaderTests.cs | 15 +- .../Metadata/Profiles/ICC/IccWriterTests.cs | 17 +- .../TestDataIcc/IccTestDataArray.cs | 132 ++-- .../TestDataIcc/IccTestDataCurves.cs | 310 ++++---- .../TestDataIcc/IccTestDataLut.cs | 194 ++--- .../TestDataIcc/IccTestDataMatrix.cs | 130 +-- .../IccTestDataMultiProcessElements.cs | 74 +- .../TestDataIcc/IccTestDataNonPrimitives.cs | 327 ++++---- .../TestDataIcc/IccTestDataPrimitives.cs | 398 +++++----- .../TestDataIcc/IccTestDataProfiles.cs | 110 ++- .../TestDataIcc/IccTestDataTagDataEntry.cs | 740 +++++++++--------- 17 files changed, 1214 insertions(+), 1255 deletions(-) diff --git a/tests/ImageSharp.Tests/Formats/Jpg/JpegEncoderTests.Metadata.cs b/tests/ImageSharp.Tests/Formats/Jpg/JpegEncoderTests.Metadata.cs index 7e8f13ed3d..404c11e7d7 100644 --- a/tests/ImageSharp.Tests/Formats/Jpg/JpegEncoderTests.Metadata.cs +++ b/tests/ImageSharp.Tests/Formats/Jpg/JpegEncoderTests.Metadata.cs @@ -77,7 +77,7 @@ public void Encode_PreservesIccProfile() { // arrange using var input = new Image(1, 1); - input.Metadata.IccProfile = new IccProfile(IccTestDataProfiles.Profile_Random_Array); + input.Metadata.IccProfile = new IccProfile(IccTestDataProfiles.ProfileRandomArray); // act using var memStream = new MemoryStream(); diff --git a/tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataReader/IccDataReaderMatrixTests.cs b/tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataReader/IccDataReaderMatrixTests.cs index b81395bb2e..86e1b73869 100644 --- a/tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataReader/IccDataReaderMatrixTests.cs +++ b/tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataReader/IccDataReaderMatrixTests.cs @@ -9,7 +9,7 @@ namespace SixLabors.ImageSharp.Tests.Metadata.Profiles.ICC.DataReader; public class IccDataReaderMatrixTests { [Theory] - [MemberData(nameof(IccTestDataMatrix.Matrix2D_FloatArrayTestData), MemberType = typeof(IccTestDataMatrix))] + [MemberData(nameof(IccTestDataMatrix.Matrix2DFloatArrayTestData), MemberType = typeof(IccTestDataMatrix))] public void ReadMatrix2D(byte[] data, int xCount, int yCount, bool isSingle, float[,] expected) { IccDataReader reader = CreateReader(data); @@ -20,7 +20,7 @@ public void ReadMatrix2D(byte[] data, int xCount, int yCount, bool isSingle, flo } [Theory] - [MemberData(nameof(IccTestDataMatrix.Matrix1D_ArrayTestData), MemberType = typeof(IccTestDataMatrix))] + [MemberData(nameof(IccTestDataMatrix.Matrix1DArrayTestData), MemberType = typeof(IccTestDataMatrix))] public void ReadMatrix1D(byte[] data, int yCount, bool isSingle, float[] expected) { IccDataReader reader = CreateReader(data); diff --git a/tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataReader/IccDataReaderTagDataEntryTests.cs b/tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataReader/IccDataReaderTagDataEntryTests.cs index d41707b7ce..07e3e5bfb7 100644 --- a/tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataReader/IccDataReaderTagDataEntryTests.cs +++ b/tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataReader/IccDataReaderTagDataEntryTests.cs @@ -166,7 +166,7 @@ internal void ReadMeasurementTagDataEntry(byte[] data, IccMeasurementTagDataEntr [Theory] [MemberData( - nameof(IccTestDataTagDataEntry.MultiLocalizedUnicodeTagDataEntryTestData_Read), + nameof(IccTestDataTagDataEntry.MultiLocalizedUnicodeTagDataEntryTestDataRead), MemberType = typeof(IccTestDataTagDataEntry))] internal void ReadMultiLocalizedUnicodeTagDataEntry(byte[] data, IccMultiLocalizedUnicodeTagDataEntry expected) { diff --git a/tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataWriter/IccDataWriterMatrixTests.cs b/tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataWriter/IccDataWriterMatrixTests.cs index 7d046aa49b..ac2cc0ff69 100644 --- a/tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataWriter/IccDataWriterMatrixTests.cs +++ b/tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataWriter/IccDataWriterMatrixTests.cs @@ -10,7 +10,7 @@ namespace SixLabors.ImageSharp.Tests.Metadata.Profiles.ICC.DataWriter; public class IccDataWriterMatrixTests { [Theory] - [MemberData(nameof(IccTestDataMatrix.Matrix2D_FloatArrayTestData), MemberType = typeof(IccTestDataMatrix))] + [MemberData(nameof(IccTestDataMatrix.Matrix2DFloatArrayTestData), MemberType = typeof(IccTestDataMatrix))] public void WriteMatrix2D_Array(byte[] expected, int xCount, int yCount, bool isSingle, float[,] data) { using IccDataWriter writer = CreateWriter(); @@ -22,7 +22,7 @@ public void WriteMatrix2D_Array(byte[] expected, int xCount, int yCount, bool is } [Theory] - [MemberData(nameof(IccTestDataMatrix.Matrix2D_Matrix4x4TestData), MemberType = typeof(IccTestDataMatrix))] + [MemberData(nameof(IccTestDataMatrix.Matrix2DMatrix4X4TestData), MemberType = typeof(IccTestDataMatrix))] public void WriteMatrix2D_Matrix4x4(byte[] expected, int xCount, int yCount, bool isSingle, Matrix4x4 data) { using IccDataWriter writer = CreateWriter(); @@ -34,7 +34,7 @@ public void WriteMatrix2D_Matrix4x4(byte[] expected, int xCount, int yCount, boo } [Theory] - [MemberData(nameof(IccTestDataMatrix.Matrix2D_DenseMatrixTestData), MemberType = typeof(IccTestDataMatrix))] + [MemberData(nameof(IccTestDataMatrix.Matrix2DDenseMatrixTestData), MemberType = typeof(IccTestDataMatrix))] internal void WriteMatrix2D_DenseMatrix(byte[] expected, int xCount, int yCount, bool isSingle, in DenseMatrix data) { using IccDataWriter writer = CreateWriter(); @@ -46,7 +46,7 @@ internal void WriteMatrix2D_DenseMatrix(byte[] expected, int xCount, int yCount, } [Theory] - [MemberData(nameof(IccTestDataMatrix.Matrix1D_ArrayTestData), MemberType = typeof(IccTestDataMatrix))] + [MemberData(nameof(IccTestDataMatrix.Matrix1DArrayTestData), MemberType = typeof(IccTestDataMatrix))] public void WriteMatrix1D_Array(byte[] expected, int yCount, bool isSingle, float[] data) { using IccDataWriter writer = CreateWriter(); @@ -58,7 +58,7 @@ public void WriteMatrix1D_Array(byte[] expected, int yCount, bool isSingle, floa } [Theory] - [MemberData(nameof(IccTestDataMatrix.Matrix1D_Vector3TestData), MemberType = typeof(IccTestDataMatrix))] + [MemberData(nameof(IccTestDataMatrix.Matrix1DVector3TestData), MemberType = typeof(IccTestDataMatrix))] public void WriteMatrix1D_Vector3(byte[] expected, int yCount, bool isSingle, Vector3 data) { using IccDataWriter writer = CreateWriter(); diff --git a/tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataWriter/IccDataWriterTagDataEntryTests.cs b/tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataWriter/IccDataWriterTagDataEntryTests.cs index 7eda24c8cf..eb613a6754 100644 --- a/tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataWriter/IccDataWriterTagDataEntryTests.cs +++ b/tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataWriter/IccDataWriterTagDataEntryTests.cs @@ -153,7 +153,7 @@ internal void WriteMeasurementTagDataEntry(byte[] expected, IccMeasurementTagDat } [Theory] - [MemberData(nameof(IccTestDataTagDataEntry.MultiLocalizedUnicodeTagDataEntryTestData_Write), MemberType = typeof(IccTestDataTagDataEntry))] + [MemberData(nameof(IccTestDataTagDataEntry.MultiLocalizedUnicodeTagDataEntryTestDataWrite), MemberType = typeof(IccTestDataTagDataEntry))] internal void WriteMultiLocalizedUnicodeTagDataEntry(byte[] expected, IccMultiLocalizedUnicodeTagDataEntry data) { using IccDataWriter writer = CreateWriter(); diff --git a/tests/ImageSharp.Tests/Metadata/Profiles/ICC/IccProfileTests.cs b/tests/ImageSharp.Tests/Metadata/Profiles/ICC/IccProfileTests.cs index fbbea97fb3..34044d245e 100644 --- a/tests/ImageSharp.Tests/Metadata/Profiles/ICC/IccProfileTests.cs +++ b/tests/ImageSharp.Tests/Metadata/Profiles/ICC/IccProfileTests.cs @@ -20,7 +20,7 @@ public void CalculateHash_WithByteArray_CalculatesProfileHash(byte[] data, IccPr [Fact] public void CalculateHash_WithByteArray_DoesNotModifyData() { - byte[] data = IccTestDataProfiles.Profile_Random_Array; + byte[] data = IccTestDataProfiles.ProfileRandomArray; var copy = new byte[data.Length]; Buffer.BlockCopy(data, 0, copy, 0, data.Length); diff --git a/tests/ImageSharp.Tests/Metadata/Profiles/ICC/IccReaderTests.cs b/tests/ImageSharp.Tests/Metadata/Profiles/ICC/IccReaderTests.cs index 9b2ca2a275..d999871be7 100644 --- a/tests/ImageSharp.Tests/Metadata/Profiles/ICC/IccReaderTests.cs +++ b/tests/ImageSharp.Tests/Metadata/Profiles/ICC/IccReaderTests.cs @@ -11,15 +11,13 @@ public class IccReaderTests [Fact] public void ReadProfile_NoEntries() { - IccReader reader = this.CreateReader(); - - IccProfile output = IccReader.Read(IccTestDataProfiles.Header_Random_Array); + IccProfile output = IccReader.Read(IccTestDataProfiles.HeaderRandomArray); Assert.Equal(0, output.Entries.Length); Assert.NotNull(output.Header); IccProfileHeader header = output.Header; - IccProfileHeader expected = IccTestDataProfiles.Header_Random_Read; + IccProfileHeader expected = IccTestDataProfiles.HeaderRandomRead; Assert.Equal(header.Class, expected.Class); Assert.Equal(header.CmmType, expected.CmmType); Assert.Equal(header.CreationDate, expected.CreationDate); @@ -42,16 +40,9 @@ public void ReadProfile_NoEntries() [Fact] public void ReadProfile_DuplicateEntry() { - IccReader reader = this.CreateReader(); - - IccProfile output = IccReader.Read(IccTestDataProfiles.Profile_Random_Array); + IccProfile output = IccReader.Read(IccTestDataProfiles.ProfileRandomArray); Assert.Equal(2, output.Entries.Length); Assert.True(ReferenceEquals(output.Entries[0], output.Entries[1])); } - - private IccReader CreateReader() - { - return new IccReader(); - } } diff --git a/tests/ImageSharp.Tests/Metadata/Profiles/ICC/IccWriterTests.cs b/tests/ImageSharp.Tests/Metadata/Profiles/ICC/IccWriterTests.cs index 89b63b7dcc..3aa032bbbd 100644 --- a/tests/ImageSharp.Tests/Metadata/Profiles/ICC/IccWriterTests.cs +++ b/tests/ImageSharp.Tests/Metadata/Profiles/ICC/IccWriterTests.cs @@ -11,29 +11,20 @@ public class IccWriterTests [Fact] public void WriteProfile_NoEntries() { - IccWriter writer = this.CreateWriter(); - var profile = new IccProfile { - Header = IccTestDataProfiles.Header_Random_Write + Header = IccTestDataProfiles.HeaderRandomWrite }; byte[] output = IccWriter.Write(profile); - Assert.Equal(IccTestDataProfiles.Header_Random_Array, output); + Assert.Equal(IccTestDataProfiles.HeaderRandomArray, output); } [Fact] public void WriteProfile_DuplicateEntry() { - IccWriter writer = this.CreateWriter(); - - byte[] output = IccWriter.Write(IccTestDataProfiles.Profile_Random_Val); + byte[] output = IccWriter.Write(IccTestDataProfiles.ProfileRandomVal); - Assert.Equal(IccTestDataProfiles.Profile_Random_Array, output); - } - - private IccWriter CreateWriter() - { - return new IccWriter(); + Assert.Equal(IccTestDataProfiles.ProfileRandomArray, output); } } diff --git a/tests/ImageSharp.Tests/TestDataIcc/IccTestDataArray.cs b/tests/ImageSharp.Tests/TestDataIcc/IccTestDataArray.cs index 8288a294dd..9b175c6e17 100644 --- a/tests/ImageSharp.Tests/TestDataIcc/IccTestDataArray.cs +++ b/tests/ImageSharp.Tests/TestDataIcc/IccTestDataArray.cs @@ -12,98 +12,98 @@ internal static class IccTestDataArray new object[] { UInt8, UInt8 } }; - public static readonly ushort[] UInt16_Val = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }; - - public static readonly byte[] UInt16_Arr = ArrayHelper.Concat( - IccTestDataPrimitives.UInt16_0, - IccTestDataPrimitives.UInt16_1, - IccTestDataPrimitives.UInt16_2, - IccTestDataPrimitives.UInt16_3, - IccTestDataPrimitives.UInt16_4, - IccTestDataPrimitives.UInt16_5, - IccTestDataPrimitives.UInt16_6, - IccTestDataPrimitives.UInt16_7, - IccTestDataPrimitives.UInt16_8, - IccTestDataPrimitives.UInt16_9); + public static readonly ushort[] UInt16Val = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }; + + public static readonly byte[] UInt16Arr = ArrayHelper.Concat( + IccTestDataPrimitives.UInt160, + IccTestDataPrimitives.UInt161, + IccTestDataPrimitives.UInt162, + IccTestDataPrimitives.UInt163, + IccTestDataPrimitives.UInt164, + IccTestDataPrimitives.UInt165, + IccTestDataPrimitives.UInt166, + IccTestDataPrimitives.UInt167, + IccTestDataPrimitives.UInt168, + IccTestDataPrimitives.UInt169); public static readonly object[][] UInt16TestData = { - new object[] { UInt16_Arr, UInt16_Val } + new object[] { UInt16Arr, UInt16Val } }; - public static readonly short[] Int16_Val = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }; + public static readonly short[] Int16Val = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }; - public static readonly byte[] Int16_Arr = ArrayHelper.Concat( - IccTestDataPrimitives.Int16_0, - IccTestDataPrimitives.Int16_1, - IccTestDataPrimitives.Int16_2, - IccTestDataPrimitives.Int16_3, - IccTestDataPrimitives.Int16_4, - IccTestDataPrimitives.Int16_5, - IccTestDataPrimitives.Int16_6, - IccTestDataPrimitives.Int16_7, - IccTestDataPrimitives.Int16_8, - IccTestDataPrimitives.Int16_9); + public static readonly byte[] Int16Arr = ArrayHelper.Concat( + IccTestDataPrimitives.Int160, + IccTestDataPrimitives.Int161, + IccTestDataPrimitives.Int162, + IccTestDataPrimitives.Int163, + IccTestDataPrimitives.Int164, + IccTestDataPrimitives.Int165, + IccTestDataPrimitives.Int166, + IccTestDataPrimitives.Int167, + IccTestDataPrimitives.Int168, + IccTestDataPrimitives.Int169); public static readonly object[][] Int16TestData = { - new object[] { Int16_Arr, Int16_Val } + new object[] { Int16Arr, Int16Val } }; - public static readonly uint[] UInt32_Val = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }; + public static readonly uint[] UInt32Val = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }; - public static readonly byte[] UInt32_Arr = ArrayHelper.Concat( - IccTestDataPrimitives.UInt32_0, - IccTestDataPrimitives.UInt32_1, - IccTestDataPrimitives.UInt32_2, - IccTestDataPrimitives.UInt32_3, - IccTestDataPrimitives.UInt32_4, - IccTestDataPrimitives.UInt32_5, - IccTestDataPrimitives.UInt32_6, - IccTestDataPrimitives.UInt32_7, - IccTestDataPrimitives.UInt32_8, - IccTestDataPrimitives.UInt32_9); + public static readonly byte[] UInt32Arr = ArrayHelper.Concat( + IccTestDataPrimitives.UInt320, + IccTestDataPrimitives.UInt321, + IccTestDataPrimitives.UInt322, + IccTestDataPrimitives.UInt323, + IccTestDataPrimitives.UInt324, + IccTestDataPrimitives.UInt325, + IccTestDataPrimitives.UInt326, + IccTestDataPrimitives.UInt327, + IccTestDataPrimitives.UInt328, + IccTestDataPrimitives.UInt329); public static readonly object[][] UInt32TestData = { - new object[] { UInt32_Arr, UInt32_Val } + new object[] { UInt32Arr, UInt32Val } }; - public static readonly int[] Int32_Val = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }; + public static readonly int[] Int32Val = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }; - public static readonly byte[] Int32_Arr = ArrayHelper.Concat( - IccTestDataPrimitives.Int32_0, - IccTestDataPrimitives.Int32_1, - IccTestDataPrimitives.Int32_2, - IccTestDataPrimitives.Int32_3, - IccTestDataPrimitives.Int32_4, - IccTestDataPrimitives.Int32_5, - IccTestDataPrimitives.Int32_6, - IccTestDataPrimitives.Int32_7, - IccTestDataPrimitives.Int32_8, - IccTestDataPrimitives.Int32_9); + public static readonly byte[] Int32Arr = ArrayHelper.Concat( + IccTestDataPrimitives.Int320, + IccTestDataPrimitives.Int321, + IccTestDataPrimitives.Int322, + IccTestDataPrimitives.Int323, + IccTestDataPrimitives.Int324, + IccTestDataPrimitives.Int325, + IccTestDataPrimitives.Int326, + IccTestDataPrimitives.Int327, + IccTestDataPrimitives.Int328, + IccTestDataPrimitives.Int329); public static readonly object[][] Int32TestData = { - new object[] { Int32_Arr, Int32_Val } + new object[] { Int32Arr, Int32Val } }; - public static readonly ulong[] UInt64_Val = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }; + public static readonly ulong[] UInt64Val = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }; - public static readonly byte[] UInt64_Arr = ArrayHelper.Concat( - IccTestDataPrimitives.UInt64_0, - IccTestDataPrimitives.UInt64_1, - IccTestDataPrimitives.UInt64_2, - IccTestDataPrimitives.UInt64_3, - IccTestDataPrimitives.UInt64_4, - IccTestDataPrimitives.UInt64_5, - IccTestDataPrimitives.UInt64_6, - IccTestDataPrimitives.UInt64_7, - IccTestDataPrimitives.UInt64_8, - IccTestDataPrimitives.UInt64_9); + public static readonly byte[] UInt64Arr = ArrayHelper.Concat( + IccTestDataPrimitives.UInt640, + IccTestDataPrimitives.UInt641, + IccTestDataPrimitives.UInt642, + IccTestDataPrimitives.UInt643, + IccTestDataPrimitives.UInt644, + IccTestDataPrimitives.UInt645, + IccTestDataPrimitives.UInt646, + IccTestDataPrimitives.UInt647, + IccTestDataPrimitives.UInt648, + IccTestDataPrimitives.UInt649); public static readonly object[][] UInt64TestData = { - new object[] { UInt64_Arr, UInt64_Val } + new object[] { UInt64Arr, UInt64Val } }; } diff --git a/tests/ImageSharp.Tests/TestDataIcc/IccTestDataCurves.cs b/tests/ImageSharp.Tests/TestDataIcc/IccTestDataCurves.cs index f76d2ba036..8092a847e2 100644 --- a/tests/ImageSharp.Tests/TestDataIcc/IccTestDataCurves.cs +++ b/tests/ImageSharp.Tests/TestDataIcc/IccTestDataCurves.cs @@ -10,302 +10,302 @@ internal static class IccTestDataCurves /// /// Channels: 3 /// - public static readonly IccResponseCurve Response_ValGrad = new IccResponseCurve( + public static readonly IccResponseCurve ResponseValGrad = new( IccCurveMeasurementEncodings.StatusA, new[] { - IccTestDataNonPrimitives.XyzNumber_ValVar1, - IccTestDataNonPrimitives.XyzNumber_ValVar2, - IccTestDataNonPrimitives.XyzNumber_ValVar3 + IccTestDataNonPrimitives.XyzNumberValVar1, + IccTestDataNonPrimitives.XyzNumberValVar2, + IccTestDataNonPrimitives.XyzNumberValVar3 }, - new IccResponseNumber[][] + new[] { - new IccResponseNumber[] { IccTestDataNonPrimitives.ResponseNumber_Val1, IccTestDataNonPrimitives.ResponseNumber_Val2 }, - new IccResponseNumber[] { IccTestDataNonPrimitives.ResponseNumber_Val3, IccTestDataNonPrimitives.ResponseNumber_Val4 }, - new IccResponseNumber[] { IccTestDataNonPrimitives.ResponseNumber_Val5, IccTestDataNonPrimitives.ResponseNumber_Val6 }, + new[] { IccTestDataNonPrimitives.ResponseNumberVal1, IccTestDataNonPrimitives.ResponseNumberVal2 }, + new[] { IccTestDataNonPrimitives.ResponseNumberVal3, IccTestDataNonPrimitives.ResponseNumberVal4 }, + new[] { IccTestDataNonPrimitives.ResponseNumberVal5, IccTestDataNonPrimitives.ResponseNumberVal6 }, }); /// /// Channels: 3 /// - public static readonly byte[] Response_Grad = ArrayHelper.Concat( + public static readonly byte[] ResponseGrad = ArrayHelper.Concat( new byte[] { 0x53, 0x74, 0x61, 0x41 }, - IccTestDataPrimitives.UInt32_2, - IccTestDataPrimitives.UInt32_2, - IccTestDataPrimitives.UInt32_2, - IccTestDataNonPrimitives.XyzNumber_Var1, - IccTestDataNonPrimitives.XyzNumber_Var2, - IccTestDataNonPrimitives.XyzNumber_Var3, - IccTestDataNonPrimitives.ResponseNumber_1, - IccTestDataNonPrimitives.ResponseNumber_2, - IccTestDataNonPrimitives.ResponseNumber_3, - IccTestDataNonPrimitives.ResponseNumber_4, - IccTestDataNonPrimitives.ResponseNumber_5, - IccTestDataNonPrimitives.ResponseNumber_6); + IccTestDataPrimitives.UInt322, + IccTestDataPrimitives.UInt322, + IccTestDataPrimitives.UInt322, + IccTestDataNonPrimitives.XyzNumberVar1, + IccTestDataNonPrimitives.XyzNumberVar2, + IccTestDataNonPrimitives.XyzNumberVar3, + IccTestDataNonPrimitives.ResponseNumber1, + IccTestDataNonPrimitives.ResponseNumber2, + IccTestDataNonPrimitives.ResponseNumber3, + IccTestDataNonPrimitives.ResponseNumber4, + IccTestDataNonPrimitives.ResponseNumber5, + IccTestDataNonPrimitives.ResponseNumber6); public static readonly object[][] ResponseCurveTestData = { - new object[] { Response_Grad, Response_ValGrad, 3 }, + new object[] { ResponseGrad, ResponseValGrad, 3 }, }; - public static readonly IccParametricCurve Parametric_ValVar1 = new IccParametricCurve(1); - public static readonly IccParametricCurve Parametric_ValVar2 = new IccParametricCurve(1, 2, 3); - public static readonly IccParametricCurve Parametric_ValVar3 = new IccParametricCurve(1, 2, 3, 4); - public static readonly IccParametricCurve Parametric_ValVar4 = new IccParametricCurve(1, 2, 3, 4, 5); - public static readonly IccParametricCurve Parametric_ValVar5 = new IccParametricCurve(1, 2, 3, 4, 5, 6, 7); + public static readonly IccParametricCurve ParametricValVar1 = new(1); + public static readonly IccParametricCurve ParametricValVar2 = new(1, 2, 3); + public static readonly IccParametricCurve ParametricValVar3 = new(1, 2, 3, 4); + public static readonly IccParametricCurve ParametricValVar4 = new(1, 2, 3, 4, 5); + public static readonly IccParametricCurve ParametricValVar5 = new(1, 2, 3, 4, 5, 6, 7); - public static readonly byte[] Parametric_Var1 = ArrayHelper.Concat( + public static readonly byte[] ParametricVar1 = ArrayHelper.Concat( new byte[] { 0x00, 0x00, 0x00, 0x00, }, - IccTestDataPrimitives.Fix16_1); + IccTestDataPrimitives.Fix161); - public static readonly byte[] Parametric_Var2 = ArrayHelper.Concat( + public static readonly byte[] ParametricVar2 = ArrayHelper.Concat( new byte[] { 0x00, 0x01, 0x00, 0x00, }, - IccTestDataPrimitives.Fix16_1, - IccTestDataPrimitives.Fix16_2, - IccTestDataPrimitives.Fix16_3); + IccTestDataPrimitives.Fix161, + IccTestDataPrimitives.Fix162, + IccTestDataPrimitives.Fix163); - public static readonly byte[] Parametric_Var3 = ArrayHelper.Concat( + public static readonly byte[] ParametricVar3 = ArrayHelper.Concat( new byte[] { 0x00, 0x02, 0x00, 0x00, }, - IccTestDataPrimitives.Fix16_1, - IccTestDataPrimitives.Fix16_2, - IccTestDataPrimitives.Fix16_3, - IccTestDataPrimitives.Fix16_4); + IccTestDataPrimitives.Fix161, + IccTestDataPrimitives.Fix162, + IccTestDataPrimitives.Fix163, + IccTestDataPrimitives.Fix164); - public static readonly byte[] Parametric_Var4 = ArrayHelper.Concat( + public static readonly byte[] ParametricVar4 = ArrayHelper.Concat( new byte[] { 0x00, 0x03, 0x00, 0x00, }, - IccTestDataPrimitives.Fix16_1, - IccTestDataPrimitives.Fix16_2, - IccTestDataPrimitives.Fix16_3, - IccTestDataPrimitives.Fix16_4, - IccTestDataPrimitives.Fix16_5); + IccTestDataPrimitives.Fix161, + IccTestDataPrimitives.Fix162, + IccTestDataPrimitives.Fix163, + IccTestDataPrimitives.Fix164, + IccTestDataPrimitives.Fix165); - public static readonly byte[] Parametric_Var5 = ArrayHelper.Concat( + public static readonly byte[] ParametricVar5 = ArrayHelper.Concat( new byte[] { 0x00, 0x04, 0x00, 0x00, }, - IccTestDataPrimitives.Fix16_1, - IccTestDataPrimitives.Fix16_2, - IccTestDataPrimitives.Fix16_3, - IccTestDataPrimitives.Fix16_4, - IccTestDataPrimitives.Fix16_5, - IccTestDataPrimitives.Fix16_6, - IccTestDataPrimitives.Fix16_7); + IccTestDataPrimitives.Fix161, + IccTestDataPrimitives.Fix162, + IccTestDataPrimitives.Fix163, + IccTestDataPrimitives.Fix164, + IccTestDataPrimitives.Fix165, + IccTestDataPrimitives.Fix166, + IccTestDataPrimitives.Fix167); public static readonly object[][] ParametricCurveTestData = { - new object[] { Parametric_Var1, Parametric_ValVar1 }, - new object[] { Parametric_Var2, Parametric_ValVar2 }, - new object[] { Parametric_Var3, Parametric_ValVar3 }, - new object[] { Parametric_Var4, Parametric_ValVar4 }, - new object[] { Parametric_Var5, Parametric_ValVar5 }, + new object[] { ParametricVar1, ParametricValVar1 }, + new object[] { ParametricVar2, ParametricValVar2 }, + new object[] { ParametricVar3, ParametricValVar3 }, + new object[] { ParametricVar4, ParametricValVar4 }, + new object[] { ParametricVar5, ParametricValVar5 }, }; // Formula Segment - public static readonly IccFormulaCurveElement Formula_ValVar1 = new IccFormulaCurveElement(IccFormulaCurveType.Type1, 1, 2, 3, 4, 0, 0); - public static readonly IccFormulaCurveElement Formula_ValVar2 = new IccFormulaCurveElement(IccFormulaCurveType.Type2, 1, 2, 3, 4, 5, 0); - public static readonly IccFormulaCurveElement Formula_ValVar3 = new IccFormulaCurveElement(IccFormulaCurveType.Type3, 0, 2, 3, 4, 5, 6); + public static readonly IccFormulaCurveElement FormulaValVar1 = new(IccFormulaCurveType.Type1, 1, 2, 3, 4, 0, 0); + public static readonly IccFormulaCurveElement FormulaValVar2 = new(IccFormulaCurveType.Type2, 1, 2, 3, 4, 5, 0); + public static readonly IccFormulaCurveElement FormulaValVar3 = new(IccFormulaCurveType.Type3, 0, 2, 3, 4, 5, 6); - public static readonly byte[] Formula_Var1 = ArrayHelper.Concat( + public static readonly byte[] FormulaVar1 = ArrayHelper.Concat( new byte[] { 0x00, 0x00, 0x00, 0x00, }, - IccTestDataPrimitives.Single_1, - IccTestDataPrimitives.Single_2, - IccTestDataPrimitives.Single_3, - IccTestDataPrimitives.Single_4); + IccTestDataPrimitives.Single1, + IccTestDataPrimitives.Single2, + IccTestDataPrimitives.Single3, + IccTestDataPrimitives.Single4); - public static readonly byte[] Formula_Var2 = ArrayHelper.Concat( + public static readonly byte[] FormulaVar2 = ArrayHelper.Concat( new byte[] { 0x00, 0x01, 0x00, 0x00, }, - IccTestDataPrimitives.Single_1, - IccTestDataPrimitives.Single_2, - IccTestDataPrimitives.Single_3, - IccTestDataPrimitives.Single_4, - IccTestDataPrimitives.Single_5); + IccTestDataPrimitives.Single1, + IccTestDataPrimitives.Single2, + IccTestDataPrimitives.Single3, + IccTestDataPrimitives.Single4, + IccTestDataPrimitives.Single5); - public static readonly byte[] Formula_Var3 = ArrayHelper.Concat( + public static readonly byte[] FormulaVar3 = ArrayHelper.Concat( new byte[] { 0x00, 0x02, 0x00, 0x00, }, - IccTestDataPrimitives.Single_2, - IccTestDataPrimitives.Single_3, - IccTestDataPrimitives.Single_4, - IccTestDataPrimitives.Single_5, - IccTestDataPrimitives.Single_6); + IccTestDataPrimitives.Single2, + IccTestDataPrimitives.Single3, + IccTestDataPrimitives.Single4, + IccTestDataPrimitives.Single5, + IccTestDataPrimitives.Single6); public static readonly object[][] FormulaCurveSegmentTestData = { - new object[] { Formula_Var1, Formula_ValVar1 }, - new object[] { Formula_Var2, Formula_ValVar2 }, - new object[] { Formula_Var3, Formula_ValVar3 }, + new object[] { FormulaVar1, FormulaValVar1 }, + new object[] { FormulaVar2, FormulaValVar2 }, + new object[] { FormulaVar3, FormulaValVar3 }, }; // Sampled Segment - public static readonly IccSampledCurveElement Sampled_ValGrad1 = new IccSampledCurveElement(new float[] { 1, 2, 3, 4, 5, 6, 7, 8, 9 }); - public static readonly IccSampledCurveElement Sampled_ValGrad2 = new IccSampledCurveElement(new float[] { 9, 8, 7, 6, 5, 4, 3, 2, 1 }); - - public static readonly byte[] Sampled_Grad1 = ArrayHelper.Concat( - IccTestDataPrimitives.UInt32_9, - IccTestDataPrimitives.Single_1, - IccTestDataPrimitives.Single_2, - IccTestDataPrimitives.Single_3, - IccTestDataPrimitives.Single_4, - IccTestDataPrimitives.Single_5, - IccTestDataPrimitives.Single_6, - IccTestDataPrimitives.Single_7, - IccTestDataPrimitives.Single_8, - IccTestDataPrimitives.Single_9); - - public static readonly byte[] Sampled_Grad2 = ArrayHelper.Concat( - IccTestDataPrimitives.UInt32_9, - IccTestDataPrimitives.Single_9, - IccTestDataPrimitives.Single_8, - IccTestDataPrimitives.Single_7, - IccTestDataPrimitives.Single_6, - IccTestDataPrimitives.Single_5, - IccTestDataPrimitives.Single_4, - IccTestDataPrimitives.Single_3, - IccTestDataPrimitives.Single_2, - IccTestDataPrimitives.Single_1); + public static readonly IccSampledCurveElement SampledValGrad1 = new(new float[] { 1, 2, 3, 4, 5, 6, 7, 8, 9 }); + public static readonly IccSampledCurveElement SampledValGrad2 = new(new float[] { 9, 8, 7, 6, 5, 4, 3, 2, 1 }); + + public static readonly byte[] SampledGrad1 = ArrayHelper.Concat( + IccTestDataPrimitives.UInt329, + IccTestDataPrimitives.Single1, + IccTestDataPrimitives.Single2, + IccTestDataPrimitives.Single3, + IccTestDataPrimitives.Single4, + IccTestDataPrimitives.Single5, + IccTestDataPrimitives.Single6, + IccTestDataPrimitives.Single7, + IccTestDataPrimitives.Single8, + IccTestDataPrimitives.Single9); + + public static readonly byte[] SampledGrad2 = ArrayHelper.Concat( + IccTestDataPrimitives.UInt329, + IccTestDataPrimitives.Single9, + IccTestDataPrimitives.Single8, + IccTestDataPrimitives.Single7, + IccTestDataPrimitives.Single6, + IccTestDataPrimitives.Single5, + IccTestDataPrimitives.Single4, + IccTestDataPrimitives.Single3, + IccTestDataPrimitives.Single2, + IccTestDataPrimitives.Single1); public static readonly object[][] SampledCurveSegmentTestData = { - new object[] { Sampled_Grad1, Sampled_ValGrad1 }, - new object[] { Sampled_Grad2, Sampled_ValGrad2 }, + new object[] { SampledGrad1, SampledValGrad1 }, + new object[] { SampledGrad2, SampledValGrad2 }, }; - public static readonly IccCurveSegment Segment_ValFormula1 = Formula_ValVar1; - public static readonly IccCurveSegment Segment_ValFormula2 = Formula_ValVar2; - public static readonly IccCurveSegment Segment_ValFormula3 = Formula_ValVar3; - public static readonly IccCurveSegment Segment_ValSampled1 = Sampled_ValGrad1; - public static readonly IccCurveSegment Segment_ValSampled2 = Sampled_ValGrad2; + public static readonly IccCurveSegment SegmentValFormula1 = FormulaValVar1; + public static readonly IccCurveSegment SegmentValFormula2 = FormulaValVar2; + public static readonly IccCurveSegment SegmentValFormula3 = FormulaValVar3; + public static readonly IccCurveSegment SegmentValSampled1 = SampledValGrad1; + public static readonly IccCurveSegment SegmentValSampled2 = SampledValGrad2; - public static readonly byte[] Segment_Formula1 = ArrayHelper.Concat( + public static readonly byte[] SegmentFormula1 = ArrayHelper.Concat( new byte[] { 0x70, 0x61, 0x72, 0x66, 0x00, 0x00, 0x00, 0x00, }, - Formula_Var1); + FormulaVar1); - public static readonly byte[] Segment_Formula2 = ArrayHelper.Concat( + public static readonly byte[] SegmentFormula2 = ArrayHelper.Concat( new byte[] { 0x70, 0x61, 0x72, 0x66, 0x00, 0x00, 0x00, 0x00, }, - Formula_Var2); + FormulaVar2); - public static readonly byte[] Segment_Formula3 = ArrayHelper.Concat( + public static readonly byte[] SegmentFormula3 = ArrayHelper.Concat( new byte[] { 0x70, 0x61, 0x72, 0x66, 0x00, 0x00, 0x00, 0x00, }, - Formula_Var3); + FormulaVar3); - public static readonly byte[] Segment_Sampled1 = ArrayHelper.Concat( + public static readonly byte[] SegmentSampled1 = ArrayHelper.Concat( new byte[] { 0x73, 0x61, 0x6D, 0x66, 0x00, 0x00, 0x00, 0x00, }, - Sampled_Grad1); + SampledGrad1); - public static readonly byte[] Segment_Sampled2 = ArrayHelper.Concat( + public static readonly byte[] SegmentSampled2 = ArrayHelper.Concat( new byte[] { 0x73, 0x61, 0x6D, 0x66, 0x00, 0x00, 0x00, 0x00, }, - Sampled_Grad2); + SampledGrad2); public static readonly object[][] CurveSegmentTestData = { - new object[] { Segment_Formula1, Segment_ValFormula1 }, - new object[] { Segment_Formula2, Segment_ValFormula2 }, - new object[] { Segment_Formula3, Segment_ValFormula3 }, - new object[] { Segment_Sampled1, Segment_ValSampled1 }, - new object[] { Segment_Sampled2, Segment_ValSampled2 }, + new object[] { SegmentFormula1, SegmentValFormula1 }, + new object[] { SegmentFormula2, SegmentValFormula2 }, + new object[] { SegmentFormula3, SegmentValFormula3 }, + new object[] { SegmentSampled1, SegmentValSampled1 }, + new object[] { SegmentSampled2, SegmentValSampled2 }, }; - public static readonly IccOneDimensionalCurve OneDimensional_ValFormula1 = new IccOneDimensionalCurve( + public static readonly IccOneDimensionalCurve OneDimensionalValFormula1 = new( new float[] { 0, 1 }, - new IccCurveSegment[] { Segment_ValFormula1, Segment_ValFormula2, Segment_ValFormula3 }); + new[] { SegmentValFormula1, SegmentValFormula2, SegmentValFormula3 }); - public static readonly IccOneDimensionalCurve OneDimensional_ValFormula2 = new IccOneDimensionalCurve( + public static readonly IccOneDimensionalCurve OneDimensionalValFormula2 = new( new float[] { 0, 1 }, - new IccCurveSegment[] { Segment_ValFormula3, Segment_ValFormula2, Segment_ValFormula1 }); + new[] { SegmentValFormula3, SegmentValFormula2, SegmentValFormula1 }); - public static readonly IccOneDimensionalCurve OneDimensional_ValSampled = new IccOneDimensionalCurve( + public static readonly IccOneDimensionalCurve OneDimensionalValSampled = new( new float[] { 0, 1 }, - new IccCurveSegment[] { Segment_ValSampled1, Segment_ValSampled2, Segment_ValSampled1 }); + new[] { SegmentValSampled1, SegmentValSampled2, SegmentValSampled1 }); - public static readonly byte[] OneDimensional_Formula1 = ArrayHelper.Concat( + public static readonly byte[] OneDimensionalFormula1 = ArrayHelper.Concat( new byte[] { 0x00, 0x03, 0x00, 0x00, }, - IccTestDataPrimitives.Single_0, - IccTestDataPrimitives.Single_1, - Segment_Formula1, - Segment_Formula2, - Segment_Formula3); + IccTestDataPrimitives.Single0, + IccTestDataPrimitives.Single1, + SegmentFormula1, + SegmentFormula2, + SegmentFormula3); - public static readonly byte[] OneDimensional_Formula2 = ArrayHelper.Concat( + public static readonly byte[] OneDimensionalFormula2 = ArrayHelper.Concat( new byte[] { 0x00, 0x03, 0x00, 0x00, }, - IccTestDataPrimitives.Single_0, - IccTestDataPrimitives.Single_1, - Segment_Formula3, - Segment_Formula2, - Segment_Formula1); + IccTestDataPrimitives.Single0, + IccTestDataPrimitives.Single1, + SegmentFormula3, + SegmentFormula2, + SegmentFormula1); - public static readonly byte[] OneDimensional_Sampled = ArrayHelper.Concat( + public static readonly byte[] OneDimensionalSampled = ArrayHelper.Concat( new byte[] { 0x00, 0x03, 0x00, 0x00, }, - IccTestDataPrimitives.Single_0, - IccTestDataPrimitives.Single_1, - Segment_Sampled1, - Segment_Sampled2, - Segment_Sampled1); + IccTestDataPrimitives.Single0, + IccTestDataPrimitives.Single1, + SegmentSampled1, + SegmentSampled2, + SegmentSampled1); public static readonly object[][] OneDimensionalCurveTestData = { - new object[] { OneDimensional_Formula1, OneDimensional_ValFormula1 }, - new object[] { OneDimensional_Formula2, OneDimensional_ValFormula2 }, - new object[] { OneDimensional_Sampled, OneDimensional_ValSampled }, + new object[] { OneDimensionalFormula1, OneDimensionalValFormula1 }, + new object[] { OneDimensionalFormula2, OneDimensionalValFormula2 }, + new object[] { OneDimensionalSampled, OneDimensionalValSampled }, }; } diff --git a/tests/ImageSharp.Tests/TestDataIcc/IccTestDataLut.cs b/tests/ImageSharp.Tests/TestDataIcc/IccTestDataLut.cs index 7a778f269b..ab7ded95d5 100644 --- a/tests/ImageSharp.Tests/TestDataIcc/IccTestDataLut.cs +++ b/tests/ImageSharp.Tests/TestDataIcc/IccTestDataLut.cs @@ -7,10 +7,10 @@ namespace SixLabors.ImageSharp.Tests; internal static class IccTestDataLut { - public static readonly IccLut LUT8_ValGrad = CreateLUT8Val(); - public static readonly byte[] LUT8_Grad = CreateLUT8(); + public static readonly IccLut Lut8ValGrad = CreateLut8Val(); + public static readonly byte[] Lut8Grad = CreateLut8(); - private static IccLut CreateLUT8Val() + private static IccLut CreateLut8Val() { float[] result = new float[256]; for (int i = 0; i < 256; i++) @@ -21,7 +21,7 @@ private static IccLut CreateLUT8Val() return new IccLut(result); } - private static byte[] CreateLUT8() + private static byte[] CreateLut8() { byte[] result = new byte[256]; for (int i = 0; i < 256; i++) @@ -34,10 +34,10 @@ private static byte[] CreateLUT8() public static readonly object[][] Lut8TestData = { - new object[] { LUT8_Grad, LUT8_ValGrad }, + new object[] { Lut8Grad, Lut8ValGrad }, }; - public static readonly IccLut LUT16_ValGrad = new IccLut(new float[] + public static readonly IccLut Lut16ValGrad = new(new[] { 1f / ushort.MaxValue, 2f / ushort.MaxValue, @@ -52,38 +52,38 @@ private static byte[] CreateLUT8() 1f }); - public static readonly byte[] LUT16_Grad = ArrayHelper.Concat( - IccTestDataPrimitives.UInt16_1, - IccTestDataPrimitives.UInt16_2, - IccTestDataPrimitives.UInt16_3, - IccTestDataPrimitives.UInt16_4, - IccTestDataPrimitives.UInt16_5, - IccTestDataPrimitives.UInt16_6, - IccTestDataPrimitives.UInt16_7, - IccTestDataPrimitives.UInt16_8, - IccTestDataPrimitives.UInt16_9, - IccTestDataPrimitives.UInt16_32768, - IccTestDataPrimitives.UInt16_Max); + public static readonly byte[] Lut16Grad = ArrayHelper.Concat( + IccTestDataPrimitives.UInt161, + IccTestDataPrimitives.UInt162, + IccTestDataPrimitives.UInt163, + IccTestDataPrimitives.UInt164, + IccTestDataPrimitives.UInt165, + IccTestDataPrimitives.UInt166, + IccTestDataPrimitives.UInt167, + IccTestDataPrimitives.UInt168, + IccTestDataPrimitives.UInt169, + IccTestDataPrimitives.UInt1632768, + IccTestDataPrimitives.UInt16Max); public static readonly object[][] Lut16TestData = { - new object[] { LUT16_Grad, LUT16_ValGrad, 11 }, + new object[] { Lut16Grad, Lut16ValGrad, 11 }, }; - public static readonly IccClut CLUT8_ValGrad = new IccClut( - new float[][] + public static readonly IccClut Clut8ValGrad = new( + new[] { - new float[] { 1f / byte.MaxValue, 2f / byte.MaxValue, 3f / byte.MaxValue }, - new float[] { 4f / byte.MaxValue, 5f / byte.MaxValue, 6f / byte.MaxValue }, - new float[] { 7f / byte.MaxValue, 8f / byte.MaxValue, 9f / byte.MaxValue }, + new[] { 1f / byte.MaxValue, 2f / byte.MaxValue, 3f / byte.MaxValue }, + new[] { 4f / byte.MaxValue, 5f / byte.MaxValue, 6f / byte.MaxValue }, + new[] { 7f / byte.MaxValue, 8f / byte.MaxValue, 9f / byte.MaxValue }, - new float[] { 10f / byte.MaxValue, 11f / byte.MaxValue, 12f / byte.MaxValue }, - new float[] { 13f / byte.MaxValue, 14f / byte.MaxValue, 15f / byte.MaxValue }, - new float[] { 16f / byte.MaxValue, 17f / byte.MaxValue, 18f / byte.MaxValue }, + new[] { 10f / byte.MaxValue, 11f / byte.MaxValue, 12f / byte.MaxValue }, + new[] { 13f / byte.MaxValue, 14f / byte.MaxValue, 15f / byte.MaxValue }, + new[] { 16f / byte.MaxValue, 17f / byte.MaxValue, 18f / byte.MaxValue }, - new float[] { 19f / byte.MaxValue, 20f / byte.MaxValue, 21f / byte.MaxValue }, - new float[] { 22f / byte.MaxValue, 23f / byte.MaxValue, 24f / byte.MaxValue }, - new float[] { 25f / byte.MaxValue, 26f / byte.MaxValue, 27f / byte.MaxValue }, + new[] { 19f / byte.MaxValue, 20f / byte.MaxValue, 21f / byte.MaxValue }, + new[] { 22f / byte.MaxValue, 23f / byte.MaxValue, 24f / byte.MaxValue }, + new[] { 25f / byte.MaxValue, 26f / byte.MaxValue, 27f / byte.MaxValue }, }, new byte[] { 3, 3 }, IccClutDataType.UInt8); @@ -93,7 +93,7 @@ private static byte[] CreateLUT8() /// Output Channel Count: 3 /// Grid-point Count: { 3, 3 } /// - public static readonly byte[] CLUT8_Grad = + public static readonly byte[] Clut8Grad = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, @@ -110,23 +110,23 @@ private static byte[] CreateLUT8() public static readonly object[][] Clut8TestData = { - new object[] { CLUT8_Grad, CLUT8_ValGrad, 2, 3, new byte[] { 3, 3 } }, + new object[] { Clut8Grad, Clut8ValGrad, 2, 3, new byte[] { 3, 3 } }, }; - public static readonly IccClut CLUT16_ValGrad = new IccClut( - new float[][] + public static readonly IccClut Clut16ValGrad = new( + new[] { - new float[] { 1f / ushort.MaxValue, 2f / ushort.MaxValue, 3f / ushort.MaxValue }, - new float[] { 4f / ushort.MaxValue, 5f / ushort.MaxValue, 6f / ushort.MaxValue }, - new float[] { 7f / ushort.MaxValue, 8f / ushort.MaxValue, 9f / ushort.MaxValue }, + new[] { 1f / ushort.MaxValue, 2f / ushort.MaxValue, 3f / ushort.MaxValue }, + new[] { 4f / ushort.MaxValue, 5f / ushort.MaxValue, 6f / ushort.MaxValue }, + new[] { 7f / ushort.MaxValue, 8f / ushort.MaxValue, 9f / ushort.MaxValue }, - new float[] { 10f / ushort.MaxValue, 11f / ushort.MaxValue, 12f / ushort.MaxValue }, - new float[] { 13f / ushort.MaxValue, 14f / ushort.MaxValue, 15f / ushort.MaxValue }, - new float[] { 16f / ushort.MaxValue, 17f / ushort.MaxValue, 18f / ushort.MaxValue }, + new[] { 10f / ushort.MaxValue, 11f / ushort.MaxValue, 12f / ushort.MaxValue }, + new[] { 13f / ushort.MaxValue, 14f / ushort.MaxValue, 15f / ushort.MaxValue }, + new[] { 16f / ushort.MaxValue, 17f / ushort.MaxValue, 18f / ushort.MaxValue }, - new float[] { 19f / ushort.MaxValue, 20f / ushort.MaxValue, 21f / ushort.MaxValue }, - new float[] { 22f / ushort.MaxValue, 23f / ushort.MaxValue, 24f / ushort.MaxValue }, - new float[] { 25f / ushort.MaxValue, 26f / ushort.MaxValue, 27f / ushort.MaxValue }, + new[] { 19f / ushort.MaxValue, 20f / ushort.MaxValue, 21f / ushort.MaxValue }, + new[] { 22f / ushort.MaxValue, 23f / ushort.MaxValue, 24f / ushort.MaxValue }, + new[] { 25f / ushort.MaxValue, 26f / ushort.MaxValue, 27f / ushort.MaxValue }, }, new byte[] { 3, 3 }, IccClutDataType.UInt16); @@ -136,7 +136,7 @@ private static byte[] CreateLUT8() /// Output Channel Count: 3 /// Grid-point Count: { 3, 3 } /// - public static readonly byte[] CLUT16_Grad = + public static readonly byte[] Clut16Grad = { 0x00, 0x01, 0x00, 0x02, 0x00, 0x03, 0x00, 0x04, 0x00, 0x05, 0x00, 0x06, @@ -153,23 +153,23 @@ private static byte[] CreateLUT8() public static readonly object[][] Clut16TestData = { - new object[] { CLUT16_Grad, CLUT16_ValGrad, 2, 3, new byte[] { 3, 3 } }, + new object[] { Clut16Grad, Clut16ValGrad, 2, 3, new byte[] { 3, 3 } }, }; - public static readonly IccClut CLUTf32_ValGrad = new IccClut( - new float[][] + public static readonly IccClut CluTf32ValGrad = new( + new[] { - new float[] { 1f, 2f, 3f }, - new float[] { 4f, 5f, 6f }, - new float[] { 7f, 8f, 9f }, + new[] { 1f, 2f, 3f }, + new[] { 4f, 5f, 6f }, + new[] { 7f, 8f, 9f }, - new float[] { 1f, 2f, 3f }, - new float[] { 4f, 5f, 6f }, - new float[] { 7f, 8f, 9f }, + new[] { 1f, 2f, 3f }, + new[] { 4f, 5f, 6f }, + new[] { 7f, 8f, 9f }, - new float[] { 1f, 2f, 3f }, - new float[] { 4f, 5f, 6f }, - new float[] { 7f, 8f, 9f }, + new[] { 1f, 2f, 3f }, + new[] { 4f, 5f, 6f }, + new[] { 7f, 8f, 9f }, }, new byte[] { 3, 3 }, IccClutDataType.Float); @@ -179,62 +179,62 @@ private static byte[] CreateLUT8() /// Output Channel Count: 3 /// Grid-point Count: { 3, 3 } /// - public static readonly byte[] CLUTf32_Grad = ArrayHelper.Concat( - IccTestDataPrimitives.Single_1, - IccTestDataPrimitives.Single_2, - IccTestDataPrimitives.Single_3, - IccTestDataPrimitives.Single_4, - IccTestDataPrimitives.Single_5, - IccTestDataPrimitives.Single_6, - IccTestDataPrimitives.Single_7, - IccTestDataPrimitives.Single_8, - IccTestDataPrimitives.Single_9, - IccTestDataPrimitives.Single_1, - IccTestDataPrimitives.Single_2, - IccTestDataPrimitives.Single_3, - IccTestDataPrimitives.Single_4, - IccTestDataPrimitives.Single_5, - IccTestDataPrimitives.Single_6, - IccTestDataPrimitives.Single_7, - IccTestDataPrimitives.Single_8, - IccTestDataPrimitives.Single_9, - IccTestDataPrimitives.Single_1, - IccTestDataPrimitives.Single_2, - IccTestDataPrimitives.Single_3, - IccTestDataPrimitives.Single_4, - IccTestDataPrimitives.Single_5, - IccTestDataPrimitives.Single_6, - IccTestDataPrimitives.Single_7, - IccTestDataPrimitives.Single_8, - IccTestDataPrimitives.Single_9); + public static readonly byte[] CluTf32Grad = ArrayHelper.Concat( + IccTestDataPrimitives.Single1, + IccTestDataPrimitives.Single2, + IccTestDataPrimitives.Single3, + IccTestDataPrimitives.Single4, + IccTestDataPrimitives.Single5, + IccTestDataPrimitives.Single6, + IccTestDataPrimitives.Single7, + IccTestDataPrimitives.Single8, + IccTestDataPrimitives.Single9, + IccTestDataPrimitives.Single1, + IccTestDataPrimitives.Single2, + IccTestDataPrimitives.Single3, + IccTestDataPrimitives.Single4, + IccTestDataPrimitives.Single5, + IccTestDataPrimitives.Single6, + IccTestDataPrimitives.Single7, + IccTestDataPrimitives.Single8, + IccTestDataPrimitives.Single9, + IccTestDataPrimitives.Single1, + IccTestDataPrimitives.Single2, + IccTestDataPrimitives.Single3, + IccTestDataPrimitives.Single4, + IccTestDataPrimitives.Single5, + IccTestDataPrimitives.Single6, + IccTestDataPrimitives.Single7, + IccTestDataPrimitives.Single8, + IccTestDataPrimitives.Single9); public static readonly object[][] ClutF32TestData = { - new object[] { CLUTf32_Grad, CLUTf32_ValGrad, 2, 3, new byte[] { 3, 3 } }, + new object[] { CluTf32Grad, CluTf32ValGrad, 2, 3, new byte[] { 3, 3 } }, }; - public static readonly IccClut CLUT_Val8 = CLUT8_ValGrad; - public static readonly IccClut CLUT_Val16 = CLUT16_ValGrad; - public static readonly IccClut CLUT_Valf32 = CLUTf32_ValGrad; + public static readonly IccClut ClutVal8 = Clut8ValGrad; + public static readonly IccClut ClutVal16 = Clut16ValGrad; + public static readonly IccClut ClutValf32 = CluTf32ValGrad; - public static readonly byte[] CLUT_8 = ArrayHelper.Concat( + public static readonly byte[] Clut8 = ArrayHelper.Concat( new byte[16] { 0x03, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, new byte[4] { 0x01, 0x00, 0x00, 0x00 }, - CLUT8_Grad); + Clut8Grad); - public static readonly byte[] CLUT_16 = ArrayHelper.Concat( + public static readonly byte[] Clut16 = ArrayHelper.Concat( new byte[16] { 0x03, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, new byte[4] { 0x02, 0x00, 0x00, 0x00 }, - CLUT16_Grad); + Clut16Grad); - public static readonly byte[] CLUT_f32 = ArrayHelper.Concat( + public static readonly byte[] ClutF32 = ArrayHelper.Concat( new byte[16] { 0x03, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, - CLUTf32_Grad); + CluTf32Grad); public static readonly object[][] ClutTestData = { - new object[] { CLUT_8, CLUT_Val8, 2, 3, false }, - new object[] { CLUT_16, CLUT_Val16, 2, 3, false }, - new object[] { CLUT_f32, CLUT_Valf32, 2, 3, true }, + new object[] { Clut8, ClutVal8, 2, 3, false }, + new object[] { Clut16, ClutVal16, 2, 3, false }, + new object[] { ClutF32, ClutValf32, 2, 3, true }, }; } diff --git a/tests/ImageSharp.Tests/TestDataIcc/IccTestDataMatrix.cs b/tests/ImageSharp.Tests/TestDataIcc/IccTestDataMatrix.cs index 94df8d69a6..6f8bee2169 100644 --- a/tests/ImageSharp.Tests/TestDataIcc/IccTestDataMatrix.cs +++ b/tests/ImageSharp.Tests/TestDataIcc/IccTestDataMatrix.cs @@ -12,7 +12,7 @@ internal static class IccTestDataMatrix /// /// 3x3 Matrix /// - public static readonly float[,] Single_2DArray_ValGrad = + public static readonly float[,] Single2DArrayValGrad = { { 1, 2, 3 }, { 4, 5, 6 }, @@ -22,7 +22,7 @@ internal static class IccTestDataMatrix /// /// 3x3 Matrix /// - public static readonly float[,] Single_2DArray_ValIdentity = + public static readonly float[,] Single2DArrayValIdentity = { { 1, 0, 0 }, { 0, 1, 0 }, @@ -32,121 +32,121 @@ internal static class IccTestDataMatrix /// /// 3x3 Matrix /// - public static readonly Matrix4x4 Single_Matrix4x4_ValGrad = new Matrix4x4(1, 2, 3, 0, 4, 5, 6, 0, 7, 8, 9, 0, 0, 0, 0, 1); + public static readonly Matrix4x4 SingleMatrix4X4ValGrad = new(1, 2, 3, 0, 4, 5, 6, 0, 7, 8, 9, 0, 0, 0, 0, 1); /// /// 3x3 Matrix /// - public static readonly Matrix4x4 Single_Matrix4x4_ValIdentity = Matrix4x4.Identity; + public static readonly Matrix4x4 SingleMatrix4X4ValIdentity = Matrix4x4.Identity; /// /// 3x3 Matrix /// - public static readonly DenseMatrix Single_DenseMatrix_ValGrad = new DenseMatrix(Single_2DArray_ValGrad); + public static readonly DenseMatrix SingleDenseMatrixValGrad = new(Single2DArrayValGrad); /// /// 3x3 Matrix /// - public static readonly DenseMatrix Single_DenseMatrix_ValIdentity = new DenseMatrix(Single_2DArray_ValIdentity); + public static readonly DenseMatrix SingleDenseMatrixValIdentity = new(Single2DArrayValIdentity); /// /// 3x3 Matrix /// - public static readonly byte[] Fix16_2D_Grad = ArrayHelper.Concat( - IccTestDataPrimitives.Fix16_1, - IccTestDataPrimitives.Fix16_4, - IccTestDataPrimitives.Fix16_7, - IccTestDataPrimitives.Fix16_2, - IccTestDataPrimitives.Fix16_5, - IccTestDataPrimitives.Fix16_8, - IccTestDataPrimitives.Fix16_3, - IccTestDataPrimitives.Fix16_6, - IccTestDataPrimitives.Fix16_9); + public static readonly byte[] Fix162DGrad = ArrayHelper.Concat( + IccTestDataPrimitives.Fix161, + IccTestDataPrimitives.Fix164, + IccTestDataPrimitives.Fix167, + IccTestDataPrimitives.Fix162, + IccTestDataPrimitives.Fix165, + IccTestDataPrimitives.Fix168, + IccTestDataPrimitives.Fix163, + IccTestDataPrimitives.Fix166, + IccTestDataPrimitives.Fix169); /// /// 3x3 Matrix /// - public static readonly byte[] Fix16_2D_Identity = ArrayHelper.Concat( - IccTestDataPrimitives.Fix16_1, - IccTestDataPrimitives.Fix16_0, - IccTestDataPrimitives.Fix16_0, - IccTestDataPrimitives.Fix16_0, - IccTestDataPrimitives.Fix16_1, - IccTestDataPrimitives.Fix16_0, - IccTestDataPrimitives.Fix16_0, - IccTestDataPrimitives.Fix16_0, - IccTestDataPrimitives.Fix16_1); + public static readonly byte[] Fix162DIdentity = ArrayHelper.Concat( + IccTestDataPrimitives.Fix161, + IccTestDataPrimitives.Fix160, + IccTestDataPrimitives.Fix160, + IccTestDataPrimitives.Fix160, + IccTestDataPrimitives.Fix161, + IccTestDataPrimitives.Fix160, + IccTestDataPrimitives.Fix160, + IccTestDataPrimitives.Fix160, + IccTestDataPrimitives.Fix161); /// /// 3x3 Matrix /// - public static readonly byte[] Single_2D_Grad = ArrayHelper.Concat( - IccTestDataPrimitives.Single_1, - IccTestDataPrimitives.Single_4, - IccTestDataPrimitives.Single_7, - IccTestDataPrimitives.Single_2, - IccTestDataPrimitives.Single_5, - IccTestDataPrimitives.Single_8, - IccTestDataPrimitives.Single_3, - IccTestDataPrimitives.Single_6, - IccTestDataPrimitives.Single_9); - - public static readonly object[][] Matrix2D_FloatArrayTestData = + public static readonly byte[] Single2DGrad = ArrayHelper.Concat( + IccTestDataPrimitives.Single1, + IccTestDataPrimitives.Single4, + IccTestDataPrimitives.Single7, + IccTestDataPrimitives.Single2, + IccTestDataPrimitives.Single5, + IccTestDataPrimitives.Single8, + IccTestDataPrimitives.Single3, + IccTestDataPrimitives.Single6, + IccTestDataPrimitives.Single9); + + public static readonly object[][] Matrix2DFloatArrayTestData = { - new object[] { Fix16_2D_Grad, 3, 3, false, Single_2DArray_ValGrad }, - new object[] { Fix16_2D_Identity, 3, 3, false, Single_2DArray_ValIdentity }, - new object[] { Single_2D_Grad, 3, 3, true, Single_2DArray_ValGrad }, + new object[] { Fix162DGrad, 3, 3, false, Single2DArrayValGrad }, + new object[] { Fix162DIdentity, 3, 3, false, Single2DArrayValIdentity }, + new object[] { Single2DGrad, 3, 3, true, Single2DArrayValGrad }, }; - public static readonly object[][] Matrix2D_DenseMatrixTestData = + public static readonly object[][] Matrix2DDenseMatrixTestData = { - new object[] { Fix16_2D_Grad, 3, 3, false, Single_DenseMatrix_ValGrad }, - new object[] { Fix16_2D_Identity, 3, 3, false, Single_DenseMatrix_ValIdentity }, - new object[] { Single_2D_Grad, 3, 3, true, Single_DenseMatrix_ValGrad }, + new object[] { Fix162DGrad, 3, 3, false, SingleDenseMatrixValGrad }, + new object[] { Fix162DIdentity, 3, 3, false, SingleDenseMatrixValIdentity }, + new object[] { Single2DGrad, 3, 3, true, SingleDenseMatrixValGrad }, }; - public static readonly object[][] Matrix2D_Matrix4x4TestData = + public static readonly object[][] Matrix2DMatrix4X4TestData = { - new object[] { Fix16_2D_Grad, 3, 3, false, Single_Matrix4x4_ValGrad }, - new object[] { Fix16_2D_Identity, 3, 3, false, Single_Matrix4x4_ValIdentity }, - new object[] { Single_2D_Grad, 3, 3, true, Single_Matrix4x4_ValGrad }, + new object[] { Fix162DGrad, 3, 3, false, SingleMatrix4X4ValGrad }, + new object[] { Fix162DIdentity, 3, 3, false, SingleMatrix4X4ValIdentity }, + new object[] { Single2DGrad, 3, 3, true, SingleMatrix4X4ValGrad }, }; /// /// 3x1 Matrix /// - public static readonly float[] Single_1DArray_ValGrad = { 1, 4, 7 }; + public static readonly float[] Single1DArrayValGrad = { 1, 4, 7 }; /// /// 3x1 Matrix /// - public static readonly Vector3 Single_Vector3_ValGrad = new Vector3(1, 4, 7); + public static readonly Vector3 SingleVector3ValGrad = new(1, 4, 7); /// /// 3x1 Matrix /// - public static readonly byte[] Fix16_1D_Grad = ArrayHelper.Concat( - IccTestDataPrimitives.Fix16_1, - IccTestDataPrimitives.Fix16_4, - IccTestDataPrimitives.Fix16_7); + public static readonly byte[] Fix161DGrad = ArrayHelper.Concat( + IccTestDataPrimitives.Fix161, + IccTestDataPrimitives.Fix164, + IccTestDataPrimitives.Fix167); /// /// 3x1 Matrix /// - public static readonly byte[] Single_1D_Grad = ArrayHelper.Concat( - IccTestDataPrimitives.Single_1, - IccTestDataPrimitives.Single_4, - IccTestDataPrimitives.Single_7); + public static readonly byte[] Single1DGrad = ArrayHelper.Concat( + IccTestDataPrimitives.Single1, + IccTestDataPrimitives.Single4, + IccTestDataPrimitives.Single7); - public static readonly object[][] Matrix1D_ArrayTestData = + public static readonly object[][] Matrix1DArrayTestData = { - new object[] { Fix16_1D_Grad, 3, false, Single_1DArray_ValGrad }, - new object[] { Single_1D_Grad, 3, true, Single_1DArray_ValGrad }, + new object[] { Fix161DGrad, 3, false, Single1DArrayValGrad }, + new object[] { Single1DGrad, 3, true, Single1DArrayValGrad }, }; - public static readonly object[][] Matrix1D_Vector3TestData = + public static readonly object[][] Matrix1DVector3TestData = { - new object[] { Fix16_1D_Grad, 3, false, Single_Vector3_ValGrad }, - new object[] { Single_1D_Grad, 3, true, Single_Vector3_ValGrad }, + new object[] { Fix161DGrad, 3, false, SingleVector3ValGrad }, + new object[] { Single1DGrad, 3, true, SingleVector3ValGrad }, }; } diff --git a/tests/ImageSharp.Tests/TestDataIcc/IccTestDataMultiProcessElements.cs b/tests/ImageSharp.Tests/TestDataIcc/IccTestDataMultiProcessElements.cs index 2c5c432710..2a8d87896d 100644 --- a/tests/ImageSharp.Tests/TestDataIcc/IccTestDataMultiProcessElements.cs +++ b/tests/ImageSharp.Tests/TestDataIcc/IccTestDataMultiProcessElements.cs @@ -11,99 +11,99 @@ internal static class IccTestDataMultiProcessElements /// Input Channel Count: 3 /// Output Channel Count: 3 /// - public static readonly IccCurveSetProcessElement CurvePE_ValGrad = new IccCurveSetProcessElement(new IccOneDimensionalCurve[] + public static readonly IccCurveSetProcessElement CurvePeValGrad = new(new[] { - IccTestDataCurves.OneDimensional_ValFormula1, - IccTestDataCurves.OneDimensional_ValFormula2, - IccTestDataCurves.OneDimensional_ValFormula1 + IccTestDataCurves.OneDimensionalValFormula1, + IccTestDataCurves.OneDimensionalValFormula2, + IccTestDataCurves.OneDimensionalValFormula1 }); /// /// Input Channel Count: 3 /// Output Channel Count: 3 /// - public static readonly byte[] CurvePE_Grad = ArrayHelper.Concat( - IccTestDataCurves.OneDimensional_Formula1, - IccTestDataCurves.OneDimensional_Formula2, - IccTestDataCurves.OneDimensional_Formula1); + public static readonly byte[] CurvePeGrad = ArrayHelper.Concat( + IccTestDataCurves.OneDimensionalFormula1, + IccTestDataCurves.OneDimensionalFormula2, + IccTestDataCurves.OneDimensionalFormula1); public static readonly object[][] CurveSetTestData = { - new object[] { CurvePE_Grad, CurvePE_ValGrad, 3, 3 }, + new object[] { CurvePeGrad, CurvePeValGrad, 3, 3 }, }; /// /// Input Channel Count: 3 /// Output Channel Count: 3 /// - public static readonly IccMatrixProcessElement MatrixPE_ValGrad = new IccMatrixProcessElement( - IccTestDataMatrix.Single_2DArray_ValGrad, - IccTestDataMatrix.Single_1DArray_ValGrad); + public static readonly IccMatrixProcessElement MatrixPeValGrad = new( + IccTestDataMatrix.Single2DArrayValGrad, + IccTestDataMatrix.Single1DArrayValGrad); /// /// Input Channel Count: 3 /// Output Channel Count: 3 /// - public static readonly byte[] MatrixPE_Grad = ArrayHelper.Concat( - IccTestDataMatrix.Single_2D_Grad, - IccTestDataMatrix.Single_1D_Grad); + public static readonly byte[] MatrixPeGrad = ArrayHelper.Concat( + IccTestDataMatrix.Single2DGrad, + IccTestDataMatrix.Single1DGrad); public static readonly object[][] MatrixTestData = { - new object[] { MatrixPE_Grad, MatrixPE_ValGrad, 3, 3 }, + new object[] { MatrixPeGrad, MatrixPeValGrad, 3, 3 }, }; /// /// Input Channel Count: 2 /// Output Channel Count: 3 /// - public static readonly IccClutProcessElement CLUTPE_ValGrad = new IccClutProcessElement(IccTestDataLut.CLUT_Valf32); + public static readonly IccClutProcessElement ClutpeValGrad = new(IccTestDataLut.ClutValf32); /// /// Input Channel Count: 2 /// Output Channel Count: 3 /// - public static readonly byte[] CLUTPE_Grad = IccTestDataLut.CLUT_f32; + public static readonly byte[] ClutpeGrad = IccTestDataLut.ClutF32; public static readonly object[][] ClutTestData = { - new object[] { CLUTPE_Grad, CLUTPE_ValGrad, 2, 3 }, + new object[] { ClutpeGrad, ClutpeValGrad, 2, 3 }, }; - public static readonly IccMultiProcessElement MPE_ValMatrix = MatrixPE_ValGrad; - public static readonly IccMultiProcessElement MPE_ValCLUT = CLUTPE_ValGrad; - public static readonly IccMultiProcessElement MPE_ValCurve = CurvePE_ValGrad; - public static readonly IccMultiProcessElement MPE_ValbACS = new IccBAcsProcessElement(3, 3); - public static readonly IccMultiProcessElement MPE_ValeACS = new IccEAcsProcessElement(3, 3); + public static readonly IccMultiProcessElement MpeValMatrix = MatrixPeValGrad; + public static readonly IccMultiProcessElement MpeValClut = ClutpeValGrad; + public static readonly IccMultiProcessElement MpeValCurve = CurvePeValGrad; + public static readonly IccMultiProcessElement MpeValbAcs = new IccBAcsProcessElement(3, 3); + public static readonly IccMultiProcessElement MpeValeAcs = new IccEAcsProcessElement(3, 3); - public static readonly byte[] MPE_Matrix = ArrayHelper.Concat( + public static readonly byte[] MpeMatrix = ArrayHelper.Concat( new byte[] { 0x6D, 0x61, 0x74, 0x66, 0x00, 0x03, 0x00, 0x03, }, - MatrixPE_Grad); + MatrixPeGrad); - public static readonly byte[] MPE_CLUT = ArrayHelper.Concat( + public static readonly byte[] MpeClut = ArrayHelper.Concat( new byte[] { 0x63, 0x6C, 0x75, 0x74, 0x00, 0x02, 0x00, 0x03, }, - CLUTPE_Grad); + ClutpeGrad); - public static readonly byte[] MPE_Curve = ArrayHelper.Concat( + public static readonly byte[] MpeCurve = ArrayHelper.Concat( new byte[] { 0x6D, 0x66, 0x6C, 0x74, 0x00, 0x03, 0x00, 0x03, }, - CurvePE_Grad); + CurvePeGrad); - public static readonly byte[] MPE_bACS = + public static readonly byte[] MpeBAcs = { 0x62, 0x41, 0x43, 0x53, 0x00, 0x03, @@ -111,7 +111,7 @@ internal static class IccTestDataMultiProcessElements 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, }; - public static readonly byte[] MPE_eACS = + public static readonly byte[] MpeEAcs = { 0x65, 0x41, 0x43, 0x53, 0x00, 0x03, @@ -121,10 +121,10 @@ internal static class IccTestDataMultiProcessElements public static readonly object[][] MultiProcessElementTestData = { - new object[] { MPE_Matrix, MPE_ValMatrix }, - new object[] { MPE_CLUT, MPE_ValCLUT }, - new object[] { MPE_Curve, MPE_ValCurve }, - new object[] { MPE_bACS, MPE_ValbACS }, - new object[] { MPE_eACS, MPE_ValeACS }, + new object[] { MpeMatrix, MpeValMatrix }, + new object[] { MpeClut, MpeValClut }, + new object[] { MpeCurve, MpeValCurve }, + new object[] { MpeBAcs, MpeValbAcs }, + new object[] { MpeEAcs, MpeValeAcs }, }; } diff --git a/tests/ImageSharp.Tests/TestDataIcc/IccTestDataNonPrimitives.cs b/tests/ImageSharp.Tests/TestDataIcc/IccTestDataNonPrimitives.cs index c476f2e6c7..6c92ccdaee 100644 --- a/tests/ImageSharp.Tests/TestDataIcc/IccTestDataNonPrimitives.cs +++ b/tests/ImageSharp.Tests/TestDataIcc/IccTestDataNonPrimitives.cs @@ -9,11 +9,11 @@ namespace SixLabors.ImageSharp.Tests; internal static class IccTestDataNonPrimitives { - public static readonly DateTime DateTime_ValMin = new DateTime(1, 1, 1, 0, 0, 0, DateTimeKind.Utc); - public static readonly DateTime DateTime_ValMax = new DateTime(9999, 12, 31, 23, 59, 59, DateTimeKind.Utc); - public static readonly DateTime DateTime_ValRand1 = new DateTime(1990, 11, 26, 3, 19, 47, DateTimeKind.Utc); + public static readonly DateTime DateTimeValMin = new(1, 1, 1, 0, 0, 0, DateTimeKind.Utc); + public static readonly DateTime DateTimeValMax = new(9999, 12, 31, 23, 59, 59, DateTimeKind.Utc); + public static readonly DateTime DateTimeValRand1 = new(1990, 11, 26, 3, 19, 47, DateTimeKind.Utc); - public static readonly byte[] DateTime_Min = + public static readonly byte[] DateTimeMin = { 0x00, 0x01, // Year 1 0x00, 0x01, // Month 1 @@ -23,7 +23,7 @@ internal static class IccTestDataNonPrimitives 0x00, 0x00, // Second 0 }; - public static readonly byte[] DateTime_Max = + public static readonly byte[] DateTimeMax = { 0x27, 0x0F, // Year 9999 0x00, 0x0C, // Month 12 @@ -33,7 +33,7 @@ internal static class IccTestDataNonPrimitives 0x00, 0x3B, // Second 59 }; - public static readonly byte[] DateTime_Invalid = + public static readonly byte[] DateTimeInvalid = { 0xFF, 0xFF, // Year 65535 0x00, 0x0E, // Month 14 @@ -43,7 +43,7 @@ internal static class IccTestDataNonPrimitives 0x00, 0x3D, // Second 61 }; - public static readonly byte[] DateTime_Rand1 = + public static readonly byte[] DateTimeRand1 = { 0x07, 0xC6, // Year 1990 0x00, 0x0B, // Month 11 @@ -55,135 +55,135 @@ internal static class IccTestDataNonPrimitives public static readonly object[][] DateTimeTestData = { - new object[] { DateTime_Min, DateTime_ValMin }, - new object[] { DateTime_Max, DateTime_ValMax }, - new object[] { DateTime_Rand1, DateTime_ValRand1 }, + new object[] { DateTimeMin, DateTimeValMin }, + new object[] { DateTimeMax, DateTimeValMax }, + new object[] { DateTimeRand1, DateTimeValRand1 }, }; - public static readonly IccVersion VersionNumber_ValMin = new IccVersion(0, 0, 0); - public static readonly IccVersion VersionNumber_Val211 = new IccVersion(2, 1, 1); - public static readonly IccVersion VersionNumber_Val430 = new IccVersion(4, 3, 0); - public static readonly IccVersion VersionNumber_ValMax = new IccVersion(255, 15, 15); + public static readonly IccVersion VersionNumberValMin = new(0, 0, 0); + public static readonly IccVersion VersionNumberVal211 = new(2, 1, 1); + public static readonly IccVersion VersionNumberVal430 = new(4, 3, 0); + public static readonly IccVersion VersionNumberValMax = new(255, 15, 15); - public static readonly byte[] VersionNumber_Min = { 0x00, 0x00, 0x00, 0x00 }; - public static readonly byte[] VersionNumber_211 = { 0x02, 0x11, 0x00, 0x00 }; - public static readonly byte[] VersionNumber_430 = { 0x04, 0x30, 0x00, 0x00 }; - public static readonly byte[] VersionNumber_Max = { 0xFF, 0xFF, 0x00, 0x00 }; + public static readonly byte[] VersionNumberMin = { 0x00, 0x00, 0x00, 0x00 }; + public static readonly byte[] VersionNumber211 = { 0x02, 0x11, 0x00, 0x00 }; + public static readonly byte[] VersionNumber430 = { 0x04, 0x30, 0x00, 0x00 }; + public static readonly byte[] VersionNumberMax = { 0xFF, 0xFF, 0x00, 0x00 }; public static readonly object[][] VersionNumberTestData = { - new object[] { VersionNumber_Min, VersionNumber_ValMin }, - new object[] { VersionNumber_211, VersionNumber_Val211 }, - new object[] { VersionNumber_430, VersionNumber_Val430 }, - new object[] { VersionNumber_Max, VersionNumber_ValMax }, + new object[] { VersionNumberMin, VersionNumberValMin }, + new object[] { VersionNumber211, VersionNumberVal211 }, + new object[] { VersionNumber430, VersionNumberVal430 }, + new object[] { VersionNumberMax, VersionNumberValMax }, }; - public static readonly Vector3 XyzNumber_ValMin = new Vector3(IccTestDataPrimitives.Fix16_ValMin, IccTestDataPrimitives.Fix16_ValMin, IccTestDataPrimitives.Fix16_ValMin); - public static readonly Vector3 XyzNumber_Val0 = new Vector3(0, 0, 0); - public static readonly Vector3 XyzNumber_Val1 = new Vector3(1, 1, 1); - public static readonly Vector3 XyzNumber_ValVar1 = new Vector3(1, 2, 3); - public static readonly Vector3 XyzNumber_ValVar2 = new Vector3(4, 5, 6); - public static readonly Vector3 XyzNumber_ValVar3 = new Vector3(7, 8, 9); - public static readonly Vector3 XyzNumber_ValMax = new Vector3(IccTestDataPrimitives.Fix16_ValMax, IccTestDataPrimitives.Fix16_ValMax, IccTestDataPrimitives.Fix16_ValMax); - - public static readonly byte[] XyzNumber_Min = ArrayHelper.Concat(IccTestDataPrimitives.Fix16_Min, IccTestDataPrimitives.Fix16_Min, IccTestDataPrimitives.Fix16_Min); - public static readonly byte[] XyzNumber_0 = ArrayHelper.Concat(IccTestDataPrimitives.Fix16_0, IccTestDataPrimitives.Fix16_0, IccTestDataPrimitives.Fix16_0); - public static readonly byte[] XyzNumber_1 = ArrayHelper.Concat(IccTestDataPrimitives.Fix16_1, IccTestDataPrimitives.Fix16_1, IccTestDataPrimitives.Fix16_1); - public static readonly byte[] XyzNumber_Var1 = ArrayHelper.Concat(IccTestDataPrimitives.Fix16_1, IccTestDataPrimitives.Fix16_2, IccTestDataPrimitives.Fix16_3); - public static readonly byte[] XyzNumber_Var2 = ArrayHelper.Concat(IccTestDataPrimitives.Fix16_4, IccTestDataPrimitives.Fix16_5, IccTestDataPrimitives.Fix16_6); - public static readonly byte[] XyzNumber_Var3 = ArrayHelper.Concat(IccTestDataPrimitives.Fix16_7, IccTestDataPrimitives.Fix16_8, IccTestDataPrimitives.Fix16_9); - public static readonly byte[] XyzNumber_Max = ArrayHelper.Concat(IccTestDataPrimitives.Fix16_Max, IccTestDataPrimitives.Fix16_Max, IccTestDataPrimitives.Fix16_Max); + public static readonly Vector3 XyzNumberValMin = new(IccTestDataPrimitives.Fix16ValMin, IccTestDataPrimitives.Fix16ValMin, IccTestDataPrimitives.Fix16ValMin); + public static readonly Vector3 XyzNumberVal0 = new(0, 0, 0); + public static readonly Vector3 XyzNumberVal1 = new(1, 1, 1); + public static readonly Vector3 XyzNumberValVar1 = new(1, 2, 3); + public static readonly Vector3 XyzNumberValVar2 = new(4, 5, 6); + public static readonly Vector3 XyzNumberValVar3 = new(7, 8, 9); + public static readonly Vector3 XyzNumberValMax = new(IccTestDataPrimitives.Fix16ValMax, IccTestDataPrimitives.Fix16ValMax, IccTestDataPrimitives.Fix16ValMax); + + public static readonly byte[] XyzNumberMin = ArrayHelper.Concat(IccTestDataPrimitives.Fix16Min, IccTestDataPrimitives.Fix16Min, IccTestDataPrimitives.Fix16Min); + public static readonly byte[] XyzNumber0 = ArrayHelper.Concat(IccTestDataPrimitives.Fix160, IccTestDataPrimitives.Fix160, IccTestDataPrimitives.Fix160); + public static readonly byte[] XyzNumber1 = ArrayHelper.Concat(IccTestDataPrimitives.Fix161, IccTestDataPrimitives.Fix161, IccTestDataPrimitives.Fix161); + public static readonly byte[] XyzNumberVar1 = ArrayHelper.Concat(IccTestDataPrimitives.Fix161, IccTestDataPrimitives.Fix162, IccTestDataPrimitives.Fix163); + public static readonly byte[] XyzNumberVar2 = ArrayHelper.Concat(IccTestDataPrimitives.Fix164, IccTestDataPrimitives.Fix165, IccTestDataPrimitives.Fix166); + public static readonly byte[] XyzNumberVar3 = ArrayHelper.Concat(IccTestDataPrimitives.Fix167, IccTestDataPrimitives.Fix168, IccTestDataPrimitives.Fix169); + public static readonly byte[] XyzNumberMax = ArrayHelper.Concat(IccTestDataPrimitives.Fix16Max, IccTestDataPrimitives.Fix16Max, IccTestDataPrimitives.Fix16Max); public static readonly object[][] XyzNumberTestData = { - new object[] { XyzNumber_Min, XyzNumber_ValMin }, - new object[] { XyzNumber_0, XyzNumber_Val0 }, - new object[] { XyzNumber_Var1, XyzNumber_ValVar1 }, - new object[] { XyzNumber_Max, XyzNumber_ValMax }, + new object[] { XyzNumberMin, XyzNumberValMin }, + new object[] { XyzNumber0, XyzNumberVal0 }, + new object[] { XyzNumberVar1, XyzNumberValVar1 }, + new object[] { XyzNumberMax, XyzNumberValMax }, }; - public static readonly IccProfileId ProfileId_ValMin = new IccProfileId(0, 0, 0, 0); - public static readonly IccProfileId ProfileId_ValRand = new IccProfileId(IccTestDataPrimitives.UInt32_ValRand1, IccTestDataPrimitives.UInt32_ValRand2, IccTestDataPrimitives.UInt32_ValRand3, IccTestDataPrimitives.UInt32_ValRand4); - public static readonly IccProfileId ProfileId_ValMax = new IccProfileId(uint.MaxValue, uint.MaxValue, uint.MaxValue, uint.MaxValue); + public static readonly IccProfileId ProfileIdValMin = new(0, 0, 0, 0); + public static readonly IccProfileId ProfileIdValRand = new(IccTestDataPrimitives.UInt32ValRand1, IccTestDataPrimitives.UInt32ValRand2, IccTestDataPrimitives.UInt32ValRand3, IccTestDataPrimitives.UInt32ValRand4); + public static readonly IccProfileId ProfileIdValMax = new(uint.MaxValue, uint.MaxValue, uint.MaxValue, uint.MaxValue); - public static readonly byte[] ProfileId_Min = ArrayHelper.Concat(IccTestDataPrimitives.UInt32_0, IccTestDataPrimitives.UInt32_0, IccTestDataPrimitives.UInt32_0, IccTestDataPrimitives.UInt32_0); - public static readonly byte[] ProfileId_Rand = ArrayHelper.Concat(IccTestDataPrimitives.UInt32_Rand1, IccTestDataPrimitives.UInt32_Rand2, IccTestDataPrimitives.UInt32_Rand3, IccTestDataPrimitives.UInt32_Rand4); - public static readonly byte[] ProfileId_Max = ArrayHelper.Concat(IccTestDataPrimitives.UInt32_Max, IccTestDataPrimitives.UInt32_Max, IccTestDataPrimitives.UInt32_Max, IccTestDataPrimitives.UInt32_Max); + public static readonly byte[] ProfileIdMin = ArrayHelper.Concat(IccTestDataPrimitives.UInt320, IccTestDataPrimitives.UInt320, IccTestDataPrimitives.UInt320, IccTestDataPrimitives.UInt320); + public static readonly byte[] ProfileIdRand = ArrayHelper.Concat(IccTestDataPrimitives.UInt32Rand1, IccTestDataPrimitives.UInt32Rand2, IccTestDataPrimitives.UInt32Rand3, IccTestDataPrimitives.UInt32Rand4); + public static readonly byte[] ProfileIdMax = ArrayHelper.Concat(IccTestDataPrimitives.UInt32Max, IccTestDataPrimitives.UInt32Max, IccTestDataPrimitives.UInt32Max, IccTestDataPrimitives.UInt32Max); public static readonly object[][] ProfileIdTestData = { - new object[] { ProfileId_Min, ProfileId_ValMin }, - new object[] { ProfileId_Rand, ProfileId_ValRand }, - new object[] { ProfileId_Max, ProfileId_ValMax }, + new object[] { ProfileIdMin, ProfileIdValMin }, + new object[] { ProfileIdRand, ProfileIdValRand }, + new object[] { ProfileIdMax, ProfileIdValMax }, }; - public static readonly IccPositionNumber PositionNumber_ValMin = new IccPositionNumber(0, 0); - public static readonly IccPositionNumber PositionNumber_ValRand = new IccPositionNumber(IccTestDataPrimitives.UInt32_ValRand1, IccTestDataPrimitives.UInt32_ValRand2); - public static readonly IccPositionNumber PositionNumber_ValMax = new IccPositionNumber(uint.MaxValue, uint.MaxValue); + public static readonly IccPositionNumber PositionNumberValMin = new(0, 0); + public static readonly IccPositionNumber PositionNumberValRand = new(IccTestDataPrimitives.UInt32ValRand1, IccTestDataPrimitives.UInt32ValRand2); + public static readonly IccPositionNumber PositionNumberValMax = new(uint.MaxValue, uint.MaxValue); - public static readonly byte[] PositionNumber_Min = ArrayHelper.Concat(IccTestDataPrimitives.UInt32_0, IccTestDataPrimitives.UInt32_0); - public static readonly byte[] PositionNumber_Rand = ArrayHelper.Concat(IccTestDataPrimitives.UInt32_Rand1, IccTestDataPrimitives.UInt32_Rand2); - public static readonly byte[] PositionNumber_Max = ArrayHelper.Concat(IccTestDataPrimitives.UInt32_Max, IccTestDataPrimitives.UInt32_Max); + public static readonly byte[] PositionNumberMin = ArrayHelper.Concat(IccTestDataPrimitives.UInt320, IccTestDataPrimitives.UInt320); + public static readonly byte[] PositionNumberRand = ArrayHelper.Concat(IccTestDataPrimitives.UInt32Rand1, IccTestDataPrimitives.UInt32Rand2); + public static readonly byte[] PositionNumberMax = ArrayHelper.Concat(IccTestDataPrimitives.UInt32Max, IccTestDataPrimitives.UInt32Max); public static readonly object[][] PositionNumberTestData = { - new object[] { PositionNumber_Min, PositionNumber_ValMin }, - new object[] { PositionNumber_Rand, PositionNumber_ValRand }, - new object[] { PositionNumber_Max, PositionNumber_ValMax }, + new object[] { PositionNumberMin, PositionNumberValMin }, + new object[] { PositionNumberRand, PositionNumberValRand }, + new object[] { PositionNumberMax, PositionNumberValMax }, }; - public static readonly IccResponseNumber ResponseNumber_ValMin = new IccResponseNumber(0, IccTestDataPrimitives.Fix16_ValMin); - public static readonly IccResponseNumber ResponseNumber_Val1 = new IccResponseNumber(1, 1); - public static readonly IccResponseNumber ResponseNumber_Val2 = new IccResponseNumber(2, 2); - public static readonly IccResponseNumber ResponseNumber_Val3 = new IccResponseNumber(3, 3); - public static readonly IccResponseNumber ResponseNumber_Val4 = new IccResponseNumber(4, 4); - public static readonly IccResponseNumber ResponseNumber_Val5 = new IccResponseNumber(5, 5); - public static readonly IccResponseNumber ResponseNumber_Val6 = new IccResponseNumber(6, 6); - public static readonly IccResponseNumber ResponseNumber_Val7 = new IccResponseNumber(7, 7); - public static readonly IccResponseNumber ResponseNumber_Val8 = new IccResponseNumber(8, 8); - public static readonly IccResponseNumber ResponseNumber_Val9 = new IccResponseNumber(9, 9); - public static readonly IccResponseNumber ResponseNumber_ValMax = new IccResponseNumber(ushort.MaxValue, IccTestDataPrimitives.Fix16_ValMax); - - public static readonly byte[] ResponseNumber_Min = ArrayHelper.Concat(IccTestDataPrimitives.UInt16_0, IccTestDataPrimitives.Fix16_Min); - public static readonly byte[] ResponseNumber_1 = ArrayHelper.Concat(IccTestDataPrimitives.UInt16_1, IccTestDataPrimitives.Fix16_1); - public static readonly byte[] ResponseNumber_2 = ArrayHelper.Concat(IccTestDataPrimitives.UInt16_2, IccTestDataPrimitives.Fix16_2); - public static readonly byte[] ResponseNumber_3 = ArrayHelper.Concat(IccTestDataPrimitives.UInt16_3, IccTestDataPrimitives.Fix16_3); - public static readonly byte[] ResponseNumber_4 = ArrayHelper.Concat(IccTestDataPrimitives.UInt16_4, IccTestDataPrimitives.Fix16_4); - public static readonly byte[] ResponseNumber_5 = ArrayHelper.Concat(IccTestDataPrimitives.UInt16_5, IccTestDataPrimitives.Fix16_5); - public static readonly byte[] ResponseNumber_6 = ArrayHelper.Concat(IccTestDataPrimitives.UInt16_6, IccTestDataPrimitives.Fix16_6); - public static readonly byte[] ResponseNumber_7 = ArrayHelper.Concat(IccTestDataPrimitives.UInt16_7, IccTestDataPrimitives.Fix16_7); - public static readonly byte[] ResponseNumber_8 = ArrayHelper.Concat(IccTestDataPrimitives.UInt16_8, IccTestDataPrimitives.Fix16_8); - public static readonly byte[] ResponseNumber_9 = ArrayHelper.Concat(IccTestDataPrimitives.UInt16_9, IccTestDataPrimitives.Fix16_9); - public static readonly byte[] ResponseNumber_Max = ArrayHelper.Concat(IccTestDataPrimitives.UInt16_Max, IccTestDataPrimitives.Fix16_Max); + public static readonly IccResponseNumber ResponseNumberValMin = new(0, IccTestDataPrimitives.Fix16ValMin); + public static readonly IccResponseNumber ResponseNumberVal1 = new(1, 1); + public static readonly IccResponseNumber ResponseNumberVal2 = new(2, 2); + public static readonly IccResponseNumber ResponseNumberVal3 = new(3, 3); + public static readonly IccResponseNumber ResponseNumberVal4 = new(4, 4); + public static readonly IccResponseNumber ResponseNumberVal5 = new(5, 5); + public static readonly IccResponseNumber ResponseNumberVal6 = new(6, 6); + public static readonly IccResponseNumber ResponseNumberVal7 = new(7, 7); + public static readonly IccResponseNumber ResponseNumberVal8 = new(8, 8); + public static readonly IccResponseNumber ResponseNumberVal9 = new(9, 9); + public static readonly IccResponseNumber ResponseNumberValMax = new(ushort.MaxValue, IccTestDataPrimitives.Fix16ValMax); + + public static readonly byte[] ResponseNumberMin = ArrayHelper.Concat(IccTestDataPrimitives.UInt160, IccTestDataPrimitives.Fix16Min); + public static readonly byte[] ResponseNumber1 = ArrayHelper.Concat(IccTestDataPrimitives.UInt161, IccTestDataPrimitives.Fix161); + public static readonly byte[] ResponseNumber2 = ArrayHelper.Concat(IccTestDataPrimitives.UInt162, IccTestDataPrimitives.Fix162); + public static readonly byte[] ResponseNumber3 = ArrayHelper.Concat(IccTestDataPrimitives.UInt163, IccTestDataPrimitives.Fix163); + public static readonly byte[] ResponseNumber4 = ArrayHelper.Concat(IccTestDataPrimitives.UInt164, IccTestDataPrimitives.Fix164); + public static readonly byte[] ResponseNumber5 = ArrayHelper.Concat(IccTestDataPrimitives.UInt165, IccTestDataPrimitives.Fix165); + public static readonly byte[] ResponseNumber6 = ArrayHelper.Concat(IccTestDataPrimitives.UInt166, IccTestDataPrimitives.Fix166); + public static readonly byte[] ResponseNumber7 = ArrayHelper.Concat(IccTestDataPrimitives.UInt167, IccTestDataPrimitives.Fix167); + public static readonly byte[] ResponseNumber8 = ArrayHelper.Concat(IccTestDataPrimitives.UInt168, IccTestDataPrimitives.Fix168); + public static readonly byte[] ResponseNumber9 = ArrayHelper.Concat(IccTestDataPrimitives.UInt169, IccTestDataPrimitives.Fix169); + public static readonly byte[] ResponseNumberMax = ArrayHelper.Concat(IccTestDataPrimitives.UInt16Max, IccTestDataPrimitives.Fix16Max); public static readonly object[][] ResponseNumberTestData = { - new object[] { ResponseNumber_Min, ResponseNumber_ValMin }, - new object[] { ResponseNumber_1, ResponseNumber_Val1 }, - new object[] { ResponseNumber_4, ResponseNumber_Val4 }, - new object[] { ResponseNumber_Max, ResponseNumber_ValMax }, + new object[] { ResponseNumberMin, ResponseNumberValMin }, + new object[] { ResponseNumber1, ResponseNumberVal1 }, + new object[] { ResponseNumber4, ResponseNumberVal4 }, + new object[] { ResponseNumberMax, ResponseNumberValMax }, }; - public static readonly IccNamedColor NamedColor_ValMin = new IccNamedColor( + public static readonly IccNamedColor NamedColorValMin = new( ArrayHelper.Fill('A', 31), new ushort[] { 0, 0, 0 }, new ushort[] { 0, 0, 0 }); - public static readonly IccNamedColor NamedColor_ValRand = new IccNamedColor( + public static readonly IccNamedColor NamedColorValRand = new( ArrayHelper.Fill('5', 31), new ushort[] { 10794, 10794, 10794 }, new ushort[] { 17219, 17219, 17219, 17219, 17219 }); - public static readonly IccNamedColor NamedColor_ValMax = new IccNamedColor( + public static readonly IccNamedColor NamedColorValMax = new( ArrayHelper.Fill('4', 31), - new ushort[] { ushort.MaxValue, ushort.MaxValue, ushort.MaxValue }, - new ushort[] { ushort.MaxValue, ushort.MaxValue, ushort.MaxValue, ushort.MaxValue }); + new[] { ushort.MaxValue, ushort.MaxValue, ushort.MaxValue }, + new[] { ushort.MaxValue, ushort.MaxValue, ushort.MaxValue, ushort.MaxValue }); - public static readonly byte[] NamedColor_Min = CreateNamedColor(3, 0x41, 0x00, 0x00); - public static readonly byte[] NamedColor_Rand = CreateNamedColor(5, 0x35, 42, 67); - public static readonly byte[] NamedColor_Max = CreateNamedColor(4, 0x34, 0xFF, 0xFF); + public static readonly byte[] NamedColorMin = CreateNamedColor(3, 0x41, 0x00, 0x00); + public static readonly byte[] NamedColorRand = CreateNamedColor(5, 0x35, 42, 67); + public static readonly byte[] NamedColorMax = CreateNamedColor(4, 0x34, 0xFF, 0xFF); - private static byte[] CreateNamedColor(int devCoordCount, byte name, byte pCS, byte device) + private static byte[] CreateNamedColor(int devCoordCount, byte name, byte pCs, byte device) { byte[] data = new byte[32 + 6 + (devCoordCount * 2)]; for (int i = 0; i < data.Length; i++) @@ -198,7 +198,7 @@ private static byte[] CreateNamedColor(int devCoordCount, byte name, byte pCS, b } else if (i < 32 + 6) { - data[i] = pCS; // PCS Coordinates + data[i] = pCs; // PCS Coordinates } else { @@ -211,145 +211,144 @@ private static byte[] CreateNamedColor(int devCoordCount, byte name, byte pCS, b public static readonly object[][] NamedColorTestData = { - new object[] { NamedColor_Min, NamedColor_ValMin, 3u }, - new object[] { NamedColor_Rand, NamedColor_ValRand, 5u }, - new object[] { NamedColor_Max, NamedColor_ValMax, 4u }, + new object[] { NamedColorMin, NamedColorValMin, 3u }, + new object[] { NamedColorRand, NamedColorValRand, 5u }, + new object[] { NamedColorMax, NamedColorValMax, 4u }, }; - private static readonly CultureInfo CultureEnUs = new CultureInfo("en-US"); - private static readonly CultureInfo CultureDeAT = new CultureInfo("de-AT"); + private static readonly CultureInfo CultureEnUs = new("en-US"); + private static readonly CultureInfo CultureDeAt = new("de-AT"); - private static readonly IccLocalizedString LocalizedString_Rand1 = new IccLocalizedString(CultureEnUs, IccTestDataPrimitives.Unicode_ValRand2); - private static readonly IccLocalizedString LocalizedString_Rand2 = new IccLocalizedString(CultureDeAT, IccTestDataPrimitives.Unicode_ValRand3); + private static readonly IccLocalizedString LocalizedStringRand1 = new(CultureEnUs, IccTestDataPrimitives.UnicodeValRand2); + private static readonly IccLocalizedString LocalizedStringRand2 = new(CultureDeAt, IccTestDataPrimitives.UnicodeValRand3); - private static readonly IccLocalizedString[] LocalizedString_RandArr1 = new IccLocalizedString[] - { - LocalizedString_Rand1, - LocalizedString_Rand2, + private static readonly IccLocalizedString[] LocalizedStringRandArr1 = { + LocalizedStringRand1, + LocalizedStringRand2, }; - private static readonly IccMultiLocalizedUnicodeTagDataEntry MultiLocalizedUnicode_Val = new IccMultiLocalizedUnicodeTagDataEntry(LocalizedString_RandArr1); - private static readonly byte[] MultiLocalizedUnicode_Arr = ArrayHelper.Concat( - IccTestDataPrimitives.UInt32_2, + private static readonly IccMultiLocalizedUnicodeTagDataEntry MultiLocalizedUnicodeVal = new(LocalizedStringRandArr1); + private static readonly byte[] MultiLocalizedUnicodeArr = ArrayHelper.Concat( + IccTestDataPrimitives.UInt322, new byte[] { 0x00, 0x00, 0x00, 0x0C }, // 12 - new byte[] { (byte)'e', (byte)'n', (byte)'U', (byte)'S' }, + new[] { (byte)'e', (byte)'n', (byte)'U', (byte)'S' }, new byte[] { 0x00, 0x00, 0x00, 0x0C }, // 12 new byte[] { 0x00, 0x00, 0x00, 0x28 }, // 40 - new byte[] { (byte)'d', (byte)'e', (byte)'A', (byte)'T' }, + new[] { (byte)'d', (byte)'e', (byte)'A', (byte)'T' }, new byte[] { 0x00, 0x00, 0x00, 0x0E }, // 14 new byte[] { 0x00, 0x00, 0x00, 0x34 }, // 52 - IccTestDataPrimitives.Unicode_Rand2, - IccTestDataPrimitives.Unicode_Rand3); + IccTestDataPrimitives.UnicodeRand2, + IccTestDataPrimitives.UnicodeRand3); - public static readonly IccTextDescriptionTagDataEntry TextDescription_Val1 = new IccTextDescriptionTagDataEntry( - IccTestDataPrimitives.Ascii_ValRand, - IccTestDataPrimitives.Unicode_ValRand1, + public static readonly IccTextDescriptionTagDataEntry TextDescriptionVal1 = new( + IccTestDataPrimitives.AsciiValRand, + IccTestDataPrimitives.UnicodeValRand1, ArrayHelper.Fill('A', 66), 1701729619, 2); - public static readonly byte[] TextDescription_Arr1 = ArrayHelper.Concat( + public static readonly byte[] TextDescriptionArr1 = ArrayHelper.Concat( new byte[] { 0x00, 0x00, 0x00, 0x0B }, // 11 - IccTestDataPrimitives.Ascii_Rand, + IccTestDataPrimitives.AsciiRand, new byte[] { 0x00 }, // Null terminator - new byte[] { (byte)'e', (byte)'n', (byte)'U', (byte)'S' }, + new[] { (byte)'e', (byte)'n', (byte)'U', (byte)'S' }, new byte[] { 0x00, 0x00, 0x00, 0x07 }, // 7 - IccTestDataPrimitives.Unicode_Rand2, + IccTestDataPrimitives.UnicodeRand2, new byte[] { 0x00, 0x00 }, // Null terminator new byte[] { 0x00, 0x02, 0x43 }, // 2, 67 ArrayHelper.Fill((byte)0x41, 66), new byte[] { 0x00 }); // Null terminator - public static readonly IccProfileDescription ProfileDescription_ValRand1 = new IccProfileDescription( + public static readonly IccProfileDescription ProfileDescriptionValRand1 = new( 1, 2, IccDeviceAttribute.ChromaBlackWhite | IccDeviceAttribute.ReflectivityMatte, IccProfileTag.ProfileDescription, - MultiLocalizedUnicode_Val.Texts, - MultiLocalizedUnicode_Val.Texts); + MultiLocalizedUnicodeVal.Texts, + MultiLocalizedUnicodeVal.Texts); - public static readonly IccProfileDescription ProfileDescription_ValRand2 = new IccProfileDescription( + public static readonly IccProfileDescription ProfileDescriptionValRand2 = new( 1, 2, IccDeviceAttribute.ChromaBlackWhite | IccDeviceAttribute.ReflectivityMatte, IccProfileTag.ProfileDescription, - new IccLocalizedString[] { LocalizedString_Rand1 }, - new IccLocalizedString[] { LocalizedString_Rand1 }); + new[] { LocalizedStringRand1 }, + new[] { LocalizedStringRand1 }); - public static readonly byte[] ProfileDescription_Rand1 = ArrayHelper.Concat( - IccTestDataPrimitives.UInt32_1, - IccTestDataPrimitives.UInt32_2, + public static readonly byte[] ProfileDescriptionRand1 = ArrayHelper.Concat( + IccTestDataPrimitives.UInt321, + IccTestDataPrimitives.UInt322, new byte[] { 0, 0, 0, 0, 0, 0, 0, 10 }, new byte[] { 0x64, 0x65, 0x73, 0x63 }, new byte[] { 0x6D, 0x6C, 0x75, 0x63 }, new byte[] { 0x00, 0x00, 0x00, 0x00 }, - MultiLocalizedUnicode_Arr, + MultiLocalizedUnicodeArr, new byte[] { 0x6D, 0x6C, 0x75, 0x63 }, new byte[] { 0x00, 0x00, 0x00, 0x00 }, - MultiLocalizedUnicode_Arr); + MultiLocalizedUnicodeArr); - public static readonly byte[] ProfileDescription_Rand2 = ArrayHelper.Concat( - IccTestDataPrimitives.UInt32_1, - IccTestDataPrimitives.UInt32_2, + public static readonly byte[] ProfileDescriptionRand2 = ArrayHelper.Concat( + IccTestDataPrimitives.UInt321, + IccTestDataPrimitives.UInt322, new byte[] { 0, 0, 0, 0, 0, 0, 0, 10 }, new byte[] { 0x64, 0x65, 0x73, 0x63 }, new byte[] { 0x64, 0x65, 0x73, 0x63 }, new byte[] { 0x00, 0x00, 0x00, 0x00 }, - TextDescription_Arr1, + TextDescriptionArr1, new byte[] { 0x64, 0x65, 0x73, 0x63 }, new byte[] { 0x00, 0x00, 0x00, 0x00 }, - TextDescription_Arr1); + TextDescriptionArr1); public static readonly object[][] ProfileDescriptionReadTestData = { - new object[] { ProfileDescription_Rand1, ProfileDescription_ValRand1 }, - new object[] { ProfileDescription_Rand2, ProfileDescription_ValRand2 }, + new object[] { ProfileDescriptionRand1, ProfileDescriptionValRand1 }, + new object[] { ProfileDescriptionRand2, ProfileDescriptionValRand2 }, }; public static readonly object[][] ProfileDescriptionWriteTestData = { - new object[] { ProfileDescription_Rand1, ProfileDescription_ValRand1 }, + new object[] { ProfileDescriptionRand1, ProfileDescriptionValRand1 }, }; - public static readonly IccColorantTableEntry ColorantTableEntry_ValRand1 = new IccColorantTableEntry(ArrayHelper.Fill('A', 31), 1, 2, 3); - public static readonly IccColorantTableEntry ColorantTableEntry_ValRand2 = new IccColorantTableEntry(ArrayHelper.Fill('4', 31), 4, 5, 6); + public static readonly IccColorantTableEntry ColorantTableEntryValRand1 = new(ArrayHelper.Fill('A', 31), 1, 2, 3); + public static readonly IccColorantTableEntry ColorantTableEntryValRand2 = new(ArrayHelper.Fill('4', 31), 4, 5, 6); - public static readonly byte[] ColorantTableEntry_Rand1 = ArrayHelper.Concat( + public static readonly byte[] ColorantTableEntryRand1 = ArrayHelper.Concat( ArrayHelper.Fill((byte)0x41, 31), new byte[1], // null terminator - IccTestDataPrimitives.UInt16_1, - IccTestDataPrimitives.UInt16_2, - IccTestDataPrimitives.UInt16_3); + IccTestDataPrimitives.UInt161, + IccTestDataPrimitives.UInt162, + IccTestDataPrimitives.UInt163); - public static readonly byte[] ColorantTableEntry_Rand2 = ArrayHelper.Concat( + public static readonly byte[] ColorantTableEntryRand2 = ArrayHelper.Concat( ArrayHelper.Fill((byte)0x34, 31), new byte[1], // null terminator - IccTestDataPrimitives.UInt16_4, - IccTestDataPrimitives.UInt16_5, - IccTestDataPrimitives.UInt16_6); + IccTestDataPrimitives.UInt164, + IccTestDataPrimitives.UInt165, + IccTestDataPrimitives.UInt166); public static readonly object[][] ColorantTableEntryTestData = { - new object[] { ColorantTableEntry_Rand1, ColorantTableEntry_ValRand1 }, - new object[] { ColorantTableEntry_Rand2, ColorantTableEntry_ValRand2 }, + new object[] { ColorantTableEntryRand1, ColorantTableEntryValRand1 }, + new object[] { ColorantTableEntryRand2, ColorantTableEntryValRand2 }, }; - public static readonly IccScreeningChannel ScreeningChannel_ValRand1 = new IccScreeningChannel(4, 6, IccScreeningSpotType.Cross); - public static readonly IccScreeningChannel ScreeningChannel_ValRand2 = new IccScreeningChannel(8, 5, IccScreeningSpotType.Diamond); + public static readonly IccScreeningChannel ScreeningChannelValRand1 = new(4, 6, IccScreeningSpotType.Cross); + public static readonly IccScreeningChannel ScreeningChannelValRand2 = new(8, 5, IccScreeningSpotType.Diamond); - public static readonly byte[] ScreeningChannel_Rand1 = ArrayHelper.Concat( - IccTestDataPrimitives.Fix16_4, - IccTestDataPrimitives.Fix16_6, - IccTestDataPrimitives.Int32_7); + public static readonly byte[] ScreeningChannelRand1 = ArrayHelper.Concat( + IccTestDataPrimitives.Fix164, + IccTestDataPrimitives.Fix166, + IccTestDataPrimitives.Int327); - public static readonly byte[] ScreeningChannel_Rand2 = ArrayHelper.Concat( - IccTestDataPrimitives.Fix16_8, - IccTestDataPrimitives.Fix16_5, - IccTestDataPrimitives.Int32_3); + public static readonly byte[] ScreeningChannelRand2 = ArrayHelper.Concat( + IccTestDataPrimitives.Fix168, + IccTestDataPrimitives.Fix165, + IccTestDataPrimitives.Int323); public static readonly object[][] ScreeningChannelTestData = { - new object[] { ScreeningChannel_Rand1, ScreeningChannel_ValRand1 }, - new object[] { ScreeningChannel_Rand2, ScreeningChannel_ValRand2 }, + new object[] { ScreeningChannelRand1, ScreeningChannelValRand1 }, + new object[] { ScreeningChannelRand2, ScreeningChannelValRand2 }, }; } diff --git a/tests/ImageSharp.Tests/TestDataIcc/IccTestDataPrimitives.cs b/tests/ImageSharp.Tests/TestDataIcc/IccTestDataPrimitives.cs index f8e8717273..88bb13d856 100644 --- a/tests/ImageSharp.Tests/TestDataIcc/IccTestDataPrimitives.cs +++ b/tests/ImageSharp.Tests/TestDataIcc/IccTestDataPrimitives.cs @@ -5,238 +5,238 @@ namespace SixLabors.ImageSharp.Tests; internal static class IccTestDataPrimitives { - public static readonly byte[] UInt16_0 = { 0x00, 0x00 }; - public static readonly byte[] UInt16_1 = { 0x00, 0x01 }; - public static readonly byte[] UInt16_2 = { 0x00, 0x02 }; - public static readonly byte[] UInt16_3 = { 0x00, 0x03 }; - public static readonly byte[] UInt16_4 = { 0x00, 0x04 }; - public static readonly byte[] UInt16_5 = { 0x00, 0x05 }; - public static readonly byte[] UInt16_6 = { 0x00, 0x06 }; - public static readonly byte[] UInt16_7 = { 0x00, 0x07 }; - public static readonly byte[] UInt16_8 = { 0x00, 0x08 }; - public static readonly byte[] UInt16_9 = { 0x00, 0x09 }; - public static readonly byte[] UInt16_32768 = { 0x80, 0x00 }; - public static readonly byte[] UInt16_Max = { 0xFF, 0xFF }; - - public static readonly byte[] Int16_Min = { 0x80, 0x00 }; - public static readonly byte[] Int16_0 = { 0x00, 0x00 }; - public static readonly byte[] Int16_1 = { 0x00, 0x01 }; - public static readonly byte[] Int16_2 = { 0x00, 0x02 }; - public static readonly byte[] Int16_3 = { 0x00, 0x03 }; - public static readonly byte[] Int16_4 = { 0x00, 0x04 }; - public static readonly byte[] Int16_5 = { 0x00, 0x05 }; - public static readonly byte[] Int16_6 = { 0x00, 0x06 }; - public static readonly byte[] Int16_7 = { 0x00, 0x07 }; - public static readonly byte[] Int16_8 = { 0x00, 0x08 }; - public static readonly byte[] Int16_9 = { 0x00, 0x09 }; - public static readonly byte[] Int16_Max = { 0x7F, 0xFF }; - - public static readonly byte[] UInt32_0 = { 0x00, 0x00, 0x00, 0x00 }; - public static readonly byte[] UInt32_1 = { 0x00, 0x00, 0x00, 0x01 }; - public static readonly byte[] UInt32_2 = { 0x00, 0x00, 0x00, 0x02 }; - public static readonly byte[] UInt32_3 = { 0x00, 0x00, 0x00, 0x03 }; - public static readonly byte[] UInt32_4 = { 0x00, 0x00, 0x00, 0x04 }; - public static readonly byte[] UInt32_5 = { 0x00, 0x00, 0x00, 0x05 }; - public static readonly byte[] UInt32_6 = { 0x00, 0x00, 0x00, 0x06 }; - public static readonly byte[] UInt32_7 = { 0x00, 0x00, 0x00, 0x07 }; - public static readonly byte[] UInt32_8 = { 0x00, 0x00, 0x00, 0x08 }; - public static readonly byte[] UInt32_9 = { 0x00, 0x00, 0x00, 0x09 }; - public static readonly byte[] UInt32_Max = { 0xFF, 0xFF, 0xFF, 0xFF }; - - public static readonly uint UInt32_ValRand1 = 1749014123; - public static readonly uint UInt32_ValRand2 = 3870560989; - public static readonly uint UInt32_ValRand3 = 1050090334; - public static readonly uint UInt32_ValRand4 = 3550252874; - - public static readonly byte[] UInt32_Rand1 = { 0x68, 0x3F, 0xD6, 0x6B }; - public static readonly byte[] UInt32_Rand2 = { 0xE6, 0xB4, 0x12, 0xDD }; - public static readonly byte[] UInt32_Rand3 = { 0x3E, 0x97, 0x1B, 0x5E }; - public static readonly byte[] UInt32_Rand4 = { 0xD3, 0x9C, 0x8F, 0x4A }; - - public static readonly byte[] Int32_Min = { 0x80, 0x00, 0x00, 0x00 }; - public static readonly byte[] Int32_0 = { 0x00, 0x00, 0x00, 0x00 }; - public static readonly byte[] Int32_1 = { 0x00, 0x00, 0x00, 0x01 }; - public static readonly byte[] Int32_2 = { 0x00, 0x00, 0x00, 0x02 }; - public static readonly byte[] Int32_3 = { 0x00, 0x00, 0x00, 0x03 }; - public static readonly byte[] Int32_4 = { 0x00, 0x00, 0x00, 0x04 }; - public static readonly byte[] Int32_5 = { 0x00, 0x00, 0x00, 0x05 }; - public static readonly byte[] Int32_6 = { 0x00, 0x00, 0x00, 0x06 }; - public static readonly byte[] Int32_7 = { 0x00, 0x00, 0x00, 0x07 }; - public static readonly byte[] Int32_8 = { 0x00, 0x00, 0x00, 0x08 }; - public static readonly byte[] Int32_9 = { 0x00, 0x00, 0x00, 0x09 }; - public static readonly byte[] Int32_Max = { 0x7F, 0xFF, 0xFF, 0xFF }; - - public static readonly byte[] UInt64_0 = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; - public static readonly byte[] UInt64_1 = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 }; - public static readonly byte[] UInt64_2 = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02 }; - public static readonly byte[] UInt64_3 = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03 }; - public static readonly byte[] UInt64_4 = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04 }; - public static readonly byte[] UInt64_5 = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05 }; - public static readonly byte[] UInt64_6 = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06 }; - public static readonly byte[] UInt64_7 = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07 }; - public static readonly byte[] UInt64_8 = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08 }; - public static readonly byte[] UInt64_9 = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x09 }; - public static readonly byte[] UInt64_Max = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF }; - - public static readonly byte[] Int64_Min = { 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; - public static readonly byte[] Int64_0 = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; - public static readonly byte[] Int64_1 = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 }; - public static readonly byte[] Int64_2 = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02 }; - public static readonly byte[] Int64_3 = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03 }; - public static readonly byte[] Int64_4 = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04 }; - public static readonly byte[] Int64_5 = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05 }; - public static readonly byte[] Int64_6 = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06 }; - public static readonly byte[] Int64_7 = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07 }; - public static readonly byte[] Int64_8 = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08 }; - public static readonly byte[] Int64_9 = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x09 }; - public static readonly byte[] Int64_Max = { 0x7F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF }; - - public static readonly byte[] Single_Min = { 0xFF, 0x7F, 0xFF, 0xFF }; - public static readonly byte[] Single_0 = { 0x00, 0x00, 0x00, 0x00 }; - public static readonly byte[] Single_1 = { 0x3F, 0x80, 0x00, 0x00 }; - public static readonly byte[] Single_2 = { 0x40, 0x00, 0x00, 0x00 }; - public static readonly byte[] Single_3 = { 0x40, 0x40, 0x00, 0x00 }; - public static readonly byte[] Single_4 = { 0x40, 0x80, 0x00, 0x00 }; - public static readonly byte[] Single_5 = { 0x40, 0xA0, 0x00, 0x00 }; - public static readonly byte[] Single_6 = { 0x40, 0xC0, 0x00, 0x00 }; - public static readonly byte[] Single_7 = { 0x40, 0xE0, 0x00, 0x00 }; - public static readonly byte[] Single_8 = { 0x41, 0x00, 0x00, 0x00 }; - public static readonly byte[] Single_9 = { 0x41, 0x10, 0x00, 0x00 }; - public static readonly byte[] Single_Max = { 0x7F, 0x7F, 0xFF, 0xFF }; - - public static readonly byte[] Double_Min = { 0xFF, 0xEF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF }; - public static readonly byte[] Double_0 = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; - public static readonly byte[] Double_1 = { 0x3F, 0xF0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; - public static readonly byte[] Double_Max = { 0x7F, 0xEF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF }; - - public const float Fix16_ValMin = short.MinValue; - public const float Fix16_ValMax = short.MaxValue + (65535f / 65536f); - - public static readonly byte[] Fix16_Min = { 0x80, 0x00, 0x00, 0x00 }; - public static readonly byte[] Fix16_0 = { 0x00, 0x00, 0x00, 0x00 }; - public static readonly byte[] Fix16_1 = { 0x00, 0x01, 0x00, 0x00 }; - public static readonly byte[] Fix16_2 = { 0x00, 0x02, 0x00, 0x00 }; - public static readonly byte[] Fix16_3 = { 0x00, 0x03, 0x00, 0x00 }; - public static readonly byte[] Fix16_4 = { 0x00, 0x04, 0x00, 0x00 }; - public static readonly byte[] Fix16_5 = { 0x00, 0x05, 0x00, 0x00 }; - public static readonly byte[] Fix16_6 = { 0x00, 0x06, 0x00, 0x00 }; - public static readonly byte[] Fix16_7 = { 0x00, 0x07, 0x00, 0x00 }; - public static readonly byte[] Fix16_8 = { 0x00, 0x08, 0x00, 0x00 }; - public static readonly byte[] Fix16_9 = { 0x00, 0x09, 0x00, 0x00 }; - public static readonly byte[] Fix16_Max = { 0x7F, 0xFF, 0xFF, 0xFF }; + public static readonly byte[] UInt160 = { 0x00, 0x00 }; + public static readonly byte[] UInt161 = { 0x00, 0x01 }; + public static readonly byte[] UInt162 = { 0x00, 0x02 }; + public static readonly byte[] UInt163 = { 0x00, 0x03 }; + public static readonly byte[] UInt164 = { 0x00, 0x04 }; + public static readonly byte[] UInt165 = { 0x00, 0x05 }; + public static readonly byte[] UInt166 = { 0x00, 0x06 }; + public static readonly byte[] UInt167 = { 0x00, 0x07 }; + public static readonly byte[] UInt168 = { 0x00, 0x08 }; + public static readonly byte[] UInt169 = { 0x00, 0x09 }; + public static readonly byte[] UInt1632768 = { 0x80, 0x00 }; + public static readonly byte[] UInt16Max = { 0xFF, 0xFF }; + + public static readonly byte[] Int16Min = { 0x80, 0x00 }; + public static readonly byte[] Int160 = { 0x00, 0x00 }; + public static readonly byte[] Int161 = { 0x00, 0x01 }; + public static readonly byte[] Int162 = { 0x00, 0x02 }; + public static readonly byte[] Int163 = { 0x00, 0x03 }; + public static readonly byte[] Int164 = { 0x00, 0x04 }; + public static readonly byte[] Int165 = { 0x00, 0x05 }; + public static readonly byte[] Int166 = { 0x00, 0x06 }; + public static readonly byte[] Int167 = { 0x00, 0x07 }; + public static readonly byte[] Int168 = { 0x00, 0x08 }; + public static readonly byte[] Int169 = { 0x00, 0x09 }; + public static readonly byte[] Int16Max = { 0x7F, 0xFF }; + + public static readonly byte[] UInt320 = { 0x00, 0x00, 0x00, 0x00 }; + public static readonly byte[] UInt321 = { 0x00, 0x00, 0x00, 0x01 }; + public static readonly byte[] UInt322 = { 0x00, 0x00, 0x00, 0x02 }; + public static readonly byte[] UInt323 = { 0x00, 0x00, 0x00, 0x03 }; + public static readonly byte[] UInt324 = { 0x00, 0x00, 0x00, 0x04 }; + public static readonly byte[] UInt325 = { 0x00, 0x00, 0x00, 0x05 }; + public static readonly byte[] UInt326 = { 0x00, 0x00, 0x00, 0x06 }; + public static readonly byte[] UInt327 = { 0x00, 0x00, 0x00, 0x07 }; + public static readonly byte[] UInt328 = { 0x00, 0x00, 0x00, 0x08 }; + public static readonly byte[] UInt329 = { 0x00, 0x00, 0x00, 0x09 }; + public static readonly byte[] UInt32Max = { 0xFF, 0xFF, 0xFF, 0xFF }; + + public static readonly uint UInt32ValRand1 = 1749014123; + public static readonly uint UInt32ValRand2 = 3870560989; + public static readonly uint UInt32ValRand3 = 1050090334; + public static readonly uint UInt32ValRand4 = 3550252874; + + public static readonly byte[] UInt32Rand1 = { 0x68, 0x3F, 0xD6, 0x6B }; + public static readonly byte[] UInt32Rand2 = { 0xE6, 0xB4, 0x12, 0xDD }; + public static readonly byte[] UInt32Rand3 = { 0x3E, 0x97, 0x1B, 0x5E }; + public static readonly byte[] UInt32Rand4 = { 0xD3, 0x9C, 0x8F, 0x4A }; + + public static readonly byte[] Int32Min = { 0x80, 0x00, 0x00, 0x00 }; + public static readonly byte[] Int320 = { 0x00, 0x00, 0x00, 0x00 }; + public static readonly byte[] Int321 = { 0x00, 0x00, 0x00, 0x01 }; + public static readonly byte[] Int322 = { 0x00, 0x00, 0x00, 0x02 }; + public static readonly byte[] Int323 = { 0x00, 0x00, 0x00, 0x03 }; + public static readonly byte[] Int324 = { 0x00, 0x00, 0x00, 0x04 }; + public static readonly byte[] Int325 = { 0x00, 0x00, 0x00, 0x05 }; + public static readonly byte[] Int326 = { 0x00, 0x00, 0x00, 0x06 }; + public static readonly byte[] Int327 = { 0x00, 0x00, 0x00, 0x07 }; + public static readonly byte[] Int328 = { 0x00, 0x00, 0x00, 0x08 }; + public static readonly byte[] Int329 = { 0x00, 0x00, 0x00, 0x09 }; + public static readonly byte[] Int32Max = { 0x7F, 0xFF, 0xFF, 0xFF }; + + public static readonly byte[] UInt640 = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; + public static readonly byte[] UInt641 = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 }; + public static readonly byte[] UInt642 = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02 }; + public static readonly byte[] UInt643 = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03 }; + public static readonly byte[] UInt644 = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04 }; + public static readonly byte[] UInt645 = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05 }; + public static readonly byte[] UInt646 = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06 }; + public static readonly byte[] UInt647 = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07 }; + public static readonly byte[] UInt648 = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08 }; + public static readonly byte[] UInt649 = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x09 }; + public static readonly byte[] UInt64Max = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF }; + + public static readonly byte[] Int64Min = { 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; + public static readonly byte[] Int640 = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; + public static readonly byte[] Int641 = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 }; + public static readonly byte[] Int642 = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02 }; + public static readonly byte[] Int643 = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03 }; + public static readonly byte[] Int644 = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04 }; + public static readonly byte[] Int645 = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05 }; + public static readonly byte[] Int646 = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06 }; + public static readonly byte[] Int647 = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07 }; + public static readonly byte[] Int648 = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08 }; + public static readonly byte[] Int649 = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x09 }; + public static readonly byte[] Int64Max = { 0x7F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF }; + + public static readonly byte[] SingleMin = { 0xFF, 0x7F, 0xFF, 0xFF }; + public static readonly byte[] Single0 = { 0x00, 0x00, 0x00, 0x00 }; + public static readonly byte[] Single1 = { 0x3F, 0x80, 0x00, 0x00 }; + public static readonly byte[] Single2 = { 0x40, 0x00, 0x00, 0x00 }; + public static readonly byte[] Single3 = { 0x40, 0x40, 0x00, 0x00 }; + public static readonly byte[] Single4 = { 0x40, 0x80, 0x00, 0x00 }; + public static readonly byte[] Single5 = { 0x40, 0xA0, 0x00, 0x00 }; + public static readonly byte[] Single6 = { 0x40, 0xC0, 0x00, 0x00 }; + public static readonly byte[] Single7 = { 0x40, 0xE0, 0x00, 0x00 }; + public static readonly byte[] Single8 = { 0x41, 0x00, 0x00, 0x00 }; + public static readonly byte[] Single9 = { 0x41, 0x10, 0x00, 0x00 }; + public static readonly byte[] SingleMax = { 0x7F, 0x7F, 0xFF, 0xFF }; + + public static readonly byte[] DoubleMin = { 0xFF, 0xEF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF }; + public static readonly byte[] Double0 = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; + public static readonly byte[] Double1 = { 0x3F, 0xF0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; + public static readonly byte[] DoubleMax = { 0x7F, 0xEF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF }; + + public const float Fix16ValMin = short.MinValue; + public const float Fix16ValMax = short.MaxValue + (65535f / 65536f); + + public static readonly byte[] Fix16Min = { 0x80, 0x00, 0x00, 0x00 }; + public static readonly byte[] Fix160 = { 0x00, 0x00, 0x00, 0x00 }; + public static readonly byte[] Fix161 = { 0x00, 0x01, 0x00, 0x00 }; + public static readonly byte[] Fix162 = { 0x00, 0x02, 0x00, 0x00 }; + public static readonly byte[] Fix163 = { 0x00, 0x03, 0x00, 0x00 }; + public static readonly byte[] Fix164 = { 0x00, 0x04, 0x00, 0x00 }; + public static readonly byte[] Fix165 = { 0x00, 0x05, 0x00, 0x00 }; + public static readonly byte[] Fix166 = { 0x00, 0x06, 0x00, 0x00 }; + public static readonly byte[] Fix167 = { 0x00, 0x07, 0x00, 0x00 }; + public static readonly byte[] Fix168 = { 0x00, 0x08, 0x00, 0x00 }; + public static readonly byte[] Fix169 = { 0x00, 0x09, 0x00, 0x00 }; + public static readonly byte[] Fix16Max = { 0x7F, 0xFF, 0xFF, 0xFF }; public static readonly object[][] Fix16TestData = { - new object[] { Fix16_Min, Fix16_ValMin }, - new object[] { Fix16_0, 0 }, - new object[] { Fix16_4, 4 }, - new object[] { Fix16_Max, Fix16_ValMax }, + new object[] { Fix16Min, Fix16ValMin }, + new object[] { Fix160, 0 }, + new object[] { Fix164, 4 }, + new object[] { Fix16Max, Fix16ValMax }, }; - public const float UFix16_ValMin = 0; - public const float UFix16_ValMax = ushort.MaxValue + (65535f / 65536f); - - public static readonly byte[] UFix16_0 = { 0x00, 0x00, 0x00, 0x00 }; - public static readonly byte[] UFix16_1 = { 0x00, 0x01, 0x00, 0x00 }; - public static readonly byte[] UFix16_2 = { 0x00, 0x02, 0x00, 0x00 }; - public static readonly byte[] UFix16_3 = { 0x00, 0x03, 0x00, 0x00 }; - public static readonly byte[] UFix16_4 = { 0x00, 0x04, 0x00, 0x00 }; - public static readonly byte[] UFix16_5 = { 0x00, 0x05, 0x00, 0x00 }; - public static readonly byte[] UFix16_6 = { 0x00, 0x06, 0x00, 0x00 }; - public static readonly byte[] UFix16_7 = { 0x00, 0x07, 0x00, 0x00 }; - public static readonly byte[] UFix16_8 = { 0x00, 0x08, 0x00, 0x00 }; - public static readonly byte[] UFix16_9 = { 0x00, 0x09, 0x00, 0x00 }; - public static readonly byte[] UFix16_Max = { 0xFF, 0xFF, 0xFF, 0xFF }; + public const float UFix16ValMin = 0; + public const float UFix16ValMax = ushort.MaxValue + (65535f / 65536f); + + public static readonly byte[] UFix160 = { 0x00, 0x00, 0x00, 0x00 }; + public static readonly byte[] UFix161 = { 0x00, 0x01, 0x00, 0x00 }; + public static readonly byte[] UFix162 = { 0x00, 0x02, 0x00, 0x00 }; + public static readonly byte[] UFix163 = { 0x00, 0x03, 0x00, 0x00 }; + public static readonly byte[] UFix164 = { 0x00, 0x04, 0x00, 0x00 }; + public static readonly byte[] UFix165 = { 0x00, 0x05, 0x00, 0x00 }; + public static readonly byte[] UFix166 = { 0x00, 0x06, 0x00, 0x00 }; + public static readonly byte[] UFix167 = { 0x00, 0x07, 0x00, 0x00 }; + public static readonly byte[] UFix168 = { 0x00, 0x08, 0x00, 0x00 }; + public static readonly byte[] UFix169 = { 0x00, 0x09, 0x00, 0x00 }; + public static readonly byte[] UFix16Max = { 0xFF, 0xFF, 0xFF, 0xFF }; public static readonly object[][] UFix16TestData = { - new object[] { UFix16_0, 0 }, - new object[] { UFix16_4, 4 }, - new object[] { UFix16_Max, UFix16_ValMax }, + new object[] { UFix160, 0 }, + new object[] { UFix164, 4 }, + new object[] { UFix16Max, UFix16ValMax }, }; - public const float U1Fix15_ValMin = 0; - public const float U1Fix15_ValMax = 1f + (32767f / 32768f); + public const float U1Fix15ValMin = 0; + public const float U1Fix15ValMax = 1f + (32767f / 32768f); - public static readonly byte[] U1Fix15_0 = { 0x00, 0x00 }; - public static readonly byte[] U1Fix15_1 = { 0x80, 0x00 }; - public static readonly byte[] U1Fix15_Max = { 0xFF, 0xFF }; + public static readonly byte[] U1Fix150 = { 0x00, 0x00 }; + public static readonly byte[] U1Fix151 = { 0x80, 0x00 }; + public static readonly byte[] U1Fix15Max = { 0xFF, 0xFF }; public static readonly object[][] U1Fix15TestData = { - new object[] { U1Fix15_0, 0 }, - new object[] { U1Fix15_1, 1 }, - new object[] { U1Fix15_Max, U1Fix15_ValMax }, + new object[] { U1Fix150, 0 }, + new object[] { U1Fix151, 1 }, + new object[] { U1Fix15Max, U1Fix15ValMax }, }; - public const float UFix8_ValMin = 0; - public const float UFix8_ValMax = byte.MaxValue + (255f / 256f); - - public static readonly byte[] UFix8_0 = { 0x00, 0x00 }; - public static readonly byte[] UFix8_1 = { 0x01, 0x00 }; - public static readonly byte[] UFix8_2 = { 0x02, 0x00 }; - public static readonly byte[] UFix8_3 = { 0x03, 0x00 }; - public static readonly byte[] UFix8_4 = { 0x04, 0x00 }; - public static readonly byte[] UFix8_5 = { 0x05, 0x00 }; - public static readonly byte[] UFix8_6 = { 0x06, 0x00 }; - public static readonly byte[] UFix8_7 = { 0x07, 0x00 }; - public static readonly byte[] UFix8_8 = { 0x08, 0x00 }; - public static readonly byte[] UFix8_9 = { 0x09, 0x00 }; - public static readonly byte[] UFix8_Max = { 0xFF, 0xFF }; + public const float UFix8ValMin = 0; + public const float UFix8ValMax = byte.MaxValue + (255f / 256f); + + public static readonly byte[] UFix80 = { 0x00, 0x00 }; + public static readonly byte[] UFix81 = { 0x01, 0x00 }; + public static readonly byte[] UFix82 = { 0x02, 0x00 }; + public static readonly byte[] UFix83 = { 0x03, 0x00 }; + public static readonly byte[] UFix84 = { 0x04, 0x00 }; + public static readonly byte[] UFix85 = { 0x05, 0x00 }; + public static readonly byte[] UFix86 = { 0x06, 0x00 }; + public static readonly byte[] UFix87 = { 0x07, 0x00 }; + public static readonly byte[] UFix88 = { 0x08, 0x00 }; + public static readonly byte[] UFix89 = { 0x09, 0x00 }; + public static readonly byte[] UFix8Max = { 0xFF, 0xFF }; public static readonly object[][] UFix8TestData = { - new object[] { UFix8_0, 0 }, - new object[] { UFix8_4, 4 }, - new object[] { UFix8_Max, UFix8_ValMax }, + new object[] { UFix80, 0 }, + new object[] { UFix84, 4 }, + new object[] { UFix8Max, UFix8ValMax }, }; - public const string Ascii_ValRand = "aBcdEf1234"; - public const string Ascii_ValRand1 = "Ecf3a"; - public const string Ascii_ValRand2 = "2Bd4c"; - public const string Ascii_ValRand3 = "cad14"; - public const string Ascii_ValRand4 = "fd4E1"; - public const string Ascii_ValRandLength4 = "aBcd"; - public const string Ascii_ValNullRand = "aBcd\0Ef\0123"; - - public static readonly byte[] Ascii_Rand = { 97, 66, 99, 100, 69, 102, 49, 50, 51, 52 }; - public static readonly byte[] Ascii_Rand1 = { 69, 99, 102, 51, 97 }; - public static readonly byte[] Ascii_Rand2 = { 50, 66, 100, 52, 99 }; - public static readonly byte[] Ascii_Rand3 = { 99, 97, 100, 49, 52 }; - public static readonly byte[] Ascii_Rand4 = { 102, 100, 52, 69, 49 }; - public static readonly byte[] Ascii_RandLength4 = { 97, 66, 99, 100 }; - public static readonly byte[] Ascii_PaddedRand = { 97, 66, 99, 100, 69, 102, 49, 50, 51, 52, 0, 0, 0, 0 }; - public static readonly byte[] Ascii_NullRand = { 97, 66, 99, 100, 0, 69, 102, 0, 49, 50, 51 }; - - public const int Ascii_Rand_Length = 10; - public const int Ascii_PaddedRand_Length = 14; - public const int Ascii_NullRand_Length = 11; - public const int Ascii_NullRand_LengthNoNull = 4; + public const string AsciiValRand = "aBcdEf1234"; + public const string AsciiValRand1 = "Ecf3a"; + public const string AsciiValRand2 = "2Bd4c"; + public const string AsciiValRand3 = "cad14"; + public const string AsciiValRand4 = "fd4E1"; + public const string AsciiValRandLength4 = "aBcd"; + public const string AsciiValNullRand = "aBcd\0Ef\0123"; + + public static readonly byte[] AsciiRand = { 97, 66, 99, 100, 69, 102, 49, 50, 51, 52 }; + public static readonly byte[] AsciiRand1 = { 69, 99, 102, 51, 97 }; + public static readonly byte[] AsciiRand2 = { 50, 66, 100, 52, 99 }; + public static readonly byte[] AsciiRand3 = { 99, 97, 100, 49, 52 }; + public static readonly byte[] AsciiRand4 = { 102, 100, 52, 69, 49 }; + public static readonly byte[] AsciiRandLength4 = { 97, 66, 99, 100 }; + public static readonly byte[] AsciiPaddedRand = { 97, 66, 99, 100, 69, 102, 49, 50, 51, 52, 0, 0, 0, 0 }; + public static readonly byte[] AsciiNullRand = { 97, 66, 99, 100, 0, 69, 102, 0, 49, 50, 51 }; + + public const int AsciiRandLength = 10; + public const int AsciiPaddedRandLength = 14; + public const int AsciiNullRandLength = 11; + public const int AsciiNullRandLengthNoNull = 4; public static readonly object[][] AsciiTestData = { - new object[] { Ascii_Rand, Ascii_Rand_Length, Ascii_ValRand }, - new object[] { Ascii_Rand, 4, Ascii_ValRandLength4 }, - new object[] { Ascii_NullRand, Ascii_NullRand_LengthNoNull, Ascii_ValRandLength4 }, + new object[] { AsciiRand, AsciiRandLength, AsciiValRand }, + new object[] { AsciiRand, 4, AsciiValRandLength4 }, + new object[] { AsciiNullRand, AsciiNullRandLengthNoNull, AsciiValRandLength4 }, }; public static readonly object[][] AsciiWriteTestData = { - new object[] { Ascii_Rand, Ascii_ValRand }, - new object[] { Ascii_NullRand, Ascii_ValNullRand }, + new object[] { AsciiRand, AsciiValRand }, + new object[] { AsciiNullRand, AsciiValNullRand }, }; public static readonly object[][] AsciiPaddingTestData = { - new object[] { Ascii_PaddedRand, Ascii_PaddedRand_Length, Ascii_ValRand, true }, - new object[] { Ascii_RandLength4, 4, Ascii_ValRand, false }, + new object[] { AsciiPaddedRand, AsciiPaddedRandLength, AsciiValRand, true }, + new object[] { AsciiRandLength4, 4, AsciiValRand, false }, }; - public const string Unicode_ValRand1 = ".6Abäñ$€β𐐷𤭢"; - public const string Unicode_ValRand2 = ".6Abäñ"; - public const string Unicode_ValRand3 = "$€β𐐷𤭢"; + public const string UnicodeValRand1 = ".6Abäñ$€β𐐷𤭢"; + public const string UnicodeValRand2 = ".6Abäñ"; + public const string UnicodeValRand3 = "$€β𐐷𤭢"; - public static readonly byte[] Unicode_Rand1 = + public static readonly byte[] UnicodeRand1 = { 0x00, 0x2e, // . 0x00, 0x36, // 6 @@ -251,7 +251,7 @@ internal static class IccTestDataPrimitives 0xD8, 0x52, 0xDF, 0x62, // 𤭢 }; - public static readonly byte[] Unicode_Rand2 = + public static readonly byte[] UnicodeRand2 = { 0x00, 0x2e, // . 0x00, 0x36, // 6 @@ -261,7 +261,7 @@ internal static class IccTestDataPrimitives 0x00, 0xf1, // ñ }; - public static readonly byte[] Unicode_Rand3 = + public static readonly byte[] UnicodeRand3 = { 0x00, 0x24, // $ 0x20, 0xAC, // € diff --git a/tests/ImageSharp.Tests/TestDataIcc/IccTestDataProfiles.cs b/tests/ImageSharp.Tests/TestDataIcc/IccTestDataProfiles.cs index 8fd6f7e4ae..f2766d3ac1 100644 --- a/tests/ImageSharp.Tests/TestDataIcc/IccTestDataProfiles.cs +++ b/tests/ImageSharp.Tests/TestDataIcc/IccTestDataProfiles.cs @@ -8,55 +8,50 @@ namespace SixLabors.ImageSharp.Tests; internal static class IccTestDataProfiles { - public static readonly IccProfileId Header_Random_Id_Value = new IccProfileId(0x84A8D460, 0xC716B6F3, 0x9B0E4C3D, 0xAB95F838); - public static readonly IccProfileId Profile_Random_Id_Value = new IccProfileId(0x917D6DE6, 0x84C958D1, 0x3BB0F5BB, 0xADD1134F); + public static readonly IccProfileId HeaderRandomIdValue = new(0x84A8D460, 0xC716B6F3, 0x9B0E4C3D, 0xAB95F838); + public static readonly IccProfileId ProfileRandomIdValue = new(0x917D6DE6, 0x84C958D1, 0x3BB0F5BB, 0xADD1134F); - public static readonly byte[] Header_Random_Id_Array = + public static readonly byte[] HeaderRandomIdArray = { 0x84, 0xA8, 0xD4, 0x60, 0xC7, 0x16, 0xB6, 0xF3, 0x9B, 0x0E, 0x4C, 0x3D, 0xAB, 0x95, 0xF8, 0x38, }; - public static readonly byte[] Profile_Random_Id_Array = + public static readonly byte[] ProfileRandomIdArray = { 0x91, 0x7D, 0x6D, 0xE6, 0x84, 0xC9, 0x58, 0xD1, 0x3B, 0xB0, 0xF5, 0xBB, 0xAD, 0xD1, 0x13, 0x4F, }; - public static readonly IccProfileHeader Header_Random_Write = CreateHeaderRandomValue( + public static readonly IccProfileHeader HeaderRandomWrite = CreateHeaderRandomValue( 562, // should be overwritten new IccProfileId(1, 2, 3, 4), // should be overwritten "ijkl"); // should be overwritten to "acsp" - public static readonly IccProfileHeader Header_Random_Read = CreateHeaderRandomValue(132, Header_Random_Id_Value, "acsp"); + public static readonly IccProfileHeader HeaderRandomRead = CreateHeaderRandomValue(132, HeaderRandomIdValue, "acsp"); - public static readonly byte[] Header_Random_Array = CreateHeaderRandomArray(132, 0, Header_Random_Id_Array); + public static readonly byte[] HeaderRandomArray = CreateHeaderRandomArray(132, 0, HeaderRandomIdArray); - public static IccProfileHeader CreateHeaderRandomValue(uint size, IccProfileId id, string fileSignature) + public static IccProfileHeader CreateHeaderRandomValue(uint size, IccProfileId id, string fileSignature) => new() { - return new IccProfileHeader - { - Class = IccProfileClass.DisplayDevice, - CmmType = "abcd", - CreationDate = new DateTime(1990, 11, 26, 7, 21, 42), - CreatorSignature = "dcba", - DataColorSpace = IccColorSpaceType.Rgb, - DeviceAttributes = IccDeviceAttribute.ChromaBlackWhite | IccDeviceAttribute.OpacityTransparent, - DeviceManufacturer = 123456789u, - DeviceModel = 987654321u, - FileSignature = "acsp", - Flags = IccProfileFlag.Embedded | IccProfileFlag.Independent, - Id = id, - PcsIlluminant = new Vector3(4, 5, 6), - PrimaryPlatformSignature = IccPrimaryPlatformType.MicrosoftCorporation, - ProfileConnectionSpace = IccColorSpaceType.CieXyz, - RenderingIntent = IccRenderingIntent.AbsoluteColorimetric, - Size = size, - Version = new IccVersion(4, 3, 0), - }; - } - - public static byte[] CreateHeaderRandomArray(uint size, uint nrOfEntries, byte[] profileId) - { - return ArrayHelper.Concat( + Class = IccProfileClass.DisplayDevice, + CmmType = "abcd", + CreationDate = new DateTime(1990, 11, 26, 7, 21, 42), + CreatorSignature = "dcba", + DataColorSpace = IccColorSpaceType.Rgb, + DeviceAttributes = IccDeviceAttribute.ChromaBlackWhite | IccDeviceAttribute.OpacityTransparent, + DeviceManufacturer = 123456789u, + DeviceModel = 987654321u, + FileSignature = "acsp", + Flags = IccProfileFlag.Embedded | IccProfileFlag.Independent, + Id = id, + PcsIlluminant = new Vector3(4, 5, 6), + PrimaryPlatformSignature = IccPrimaryPlatformType.MicrosoftCorporation, + ProfileConnectionSpace = IccColorSpaceType.CieXyz, + RenderingIntent = IccRenderingIntent.AbsoluteColorimetric, + Size = size, + Version = new IccVersion(4, 3, 0), + }; + + public static byte[] CreateHeaderRandomArray(uint size, uint nrOfEntries, byte[] profileId) => ArrayHelper.Concat( new byte[] { (byte)(size >> 24), (byte)(size >> 16), (byte)(size >> 8), (byte)size, // Size @@ -91,10 +86,9 @@ public static byte[] CreateHeaderRandomArray(uint size, uint nrOfEntries, byte[] (byte)(nrOfEntries >> 8), (byte)nrOfEntries }); - } - public static readonly byte[] Profile_Random_Array = ArrayHelper.Concat( - CreateHeaderRandomArray(168, 2, Profile_Random_Id_Array), + public static readonly byte[] ProfileRandomArray = ArrayHelper.Concat( + CreateHeaderRandomArray(168, 2, ProfileRandomIdArray), new byte[] { 0x00, 0x00, 0x00, 0x00, // tag signature (Unknown) @@ -104,17 +98,17 @@ public static byte[] CreateHeaderRandomArray(uint size, uint nrOfEntries, byte[] 0x00, 0x00, 0x00, 0x9C, // tag offset (156) 0x00, 0x00, 0x00, 0x0C, // tag size (12) }, - IccTestDataTagDataEntry.TagDataEntryHeader_UnknownArr, - IccTestDataTagDataEntry.Unknown_Arr); + IccTestDataTagDataEntry.TagDataEntryHeaderUnknownArr, + IccTestDataTagDataEntry.UnknownArr); - public static readonly IccProfile Profile_Random_Val = new IccProfile( + public static readonly IccProfile ProfileRandomVal = new( CreateHeaderRandomValue( 168, - Profile_Random_Id_Value, + ProfileRandomIdValue, "acsp"), - new IccTagDataEntry[] { IccTestDataTagDataEntry.Unknown_Val, IccTestDataTagDataEntry.Unknown_Val }); + new IccTagDataEntry[] { IccTestDataTagDataEntry.UnknownVal, IccTestDataTagDataEntry.UnknownVal }); - public static readonly byte[] Header_CorruptDataColorSpace_Array = + public static readonly byte[] HeaderCorruptDataColorSpaceArray = { 0x00, 0x00, 0x00, 0x80, // Size 0x61, 0x62, 0x63, 0x64, // CmmType @@ -143,7 +137,7 @@ public static byte[] CreateHeaderRandomArray(uint size, uint nrOfEntries, byte[] 0x00, 0x00, 0x00, 0x00, }; - public static readonly byte[] Header_CorruptProfileConnectionSpace_Array = + public static readonly byte[] HeaderCorruptProfileConnectionSpaceArray = { 0x00, 0x00, 0x00, 0x80, // Size 0x62, 0x63, 0x64, 0x65, // CmmType @@ -172,7 +166,7 @@ public static byte[] CreateHeaderRandomArray(uint size, uint nrOfEntries, byte[] 0x00, 0x00, 0x00, 0x00, }; - public static readonly byte[] Header_CorruptRenderingIntent_Array = + public static readonly byte[] HeaderCorruptRenderingIntentArray = { 0x00, 0x00, 0x00, 0x80, // Size 0x63, 0x64, 0x65, 0x66, // CmmType @@ -201,29 +195,29 @@ public static byte[] CreateHeaderRandomArray(uint size, uint nrOfEntries, byte[] 0x00, 0x00, 0x00, 0x00, }; - public static readonly byte[] Header_DataTooSmall_Array = new byte[127]; + public static readonly byte[] HeaderDataTooSmallArray = new byte[127]; - public static readonly byte[] Header_InvalidSizeSmall_Array = CreateHeaderRandomArray(127, 0, Header_Random_Id_Array); + public static readonly byte[] HeaderInvalidSizeSmallArray = CreateHeaderRandomArray(127, 0, HeaderRandomIdArray); - public static readonly byte[] Header_InvalidSizeBig_Array = CreateHeaderRandomArray(50_000_000, 0, Header_Random_Id_Array); + public static readonly byte[] HeaderInvalidSizeBigArray = CreateHeaderRandomArray(50_000_000, 0, HeaderRandomIdArray); - public static readonly byte[] Header_SizeBiggerThanData_Array = CreateHeaderRandomArray(160, 0, Header_Random_Id_Array); + public static readonly byte[] HeaderSizeBiggerThanDataArray = CreateHeaderRandomArray(160, 0, HeaderRandomIdArray); public static readonly object[][] ProfileIdTestData = { - new object[] { Header_Random_Array, Header_Random_Id_Value }, - new object[] { Profile_Random_Array, Profile_Random_Id_Value }, + new object[] { HeaderRandomArray, HeaderRandomIdValue }, + new object[] { ProfileRandomArray, ProfileRandomIdValue }, }; public static readonly object[][] ProfileValidityTestData = { - new object[] { Header_CorruptDataColorSpace_Array, false }, - new object[] { Header_CorruptProfileConnectionSpace_Array, false }, - new object[] { Header_CorruptRenderingIntent_Array, false }, - new object[] { Header_DataTooSmall_Array, false }, - new object[] { Header_InvalidSizeSmall_Array, false }, - new object[] { Header_InvalidSizeBig_Array, false }, - new object[] { Header_SizeBiggerThanData_Array, false }, - new object[] { Header_Random_Array, true }, + new object[] { HeaderCorruptDataColorSpaceArray, false }, + new object[] { HeaderCorruptProfileConnectionSpaceArray, false }, + new object[] { HeaderCorruptRenderingIntentArray, false }, + new object[] { HeaderDataTooSmallArray, false }, + new object[] { HeaderInvalidSizeSmallArray, false }, + new object[] { HeaderInvalidSizeBigArray, false }, + new object[] { HeaderSizeBiggerThanDataArray, false }, + new object[] { HeaderRandomArray, true }, }; } diff --git a/tests/ImageSharp.Tests/TestDataIcc/IccTestDataTagDataEntry.cs b/tests/ImageSharp.Tests/TestDataIcc/IccTestDataTagDataEntry.cs index 69d375cedf..6c010a5f03 100644 --- a/tests/ImageSharp.Tests/TestDataIcc/IccTestDataTagDataEntry.cs +++ b/tests/ImageSharp.Tests/TestDataIcc/IccTestDataTagDataEntry.cs @@ -9,22 +9,22 @@ namespace SixLabors.ImageSharp.Tests; internal static class IccTestDataTagDataEntry { - public static readonly IccTypeSignature TagDataEntryHeader_UnknownVal = IccTypeSignature.Unknown; - public static readonly byte[] TagDataEntryHeader_UnknownArr = + public static readonly IccTypeSignature TagDataEntryHeaderUnknownVal = IccTypeSignature.Unknown; + public static readonly byte[] TagDataEntryHeaderUnknownArr = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, }; - public static readonly IccTypeSignature TagDataEntryHeader_MultiLocalizedUnicodeVal = IccTypeSignature.MultiLocalizedUnicode; - public static readonly byte[] TagDataEntryHeader_MultiLocalizedUnicodeArr = + public static readonly IccTypeSignature TagDataEntryHeaderMultiLocalizedUnicodeVal = IccTypeSignature.MultiLocalizedUnicode; + public static readonly byte[] TagDataEntryHeaderMultiLocalizedUnicodeArr = { 0x6D, 0x6C, 0x75, 0x63, 0x00, 0x00, 0x00, 0x00, }; - public static readonly IccTypeSignature TagDataEntryHeader_CurveVal = IccTypeSignature.Curve; - public static readonly byte[] TagDataEntryHeader_CurveArr = + public static readonly IccTypeSignature TagDataEntryHeaderCurveVal = IccTypeSignature.Curve; + public static readonly byte[] TagDataEntryHeaderCurveArr = { 0x63, 0x75, 0x72, 0x76, 0x00, 0x00, 0x00, 0x00, @@ -32,24 +32,24 @@ internal static class IccTestDataTagDataEntry public static readonly object[][] TagDataEntryHeaderTestData = { - new object[] { TagDataEntryHeader_UnknownArr, TagDataEntryHeader_UnknownVal }, - new object[] { TagDataEntryHeader_MultiLocalizedUnicodeArr, TagDataEntryHeader_MultiLocalizedUnicodeVal }, - new object[] { TagDataEntryHeader_CurveArr, TagDataEntryHeader_CurveVal }, + new object[] { TagDataEntryHeaderUnknownArr, TagDataEntryHeaderUnknownVal }, + new object[] { TagDataEntryHeaderMultiLocalizedUnicodeArr, TagDataEntryHeaderMultiLocalizedUnicodeVal }, + new object[] { TagDataEntryHeaderCurveArr, TagDataEntryHeaderCurveVal }, }; - public static readonly IccUnknownTagDataEntry Unknown_Val = new(new byte[] { 0x00, 0x01, 0x02, 0x03 }); + public static readonly IccUnknownTagDataEntry UnknownVal = new(new byte[] { 0x00, 0x01, 0x02, 0x03 }); - public static readonly byte[] Unknown_Arr = { 0x00, 0x01, 0x02, 0x03 }; + public static readonly byte[] UnknownArr = { 0x00, 0x01, 0x02, 0x03 }; public static readonly object[][] UnknownTagDataEntryTestData = { - new object[] { Unknown_Arr, Unknown_Val, 12u }, + new object[] { UnknownArr, UnknownVal, 12u }, }; - public static readonly IccChromaticityTagDataEntry Chromaticity_Val1 = new(IccColorantEncoding.ItuRBt709_2); - public static readonly byte[] Chromaticity_Arr1 = ArrayHelper.Concat( - IccTestDataPrimitives.UInt16_3, - IccTestDataPrimitives.UInt16_1, + public static readonly IccChromaticityTagDataEntry ChromaticityVal1 = new(IccColorantEncoding.ItuRBt709_2); + public static readonly byte[] ChromaticityArr1 = ArrayHelper.Concat( + IccTestDataPrimitives.UInt163, + IccTestDataPrimitives.UInt161, new byte[] { 0x00, 0x00, 0xA3, 0xD7 }, // 0.640 new byte[] { 0x00, 0x00, 0x54, 0x7B }, // 0.330 new byte[] { 0x00, 0x00, 0x4C, 0xCD }, // 0.300 @@ -57,103 +57,99 @@ internal static class IccTestDataTagDataEntry new byte[] { 0x00, 0x00, 0x26, 0x66 }, // 0.150 new byte[] { 0x00, 0x00, 0x0F, 0x5C }); // 0.060 - public static readonly IccChromaticityTagDataEntry Chromaticity_Val2 = new( - new double[][] + public static readonly IccChromaticityTagDataEntry ChromaticityVal2 = new( + new[] { new double[] { 1, 2 }, new double[] { 3, 4 }, }); - public static readonly byte[] Chromaticity_Arr2 = ArrayHelper.Concat( - IccTestDataPrimitives.UInt16_2, - IccTestDataPrimitives.UInt16_0, - IccTestDataPrimitives.UFix16_1, - IccTestDataPrimitives.UFix16_2, - IccTestDataPrimitives.UFix16_3, - IccTestDataPrimitives.UFix16_4); + public static readonly byte[] ChromaticityArr2 = ArrayHelper.Concat( + IccTestDataPrimitives.UInt162, + IccTestDataPrimitives.UInt160, + IccTestDataPrimitives.UFix161, + IccTestDataPrimitives.UFix162, + IccTestDataPrimitives.UFix163, + IccTestDataPrimitives.UFix164); /// /// : channel count must be 3 for any enum other than /// - public static readonly byte[] Chromaticity_ArrInvalid1 = ArrayHelper.Concat( - IccTestDataPrimitives.UInt16_5, - IccTestDataPrimitives.UInt16_1); + public static readonly byte[] ChromaticityArrInvalid1 = ArrayHelper.Concat( + IccTestDataPrimitives.UInt165, + IccTestDataPrimitives.UInt161); /// /// : invalid enum value /// - public static readonly byte[] Chromaticity_ArrInvalid2 = ArrayHelper.Concat( - IccTestDataPrimitives.UInt16_3, - IccTestDataPrimitives.UInt16_9); + public static readonly byte[] ChromaticityArrInvalid2 = ArrayHelper.Concat( + IccTestDataPrimitives.UInt163, + IccTestDataPrimitives.UInt169); public static readonly object[][] ChromaticityTagDataEntryTestData = { - new object[] { Chromaticity_Arr1, Chromaticity_Val1 }, - new object[] { Chromaticity_Arr2, Chromaticity_Val2 }, + new object[] { ChromaticityArr1, ChromaticityVal1 }, + new object[] { ChromaticityArr2, ChromaticityVal2 }, }; - public static readonly IccColorantOrderTagDataEntry ColorantOrder_Val = new(new byte[] { 0x00, 0x01, 0x02 }); - public static readonly byte[] ColorantOrder_Arr = ArrayHelper.Concat(IccTestDataPrimitives.UInt32_3, new byte[] { 0x00, 0x01, 0x02 }); + public static readonly IccColorantOrderTagDataEntry ColorantOrderVal = new(new byte[] { 0x00, 0x01, 0x02 }); + public static readonly byte[] ColorantOrderArr = ArrayHelper.Concat(IccTestDataPrimitives.UInt323, new byte[] { 0x00, 0x01, 0x02 }); public static readonly object[][] ColorantOrderTagDataEntryTestData = { - new object[] { ColorantOrder_Arr, ColorantOrder_Val }, + new object[] { ColorantOrderArr, ColorantOrderVal }, }; - public static readonly IccColorantTableTagDataEntry ColorantTable_Val = new( - new IccColorantTableEntry[] + public static readonly IccColorantTableTagDataEntry ColorantTableVal = new( + new[] { - IccTestDataNonPrimitives.ColorantTableEntry_ValRand1, - IccTestDataNonPrimitives.ColorantTableEntry_ValRand2 + IccTestDataNonPrimitives.ColorantTableEntryValRand1, + IccTestDataNonPrimitives.ColorantTableEntryValRand2 }); - public static readonly byte[] ColorantTable_Arr = ArrayHelper.Concat( - IccTestDataPrimitives.UInt32_2, - IccTestDataNonPrimitives.ColorantTableEntry_Rand1, - IccTestDataNonPrimitives.ColorantTableEntry_Rand2); + public static readonly byte[] ColorantTableArr = ArrayHelper.Concat( + IccTestDataPrimitives.UInt322, + IccTestDataNonPrimitives.ColorantTableEntryRand1, + IccTestDataNonPrimitives.ColorantTableEntryRand2); public static readonly object[][] ColorantTableTagDataEntryTestData = { - new object[] { ColorantTable_Arr, ColorantTable_Val }, + new object[] { ColorantTableArr, ColorantTableVal }, }; - public static readonly IccCurveTagDataEntry Curve_Val_0 = new(); - public static readonly byte[] Curve_Arr_0 = IccTestDataPrimitives.UInt32_0; + public static readonly IccCurveTagDataEntry CurveVal0 = new(); + public static readonly byte[] CurveArr0 = IccTestDataPrimitives.UInt320; - public static readonly IccCurveTagDataEntry Curve_Val_1 = new(1f); - public static readonly byte[] Curve_Arr_1 = ArrayHelper.Concat( - IccTestDataPrimitives.UInt32_1, - IccTestDataPrimitives.UFix8_1); + public static readonly IccCurveTagDataEntry CurveVal1 = new(1f); + public static readonly byte[] CurveArr1 = ArrayHelper.Concat( + IccTestDataPrimitives.UInt321, + IccTestDataPrimitives.UFix81); - public static readonly IccCurveTagDataEntry Curve_Val_2 = new(new float[] { 1 / 65535f, 2 / 65535f, 3 / 65535f }); - public static readonly byte[] Curve_Arr_2 = ArrayHelper.Concat( - IccTestDataPrimitives.UInt32_3, - IccTestDataPrimitives.UInt16_1, - IccTestDataPrimitives.UInt16_2, - IccTestDataPrimitives.UInt16_3); + public static readonly IccCurveTagDataEntry CurveVal2 = new(new float[] { 1 / 65535f, 2 / 65535f, 3 / 65535f }); + public static readonly byte[] CurveArr2 = ArrayHelper.Concat( + IccTestDataPrimitives.UInt323, + IccTestDataPrimitives.UInt161, + IccTestDataPrimitives.UInt162, + IccTestDataPrimitives.UInt163); public static readonly object[][] CurveTagDataEntryTestData = { - new object[] { Curve_Arr_0, Curve_Val_0 }, - new object[] { Curve_Arr_1, Curve_Val_1 }, - new object[] { Curve_Arr_2, Curve_Val_2 }, + new object[] { CurveArr0, CurveVal0 }, + new object[] { CurveArr1, CurveVal1 }, + new object[] { CurveArr2, CurveVal2 }, }; - public static readonly IccDataTagDataEntry Data_ValNoASCII = new( - new byte[] { 0x01, 0x02, 0x03, 0x04 }, - false); + public static readonly IccDataTagDataEntry DataValNoAscii = new(new byte[] { 0x01, 0x02, 0x03, 0x04 }, false); - public static readonly byte[] Data_ArrNoASCII = + public static readonly byte[] DataArrNoAscii = { 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x03, 0x04 }; - public static readonly IccDataTagDataEntry Data_ValASCII = new( - new byte[] { (byte)'A', (byte)'S', (byte)'C', (byte)'I', (byte)'I' }, - true); + public static readonly IccDataTagDataEntry DataValAscii = new(new[] { (byte)'A', (byte)'S', (byte)'C', (byte)'I', (byte)'I' }, true); - public static readonly byte[] Data_ArrASCII = + public static readonly byte[] DataArrAscii = { 0x00, 0x00, 0x00, 0x01, (byte)'A', (byte)'S', (byte)'C', (byte)'I', (byte)'I' @@ -161,86 +157,77 @@ internal static class IccTestDataTagDataEntry public static readonly object[][] DataTagDataEntryTestData = { - new object[] { Data_ArrNoASCII, Data_ValNoASCII, 16u }, - new object[] { Data_ArrASCII, Data_ValASCII, 17u }, + new object[] { DataArrNoAscii, DataValNoAscii, 16u }, + new object[] { DataArrAscii, DataValAscii, 17u }, }; - public static readonly IccDateTimeTagDataEntry DateTime_Val = new(IccTestDataNonPrimitives.DateTime_ValRand1); - public static readonly byte[] DateTime_Arr = IccTestDataNonPrimitives.DateTime_Rand1; + public static readonly IccDateTimeTagDataEntry DateTimeVal = new(IccTestDataNonPrimitives.DateTimeValRand1); + public static readonly byte[] DateTimeArr = IccTestDataNonPrimitives.DateTimeRand1; public static readonly object[][] DateTimeTagDataEntryTestData = { - new object[] { DateTime_Arr, DateTime_Val }, + new object[] { DateTimeArr, DateTimeVal }, }; - public static readonly IccLut16TagDataEntry Lut16_Val = new( - new IccLut[] { IccTestDataLut.LUT16_ValGrad, IccTestDataLut.LUT16_ValGrad }, - IccTestDataLut.CLUT16_ValGrad, - new IccLut[] { IccTestDataLut.LUT16_ValGrad, IccTestDataLut.LUT16_ValGrad, IccTestDataLut.LUT16_ValGrad }); + public static readonly IccLut16TagDataEntry Lut16Val = new( + new[] { IccTestDataLut.Lut16ValGrad, IccTestDataLut.Lut16ValGrad }, + IccTestDataLut.Clut16ValGrad, + new[] { IccTestDataLut.Lut16ValGrad, IccTestDataLut.Lut16ValGrad, IccTestDataLut.Lut16ValGrad }); - public static readonly byte[] Lut16_Arr = ArrayHelper.Concat( + public static readonly byte[] Lut16Arr = ArrayHelper.Concat( new byte[] { 0x02, 0x03, 0x03, 0x00 }, - IccTestDataMatrix.Fix16_2D_Identity, - new byte[] { 0x00, (byte)IccTestDataLut.LUT16_ValGrad.Values.Length, 0x00, (byte)IccTestDataLut.LUT16_ValGrad.Values.Length }, - IccTestDataLut.LUT16_Grad, - IccTestDataLut.LUT16_Grad, - IccTestDataLut.CLUT16_Grad, - IccTestDataLut.LUT16_Grad, - IccTestDataLut.LUT16_Grad, - IccTestDataLut.LUT16_Grad); + IccTestDataMatrix.Fix162DIdentity, + new byte[] { 0x00, (byte)IccTestDataLut.Lut16ValGrad.Values.Length, 0x00, (byte)IccTestDataLut.Lut16ValGrad.Values.Length }, + IccTestDataLut.Lut16Grad, + IccTestDataLut.Lut16Grad, + IccTestDataLut.Clut16Grad, + IccTestDataLut.Lut16Grad, + IccTestDataLut.Lut16Grad, + IccTestDataLut.Lut16Grad); public static readonly object[][] Lut16TagDataEntryTestData = { - new object[] { Lut16_Arr, Lut16_Val }, + new object[] { Lut16Arr, Lut16Val }, }; - public static readonly IccLut8TagDataEntry Lut8_Val = new( - new IccLut[] { IccTestDataLut.LUT8_ValGrad, IccTestDataLut.LUT8_ValGrad }, - IccTestDataLut.CLUT8_ValGrad, - new IccLut[] { IccTestDataLut.LUT8_ValGrad, IccTestDataLut.LUT8_ValGrad, IccTestDataLut.LUT8_ValGrad }); + public static readonly IccLut8TagDataEntry Lut8Val = new( + new IccLut[] { IccTestDataLut.Lut8ValGrad, IccTestDataLut.Lut8ValGrad }, + IccTestDataLut.Clut8ValGrad, + new IccLut[] { IccTestDataLut.Lut8ValGrad, IccTestDataLut.Lut8ValGrad, IccTestDataLut.Lut8ValGrad }); - public static readonly byte[] Lut8_Arr = ArrayHelper.Concat( + public static readonly byte[] Lut8Arr = ArrayHelper.Concat( new byte[] { 0x02, 0x03, 0x03, 0x00 }, - IccTestDataMatrix.Fix16_2D_Identity, - IccTestDataLut.LUT8_Grad, - IccTestDataLut.LUT8_Grad, - IccTestDataLut.CLUT8_Grad, - IccTestDataLut.LUT8_Grad, - IccTestDataLut.LUT8_Grad, - IccTestDataLut.LUT8_Grad); + IccTestDataMatrix.Fix162DIdentity, + IccTestDataLut.Lut8Grad, + IccTestDataLut.Lut8Grad, + IccTestDataLut.Clut8Grad, + IccTestDataLut.Lut8Grad, + IccTestDataLut.Lut8Grad, + IccTestDataLut.Lut8Grad); - public static readonly object[][] Lut8TagDataEntryTestData = - { - new object[] { Lut8_Arr, Lut8_Val }, - }; + public static readonly object[][] Lut8TagDataEntryTestData = { new object[] { Lut8Arr, Lut8Val }, }; - private static readonly byte[] CurveFull_0 = ArrayHelper.Concat( - TagDataEntryHeader_CurveArr, - Curve_Arr_0); + private static readonly byte[] CurveFull0 = ArrayHelper.Concat(TagDataEntryHeaderCurveArr, CurveArr0); - private static readonly byte[] CurveFull_1 = ArrayHelper.Concat( - TagDataEntryHeader_CurveArr, - Curve_Arr_1); + private static readonly byte[] CurveFull1 = ArrayHelper.Concat(TagDataEntryHeaderCurveArr, CurveArr1); - private static readonly byte[] CurveFull_2 = ArrayHelper.Concat( - TagDataEntryHeader_CurveArr, - Curve_Arr_2); + private static readonly byte[] CurveFull2 = ArrayHelper.Concat(TagDataEntryHeaderCurveArr, CurveArr2); - public static readonly IccLutAToBTagDataEntry LutAToB_Val + public static readonly IccLutAToBTagDataEntry LutAToBVal = new( - new IccCurveTagDataEntry[] + new[] { - Curve_Val_0, - Curve_Val_1, - Curve_Val_2, + CurveVal0, + CurveVal1, + CurveVal2, }, - IccTestDataMatrix.Single_2DArray_ValGrad, - IccTestDataMatrix.Single_1DArray_ValGrad, - new IccCurveTagDataEntry[] { Curve_Val_1, Curve_Val_2, Curve_Val_0 }, - IccTestDataLut.CLUT_Val16, - new IccCurveTagDataEntry[] { Curve_Val_2, Curve_Val_1 }); + IccTestDataMatrix.Single2DArrayValGrad, + IccTestDataMatrix.Single1DArrayValGrad, + new[] { CurveVal1, CurveVal2, CurveVal0 }, + IccTestDataLut.ClutVal16, + new[] { CurveVal2, CurveVal1 }); - public static readonly byte[] LutAToB_Arr = ArrayHelper.Concat( + public static readonly byte[] LutAToBArr = ArrayHelper.Concat( new byte[] { 0x02, 0x03, 0x00, 0x00 }, new byte[] { 0x00, 0x00, 0x00, 0x20 }, // b: 32 new byte[] { 0x00, 0x00, 0x00, 0x50 }, // matrix: 80 @@ -249,51 +236,48 @@ public static readonly IccLutAToBTagDataEntry LutAToB_Val new byte[] { 0x00, 0x00, 0x00, 0xFC }, // a: 252 // B - CurveFull_0, // 12 bytes - CurveFull_1, // 14 bytes + CurveFull0, // 12 bytes + CurveFull1, // 14 bytes new byte[] { 0x00, 0x00 }, // Padding - CurveFull_2, // 18 bytes + CurveFull2, // 18 bytes new byte[] { 0x00, 0x00 }, // Padding // Matrix - IccTestDataMatrix.Fix16_2D_Grad, // 36 bytes - IccTestDataMatrix.Fix16_1D_Grad, // 12 bytes + IccTestDataMatrix.Fix162DGrad, // 36 bytes + IccTestDataMatrix.Fix161DGrad, // 12 bytes // M - CurveFull_1, // 14 bytes + CurveFull1, // 14 bytes new byte[] { 0x00, 0x00 }, // Padding - CurveFull_2, // 18 bytes + CurveFull2, // 18 bytes new byte[] { 0x00, 0x00 }, // Padding - CurveFull_0, // 12 bytes + CurveFull0, // 12 bytes // CLUT - IccTestDataLut.CLUT_16, // 74 bytes + IccTestDataLut.Clut16, // 74 bytes new byte[] { 0x00, 0x00 }, // Padding // A - CurveFull_2, // 18 bytes + CurveFull2, // 18 bytes new byte[] { 0x00, 0x00 }, // Padding - CurveFull_1, // 14 bytes + CurveFull1, // 14 bytes new byte[] { 0x00, 0x00 }); // Padding - public static readonly object[][] LutAToBTagDataEntryTestData = - { - new object[] { LutAToB_Arr, LutAToB_Val }, - }; + public static readonly object[][] LutAToBTagDataEntryTestData = { new object[] { LutAToBArr, LutAToBVal }, }; - public static readonly IccLutBToATagDataEntry LutBToA_Val = new( + public static readonly IccLutBToATagDataEntry LutBToAVal = new( new[] { - Curve_Val_0, - Curve_Val_1, + CurveVal0, + CurveVal1, }, null, null, null, - IccTestDataLut.CLUT_Val16, - new[] { Curve_Val_2, Curve_Val_1, Curve_Val_0 }); + IccTestDataLut.ClutVal16, + new[] { CurveVal2, CurveVal1, CurveVal0 }); - public static readonly byte[] LutBToA_Arr = ArrayHelper.Concat( + public static readonly byte[] LutBToAArr = ArrayHelper.Concat( new byte[] { 0x02, 0x03, 0x00, 0x00 }, new byte[] { 0x00, 0x00, 0x00, 0x20 }, // b: 32 new byte[] { 0x00, 0x00, 0x00, 0x00 }, // matrix: 0 @@ -302,52 +286,52 @@ public static readonly IccLutAToBTagDataEntry LutAToB_Val new byte[] { 0x00, 0x00, 0x00, 0x88 }, // a: 136 // B - CurveFull_0, // 12 bytes - CurveFull_1, // 14 bytes + CurveFull0, // 12 bytes + CurveFull1, // 14 bytes new byte[] { 0x00, 0x00 }, // Padding // CLUT - IccTestDataLut.CLUT_16, // 74 bytes + IccTestDataLut.Clut16, // 74 bytes new byte[] { 0x00, 0x00 }, // Padding // A - CurveFull_2, // 18 bytes + CurveFull2, // 18 bytes new byte[] { 0x00, 0x00 }, // Padding - CurveFull_1, // 14 bytes + CurveFull1, // 14 bytes new byte[] { 0x00, 0x00 }, // Padding - CurveFull_0); // 12 bytes + CurveFull0); // 12 bytes public static readonly object[][] LutBToATagDataEntryTestData = { - new object[] { LutBToA_Arr, LutBToA_Val }, + new object[] { LutBToAArr, LutBToAVal }, }; - public static readonly IccMeasurementTagDataEntry Measurement_Val = new( + public static readonly IccMeasurementTagDataEntry MeasurementVal = new( IccStandardObserver.Cie1931Observer, - IccTestDataNonPrimitives.XyzNumber_ValVar1, + IccTestDataNonPrimitives.XyzNumberValVar1, IccMeasurementGeometry.Degree0ToDOrDTo0, 1f, IccStandardIlluminant.D50); - public static readonly byte[] Measurement_Arr = ArrayHelper.Concat( - IccTestDataPrimitives.UInt32_1, - IccTestDataNonPrimitives.XyzNumber_Var1, - IccTestDataPrimitives.UInt32_2, - IccTestDataPrimitives.UFix16_1, - IccTestDataPrimitives.UInt32_1); + public static readonly byte[] MeasurementArr = ArrayHelper.Concat( + IccTestDataPrimitives.UInt321, + IccTestDataNonPrimitives.XyzNumberVar1, + IccTestDataPrimitives.UInt322, + IccTestDataPrimitives.UFix161, + IccTestDataPrimitives.UInt321); public static readonly object[][] MeasurementTagDataEntryTestData = { - new object[] { Measurement_Arr, Measurement_Val }, + new object[] { MeasurementArr, MeasurementVal }, }; - private static readonly IccLocalizedString LocalizedString_Rand_enUS = CreateLocalizedString("en", "US", IccTestDataPrimitives.Unicode_ValRand2); - private static readonly IccLocalizedString LocalizedString_Rand_deDE = CreateLocalizedString("de", "DE", IccTestDataPrimitives.Unicode_ValRand3); - private static readonly IccLocalizedString LocalizedString_Rand2_deDE = CreateLocalizedString("de", "DE", IccTestDataPrimitives.Unicode_ValRand2); - private static readonly IccLocalizedString LocalizedString_Rand2_esXL = CreateLocalizedString("es", "XL", IccTestDataPrimitives.Unicode_ValRand2); - private static readonly IccLocalizedString LocalizedString_Rand2_xyXL = CreateLocalizedString("xy", "XL", IccTestDataPrimitives.Unicode_ValRand2); - private static readonly IccLocalizedString LocalizedString_Rand_en = CreateLocalizedString("en", null, IccTestDataPrimitives.Unicode_ValRand2); - private static readonly IccLocalizedString LocalizedString_Rand_Invariant = new(CultureInfo.InvariantCulture, IccTestDataPrimitives.Unicode_ValRand3); + private static readonly IccLocalizedString LocalizedStringRandEnUs = CreateLocalizedString("en", "US", IccTestDataPrimitives.UnicodeValRand2); + private static readonly IccLocalizedString LocalizedStringRandDeDe = CreateLocalizedString("de", "DE", IccTestDataPrimitives.UnicodeValRand3); + private static readonly IccLocalizedString LocalizedStringRand2DeDe = CreateLocalizedString("de", "DE", IccTestDataPrimitives.UnicodeValRand2); + private static readonly IccLocalizedString LocalizedStringRand2EsXl = CreateLocalizedString("es", "XL", IccTestDataPrimitives.UnicodeValRand2); + private static readonly IccLocalizedString LocalizedStringRand2XyXl = CreateLocalizedString("xy", "XL", IccTestDataPrimitives.UnicodeValRand2); + private static readonly IccLocalizedString LocalizedStringRandEn = CreateLocalizedString("en", null, IccTestDataPrimitives.UnicodeValRand2); + private static readonly IccLocalizedString LocalizedStringRandInvariant = new(CultureInfo.InvariantCulture, IccTestDataPrimitives.UnicodeValRand3); private static IccLocalizedString CreateLocalizedString(string language, string country, string text) { @@ -378,29 +362,29 @@ private static IccLocalizedString CreateLocalizedString(string language, string return new IccLocalizedString(culture, text); } - private static readonly IccLocalizedString[] LocalizedString_RandArr_enUS_deDE = new IccLocalizedString[] + private static readonly IccLocalizedString[] LocalizedStringRandArrEnUsDeDe = new[] { - LocalizedString_Rand_enUS, - LocalizedString_Rand_deDE, + LocalizedStringRandEnUs, + LocalizedStringRandDeDe, }; - private static readonly IccLocalizedString[] LocalizedString_RandArr_en_Invariant = new IccLocalizedString[] + private static readonly IccLocalizedString[] LocalizedStringRandArrEnInvariant = new[] { - LocalizedString_Rand_en, - LocalizedString_Rand_Invariant, + LocalizedStringRandEn, + LocalizedStringRandInvariant, }; - private static readonly IccLocalizedString[] LocalizedString_SameArr_enUS_deDE_esXL_xyXL = new IccLocalizedString[] + private static readonly IccLocalizedString[] LocalizedStringSameArrEnUsDeDeEsXlXyXl = new[] { - LocalizedString_Rand_enUS, - LocalizedString_Rand2_deDE, - LocalizedString_Rand2_esXL, - LocalizedString_Rand2_xyXL, + LocalizedStringRandEnUs, + LocalizedStringRand2DeDe, + LocalizedStringRand2EsXl, + LocalizedStringRand2XyXl, }; - public static readonly IccMultiLocalizedUnicodeTagDataEntry MultiLocalizedUnicode_Val = new(LocalizedString_RandArr_enUS_deDE); - public static readonly byte[] MultiLocalizedUnicode_Arr = ArrayHelper.Concat( - IccTestDataPrimitives.UInt32_2, + public static readonly IccMultiLocalizedUnicodeTagDataEntry MultiLocalizedUnicodeVal = new(LocalizedStringRandArrEnUsDeDe); + public static readonly byte[] MultiLocalizedUnicodeArr = ArrayHelper.Concat( + IccTestDataPrimitives.UInt322, new byte[] { 0x00, 0x00, 0x00, 0x0C }, // 12 new byte[] { (byte)'e', (byte)'n', (byte)'U', (byte)'S' }, new byte[] { 0x00, 0x00, 0x00, 0x0C }, // 12 @@ -408,12 +392,12 @@ private static IccLocalizedString CreateLocalizedString(string language, string new byte[] { (byte)'d', (byte)'e', (byte)'D', (byte)'E' }, new byte[] { 0x00, 0x00, 0x00, 0x0E }, // 14 new byte[] { 0x00, 0x00, 0x00, 0x34 }, // 52 - IccTestDataPrimitives.Unicode_Rand2, - IccTestDataPrimitives.Unicode_Rand3); + IccTestDataPrimitives.UnicodeRand2, + IccTestDataPrimitives.UnicodeRand3); - public static readonly IccMultiLocalizedUnicodeTagDataEntry MultiLocalizedUnicode_Val2 = new(LocalizedString_RandArr_en_Invariant); - public static readonly byte[] MultiLocalizedUnicode_Arr2_Read = ArrayHelper.Concat( - IccTestDataPrimitives.UInt32_2, + public static readonly IccMultiLocalizedUnicodeTagDataEntry MultiLocalizedUnicodeVal2 = new(LocalizedStringRandArrEnInvariant); + public static readonly byte[] MultiLocalizedUnicodeArr2Read = ArrayHelper.Concat( + IccTestDataPrimitives.UInt322, new byte[] { 0x00, 0x00, 0x00, 0x0C }, // 12 new byte[] { (byte)'e', (byte)'n', 0x00, 0x00 }, new byte[] { 0x00, 0x00, 0x00, 0x0C }, // 12 @@ -421,11 +405,11 @@ private static IccLocalizedString CreateLocalizedString(string language, string new byte[] { 0x00, 0x00, 0x00, 0x00 }, new byte[] { 0x00, 0x00, 0x00, 0x0E }, // 14 new byte[] { 0x00, 0x00, 0x00, 0x34 }, // 52 - IccTestDataPrimitives.Unicode_Rand2, - IccTestDataPrimitives.Unicode_Rand3); + IccTestDataPrimitives.UnicodeRand2, + IccTestDataPrimitives.UnicodeRand3); - public static readonly byte[] MultiLocalizedUnicode_Arr2_Write = ArrayHelper.Concat( - IccTestDataPrimitives.UInt32_2, + public static readonly byte[] MultiLocalizedUnicodeArr2Write = ArrayHelper.Concat( + IccTestDataPrimitives.UInt322, new byte[] { 0x00, 0x00, 0x00, 0x0C }, // 12 new byte[] { (byte)'e', (byte)'n', 0x00, 0x00 }, new byte[] { 0x00, 0x00, 0x00, 0x0C }, // 12 @@ -433,12 +417,12 @@ private static IccLocalizedString CreateLocalizedString(string language, string new byte[] { (byte)'x', (byte)'x', 0x00, 0x00 }, new byte[] { 0x00, 0x00, 0x00, 0x0E }, // 14 new byte[] { 0x00, 0x00, 0x00, 0x34 }, // 52 - IccTestDataPrimitives.Unicode_Rand2, - IccTestDataPrimitives.Unicode_Rand3); + IccTestDataPrimitives.UnicodeRand2, + IccTestDataPrimitives.UnicodeRand3); - public static readonly IccMultiLocalizedUnicodeTagDataEntry MultiLocalizedUnicode_Val3 = new(LocalizedString_SameArr_enUS_deDE_esXL_xyXL); - public static readonly byte[] MultiLocalizedUnicode_Arr3 = ArrayHelper.Concat( - IccTestDataPrimitives.UInt32_4, + public static readonly IccMultiLocalizedUnicodeTagDataEntry MultiLocalizedUnicodeVal3 = new(LocalizedStringSameArrEnUsDeDeEsXlXyXl); + public static readonly byte[] MultiLocalizedUnicodeArr3 = ArrayHelper.Concat( + IccTestDataPrimitives.UInt324, new byte[] { 0x00, 0x00, 0x00, 0x0C }, // 12 new byte[] { (byte)'e', (byte)'n', (byte)'U', (byte)'S' }, new byte[] { 0x00, 0x00, 0x00, 0x0C }, // 12 @@ -452,374 +436,374 @@ private static IccLocalizedString CreateLocalizedString(string language, string new byte[] { (byte)'x', (byte)'y', (byte)'X', (byte)'L' }, new byte[] { 0x00, 0x00, 0x00, 0x0C }, // 12 new byte[] { 0x00, 0x00, 0x00, 0x40 }, // 64 - IccTestDataPrimitives.Unicode_Rand2); + IccTestDataPrimitives.UnicodeRand2); - public static readonly object[][] MultiLocalizedUnicodeTagDataEntryTestData_Read = + public static readonly object[][] MultiLocalizedUnicodeTagDataEntryTestDataRead = { - new object[] { MultiLocalizedUnicode_Arr, MultiLocalizedUnicode_Val }, - new object[] { MultiLocalizedUnicode_Arr2_Read, MultiLocalizedUnicode_Val2 }, - new object[] { MultiLocalizedUnicode_Arr3, MultiLocalizedUnicode_Val3 }, + new object[] { MultiLocalizedUnicodeArr, MultiLocalizedUnicodeVal }, + new object[] { MultiLocalizedUnicodeArr2Read, MultiLocalizedUnicodeVal2 }, + new object[] { MultiLocalizedUnicodeArr3, MultiLocalizedUnicodeVal3 }, }; - public static readonly object[][] MultiLocalizedUnicodeTagDataEntryTestData_Write = + public static readonly object[][] MultiLocalizedUnicodeTagDataEntryTestDataWrite = { - new object[] { MultiLocalizedUnicode_Arr, MultiLocalizedUnicode_Val }, - new object[] { MultiLocalizedUnicode_Arr2_Write, MultiLocalizedUnicode_Val2 }, - new object[] { MultiLocalizedUnicode_Arr3, MultiLocalizedUnicode_Val3 }, + new object[] { MultiLocalizedUnicodeArr, MultiLocalizedUnicodeVal }, + new object[] { MultiLocalizedUnicodeArr2Write, MultiLocalizedUnicodeVal2 }, + new object[] { MultiLocalizedUnicodeArr3, MultiLocalizedUnicodeVal3 }, }; - public static readonly IccMultiProcessElementsTagDataEntry MultiProcessElements_Val = new( + public static readonly IccMultiProcessElementsTagDataEntry MultiProcessElementsVal = new( new IccMultiProcessElement[] { - IccTestDataMultiProcessElements.MPE_ValCLUT, - IccTestDataMultiProcessElements.MPE_ValCLUT, + IccTestDataMultiProcessElements.MpeValClut, + IccTestDataMultiProcessElements.MpeValClut, }); - public static readonly byte[] MultiProcessElements_Arr = ArrayHelper.Concat( - IccTestDataPrimitives.UInt16_2, - IccTestDataPrimitives.UInt16_3, - IccTestDataPrimitives.UInt32_2, + public static readonly byte[] MultiProcessElementsArr = ArrayHelper.Concat( + IccTestDataPrimitives.UInt162, + IccTestDataPrimitives.UInt163, + IccTestDataPrimitives.UInt322, new byte[] { 0x00, 0x00, 0x00, 0x20 }, // 32 new byte[] { 0x00, 0x00, 0x00, 0x84 }, // 132 new byte[] { 0x00, 0x00, 0x00, 0xA4 }, // 164 new byte[] { 0x00, 0x00, 0x00, 0x84 }, // 132 - IccTestDataMultiProcessElements.MPE_CLUT, - IccTestDataMultiProcessElements.MPE_CLUT); + IccTestDataMultiProcessElements.MpeClut, + IccTestDataMultiProcessElements.MpeClut); public static readonly object[][] MultiProcessElementsTagDataEntryTestData = { - new object[] { MultiProcessElements_Arr, MultiProcessElements_Val }, + new object[] { MultiProcessElementsArr, MultiProcessElementsVal }, }; - public static readonly IccNamedColor2TagDataEntry NamedColor2_Val = new( + public static readonly IccNamedColor2TagDataEntry NamedColor2Val = new( 16909060, ArrayHelper.Fill('A', 31), ArrayHelper.Fill('4', 31), - new IccNamedColor[] { IccTestDataNonPrimitives.NamedColor_ValMin, IccTestDataNonPrimitives.NamedColor_ValMin }); + new IccNamedColor[] { IccTestDataNonPrimitives.NamedColorValMin, IccTestDataNonPrimitives.NamedColorValMin }); - public static readonly byte[] NamedColor2_Arr = ArrayHelper.Concat( + public static readonly byte[] NamedColor2Arr = ArrayHelper.Concat( new byte[] { 0x01, 0x02, 0x03, 0x04 }, - IccTestDataPrimitives.UInt32_2, - IccTestDataPrimitives.UInt32_3, + IccTestDataPrimitives.UInt322, + IccTestDataPrimitives.UInt323, ArrayHelper.Fill((byte)0x41, 31), new byte[] { 0x00 }, ArrayHelper.Fill((byte)0x34, 31), new byte[] { 0x00 }, - IccTestDataNonPrimitives.NamedColor_Min, - IccTestDataNonPrimitives.NamedColor_Min); + IccTestDataNonPrimitives.NamedColorMin, + IccTestDataNonPrimitives.NamedColorMin); public static readonly object[][] NamedColor2TagDataEntryTestData = { - new object[] { NamedColor2_Arr, NamedColor2_Val }, + new object[] { NamedColor2Arr, NamedColor2Val }, }; - public static readonly IccParametricCurveTagDataEntry ParametricCurve_Val = new(IccTestDataCurves.Parametric_ValVar1); - public static readonly byte[] ParametricCurve_Arr = IccTestDataCurves.Parametric_Var1; + public static readonly IccParametricCurveTagDataEntry ParametricCurveVal = new(IccTestDataCurves.ParametricValVar1); + public static readonly byte[] ParametricCurveArr = IccTestDataCurves.ParametricVar1; public static readonly object[][] ParametricCurveTagDataEntryTestData = { - new object[] { ParametricCurve_Arr, ParametricCurve_Val }, + new object[] { ParametricCurveArr, ParametricCurveVal }, }; - public static readonly IccProfileSequenceDescTagDataEntry ProfileSequenceDesc_Val = new( + public static readonly IccProfileSequenceDescTagDataEntry ProfileSequenceDescVal = new( new IccProfileDescription[] { - IccTestDataNonPrimitives.ProfileDescription_ValRand1, - IccTestDataNonPrimitives.ProfileDescription_ValRand1 + IccTestDataNonPrimitives.ProfileDescriptionValRand1, + IccTestDataNonPrimitives.ProfileDescriptionValRand1 }); - public static readonly byte[] ProfileSequenceDesc_Arr = ArrayHelper.Concat( - IccTestDataPrimitives.UInt32_2, - IccTestDataNonPrimitives.ProfileDescription_Rand1, - IccTestDataNonPrimitives.ProfileDescription_Rand1); + public static readonly byte[] ProfileSequenceDescArr = ArrayHelper.Concat( + IccTestDataPrimitives.UInt322, + IccTestDataNonPrimitives.ProfileDescriptionRand1, + IccTestDataNonPrimitives.ProfileDescriptionRand1); public static readonly object[][] ProfileSequenceDescTagDataEntryTestData = { - new object[] { ProfileSequenceDesc_Arr, ProfileSequenceDesc_Val }, + new object[] { ProfileSequenceDescArr, ProfileSequenceDescVal }, }; public static readonly IccProfileSequenceIdentifierTagDataEntry ProfileSequenceIdentifier_Val = new( - new IccProfileSequenceIdentifier[] + new[] { - new IccProfileSequenceIdentifier(IccTestDataNonPrimitives.ProfileId_ValRand, LocalizedString_RandArr_enUS_deDE), - new IccProfileSequenceIdentifier(IccTestDataNonPrimitives.ProfileId_ValRand, LocalizedString_RandArr_enUS_deDE), + new IccProfileSequenceIdentifier(IccTestDataNonPrimitives.ProfileIdValRand, LocalizedStringRandArrEnUsDeDe), + new IccProfileSequenceIdentifier(IccTestDataNonPrimitives.ProfileIdValRand, LocalizedStringRandArrEnUsDeDe), }); - public static readonly byte[] ProfileSequenceIdentifier_Arr = ArrayHelper.Concat( - IccTestDataPrimitives.UInt32_2, + public static readonly byte[] ProfileSequenceIdentifierArr = ArrayHelper.Concat( + IccTestDataPrimitives.UInt322, new byte[] { 0x00, 0x00, 0x00, 0x1C }, // 28 new byte[] { 0x00, 0x00, 0x00, 0x54 }, // 84 new byte[] { 0x00, 0x00, 0x00, 0x70 }, // 112 new byte[] { 0x00, 0x00, 0x00, 0x54 }, // 84 - IccTestDataNonPrimitives.ProfileId_Rand, // 16 bytes - TagDataEntryHeader_MultiLocalizedUnicodeArr, // 8 bytes - MultiLocalizedUnicode_Arr, // 58 bytes + IccTestDataNonPrimitives.ProfileIdRand, // 16 bytes + TagDataEntryHeaderMultiLocalizedUnicodeArr, // 8 bytes + MultiLocalizedUnicodeArr, // 58 bytes new byte[] { 0x00, 0x00 }, // 2 bytes (padding) - IccTestDataNonPrimitives.ProfileId_Rand, - TagDataEntryHeader_MultiLocalizedUnicodeArr, - MultiLocalizedUnicode_Arr, + IccTestDataNonPrimitives.ProfileIdRand, + TagDataEntryHeaderMultiLocalizedUnicodeArr, + MultiLocalizedUnicodeArr, new byte[] { 0x00, 0x00 }); public static readonly object[][] ProfileSequenceIdentifierTagDataEntryTestData = { - new object[] { ProfileSequenceIdentifier_Arr, ProfileSequenceIdentifier_Val }, + new object[] { ProfileSequenceIdentifierArr, ProfileSequenceIdentifier_Val }, }; - public static readonly IccResponseCurveSet16TagDataEntry ResponseCurveSet16_Val = new( - new IccResponseCurve[] + public static readonly IccResponseCurveSet16TagDataEntry ResponseCurveSet16Val = new( + new[] { - IccTestDataCurves.Response_ValGrad, - IccTestDataCurves.Response_ValGrad, + IccTestDataCurves.ResponseValGrad, + IccTestDataCurves.ResponseValGrad, }); - public static readonly byte[] ResponseCurveSet16_Arr = ArrayHelper.Concat( - IccTestDataPrimitives.UInt16_3, - IccTestDataPrimitives.UInt16_2, + public static readonly byte[] ResponseCurveSet16Arr = ArrayHelper.Concat( + IccTestDataPrimitives.UInt163, + IccTestDataPrimitives.UInt162, new byte[] { 0x00, 0x00, 0x00, 0x14 }, // 20 new byte[] { 0x00, 0x00, 0x00, 0x6C }, // 108 - IccTestDataCurves.Response_Grad, // 88 bytes - IccTestDataCurves.Response_Grad); // 88 bytes + IccTestDataCurves.ResponseGrad, // 88 bytes + IccTestDataCurves.ResponseGrad); // 88 bytes public static readonly object[][] ResponseCurveSet16TagDataEntryTestData = { - new object[] { ResponseCurveSet16_Arr, ResponseCurveSet16_Val }, + new object[] { ResponseCurveSet16Arr, ResponseCurveSet16Val }, }; - public static readonly IccFix16ArrayTagDataEntry Fix16Array_Val = new(new float[] { 1 / 256f, 2 / 256f, 3 / 256f }); - public static readonly byte[] Fix16Array_Arr = ArrayHelper.Concat( - IccTestDataPrimitives.Fix16_1, - IccTestDataPrimitives.Fix16_2, - IccTestDataPrimitives.Fix16_3); + public static readonly IccFix16ArrayTagDataEntry Fix16ArrayVal = new(new[] { 1 / 256f, 2 / 256f, 3 / 256f }); + public static readonly byte[] Fix16ArrayArr = ArrayHelper.Concat( + IccTestDataPrimitives.Fix161, + IccTestDataPrimitives.Fix162, + IccTestDataPrimitives.Fix163); public static readonly object[][] Fix16ArrayTagDataEntryTestData = { - new object[] { Fix16Array_Arr, Fix16Array_Val, 20u }, + new object[] { Fix16ArrayArr, Fix16ArrayVal, 20u }, }; - public static readonly IccSignatureTagDataEntry Signature_Val = new("ABCD"); - public static readonly byte[] Signature_Arr = { 0x41, 0x42, 0x43, 0x44, }; + public static readonly IccSignatureTagDataEntry SignatureVal = new("ABCD"); + public static readonly byte[] SignatureArr = { 0x41, 0x42, 0x43, 0x44, }; public static readonly object[][] SignatureTagDataEntryTestData = { - new object[] { Signature_Arr, Signature_Val }, + new object[] { SignatureArr, SignatureVal }, }; - public static readonly IccTextTagDataEntry Text_Val = new("ABCD"); - public static readonly byte[] Text_Arr = { 0x41, 0x42, 0x43, 0x44 }; + public static readonly IccTextTagDataEntry TextVal = new("ABCD"); + public static readonly byte[] TextArr = { 0x41, 0x42, 0x43, 0x44 }; public static readonly object[][] TextTagDataEntryTestData = { - new object[] { Text_Arr, Text_Val, 12u }, + new object[] { TextArr, TextVal, 12u }, }; - public static readonly IccUFix16ArrayTagDataEntry UFix16Array_Val = new(new float[] { 1, 2, 3 }); - public static readonly byte[] UFix16Array_Arr = ArrayHelper.Concat( - IccTestDataPrimitives.UFix16_1, - IccTestDataPrimitives.UFix16_2, - IccTestDataPrimitives.UFix16_3); + public static readonly IccUFix16ArrayTagDataEntry UFix16ArrayVal = new(new float[] { 1, 2, 3 }); + public static readonly byte[] UFix16ArrayArr = ArrayHelper.Concat( + IccTestDataPrimitives.UFix161, + IccTestDataPrimitives.UFix162, + IccTestDataPrimitives.UFix163); public static readonly object[][] UFix16ArrayTagDataEntryTestData = { - new object[] { UFix16Array_Arr, UFix16Array_Val, 20u }, + new object[] { UFix16ArrayArr, UFix16ArrayVal, 20u }, }; - public static readonly IccUInt16ArrayTagDataEntry UInt16Array_Val = new(new ushort[] { 1, 2, 3 }); - public static readonly byte[] UInt16Array_Arr = ArrayHelper.Concat( - IccTestDataPrimitives.UInt16_1, - IccTestDataPrimitives.UInt16_2, - IccTestDataPrimitives.UInt16_3); + public static readonly IccUInt16ArrayTagDataEntry UInt16ArrayVal = new(new ushort[] { 1, 2, 3 }); + public static readonly byte[] UInt16ArrayArr = ArrayHelper.Concat( + IccTestDataPrimitives.UInt161, + IccTestDataPrimitives.UInt162, + IccTestDataPrimitives.UInt163); public static readonly object[][] UInt16ArrayTagDataEntryTestData = { - new object[] { UInt16Array_Arr, UInt16Array_Val, 14u }, + new object[] { UInt16ArrayArr, UInt16ArrayVal, 14u }, }; - public static readonly IccUInt32ArrayTagDataEntry UInt32Array_Val = new(new uint[] { 1, 2, 3 }); - public static readonly byte[] UInt32Array_Arr = ArrayHelper.Concat( - IccTestDataPrimitives.UInt32_1, - IccTestDataPrimitives.UInt32_2, - IccTestDataPrimitives.UInt32_3); + public static readonly IccUInt32ArrayTagDataEntry UInt32ArrayVal = new(new uint[] { 1, 2, 3 }); + public static readonly byte[] UInt32ArrayArr = ArrayHelper.Concat( + IccTestDataPrimitives.UInt321, + IccTestDataPrimitives.UInt322, + IccTestDataPrimitives.UInt323); public static readonly object[][] UInt32ArrayTagDataEntryTestData = { - new object[] { UInt32Array_Arr, UInt32Array_Val, 20u }, + new object[] { UInt32ArrayArr, UInt32ArrayVal, 20u }, }; - public static readonly IccUInt64ArrayTagDataEntry UInt64Array_Val = new(new ulong[] { 1, 2, 3 }); - public static readonly byte[] UInt64Array_Arr = ArrayHelper.Concat( - IccTestDataPrimitives.UInt64_1, - IccTestDataPrimitives.UInt64_2, - IccTestDataPrimitives.UInt64_3); + public static readonly IccUInt64ArrayTagDataEntry UInt64ArrayVal = new(new ulong[] { 1, 2, 3 }); + public static readonly byte[] UInt64ArrayArr = ArrayHelper.Concat( + IccTestDataPrimitives.UInt641, + IccTestDataPrimitives.UInt642, + IccTestDataPrimitives.UInt643); public static readonly object[][] UInt64ArrayTagDataEntryTestData = { - new object[] { UInt64Array_Arr, UInt64Array_Val, 32u }, + new object[] { UInt64ArrayArr, UInt64ArrayVal, 32u }, }; - public static readonly IccUInt8ArrayTagDataEntry UInt8Array_Val = new(new byte[] { 1, 2, 3 }); - public static readonly byte[] UInt8Array_Arr = { 1, 2, 3 }; + public static readonly IccUInt8ArrayTagDataEntry UInt8ArrayVal = new(new byte[] { 1, 2, 3 }); + public static readonly byte[] UInt8ArrayArr = { 1, 2, 3 }; public static readonly object[][] UInt8ArrayTagDataEntryTestData = { - new object[] { UInt8Array_Arr, UInt8Array_Val, 11u }, + new object[] { UInt8ArrayArr, UInt8ArrayVal, 11u }, }; - public static readonly IccViewingConditionsTagDataEntry ViewingConditions_Val = new( - IccTestDataNonPrimitives.XyzNumber_ValVar1, - IccTestDataNonPrimitives.XyzNumber_ValVar2, + public static readonly IccViewingConditionsTagDataEntry ViewingConditionsVal = new( + IccTestDataNonPrimitives.XyzNumberValVar1, + IccTestDataNonPrimitives.XyzNumberValVar2, IccStandardIlluminant.D50); - public static readonly byte[] ViewingConditions_Arr = ArrayHelper.Concat( - IccTestDataNonPrimitives.XyzNumber_Var1, - IccTestDataNonPrimitives.XyzNumber_Var2, - IccTestDataPrimitives.UInt32_1); + public static readonly byte[] ViewingConditionsArr = ArrayHelper.Concat( + IccTestDataNonPrimitives.XyzNumberVar1, + IccTestDataNonPrimitives.XyzNumberVar2, + IccTestDataPrimitives.UInt321); public static readonly object[][] ViewingConditionsTagDataEntryTestData = { - new object[] { ViewingConditions_Arr, ViewingConditions_Val }, + new object[] { ViewingConditionsArr, ViewingConditionsVal }, }; - public static readonly IccXyzTagDataEntry XYZ_Val = new(new Vector3[] + public static readonly IccXyzTagDataEntry XyzVal = new(new[] { - IccTestDataNonPrimitives.XyzNumber_ValVar1, - IccTestDataNonPrimitives.XyzNumber_ValVar2, - IccTestDataNonPrimitives.XyzNumber_ValVar3, + IccTestDataNonPrimitives.XyzNumberValVar1, + IccTestDataNonPrimitives.XyzNumberValVar2, + IccTestDataNonPrimitives.XyzNumberValVar3, }); - public static readonly byte[] XYZ_Arr = ArrayHelper.Concat( - IccTestDataNonPrimitives.XyzNumber_Var1, - IccTestDataNonPrimitives.XyzNumber_Var2, - IccTestDataNonPrimitives.XyzNumber_Var3); + public static readonly byte[] XyzArr = ArrayHelper.Concat( + IccTestDataNonPrimitives.XyzNumberVar1, + IccTestDataNonPrimitives.XyzNumberVar2, + IccTestDataNonPrimitives.XyzNumberVar3); public static readonly object[][] XYZTagDataEntryTestData = { - new object[] { XYZ_Arr, XYZ_Val, 44u }, + new object[] { XyzArr, XyzVal, 44u }, }; - public static readonly IccTextDescriptionTagDataEntry TextDescription_Val1 = new( - IccTestDataPrimitives.Ascii_ValRand, - IccTestDataPrimitives.Unicode_ValRand1, + public static readonly IccTextDescriptionTagDataEntry TextDescriptionVal1 = new( + IccTestDataPrimitives.AsciiValRand, + IccTestDataPrimitives.UnicodeValRand1, ArrayHelper.Fill('A', 66), 1701729619, 2); - public static readonly byte[] TextDescription_Arr1 = ArrayHelper.Concat( + public static readonly byte[] TextDescriptionArr1 = ArrayHelper.Concat( new byte[] { 0x00, 0x00, 0x00, 0x0B }, // 11 - IccTestDataPrimitives.Ascii_Rand, + IccTestDataPrimitives.AsciiRand, new byte[] { 0x00 }, // Null terminator new byte[] { 0x65, 0x6E, 0x55, 0x53 }, // enUS new byte[] { 0x00, 0x00, 0x00, 0x0E }, // 14 - IccTestDataPrimitives.Unicode_Rand1, + IccTestDataPrimitives.UnicodeRand1, new byte[] { 0x00, 0x00 }, // Null terminator new byte[] { 0x00, 0x02, 0x43 }, // 2, 67 ArrayHelper.Fill((byte)0x41, 66), new byte[] { 0x00 }); // Null terminator - public static readonly IccTextDescriptionTagDataEntry TextDescription_Val2 = new(IccTestDataPrimitives.Ascii_ValRand, null, null, 0, 0); - public static readonly byte[] TextDescription_Arr2 = ArrayHelper.Concat( + public static readonly IccTextDescriptionTagDataEntry TextDescriptionVal2 = new(IccTestDataPrimitives.AsciiValRand, null, null, 0, 0); + public static readonly byte[] TextDescriptionArr2 = ArrayHelper.Concat( new byte[] { 0x00, 0x00, 0x00, 0x0B }, // 11 - IccTestDataPrimitives.Ascii_Rand, + IccTestDataPrimitives.AsciiRand, new byte[] { 0x00 }, // Null terminator - IccTestDataPrimitives.UInt32_0, - IccTestDataPrimitives.UInt32_0, + IccTestDataPrimitives.UInt320, + IccTestDataPrimitives.UInt320, new byte[] { 0x00, 0x00, 0x00 }, // 0, 0 ArrayHelper.Fill((byte)0x00, 67)); public static readonly object[][] TextDescriptionTagDataEntryTestData = { - new object[] { TextDescription_Arr1, TextDescription_Val1 }, - new object[] { TextDescription_Arr2, TextDescription_Val2 }, + new object[] { TextDescriptionArr1, TextDescriptionVal1 }, + new object[] { TextDescriptionArr2, TextDescriptionVal2 }, }; - public static readonly IccCrdInfoTagDataEntry CrdInfo_Val = new( - IccTestDataPrimitives.Ascii_ValRand4, - IccTestDataPrimitives.Ascii_ValRand1, - IccTestDataPrimitives.Ascii_ValRand2, - IccTestDataPrimitives.Ascii_ValRand3, - IccTestDataPrimitives.Ascii_ValRand4); + public static readonly IccCrdInfoTagDataEntry CrdInfoVal = new( + IccTestDataPrimitives.AsciiValRand4, + IccTestDataPrimitives.AsciiValRand1, + IccTestDataPrimitives.AsciiValRand2, + IccTestDataPrimitives.AsciiValRand3, + IccTestDataPrimitives.AsciiValRand4); - public static readonly byte[] CrdInfo_Arr = ArrayHelper.Concat( - IccTestDataPrimitives.UInt32_6, - IccTestDataPrimitives.Ascii_Rand4, + public static readonly byte[] CrdInfoArr = ArrayHelper.Concat( + IccTestDataPrimitives.UInt326, + IccTestDataPrimitives.AsciiRand4, new byte[] { 0 }, - IccTestDataPrimitives.UInt32_6, - IccTestDataPrimitives.Ascii_Rand1, + IccTestDataPrimitives.UInt326, + IccTestDataPrimitives.AsciiRand1, new byte[] { 0 }, - IccTestDataPrimitives.UInt32_6, - IccTestDataPrimitives.Ascii_Rand2, + IccTestDataPrimitives.UInt326, + IccTestDataPrimitives.AsciiRand2, new byte[] { 0 }, - IccTestDataPrimitives.UInt32_6, - IccTestDataPrimitives.Ascii_Rand3, + IccTestDataPrimitives.UInt326, + IccTestDataPrimitives.AsciiRand3, new byte[] { 0 }, - IccTestDataPrimitives.UInt32_6, - IccTestDataPrimitives.Ascii_Rand4, + IccTestDataPrimitives.UInt326, + IccTestDataPrimitives.AsciiRand4, new byte[] { 0 }); public static readonly object[][] CrdInfoTagDataEntryTestData = { - new object[] { CrdInfo_Arr, CrdInfo_Val }, + new object[] { CrdInfoArr, CrdInfoVal }, }; - public static readonly IccScreeningTagDataEntry Screening_Val = new( + public static readonly IccScreeningTagDataEntry ScreeningVal = new( IccScreeningFlag.DefaultScreens | IccScreeningFlag.UnitLinesPerCm, - new IccScreeningChannel[] { IccTestDataNonPrimitives.ScreeningChannel_ValRand1, IccTestDataNonPrimitives.ScreeningChannel_ValRand2 }); + new IccScreeningChannel[] { IccTestDataNonPrimitives.ScreeningChannelValRand1, IccTestDataNonPrimitives.ScreeningChannelValRand2 }); - public static readonly byte[] Screening_Arr = ArrayHelper.Concat( - IccTestDataPrimitives.Int32_1, - IccTestDataPrimitives.UInt32_2, - IccTestDataNonPrimitives.ScreeningChannel_Rand1, - IccTestDataNonPrimitives.ScreeningChannel_Rand2); + public static readonly byte[] ScreeningArr = ArrayHelper.Concat( + IccTestDataPrimitives.Int321, + IccTestDataPrimitives.UInt322, + IccTestDataNonPrimitives.ScreeningChannelRand1, + IccTestDataNonPrimitives.ScreeningChannelRand2); public static readonly object[][] ScreeningTagDataEntryTestData = { - new object[] { Screening_Arr, Screening_Val }, + new object[] { ScreeningArr, ScreeningVal }, }; - public static readonly IccUcrBgTagDataEntry UcrBg_Val = new( + public static readonly IccUcrBgTagDataEntry UcrBgVal = new( new ushort[] { 3, 4, 6 }, new ushort[] { 9, 7, 2, 5 }, - IccTestDataPrimitives.Ascii_ValRand); - - public static readonly byte[] UcrBg_Arr = ArrayHelper.Concat( - IccTestDataPrimitives.UInt32_3, - IccTestDataPrimitives.UInt16_3, - IccTestDataPrimitives.UInt16_4, - IccTestDataPrimitives.UInt16_6, - IccTestDataPrimitives.UInt32_4, - IccTestDataPrimitives.UInt16_9, - IccTestDataPrimitives.UInt16_7, - IccTestDataPrimitives.UInt16_2, - IccTestDataPrimitives.UInt16_5, - IccTestDataPrimitives.Ascii_Rand, + IccTestDataPrimitives.AsciiValRand); + + public static readonly byte[] UcrBgArr = ArrayHelper.Concat( + IccTestDataPrimitives.UInt323, + IccTestDataPrimitives.UInt163, + IccTestDataPrimitives.UInt164, + IccTestDataPrimitives.UInt166, + IccTestDataPrimitives.UInt324, + IccTestDataPrimitives.UInt169, + IccTestDataPrimitives.UInt167, + IccTestDataPrimitives.UInt162, + IccTestDataPrimitives.UInt165, + IccTestDataPrimitives.AsciiRand, new byte[] { 0 }); public static readonly object[][] UcrBgTagDataEntryTestData = { - new object[] { UcrBg_Arr, UcrBg_Val, 41 }, + new object[] { UcrBgArr, UcrBgVal, 41 }, }; - public static readonly IccTagDataEntry TagDataEntry_CurveVal = Curve_Val_2; - public static readonly byte[] TagDataEntry_CurveArr = ArrayHelper.Concat( - TagDataEntryHeader_CurveArr, - Curve_Arr_2, + public static readonly IccTagDataEntry TagDataEntryCurveVal = CurveVal2; + public static readonly byte[] TagDataEntryCurveArr = ArrayHelper.Concat( + TagDataEntryHeaderCurveArr, + CurveArr2, new byte[] { 0x00, 0x00 }); // padding - public static readonly IccTagDataEntry TagDataEntry_MultiLocalizedUnicodeVal = MultiLocalizedUnicode_Val; - public static readonly byte[] TagDataEntry_MultiLocalizedUnicodeArr = ArrayHelper.Concat( - TagDataEntryHeader_MultiLocalizedUnicodeArr, - MultiLocalizedUnicode_Arr, + public static readonly IccTagDataEntry TagDataEntryMultiLocalizedUnicodeVal = MultiLocalizedUnicodeVal; + public static readonly byte[] TagDataEntryMultiLocalizedUnicodeArr = ArrayHelper.Concat( + TagDataEntryHeaderMultiLocalizedUnicodeArr, + MultiLocalizedUnicodeArr, new byte[] { 0x00, 0x00 }); // padding - public static readonly IccTagTableEntry TagDataEntry_MultiLocalizedUnicodeTable = new( + public static readonly IccTagTableEntry TagDataEntryMultiLocalizedUnicodeTable = new( IccProfileTag.Unknown, 0, - (uint)TagDataEntry_MultiLocalizedUnicodeArr.Length - 2); + (uint)TagDataEntryMultiLocalizedUnicodeArr.Length - 2); - public static readonly IccTagTableEntry TagDataEntry_CurveTable = new(IccProfileTag.Unknown, 0, (uint)TagDataEntry_CurveArr.Length - 2); + public static readonly IccTagTableEntry TagDataEntryCurveTable = new(IccProfileTag.Unknown, 0, (uint)TagDataEntryCurveArr.Length - 2); public static readonly object[][] TagDataEntryTestData = { - new object[] { TagDataEntry_CurveArr, TagDataEntry_CurveVal }, - new object[] { TagDataEntry_MultiLocalizedUnicodeArr, TagDataEntry_MultiLocalizedUnicodeVal }, + new object[] { TagDataEntryCurveArr, TagDataEntryCurveVal }, + new object[] { TagDataEntryMultiLocalizedUnicodeArr, TagDataEntryMultiLocalizedUnicodeVal }, }; } From 73c8d8f4f8affc85f263478b0672613612b9b5fc Mon Sep 17 00:00:00 2001 From: Brian Popow Date: Thu, 24 Nov 2022 20:53:31 +0100 Subject: [PATCH 07/42] Fix Copyright notice --- tests/ImageSharp.Tests/Colorspaces/CieLchTests.cs | 8 ++++---- tests/ImageSharp.Tests/Colorspaces/CieLchuvTests.cs | 8 ++++---- tests/ImageSharp.Tests/Colorspaces/CieLuvTests.cs | 2 +- tests/ImageSharp.Tests/Colorspaces/CieXyyTests.cs | 2 +- tests/ImageSharp.Tests/Colorspaces/CieXyzTests.cs | 2 +- tests/ImageSharp.Tests/Colorspaces/CmykTests.cs | 2 +- .../Colorspaces/Companding/CompandingTests.cs | 2 +- .../Conversion/CieLabAndCieLuvConversionTests.cs | 2 +- .../Conversion/CieLabAndCmykConversionTests.cs | 2 +- .../Colorspaces/Conversion/CieLabAndHslConversionTests.cs | 2 +- .../Colorspaces/Conversion/CieLabAndHsvConversionTests.cs | 2 +- .../Conversion/CieLabAndHunterLabConversionTests.cs | 2 +- .../Conversion/CieLabAndLinearRgbConversionTests.cs | 2 +- .../Colorspaces/Conversion/CieLabAndLmsConversionTests.cs | 2 +- .../Colorspaces/Conversion/CieLabAndRgbConversionTests.cs | 2 +- .../Conversion/CieLabAndYCbCrConversionTests.cs | 2 +- .../Conversion/CieLchAndCieLuvConversionTests.cs | 2 +- .../Colorspaces/Conversion/CieLchAndHslConversionTests.cs | 2 +- .../Colorspaces/Conversion/CieLchAndHsvConversionTests.cs | 2 +- .../Conversion/CieLchAndHunterLabConversionTests.cs | 2 +- .../Conversion/CieLchAndLinearRgbConversionTests.cs | 2 +- .../Colorspaces/Conversion/CieLchAndLmsConversionTests.cs | 2 +- .../Colorspaces/Conversion/CieLchAndRgbConversionTests.cs | 2 +- .../Conversion/CieLchAndYCbCrConversionTests.cs | 2 +- .../Conversion/CieLchuvAndCieLchConversionTests.cs | 2 +- .../Conversion/CieLchuvAndCmykConversionTests.cs | 2 +- .../Conversion/CieXyzAndCieLabConversionTest.cs | 2 +- .../Conversion/CieXyzAndCieLuvConversionTest.cs | 2 +- .../Conversion/CieXyzAndCieXyyConversionTest.cs | 2 +- .../Conversion/CieXyzAndHunterLabConversionTest.cs | 2 +- .../Colorspaces/Conversion/CieXyzAndLmsConversionTest.cs | 2 +- .../Conversion/CmykAndCieLchConversionTests.cs | 2 +- .../Conversion/CmykAndCieLuvConversionTests.cs | 2 +- .../Conversion/CmykAndCieXyyConversionTests.cs | 2 +- .../Conversion/CmykAndCieXyzConversionTests.cs | 2 +- .../Colorspaces/Conversion/CmykAndHslConversionTests.cs | 2 +- .../Colorspaces/Conversion/CmykAndHsvConversionTests.cs | 2 +- .../Conversion/CmykAndHunterLabConversionTests.cs | 2 +- .../Colorspaces/Conversion/CmykAndYCbCrConversionTests.cs | 2 +- .../Colorspaces/Conversion/RgbAndCieXyzConversionTest.cs | 2 +- .../Colorspaces/Conversion/RgbAndCmykConversionTest.cs | 2 +- .../Colorspaces/Conversion/RgbAndHsvConversionTest.cs | 2 +- .../Colorspaces/Conversion/RgbAndYCbCrConversionTest.cs | 2 +- tests/ImageSharp.Tests/Colorspaces/HslTests.cs | 2 +- tests/ImageSharp.Tests/Colorspaces/HsvTests.cs | 2 +- .../Colorspaces/Icc/Calculators/CurveCalculatorTests.cs | 2 +- .../Colorspaces/Icc/Calculators/LutABCalculatorTests.cs | 2 +- .../Colorspaces/Icc/Calculators/LutCalculatorTests.cs | 2 +- .../Icc/Calculators/LutEntryCalculatorTests.cs | 2 +- .../Colorspaces/Icc/Calculators/MatrixCalculatorTests.cs | 2 +- .../Icc/Calculators/ParametricCurveCalculatorTests.cs | 2 +- .../Colorspaces/Icc/Calculators/TrcCalculatorTests.cs | 2 +- tests/ImageSharp.Tests/Colorspaces/LinearRgbTests.cs | 2 +- tests/ImageSharp.Tests/Colorspaces/YCbCrTests.cs | 2 +- .../TestDataIcc/Conversion/IccConversionDataClut.cs | 2 +- .../TestDataIcc/Conversion/IccConversionDataLut.cs | 2 +- .../TestDataIcc/Conversion/IccConversionDataLutAB.cs | 2 +- .../TestDataIcc/Conversion/IccConversionDataLutEntry.cs | 2 +- .../TestDataIcc/Conversion/IccConversionDataMatrix.cs | 2 +- .../Conversion/IccConversionDataMultiProcessElement.cs | 2 +- .../TestDataIcc/Conversion/IccConversionDataTrc.cs | 2 +- 61 files changed, 67 insertions(+), 67 deletions(-) diff --git a/tests/ImageSharp.Tests/Colorspaces/CieLchTests.cs b/tests/ImageSharp.Tests/Colorspaces/CieLchTests.cs index a5d39f6209..24839616eb 100644 --- a/tests/ImageSharp.Tests/Colorspaces/CieLchTests.cs +++ b/tests/ImageSharp.Tests/Colorspaces/CieLchTests.cs @@ -1,5 +1,5 @@ // Copyright (c) Six Labors. -// Licensed under the Apache License, Version 2.0. +// Licensed under the Six Labors Split License. using System.Numerics; using SixLabors.ImageSharp.ColorSpaces; @@ -31,9 +31,9 @@ public void CieLchEquality() 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 8a1cf666c7..a6c054a521 100644 --- a/tests/ImageSharp.Tests/Colorspaces/CieLchuvTests.cs +++ b/tests/ImageSharp.Tests/Colorspaces/CieLchuvTests.cs @@ -1,5 +1,5 @@ // Copyright (c) Six Labors. -// Licensed under the Apache License, Version 2.0. +// Licensed under the Six Labors Split License. using System.Numerics; using SixLabors.ImageSharp.ColorSpaces; @@ -31,9 +31,9 @@ public void CieLchuvEquality() 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 == default(CieLchuv)); + Assert.False(default != default(CieLchuv)); + Assert.Equal(default, default(CieLchuv)); 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 9fe1eb7932..4864bbf8d7 100644 --- a/tests/ImageSharp.Tests/Colorspaces/CieLuvTests.cs +++ b/tests/ImageSharp.Tests/Colorspaces/CieLuvTests.cs @@ -1,5 +1,5 @@ // Copyright (c) Six Labors. -// Licensed under the Apache License, Version 2.0. +// Licensed under the Six Labors Split License. using System.Numerics; using SixLabors.ImageSharp.ColorSpaces; diff --git a/tests/ImageSharp.Tests/Colorspaces/CieXyyTests.cs b/tests/ImageSharp.Tests/Colorspaces/CieXyyTests.cs index ffd9109328..8183fe947a 100644 --- a/tests/ImageSharp.Tests/Colorspaces/CieXyyTests.cs +++ b/tests/ImageSharp.Tests/Colorspaces/CieXyyTests.cs @@ -1,5 +1,5 @@ // Copyright (c) Six Labors. -// Licensed under the Apache License, Version 2.0. +// Licensed under the Six Labors Split License. using System.Numerics; using SixLabors.ImageSharp.ColorSpaces; diff --git a/tests/ImageSharp.Tests/Colorspaces/CieXyzTests.cs b/tests/ImageSharp.Tests/Colorspaces/CieXyzTests.cs index a6a9a0cce7..c5d5d9b860 100644 --- a/tests/ImageSharp.Tests/Colorspaces/CieXyzTests.cs +++ b/tests/ImageSharp.Tests/Colorspaces/CieXyzTests.cs @@ -1,5 +1,5 @@ // Copyright (c) Six Labors. -// Licensed under the Apache License, Version 2.0. +// Licensed under the Six Labors Split License. using System.Numerics; using SixLabors.ImageSharp.ColorSpaces; diff --git a/tests/ImageSharp.Tests/Colorspaces/CmykTests.cs b/tests/ImageSharp.Tests/Colorspaces/CmykTests.cs index 8d8dcf5661..6eaf452b9d 100644 --- a/tests/ImageSharp.Tests/Colorspaces/CmykTests.cs +++ b/tests/ImageSharp.Tests/Colorspaces/CmykTests.cs @@ -1,5 +1,5 @@ // Copyright (c) Six Labors. -// Licensed under the Apache License, Version 2.0. +// Licensed under the Six Labors Split License. using System.Numerics; using SixLabors.ImageSharp.ColorSpaces; diff --git a/tests/ImageSharp.Tests/Colorspaces/Companding/CompandingTests.cs b/tests/ImageSharp.Tests/Colorspaces/Companding/CompandingTests.cs index a24d2dbda3..1bb282bb9d 100644 --- a/tests/ImageSharp.Tests/Colorspaces/Companding/CompandingTests.cs +++ b/tests/ImageSharp.Tests/Colorspaces/Companding/CompandingTests.cs @@ -1,5 +1,5 @@ // Copyright (c) Six Labors. -// Licensed under the Apache License, Version 2.0. +// Licensed under the Six Labors Split License. using System.Numerics; using SixLabors.ImageSharp.ColorSpaces.Companding; diff --git a/tests/ImageSharp.Tests/Colorspaces/Conversion/CieLabAndCieLuvConversionTests.cs b/tests/ImageSharp.Tests/Colorspaces/Conversion/CieLabAndCieLuvConversionTests.cs index bd1f60a9ed..7411e809ed 100644 --- a/tests/ImageSharp.Tests/Colorspaces/Conversion/CieLabAndCieLuvConversionTests.cs +++ b/tests/ImageSharp.Tests/Colorspaces/Conversion/CieLabAndCieLuvConversionTests.cs @@ -1,5 +1,5 @@ // Copyright (c) Six Labors. -// Licensed under the Apache License, Version 2.0. +// Licensed under the Six Labors Split License. using SixLabors.ImageSharp.ColorSpaces; using SixLabors.ImageSharp.ColorSpaces.Conversion; diff --git a/tests/ImageSharp.Tests/Colorspaces/Conversion/CieLabAndCmykConversionTests.cs b/tests/ImageSharp.Tests/Colorspaces/Conversion/CieLabAndCmykConversionTests.cs index fa4d6f0b8b..e3acb2b7b5 100644 --- a/tests/ImageSharp.Tests/Colorspaces/Conversion/CieLabAndCmykConversionTests.cs +++ b/tests/ImageSharp.Tests/Colorspaces/Conversion/CieLabAndCmykConversionTests.cs @@ -1,5 +1,5 @@ // Copyright (c) Six Labors. -// Licensed under the Apache License, Version 2.0. +// Licensed under the Six Labors Split License. using SixLabors.ImageSharp.ColorSpaces; using SixLabors.ImageSharp.ColorSpaces.Conversion; diff --git a/tests/ImageSharp.Tests/Colorspaces/Conversion/CieLabAndHslConversionTests.cs b/tests/ImageSharp.Tests/Colorspaces/Conversion/CieLabAndHslConversionTests.cs index 6fbbb2c65a..c235ce5572 100644 --- a/tests/ImageSharp.Tests/Colorspaces/Conversion/CieLabAndHslConversionTests.cs +++ b/tests/ImageSharp.Tests/Colorspaces/Conversion/CieLabAndHslConversionTests.cs @@ -1,5 +1,5 @@ // Copyright (c) Six Labors. -// Licensed under the Apache License, Version 2.0. +// Licensed under the Six Labors Split License. using SixLabors.ImageSharp.ColorSpaces; using SixLabors.ImageSharp.ColorSpaces.Conversion; diff --git a/tests/ImageSharp.Tests/Colorspaces/Conversion/CieLabAndHsvConversionTests.cs b/tests/ImageSharp.Tests/Colorspaces/Conversion/CieLabAndHsvConversionTests.cs index b0239c2c22..9def3b0993 100644 --- a/tests/ImageSharp.Tests/Colorspaces/Conversion/CieLabAndHsvConversionTests.cs +++ b/tests/ImageSharp.Tests/Colorspaces/Conversion/CieLabAndHsvConversionTests.cs @@ -1,5 +1,5 @@ // Copyright (c) Six Labors. -// Licensed under the Apache License, Version 2.0. +// Licensed under the Six Labors Split License. using SixLabors.ImageSharp.ColorSpaces; using SixLabors.ImageSharp.ColorSpaces.Conversion; diff --git a/tests/ImageSharp.Tests/Colorspaces/Conversion/CieLabAndHunterLabConversionTests.cs b/tests/ImageSharp.Tests/Colorspaces/Conversion/CieLabAndHunterLabConversionTests.cs index cc658d62df..bf0b884a2b 100644 --- a/tests/ImageSharp.Tests/Colorspaces/Conversion/CieLabAndHunterLabConversionTests.cs +++ b/tests/ImageSharp.Tests/Colorspaces/Conversion/CieLabAndHunterLabConversionTests.cs @@ -1,5 +1,5 @@ // Copyright (c) Six Labors. -// Licensed under the Apache License, Version 2.0. +// Licensed under the Six Labors Split License. using SixLabors.ImageSharp.ColorSpaces; using SixLabors.ImageSharp.ColorSpaces.Conversion; diff --git a/tests/ImageSharp.Tests/Colorspaces/Conversion/CieLabAndLinearRgbConversionTests.cs b/tests/ImageSharp.Tests/Colorspaces/Conversion/CieLabAndLinearRgbConversionTests.cs index 13df0f4920..f12c2e49f0 100644 --- a/tests/ImageSharp.Tests/Colorspaces/Conversion/CieLabAndLinearRgbConversionTests.cs +++ b/tests/ImageSharp.Tests/Colorspaces/Conversion/CieLabAndLinearRgbConversionTests.cs @@ -1,5 +1,5 @@ // Copyright (c) Six Labors. -// Licensed under the Apache License, Version 2.0. +// Licensed under the Six Labors Split License. using SixLabors.ImageSharp.ColorSpaces; using SixLabors.ImageSharp.ColorSpaces.Conversion; diff --git a/tests/ImageSharp.Tests/Colorspaces/Conversion/CieLabAndLmsConversionTests.cs b/tests/ImageSharp.Tests/Colorspaces/Conversion/CieLabAndLmsConversionTests.cs index 530af962e6..c33b388d3d 100644 --- a/tests/ImageSharp.Tests/Colorspaces/Conversion/CieLabAndLmsConversionTests.cs +++ b/tests/ImageSharp.Tests/Colorspaces/Conversion/CieLabAndLmsConversionTests.cs @@ -1,5 +1,5 @@ // Copyright (c) Six Labors. -// Licensed under the Apache License, Version 2.0. +// Licensed under the Six Labors Split License. using SixLabors.ImageSharp.ColorSpaces; using SixLabors.ImageSharp.ColorSpaces.Conversion; diff --git a/tests/ImageSharp.Tests/Colorspaces/Conversion/CieLabAndRgbConversionTests.cs b/tests/ImageSharp.Tests/Colorspaces/Conversion/CieLabAndRgbConversionTests.cs index 5d5c31690a..544ca265cd 100644 --- a/tests/ImageSharp.Tests/Colorspaces/Conversion/CieLabAndRgbConversionTests.cs +++ b/tests/ImageSharp.Tests/Colorspaces/Conversion/CieLabAndRgbConversionTests.cs @@ -1,5 +1,5 @@ // Copyright (c) Six Labors. -// Licensed under the Apache License, Version 2.0. +// Licensed under the Six Labors Split License. using SixLabors.ImageSharp.ColorSpaces; using SixLabors.ImageSharp.ColorSpaces.Conversion; diff --git a/tests/ImageSharp.Tests/Colorspaces/Conversion/CieLabAndYCbCrConversionTests.cs b/tests/ImageSharp.Tests/Colorspaces/Conversion/CieLabAndYCbCrConversionTests.cs index a8f6a5d197..0936acb362 100644 --- a/tests/ImageSharp.Tests/Colorspaces/Conversion/CieLabAndYCbCrConversionTests.cs +++ b/tests/ImageSharp.Tests/Colorspaces/Conversion/CieLabAndYCbCrConversionTests.cs @@ -1,5 +1,5 @@ // Copyright (c) Six Labors. -// Licensed under the Apache License, Version 2.0. +// Licensed under the Six Labors Split License. using SixLabors.ImageSharp.ColorSpaces; using SixLabors.ImageSharp.ColorSpaces.Conversion; diff --git a/tests/ImageSharp.Tests/Colorspaces/Conversion/CieLchAndCieLuvConversionTests.cs b/tests/ImageSharp.Tests/Colorspaces/Conversion/CieLchAndCieLuvConversionTests.cs index 56c6cabccf..6dd780af36 100644 --- a/tests/ImageSharp.Tests/Colorspaces/Conversion/CieLchAndCieLuvConversionTests.cs +++ b/tests/ImageSharp.Tests/Colorspaces/Conversion/CieLchAndCieLuvConversionTests.cs @@ -1,5 +1,5 @@ // Copyright (c) Six Labors. -// Licensed under the Apache License, Version 2.0. +// Licensed under the Six Labors Split License. using SixLabors.ImageSharp.ColorSpaces; using SixLabors.ImageSharp.ColorSpaces.Conversion; diff --git a/tests/ImageSharp.Tests/Colorspaces/Conversion/CieLchAndHslConversionTests.cs b/tests/ImageSharp.Tests/Colorspaces/Conversion/CieLchAndHslConversionTests.cs index bd1000e823..9af5b6d956 100644 --- a/tests/ImageSharp.Tests/Colorspaces/Conversion/CieLchAndHslConversionTests.cs +++ b/tests/ImageSharp.Tests/Colorspaces/Conversion/CieLchAndHslConversionTests.cs @@ -1,5 +1,5 @@ // Copyright (c) Six Labors. -// Licensed under the Apache License, Version 2.0. +// Licensed under the Six Labors Split License. using SixLabors.ImageSharp.ColorSpaces; using SixLabors.ImageSharp.ColorSpaces.Conversion; diff --git a/tests/ImageSharp.Tests/Colorspaces/Conversion/CieLchAndHsvConversionTests.cs b/tests/ImageSharp.Tests/Colorspaces/Conversion/CieLchAndHsvConversionTests.cs index 8b4a56ddb8..5df78ab208 100644 --- a/tests/ImageSharp.Tests/Colorspaces/Conversion/CieLchAndHsvConversionTests.cs +++ b/tests/ImageSharp.Tests/Colorspaces/Conversion/CieLchAndHsvConversionTests.cs @@ -1,5 +1,5 @@ // Copyright (c) Six Labors. -// Licensed under the Apache License, Version 2.0. +// Licensed under the Six Labors Split License. using SixLabors.ImageSharp.ColorSpaces; using SixLabors.ImageSharp.ColorSpaces.Conversion; diff --git a/tests/ImageSharp.Tests/Colorspaces/Conversion/CieLchAndHunterLabConversionTests.cs b/tests/ImageSharp.Tests/Colorspaces/Conversion/CieLchAndHunterLabConversionTests.cs index 21aa8ecfa1..64a172cc1c 100644 --- a/tests/ImageSharp.Tests/Colorspaces/Conversion/CieLchAndHunterLabConversionTests.cs +++ b/tests/ImageSharp.Tests/Colorspaces/Conversion/CieLchAndHunterLabConversionTests.cs @@ -1,5 +1,5 @@ // Copyright (c) Six Labors. -// Licensed under the Apache License, Version 2.0. +// Licensed under the Six Labors Split License. using SixLabors.ImageSharp.ColorSpaces; using SixLabors.ImageSharp.ColorSpaces.Conversion; diff --git a/tests/ImageSharp.Tests/Colorspaces/Conversion/CieLchAndLinearRgbConversionTests.cs b/tests/ImageSharp.Tests/Colorspaces/Conversion/CieLchAndLinearRgbConversionTests.cs index f1d3fd7645..13c69abc87 100644 --- a/tests/ImageSharp.Tests/Colorspaces/Conversion/CieLchAndLinearRgbConversionTests.cs +++ b/tests/ImageSharp.Tests/Colorspaces/Conversion/CieLchAndLinearRgbConversionTests.cs @@ -1,5 +1,5 @@ // Copyright (c) Six Labors. -// Licensed under the Apache License, Version 2.0. +// Licensed under the Six Labors Split License. using SixLabors.ImageSharp.ColorSpaces; using SixLabors.ImageSharp.ColorSpaces.Conversion; diff --git a/tests/ImageSharp.Tests/Colorspaces/Conversion/CieLchAndLmsConversionTests.cs b/tests/ImageSharp.Tests/Colorspaces/Conversion/CieLchAndLmsConversionTests.cs index 60ef9426ad..575b0b871e 100644 --- a/tests/ImageSharp.Tests/Colorspaces/Conversion/CieLchAndLmsConversionTests.cs +++ b/tests/ImageSharp.Tests/Colorspaces/Conversion/CieLchAndLmsConversionTests.cs @@ -1,5 +1,5 @@ // Copyright (c) Six Labors. -// Licensed under the Apache License, Version 2.0. +// Licensed under the Six Labors Split License. using SixLabors.ImageSharp.ColorSpaces; using SixLabors.ImageSharp.ColorSpaces.Conversion; diff --git a/tests/ImageSharp.Tests/Colorspaces/Conversion/CieLchAndRgbConversionTests.cs b/tests/ImageSharp.Tests/Colorspaces/Conversion/CieLchAndRgbConversionTests.cs index 5055295846..4dda8d0556 100644 --- a/tests/ImageSharp.Tests/Colorspaces/Conversion/CieLchAndRgbConversionTests.cs +++ b/tests/ImageSharp.Tests/Colorspaces/Conversion/CieLchAndRgbConversionTests.cs @@ -1,5 +1,5 @@ // Copyright (c) Six Labors. -// Licensed under the Apache License, Version 2.0. +// Licensed under the Six Labors Split License. using SixLabors.ImageSharp.ColorSpaces; using SixLabors.ImageSharp.ColorSpaces.Conversion; diff --git a/tests/ImageSharp.Tests/Colorspaces/Conversion/CieLchAndYCbCrConversionTests.cs b/tests/ImageSharp.Tests/Colorspaces/Conversion/CieLchAndYCbCrConversionTests.cs index c353245489..da5273dc88 100644 --- a/tests/ImageSharp.Tests/Colorspaces/Conversion/CieLchAndYCbCrConversionTests.cs +++ b/tests/ImageSharp.Tests/Colorspaces/Conversion/CieLchAndYCbCrConversionTests.cs @@ -1,5 +1,5 @@ // Copyright (c) Six Labors. -// Licensed under the Apache License, Version 2.0. +// Licensed under the Six Labors Split License. using SixLabors.ImageSharp.ColorSpaces; using SixLabors.ImageSharp.ColorSpaces.Conversion; diff --git a/tests/ImageSharp.Tests/Colorspaces/Conversion/CieLchuvAndCieLchConversionTests.cs b/tests/ImageSharp.Tests/Colorspaces/Conversion/CieLchuvAndCieLchConversionTests.cs index c3d9fd0d67..f1339346c0 100644 --- a/tests/ImageSharp.Tests/Colorspaces/Conversion/CieLchuvAndCieLchConversionTests.cs +++ b/tests/ImageSharp.Tests/Colorspaces/Conversion/CieLchuvAndCieLchConversionTests.cs @@ -1,5 +1,5 @@ // Copyright (c) Six Labors. -// Licensed under the Apache License, Version 2.0. +// Licensed under the Six Labors Split License. using SixLabors.ImageSharp.ColorSpaces; using SixLabors.ImageSharp.ColorSpaces.Conversion; diff --git a/tests/ImageSharp.Tests/Colorspaces/Conversion/CieLchuvAndCmykConversionTests.cs b/tests/ImageSharp.Tests/Colorspaces/Conversion/CieLchuvAndCmykConversionTests.cs index 6b8536608a..6061b1fc0e 100644 --- a/tests/ImageSharp.Tests/Colorspaces/Conversion/CieLchuvAndCmykConversionTests.cs +++ b/tests/ImageSharp.Tests/Colorspaces/Conversion/CieLchuvAndCmykConversionTests.cs @@ -1,5 +1,5 @@ // Copyright (c) Six Labors. -// Licensed under the Apache License, Version 2.0. +// Licensed under the Six Labors Split License. using SixLabors.ImageSharp.ColorSpaces; using SixLabors.ImageSharp.ColorSpaces.Conversion; diff --git a/tests/ImageSharp.Tests/Colorspaces/Conversion/CieXyzAndCieLabConversionTest.cs b/tests/ImageSharp.Tests/Colorspaces/Conversion/CieXyzAndCieLabConversionTest.cs index e2db3e775d..fae4d28e30 100644 --- a/tests/ImageSharp.Tests/Colorspaces/Conversion/CieXyzAndCieLabConversionTest.cs +++ b/tests/ImageSharp.Tests/Colorspaces/Conversion/CieXyzAndCieLabConversionTest.cs @@ -1,5 +1,5 @@ // Copyright (c) Six Labors. -// Licensed under the Apache License, Version 2.0. +// Licensed under the Six Labors Split License. using SixLabors.ImageSharp.ColorSpaces; using SixLabors.ImageSharp.ColorSpaces.Conversion; diff --git a/tests/ImageSharp.Tests/Colorspaces/Conversion/CieXyzAndCieLuvConversionTest.cs b/tests/ImageSharp.Tests/Colorspaces/Conversion/CieXyzAndCieLuvConversionTest.cs index 629ce5edf7..12daeff887 100644 --- a/tests/ImageSharp.Tests/Colorspaces/Conversion/CieXyzAndCieLuvConversionTest.cs +++ b/tests/ImageSharp.Tests/Colorspaces/Conversion/CieXyzAndCieLuvConversionTest.cs @@ -1,5 +1,5 @@ // Copyright (c) Six Labors. -// Licensed under the Apache License, Version 2.0. +// Licensed under the Six Labors Split License. using SixLabors.ImageSharp.ColorSpaces; using SixLabors.ImageSharp.ColorSpaces.Conversion; diff --git a/tests/ImageSharp.Tests/Colorspaces/Conversion/CieXyzAndCieXyyConversionTest.cs b/tests/ImageSharp.Tests/Colorspaces/Conversion/CieXyzAndCieXyyConversionTest.cs index a70e31ae4d..65447453f6 100644 --- a/tests/ImageSharp.Tests/Colorspaces/Conversion/CieXyzAndCieXyyConversionTest.cs +++ b/tests/ImageSharp.Tests/Colorspaces/Conversion/CieXyzAndCieXyyConversionTest.cs @@ -1,5 +1,5 @@ // Copyright (c) Six Labors. -// Licensed under the Apache License, Version 2.0. +// Licensed under the Six Labors Split License. using SixLabors.ImageSharp.ColorSpaces; using SixLabors.ImageSharp.ColorSpaces.Conversion; diff --git a/tests/ImageSharp.Tests/Colorspaces/Conversion/CieXyzAndHunterLabConversionTest.cs b/tests/ImageSharp.Tests/Colorspaces/Conversion/CieXyzAndHunterLabConversionTest.cs index a6fbb4d528..33bebe05d2 100644 --- a/tests/ImageSharp.Tests/Colorspaces/Conversion/CieXyzAndHunterLabConversionTest.cs +++ b/tests/ImageSharp.Tests/Colorspaces/Conversion/CieXyzAndHunterLabConversionTest.cs @@ -1,5 +1,5 @@ // Copyright (c) Six Labors. -// Licensed under the Apache License, Version 2.0. +// Licensed under the Six Labors Split License. using SixLabors.ImageSharp.ColorSpaces; using SixLabors.ImageSharp.ColorSpaces.Conversion; diff --git a/tests/ImageSharp.Tests/Colorspaces/Conversion/CieXyzAndLmsConversionTest.cs b/tests/ImageSharp.Tests/Colorspaces/Conversion/CieXyzAndLmsConversionTest.cs index ef652c87cc..a5e854926b 100644 --- a/tests/ImageSharp.Tests/Colorspaces/Conversion/CieXyzAndLmsConversionTest.cs +++ b/tests/ImageSharp.Tests/Colorspaces/Conversion/CieXyzAndLmsConversionTest.cs @@ -1,5 +1,5 @@ // Copyright (c) Six Labors. -// Licensed under the Apache License, Version 2.0. +// Licensed under the Six Labors Split License. using SixLabors.ImageSharp.ColorSpaces; using SixLabors.ImageSharp.ColorSpaces.Conversion; diff --git a/tests/ImageSharp.Tests/Colorspaces/Conversion/CmykAndCieLchConversionTests.cs b/tests/ImageSharp.Tests/Colorspaces/Conversion/CmykAndCieLchConversionTests.cs index 3fae1e2c90..9325f2786f 100644 --- a/tests/ImageSharp.Tests/Colorspaces/Conversion/CmykAndCieLchConversionTests.cs +++ b/tests/ImageSharp.Tests/Colorspaces/Conversion/CmykAndCieLchConversionTests.cs @@ -1,5 +1,5 @@ // Copyright (c) Six Labors. -// Licensed under the Apache License, Version 2.0. +// Licensed under the Six Labors Split License. using SixLabors.ImageSharp.ColorSpaces; using SixLabors.ImageSharp.ColorSpaces.Conversion; diff --git a/tests/ImageSharp.Tests/Colorspaces/Conversion/CmykAndCieLuvConversionTests.cs b/tests/ImageSharp.Tests/Colorspaces/Conversion/CmykAndCieLuvConversionTests.cs index c6c2f5c1cf..0774618c16 100644 --- a/tests/ImageSharp.Tests/Colorspaces/Conversion/CmykAndCieLuvConversionTests.cs +++ b/tests/ImageSharp.Tests/Colorspaces/Conversion/CmykAndCieLuvConversionTests.cs @@ -1,5 +1,5 @@ // Copyright (c) Six Labors. -// Licensed under the Apache License, Version 2.0. +// Licensed under the Six Labors Split License. using SixLabors.ImageSharp.ColorSpaces; using SixLabors.ImageSharp.ColorSpaces.Conversion; diff --git a/tests/ImageSharp.Tests/Colorspaces/Conversion/CmykAndCieXyyConversionTests.cs b/tests/ImageSharp.Tests/Colorspaces/Conversion/CmykAndCieXyyConversionTests.cs index 58eb6dcdc3..8fa92c67b5 100644 --- a/tests/ImageSharp.Tests/Colorspaces/Conversion/CmykAndCieXyyConversionTests.cs +++ b/tests/ImageSharp.Tests/Colorspaces/Conversion/CmykAndCieXyyConversionTests.cs @@ -1,5 +1,5 @@ // Copyright (c) Six Labors. -// Licensed under the Apache License, Version 2.0. +// Licensed under the Six Labors Split License. using SixLabors.ImageSharp.ColorSpaces; using SixLabors.ImageSharp.ColorSpaces.Conversion; diff --git a/tests/ImageSharp.Tests/Colorspaces/Conversion/CmykAndCieXyzConversionTests.cs b/tests/ImageSharp.Tests/Colorspaces/Conversion/CmykAndCieXyzConversionTests.cs index e09892a21e..9f9f40ef08 100644 --- a/tests/ImageSharp.Tests/Colorspaces/Conversion/CmykAndCieXyzConversionTests.cs +++ b/tests/ImageSharp.Tests/Colorspaces/Conversion/CmykAndCieXyzConversionTests.cs @@ -1,5 +1,5 @@ // Copyright (c) Six Labors. -// Licensed under the Apache License, Version 2.0. +// Licensed under the Six Labors Split License. using SixLabors.ImageSharp.ColorSpaces; using SixLabors.ImageSharp.ColorSpaces.Conversion; diff --git a/tests/ImageSharp.Tests/Colorspaces/Conversion/CmykAndHslConversionTests.cs b/tests/ImageSharp.Tests/Colorspaces/Conversion/CmykAndHslConversionTests.cs index 16faff9113..d60b499d0c 100644 --- a/tests/ImageSharp.Tests/Colorspaces/Conversion/CmykAndHslConversionTests.cs +++ b/tests/ImageSharp.Tests/Colorspaces/Conversion/CmykAndHslConversionTests.cs @@ -1,5 +1,5 @@ // Copyright (c) Six Labors. -// Licensed under the Apache License, Version 2.0. +// Licensed under the Six Labors Split License. using SixLabors.ImageSharp.ColorSpaces; using SixLabors.ImageSharp.ColorSpaces.Conversion; diff --git a/tests/ImageSharp.Tests/Colorspaces/Conversion/CmykAndHsvConversionTests.cs b/tests/ImageSharp.Tests/Colorspaces/Conversion/CmykAndHsvConversionTests.cs index 1c75f8c3a4..4f75907b9b 100644 --- a/tests/ImageSharp.Tests/Colorspaces/Conversion/CmykAndHsvConversionTests.cs +++ b/tests/ImageSharp.Tests/Colorspaces/Conversion/CmykAndHsvConversionTests.cs @@ -1,5 +1,5 @@ // Copyright (c) Six Labors. -// Licensed under the Apache License, Version 2.0. +// Licensed under the Six Labors Split License. using SixLabors.ImageSharp.ColorSpaces; using SixLabors.ImageSharp.ColorSpaces.Conversion; diff --git a/tests/ImageSharp.Tests/Colorspaces/Conversion/CmykAndHunterLabConversionTests.cs b/tests/ImageSharp.Tests/Colorspaces/Conversion/CmykAndHunterLabConversionTests.cs index 780065e0ef..f4304af24b 100644 --- a/tests/ImageSharp.Tests/Colorspaces/Conversion/CmykAndHunterLabConversionTests.cs +++ b/tests/ImageSharp.Tests/Colorspaces/Conversion/CmykAndHunterLabConversionTests.cs @@ -1,5 +1,5 @@ // Copyright (c) Six Labors. -// Licensed under the Apache License, Version 2.0. +// Licensed under the Six Labors Split License. using SixLabors.ImageSharp.ColorSpaces; using SixLabors.ImageSharp.ColorSpaces.Conversion; diff --git a/tests/ImageSharp.Tests/Colorspaces/Conversion/CmykAndYCbCrConversionTests.cs b/tests/ImageSharp.Tests/Colorspaces/Conversion/CmykAndYCbCrConversionTests.cs index 39fb8eb62e..43dd4dc14f 100644 --- a/tests/ImageSharp.Tests/Colorspaces/Conversion/CmykAndYCbCrConversionTests.cs +++ b/tests/ImageSharp.Tests/Colorspaces/Conversion/CmykAndYCbCrConversionTests.cs @@ -1,5 +1,5 @@ // Copyright (c) Six Labors. -// Licensed under the Apache License, Version 2.0. +// Licensed under the Six Labors Split License. using SixLabors.ImageSharp.ColorSpaces; using SixLabors.ImageSharp.ColorSpaces.Conversion; diff --git a/tests/ImageSharp.Tests/Colorspaces/Conversion/RgbAndCieXyzConversionTest.cs b/tests/ImageSharp.Tests/Colorspaces/Conversion/RgbAndCieXyzConversionTest.cs index b7138a2c10..1e7b3bac4b 100644 --- a/tests/ImageSharp.Tests/Colorspaces/Conversion/RgbAndCieXyzConversionTest.cs +++ b/tests/ImageSharp.Tests/Colorspaces/Conversion/RgbAndCieXyzConversionTest.cs @@ -1,5 +1,5 @@ // Copyright (c) Six Labors. -// Licensed under the Apache License, Version 2.0. +// Licensed under the Six Labors Split License. using SixLabors.ImageSharp.ColorSpaces; using SixLabors.ImageSharp.ColorSpaces.Conversion; diff --git a/tests/ImageSharp.Tests/Colorspaces/Conversion/RgbAndCmykConversionTest.cs b/tests/ImageSharp.Tests/Colorspaces/Conversion/RgbAndCmykConversionTest.cs index e95dd80eea..2020d5b541 100644 --- a/tests/ImageSharp.Tests/Colorspaces/Conversion/RgbAndCmykConversionTest.cs +++ b/tests/ImageSharp.Tests/Colorspaces/Conversion/RgbAndCmykConversionTest.cs @@ -1,5 +1,5 @@ // Copyright (c) Six Labors. -// Licensed under the Apache License, Version 2.0. +// Licensed under the Six Labors Split License. using SixLabors.ImageSharp.ColorSpaces; using SixLabors.ImageSharp.ColorSpaces.Conversion; diff --git a/tests/ImageSharp.Tests/Colorspaces/Conversion/RgbAndHsvConversionTest.cs b/tests/ImageSharp.Tests/Colorspaces/Conversion/RgbAndHsvConversionTest.cs index ac2f97b587..185157e977 100644 --- a/tests/ImageSharp.Tests/Colorspaces/Conversion/RgbAndHsvConversionTest.cs +++ b/tests/ImageSharp.Tests/Colorspaces/Conversion/RgbAndHsvConversionTest.cs @@ -1,5 +1,5 @@ // Copyright (c) Six Labors. -// Licensed under the Apache License, Version 2.0. +// Licensed under the Six Labors Split License. using SixLabors.ImageSharp.ColorSpaces; using SixLabors.ImageSharp.ColorSpaces.Conversion; diff --git a/tests/ImageSharp.Tests/Colorspaces/Conversion/RgbAndYCbCrConversionTest.cs b/tests/ImageSharp.Tests/Colorspaces/Conversion/RgbAndYCbCrConversionTest.cs index 07d148f685..7c9333b31a 100644 --- a/tests/ImageSharp.Tests/Colorspaces/Conversion/RgbAndYCbCrConversionTest.cs +++ b/tests/ImageSharp.Tests/Colorspaces/Conversion/RgbAndYCbCrConversionTest.cs @@ -1,5 +1,5 @@ // Copyright (c) Six Labors. -// Licensed under the Apache License, Version 2.0. +// Licensed under the Six Labors Split License. using SixLabors.ImageSharp.ColorSpaces; using SixLabors.ImageSharp.ColorSpaces.Conversion; diff --git a/tests/ImageSharp.Tests/Colorspaces/HslTests.cs b/tests/ImageSharp.Tests/Colorspaces/HslTests.cs index cf8fe9efda..be8f988277 100644 --- a/tests/ImageSharp.Tests/Colorspaces/HslTests.cs +++ b/tests/ImageSharp.Tests/Colorspaces/HslTests.cs @@ -1,5 +1,5 @@ // Copyright (c) Six Labors. -// Licensed under the Apache License, Version 2.0. +// Licensed under the Six Labors Split License. using System.Numerics; using SixLabors.ImageSharp.ColorSpaces; diff --git a/tests/ImageSharp.Tests/Colorspaces/HsvTests.cs b/tests/ImageSharp.Tests/Colorspaces/HsvTests.cs index 56e98a446a..a68e36bda3 100644 --- a/tests/ImageSharp.Tests/Colorspaces/HsvTests.cs +++ b/tests/ImageSharp.Tests/Colorspaces/HsvTests.cs @@ -1,5 +1,5 @@ // Copyright (c) Six Labors. -// Licensed under the Apache License, Version 2.0. +// Licensed under the Six Labors Split License. using System.Numerics; using SixLabors.ImageSharp.ColorSpaces; diff --git a/tests/ImageSharp.Tests/Colorspaces/Icc/Calculators/CurveCalculatorTests.cs b/tests/ImageSharp.Tests/Colorspaces/Icc/Calculators/CurveCalculatorTests.cs index d52ec5de79..384f68afdf 100644 --- a/tests/ImageSharp.Tests/Colorspaces/Icc/Calculators/CurveCalculatorTests.cs +++ b/tests/ImageSharp.Tests/Colorspaces/Icc/Calculators/CurveCalculatorTests.cs @@ -1,5 +1,5 @@ // Copyright (c) Six Labors. -// Licensed under the Apache License, Version 2.0. +// Licensed under the Six Labors Split License. using SixLabors.ImageSharp.ColorSpaces.Conversion.Icc; using SixLabors.ImageSharp.Metadata.Profiles.Icc; diff --git a/tests/ImageSharp.Tests/Colorspaces/Icc/Calculators/LutABCalculatorTests.cs b/tests/ImageSharp.Tests/Colorspaces/Icc/Calculators/LutABCalculatorTests.cs index f4d3d0e76f..712d096cbb 100644 --- a/tests/ImageSharp.Tests/Colorspaces/Icc/Calculators/LutABCalculatorTests.cs +++ b/tests/ImageSharp.Tests/Colorspaces/Icc/Calculators/LutABCalculatorTests.cs @@ -1,5 +1,5 @@ // Copyright (c) Six Labors. -// Licensed under the Apache License, Version 2.0. +// Licensed under the Six Labors Split License. using System.Numerics; using SixLabors.ImageSharp.ColorSpaces.Conversion.Icc; diff --git a/tests/ImageSharp.Tests/Colorspaces/Icc/Calculators/LutCalculatorTests.cs b/tests/ImageSharp.Tests/Colorspaces/Icc/Calculators/LutCalculatorTests.cs index b371d3daa0..3caad03a6c 100644 --- a/tests/ImageSharp.Tests/Colorspaces/Icc/Calculators/LutCalculatorTests.cs +++ b/tests/ImageSharp.Tests/Colorspaces/Icc/Calculators/LutCalculatorTests.cs @@ -1,5 +1,5 @@ // Copyright (c) Six Labors. -// Licensed under the Apache License, Version 2.0. +// Licensed under the Six Labors Split License. using SixLabors.ImageSharp.ColorSpaces.Conversion.Icc; using SixLabors.ImageSharp.Tests.TestDataIcc.Conversion; diff --git a/tests/ImageSharp.Tests/Colorspaces/Icc/Calculators/LutEntryCalculatorTests.cs b/tests/ImageSharp.Tests/Colorspaces/Icc/Calculators/LutEntryCalculatorTests.cs index a0558701c9..8b374dedb6 100644 --- a/tests/ImageSharp.Tests/Colorspaces/Icc/Calculators/LutEntryCalculatorTests.cs +++ b/tests/ImageSharp.Tests/Colorspaces/Icc/Calculators/LutEntryCalculatorTests.cs @@ -1,5 +1,5 @@ // Copyright (c) Six Labors. -// Licensed under the Apache License, Version 2.0. +// Licensed under the Six Labors Split License. using System.Numerics; using SixLabors.ImageSharp.ColorSpaces.Conversion.Icc; diff --git a/tests/ImageSharp.Tests/Colorspaces/Icc/Calculators/MatrixCalculatorTests.cs b/tests/ImageSharp.Tests/Colorspaces/Icc/Calculators/MatrixCalculatorTests.cs index a353e7df28..925b00ef4f 100644 --- a/tests/ImageSharp.Tests/Colorspaces/Icc/Calculators/MatrixCalculatorTests.cs +++ b/tests/ImageSharp.Tests/Colorspaces/Icc/Calculators/MatrixCalculatorTests.cs @@ -1,5 +1,5 @@ // Copyright (c) Six Labors. -// Licensed under the Apache License, Version 2.0. +// Licensed under the Six Labors Split License. using System.Numerics; using SixLabors.ImageSharp.ColorSpaces.Conversion.Icc; diff --git a/tests/ImageSharp.Tests/Colorspaces/Icc/Calculators/ParametricCurveCalculatorTests.cs b/tests/ImageSharp.Tests/Colorspaces/Icc/Calculators/ParametricCurveCalculatorTests.cs index e15867d9bf..89d0e1da12 100644 --- a/tests/ImageSharp.Tests/Colorspaces/Icc/Calculators/ParametricCurveCalculatorTests.cs +++ b/tests/ImageSharp.Tests/Colorspaces/Icc/Calculators/ParametricCurveCalculatorTests.cs @@ -1,5 +1,5 @@ // Copyright (c) Six Labors. -// Licensed under the Apache License, Version 2.0. +// Licensed under the Six Labors Split License. using SixLabors.ImageSharp.ColorSpaces.Conversion.Icc; using SixLabors.ImageSharp.Metadata.Profiles.Icc; diff --git a/tests/ImageSharp.Tests/Colorspaces/Icc/Calculators/TrcCalculatorTests.cs b/tests/ImageSharp.Tests/Colorspaces/Icc/Calculators/TrcCalculatorTests.cs index dcaebc9d34..c7b198b8dc 100644 --- a/tests/ImageSharp.Tests/Colorspaces/Icc/Calculators/TrcCalculatorTests.cs +++ b/tests/ImageSharp.Tests/Colorspaces/Icc/Calculators/TrcCalculatorTests.cs @@ -1,5 +1,5 @@ // Copyright (c) Six Labors. -// Licensed under the Apache License, Version 2.0. +// Licensed under the Six Labors Split License. using System.Numerics; using SixLabors.ImageSharp.ColorSpaces.Conversion.Icc; diff --git a/tests/ImageSharp.Tests/Colorspaces/LinearRgbTests.cs b/tests/ImageSharp.Tests/Colorspaces/LinearRgbTests.cs index a6a0f580cb..a2552cab81 100644 --- a/tests/ImageSharp.Tests/Colorspaces/LinearRgbTests.cs +++ b/tests/ImageSharp.Tests/Colorspaces/LinearRgbTests.cs @@ -1,5 +1,5 @@ // Copyright (c) Six Labors. -// Licensed under the Apache License, Version 2.0. +// Licensed under the Six Labors Split License. using System.Numerics; using SixLabors.ImageSharp.ColorSpaces; diff --git a/tests/ImageSharp.Tests/Colorspaces/YCbCrTests.cs b/tests/ImageSharp.Tests/Colorspaces/YCbCrTests.cs index b3c0558cbb..5b9fb8c447 100644 --- a/tests/ImageSharp.Tests/Colorspaces/YCbCrTests.cs +++ b/tests/ImageSharp.Tests/Colorspaces/YCbCrTests.cs @@ -1,5 +1,5 @@ // Copyright (c) Six Labors. -// Licensed under the Apache License, Version 2.0. +// Licensed under the Six Labors Split License. using System.Numerics; using SixLabors.ImageSharp.ColorSpaces; diff --git a/tests/ImageSharp.Tests/TestDataIcc/Conversion/IccConversionDataClut.cs b/tests/ImageSharp.Tests/TestDataIcc/Conversion/IccConversionDataClut.cs index 29474187b4..f24e02c780 100644 --- a/tests/ImageSharp.Tests/TestDataIcc/Conversion/IccConversionDataClut.cs +++ b/tests/ImageSharp.Tests/TestDataIcc/Conversion/IccConversionDataClut.cs @@ -1,5 +1,5 @@ // Copyright (c) Six Labors. -// Licensed under the Apache License, Version 2.0. +// Licensed under the Six Labors Split License. using System.Numerics; using SixLabors.ImageSharp.Metadata.Profiles.Icc; diff --git a/tests/ImageSharp.Tests/TestDataIcc/Conversion/IccConversionDataLut.cs b/tests/ImageSharp.Tests/TestDataIcc/Conversion/IccConversionDataLut.cs index f9e5bafd11..9e48fcc283 100644 --- a/tests/ImageSharp.Tests/TestDataIcc/Conversion/IccConversionDataLut.cs +++ b/tests/ImageSharp.Tests/TestDataIcc/Conversion/IccConversionDataLut.cs @@ -1,5 +1,5 @@ // Copyright (c) Six Labors. -// Licensed under the Apache License, Version 2.0. +// Licensed under the Six Labors Split License. namespace SixLabors.ImageSharp.Tests.TestDataIcc.Conversion { diff --git a/tests/ImageSharp.Tests/TestDataIcc/Conversion/IccConversionDataLutAB.cs b/tests/ImageSharp.Tests/TestDataIcc/Conversion/IccConversionDataLutAB.cs index aca6599c27..b8f4c8d1e7 100644 --- a/tests/ImageSharp.Tests/TestDataIcc/Conversion/IccConversionDataLutAB.cs +++ b/tests/ImageSharp.Tests/TestDataIcc/Conversion/IccConversionDataLutAB.cs @@ -1,5 +1,5 @@ // Copyright (c) Six Labors. -// Licensed under the Apache License, Version 2.0. +// Licensed under the Six Labors Split License. using System.Numerics; using SixLabors.ImageSharp.Metadata.Profiles.Icc; diff --git a/tests/ImageSharp.Tests/TestDataIcc/Conversion/IccConversionDataLutEntry.cs b/tests/ImageSharp.Tests/TestDataIcc/Conversion/IccConversionDataLutEntry.cs index 95b94793b9..03c3355a35 100644 --- a/tests/ImageSharp.Tests/TestDataIcc/Conversion/IccConversionDataLutEntry.cs +++ b/tests/ImageSharp.Tests/TestDataIcc/Conversion/IccConversionDataLutEntry.cs @@ -1,5 +1,5 @@ // Copyright (c) Six Labors. -// Licensed under the Apache License, Version 2.0. +// Licensed under the Six Labors Split License. using System.Numerics; using SixLabors.ImageSharp.Metadata.Profiles.Icc; diff --git a/tests/ImageSharp.Tests/TestDataIcc/Conversion/IccConversionDataMatrix.cs b/tests/ImageSharp.Tests/TestDataIcc/Conversion/IccConversionDataMatrix.cs index b45607c2db..dcb48f3a4a 100644 --- a/tests/ImageSharp.Tests/TestDataIcc/Conversion/IccConversionDataMatrix.cs +++ b/tests/ImageSharp.Tests/TestDataIcc/Conversion/IccConversionDataMatrix.cs @@ -1,5 +1,5 @@ // Copyright (c) Six Labors. -// Licensed under the Apache License, Version 2.0. +// Licensed under the Six Labors Split License. using System.Numerics; diff --git a/tests/ImageSharp.Tests/TestDataIcc/Conversion/IccConversionDataMultiProcessElement.cs b/tests/ImageSharp.Tests/TestDataIcc/Conversion/IccConversionDataMultiProcessElement.cs index 8848576efa..2c3f2651ec 100644 --- a/tests/ImageSharp.Tests/TestDataIcc/Conversion/IccConversionDataMultiProcessElement.cs +++ b/tests/ImageSharp.Tests/TestDataIcc/Conversion/IccConversionDataMultiProcessElement.cs @@ -1,5 +1,5 @@ // Copyright (c) Six Labors. -// Licensed under the Apache License, Version 2.0. +// Licensed under the Six Labors Split License. using SixLabors.ImageSharp.Metadata.Profiles.Icc; diff --git a/tests/ImageSharp.Tests/TestDataIcc/Conversion/IccConversionDataTrc.cs b/tests/ImageSharp.Tests/TestDataIcc/Conversion/IccConversionDataTrc.cs index 4d813bd2b7..ee20f5a0df 100644 --- a/tests/ImageSharp.Tests/TestDataIcc/Conversion/IccConversionDataTrc.cs +++ b/tests/ImageSharp.Tests/TestDataIcc/Conversion/IccConversionDataTrc.cs @@ -1,5 +1,5 @@ // Copyright (c) Six Labors. -// Licensed under the Apache License, Version 2.0. +// Licensed under the Six Labors Split License. using System.Numerics; using SixLabors.ImageSharp.Metadata.Profiles.Icc; From d229fed8a43a330f5091c23a51eccbc3a84e2e07 Mon Sep 17 00:00:00 2001 From: Brian Popow Date: Thu, 24 Nov 2022 21:02:15 +0100 Subject: [PATCH 08/42] Fix icc namespaces --- .../Formats/Jpg/JpegEncoderTests.Metadata.cs | 1 + .../DataReader/IccDataReaderCurvesTests.cs | 1 + .../ICC/DataReader/IccDataReaderLutTests.cs | 1 + .../DataReader/IccDataReaderMatrixTests.cs | 6 +- .../IccDataReaderMultiProcessElementTests.cs | 1 + .../IccDataReaderNonPrimitivesTests.cs | 1 + .../IccDataReaderPrimitivesTests.cs | 1 + .../IccDataReaderTagDataEntryTests.cs | 1 + .../DataWriter/IccDataWriterCurvesTests.cs | 6 +- .../ICC/DataWriter/IccDataWriterLutTests.cs | 6 +- .../ICC/DataWriter/IccDataWriterLutTests1.cs | 6 +- .../ICC/DataWriter/IccDataWriterLutTests2.cs | 6 +- .../DataWriter/IccDataWriterMatrixTests.cs | 6 +- .../IccDataWriterMultiProcessElementTests.cs | 6 +- .../IccDataWriterNonPrimitivesTests.cs | 6 +- .../IccDataWriterPrimitivesTests.cs | 6 +- .../IccDataWriterTagDataEntryTests.cs | 6 +- .../ICC/DataWriter/IccDataWriterTests.cs | 6 +- .../Metadata/Profiles/ICC/IccProfileTests.cs | 1 + .../Metadata/Profiles/ICC/IccReaderTests.cs | 1 + .../Metadata/Profiles/ICC/IccWriterTests.cs | 1 + .../Conversion/IccConversionDataClut.cs | 307 +++++++++--------- .../Conversion/IccConversionDataLut.cs | 41 ++- .../Conversion/IccConversionDataLutAB.cs | 79 +++-- .../Conversion/IccConversionDataLutEntry.cs | 95 +++--- .../Conversion/IccConversionDataMatrix.cs | 85 +++-- .../IccConversionDataMultiProcessElement.cs | 113 +++---- .../Conversion/IccConversionDataTrc.cs | 123 ++++--- .../TestDataIcc/IccTestDataArray.cs | 2 +- .../TestDataIcc/IccTestDataCurves.cs | 2 +- .../TestDataIcc/IccTestDataLut.cs | 2 +- .../TestDataIcc/IccTestDataMatrix.cs | 4 +- .../IccTestDataMultiProcessElements.cs | 2 +- .../TestDataIcc/IccTestDataNonPrimitives.cs | 2 +- .../TestDataIcc/IccTestDataPrimitives.cs | 2 +- .../TestDataIcc/IccTestDataProfiles.cs | 2 +- .../TestDataIcc/IccTestDataTagDataEntry.cs | 3 +- 37 files changed, 460 insertions(+), 480 deletions(-) diff --git a/tests/ImageSharp.Tests/Formats/Jpg/JpegEncoderTests.Metadata.cs b/tests/ImageSharp.Tests/Formats/Jpg/JpegEncoderTests.Metadata.cs index 404c11e7d7..6e5ae192a2 100644 --- a/tests/ImageSharp.Tests/Formats/Jpg/JpegEncoderTests.Metadata.cs +++ b/tests/ImageSharp.Tests/Formats/Jpg/JpegEncoderTests.Metadata.cs @@ -7,6 +7,7 @@ using SixLabors.ImageSharp.Metadata.Profiles.Icc; using SixLabors.ImageSharp.Metadata.Profiles.Iptc; using SixLabors.ImageSharp.PixelFormats; +using SixLabors.ImageSharp.Tests.TestDataIcc; namespace SixLabors.ImageSharp.Tests.Formats.Jpg; diff --git a/tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataReader/IccDataReaderCurvesTests.cs b/tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataReader/IccDataReaderCurvesTests.cs index 73ae46c2c9..86c6a5e9f2 100644 --- a/tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataReader/IccDataReaderCurvesTests.cs +++ b/tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataReader/IccDataReaderCurvesTests.cs @@ -2,6 +2,7 @@ // Licensed under the Six Labors Split License. using SixLabors.ImageSharp.Metadata.Profiles.Icc; +using SixLabors.ImageSharp.Tests.TestDataIcc; namespace SixLabors.ImageSharp.Tests.Metadata.Profiles.ICC.DataReader; diff --git a/tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataReader/IccDataReaderLutTests.cs b/tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataReader/IccDataReaderLutTests.cs index 63585a3bd4..a686d44872 100644 --- a/tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataReader/IccDataReaderLutTests.cs +++ b/tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataReader/IccDataReaderLutTests.cs @@ -2,6 +2,7 @@ // Licensed under the Six Labors Split License. using SixLabors.ImageSharp.Metadata.Profiles.Icc; +using SixLabors.ImageSharp.Tests.TestDataIcc; namespace SixLabors.ImageSharp.Tests.Metadata.Profiles.ICC.DataReader; diff --git a/tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataReader/IccDataReaderMatrixTests.cs b/tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataReader/IccDataReaderMatrixTests.cs index 86e1b73869..5ef102cd93 100644 --- a/tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataReader/IccDataReaderMatrixTests.cs +++ b/tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataReader/IccDataReaderMatrixTests.cs @@ -2,6 +2,7 @@ // Licensed under the Six Labors Split License. using SixLabors.ImageSharp.Metadata.Profiles.Icc; +using SixLabors.ImageSharp.Tests.TestDataIcc; namespace SixLabors.ImageSharp.Tests.Metadata.Profiles.ICC.DataReader; @@ -30,8 +31,5 @@ public void ReadMatrix1D(byte[] data, int yCount, bool isSingle, float[] expecte Assert.Equal(expected, output); } - private static IccDataReader CreateReader(byte[] data) - { - return new IccDataReader(data); - } + private static IccDataReader CreateReader(byte[] data) => new(data); } diff --git a/tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataReader/IccDataReaderMultiProcessElementTests.cs b/tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataReader/IccDataReaderMultiProcessElementTests.cs index 9023b1b723..930665a07c 100644 --- a/tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataReader/IccDataReaderMultiProcessElementTests.cs +++ b/tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataReader/IccDataReaderMultiProcessElementTests.cs @@ -2,6 +2,7 @@ // Licensed under the Six Labors Split License. using SixLabors.ImageSharp.Metadata.Profiles.Icc; +using SixLabors.ImageSharp.Tests.TestDataIcc; namespace SixLabors.ImageSharp.Tests.Metadata.Profiles.ICC.DataReader; diff --git a/tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataReader/IccDataReaderNonPrimitivesTests.cs b/tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataReader/IccDataReaderNonPrimitivesTests.cs index 91294a3dab..ee0464bb23 100644 --- a/tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataReader/IccDataReaderNonPrimitivesTests.cs +++ b/tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataReader/IccDataReaderNonPrimitivesTests.cs @@ -3,6 +3,7 @@ using System.Numerics; using SixLabors.ImageSharp.Metadata.Profiles.Icc; +using SixLabors.ImageSharp.Tests.TestDataIcc; namespace SixLabors.ImageSharp.Tests.Metadata.Profiles.ICC.DataReader; diff --git a/tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataReader/IccDataReaderPrimitivesTests.cs b/tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataReader/IccDataReaderPrimitivesTests.cs index b6135cd197..9c5be4c675 100644 --- a/tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataReader/IccDataReaderPrimitivesTests.cs +++ b/tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataReader/IccDataReaderPrimitivesTests.cs @@ -2,6 +2,7 @@ // Licensed under the Six Labors Split License. using SixLabors.ImageSharp.Metadata.Profiles.Icc; +using SixLabors.ImageSharp.Tests.TestDataIcc; namespace SixLabors.ImageSharp.Tests.Metadata.Profiles.ICC.DataReader; diff --git a/tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataReader/IccDataReaderTagDataEntryTests.cs b/tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataReader/IccDataReaderTagDataEntryTests.cs index 07e3e5bfb7..e0cfa65431 100644 --- a/tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataReader/IccDataReaderTagDataEntryTests.cs +++ b/tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataReader/IccDataReaderTagDataEntryTests.cs @@ -2,6 +2,7 @@ // Licensed under the Six Labors Split License. using SixLabors.ImageSharp.Metadata.Profiles.Icc; +using SixLabors.ImageSharp.Tests.TestDataIcc; namespace SixLabors.ImageSharp.Tests.Metadata.Profiles.ICC.DataReader; diff --git a/tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataWriter/IccDataWriterCurvesTests.cs b/tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataWriter/IccDataWriterCurvesTests.cs index 1a23c8d002..f6ac8517d8 100644 --- a/tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataWriter/IccDataWriterCurvesTests.cs +++ b/tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataWriter/IccDataWriterCurvesTests.cs @@ -2,6 +2,7 @@ // Licensed under the Six Labors Split License. using SixLabors.ImageSharp.Metadata.Profiles.Icc; +using SixLabors.ImageSharp.Tests.TestDataIcc; namespace SixLabors.ImageSharp.Tests.Metadata.Profiles.ICC.DataWriter; @@ -80,8 +81,5 @@ internal void WriteSampledCurveElement(byte[] expected, IccSampledCurveElement d Assert.Equal(expected, output); } - private static IccDataWriter CreateWriter() - { - return new IccDataWriter(); - } + private static IccDataWriter CreateWriter() => new IccDataWriter(); } diff --git a/tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataWriter/IccDataWriterLutTests.cs b/tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataWriter/IccDataWriterLutTests.cs index 4a3dc48bcb..8f696e99df 100644 --- a/tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataWriter/IccDataWriterLutTests.cs +++ b/tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataWriter/IccDataWriterLutTests.cs @@ -2,6 +2,7 @@ // Licensed under the Six Labors Split License. using SixLabors.ImageSharp.Metadata.Profiles.Icc; +using SixLabors.ImageSharp.Tests.TestDataIcc; namespace SixLabors.ImageSharp.Tests.Metadata.Profiles.ICC.DataWriter; @@ -80,8 +81,5 @@ internal void WriteLut16(byte[] expected, IccLut data, int count) Assert.Equal(expected, output); } - private static IccDataWriter CreateWriter() - { - return new IccDataWriter(); - } + private static IccDataWriter CreateWriter() => new IccDataWriter(); } diff --git a/tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataWriter/IccDataWriterLutTests1.cs b/tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataWriter/IccDataWriterLutTests1.cs index 1973d94b89..9317b45034 100644 --- a/tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataWriter/IccDataWriterLutTests1.cs +++ b/tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataWriter/IccDataWriterLutTests1.cs @@ -2,6 +2,7 @@ // Licensed under the Six Labors Split License. using SixLabors.ImageSharp.Metadata.Profiles.Icc; +using SixLabors.ImageSharp.Tests.TestDataIcc; namespace SixLabors.ImageSharp.Tests.Metadata.Profiles.ICC.DataWriter; @@ -80,8 +81,5 @@ internal void WriteLut16(byte[] expected, IccLut data, int count) Assert.Equal(expected, output); } - private static IccDataWriter CreateWriter() - { - return new IccDataWriter(); - } + private static IccDataWriter CreateWriter() => new(); } diff --git a/tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataWriter/IccDataWriterLutTests2.cs b/tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataWriter/IccDataWriterLutTests2.cs index 4ffc9e0c36..147a332c39 100644 --- a/tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataWriter/IccDataWriterLutTests2.cs +++ b/tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataWriter/IccDataWriterLutTests2.cs @@ -2,6 +2,7 @@ // Licensed under the Six Labors Split License. using SixLabors.ImageSharp.Metadata.Profiles.Icc; +using SixLabors.ImageSharp.Tests.TestDataIcc; namespace SixLabors.ImageSharp.Tests.Metadata.Profiles.ICC.DataWriter; @@ -80,8 +81,5 @@ internal void WriteLut16(byte[] expected, IccLut data, int count) Assert.Equal(expected, output); } - private static IccDataWriter CreateWriter() - { - return new IccDataWriter(); - } + private static IccDataWriter CreateWriter() => new(); } diff --git a/tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataWriter/IccDataWriterMatrixTests.cs b/tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataWriter/IccDataWriterMatrixTests.cs index ac2cc0ff69..c72d4386ad 100644 --- a/tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataWriter/IccDataWriterMatrixTests.cs +++ b/tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataWriter/IccDataWriterMatrixTests.cs @@ -3,6 +3,7 @@ using System.Numerics; using SixLabors.ImageSharp.Metadata.Profiles.Icc; +using SixLabors.ImageSharp.Tests.TestDataIcc; namespace SixLabors.ImageSharp.Tests.Metadata.Profiles.ICC.DataWriter; @@ -69,8 +70,5 @@ public void WriteMatrix1D_Vector3(byte[] expected, int yCount, bool isSingle, Ve Assert.Equal(expected, output); } - private static IccDataWriter CreateWriter() - { - return new IccDataWriter(); - } + private static IccDataWriter CreateWriter() => new(); } diff --git a/tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataWriter/IccDataWriterMultiProcessElementTests.cs b/tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataWriter/IccDataWriterMultiProcessElementTests.cs index ba2add5eb9..b7259d536a 100644 --- a/tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataWriter/IccDataWriterMultiProcessElementTests.cs +++ b/tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataWriter/IccDataWriterMultiProcessElementTests.cs @@ -2,6 +2,7 @@ // Licensed under the Six Labors Split License. using SixLabors.ImageSharp.Metadata.Profiles.Icc; +using SixLabors.ImageSharp.Tests.TestDataIcc; namespace SixLabors.ImageSharp.Tests.Metadata.Profiles.ICC.DataWriter; @@ -56,8 +57,5 @@ internal void WriteClutProcessElement(byte[] expected, IccClutProcessElement dat Assert.Equal(expected, output); } - private static IccDataWriter CreateWriter() - { - return new IccDataWriter(); - } + private static IccDataWriter CreateWriter() => new(); } diff --git a/tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataWriter/IccDataWriterNonPrimitivesTests.cs b/tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataWriter/IccDataWriterNonPrimitivesTests.cs index b17ed44419..b1b30d49fa 100644 --- a/tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataWriter/IccDataWriterNonPrimitivesTests.cs +++ b/tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataWriter/IccDataWriterNonPrimitivesTests.cs @@ -3,6 +3,7 @@ using System.Numerics; using SixLabors.ImageSharp.Metadata.Profiles.Icc; +using SixLabors.ImageSharp.Tests.TestDataIcc; namespace SixLabors.ImageSharp.Tests.Metadata.Profiles.ICC.DataWriter; @@ -117,8 +118,5 @@ internal void WriteScreeningChannel(byte[] expected, IccScreeningChannel data) Assert.Equal(expected, output); } - private static IccDataWriter CreateWriter() - { - return new IccDataWriter(); - } + private static IccDataWriter CreateWriter() => new(); } diff --git a/tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataWriter/IccDataWriterPrimitivesTests.cs b/tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataWriter/IccDataWriterPrimitivesTests.cs index fbe8fe1ced..c8f46d3aa4 100644 --- a/tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataWriter/IccDataWriterPrimitivesTests.cs +++ b/tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataWriter/IccDataWriterPrimitivesTests.cs @@ -2,6 +2,7 @@ // Licensed under the Six Labors Split License. using SixLabors.ImageSharp.Metadata.Profiles.Icc; +using SixLabors.ImageSharp.Tests.TestDataIcc; namespace SixLabors.ImageSharp.Tests.Metadata.Profiles.ICC.DataWriter; @@ -112,8 +113,5 @@ public void WriteUFix8(byte[] expected, float data) Assert.Equal(expected, output); } - private static IccDataWriter CreateWriter() - { - return new IccDataWriter(); - } + private static IccDataWriter CreateWriter() => new(); } diff --git a/tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataWriter/IccDataWriterTagDataEntryTests.cs b/tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataWriter/IccDataWriterTagDataEntryTests.cs index eb613a6754..791bcee5e6 100644 --- a/tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataWriter/IccDataWriterTagDataEntryTests.cs +++ b/tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataWriter/IccDataWriterTagDataEntryTests.cs @@ -2,6 +2,7 @@ // Licensed under the Six Labors Split License. using SixLabors.ImageSharp.Metadata.Profiles.Icc; +using SixLabors.ImageSharp.Tests.TestDataIcc; namespace SixLabors.ImageSharp.Tests.Metadata.Profiles.ICC.DataWriter; @@ -404,8 +405,5 @@ internal void WriteUcrBgTagDataEntry(byte[] expected, IccUcrBgTagDataEntry data, Assert.Equal(expected, output); } - private static IccDataWriter CreateWriter() - { - return new IccDataWriter(); - } + private static IccDataWriter CreateWriter() => new(); } diff --git a/tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataWriter/IccDataWriterTests.cs b/tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataWriter/IccDataWriterTests.cs index 205941fcec..606a69d390 100644 --- a/tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataWriter/IccDataWriterTests.cs +++ b/tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataWriter/IccDataWriterTests.cs @@ -2,6 +2,7 @@ // Licensed under the Six Labors Split License. using SixLabors.ImageSharp.Metadata.Profiles.Icc; +using SixLabors.ImageSharp.Tests.TestDataIcc; namespace SixLabors.ImageSharp.Tests.Metadata.Profiles.ICC.DataWriter; @@ -105,8 +106,5 @@ public void WriteArrayUInt64(byte[] expected, ulong[] data) Assert.Equal(expected, output); } - private static IccDataWriter CreateWriter() - { - return new IccDataWriter(); - } + private static IccDataWriter CreateWriter() => new(); } diff --git a/tests/ImageSharp.Tests/Metadata/Profiles/ICC/IccProfileTests.cs b/tests/ImageSharp.Tests/Metadata/Profiles/ICC/IccProfileTests.cs index 34044d245e..9c4abfe3e6 100644 --- a/tests/ImageSharp.Tests/Metadata/Profiles/ICC/IccProfileTests.cs +++ b/tests/ImageSharp.Tests/Metadata/Profiles/ICC/IccProfileTests.cs @@ -2,6 +2,7 @@ // Licensed under the Six Labors Split License. using SixLabors.ImageSharp.Metadata.Profiles.Icc; +using SixLabors.ImageSharp.Tests.TestDataIcc; namespace SixLabors.ImageSharp.Tests.Metadata.Profiles.Icc; diff --git a/tests/ImageSharp.Tests/Metadata/Profiles/ICC/IccReaderTests.cs b/tests/ImageSharp.Tests/Metadata/Profiles/ICC/IccReaderTests.cs index d999871be7..3e3a2513a4 100644 --- a/tests/ImageSharp.Tests/Metadata/Profiles/ICC/IccReaderTests.cs +++ b/tests/ImageSharp.Tests/Metadata/Profiles/ICC/IccReaderTests.cs @@ -2,6 +2,7 @@ // Licensed under the Six Labors Split License. using SixLabors.ImageSharp.Metadata.Profiles.Icc; +using SixLabors.ImageSharp.Tests.TestDataIcc; namespace SixLabors.ImageSharp.Tests.Metadata.Profiles.Icc; diff --git a/tests/ImageSharp.Tests/Metadata/Profiles/ICC/IccWriterTests.cs b/tests/ImageSharp.Tests/Metadata/Profiles/ICC/IccWriterTests.cs index 3aa032bbbd..24671aa3c5 100644 --- a/tests/ImageSharp.Tests/Metadata/Profiles/ICC/IccWriterTests.cs +++ b/tests/ImageSharp.Tests/Metadata/Profiles/ICC/IccWriterTests.cs @@ -2,6 +2,7 @@ // Licensed under the Six Labors Split License. using SixLabors.ImageSharp.Metadata.Profiles.Icc; +using SixLabors.ImageSharp.Tests.TestDataIcc; namespace SixLabors.ImageSharp.Tests.Metadata.Profiles.Icc; diff --git a/tests/ImageSharp.Tests/TestDataIcc/Conversion/IccConversionDataClut.cs b/tests/ImageSharp.Tests/TestDataIcc/Conversion/IccConversionDataClut.cs index f24e02c780..dadbc5262b 100644 --- a/tests/ImageSharp.Tests/TestDataIcc/Conversion/IccConversionDataClut.cs +++ b/tests/ImageSharp.Tests/TestDataIcc/Conversion/IccConversionDataClut.cs @@ -4,160 +4,159 @@ using System.Numerics; using SixLabors.ImageSharp.Metadata.Profiles.Icc; -namespace SixLabors.ImageSharp.Tests.TestDataIcc.Conversion +namespace SixLabors.ImageSharp.Tests.TestDataIcc.Conversion; + +public class IccConversionDataClut { - 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 = + internal static IccClut Clut3x2 = new( + 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( + 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( + new[] { - 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) }, - }; - } + 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( + 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( + new[] + { + new[] { 0f, 0.5f }, + new[] { 0.25f, 0.75f, }, + new[] { 0.5f, 1f }, + }, + new byte[] { 3 }, + IccClutDataType.Float); + + internal static IccClut Clut1x1 = new( + 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/IccConversionDataLut.cs b/tests/ImageSharp.Tests/TestDataIcc/Conversion/IccConversionDataLut.cs index 9e48fcc283..e910038efb 100644 --- a/tests/ImageSharp.Tests/TestDataIcc/Conversion/IccConversionDataLut.cs +++ b/tests/ImageSharp.Tests/TestDataIcc/Conversion/IccConversionDataLut.cs @@ -1,31 +1,30 @@ // Copyright (c) Six Labors. // Licensed under the Six Labors Split License. -namespace SixLabors.ImageSharp.Tests.TestDataIcc.Conversion +namespace SixLabors.ImageSharp.Tests.TestDataIcc.Conversion; + +public class IccConversionDataLut { - public class IccConversionDataLut - { - private static readonly float[] LutEven = { 0, 0.5f, 1 }; + private static readonly float[] LutEven = { 0, 0.5f, 1 }; - private static readonly float[] LutUneven = { 0, 0.7f, 1 }; + private static readonly float[] LutUneven = { 0, 0.7f, 1 }; - public static object[][] LutConversionTestData = - { - new object[] { LutEven, false, 0.5f, 0.5f }, - new object[] { LutEven, false, 0.25f, 0.25f }, - new object[] { LutEven, false, 0.75f, 0.75f }, + public static object[][] LutConversionTestData = + { + new object[] { LutEven, false, 0.5f, 0.5f }, + new object[] { LutEven, false, 0.25f, 0.25f }, + new object[] { LutEven, false, 0.75f, 0.75f }, - new object[] { LutEven, true, 0.5f, 0.5f }, - new object[] { LutEven, true, 0.25f, 0.25f }, - new object[] { LutEven, true, 0.75f, 0.75f }, + new object[] { LutEven, true, 0.5f, 0.5f }, + new object[] { LutEven, true, 0.25f, 0.25f }, + new object[] { LutEven, true, 0.75f, 0.75f }, - new object[] { LutUneven, false, 0.1, 0.14 }, - new object[] { LutUneven, false, 0.5, 0.7 }, - new object[] { LutUneven, false, 0.75, 0.85 }, + new object[] { LutUneven, false, 0.1, 0.14 }, + new object[] { LutUneven, false, 0.5, 0.7 }, + new object[] { LutUneven, false, 0.75, 0.85 }, - new object[] { LutUneven, true, 0.14, 0.1 }, - new object[] { LutUneven, true, 0.7, 0.5 }, - new object[] { LutUneven, true, 0.85, 0.75 }, - }; - } + new object[] { LutUneven, true, 0.14, 0.1 }, + new object[] { LutUneven, true, 0.7, 0.5 }, + new object[] { LutUneven, true, 0.85, 0.75 }, + }; } diff --git a/tests/ImageSharp.Tests/TestDataIcc/Conversion/IccConversionDataLutAB.cs b/tests/ImageSharp.Tests/TestDataIcc/Conversion/IccConversionDataLutAB.cs index b8f4c8d1e7..02fc23735b 100644 --- a/tests/ImageSharp.Tests/TestDataIcc/Conversion/IccConversionDataLutAB.cs +++ b/tests/ImageSharp.Tests/TestDataIcc/Conversion/IccConversionDataLutAB.cs @@ -4,48 +4,47 @@ using System.Numerics; using SixLabors.ImageSharp.Metadata.Profiles.Icc; -namespace SixLabors.ImageSharp.Tests.TestDataIcc.Conversion +namespace SixLabors.ImageSharp.Tests.TestDataIcc.Conversion; + +public class IccConversionDataLutAB { - public class IccConversionDataLutAB - { - private static readonly IccLutAToBTagDataEntry LutAtoBSingleCurve = new IccLutAToBTagDataEntry( - new IccTagDataEntry[] - { - IccConversionDataTrc.IdentityCurve, - IccConversionDataTrc.IdentityCurve, - IccConversionDataTrc.IdentityCurve - }, - null, - null, - null, - null, - null); + private static readonly IccLutAToBTagDataEntry LutAtoBSingleCurve = new( + new IccTagDataEntry[] + { + IccConversionDataTrc.IdentityCurve, + IccConversionDataTrc.IdentityCurve, + IccConversionDataTrc.IdentityCurve + }, + null, + null, + null, + null, + null); - // also need: - // # CurveM + matrix - // # CurveA + CLUT + CurveB - // # CurveA + CLUT + CurveM + Matrix + CurveB - private static readonly IccLutBToATagDataEntry LutBtoASingleCurve = new IccLutBToATagDataEntry( - new IccTagDataEntry[] - { - IccConversionDataTrc.IdentityCurve, - IccConversionDataTrc.IdentityCurve, - IccConversionDataTrc.IdentityCurve - }, - null, - null, - null, - null, - null); + // also need: + // # CurveM + matrix + // # CurveA + CLUT + CurveB + // # CurveA + CLUT + CurveM + Matrix + CurveB + private static readonly IccLutBToATagDataEntry LutBtoASingleCurve = new( + new IccTagDataEntry[] + { + IccConversionDataTrc.IdentityCurve, + IccConversionDataTrc.IdentityCurve, + IccConversionDataTrc.IdentityCurve + }, + null, + null, + null, + null, + null); - public static object[][] LutAToBConversionTestData = - { - new object[] { LutAtoBSingleCurve, new Vector4(0.2f, 0.3f, 0.4f, 0), new Vector4(0.2f, 0.3f, 0.4f, 0) }, - }; + public static object[][] LutAToBConversionTestData = + { + 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[] { LutBtoASingleCurve, new Vector4(0.2f, 0.3f, 0.4f, 0), new Vector4(0.2f, 0.3f, 0.4f, 0) }, - }; - } + public static object[][] LutBToAConversionTestData = + { + 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/IccConversionDataLutEntry.cs b/tests/ImageSharp.Tests/TestDataIcc/Conversion/IccConversionDataLutEntry.cs index 03c3355a35..cdffe3c23a 100644 --- a/tests/ImageSharp.Tests/TestDataIcc/Conversion/IccConversionDataLutEntry.cs +++ b/tests/ImageSharp.Tests/TestDataIcc/Conversion/IccConversionDataLutEntry.cs @@ -4,59 +4,58 @@ using System.Numerics; using SixLabors.ImageSharp.Metadata.Profiles.Icc; -namespace SixLabors.ImageSharp.Tests.TestDataIcc.Conversion +namespace SixLabors.ImageSharp.Tests.TestDataIcc.Conversion; + +public class IccConversionDataLutEntry { - public class IccConversionDataLutEntry + private static readonly IccLut Lut256 = CreateLut(256); + private static readonly IccLut Lut32 = CreateLut(32); + private static readonly IccLut LutIdentity = CreateIdentityLut(0, 1); + + private static readonly IccLut8TagDataEntry Lut8 = new( + new[] { Lut256, Lut256 }, + IccConversionDataClut.Clut2x1, + new[] { Lut256 }); + + private static readonly IccLut16TagDataEntry Lut16 = new( + new[] { Lut32, Lut32 }, + IccConversionDataClut.Clut2x1, + new[] { LutIdentity }); + + private static readonly IccLut8TagDataEntry Lut8Matrix = new( + IccConversionDataMatrix.Matrix3x3Random, + new[] { Lut256, Lut256, Lut256 }, + IccConversionDataClut.Clut3x1, + new[] { Lut256 }); + + private static readonly IccLut16TagDataEntry Lut16Matrix = new( + IccConversionDataMatrix.Matrix3x3Random, + new[] { Lut32, Lut32, Lut32 }, + IccConversionDataClut.Clut3x1, + new[] { LutIdentity }); + + private static IccLut CreateLut(int length) { - private static readonly IccLut Lut256 = CreateLut(256); - private static readonly IccLut Lut32 = CreateLut(32); - private static readonly IccLut LutIdentity = CreateIdentityLut(0, 1); - - private static readonly IccLut8TagDataEntry Lut8 = new IccLut8TagDataEntry( - new[] { Lut256, Lut256 }, - IccConversionDataClut.Clut2x1, - new[] { Lut256 }); - - private static readonly IccLut16TagDataEntry Lut16 = new IccLut16TagDataEntry( - new[] { Lut32, Lut32 }, - IccConversionDataClut.Clut2x1, - new[] { LutIdentity }); - - private static readonly IccLut8TagDataEntry Lut8Matrix = new IccLut8TagDataEntry( - IccConversionDataMatrix.Matrix3x3Random, - new[] { Lut256, Lut256, Lut256 }, - IccConversionDataClut.Clut3x1, - new[] { Lut256 }); - - private static readonly IccLut16TagDataEntry Lut16Matrix = new IccLut16TagDataEntry( - IccConversionDataMatrix.Matrix3x3Random, - new[] { Lut32, Lut32, Lut32 }, - IccConversionDataClut.Clut3x1, - new[] { LutIdentity }); - - private static IccLut CreateLut(int length) + float[] values = new float[length]; + for (int i = 0; i < values.Length; i++) { - float[] values = new float[length]; - for (int i = 0; i < values.Length; i++) - { - values[i] = 0.1f + (i / (float)length); - } - - return new IccLut(values); + values[i] = 0.1f + (i / (float)length); } - private static IccLut CreateIdentityLut(float min, float max) => new IccLut(new[] { min, max }); + return new IccLut(values); + } - public static object[][] Lut8ConversionTestData = - { - new object[] { Lut8, new Vector4(0.2f, 0.3f, 0, 0), new Vector4(0.339762866f, 0, 0, 0) }, - new object[] { Lut8Matrix, new Vector4(0.21f, 0.31f, 0.41f, 0), new Vector4(0.431305826f, 0, 0, 0) }, - }; + private static IccLut CreateIdentityLut(float min, float max) => new(new[] { min, max }); - public static object[][] Lut16ConversionTestData = - { - new object[] { Lut16, new Vector4(0.2f, 0.3f, 0, 0), new Vector4(0.245625019f, 0, 0, 0) }, - new object[] { Lut16Matrix, new Vector4(0.21f, 0.31f, 0.41f, 0), new Vector4(0.336980581f, 0, 0, 0) }, - }; - } + public static object[][] Lut8ConversionTestData = + { + new object[] { Lut8, new Vector4(0.2f, 0.3f, 0, 0), new Vector4(0.339762866f, 0, 0, 0) }, + new object[] { Lut8Matrix, new Vector4(0.21f, 0.31f, 0.41f, 0), new Vector4(0.431305826f, 0, 0, 0) }, + }; + + public static object[][] Lut16ConversionTestData = + { + new object[] { Lut16, new Vector4(0.2f, 0.3f, 0, 0), new Vector4(0.245625019f, 0, 0, 0) }, + new object[] { Lut16Matrix, new Vector4(0.21f, 0.31f, 0.41f, 0), new Vector4(0.336980581f, 0, 0, 0) }, + }; } diff --git a/tests/ImageSharp.Tests/TestDataIcc/Conversion/IccConversionDataMatrix.cs b/tests/ImageSharp.Tests/TestDataIcc/Conversion/IccConversionDataMatrix.cs index dcb48f3a4a..f91c32df8a 100644 --- a/tests/ImageSharp.Tests/TestDataIcc/Conversion/IccConversionDataMatrix.cs +++ b/tests/ImageSharp.Tests/TestDataIcc/Conversion/IccConversionDataMatrix.cs @@ -3,52 +3,51 @@ using System.Numerics; -namespace SixLabors.ImageSharp.Tests.TestDataIcc.Conversion +namespace SixLabors.ImageSharp.Tests.TestDataIcc.Conversion; + +public class IccConversionDataMatrix { - public class IccConversionDataMatrix - { - private static readonly Vector3 Vector3Zero = new Vector3(0.0f, 0.0f, 0.0f); + private static readonly Vector3 Vector3Zero = new(0.0f, 0.0f, 0.0f); - 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[,] 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[,] Matrix3x3Identity = + { + { 1, 0, 0 }, + { 0, 1, 0 }, + { 0, 0, 1 } + }; - public static object[][] MatrixConversionTestData = - { - new object[] { CreateMatrix(Matrix3x3Identity), Vector3Zero, new Vector4(0.5f, 0.5f, 0.5f, 0), new Vector4(0.5f, 0.5f, 0.5f, 0) }, - new object[] { CreateMatrix(Matrix3x3Identity), new Vector3(0.2f, 0.2f, 0.2f), new Vector4(0.5f, 0.5f, 0.5f, 0), new Vector4(0.7f, 0.7f, 0.7f, 0) }, - new object[] { CreateMatrix(Matrix3x3Random), Vector3Zero, new Vector4(0.5f, 0.5f, 0.5f, 0), new Vector4(0.6f, 0.75f, 0.9f, 0) }, - new object[] { CreateMatrix(Matrix3x3Random), new Vector3(0.1f, 0.2f, 0.3f), new Vector4(0.5f, 0.5f, 0.5f, 0), new Vector4(0.7f, 0.95f, 1.2f, 0) }, - new object[] { CreateMatrix(Matrix3x3Random), Vector3Zero, 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) }, - }; + public static object[][] MatrixConversionTestData = + { + new object[] { CreateMatrix(Matrix3x3Identity), Vector3Zero, new Vector4(0.5f, 0.5f, 0.5f, 0), new Vector4(0.5f, 0.5f, 0.5f, 0) }, + new object[] { CreateMatrix(Matrix3x3Identity), new Vector3(0.2f, 0.2f, 0.2f), new Vector4(0.5f, 0.5f, 0.5f, 0), new Vector4(0.7f, 0.7f, 0.7f, 0) }, + new object[] { CreateMatrix(Matrix3x3Random), Vector3Zero, new Vector4(0.5f, 0.5f, 0.5f, 0), new Vector4(0.6f, 0.75f, 0.9f, 0) }, + new object[] { CreateMatrix(Matrix3x3Random), new Vector3(0.1f, 0.2f, 0.3f), new Vector4(0.5f, 0.5f, 0.5f, 0), new Vector4(0.7f, 0.95f, 1.2f, 0) }, + new object[] { CreateMatrix(Matrix3x3Random), Vector3Zero, 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) => new Matrix4x4( - matrix[0, 0], - matrix[0, 1], - matrix[0, 2], - 0, - matrix[1, 0], - matrix[1, 1], - matrix[1, 2], - 0, - matrix[2, 0], - matrix[2, 1], - matrix[2, 2], - 0, - 0, - 0, - 0, - 1); - } + private static Matrix4x4 CreateMatrix(float[,] matrix) => new( + matrix[0, 0], + matrix[0, 1], + matrix[0, 2], + 0, + matrix[1, 0], + matrix[1, 1], + matrix[1, 2], + 0, + matrix[2, 0], + matrix[2, 1], + matrix[2, 2], + 0, + 0, + 0, + 0, + 1); } diff --git a/tests/ImageSharp.Tests/TestDataIcc/Conversion/IccConversionDataMultiProcessElement.cs b/tests/ImageSharp.Tests/TestDataIcc/Conversion/IccConversionDataMultiProcessElement.cs index 2c3f2651ec..3c3e576fe2 100644 --- a/tests/ImageSharp.Tests/TestDataIcc/Conversion/IccConversionDataMultiProcessElement.cs +++ b/tests/ImageSharp.Tests/TestDataIcc/Conversion/IccConversionDataMultiProcessElement.cs @@ -3,76 +3,77 @@ using SixLabors.ImageSharp.Metadata.Profiles.Icc; -namespace SixLabors.ImageSharp.Tests.TestDataIcc.Conversion +namespace SixLabors.ImageSharp.Tests.TestDataIcc.Conversion; + +public class IccConversionDataMultiProcessElement { - public class IccConversionDataMultiProcessElement + private static readonly IccMatrixProcessElement Matrix = new( + new float[,] { - private static readonly IccMatrixProcessElement Matrix = new IccMatrixProcessElement( - new float[,] - { - { 2, 4, 6 }, - { 3, 5, 7 }, - }, new float[] { 3, 4, 5 }); + { 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 }, + private static readonly IccClut Clut = new( + new[] + { + new[] { 0.2f, 0.3f }, + new[] { 0.4f, 0.5f }, - new[] { 0.21f, 0.31f }, - new[] { 0.41f, 0.51f }, + new[] { 0.21f, 0.31f }, + new[] { 0.41f, 0.51f }, - new[] { 0.22f, 0.32f }, - new[] { 0.42f, 0.52f }, + 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); + 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 IccFormulaCurveElement FormulaCurveElement1 = new(IccFormulaCurveType.Type1, 2.2f, 0.7f, 0.2f, 0.3f, 0, 0); + private static readonly IccFormulaCurveElement FormulaCurveElement2 = new(IccFormulaCurveType.Type2, 2.2f, 0.9f, 0.9f, 0.02f, 0.1f, 0); + private static readonly IccFormulaCurveElement FormulaCurveElement3 = new(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 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 IccCurveSetProcessElement CurveSet1DFormula1And2 = Create1DMultiCurveSet(new[] { 0.5f }, FormulaCurveElement1, FormulaCurveElement2); - private static readonly IccClutProcessElement ClutElement = new IccClutProcessElement(Clut); + private static readonly IccClutProcessElement ClutElement = new(Clut); - private static IccCurveSetProcessElement Create1DSingleCurveSet(IccCurveSegment segment) - { - var curve = new IccOneDimensionalCurve(new float[0], new[] { segment }); - return new IccCurveSetProcessElement(new[] { curve }); - } + 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 }); - } + 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 } }, + 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 } }, - }; + 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[][] 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 } } - }; - } + 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/IccConversionDataTrc.cs b/tests/ImageSharp.Tests/TestDataIcc/Conversion/IccConversionDataTrc.cs index ee20f5a0df..1536b2f957 100644 --- a/tests/ImageSharp.Tests/TestDataIcc/Conversion/IccConversionDataTrc.cs +++ b/tests/ImageSharp.Tests/TestDataIcc/Conversion/IccConversionDataTrc.cs @@ -4,74 +4,73 @@ using System.Numerics; using SixLabors.ImageSharp.Metadata.Profiles.Icc; -namespace SixLabors.ImageSharp.Tests.TestDataIcc.Conversion +namespace SixLabors.ImageSharp.Tests.TestDataIcc.Conversion; + +public class IccConversionDataTrc { - public class IccConversionDataTrc - { - internal static IccCurveTagDataEntry IdentityCurve = new IccCurveTagDataEntry(); - internal static IccCurveTagDataEntry Gamma2Curve = new IccCurveTagDataEntry(2); - internal static IccCurveTagDataEntry LutCurve = new IccCurveTagDataEntry(new float[] { 0, 0.7f, 1 }); + internal static IccCurveTagDataEntry IdentityCurve = new(); + internal static IccCurveTagDataEntry Gamma2Curve = new(2); + internal static IccCurveTagDataEntry LutCurve = new(new float[] { 0, 0.7f, 1 }); - internal static IccParametricCurveTagDataEntry ParamCurve1 = new IccParametricCurveTagDataEntry(new IccParametricCurve(2.2f)); - internal static IccParametricCurveTagDataEntry ParamCurve2 = new IccParametricCurveTagDataEntry(new IccParametricCurve(2.2f, 1.5f, -0.5f)); - internal static IccParametricCurveTagDataEntry ParamCurve3 = new IccParametricCurveTagDataEntry(new IccParametricCurve(2.2f, 1.5f, -0.5f, 0.3f)); - internal static IccParametricCurveTagDataEntry ParamCurve4 = new IccParametricCurveTagDataEntry(new IccParametricCurve(2.4f, 1 / 1.055f, 0.055f / 1.055f, 1 / 12.92f, 0.04045f)); - internal static IccParametricCurveTagDataEntry ParamCurve5 = new IccParametricCurveTagDataEntry(new IccParametricCurve(2.2f, 0.7f, 0.2f, 0.3f, 0.1f, 0.5f, 0.2f)); + internal static IccParametricCurveTagDataEntry ParamCurve1 = new(new IccParametricCurve(2.2f)); + internal static IccParametricCurveTagDataEntry ParamCurve2 = new(new IccParametricCurve(2.2f, 1.5f, -0.5f)); + internal static IccParametricCurveTagDataEntry ParamCurve3 = new(new IccParametricCurve(2.2f, 1.5f, -0.5f, 0.3f)); + internal static IccParametricCurveTagDataEntry ParamCurve4 = new(new IccParametricCurve(2.4f, 1 / 1.055f, 0.055f / 1.055f, 1 / 12.92f, 0.04045f)); + internal static IccParametricCurveTagDataEntry ParamCurve5 = new(new IccParametricCurve(2.2f, 0.7f, 0.2f, 0.3f, 0.1f, 0.5f, 0.2f)); - public static object[][] TrcArrayConversionTestData = + public static object[][] TrcArrayConversionTestData = + { + new object[] { - new object[] - { - new IccTagDataEntry[] { IdentityCurve, Gamma2Curve, ParamCurve1 }, - false, - new Vector4(2, 2, 0.5f, 0), - new Vector4(2, 4, 0.217637628f, 0), - }, - new object[] - { - new IccTagDataEntry[] { IdentityCurve, Gamma2Curve, ParamCurve1 }, - true, - new Vector4(1, 4, 0.217637628f, 0), - new Vector4(1, 2, 0.5f, 0), - }, - }; - - public static object[][] CurveConversionTestData = + new IccTagDataEntry[] { IdentityCurve, Gamma2Curve, ParamCurve1 }, + false, + new Vector4(2, 2, 0.5f, 0), + new Vector4(2, 4, 0.217637628f, 0), + }, + new object[] { - new object[] { IdentityCurve, false, 2, 2 }, - new object[] { Gamma2Curve, false, 2, 4 }, - new object[] { LutCurve, false, 0.1, 0.14 }, - new object[] { LutCurve, false, 0.5, 0.7 }, - new object[] { LutCurve, false, 0.75, 0.85 }, + new IccTagDataEntry[] { IdentityCurve, Gamma2Curve, ParamCurve1 }, + true, + new Vector4(1, 4, 0.217637628f, 0), + new Vector4(1, 2, 0.5f, 0), + }, + }; - new object[] { IdentityCurve, true, 2, 2 }, - new object[] { Gamma2Curve, true, 4, 2 }, - new object[] { LutCurve, true, 0.14, 0.1 }, - new object[] { LutCurve, true, 0.7, 0.5 }, - new object[] { LutCurve, true, 0.85, 0.75 }, - }; + public static object[][] CurveConversionTestData = + { + new object[] { IdentityCurve, false, 2, 2 }, + new object[] { Gamma2Curve, false, 2, 4 }, + new object[] { LutCurve, false, 0.1, 0.14 }, + new object[] { LutCurve, false, 0.5, 0.7 }, + new object[] { LutCurve, false, 0.75, 0.85 }, - public static object[][] ParametricCurveConversionTestData = - { - new object[] { ParamCurve1, false, 0.5f, 0.217637628f }, - new object[] { ParamCurve2, false, 0.6f, 0.133208528f }, - new object[] { ParamCurve2, false, 0.21f, 0 }, - new object[] { ParamCurve3, false, 0.61f, 0.444446117f }, - new object[] { ParamCurve3, false, 0.22f, 0.3f }, - new object[] { ParamCurve4, false, 0.3f, 0.0732389539f }, - new object[] { ParamCurve4, false, 0.03f, 0.00232198136f }, - new object[] { ParamCurve5, false, 0.2f, 0.593165159f }, - new object[] { ParamCurve5, false, 0.05f, 0.215f }, + new object[] { IdentityCurve, true, 2, 2 }, + new object[] { Gamma2Curve, true, 4, 2 }, + new object[] { LutCurve, true, 0.14, 0.1 }, + new object[] { LutCurve, true, 0.7, 0.5 }, + new object[] { LutCurve, true, 0.85, 0.75 }, + }; + + public static object[][] ParametricCurveConversionTestData = + { + new object[] { ParamCurve1, false, 0.5f, 0.217637628f }, + new object[] { ParamCurve2, false, 0.6f, 0.133208528f }, + new object[] { ParamCurve2, false, 0.21f, 0 }, + new object[] { ParamCurve3, false, 0.61f, 0.444446117f }, + new object[] { ParamCurve3, false, 0.22f, 0.3f }, + new object[] { ParamCurve4, false, 0.3f, 0.0732389539f }, + new object[] { ParamCurve4, false, 0.03f, 0.00232198136f }, + new object[] { ParamCurve5, false, 0.2f, 0.593165159f }, + new object[] { ParamCurve5, false, 0.05f, 0.215f }, - new object[] { ParamCurve1, true, 0.217637628f, 0.5f }, - new object[] { ParamCurve2, true, 0.133208528f, 0.6f }, - new object[] { ParamCurve2, true, 0, 1 / 3f }, - new object[] { ParamCurve3, true, 0.444446117f, 0.61f }, - new object[] { ParamCurve3, true, 0.3f, 1 / 3f }, - new object[] { ParamCurve4, true, 0.0732389539f, 0.3f }, - new object[] { ParamCurve4, true, 0.00232198136f, 0.03f }, - new object[] { ParamCurve5, true, 0.593165159f, 0.2f }, - new object[] { ParamCurve5, true, 0.215f, 0.05f }, - }; - } + new object[] { ParamCurve1, true, 0.217637628f, 0.5f }, + new object[] { ParamCurve2, true, 0.133208528f, 0.6f }, + new object[] { ParamCurve2, true, 0, 1 / 3f }, + new object[] { ParamCurve3, true, 0.444446117f, 0.61f }, + new object[] { ParamCurve3, true, 0.3f, 1 / 3f }, + new object[] { ParamCurve4, true, 0.0732389539f, 0.3f }, + new object[] { ParamCurve4, true, 0.00232198136f, 0.03f }, + new object[] { ParamCurve5, true, 0.593165159f, 0.2f }, + new object[] { ParamCurve5, true, 0.215f, 0.05f }, + }; } diff --git a/tests/ImageSharp.Tests/TestDataIcc/IccTestDataArray.cs b/tests/ImageSharp.Tests/TestDataIcc/IccTestDataArray.cs index 9b175c6e17..cedd20f2d7 100644 --- a/tests/ImageSharp.Tests/TestDataIcc/IccTestDataArray.cs +++ b/tests/ImageSharp.Tests/TestDataIcc/IccTestDataArray.cs @@ -1,7 +1,7 @@ // Copyright (c) Six Labors. // Licensed under the Six Labors Split License. -namespace SixLabors.ImageSharp.Tests; +namespace SixLabors.ImageSharp.Tests.TestDataIcc; internal static class IccTestDataArray { diff --git a/tests/ImageSharp.Tests/TestDataIcc/IccTestDataCurves.cs b/tests/ImageSharp.Tests/TestDataIcc/IccTestDataCurves.cs index 8092a847e2..6f8244f1c7 100644 --- a/tests/ImageSharp.Tests/TestDataIcc/IccTestDataCurves.cs +++ b/tests/ImageSharp.Tests/TestDataIcc/IccTestDataCurves.cs @@ -3,7 +3,7 @@ using SixLabors.ImageSharp.Metadata.Profiles.Icc; -namespace SixLabors.ImageSharp.Tests; +namespace SixLabors.ImageSharp.Tests.TestDataIcc; internal static class IccTestDataCurves { diff --git a/tests/ImageSharp.Tests/TestDataIcc/IccTestDataLut.cs b/tests/ImageSharp.Tests/TestDataIcc/IccTestDataLut.cs index ab7ded95d5..ea4a756007 100644 --- a/tests/ImageSharp.Tests/TestDataIcc/IccTestDataLut.cs +++ b/tests/ImageSharp.Tests/TestDataIcc/IccTestDataLut.cs @@ -3,7 +3,7 @@ using SixLabors.ImageSharp.Metadata.Profiles.Icc; -namespace SixLabors.ImageSharp.Tests; +namespace SixLabors.ImageSharp.Tests.TestDataIcc; internal static class IccTestDataLut { diff --git a/tests/ImageSharp.Tests/TestDataIcc/IccTestDataMatrix.cs b/tests/ImageSharp.Tests/TestDataIcc/IccTestDataMatrix.cs index 6f8bee2169..1a72d39b19 100644 --- a/tests/ImageSharp.Tests/TestDataIcc/IccTestDataMatrix.cs +++ b/tests/ImageSharp.Tests/TestDataIcc/IccTestDataMatrix.cs @@ -3,9 +3,7 @@ using System.Numerics; -namespace SixLabors.ImageSharp.Tests; - -using SixLabors.ImageSharp; +namespace SixLabors.ImageSharp.Tests.TestDataIcc; internal static class IccTestDataMatrix { diff --git a/tests/ImageSharp.Tests/TestDataIcc/IccTestDataMultiProcessElements.cs b/tests/ImageSharp.Tests/TestDataIcc/IccTestDataMultiProcessElements.cs index 2a8d87896d..2e3679e3af 100644 --- a/tests/ImageSharp.Tests/TestDataIcc/IccTestDataMultiProcessElements.cs +++ b/tests/ImageSharp.Tests/TestDataIcc/IccTestDataMultiProcessElements.cs @@ -3,7 +3,7 @@ using SixLabors.ImageSharp.Metadata.Profiles.Icc; -namespace SixLabors.ImageSharp.Tests; +namespace SixLabors.ImageSharp.Tests.TestDataIcc; internal static class IccTestDataMultiProcessElements { diff --git a/tests/ImageSharp.Tests/TestDataIcc/IccTestDataNonPrimitives.cs b/tests/ImageSharp.Tests/TestDataIcc/IccTestDataNonPrimitives.cs index 6c92ccdaee..0674274246 100644 --- a/tests/ImageSharp.Tests/TestDataIcc/IccTestDataNonPrimitives.cs +++ b/tests/ImageSharp.Tests/TestDataIcc/IccTestDataNonPrimitives.cs @@ -5,7 +5,7 @@ using System.Numerics; using SixLabors.ImageSharp.Metadata.Profiles.Icc; -namespace SixLabors.ImageSharp.Tests; +namespace SixLabors.ImageSharp.Tests.TestDataIcc; internal static class IccTestDataNonPrimitives { diff --git a/tests/ImageSharp.Tests/TestDataIcc/IccTestDataPrimitives.cs b/tests/ImageSharp.Tests/TestDataIcc/IccTestDataPrimitives.cs index 88bb13d856..81cfea46fd 100644 --- a/tests/ImageSharp.Tests/TestDataIcc/IccTestDataPrimitives.cs +++ b/tests/ImageSharp.Tests/TestDataIcc/IccTestDataPrimitives.cs @@ -1,7 +1,7 @@ // Copyright (c) Six Labors. // Licensed under the Six Labors Split License. -namespace SixLabors.ImageSharp.Tests; +namespace SixLabors.ImageSharp.Tests.TestDataIcc; internal static class IccTestDataPrimitives { diff --git a/tests/ImageSharp.Tests/TestDataIcc/IccTestDataProfiles.cs b/tests/ImageSharp.Tests/TestDataIcc/IccTestDataProfiles.cs index f2766d3ac1..7441bede83 100644 --- a/tests/ImageSharp.Tests/TestDataIcc/IccTestDataProfiles.cs +++ b/tests/ImageSharp.Tests/TestDataIcc/IccTestDataProfiles.cs @@ -4,7 +4,7 @@ using System.Numerics; using SixLabors.ImageSharp.Metadata.Profiles.Icc; -namespace SixLabors.ImageSharp.Tests; +namespace SixLabors.ImageSharp.Tests.TestDataIcc; internal static class IccTestDataProfiles { diff --git a/tests/ImageSharp.Tests/TestDataIcc/IccTestDataTagDataEntry.cs b/tests/ImageSharp.Tests/TestDataIcc/IccTestDataTagDataEntry.cs index 6c010a5f03..a83dc3575d 100644 --- a/tests/ImageSharp.Tests/TestDataIcc/IccTestDataTagDataEntry.cs +++ b/tests/ImageSharp.Tests/TestDataIcc/IccTestDataTagDataEntry.cs @@ -2,10 +2,9 @@ // Licensed under the Six Labors Split License. using System.Globalization; -using System.Numerics; using SixLabors.ImageSharp.Metadata.Profiles.Icc; -namespace SixLabors.ImageSharp.Tests; +namespace SixLabors.ImageSharp.Tests.TestDataIcc; internal static class IccTestDataTagDataEntry { From 0a08da0bc66205a11a2d4f6c2b1846d0045274f0 Mon Sep 17 00:00:00 2001 From: Brian Popow Date: Sun, 27 Nov 2022 17:25:46 +0100 Subject: [PATCH 09/42] Use file scoped namespaces --- .../CurveCalculator.CalculationType.cs | 17 +- .../Icc/Calculators/CurveCalculator.cs | 70 +++-- .../Icc/Calculators/GrayTrcCalculator.cs | 25 +- .../Icc/Calculators/ISingleCalculator.cs | 21 +- .../Icc/Calculators/IVector4Calculator.cs | 21 +- .../LutABCalculator.CalculationType.cs | 21 +- .../Icc/Calculators/LutABCalculator.cs | 225 ++++++++-------- .../Icc/Calculators/LutCalculator.cs | 99 ++++--- .../Icc/Calculators/LutEntryCalculator.cs | 101 ++++--- .../Icc/Calculators/MatrixCalculator.cs | 31 ++- .../Calculators/ParametricCurveCalculator.cs | 245 +++++++++-------- .../Icc/Calculators/TrcCalculator.cs | 57 ++-- .../Icc/IccConverterBase.ConversionMethod.cs | 93 ++++--- .../Icc/IccConverterbase.Conversions.cs | 249 +++++++++--------- .../Implementation/Icc/IccConverterbase.cs | 45 ++-- .../Icc/IccDataToDataConverter.cs | 21 +- .../Icc/IccDataToPcsConverter.cs | 21 +- .../Icc/IccPcsToDataConverter.cs | 21 +- .../Icc/IccPcsToPcsConverter.cs | 21 +- 19 files changed, 692 insertions(+), 712 deletions(-) diff --git a/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/CurveCalculator.CalculationType.cs b/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/CurveCalculator.CalculationType.cs index 187b17866b..b3e26e2a29 100644 --- a/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/CurveCalculator.CalculationType.cs +++ b/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/CurveCalculator.CalculationType.cs @@ -1,15 +1,14 @@ -// Copyright (c) Six Labors. +// Copyright (c) Six Labors. // Licensed under the Six Labors Split License. -namespace SixLabors.ImageSharp.ColorSpaces.Conversion.Icc +namespace SixLabors.ImageSharp.ColorSpaces.Conversion.Icc; + +internal partial class CurveCalculator { - internal partial class CurveCalculator + private enum CalculationType { - private enum CalculationType - { - Identity, - Gamma, - Lut, - } + Identity, + Gamma, + Lut, } } diff --git a/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/CurveCalculator.cs b/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/CurveCalculator.cs index 976ff2a85b..48213a486d 100644 --- a/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/CurveCalculator.cs +++ b/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/CurveCalculator.cs @@ -1,56 +1,54 @@ // Copyright (c) Six Labors. // Licensed under the Six Labors Split License. -using System; using SixLabors.ImageSharp.Metadata.Profiles.Icc; -namespace SixLabors.ImageSharp.ColorSpaces.Conversion.Icc +namespace SixLabors.ImageSharp.ColorSpaces.Conversion.Icc; + +internal partial class CurveCalculator : ISingleCalculator { - internal partial class CurveCalculator : ISingleCalculator - { - private LutCalculator lutCalculator; - private float gamma; - private CalculationType type; + private LutCalculator lutCalculator; + private float gamma; + private CalculationType type; - public CurveCalculator(IccCurveTagDataEntry entry, bool inverted) + public CurveCalculator(IccCurveTagDataEntry entry, bool inverted) + { + if (entry.IsIdentityResponse) + { + this.type = CalculationType.Identity; + } + else if (entry.IsGamma) { - if (entry.IsIdentityResponse) + this.gamma = entry.Gamma; + if (inverted) { - this.type = CalculationType.Identity; + this.gamma = 1f / this.gamma; } - else if (entry.IsGamma) - { - this.gamma = entry.Gamma; - if (inverted) - { - this.gamma = 1f / this.gamma; - } - this.type = CalculationType.Gamma; - } - else - { - this.lutCalculator = new LutCalculator(entry.CurveData, inverted); - this.type = CalculationType.Lut; - } + this.type = CalculationType.Gamma; + } + else + { + this.lutCalculator = new LutCalculator(entry.CurveData, inverted); + this.type = CalculationType.Lut; } + } - public float Calculate(float value) + public float Calculate(float value) + { + switch (this.type) { - switch (this.type) - { - case CalculationType.Identity: - return value; + case CalculationType.Identity: + return value; - case CalculationType.Gamma: - return MathF.Pow(value, this.gamma); + case CalculationType.Gamma: + return MathF.Pow(value, this.gamma); - case CalculationType.Lut: - return this.lutCalculator.Calculate(value); + case CalculationType.Lut: + return this.lutCalculator.Calculate(value); - default: - throw new InvalidOperationException("Invalid calculation type"); - } + default: + throw new InvalidOperationException("Invalid calculation type"); } } } diff --git a/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/GrayTrcCalculator.cs b/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/GrayTrcCalculator.cs index af1e24e20c..1c68668d20 100644 --- a/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/GrayTrcCalculator.cs +++ b/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/GrayTrcCalculator.cs @@ -5,21 +5,20 @@ using System.Runtime.CompilerServices; using SixLabors.ImageSharp.Metadata.Profiles.Icc; -namespace SixLabors.ImageSharp.ColorSpaces.Conversion.Icc +namespace SixLabors.ImageSharp.ColorSpaces.Conversion.Icc; + +internal class GrayTrcCalculator : IVector4Calculator { - internal class GrayTrcCalculator : IVector4Calculator - { - private TrcCalculator calculator; + private TrcCalculator calculator; - public GrayTrcCalculator(IccTagDataEntry grayTrc, bool toPcs) - { - this.calculator = new TrcCalculator(new IccTagDataEntry[] { grayTrc }, !toPcs); - } + public GrayTrcCalculator(IccTagDataEntry grayTrc, bool toPcs) + { + this.calculator = new TrcCalculator(new IccTagDataEntry[] { grayTrc }, !toPcs); + } - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public Vector4 Calculate(Vector4 value) - { - return this.calculator.Calculate(value); - } + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public Vector4 Calculate(Vector4 value) + { + return this.calculator.Calculate(value); } } diff --git a/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/ISingleCalculator.cs b/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/ISingleCalculator.cs index 570415a697..3b4b4b51dd 100644 --- a/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/ISingleCalculator.cs +++ b/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/ISingleCalculator.cs @@ -1,18 +1,17 @@ // Copyright (c) Six Labors. // Licensed under the Six Labors Split License. -namespace SixLabors.ImageSharp.ColorSpaces.Conversion.Icc +namespace SixLabors.ImageSharp.ColorSpaces.Conversion.Icc; + +/// +/// Represents an ICC calculator with a single floating point value and result +/// +internal interface ISingleCalculator { /// - /// Represents an ICC calculator with a single floating point value and result + /// Calculates a result from the given value /// - internal interface ISingleCalculator - { - /// - /// Calculates a result from the given value - /// - /// The input value - /// The calculated result - float Calculate(float value); - } + /// The input value + /// The calculated result + float Calculate(float value); } diff --git a/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/IVector4Calculator.cs b/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/IVector4Calculator.cs index cf30c634c5..5baa4666cb 100644 --- a/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/IVector4Calculator.cs +++ b/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/IVector4Calculator.cs @@ -3,18 +3,17 @@ using System.Numerics; -namespace SixLabors.ImageSharp.ColorSpaces.Conversion.Icc +namespace SixLabors.ImageSharp.ColorSpaces.Conversion.Icc; + +/// +/// Represents an ICC calculator with values and results +/// +internal interface IVector4Calculator { /// - /// Represents an ICC calculator with values and results + /// Calculates a result from the given values /// - internal interface IVector4Calculator - { - /// - /// Calculates a result from the given values - /// - /// The input values - /// The calculated result - Vector4 Calculate(Vector4 value); - } + /// The input values + /// The calculated result + Vector4 Calculate(Vector4 value); } diff --git a/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/LutABCalculator.CalculationType.cs b/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/LutABCalculator.CalculationType.cs index a2a060eb9f..7473fd7a0f 100644 --- a/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/LutABCalculator.CalculationType.cs +++ b/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/LutABCalculator.CalculationType.cs @@ -1,19 +1,18 @@ // Copyright (c) Six Labors. // Licensed under the Six Labors Split License. -namespace SixLabors.ImageSharp.ColorSpaces.Conversion.Icc +namespace SixLabors.ImageSharp.ColorSpaces.Conversion.Icc; + +internal partial class LutABCalculator { - internal partial class LutABCalculator + private enum CalculationType { - private enum CalculationType - { - AtoB = 1 << 3, - BtoA = 1 << 4, + AtoB = 1 << 3, + BtoA = 1 << 4, - SingleCurve = 1, - CurveMatrix = 2, - CurveClut = 3, - Full = 4, - } + SingleCurve = 1, + CurveMatrix = 2, + CurveClut = 3, + Full = 4, } } diff --git a/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/LutABCalculator.cs b/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/LutABCalculator.cs index 0a7c774a18..5ea734d713 100644 --- a/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/LutABCalculator.cs +++ b/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/LutABCalculator.cs @@ -5,131 +5,130 @@ using System.Numerics; using SixLabors.ImageSharp.Metadata.Profiles.Icc; -namespace SixLabors.ImageSharp.ColorSpaces.Conversion.Icc +namespace SixLabors.ImageSharp.ColorSpaces.Conversion.Icc; + +internal partial class LutABCalculator : IVector4Calculator { - internal partial class LutABCalculator : IVector4Calculator + private CalculationType type; + private TrcCalculator curveACalculator; + private TrcCalculator curveBCalculator; + private TrcCalculator curveMCalculator; + private MatrixCalculator matrixCalculator; + private ClutCalculator clutCalculator; + + public LutABCalculator(IccLutAToBTagDataEntry entry) + { + Guard.NotNull(entry, nameof(entry)); + this.Init(entry.CurveA, entry.CurveB, entry.CurveM, entry.Matrix3x1, entry.Matrix3x3, entry.ClutValues); + this.type |= CalculationType.AtoB; + } + + public LutABCalculator(IccLutBToATagDataEntry entry) + { + Guard.NotNull(entry, nameof(entry)); + this.Init(entry.CurveA, entry.CurveB, entry.CurveM, entry.Matrix3x1, entry.Matrix3x3, entry.ClutValues); + this.type |= CalculationType.BtoA; + } + + public Vector4 Calculate(Vector4 value) { - private CalculationType type; - private TrcCalculator curveACalculator; - private TrcCalculator curveBCalculator; - private TrcCalculator curveMCalculator; - private MatrixCalculator matrixCalculator; - private ClutCalculator clutCalculator; - - public LutABCalculator(IccLutAToBTagDataEntry entry) + switch (this.type) + { + case CalculationType.Full | CalculationType.AtoB: + value = this.curveACalculator.Calculate(value); + value = this.clutCalculator.Calculate(value); + value = this.curveMCalculator.Calculate(value); + value = this.matrixCalculator.Calculate(value); + return this.curveBCalculator.Calculate(value); + + case CalculationType.Full | CalculationType.BtoA: + value = this.curveBCalculator.Calculate(value); + value = this.matrixCalculator.Calculate(value); + value = this.curveMCalculator.Calculate(value); + value = this.clutCalculator.Calculate(value); + return this.curveACalculator.Calculate(value); + + case CalculationType.CurveClut | CalculationType.AtoB: + value = this.curveACalculator.Calculate(value); + value = this.clutCalculator.Calculate(value); + return this.curveBCalculator.Calculate(value); + + case CalculationType.CurveClut | CalculationType.BtoA: + value = this.curveBCalculator.Calculate(value); + value = this.clutCalculator.Calculate(value); + return this.curveACalculator.Calculate(value); + + case CalculationType.CurveMatrix | CalculationType.AtoB: + value = this.curveMCalculator.Calculate(value); + value = this.matrixCalculator.Calculate(value); + return this.curveBCalculator.Calculate(value); + + case CalculationType.CurveMatrix | CalculationType.BtoA: + value = this.curveBCalculator.Calculate(value); + value = this.matrixCalculator.Calculate(value); + return this.curveMCalculator.Calculate(value); + + case CalculationType.SingleCurve | CalculationType.AtoB: + case CalculationType.SingleCurve | CalculationType.BtoA: + return this.curveBCalculator.Calculate(value); + + default: + throw new InvalidOperationException("Invalid calculation type"); + } + } + + private void Init(IccTagDataEntry[] curveA, IccTagDataEntry[] curveB, IccTagDataEntry[] curveM, Vector3? matrix3x1, Matrix4x4? matrix3x3, IccClut clut) + { + bool hasACurve = curveA != null; + bool hasBCurve = curveB != null; + bool hasMCurve = curveM != null; + bool hasMatrix = matrix3x1 != null && matrix3x3 != null; + bool hasClut = clut != null; + + if (hasBCurve && hasMatrix && hasMCurve && hasClut && hasACurve) + { + this.type = CalculationType.Full; + } + else if (hasBCurve && hasClut && hasACurve) + { + this.type = CalculationType.CurveClut; + } + else if (hasBCurve && hasMatrix && hasMCurve) + { + this.type = CalculationType.CurveMatrix; + } + else if (hasBCurve) + { + this.type = CalculationType.SingleCurve; + } + else + { + throw new InvalidIccProfileException("AToB or BToA tag has an invalid configuration"); + } + + if (hasACurve) + { + this.curveACalculator = new TrcCalculator(curveA, false); + } + + if (hasBCurve) { - Guard.NotNull(entry, nameof(entry)); - this.Init(entry.CurveA, entry.CurveB, entry.CurveM, entry.Matrix3x1, entry.Matrix3x3, entry.ClutValues); - this.type |= CalculationType.AtoB; + this.curveBCalculator = new TrcCalculator(curveB, false); } - public LutABCalculator(IccLutBToATagDataEntry entry) + if (hasMCurve) { - Guard.NotNull(entry, nameof(entry)); - this.Init(entry.CurveA, entry.CurveB, entry.CurveM, entry.Matrix3x1, entry.Matrix3x3, entry.ClutValues); - this.type |= CalculationType.BtoA; + this.curveMCalculator = new TrcCalculator(curveM, false); } - public Vector4 Calculate(Vector4 value) + if (hasMatrix) { - switch (this.type) - { - case CalculationType.Full | CalculationType.AtoB: - value = this.curveACalculator.Calculate(value); - value = this.clutCalculator.Calculate(value); - value = this.curveMCalculator.Calculate(value); - value = this.matrixCalculator.Calculate(value); - return this.curveBCalculator.Calculate(value); - - case CalculationType.Full | CalculationType.BtoA: - value = this.curveBCalculator.Calculate(value); - value = this.matrixCalculator.Calculate(value); - value = this.curveMCalculator.Calculate(value); - value = this.clutCalculator.Calculate(value); - return this.curveACalculator.Calculate(value); - - case CalculationType.CurveClut | CalculationType.AtoB: - value = this.curveACalculator.Calculate(value); - value = this.clutCalculator.Calculate(value); - return this.curveBCalculator.Calculate(value); - - case CalculationType.CurveClut | CalculationType.BtoA: - value = this.curveBCalculator.Calculate(value); - value = this.clutCalculator.Calculate(value); - return this.curveACalculator.Calculate(value); - - case CalculationType.CurveMatrix | CalculationType.AtoB: - value = this.curveMCalculator.Calculate(value); - value = this.matrixCalculator.Calculate(value); - return this.curveBCalculator.Calculate(value); - - case CalculationType.CurveMatrix | CalculationType.BtoA: - value = this.curveBCalculator.Calculate(value); - value = this.matrixCalculator.Calculate(value); - return this.curveMCalculator.Calculate(value); - - case CalculationType.SingleCurve | CalculationType.AtoB: - case CalculationType.SingleCurve | CalculationType.BtoA: - return this.curveBCalculator.Calculate(value); - - default: - throw new InvalidOperationException("Invalid calculation type"); - } + this.matrixCalculator = new MatrixCalculator(matrix3x3.Value, matrix3x1.Value); } - private void Init(IccTagDataEntry[] curveA, IccTagDataEntry[] curveB, IccTagDataEntry[] curveM, Vector3? matrix3x1, Matrix4x4? matrix3x3, IccClut clut) + if (hasClut) { - bool hasACurve = curveA != null; - bool hasBCurve = curveB != null; - bool hasMCurve = curveM != null; - bool hasMatrix = matrix3x1 != null && matrix3x3 != null; - bool hasClut = clut != null; - - if (hasBCurve && hasMatrix && hasMCurve && hasClut && hasACurve) - { - this.type = CalculationType.Full; - } - else if (hasBCurve && hasClut && hasACurve) - { - this.type = CalculationType.CurveClut; - } - else if (hasBCurve && hasMatrix && hasMCurve) - { - this.type = CalculationType.CurveMatrix; - } - else if (hasBCurve) - { - this.type = CalculationType.SingleCurve; - } - else - { - throw new InvalidIccProfileException("AToB or BToA tag has an invalid configuration"); - } - - if (hasACurve) - { - this.curveACalculator = new TrcCalculator(curveA, false); - } - - if (hasBCurve) - { - this.curveBCalculator = new TrcCalculator(curveB, false); - } - - if (hasMCurve) - { - this.curveMCalculator = new TrcCalculator(curveM, false); - } - - if (hasMatrix) - { - this.matrixCalculator = new MatrixCalculator(matrix3x3.Value, matrix3x1.Value); - } - - if (hasClut) - { - this.clutCalculator = new ClutCalculator(clut); - } + this.clutCalculator = new ClutCalculator(clut); } } } diff --git a/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/LutCalculator.cs b/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/LutCalculator.cs index 3e5717b1ff..18fd622e6c 100644 --- a/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/LutCalculator.cs +++ b/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/LutCalculator.cs @@ -4,70 +4,69 @@ using System; using System.Runtime.CompilerServices; -namespace SixLabors.ImageSharp.ColorSpaces.Conversion.Icc +namespace SixLabors.ImageSharp.ColorSpaces.Conversion.Icc; + +internal class LutCalculator : ISingleCalculator { - internal class LutCalculator : ISingleCalculator + private float[] lut; + private bool inverse; + + public LutCalculator(float[] lut, bool inverse) { - private float[] lut; - private bool inverse; + Guard.NotNull(lut, nameof(lut)); - public LutCalculator(float[] lut, bool inverse) - { - Guard.NotNull(lut, nameof(lut)); + this.lut = lut; + this.inverse = inverse; + } - this.lut = lut; - this.inverse = inverse; + public float Calculate(float value) + { + if (this.inverse) + { + return this.LookupInverse(value); } - - public float Calculate(float value) + else { - if (this.inverse) - { - return this.LookupInverse(value); - } - else - { - return this.Lookup(value); - } + return this.Lookup(value); } + } - [MethodImpl(MethodImplOptions.AggressiveInlining)] - private float Lookup(float value) + [MethodImpl(MethodImplOptions.AggressiveInlining)] + private float Lookup(float value) + { + float factor = value * (this.lut.Length - 1); + int index = (int)factor; + float low = this.lut[index]; + float high = this.lut[index + 1]; + return low + ((high - low) * (factor - index)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + private float LookupInverse(float value) + { + int index = Array.BinarySearch(this.lut, value); + if (index >= 0) { - float factor = value * (this.lut.Length - 1); - int index = (int)factor; - float low = this.lut[index]; - float high = this.lut[index + 1]; - return low + ((high - low) * (factor - index)); + return index / (float)(this.lut.Length - 1); } - [MethodImpl(MethodImplOptions.AggressiveInlining)] - private float LookupInverse(float value) + index = ~index; + if (index == 0) { - int index = Array.BinarySearch(this.lut, value); - if (index >= 0) - { - return index / (float)(this.lut.Length - 1); - } - - index = ~index; - if (index == 0) - { - return 0; - } - else if (index == this.lut.Length) - { - return 1; - } + return 0; + } + else if (index == this.lut.Length) + { + return 1; + } - float high = this.lut[index]; - float low = this.lut[index - 1]; + float high = this.lut[index]; + float low = this.lut[index - 1]; - float valuePercent = (value - low) / (high - low); - float lutRange = 1 / (float)(this.lut.Length - 1); - float lutLow = (index - 1) / (float)(this.lut.Length - 1); + float valuePercent = (value - low) / (high - low); + float lutRange = 1 / (float)(this.lut.Length - 1); + float lutLow = (index - 1) / (float)(this.lut.Length - 1); - return lutLow + (valuePercent * lutRange); - } + return lutLow + (valuePercent * lutRange); } } diff --git a/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/LutEntryCalculator.cs b/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/LutEntryCalculator.cs index 6005990cdf..dd3e62a763 100644 --- a/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/LutEntryCalculator.cs +++ b/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/LutEntryCalculator.cs @@ -4,72 +4,71 @@ using System.Numerics; using SixLabors.ImageSharp.Metadata.Profiles.Icc; -namespace SixLabors.ImageSharp.ColorSpaces.Conversion.Icc +namespace SixLabors.ImageSharp.ColorSpaces.Conversion.Icc; + +internal class LutEntryCalculator : IVector4Calculator { - internal class LutEntryCalculator : IVector4Calculator + private LutCalculator[] inputCurve; + private LutCalculator[] outputCurve; + private ClutCalculator clutCalculator; + private Matrix4x4 matrix; + private bool doTransform; + + public LutEntryCalculator(IccLut8TagDataEntry lut) { - private LutCalculator[] inputCurve; - private LutCalculator[] outputCurve; - private ClutCalculator clutCalculator; - private Matrix4x4 matrix; - private bool doTransform; + Guard.NotNull(lut, nameof(lut)); + this.Init(lut.InputValues, lut.OutputValues, lut.ClutValues, lut.Matrix); + } - public LutEntryCalculator(IccLut8TagDataEntry lut) - { - Guard.NotNull(lut, nameof(lut)); - this.Init(lut.InputValues, lut.OutputValues, lut.ClutValues, lut.Matrix); - } + public LutEntryCalculator(IccLut16TagDataEntry lut) + { + Guard.NotNull(lut, nameof(lut)); + this.Init(lut.InputValues, lut.OutputValues, lut.ClutValues, lut.Matrix); + } - public LutEntryCalculator(IccLut16TagDataEntry lut) + public Vector4 Calculate(Vector4 value) + { + if (this.doTransform) { - Guard.NotNull(lut, nameof(lut)); - this.Init(lut.InputValues, lut.OutputValues, lut.ClutValues, lut.Matrix); + value = Vector4.Transform(value, this.matrix); } - public Vector4 Calculate(Vector4 value) - { - if (this.doTransform) - { - value = Vector4.Transform(value, this.matrix); - } + value = this.CalculateLut(this.inputCurve, value); + value = this.clutCalculator.Calculate(value); + return this.CalculateLut(this.outputCurve, value); + } - value = this.CalculateLut(this.inputCurve, value); - value = this.clutCalculator.Calculate(value); - return this.CalculateLut(this.outputCurve, value); - } + private unsafe Vector4 CalculateLut(LutCalculator[] lut, Vector4 value) + { + value = Vector4.Clamp(value, Vector4.Zero, Vector4.One); - private unsafe Vector4 CalculateLut(LutCalculator[] lut, Vector4 value) + float* valuePointer = (float*)&value; + for (int i = 0; i < lut.Length; i++) { - value = Vector4.Clamp(value, Vector4.Zero, Vector4.One); - - float* valuePointer = (float*)&value; - for (int i = 0; i < lut.Length; i++) - { - valuePointer[i] = lut[i].Calculate(valuePointer[i]); - } - - return value; + valuePointer[i] = lut[i].Calculate(valuePointer[i]); } - private void Init(IccLut[] inputCurve, IccLut[] outputCurve, IccClut clut, Matrix4x4 matrix) - { - this.inputCurve = InitLut(inputCurve); - this.outputCurve = InitLut(outputCurve); - this.clutCalculator = new ClutCalculator(clut); - this.matrix = matrix; + return value; + } - this.doTransform = !matrix.IsIdentity && inputCurve.Length == 3; - } + private void Init(IccLut[] inputCurve, IccLut[] outputCurve, IccClut clut, Matrix4x4 matrix) + { + this.inputCurve = InitLut(inputCurve); + this.outputCurve = InitLut(outputCurve); + this.clutCalculator = new ClutCalculator(clut); + this.matrix = matrix; - private static LutCalculator[] InitLut(IccLut[] curves) - { - LutCalculator[] calculators = new LutCalculator[curves.Length]; - for (int i = 0; i < curves.Length; i++) - { - calculators[i] = new LutCalculator(curves[i].Values, false); - } + this.doTransform = !matrix.IsIdentity && inputCurve.Length == 3; + } - return calculators; + private static LutCalculator[] InitLut(IccLut[] curves) + { + LutCalculator[] calculators = new LutCalculator[curves.Length]; + for (int i = 0; i < curves.Length; i++) + { + calculators[i] = new LutCalculator(curves[i].Values, false); } + + return calculators; } } diff --git a/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/MatrixCalculator.cs b/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/MatrixCalculator.cs index 570e02b819..f479d186a8 100644 --- a/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/MatrixCalculator.cs +++ b/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/MatrixCalculator.cs @@ -4,24 +4,23 @@ using System.Numerics; using System.Runtime.CompilerServices; -namespace SixLabors.ImageSharp.ColorSpaces.Conversion.Icc +namespace SixLabors.ImageSharp.ColorSpaces.Conversion.Icc; + +internal class MatrixCalculator : IVector4Calculator { - internal class MatrixCalculator : IVector4Calculator - { - private Matrix4x4 matrix2D; - private Vector4 matrix1D; + private Matrix4x4 matrix2D; + private Vector4 matrix1D; - public MatrixCalculator(Matrix4x4 matrix3x3, Vector3 matrix3x1) - { - this.matrix2D = matrix3x3; - this.matrix1D = new Vector4(matrix3x1, 0); - } + public MatrixCalculator(Matrix4x4 matrix3x3, Vector3 matrix3x1) + { + this.matrix2D = matrix3x3; + this.matrix1D = new Vector4(matrix3x1, 0); + } - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public Vector4 Calculate(Vector4 value) - { - var transformed = Vector4.Transform(value, this.matrix2D); - return Vector4.Add(this.matrix1D, transformed); - } + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public Vector4 Calculate(Vector4 value) + { + var transformed = Vector4.Transform(value, this.matrix2D); + return Vector4.Add(this.matrix1D, transformed); } } diff --git a/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/ParametricCurveCalculator.cs b/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/ParametricCurveCalculator.cs index 53d783bb4c..5a3bab6e86 100644 --- a/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/ParametricCurveCalculator.cs +++ b/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/ParametricCurveCalculator.cs @@ -5,164 +5,163 @@ using System.Runtime.CompilerServices; using SixLabors.ImageSharp.Metadata.Profiles.Icc; -namespace SixLabors.ImageSharp.ColorSpaces.Conversion.Icc +namespace SixLabors.ImageSharp.ColorSpaces.Conversion.Icc; + +internal class ParametricCurveCalculator : ISingleCalculator { - internal class ParametricCurveCalculator : ISingleCalculator + private IccParametricCurve curve; + private IccParametricCurveType type; + private const IccParametricCurveType InvertedFlag = (IccParametricCurveType)(1 << 3); + + public ParametricCurveCalculator(IccParametricCurveTagDataEntry entry, bool inverted) { - private IccParametricCurve curve; - private IccParametricCurveType type; - private const IccParametricCurveType InvertedFlag = (IccParametricCurveType)(1 << 3); - - public ParametricCurveCalculator(IccParametricCurveTagDataEntry entry, bool inverted) - { - Guard.NotNull(entry, nameof(entry)); - this.curve = entry.Curve; - this.type = entry.Curve.Type; + Guard.NotNull(entry, nameof(entry)); + this.curve = entry.Curve; + this.type = entry.Curve.Type; - if (inverted) - { - this.type |= InvertedFlag; - } + if (inverted) + { + this.type |= InvertedFlag; } + } - public float Calculate(float value) + public float Calculate(float value) + { + switch (this.type) { - switch (this.type) - { - case IccParametricCurveType.Type1: - return this.CalculateGamma(value); - case IccParametricCurveType.Cie122_1996: - return this.CalculateCie122(value); - case IccParametricCurveType.Iec61966_3: - return this.CalculateIec61966(value); - case IccParametricCurveType.SRgb: - return this.CalculateSRgb(value); - case IccParametricCurveType.Type5: - return this.CalculateType5(value); + case IccParametricCurveType.Type1: + return this.CalculateGamma(value); + case IccParametricCurveType.Cie122_1996: + return this.CalculateCie122(value); + case IccParametricCurveType.Iec61966_3: + return this.CalculateIec61966(value); + case IccParametricCurveType.SRgb: + return this.CalculateSRgb(value); + case IccParametricCurveType.Type5: + return this.CalculateType5(value); + + case IccParametricCurveType.Type1 | InvertedFlag: + return this.CalculateInvertedGamma(value); + case IccParametricCurveType.Cie122_1996 | InvertedFlag: + return this.CalculateInvertedCie122(value); + case IccParametricCurveType.Iec61966_3 | InvertedFlag: + return this.CalculateInvertedIec61966(value); + case IccParametricCurveType.SRgb | InvertedFlag: + return this.CalculateInvertedSRgb(value); + case IccParametricCurveType.Type5 | InvertedFlag: + return this.CalculateInvertedType5(value); + + default: + throw new InvalidIccProfileException("ParametricCurve"); + } + } - case IccParametricCurveType.Type1 | InvertedFlag: - return this.CalculateInvertedGamma(value); - case IccParametricCurveType.Cie122_1996 | InvertedFlag: - return this.CalculateInvertedCie122(value); - case IccParametricCurveType.Iec61966_3 | InvertedFlag: - return this.CalculateInvertedIec61966(value); - case IccParametricCurveType.SRgb | InvertedFlag: - return this.CalculateInvertedSRgb(value); - case IccParametricCurveType.Type5 | InvertedFlag: - return this.CalculateInvertedType5(value); + [MethodImpl(MethodImplOptions.AggressiveInlining)] + private float CalculateGamma(float value) + { + return MathF.Pow(value, this.curve.G); + } - default: - throw new InvalidIccProfileException("ParametricCurve"); - } + [MethodImpl(MethodImplOptions.AggressiveInlining)] + private float CalculateCie122(float value) + { + if (value >= -this.curve.B / this.curve.A) + { + return MathF.Pow((this.curve.A * value) + this.curve.B, this.curve.G); } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - private float CalculateGamma(float value) + else { - return MathF.Pow(value, this.curve.G); + return 0; } + } - [MethodImpl(MethodImplOptions.AggressiveInlining)] - private float CalculateCie122(float value) + [MethodImpl(MethodImplOptions.AggressiveInlining)] + private float CalculateIec61966(float value) + { + if (value >= -this.curve.B / this.curve.A) { - if (value >= -this.curve.B / this.curve.A) - { - return MathF.Pow((this.curve.A * value) + this.curve.B, this.curve.G); - } - else - { - return 0; - } + return MathF.Pow((this.curve.A * value) + this.curve.B, this.curve.G) + this.curve.C; } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - private float CalculateIec61966(float value) + else { - if (value >= -this.curve.B / this.curve.A) - { - return MathF.Pow((this.curve.A * value) + this.curve.B, this.curve.G) + this.curve.C; - } - else - { - return this.curve.C; - } + return this.curve.C; } + } - [MethodImpl(MethodImplOptions.AggressiveInlining)] - private float CalculateSRgb(float value) + [MethodImpl(MethodImplOptions.AggressiveInlining)] + private float CalculateSRgb(float value) + { + if (value >= this.curve.D) { - if (value >= this.curve.D) - { - return MathF.Pow((this.curve.A * value) + this.curve.B, this.curve.G); - } - else - { - return this.curve.C * value; - } + return MathF.Pow((this.curve.A * value) + this.curve.B, this.curve.G); } + else + { + return this.curve.C * value; + } + } - [MethodImpl(MethodImplOptions.AggressiveInlining)] - private float CalculateType5(float value) + [MethodImpl(MethodImplOptions.AggressiveInlining)] + private float CalculateType5(float value) + { + if (value >= this.curve.D) + { + return MathF.Pow((this.curve.A * value) + this.curve.B, this.curve.G) + this.curve.E; + } + else { - if (value >= this.curve.D) - { - return MathF.Pow((this.curve.A * value) + this.curve.B, this.curve.G) + this.curve.E; - } - else - { - return (this.curve.C * value) + this.curve.F; - } + return (this.curve.C * value) + this.curve.F; } + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + private float CalculateInvertedGamma(float value) + { + return MathF.Pow(value, 1 / this.curve.G); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + private float CalculateInvertedCie122(float value) + { + return (MathF.Pow(value, 1 / this.curve.G) - this.curve.B) / this.curve.A; + } - [MethodImpl(MethodImplOptions.AggressiveInlining)] - private float CalculateInvertedGamma(float value) + [MethodImpl(MethodImplOptions.AggressiveInlining)] + private float CalculateInvertedIec61966(float value) + { + if (value >= this.curve.C) + { + return (MathF.Pow(value - this.curve.C, 1 / this.curve.G) - this.curve.B) / this.curve.A; + } + else { - return MathF.Pow(value, 1 / this.curve.G); + return -this.curve.B / this.curve.A; } + } - [MethodImpl(MethodImplOptions.AggressiveInlining)] - private float CalculateInvertedCie122(float value) + [MethodImpl(MethodImplOptions.AggressiveInlining)] + private float CalculateInvertedSRgb(float value) + { + if (value >= MathF.Pow((this.curve.A * this.curve.D) + this.curve.B, this.curve.G)) { return (MathF.Pow(value, 1 / this.curve.G) - this.curve.B) / this.curve.A; } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - private float CalculateInvertedIec61966(float value) + else { - if (value >= this.curve.C) - { - return (MathF.Pow(value - this.curve.C, 1 / this.curve.G) - this.curve.B) / this.curve.A; - } - else - { - return -this.curve.B / this.curve.A; - } + return value / this.curve.C; } + } - [MethodImpl(MethodImplOptions.AggressiveInlining)] - private float CalculateInvertedSRgb(float value) + [MethodImpl(MethodImplOptions.AggressiveInlining)] + private float CalculateInvertedType5(float value) + { + if (value >= (this.curve.C * this.curve.D) + this.curve.F) { - if (value >= MathF.Pow((this.curve.A * this.curve.D) + this.curve.B, this.curve.G)) - { - return (MathF.Pow(value, 1 / this.curve.G) - this.curve.B) / this.curve.A; - } - else - { - return value / this.curve.C; - } + return (MathF.Pow(value - this.curve.E, 1 / this.curve.G) - this.curve.B) / this.curve.A; } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - private float CalculateInvertedType5(float value) + else { - if (value >= (this.curve.C * this.curve.D) + this.curve.F) - { - return (MathF.Pow(value - this.curve.E, 1 / this.curve.G) - this.curve.B) / this.curve.A; - } - else - { - return (value - this.curve.F) / this.curve.C; - } + return (value - this.curve.F) / this.curve.C; } } } diff --git a/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/TrcCalculator.cs b/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/TrcCalculator.cs index 0a8042aa65..83a6f0ecd9 100644 --- a/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/TrcCalculator.cs +++ b/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/TrcCalculator.cs @@ -4,44 +4,43 @@ using System.Numerics; using SixLabors.ImageSharp.Metadata.Profiles.Icc; -namespace SixLabors.ImageSharp.ColorSpaces.Conversion.Icc +namespace SixLabors.ImageSharp.ColorSpaces.Conversion.Icc; + +internal class TrcCalculator : IVector4Calculator { - internal class TrcCalculator : IVector4Calculator + private ISingleCalculator[] calculators; + + public TrcCalculator(IccTagDataEntry[] entries, bool inverted) { - private ISingleCalculator[] calculators; + Guard.NotNull(entries, nameof(entries)); - public TrcCalculator(IccTagDataEntry[] entries, bool inverted) + this.calculators = new ISingleCalculator[entries.Length]; + for (int i = 0; i < entries.Length; i++) { - Guard.NotNull(entries, nameof(entries)); - - this.calculators = new ISingleCalculator[entries.Length]; - for (int i = 0; i < entries.Length; i++) + switch (entries[i]) { - switch (entries[i]) - { - case IccCurveTagDataEntry curve: - this.calculators[i] = new CurveCalculator(curve, inverted); - break; - - case IccParametricCurveTagDataEntry parametricCurve: - this.calculators[i] = new ParametricCurveCalculator(parametricCurve, inverted); - break; - - default: - throw new InvalidIccProfileException("Invalid Entry."); - } + case IccCurveTagDataEntry curve: + this.calculators[i] = new CurveCalculator(curve, inverted); + break; + + case IccParametricCurveTagDataEntry parametricCurve: + this.calculators[i] = new ParametricCurveCalculator(parametricCurve, inverted); + break; + + default: + throw new InvalidIccProfileException("Invalid Entry."); } } + } - public unsafe Vector4 Calculate(Vector4 value) + public unsafe Vector4 Calculate(Vector4 value) + { + float* valuePointer = (float*)&value; + for (int i = 0; i < this.calculators.Length; i++) { - float* valuePointer = (float*)&value; - for (int i = 0; i < this.calculators.Length; i++) - { - valuePointer[i] = this.calculators[i].Calculate(valuePointer[i]); - } - - return value; + valuePointer[i] = this.calculators[i].Calculate(valuePointer[i]); } + + return value; } } diff --git a/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/IccConverterBase.ConversionMethod.cs b/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/IccConverterBase.ConversionMethod.cs index 4a74434cc7..3967560210 100644 --- a/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/IccConverterBase.ConversionMethod.cs +++ b/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/IccConverterBase.ConversionMethod.cs @@ -1,67 +1,66 @@ // Copyright (c) Six Labors. // Licensed under the Six Labors Split License. -namespace SixLabors.ImageSharp.ColorSpaces.Conversion.Icc +namespace SixLabors.ImageSharp.ColorSpaces.Conversion.Icc; + +/// +/// Color converter for ICC profiles +/// +internal abstract partial class IccConverterBase { /// - /// Color converter for ICC profiles + /// Conversion methods with ICC profiles /// - internal abstract partial class IccConverterBase + private enum ConversionMethod { /// - /// Conversion methods with ICC profiles + /// Conversion using anything but Multi Process Elements with perceptual rendering intent /// - private enum ConversionMethod - { - /// - /// Conversion using anything but Multi Process Elements with perceptual rendering intent - /// - A0, + A0, - /// - /// Conversion using anything but Multi Process Elements with relative colorimetric rendering intent - /// - A1, + /// + /// Conversion using anything but Multi Process Elements with relative colorimetric rendering intent + /// + A1, - /// - /// Conversion using anything but Multi Process Elements with saturation rendering intent - /// - A2, + /// + /// Conversion using anything but Multi Process Elements with saturation rendering intent + /// + A2, - /// - /// Conversion using Multi Process Elements with perceptual rendering intent - /// - D0, + /// + /// Conversion using Multi Process Elements with perceptual rendering intent + /// + D0, - /// - /// Conversion using Multi Process Elements with relative colorimetric rendering intent - /// - D1, + /// + /// Conversion using Multi Process Elements with relative colorimetric rendering intent + /// + D1, - /// - /// Conversion using Multi Process Elements with saturation rendering intent - /// - D2, + /// + /// Conversion using Multi Process Elements with saturation rendering intent + /// + D2, - /// - /// Conversion using Multi Process Elements with absolute colorimetric rendering intent - /// - D3, + /// + /// Conversion using Multi Process Elements with absolute colorimetric rendering intent + /// + D3, - /// - /// Conversion of more than one channel using tone reproduction curves - /// - ColorTrc, + /// + /// Conversion of more than one channel using tone reproduction curves + /// + ColorTrc, - /// - /// Conversion of exactly one channel using a tone reproduction curve - /// - GrayTrc, + /// + /// Conversion of exactly one channel using a tone reproduction curve + /// + GrayTrc, - /// - /// No valid conversion method available or found - /// - Invalid, - } + /// + /// No valid conversion method available or found + /// + Invalid, } } diff --git a/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/IccConverterbase.Conversions.cs b/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/IccConverterbase.Conversions.cs index 6e4c58e180..56941c19e3 100644 --- a/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/IccConverterbase.Conversions.cs +++ b/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/IccConverterbase.Conversions.cs @@ -5,146 +5,145 @@ using SixLabors.ImageSharp.ColorSpaces.Conversion.Icc; using SixLabors.ImageSharp.Metadata.Profiles.Icc; -namespace SixLabors.ImageSharp.ColorSpaces.Conversion.Icc +namespace SixLabors.ImageSharp.ColorSpaces.Conversion.Icc; + +/// +/// Color converter for ICC profiles +/// +internal abstract partial class IccConverterBase { + private IVector4Calculator calculator; + /// - /// Color converter for ICC profiles + /// Checks the profile for available conversion methods and gathers all the informations necessary for it /// - internal abstract partial class IccConverterBase + /// The profile to use for the conversion + /// True if the conversion is to the Profile Connection Space + /// The wanted rendering intent. Can be ignored if not available + protected void Init(IccProfile profile, bool toPcs, IccRenderingIntent renderingIntent) { - private IVector4Calculator calculator; - - /// - /// Checks the profile for available conversion methods and gathers all the informations necessary for it - /// - /// The profile to use for the conversion - /// True if the conversion is to the Profile Connection Space - /// The wanted rendering intent. Can be ignored if not available - protected void Init(IccProfile profile, bool toPcs, IccRenderingIntent renderingIntent) + ConversionMethod method = GetConversionMethod(profile, renderingIntent); + switch (method) { - ConversionMethod method = GetConversionMethod(profile, renderingIntent); - switch (method) - { - case ConversionMethod.D0: - this.calculator = toPcs ? - InitD(profile, IccProfileTag.DToB0) : - InitD(profile, IccProfileTag.BToD0); - break; - - case ConversionMethod.D1: - this.calculator = toPcs ? - InitD(profile, IccProfileTag.DToB1) : - InitD(profile, IccProfileTag.BToD1); - break; - - case ConversionMethod.D2: - this.calculator = toPcs ? - InitD(profile, IccProfileTag.DToB2) : - InitD(profile, IccProfileTag.BToD2); - break; - - case ConversionMethod.D3: - this.calculator = toPcs ? - InitD(profile, IccProfileTag.DToB3) : - InitD(profile, IccProfileTag.BToD3); - break; - - case ConversionMethod.A0: - this.calculator = toPcs ? - InitA(profile, IccProfileTag.AToB0) : - InitA(profile, IccProfileTag.BToA0); - break; - - case ConversionMethod.A1: - this.calculator = toPcs ? - InitA(profile, IccProfileTag.AToB1) : - InitA(profile, IccProfileTag.BToA1); - break; - - case ConversionMethod.A2: - this.calculator = toPcs ? - InitA(profile, IccProfileTag.AToB2) : - InitA(profile, IccProfileTag.BToA2); - break; - - case ConversionMethod.ColorTrc: - this.calculator = InitColorTrc(profile, toPcs); - break; - - case ConversionMethod.GrayTrc: - this.calculator = InitGrayTrc(profile, toPcs); - break; - - case ConversionMethod.Invalid: - default: - throw new InvalidIccProfileException("Invalid conversion method."); - } + case ConversionMethod.D0: + this.calculator = toPcs ? + InitD(profile, IccProfileTag.DToB0) : + InitD(profile, IccProfileTag.BToD0); + break; + + case ConversionMethod.D1: + this.calculator = toPcs ? + InitD(profile, IccProfileTag.DToB1) : + InitD(profile, IccProfileTag.BToD1); + break; + + case ConversionMethod.D2: + this.calculator = toPcs ? + InitD(profile, IccProfileTag.DToB2) : + InitD(profile, IccProfileTag.BToD2); + break; + + case ConversionMethod.D3: + this.calculator = toPcs ? + InitD(profile, IccProfileTag.DToB3) : + InitD(profile, IccProfileTag.BToD3); + break; + + case ConversionMethod.A0: + this.calculator = toPcs ? + InitA(profile, IccProfileTag.AToB0) : + InitA(profile, IccProfileTag.BToA0); + break; + + case ConversionMethod.A1: + this.calculator = toPcs ? + InitA(profile, IccProfileTag.AToB1) : + InitA(profile, IccProfileTag.BToA1); + break; + + case ConversionMethod.A2: + this.calculator = toPcs ? + InitA(profile, IccProfileTag.AToB2) : + InitA(profile, IccProfileTag.BToA2); + break; + + case ConversionMethod.ColorTrc: + this.calculator = InitColorTrc(profile, toPcs); + break; + + case ConversionMethod.GrayTrc: + this.calculator = InitGrayTrc(profile, toPcs); + break; + + case ConversionMethod.Invalid: + default: + throw new InvalidIccProfileException("Invalid conversion method."); } + } - private static IVector4Calculator InitA(IccProfile profile, IccProfileTag tag) + private static IVector4Calculator InitA(IccProfile profile, IccProfileTag tag) + { + IccTagDataEntry entry = GetTag(profile, tag); + switch (entry) { - IccTagDataEntry entry = GetTag(profile, tag); - switch (entry) - { - case IccLut8TagDataEntry lut8: - return new LutEntryCalculator(lut8); - case IccLut16TagDataEntry lut16: - return new LutEntryCalculator(lut16); - case IccLutAToBTagDataEntry lutAtoB: - return new LutABCalculator(lutAtoB); - case IccLutBToATagDataEntry lutBtoA: - return new LutABCalculator(lutBtoA); - - default: - throw new InvalidIccProfileException("Invalid entry."); - } + case IccLut8TagDataEntry lut8: + return new LutEntryCalculator(lut8); + case IccLut16TagDataEntry lut16: + return new LutEntryCalculator(lut16); + case IccLutAToBTagDataEntry lutAtoB: + return new LutABCalculator(lutAtoB); + case IccLutBToATagDataEntry lutBtoA: + return new LutABCalculator(lutBtoA); + + default: + throw new InvalidIccProfileException("Invalid entry."); } + } - private static IVector4Calculator InitD(IccProfile profile, IccProfileTag tag) + private static IVector4Calculator InitD(IccProfile profile, IccProfileTag tag) + { + IccMultiProcessElementsTagDataEntry entry = GetTag(profile, tag); + if (entry == null) { - IccMultiProcessElementsTagDataEntry entry = GetTag(profile, tag); - if (entry == null) - { - throw new InvalidIccProfileException("Entry is null."); - } - - throw new NotImplementedException("Multi process elements are not supported"); + throw new InvalidIccProfileException("Entry is null."); } - private static IVector4Calculator InitColorTrc(IccProfile profile, bool toPcs) - { - IccXyzTagDataEntry redMatrixColumn = GetTag(profile, IccProfileTag.RedMatrixColumn); - IccXyzTagDataEntry greenMatrixColumn = GetTag(profile, IccProfileTag.GreenMatrixColumn); - IccXyzTagDataEntry blueMatrixColumn = GetTag(profile, IccProfileTag.BlueMatrixColumn); - - IccTagDataEntry redTrc = GetTag(profile, IccProfileTag.RedTrc); - IccTagDataEntry greenTrc = GetTag(profile, IccProfileTag.GreenTrc); - IccTagDataEntry blueTrc = GetTag(profile, IccProfileTag.BlueTrc); - - if (redMatrixColumn == null || - greenMatrixColumn == null || - blueMatrixColumn == null || - redTrc == null || - greenTrc == null || - blueTrc == null) - { - throw new InvalidIccProfileException("Missing matrix column or channel."); - } - - return new ColorTrcCalculator( - redMatrixColumn, - greenMatrixColumn, - blueMatrixColumn, - redTrc, - greenTrc, - blueTrc, - toPcs); - } + throw new NotImplementedException("Multi process elements are not supported"); + } - private static IVector4Calculator InitGrayTrc(IccProfile profile, bool toPcs) + private static IVector4Calculator InitColorTrc(IccProfile profile, bool toPcs) + { + IccXyzTagDataEntry redMatrixColumn = GetTag(profile, IccProfileTag.RedMatrixColumn); + IccXyzTagDataEntry greenMatrixColumn = GetTag(profile, IccProfileTag.GreenMatrixColumn); + IccXyzTagDataEntry blueMatrixColumn = GetTag(profile, IccProfileTag.BlueMatrixColumn); + + IccTagDataEntry redTrc = GetTag(profile, IccProfileTag.RedTrc); + IccTagDataEntry greenTrc = GetTag(profile, IccProfileTag.GreenTrc); + IccTagDataEntry blueTrc = GetTag(profile, IccProfileTag.BlueTrc); + + if (redMatrixColumn == null || + greenMatrixColumn == null || + blueMatrixColumn == null || + redTrc == null || + greenTrc == null || + blueTrc == null) { - IccTagDataEntry entry = GetTag(profile, IccProfileTag.GrayTrc); - return new GrayTrcCalculator(entry, toPcs); + throw new InvalidIccProfileException("Missing matrix column or channel."); } + + return new ColorTrcCalculator( + redMatrixColumn, + greenMatrixColumn, + blueMatrixColumn, + redTrc, + greenTrc, + blueTrc, + toPcs); + } + + private static IVector4Calculator InitGrayTrc(IccProfile profile, bool toPcs) + { + IccTagDataEntry entry = GetTag(profile, IccProfileTag.GrayTrc); + return new GrayTrcCalculator(entry, toPcs); } } diff --git a/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/IccConverterbase.cs b/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/IccConverterbase.cs index d0e147c19b..6e9c8aa829 100644 --- a/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/IccConverterbase.cs +++ b/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/IccConverterbase.cs @@ -5,33 +5,32 @@ using System.Runtime.CompilerServices; using SixLabors.ImageSharp.Metadata.Profiles.Icc; -namespace SixLabors.ImageSharp.ColorSpaces.Conversion.Icc +namespace SixLabors.ImageSharp.ColorSpaces.Conversion.Icc; + +/// +/// Color converter for ICC profiles +/// +internal abstract partial class IccConverterBase { /// - /// Color converter for ICC profiles + /// Initializes a new instance of the class. /// - internal abstract partial class IccConverterBase + /// The ICC profile to use for the conversions + /// True if the conversion is to the profile connection space (PCS); False if the conversion is to the data space + protected IccConverterBase(IccProfile profile, bool toPcs) { - /// - /// Initializes a new instance of the class. - /// - /// The ICC profile to use for the conversions - /// True if the conversion is to the profile connection space (PCS); False if the conversion is to the data space - protected IccConverterBase(IccProfile profile, bool toPcs) - { - Guard.NotNull(profile, nameof(profile)); - this.Init(profile, toPcs, profile.Header.RenderingIntent); - } + Guard.NotNull(profile, nameof(profile)); + this.Init(profile, toPcs, profile.Header.RenderingIntent); + } - /// - /// Converts colors with the initially provided ICC profile - /// - /// The value to convert - /// The converted value - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public Vector4 Calculate(Vector4 value) - { - return this.calculator.Calculate(value); - } + /// + /// Converts colors with the initially provided ICC profile + /// + /// The value to convert + /// The converted value + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public Vector4 Calculate(Vector4 value) + { + return this.calculator.Calculate(value); } } diff --git a/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/IccDataToDataConverter.cs b/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/IccDataToDataConverter.cs index dccba51ccc..86e73b54df 100644 --- a/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/IccDataToDataConverter.cs +++ b/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/IccDataToDataConverter.cs @@ -3,20 +3,19 @@ using SixLabors.ImageSharp.Metadata.Profiles.Icc; -namespace SixLabors.ImageSharp.ColorSpaces.Conversion.Icc +namespace SixLabors.ImageSharp.ColorSpaces.Conversion.Icc; + +/// +/// Color converter for ICC profiles +/// +internal class IccDataToDataConverter : IccConverterBase { /// - /// Color converter for ICC profiles + /// Initializes a new instance of the class. /// - internal class IccDataToDataConverter : IccConverterBase + /// The ICC profile to use for the conversions + public IccDataToDataConverter(IccProfile profile) + : base(profile, true) // toPCS is true because in this case the PCS space is also a data space { - /// - /// Initializes a new instance of the class. - /// - /// The ICC profile to use for the conversions - public IccDataToDataConverter(IccProfile profile) - : base(profile, true) // toPCS is true because in this case the PCS space is also a data space - { - } } } diff --git a/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/IccDataToPcsConverter.cs b/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/IccDataToPcsConverter.cs index 6cec8695f6..86ed81240b 100644 --- a/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/IccDataToPcsConverter.cs +++ b/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/IccDataToPcsConverter.cs @@ -3,20 +3,19 @@ using SixLabors.ImageSharp.Metadata.Profiles.Icc; -namespace SixLabors.ImageSharp.ColorSpaces.Conversion.Icc +namespace SixLabors.ImageSharp.ColorSpaces.Conversion.Icc; + +/// +/// Color converter for ICC profiles +/// +internal class IccDataToPcsConverter : IccConverterBase { /// - /// Color converter for ICC profiles + /// Initializes a new instance of the class. /// - internal class IccDataToPcsConverter : IccConverterBase + /// The ICC profile to use for the conversions + public IccDataToPcsConverter(IccProfile profile) + : base(profile, true) { - /// - /// Initializes a new instance of the class. - /// - /// The ICC profile to use for the conversions - public IccDataToPcsConverter(IccProfile profile) - : base(profile, true) - { - } } } diff --git a/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/IccPcsToDataConverter.cs b/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/IccPcsToDataConverter.cs index 5647c465cc..c38f7b64e0 100644 --- a/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/IccPcsToDataConverter.cs +++ b/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/IccPcsToDataConverter.cs @@ -3,20 +3,19 @@ using SixLabors.ImageSharp.Metadata.Profiles.Icc; -namespace SixLabors.ImageSharp.ColorSpaces.Conversion.Icc +namespace SixLabors.ImageSharp.ColorSpaces.Conversion.Icc; + +/// +/// Color converter for ICC profiles +/// +internal class IccPcsToDataConverter : IccConverterBase { /// - /// Color converter for ICC profiles + /// Initializes a new instance of the class. /// - internal class IccPcsToDataConverter : IccConverterBase + /// The ICC profile to use for the conversions + public IccPcsToDataConverter(IccProfile profile) + : base(profile, false) { - /// - /// Initializes a new instance of the class. - /// - /// The ICC profile to use for the conversions - public IccPcsToDataConverter(IccProfile profile) - : base(profile, false) - { - } } } diff --git a/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/IccPcsToPcsConverter.cs b/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/IccPcsToPcsConverter.cs index a40a81d5d2..7d85203df5 100644 --- a/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/IccPcsToPcsConverter.cs +++ b/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/IccPcsToPcsConverter.cs @@ -3,20 +3,19 @@ using SixLabors.ImageSharp.Metadata.Profiles.Icc; -namespace SixLabors.ImageSharp.ColorSpaces.Conversion.Icc +namespace SixLabors.ImageSharp.ColorSpaces.Conversion.Icc; + +/// +/// Color converter for ICC profiles +/// +internal class IccPcsToPcsConverter : IccConverterBase { /// - /// Color converter for ICC profiles + /// Initializes a new instance of the class. /// - internal class IccPcsToPcsConverter : IccConverterBase + /// The ICC profile to use for the conversions + public IccPcsToPcsConverter(IccProfile profile) + : base(profile, true) { - /// - /// Initializes a new instance of the class. - /// - /// The ICC profile to use for the conversions - public IccPcsToPcsConverter(IccProfile profile) - : base(profile, true) - { - } } } From daf366b37494230c1471be91a71d6d7080800e63 Mon Sep 17 00:00:00 2001 From: James Jackson-South Date: Wed, 30 Nov 2022 15:56:21 +1000 Subject: [PATCH 10/42] Cleanup and add conversion tests --- .../Icc/Calculators/MatrixCalculator.cs | 4 +- .../Calculators/ParametricCurveCalculator.cs | 61 ++++++------------- .../Icc/IccConverterBase.Checks.cs | 4 +- .../Implementation/Icc/IccConverterbase.cs | 5 +- .../Implementation/Icc/IccProfileConverter.cs | 43 +++++++++++++ .../Metadata/Profiles/ICC/IccProfile.cs | 2 - .../Metadata/Profiles/ICC/IccTagDataEntry.cs | 6 +- .../Icc/IccProfileConverterTests.cs | 58 ++++++++++++++++++ tests/ImageSharp.Tests/TestImages.cs | 10 +++ .../Jpg/icc-profiles/Momiji-AdobeRGB-yes.jpg | 3 + .../Jpg/icc-profiles/Momiji-AppleRGB-yes.jpg | 3 + .../icc-profiles/Momiji-ColorMatch-yes.jpg | 3 + .../Jpg/icc-profiles/Momiji-ProPhoto-yes.jpg | 3 + .../Jpg/icc-profiles/Momiji-WideRGB-yes.jpg | 3 + .../Jpg/icc-profiles/Momiji-sRGB-yes.jpg | 3 + 15 files changed, 154 insertions(+), 57 deletions(-) create mode 100644 src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/IccProfileConverter.cs create mode 100644 tests/ImageSharp.Tests/Colorspaces/Icc/IccProfileConverterTests.cs create mode 100644 tests/Images/Input/Jpg/icc-profiles/Momiji-AdobeRGB-yes.jpg create mode 100644 tests/Images/Input/Jpg/icc-profiles/Momiji-AppleRGB-yes.jpg create mode 100644 tests/Images/Input/Jpg/icc-profiles/Momiji-ColorMatch-yes.jpg create mode 100644 tests/Images/Input/Jpg/icc-profiles/Momiji-ProPhoto-yes.jpg create mode 100644 tests/Images/Input/Jpg/icc-profiles/Momiji-WideRGB-yes.jpg create mode 100644 tests/Images/Input/Jpg/icc-profiles/Momiji-sRGB-yes.jpg diff --git a/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/MatrixCalculator.cs b/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/MatrixCalculator.cs index f479d186a8..5997a9cdc8 100644 --- a/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/MatrixCalculator.cs +++ b/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/MatrixCalculator.cs @@ -1,4 +1,4 @@ -// Copyright (c) Six Labors. +// Copyright (c) Six Labors. // Licensed under the Six Labors Split License. using System.Numerics; @@ -20,7 +20,7 @@ public MatrixCalculator(Matrix4x4 matrix3x3, Vector3 matrix3x1) [MethodImpl(MethodImplOptions.AggressiveInlining)] public Vector4 Calculate(Vector4 value) { - var transformed = Vector4.Transform(value, this.matrix2D); + Vector4 transformed = Vector4.Transform(value, this.matrix2D); return Vector4.Add(this.matrix1D, transformed); } } diff --git a/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/ParametricCurveCalculator.cs b/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/ParametricCurveCalculator.cs index 5a3bab6e86..9312326830 100644 --- a/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/ParametricCurveCalculator.cs +++ b/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/ParametricCurveCalculator.cs @@ -1,7 +1,6 @@ // Copyright (c) Six Labors. // Licensed under the Six Labors Split License. -using System; using System.Runtime.CompilerServices; using SixLabors.ImageSharp.Metadata.Profiles.Icc; @@ -9,8 +8,8 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion.Icc; internal class ParametricCurveCalculator : ISingleCalculator { - private IccParametricCurve curve; - private IccParametricCurveType type; + private readonly IccParametricCurve curve; + private readonly IccParametricCurveType type; private const IccParametricCurveType InvertedFlag = (IccParametricCurveType)(1 << 3); public ParametricCurveCalculator(IccParametricCurveTagDataEntry entry, bool inverted) @@ -26,41 +25,23 @@ public ParametricCurveCalculator(IccParametricCurveTagDataEntry entry, bool inve } public float Calculate(float value) - { - switch (this.type) - { - case IccParametricCurveType.Type1: - return this.CalculateGamma(value); - case IccParametricCurveType.Cie122_1996: - return this.CalculateCie122(value); - case IccParametricCurveType.Iec61966_3: - return this.CalculateIec61966(value); - case IccParametricCurveType.SRgb: - return this.CalculateSRgb(value); - case IccParametricCurveType.Type5: - return this.CalculateType5(value); - - case IccParametricCurveType.Type1 | InvertedFlag: - return this.CalculateInvertedGamma(value); - case IccParametricCurveType.Cie122_1996 | InvertedFlag: - return this.CalculateInvertedCie122(value); - case IccParametricCurveType.Iec61966_3 | InvertedFlag: - return this.CalculateInvertedIec61966(value); - case IccParametricCurveType.SRgb | InvertedFlag: - return this.CalculateInvertedSRgb(value); - case IccParametricCurveType.Type5 | InvertedFlag: - return this.CalculateInvertedType5(value); - - default: - throw new InvalidIccProfileException("ParametricCurve"); - } - } + => this.type switch + { + IccParametricCurveType.Type1 => this.CalculateGamma(value), + IccParametricCurveType.Cie122_1996 => this.CalculateCie122(value), + IccParametricCurveType.Iec61966_3 => this.CalculateIec61966(value), + IccParametricCurveType.SRgb => this.CalculateSRgb(value), + IccParametricCurveType.Type5 => this.CalculateType5(value), + IccParametricCurveType.Type1 | InvertedFlag => this.CalculateInvertedGamma(value), + IccParametricCurveType.Cie122_1996 | InvertedFlag => this.CalculateInvertedCie122(value), + IccParametricCurveType.Iec61966_3 | InvertedFlag => this.CalculateInvertedIec61966(value), + IccParametricCurveType.SRgb | InvertedFlag => this.CalculateInvertedSRgb(value), + IccParametricCurveType.Type5 | InvertedFlag => this.CalculateInvertedType5(value), + _ => throw new InvalidIccProfileException("ParametricCurve"), + }; [MethodImpl(MethodImplOptions.AggressiveInlining)] - private float CalculateGamma(float value) - { - return MathF.Pow(value, this.curve.G); - } + private float CalculateGamma(float value) => MathF.Pow(value, this.curve.G); [MethodImpl(MethodImplOptions.AggressiveInlining)] private float CalculateCie122(float value) @@ -116,15 +97,11 @@ private float CalculateType5(float value) [MethodImpl(MethodImplOptions.AggressiveInlining)] private float CalculateInvertedGamma(float value) - { - return MathF.Pow(value, 1 / this.curve.G); - } + => MathF.Pow(value, 1 / this.curve.G); [MethodImpl(MethodImplOptions.AggressiveInlining)] private float CalculateInvertedCie122(float value) - { - return (MathF.Pow(value, 1 / this.curve.G) - this.curve.B) / this.curve.A; - } + => (MathF.Pow(value, 1 / this.curve.G) - this.curve.B) / this.curve.A; [MethodImpl(MethodImplOptions.AggressiveInlining)] private float CalculateInvertedIec61966(float value) diff --git a/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/IccConverterBase.Checks.cs b/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/IccConverterBase.Checks.cs index fac56c3b5d..344efddad2 100644 --- a/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/IccConverterBase.Checks.cs +++ b/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/IccConverterBase.Checks.cs @@ -31,9 +31,7 @@ private static ConversionMethod GetConversionMethod(IccProfile profile, IccRende private static ConversionMethod CheckMethod1(IccProfile profile, IccRenderingIntent renderingIntent) { - ConversionMethod method = ConversionMethod.Invalid; - - method = CheckMethodD(profile, renderingIntent); + ConversionMethod method = CheckMethodD(profile, renderingIntent); if (method != ConversionMethod.Invalid) { return method; diff --git a/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/IccConverterbase.cs b/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/IccConverterbase.cs index 6e9c8aa829..79f04229e1 100644 --- a/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/IccConverterbase.cs +++ b/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/IccConverterbase.cs @@ -29,8 +29,5 @@ protected IccConverterBase(IccProfile profile, bool toPcs) /// The value to convert /// The converted value [MethodImpl(MethodImplOptions.AggressiveInlining)] - public Vector4 Calculate(Vector4 value) - { - return this.calculator.Calculate(value); - } + public Vector4 Calculate(Vector4 value) => this.calculator.Calculate(value); } diff --git a/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/IccProfileConverter.cs b/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/IccProfileConverter.cs new file mode 100644 index 0000000000..ef7be7d1ab --- /dev/null +++ b/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/IccProfileConverter.cs @@ -0,0 +1,43 @@ +// Copyright (c) Six Labors. +// Licensed under the Six Labors Split License. + +using System.Buffers; +using System.Numerics; +using SixLabors.ImageSharp.Advanced; +using SixLabors.ImageSharp.ColorSpaces.Conversion.Icc; +using SixLabors.ImageSharp.Memory; +using SixLabors.ImageSharp.Metadata.Profiles.Icc; +using SixLabors.ImageSharp.PixelFormats; + +namespace SixLabors.ImageSharp.ColorSpaces.Conversion.Implementation.Icc; +internal static class IccProfileConverter +{ + public static void Convert(Image image, IccProfile inputIccProfile, IccProfile outputIccProfile) + where TPixel : unmanaged, IPixel + { + IccDataToPcsConverter converterDataToPcs = new(inputIccProfile); + IccPcsToDataConverter converterPcsToData = new(outputIccProfile); + Configuration configuration = image.GetConfiguration(); + + image.ProcessPixelRows(accessor => + { + using IMemoryOwner vectors = configuration.MemoryAllocator.Allocate(accessor.Width); + Span vectorsSpan = vectors.GetSpan(); + for (int y = 0; y < accessor.Height; y++) + { + Span row = accessor.GetRowSpan(y); + PixelOperations.Instance.ToVector4(configuration, row, vectorsSpan, PixelConversionModifiers.Scale); + + for (int x = 0; x < vectorsSpan.Length; x++) + { + Vector4 pcs = converterDataToPcs.Calculate(vectorsSpan[x]); + vectorsSpan[x] = converterPcsToData.Calculate(pcs); + } + + PixelOperations.Instance.FromVector4Destructive(configuration, vectorsSpan, row); + } + }); + + image.Metadata.IccProfile = outputIccProfile; + } +} diff --git a/src/ImageSharp/Metadata/Profiles/ICC/IccProfile.cs b/src/ImageSharp/Metadata/Profiles/ICC/IccProfile.cs index e4403a47e2..00c545c88a 100644 --- a/src/ImageSharp/Metadata/Profiles/ICC/IccProfile.cs +++ b/src/ImageSharp/Metadata/Profiles/ICC/IccProfile.cs @@ -174,7 +174,6 @@ public byte[] ToByteArray() return copy; } - IccWriter writer = new(); return IccWriter.Write(this); } @@ -191,7 +190,6 @@ private void InitializeHeader() return; } - IccReader reader = new(); this.header = IccReader.ReadHeader(this.data); } diff --git a/src/ImageSharp/Metadata/Profiles/ICC/IccTagDataEntry.cs b/src/ImageSharp/Metadata/Profiles/ICC/IccTagDataEntry.cs index 56d620ec32..428dabf37b 100644 --- a/src/ImageSharp/Metadata/Profiles/ICC/IccTagDataEntry.cs +++ b/src/ImageSharp/Metadata/Profiles/ICC/IccTagDataEntry.cs @@ -1,4 +1,4 @@ -// Copyright (c) Six Labors. +// Copyright (c) Six Labors. // Licensed under the Six Labors Split License. namespace SixLabors.ImageSharp.Metadata.Profiles.Icc; @@ -41,9 +41,7 @@ protected IccTagDataEntry(IccTypeSignature signature, IccProfileTag tagSignature /// public override bool Equals(object obj) - { - return obj is IccTagDataEntry entry && this.Equals(entry); - } + => obj is IccTagDataEntry entry && this.Equals(entry); /// public virtual bool Equals(IccTagDataEntry other) diff --git a/tests/ImageSharp.Tests/Colorspaces/Icc/IccProfileConverterTests.cs b/tests/ImageSharp.Tests/Colorspaces/Icc/IccProfileConverterTests.cs new file mode 100644 index 0000000000..272219a5cf --- /dev/null +++ b/tests/ImageSharp.Tests/Colorspaces/Icc/IccProfileConverterTests.cs @@ -0,0 +1,58 @@ +// Copyright (c) Six Labors. +// Licensed under the Six Labors Split License. + +using SixLabors.ImageSharp.ColorSpaces.Conversion.Implementation.Icc; +using SixLabors.ImageSharp.Formats.Png; +using SixLabors.ImageSharp.Metadata.Profiles.Icc; +using SixLabors.ImageSharp.PixelFormats; + +namespace SixLabors.ImageSharp.Tests.Colorspaces.Icc; +public class IccProfileConverterTests +{ + private static PngEncoder Encoder = new PngEncoder(); + + [Theory] + [WithFile(TestImages.Jpeg.ICC.AdobeRgb, PixelTypes.Rgb24)] + [WithFile(TestImages.Jpeg.ICC.AppleRGB, PixelTypes.Rgb24)] + [WithFile(TestImages.Jpeg.ICC.ColorMatch, PixelTypes.Rgb24)] + [WithFile(TestImages.Jpeg.ICC.WideRGB, PixelTypes.Rgb24)] + + // [WithFile(TestImages.Jpeg.ICC.SRgb, PixelTypes.Rgb24)] ConverterBase says this is invalid. + // [WithFile(TestImages.Jpeg.ICC.ProPhoto, PixelTypes.Rgb24)] ConverterBase says this is invalid. + public void CanRoundTripProfile(TestImageProvider provider) + where TPixel : unmanaged, IPixel + { + using Image image = provider.GetImage(); + + IccProfile profile = image.Metadata.IccProfile; + + TPixel expected = image[0, 0]; + + IccProfileConverter.Convert(image, profile, profile); + + image.DebugSave(provider, Encoder); + + TPixel actual = image[0, 0]; + + Assert.Equal(expected, actual); + } + + // TODO: This fails as the base calculator says sRGB is invalid. + [Theory] + [WithFile(TestImages.Jpeg.ICC.AdobeRgb, PixelTypes.Rgb24)] + public void CanConvertTosRGB(TestImageProvider provider) + where TPixel : unmanaged, IPixel + { + using Image image = provider.GetImage(); + IccProfile profile = image.Metadata.IccProfile; + + string file = Path.Combine(TestEnvironment.InputImagesDirectoryFullPath, TestImages.Jpeg.ICC.SRgb); + IImageInfo i = Image.Identify(file); + IccProfile sRGBProfile = i.Metadata.IccProfile; + + IccProfileConverter.Convert(image, profile, sRGBProfile); + + // TODO: Compare. + image.DebugSave(provider, Encoder); + } +} diff --git a/tests/ImageSharp.Tests/TestImages.cs b/tests/ImageSharp.Tests/TestImages.cs index 638f7dfb71..39e4feab32 100644 --- a/tests/ImageSharp.Tests/TestImages.cs +++ b/tests/ImageSharp.Tests/TestImages.cs @@ -169,6 +169,16 @@ public static class Bad public static class Jpeg { + public static class ICC + { + public const string SRgb = "Jpg/icc-profiles/Momiji-sRGB-yes.jpg"; + public const string AdobeRgb = "Jpg/icc-profiles/Momiji-AdobeRGB-yes.jpg"; + public const string ColorMatch = "Jpg/icc-profiles/Momiji-ColorMatch-yes.jpg"; + public const string ProPhoto = "Jpg/icc-profiles/Momiji-ProPhoto-yes.jpg"; + public const string WideRGB = "Jpg/icc-profiles/Momiji-WideRGB-yes.jpg"; + public const string AppleRGB = "Jpg/icc-profiles/Momiji-AppleRGB-yes.jpg"; + } + public static class Progressive { public const string Fb = "Jpg/progressive/fb.jpg"; diff --git a/tests/Images/Input/Jpg/icc-profiles/Momiji-AdobeRGB-yes.jpg b/tests/Images/Input/Jpg/icc-profiles/Momiji-AdobeRGB-yes.jpg new file mode 100644 index 0000000000..077ee22beb --- /dev/null +++ b/tests/Images/Input/Jpg/icc-profiles/Momiji-AdobeRGB-yes.jpg @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:cb8bdcc137efa3e28db69e48612230b3a9fec17267de9ce29757d9bacc181d28 +size 42001 diff --git a/tests/Images/Input/Jpg/icc-profiles/Momiji-AppleRGB-yes.jpg b/tests/Images/Input/Jpg/icc-profiles/Momiji-AppleRGB-yes.jpg new file mode 100644 index 0000000000..188faa2bdd --- /dev/null +++ b/tests/Images/Input/Jpg/icc-profiles/Momiji-AppleRGB-yes.jpg @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:7129f5485e997b75cff143021522cc8ab94e2c3c1912689bc765ce2b3b937441 +size 72150 diff --git a/tests/Images/Input/Jpg/icc-profiles/Momiji-ColorMatch-yes.jpg b/tests/Images/Input/Jpg/icc-profiles/Momiji-ColorMatch-yes.jpg new file mode 100644 index 0000000000..befc3d1170 --- /dev/null +++ b/tests/Images/Input/Jpg/icc-profiles/Momiji-ColorMatch-yes.jpg @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:fe7fa60a53893836200c62f34492c7a0c931692dd073dffa4afc49fe3826e433 +size 44446 diff --git a/tests/Images/Input/Jpg/icc-profiles/Momiji-ProPhoto-yes.jpg b/tests/Images/Input/Jpg/icc-profiles/Momiji-ProPhoto-yes.jpg new file mode 100644 index 0000000000..645ad2869a --- /dev/null +++ b/tests/Images/Input/Jpg/icc-profiles/Momiji-ProPhoto-yes.jpg @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:bb686b44e3253143a32db890823f63c79026c9ac9badc4ad9de21f6cb2fa2f2a +size 40703 diff --git a/tests/Images/Input/Jpg/icc-profiles/Momiji-WideRGB-yes.jpg b/tests/Images/Input/Jpg/icc-profiles/Momiji-WideRGB-yes.jpg new file mode 100644 index 0000000000..57727aaa29 --- /dev/null +++ b/tests/Images/Input/Jpg/icc-profiles/Momiji-WideRGB-yes.jpg @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:928b854a9629d1532d37095c4744da6bc2fc986f878a76aea373f69490f4b586 +size 40505 diff --git a/tests/Images/Input/Jpg/icc-profiles/Momiji-sRGB-yes.jpg b/tests/Images/Input/Jpg/icc-profiles/Momiji-sRGB-yes.jpg new file mode 100644 index 0000000000..4b7b612be0 --- /dev/null +++ b/tests/Images/Input/Jpg/icc-profiles/Momiji-sRGB-yes.jpg @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:faf67048c2b7bd3fb5fa9b69bd53943d63a216ef371c5dc9d062ac443c9d2d34 +size 47434 From 54856ff945233315f486c61d17d7b9e83e5f4a22 Mon Sep 17 00:00:00 2001 From: James Jackson-South Date: Sun, 4 Dec 2022 18:24:58 +1000 Subject: [PATCH 11/42] Fix reader and out of range exception --- .../Icc/Calculators/LutABCalculator.cs | 1 - .../Icc/Calculators/LutCalculator.cs | 21 +++++++++++-------- .../Icc/IccConverterbase.Conversions.cs | 8 +++---- .../Metadata/Profiles/ICC/IccProfile.cs | 1 - .../Metadata/Profiles/ICC/IccReader.cs | 21 ++++++------------- .../Profiles/ICC/Various/IccTagTableEntry.cs | 10 +++------ .../Icc/IccProfileConverterTests.cs | 10 ++++----- 7 files changed, 29 insertions(+), 43 deletions(-) diff --git a/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/LutABCalculator.cs b/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/LutABCalculator.cs index 5ea734d713..817566c850 100644 --- a/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/LutABCalculator.cs +++ b/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/LutABCalculator.cs @@ -1,7 +1,6 @@ // Copyright (c) Six Labors. // Licensed under the Six Labors Split License. -using System; using System.Numerics; using SixLabors.ImageSharp.Metadata.Profiles.Icc; diff --git a/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/LutCalculator.cs b/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/LutCalculator.cs index 18fd622e6c..f15cc16588 100644 --- a/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/LutCalculator.cs +++ b/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/LutCalculator.cs @@ -1,15 +1,14 @@ -// Copyright (c) Six Labors. +// Copyright (c) Six Labors. // Licensed under the Six Labors Split License. -using System; using System.Runtime.CompilerServices; namespace SixLabors.ImageSharp.ColorSpaces.Conversion.Icc; internal class LutCalculator : ISingleCalculator { - private float[] lut; - private bool inverse; + private readonly float[] lut; + private readonly bool inverse; public LutCalculator(float[] lut, bool inverse) { @@ -25,10 +24,8 @@ public float Calculate(float value) { return this.LookupInverse(value); } - else - { - return this.Lookup(value); - } + + return this.Lookup(value); } [MethodImpl(MethodImplOptions.AggressiveInlining)] @@ -37,7 +34,13 @@ private float Lookup(float value) float factor = value * (this.lut.Length - 1); int index = (int)factor; float low = this.lut[index]; - float high = this.lut[index + 1]; + + float high = 1F; + if (index < this.lut.Length - 1) + { + high = this.lut[index + 1]; + } + return low + ((high - low) * (factor - index)); } diff --git a/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/IccConverterbase.Conversions.cs b/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/IccConverterbase.Conversions.cs index 56941c19e3..f40361696c 100644 --- a/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/IccConverterbase.Conversions.cs +++ b/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/IccConverterbase.Conversions.cs @@ -22,8 +22,7 @@ internal abstract partial class IccConverterBase /// The wanted rendering intent. Can be ignored if not available protected void Init(IccProfile profile, bool toPcs, IccRenderingIntent renderingIntent) { - ConversionMethod method = GetConversionMethod(profile, renderingIntent); - switch (method) + switch (GetConversionMethod(profile, renderingIntent)) { case ConversionMethod.D0: this.calculator = toPcs ? @@ -83,8 +82,7 @@ protected void Init(IccProfile profile, bool toPcs, IccRenderingIntent rendering private static IVector4Calculator InitA(IccProfile profile, IccProfileTag tag) { - IccTagDataEntry entry = GetTag(profile, tag); - switch (entry) + switch (GetTag(profile, tag)) { case IccLut8TagDataEntry lut8: return new LutEntryCalculator(lut8); @@ -96,6 +94,8 @@ private static IVector4Calculator InitA(IccProfile profile, IccProfileTag tag) return new LutABCalculator(lutBtoA); default: + + // TODO: This is where we likely return a matrix calculator. throw new InvalidIccProfileException("Invalid entry."); } } diff --git a/src/ImageSharp/Metadata/Profiles/ICC/IccProfile.cs b/src/ImageSharp/Metadata/Profiles/ICC/IccProfile.cs index 00c545c88a..aa0ebe4880 100644 --- a/src/ImageSharp/Metadata/Profiles/ICC/IccProfile.cs +++ b/src/ImageSharp/Metadata/Profiles/ICC/IccProfile.cs @@ -206,7 +206,6 @@ private void InitializeEntries() return; } - IccReader reader = new(); this.entries = IccReader.ReadTagData(this.data); } } diff --git a/src/ImageSharp/Metadata/Profiles/ICC/IccReader.cs b/src/ImageSharp/Metadata/Profiles/ICC/IccReader.cs index 0fe01fbdb2..074712d302 100644 --- a/src/ImageSharp/Metadata/Profiles/ICC/IccReader.cs +++ b/src/ImageSharp/Metadata/Profiles/ICC/IccReader.cs @@ -83,28 +83,19 @@ private static IccTagDataEntry[] ReadTagData(IccDataReader reader) { IccTagTableEntry[] tagTable = ReadTagTable(reader); List entries = new(tagTable.Length); - Dictionary store = new(); foreach (IccTagTableEntry tag in tagTable) { IccTagDataEntry entry; - if (store.ContainsKey(tag.Offset)) + + try { - entry = store[tag.Offset]; + entry = reader.ReadTagDataEntry(tag); } - else + catch { - try - { - entry = reader.ReadTagDataEntry(tag); - } - catch - { - // Ignore tags that could not be read - continue; - } - - store.Add(tag.Offset, entry); + // Ignore tags that could not be read + continue; } entry.TagSignature = tag.Signature; diff --git a/src/ImageSharp/Metadata/Profiles/ICC/Various/IccTagTableEntry.cs b/src/ImageSharp/Metadata/Profiles/ICC/Various/IccTagTableEntry.cs index 539fe723e2..2e0a5eaa96 100644 --- a/src/ImageSharp/Metadata/Profiles/ICC/Various/IccTagTableEntry.cs +++ b/src/ImageSharp/Metadata/Profiles/ICC/Various/IccTagTableEntry.cs @@ -1,4 +1,4 @@ -// Copyright (c) Six Labors. +// Copyright (c) Six Labors. // Licensed under the Six Labors Split License. namespace SixLabors.ImageSharp.Metadata.Profiles.Icc; @@ -49,9 +49,7 @@ public IccTagTableEntry(IccProfileTag signature, uint offset, uint dataSize) /// True if the parameter is equal to the parameter; otherwise, false. /// public static bool operator ==(IccTagTableEntry left, IccTagTableEntry right) - { - return left.Equals(right); - } + => left.Equals(right); /// /// Compares two objects for equality. @@ -62,9 +60,7 @@ public IccTagTableEntry(IccProfileTag signature, uint offset, uint dataSize) /// True if the parameter is not equal to the parameter; otherwise, false. /// public static bool operator !=(IccTagTableEntry left, IccTagTableEntry right) - { - return !left.Equals(right); - } + => !left.Equals(right); /// public override bool Equals(object obj) => obj is IccTagTableEntry other && this.Equals(other); diff --git a/tests/ImageSharp.Tests/Colorspaces/Icc/IccProfileConverterTests.cs b/tests/ImageSharp.Tests/Colorspaces/Icc/IccProfileConverterTests.cs index 272219a5cf..67aa347b2f 100644 --- a/tests/ImageSharp.Tests/Colorspaces/Icc/IccProfileConverterTests.cs +++ b/tests/ImageSharp.Tests/Colorspaces/Icc/IccProfileConverterTests.cs @@ -9,16 +9,15 @@ namespace SixLabors.ImageSharp.Tests.Colorspaces.Icc; public class IccProfileConverterTests { - private static PngEncoder Encoder = new PngEncoder(); + private static readonly PngEncoder Encoder = new(); [Theory] [WithFile(TestImages.Jpeg.ICC.AdobeRgb, PixelTypes.Rgb24)] [WithFile(TestImages.Jpeg.ICC.AppleRGB, PixelTypes.Rgb24)] [WithFile(TestImages.Jpeg.ICC.ColorMatch, PixelTypes.Rgb24)] [WithFile(TestImages.Jpeg.ICC.WideRGB, PixelTypes.Rgb24)] - - // [WithFile(TestImages.Jpeg.ICC.SRgb, PixelTypes.Rgb24)] ConverterBase says this is invalid. - // [WithFile(TestImages.Jpeg.ICC.ProPhoto, PixelTypes.Rgb24)] ConverterBase says this is invalid. + [WithFile(TestImages.Jpeg.ICC.SRgb, PixelTypes.Rgb24)] + [WithFile(TestImages.Jpeg.ICC.ProPhoto, PixelTypes.Rgb24)] public void CanRoundTripProfile(TestImageProvider provider) where TPixel : unmanaged, IPixel { @@ -37,10 +36,9 @@ public void CanRoundTripProfile(TestImageProvider provider) Assert.Equal(expected, actual); } - // TODO: This fails as the base calculator says sRGB is invalid. [Theory] [WithFile(TestImages.Jpeg.ICC.AdobeRgb, PixelTypes.Rgb24)] - public void CanConvertTosRGB(TestImageProvider provider) + public void CanConvertToWide(TestImageProvider provider) where TPixel : unmanaged, IPixel { using Image image = provider.GetImage(); From eee14c649ffb930880e5027e2dba39e8b5a50b3a Mon Sep 17 00:00:00 2001 From: James Jackson-South Date: Sun, 4 Dec 2022 19:44:28 +1000 Subject: [PATCH 12/42] Remove invalid test. --- .../ICC/DataReader/IccDataReader.TagDataEntry.cs | 6 ++---- .../Metadata/Profiles/ICC/IccReaderTests.cs | 9 --------- 2 files changed, 2 insertions(+), 13 deletions(-) diff --git a/src/ImageSharp/Metadata/Profiles/ICC/DataReader/IccDataReader.TagDataEntry.cs b/src/ImageSharp/Metadata/Profiles/ICC/DataReader/IccDataReader.TagDataEntry.cs index 53b47d38bd..5604981ceb 100644 --- a/src/ImageSharp/Metadata/Profiles/ICC/DataReader/IccDataReader.TagDataEntry.cs +++ b/src/ImageSharp/Metadata/Profiles/ICC/DataReader/IccDataReader.TagDataEntry.cs @@ -19,9 +19,7 @@ internal sealed partial class IccDataReader public IccTagDataEntry ReadTagDataEntry(IccTagTableEntry info) { this.currentIndex = (int)info.Offset; - IccTypeSignature type = this.ReadTagDataEntryHeader(); - - switch (type) + switch (this.ReadTagDataEntryHeader()) { case IccTypeSignature.Chromaticity: return this.ReadChromaticityTagDataEntry(); @@ -105,7 +103,7 @@ public IccTagDataEntry ReadTagDataEntry(IccTagTableEntry info) /// The read signature public IccTypeSignature ReadTagDataEntryHeader() { - var type = (IccTypeSignature)this.ReadUInt32(); + IccTypeSignature type = (IccTypeSignature)this.ReadUInt32(); this.AddIndex(4); // 4 bytes are not used return type; } diff --git a/tests/ImageSharp.Tests/Metadata/Profiles/ICC/IccReaderTests.cs b/tests/ImageSharp.Tests/Metadata/Profiles/ICC/IccReaderTests.cs index 3e3a2513a4..78b3567872 100644 --- a/tests/ImageSharp.Tests/Metadata/Profiles/ICC/IccReaderTests.cs +++ b/tests/ImageSharp.Tests/Metadata/Profiles/ICC/IccReaderTests.cs @@ -37,13 +37,4 @@ public void ReadProfile_NoEntries() Assert.Equal(header.Size, expected.Size); Assert.Equal(header.Version, expected.Version); } - - [Fact] - public void ReadProfile_DuplicateEntry() - { - IccProfile output = IccReader.Read(IccTestDataProfiles.ProfileRandomArray); - - Assert.Equal(2, output.Entries.Length); - Assert.True(ReferenceEquals(output.Entries[0], output.Entries[1])); - } } From 8de137ec8a8b97f078d0c3257777814a5463b4f7 Mon Sep 17 00:00:00 2001 From: James Jackson-South Date: Thu, 15 Dec 2022 10:11:14 +1000 Subject: [PATCH 13/42] Cleanup code style --- .../Icc/Calculators/ColorTrcCalculator.cs | 12 +- .../Icc/Calculators/CurveCalculator.cs | 27 ++--- .../Icc/Calculators/GrayTrcCalculator.cs | 11 +- .../LutABCalculator.CalculationType.cs | 2 +- .../Icc/Calculators/LutEntryCalculator.cs | 14 ++- .../Calculators/ParametricCurveCalculator.cs | 42 +++---- .../Icc/Calculators/TrcCalculator.cs | 24 ++-- .../Icc/IccConverterBase.Checks.cs | 27 ++--- .../Icc/IccConverterbase.Conversions.cs | 110 ++++++------------ .../Implementation/Icc/IccProfileConverter.cs | 18 +++ .../Icc/Calculators/CurveCalculatorTests.cs | 3 +- .../Icc/Calculators/LutABCalculatorTests.cs | 5 +- .../Icc/Calculators/LutCalculatorTests.cs | 3 +- .../Calculators/LutEntryCalculatorTests.cs | 5 +- .../Icc/Calculators/MatrixCalculatorTests.cs | 3 +- .../ParametricCurveCalculatorTests.cs | 3 +- .../Icc/Calculators/TrcCalculatorTests.cs | 3 +- .../Conversion/IccConversionDataTrc.cs | 8 +- 18 files changed, 123 insertions(+), 197 deletions(-) diff --git a/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/ColorTrcCalculator.cs b/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/ColorTrcCalculator.cs index eb6d06b5d0..ef557cc862 100644 --- a/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/ColorTrcCalculator.cs +++ b/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/ColorTrcCalculator.cs @@ -9,9 +9,9 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion.Icc; internal class ColorTrcCalculator : IVector4Calculator { - private TrcCalculator curveCalculator; + private readonly TrcCalculator curveCalculator; private Matrix4x4 matrix; - private bool toPcs; + private readonly bool toPcs; public ColorTrcCalculator( IccXyzTagDataEntry redMatrixColumn, @@ -44,10 +44,8 @@ public Vector4 Calculate(Vector4 value) value = this.curveCalculator.Calculate(value); return Vector4.Transform(value, this.matrix); } - else - { - value = Vector4.Transform(value, this.matrix); - return this.curveCalculator.Calculate(value); - } + + value = Vector4.Transform(value, this.matrix); + return this.curveCalculator.Calculate(value); } } diff --git a/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/CurveCalculator.cs b/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/CurveCalculator.cs index 48213a486d..da40d3912c 100644 --- a/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/CurveCalculator.cs +++ b/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/CurveCalculator.cs @@ -7,9 +7,9 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion.Icc; internal partial class CurveCalculator : ISingleCalculator { - private LutCalculator lutCalculator; - private float gamma; - private CalculationType type; + private readonly LutCalculator lutCalculator; + private readonly float gamma; + private readonly CalculationType type; public CurveCalculator(IccCurveTagDataEntry entry, bool inverted) { @@ -35,20 +35,11 @@ public CurveCalculator(IccCurveTagDataEntry entry, bool inverted) } public float Calculate(float value) - { - switch (this.type) + => this.type switch { - case CalculationType.Identity: - return value; - - case CalculationType.Gamma: - return MathF.Pow(value, this.gamma); - - case CalculationType.Lut: - return this.lutCalculator.Calculate(value); - - default: - throw new InvalidOperationException("Invalid calculation type"); - } - } + CalculationType.Identity => value, + CalculationType.Gamma => MathF.Pow(value, this.gamma), // TODO: This could be optimized using a LUT. See SrgbCompanding + CalculationType.Lut => this.lutCalculator.Calculate(value), + _ => throw new InvalidOperationException("Invalid calculation type"), + }; } diff --git a/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/GrayTrcCalculator.cs b/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/GrayTrcCalculator.cs index 1c68668d20..4df47950ec 100644 --- a/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/GrayTrcCalculator.cs +++ b/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/GrayTrcCalculator.cs @@ -9,16 +9,11 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion.Icc; internal class GrayTrcCalculator : IVector4Calculator { - private TrcCalculator calculator; + private readonly TrcCalculator calculator; public GrayTrcCalculator(IccTagDataEntry grayTrc, bool toPcs) - { - this.calculator = new TrcCalculator(new IccTagDataEntry[] { grayTrc }, !toPcs); - } + => this.calculator = new TrcCalculator(new IccTagDataEntry[] { grayTrc }, !toPcs); [MethodImpl(MethodImplOptions.AggressiveInlining)] - public Vector4 Calculate(Vector4 value) - { - return this.calculator.Calculate(value); - } + public Vector4 Calculate(Vector4 value) => this.calculator.Calculate(value); } diff --git a/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/LutABCalculator.CalculationType.cs b/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/LutABCalculator.CalculationType.cs index 7473fd7a0f..a09150c9b6 100644 --- a/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/LutABCalculator.CalculationType.cs +++ b/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/LutABCalculator.CalculationType.cs @@ -1,4 +1,4 @@ -// Copyright (c) Six Labors. +// Copyright (c) Six Labors. // Licensed under the Six Labors Split License. namespace SixLabors.ImageSharp.ColorSpaces.Conversion.Icc; diff --git a/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/LutEntryCalculator.cs b/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/LutEntryCalculator.cs index dd3e62a763..643090c9d8 100644 --- a/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/LutEntryCalculator.cs +++ b/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/LutEntryCalculator.cs @@ -2,6 +2,7 @@ // Licensed under the Six Labors Split License. using System.Numerics; +using System.Runtime.CompilerServices; using SixLabors.ImageSharp.Metadata.Profiles.Icc; namespace SixLabors.ImageSharp.ColorSpaces.Conversion.Icc; @@ -26,6 +27,7 @@ public LutEntryCalculator(IccLut16TagDataEntry lut) this.Init(lut.InputValues, lut.OutputValues, lut.ClutValues, lut.Matrix); } + [MethodImpl(MethodImplOptions.AggressiveInlining)] public Vector4 Calculate(Vector4 value) { if (this.doTransform) @@ -33,19 +35,19 @@ public Vector4 Calculate(Vector4 value) value = Vector4.Transform(value, this.matrix); } - value = this.CalculateLut(this.inputCurve, value); + value = CalculateLut(this.inputCurve, value); value = this.clutCalculator.Calculate(value); - return this.CalculateLut(this.outputCurve, value); + return CalculateLut(this.outputCurve, value); } - private unsafe Vector4 CalculateLut(LutCalculator[] lut, Vector4 value) + [MethodImpl(MethodImplOptions.AggressiveInlining)] + private static unsafe Vector4 CalculateLut(LutCalculator[] lut, Vector4 value) { value = Vector4.Clamp(value, Vector4.Zero, Vector4.One); - - float* valuePointer = (float*)&value; + ref float f = ref Unsafe.As(ref value); for (int i = 0; i < lut.Length; i++) { - valuePointer[i] = lut[i].Calculate(valuePointer[i]); + Unsafe.Add(ref f, i) = lut[i].Calculate(Unsafe.Add(ref f, i)); } return value; diff --git a/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/ParametricCurveCalculator.cs b/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/ParametricCurveCalculator.cs index 9312326830..b38c6ecdce 100644 --- a/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/ParametricCurveCalculator.cs +++ b/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/ParametricCurveCalculator.cs @@ -50,10 +50,8 @@ private float CalculateCie122(float value) { return MathF.Pow((this.curve.A * value) + this.curve.B, this.curve.G); } - else - { - return 0; - } + + return 0; } [MethodImpl(MethodImplOptions.AggressiveInlining)] @@ -63,10 +61,8 @@ private float CalculateIec61966(float value) { return MathF.Pow((this.curve.A * value) + this.curve.B, this.curve.G) + this.curve.C; } - else - { - return this.curve.C; - } + + return this.curve.C; } [MethodImpl(MethodImplOptions.AggressiveInlining)] @@ -76,10 +72,8 @@ private float CalculateSRgb(float value) { return MathF.Pow((this.curve.A * value) + this.curve.B, this.curve.G); } - else - { - return this.curve.C * value; - } + + return this.curve.C * value; } [MethodImpl(MethodImplOptions.AggressiveInlining)] @@ -89,10 +83,8 @@ private float CalculateType5(float value) { return MathF.Pow((this.curve.A * value) + this.curve.B, this.curve.G) + this.curve.E; } - else - { - return (this.curve.C * value) + this.curve.F; - } + + return (this.curve.C * value) + this.curve.F; } [MethodImpl(MethodImplOptions.AggressiveInlining)] @@ -110,10 +102,8 @@ private float CalculateInvertedIec61966(float value) { return (MathF.Pow(value - this.curve.C, 1 / this.curve.G) - this.curve.B) / this.curve.A; } - else - { - return -this.curve.B / this.curve.A; - } + + return -this.curve.B / this.curve.A; } [MethodImpl(MethodImplOptions.AggressiveInlining)] @@ -123,10 +113,8 @@ private float CalculateInvertedSRgb(float value) { return (MathF.Pow(value, 1 / this.curve.G) - this.curve.B) / this.curve.A; } - else - { - return value / this.curve.C; - } + + return value / this.curve.C; } [MethodImpl(MethodImplOptions.AggressiveInlining)] @@ -136,9 +124,7 @@ private float CalculateInvertedType5(float value) { return (MathF.Pow(value - this.curve.E, 1 / this.curve.G) - this.curve.B) / this.curve.A; } - else - { - return (value - this.curve.F) / this.curve.C; - } + + return (value - this.curve.F) / this.curve.C; } } diff --git a/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/TrcCalculator.cs b/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/TrcCalculator.cs index 83a6f0ecd9..a064610380 100644 --- a/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/TrcCalculator.cs +++ b/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/TrcCalculator.cs @@ -2,13 +2,14 @@ // Licensed under the Six Labors Split License. using System.Numerics; +using System.Runtime.CompilerServices; using SixLabors.ImageSharp.Metadata.Profiles.Icc; namespace SixLabors.ImageSharp.ColorSpaces.Conversion.Icc; internal class TrcCalculator : IVector4Calculator { - private ISingleCalculator[] calculators; + private readonly ISingleCalculator[] calculators; public TrcCalculator(IccTagDataEntry[] entries, bool inverted) { @@ -17,28 +18,21 @@ public TrcCalculator(IccTagDataEntry[] entries, bool inverted) this.calculators = new ISingleCalculator[entries.Length]; for (int i = 0; i < entries.Length; i++) { - switch (entries[i]) + this.calculators[i] = entries[i] switch { - case IccCurveTagDataEntry curve: - this.calculators[i] = new CurveCalculator(curve, inverted); - break; - - case IccParametricCurveTagDataEntry parametricCurve: - this.calculators[i] = new ParametricCurveCalculator(parametricCurve, inverted); - break; - - default: - throw new InvalidIccProfileException("Invalid Entry."); - } + IccCurveTagDataEntry curve => new CurveCalculator(curve, inverted), + IccParametricCurveTagDataEntry parametricCurve => new ParametricCurveCalculator(parametricCurve, inverted), + _ => throw new InvalidIccProfileException("Invalid Entry."), + }; } } public unsafe Vector4 Calculate(Vector4 value) { - float* valuePointer = (float*)&value; + ref float f = ref Unsafe.As(ref value); for (int i = 0; i < this.calculators.Length; i++) { - valuePointer[i] = this.calculators[i].Calculate(valuePointer[i]); + Unsafe.Add(ref f, i) = this.calculators[i].Calculate(Unsafe.Add(ref f, i)); } return value; diff --git a/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/IccConverterBase.Checks.cs b/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/IccConverterBase.Checks.cs index 344efddad2..59ff612bd0 100644 --- a/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/IccConverterBase.Checks.cs +++ b/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/IccConverterBase.Checks.cs @@ -10,24 +10,15 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion.Icc; /// internal abstract partial class IccConverterBase { - private static ConversionMethod GetConversionMethod(IccProfile profile, IccRenderingIntent renderingIntent) + private static ConversionMethod GetConversionMethod(IccProfile profile, IccRenderingIntent renderingIntent) => profile.Header.Class switch { - switch (profile.Header.Class) - { - case IccProfileClass.InputDevice: - case IccProfileClass.DisplayDevice: - case IccProfileClass.OutputDevice: - case IccProfileClass.ColorSpace: - return CheckMethod1(profile, renderingIntent); - - case IccProfileClass.DeviceLink: - case IccProfileClass.Abstract: - return CheckMethod2(profile); - - default: - return ConversionMethod.Invalid; - } - } + IccProfileClass.InputDevice or + IccProfileClass.DisplayDevice or + IccProfileClass.OutputDevice or + IccProfileClass.ColorSpace => CheckMethod1(profile, renderingIntent), + IccProfileClass.DeviceLink or IccProfileClass.Abstract => CheckMethod2(profile), + _ => ConversionMethod.Invalid, + }; private static ConversionMethod CheckMethod1(IccProfile profile, IccRenderingIntent renderingIntent) { @@ -155,7 +146,7 @@ private static bool HasTag(IccProfile profile, IccProfileTag tag) => profile.Entries.Any(t => t.TagSignature == tag); private static IccTagDataEntry GetTag(IccProfile profile, IccProfileTag tag) - => profile.Entries.FirstOrDefault(t => t.TagSignature == tag); + => Array.Find(profile.Entries, t => t.TagSignature == tag); private static T GetTag(IccProfile profile, IccProfileTag tag) where T : IccTagDataEntry diff --git a/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/IccConverterbase.Conversions.cs b/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/IccConverterbase.Conversions.cs index f40361696c..9d2390ac79 100644 --- a/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/IccConverterbase.Conversions.cs +++ b/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/IccConverterbase.Conversions.cs @@ -1,8 +1,6 @@ // Copyright (c) Six Labors. // Licensed under the Six Labors Split License. -using System; -using SixLabors.ImageSharp.ColorSpaces.Conversion.Icc; using SixLabors.ImageSharp.Metadata.Profiles.Icc; namespace SixLabors.ImageSharp.ColorSpaces.Conversion.Icc; @@ -20,85 +18,45 @@ internal abstract partial class IccConverterBase /// The profile to use for the conversion /// True if the conversion is to the Profile Connection Space /// The wanted rendering intent. Can be ignored if not available + /// Invalid conversion method. protected void Init(IccProfile profile, bool toPcs, IccRenderingIntent renderingIntent) - { - switch (GetConversionMethod(profile, renderingIntent)) + => this.calculator = GetConversionMethod(profile, renderingIntent) switch { - case ConversionMethod.D0: - this.calculator = toPcs ? - InitD(profile, IccProfileTag.DToB0) : - InitD(profile, IccProfileTag.BToD0); - break; - - case ConversionMethod.D1: - this.calculator = toPcs ? - InitD(profile, IccProfileTag.DToB1) : - InitD(profile, IccProfileTag.BToD1); - break; - - case ConversionMethod.D2: - this.calculator = toPcs ? - InitD(profile, IccProfileTag.DToB2) : - InitD(profile, IccProfileTag.BToD2); - break; - - case ConversionMethod.D3: - this.calculator = toPcs ? - InitD(profile, IccProfileTag.DToB3) : - InitD(profile, IccProfileTag.BToD3); - break; - - case ConversionMethod.A0: - this.calculator = toPcs ? - InitA(profile, IccProfileTag.AToB0) : - InitA(profile, IccProfileTag.BToA0); - break; - - case ConversionMethod.A1: - this.calculator = toPcs ? - InitA(profile, IccProfileTag.AToB1) : - InitA(profile, IccProfileTag.BToA1); - break; - - case ConversionMethod.A2: - this.calculator = toPcs ? - InitA(profile, IccProfileTag.AToB2) : - InitA(profile, IccProfileTag.BToA2); - break; - - case ConversionMethod.ColorTrc: - this.calculator = InitColorTrc(profile, toPcs); - break; - - case ConversionMethod.GrayTrc: - this.calculator = InitGrayTrc(profile, toPcs); - break; - - case ConversionMethod.Invalid: - default: - throw new InvalidIccProfileException("Invalid conversion method."); - } - } + ConversionMethod.D0 => toPcs ? + InitD(profile, IccProfileTag.DToB0) : + InitD(profile, IccProfileTag.BToD0), + ConversionMethod.D1 => toPcs ? + InitD(profile, IccProfileTag.DToB1) : + InitD(profile, IccProfileTag.BToD1), + ConversionMethod.D2 => toPcs ? + InitD(profile, IccProfileTag.DToB2) : + InitD(profile, IccProfileTag.BToD2), + ConversionMethod.D3 => toPcs ? + InitD(profile, IccProfileTag.DToB3) : + InitD(profile, IccProfileTag.BToD3), + ConversionMethod.A0 => toPcs ? + InitA(profile, IccProfileTag.AToB0) : + InitA(profile, IccProfileTag.BToA0), + ConversionMethod.A1 => toPcs ? + InitA(profile, IccProfileTag.AToB1) : + InitA(profile, IccProfileTag.BToA1), + ConversionMethod.A2 => toPcs ? + InitA(profile, IccProfileTag.AToB2) : + InitA(profile, IccProfileTag.BToA2), + ConversionMethod.ColorTrc => InitColorTrc(profile, toPcs), + ConversionMethod.GrayTrc => InitGrayTrc(profile, toPcs), + _ => throw new InvalidIccProfileException("Invalid conversion method."), + }; private static IVector4Calculator InitA(IccProfile profile, IccProfileTag tag) - { - switch (GetTag(profile, tag)) + => GetTag(profile, tag) switch { - case IccLut8TagDataEntry lut8: - return new LutEntryCalculator(lut8); - case IccLut16TagDataEntry lut16: - return new LutEntryCalculator(lut16); - case IccLutAToBTagDataEntry lutAtoB: - return new LutABCalculator(lutAtoB); - case IccLutBToATagDataEntry lutBtoA: - return new LutABCalculator(lutBtoA); - - default: - - // TODO: This is where we likely return a matrix calculator. - throw new InvalidIccProfileException("Invalid entry."); - } - } + IccLut8TagDataEntry lut8 => new LutEntryCalculator(lut8), + IccLut16TagDataEntry lut16 => new LutEntryCalculator(lut16), + IccLutAToBTagDataEntry lutAtoB => new LutABCalculator(lutAtoB), + IccLutBToATagDataEntry lutBtoA => new LutABCalculator(lutBtoA), + _ => throw new InvalidIccProfileException("Invalid entry."), + }; private static IVector4Calculator InitD(IccProfile profile, IccProfileTag tag) { diff --git a/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/IccProfileConverter.cs b/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/IccProfileConverter.cs index ef7be7d1ab..6325c5ce19 100644 --- a/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/IccProfileConverter.cs +++ b/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/IccProfileConverter.cs @@ -10,11 +10,28 @@ using SixLabors.ImageSharp.PixelFormats; namespace SixLabors.ImageSharp.ColorSpaces.Conversion.Implementation.Icc; + +/// +/// Allows the copnversion between ICC profiles. +/// internal static class IccProfileConverter { + /// + /// Performs a conversion of the image pixels based on the input and output ICC profiles. + /// + /// The type of pixel. + /// The image to convert. + /// The input ICC profile. + /// The output ICC profile. public static void Convert(Image image, IccProfile inputIccProfile, IccProfile outputIccProfile) where TPixel : unmanaged, IPixel { + // TODO: Is this the correct property? + if (inputIccProfile.Header.Id.Equals(outputIccProfile.Header.Id)) + { + return; + } + IccDataToPcsConverter converterDataToPcs = new(inputIccProfile); IccPcsToDataConverter converterPcsToData = new(outputIccProfile); Configuration configuration = image.GetConfiguration(); @@ -38,6 +55,7 @@ public static void Convert(Image image, IccProfile inputIccProfi } }); + // TODO: Do not preserve the profile if we are converting to sRGB. image.Metadata.IccProfile = outputIccProfile; } } diff --git a/tests/ImageSharp.Tests/Colorspaces/Icc/Calculators/CurveCalculatorTests.cs b/tests/ImageSharp.Tests/Colorspaces/Icc/Calculators/CurveCalculatorTests.cs index 384f68afdf..65d41f2df6 100644 --- a/tests/ImageSharp.Tests/Colorspaces/Icc/Calculators/CurveCalculatorTests.cs +++ b/tests/ImageSharp.Tests/Colorspaces/Icc/Calculators/CurveCalculatorTests.cs @@ -4,7 +4,6 @@ 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 { @@ -18,7 +17,7 @@ public class CurveCalculatorTests [MemberData(nameof(IccConversionDataTrc.CurveConversionTestData), MemberType = typeof(IccConversionDataTrc))] internal void CurveCalculator_WithCurveEntry_ReturnsResult(IccCurveTagDataEntry curve, bool inverted, float input, float expected) { - var calculator = new CurveCalculator(curve, inverted); + CurveCalculator calculator = new(curve, inverted); float result = calculator.Calculate(input); diff --git a/tests/ImageSharp.Tests/Colorspaces/Icc/Calculators/LutABCalculatorTests.cs b/tests/ImageSharp.Tests/Colorspaces/Icc/Calculators/LutABCalculatorTests.cs index 712d096cbb..4b0ec9af1a 100644 --- a/tests/ImageSharp.Tests/Colorspaces/Icc/Calculators/LutABCalculatorTests.cs +++ b/tests/ImageSharp.Tests/Colorspaces/Icc/Calculators/LutABCalculatorTests.cs @@ -5,7 +5,6 @@ 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 { @@ -19,7 +18,7 @@ public class LutABCalculatorTests [MemberData(nameof(IccConversionDataLutAB.LutAToBConversionTestData), MemberType = typeof(IccConversionDataLutAB))] internal void LutABCalculator_WithLutAToB_ReturnsResult(IccLutAToBTagDataEntry lut, Vector4 input, Vector4 expected) { - var calculator = new LutABCalculator(lut); + LutABCalculator calculator = new(lut); Vector4 result = calculator.Calculate(input); @@ -30,7 +29,7 @@ internal void LutABCalculator_WithLutAToB_ReturnsResult(IccLutAToBTagDataEntry l [MemberData(nameof(IccConversionDataLutAB.LutBToAConversionTestData), MemberType = typeof(IccConversionDataLutAB))] internal void LutABCalculator_WithLutBToA_ReturnsResult(IccLutBToATagDataEntry lut, Vector4 input, Vector4 expected) { - var calculator = new LutABCalculator(lut); + LutABCalculator calculator = new(lut); Vector4 result = calculator.Calculate(input); diff --git a/tests/ImageSharp.Tests/Colorspaces/Icc/Calculators/LutCalculatorTests.cs b/tests/ImageSharp.Tests/Colorspaces/Icc/Calculators/LutCalculatorTests.cs index 3caad03a6c..2c6317d605 100644 --- a/tests/ImageSharp.Tests/Colorspaces/Icc/Calculators/LutCalculatorTests.cs +++ b/tests/ImageSharp.Tests/Colorspaces/Icc/Calculators/LutCalculatorTests.cs @@ -3,7 +3,6 @@ using SixLabors.ImageSharp.ColorSpaces.Conversion.Icc; using SixLabors.ImageSharp.Tests.TestDataIcc.Conversion; -using Xunit; namespace SixLabors.ImageSharp.Tests.Colorspaces.Icc.Calculators { @@ -17,7 +16,7 @@ public class LutCalculatorTests [MemberData(nameof(IccConversionDataLut.LutConversionTestData), MemberType = typeof(IccConversionDataLut))] internal void LutCalculator_WithLut_ReturnsResult(float[] lut, bool inverted, float input, float expected) { - var calculator = new LutCalculator(lut, inverted); + LutCalculator calculator = new(lut, inverted); float result = calculator.Calculate(input); diff --git a/tests/ImageSharp.Tests/Colorspaces/Icc/Calculators/LutEntryCalculatorTests.cs b/tests/ImageSharp.Tests/Colorspaces/Icc/Calculators/LutEntryCalculatorTests.cs index 8b374dedb6..e275b66634 100644 --- a/tests/ImageSharp.Tests/Colorspaces/Icc/Calculators/LutEntryCalculatorTests.cs +++ b/tests/ImageSharp.Tests/Colorspaces/Icc/Calculators/LutEntryCalculatorTests.cs @@ -5,7 +5,6 @@ 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 { @@ -19,7 +18,7 @@ public class LutEntryCalculatorTests [MemberData(nameof(IccConversionDataLutEntry.Lut8ConversionTestData), MemberType = typeof(IccConversionDataLutEntry))] internal void LutEntryCalculator_WithLut8_ReturnsResult(IccLut8TagDataEntry lut, Vector4 input, Vector4 expected) { - var calculator = new LutEntryCalculator(lut); + LutEntryCalculator calculator = new(lut); Vector4 result = calculator.Calculate(input); @@ -30,7 +29,7 @@ internal void LutEntryCalculator_WithLut8_ReturnsResult(IccLut8TagDataEntry lut, [MemberData(nameof(IccConversionDataLutEntry.Lut16ConversionTestData), MemberType = typeof(IccConversionDataLutEntry))] internal void LutEntryCalculator_WithLut16_ReturnsResult(IccLut16TagDataEntry lut, Vector4 input, Vector4 expected) { - var calculator = new LutEntryCalculator(lut); + LutEntryCalculator calculator = new(lut); Vector4 result = calculator.Calculate(input); diff --git a/tests/ImageSharp.Tests/Colorspaces/Icc/Calculators/MatrixCalculatorTests.cs b/tests/ImageSharp.Tests/Colorspaces/Icc/Calculators/MatrixCalculatorTests.cs index 925b00ef4f..1770b2e9fb 100644 --- a/tests/ImageSharp.Tests/Colorspaces/Icc/Calculators/MatrixCalculatorTests.cs +++ b/tests/ImageSharp.Tests/Colorspaces/Icc/Calculators/MatrixCalculatorTests.cs @@ -4,7 +4,6 @@ using System.Numerics; using SixLabors.ImageSharp.ColorSpaces.Conversion.Icc; using SixLabors.ImageSharp.Tests.TestDataIcc.Conversion; -using Xunit; namespace SixLabors.ImageSharp.Tests.Colorspaces.Icc.Calculators { @@ -18,7 +17,7 @@ public class MatrixCalculatorTests [MemberData(nameof(IccConversionDataMatrix.MatrixConversionTestData), MemberType = typeof(IccConversionDataMatrix))] internal void MatrixCalculator_WithMatrix_ReturnsResult(Matrix4x4 matrix2D, Vector3 matrix1D, Vector4 input, Vector4 expected) { - var calculator = new MatrixCalculator(matrix2D, matrix1D); + MatrixCalculator calculator = new(matrix2D, matrix1D); Vector4 result = calculator.Calculate(input); diff --git a/tests/ImageSharp.Tests/Colorspaces/Icc/Calculators/ParametricCurveCalculatorTests.cs b/tests/ImageSharp.Tests/Colorspaces/Icc/Calculators/ParametricCurveCalculatorTests.cs index 89d0e1da12..c2387613c9 100644 --- a/tests/ImageSharp.Tests/Colorspaces/Icc/Calculators/ParametricCurveCalculatorTests.cs +++ b/tests/ImageSharp.Tests/Colorspaces/Icc/Calculators/ParametricCurveCalculatorTests.cs @@ -4,7 +4,6 @@ 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 { @@ -18,7 +17,7 @@ public class ParametricCurveCalculatorTests [MemberData(nameof(IccConversionDataTrc.ParametricCurveConversionTestData), MemberType = typeof(IccConversionDataTrc))] internal void ParametricCurveCalculator_WithCurveEntry_ReturnsResult(IccParametricCurveTagDataEntry curve, bool inverted, float input, float expected) { - var calculator = new ParametricCurveCalculator(curve, inverted); + ParametricCurveCalculator calculator = new(curve, inverted); float result = calculator.Calculate(input); diff --git a/tests/ImageSharp.Tests/Colorspaces/Icc/Calculators/TrcCalculatorTests.cs b/tests/ImageSharp.Tests/Colorspaces/Icc/Calculators/TrcCalculatorTests.cs index c7b198b8dc..4029cc326d 100644 --- a/tests/ImageSharp.Tests/Colorspaces/Icc/Calculators/TrcCalculatorTests.cs +++ b/tests/ImageSharp.Tests/Colorspaces/Icc/Calculators/TrcCalculatorTests.cs @@ -5,7 +5,6 @@ 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 { @@ -19,7 +18,7 @@ public class TrcCalculatorTests [MemberData(nameof(IccConversionDataTrc.TrcArrayConversionTestData), MemberType = typeof(IccConversionDataTrc))] internal void TrcCalculator_WithCurvesArray_ReturnsResult(IccTagDataEntry[] entries, bool inverted, Vector4 input, Vector4 expected) { - var calculator = new TrcCalculator(entries, inverted); + TrcCalculator calculator = new(entries, inverted); Vector4 result = calculator.Calculate(input); diff --git a/tests/ImageSharp.Tests/TestDataIcc/Conversion/IccConversionDataTrc.cs b/tests/ImageSharp.Tests/TestDataIcc/Conversion/IccConversionDataTrc.cs index 1536b2f957..6cd99367a9 100644 --- a/tests/ImageSharp.Tests/TestDataIcc/Conversion/IccConversionDataTrc.cs +++ b/tests/ImageSharp.Tests/TestDataIcc/Conversion/IccConversionDataTrc.cs @@ -6,7 +6,7 @@ namespace SixLabors.ImageSharp.Tests.TestDataIcc.Conversion; -public class IccConversionDataTrc +public static class IccConversionDataTrc { internal static IccCurveTagDataEntry IdentityCurve = new(); internal static IccCurveTagDataEntry Gamma2Curve = new(2); @@ -18,7 +18,7 @@ public class IccConversionDataTrc internal static IccParametricCurveTagDataEntry ParamCurve4 = new(new IccParametricCurve(2.4f, 1 / 1.055f, 0.055f / 1.055f, 1 / 12.92f, 0.04045f)); internal static IccParametricCurveTagDataEntry ParamCurve5 = new(new IccParametricCurve(2.2f, 0.7f, 0.2f, 0.3f, 0.1f, 0.5f, 0.2f)); - public static object[][] TrcArrayConversionTestData = + public static object[][] TrcArrayConversionTestData { get; } = { new object[] { @@ -36,7 +36,7 @@ public class IccConversionDataTrc }, }; - public static object[][] CurveConversionTestData = + public static object[][] CurveConversionTestData { get; } = { new object[] { IdentityCurve, false, 2, 2 }, new object[] { Gamma2Curve, false, 2, 4 }, @@ -51,7 +51,7 @@ public class IccConversionDataTrc new object[] { LutCurve, true, 0.85, 0.75 }, }; - public static object[][] ParametricCurveConversionTestData = + public static object[][] ParametricCurveConversionTestData { get; } = { new object[] { ParamCurve1, false, 0.5f, 0.217637628f }, new object[] { ParamCurve2, false, 0.6f, 0.133208528f }, From fb8003c80d1a37e8f3a3128ac7771ac326371942 Mon Sep 17 00:00:00 2001 From: James Jackson-South Date: Thu, 15 Dec 2022 10:12:56 +1000 Subject: [PATCH 14/42] Remove double clamping --- .../Implementation/Icc/Calculators/ClutCalculator.cs | 2 -- .../Implementation/Icc/Calculators/LutEntryCalculator.cs | 3 +-- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/ClutCalculator.cs b/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/ClutCalculator.cs index 4b65f46a84..a1891d127c 100644 --- a/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/ClutCalculator.cs +++ b/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/ClutCalculator.cs @@ -29,8 +29,6 @@ public ClutCalculator(IccClut clut) public unsafe Vector4 Calculate(Vector4 value) { - value = Vector4.Clamp(value, Vector4.Zero, Vector4.One); - Vector4 result = default; this.Interpolate((float*)&value, this.inputCount, (float*)&result, this.outputCount); diff --git a/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/LutEntryCalculator.cs b/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/LutEntryCalculator.cs index 643090c9d8..a5645266fc 100644 --- a/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/LutEntryCalculator.cs +++ b/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/LutEntryCalculator.cs @@ -41,9 +41,8 @@ public Vector4 Calculate(Vector4 value) } [MethodImpl(MethodImplOptions.AggressiveInlining)] - private static unsafe Vector4 CalculateLut(LutCalculator[] lut, Vector4 value) + private static Vector4 CalculateLut(LutCalculator[] lut, Vector4 value) { - value = Vector4.Clamp(value, Vector4.Zero, Vector4.One); ref float f = ref Unsafe.As(ref value); for (int i = 0; i < lut.Length; i++) { From 9f0f9cb3548555bd384135a2ead122ad81fa330e Mon Sep 17 00:00:00 2001 From: James Jackson-South Date: Thu, 15 Dec 2022 10:38:36 +1000 Subject: [PATCH 15/42] Optimize matrix read/write --- .../ICC/DataReader/IccDataReader.Matrix.cs | 28 +++++++++++------ .../ICC/DataWriter/IccDataWriter.Matrix.cs | 31 +++++++++++++------ 2 files changed, 41 insertions(+), 18 deletions(-) diff --git a/src/ImageSharp/Metadata/Profiles/ICC/DataReader/IccDataReader.Matrix.cs b/src/ImageSharp/Metadata/Profiles/ICC/DataReader/IccDataReader.Matrix.cs index 61ecda4aab..ecc9bfbffb 100644 --- a/src/ImageSharp/Metadata/Profiles/ICC/DataReader/IccDataReader.Matrix.cs +++ b/src/ImageSharp/Metadata/Profiles/ICC/DataReader/IccDataReader.Matrix.cs @@ -17,16 +17,23 @@ internal sealed partial class IccDataReader /// The read matrix public float[,] ReadMatrix(int xCount, int yCount, bool isSingle) { - var matrix = new float[xCount, yCount]; - for (int y = 0; y < yCount; y++) + float[,] matrix = new float[xCount, yCount]; + + if (isSingle) { - for (int x = 0; x < xCount; x++) + for (int y = 0; y < yCount; y++) { - if (isSingle) + for (int x = 0; x < xCount; x++) { matrix[x, y] = this.ReadSingle(); } - else + } + } + else + { + for (int y = 0; y < yCount; y++) + { + for (int x = 0; x < xCount; x++) { matrix[x, y] = this.ReadFix16(); } @@ -44,14 +51,17 @@ internal sealed partial class IccDataReader /// The read matrix public float[] ReadMatrix(int yCount, bool isSingle) { - var matrix = new float[yCount]; - for (int i = 0; i < yCount; i++) + float[] matrix = new float[yCount]; + if (isSingle) { - if (isSingle) + for (int i = 0; i < yCount; i++) { matrix[i] = this.ReadSingle(); } - else + } + else + { + for (int i = 0; i < yCount; i++) { matrix[i] = this.ReadFix16(); } diff --git a/src/ImageSharp/Metadata/Profiles/ICC/DataWriter/IccDataWriter.Matrix.cs b/src/ImageSharp/Metadata/Profiles/ICC/DataWriter/IccDataWriter.Matrix.cs index 1e5f359e09..636cc90a57 100644 --- a/src/ImageSharp/Metadata/Profiles/ICC/DataWriter/IccDataWriter.Matrix.cs +++ b/src/ImageSharp/Metadata/Profiles/ICC/DataWriter/IccDataWriter.Matrix.cs @@ -1,4 +1,4 @@ -// Copyright (c) Six Labors. +// Copyright (c) Six Labors. // Licensed under the Six Labors Split License. using System.Numerics; @@ -61,15 +61,21 @@ public int WriteMatrix(Matrix4x4 value, bool isSingle) public int WriteMatrix(in DenseMatrix value, bool isSingle) { int count = 0; - for (int y = 0; y < value.Rows; y++) + if (isSingle) { - for (int x = 0; x < value.Columns; x++) + for (int y = 0; y < value.Rows; y++) { - if (isSingle) + for (int x = 0; x < value.Columns; x++) { count += this.WriteSingle(value[x, y]); } - else + } + } + else + { + for (int y = 0; y < value.Rows; y++) + { + for (int x = 0; x < value.Columns; x++) { count += this.WriteFix16(value[x, y]); } @@ -88,15 +94,22 @@ public int WriteMatrix(in DenseMatrix value, bool isSingle) public int WriteMatrix(float[,] value, bool isSingle) { int count = 0; - for (int y = 0; y < value.GetLength(1); y++) + + if (isSingle) { - for (int x = 0; x < value.GetLength(0); x++) + for (int y = 0; y < value.GetLength(1); y++) { - if (isSingle) + for (int x = 0; x < value.GetLength(0); x++) { count += this.WriteSingle(value[x, y]); } - else + } + } + else + { + for (int y = 0; y < value.GetLength(1); y++) + { + for (int x = 0; x < value.GetLength(0); x++) { count += this.WriteFix16(value[x, y]); } From ece11eb5c73cf57e2d9bcb9cf1de132abcbb0818 Mon Sep 17 00:00:00 2001 From: James Jackson-South Date: Sat, 17 Dec 2022 13:20:05 +1000 Subject: [PATCH 16/42] Create ColorProfileHandling.cs --- .../Formats/ColorProfileHandling.cs | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 src/ImageSharp/Formats/ColorProfileHandling.cs diff --git a/src/ImageSharp/Formats/ColorProfileHandling.cs b/src/ImageSharp/Formats/ColorProfileHandling.cs new file mode 100644 index 0000000000..de1a765a98 --- /dev/null +++ b/src/ImageSharp/Formats/ColorProfileHandling.cs @@ -0,0 +1,21 @@ +// Copyright (c) Six Labors. +// Licensed under the Six Labors Split License. + +namespace SixLabors.ImageSharp.Formats; + +/// +/// Provides enumeration of methods that control how ICC profiles are handled during decode. +/// +public enum ColorProfileHandling +{ + /// + /// Leaves any embedded ICC color profiles intact. + /// + Preserve, + + /// + /// Transforms the pixels of the image based on the conversion of any embedded ICC color profiles to sRGB. + /// The original profile is then removed. + /// + Convert +} From 9a21485f010147446033337017299715c3ff25b5 Mon Sep 17 00:00:00 2001 From: James Jackson-South Date: Sat, 17 Dec 2022 13:24:07 +1000 Subject: [PATCH 17/42] Nullable disable --- .../Conversion/Implementation/Icc/Calculators/CurveCalculator.cs | 1 + .../Conversion/Implementation/Icc/Calculators/LutABCalculator.cs | 1 + .../Implementation/Icc/Calculators/LutEntryCalculator.cs | 1 + .../Conversion/Implementation/Icc/IccConverterBase.Checks.cs | 1 + .../Conversion/Implementation/Icc/IccConverterbase.cs | 1 + 5 files changed, 5 insertions(+) diff --git a/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/CurveCalculator.cs b/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/CurveCalculator.cs index da40d3912c..cb73f464d1 100644 --- a/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/CurveCalculator.cs +++ b/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/CurveCalculator.cs @@ -1,5 +1,6 @@ // Copyright (c) Six Labors. // Licensed under the Six Labors Split License. +#nullable disable using SixLabors.ImageSharp.Metadata.Profiles.Icc; diff --git a/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/LutABCalculator.cs b/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/LutABCalculator.cs index 817566c850..bc1cb73476 100644 --- a/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/LutABCalculator.cs +++ b/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/LutABCalculator.cs @@ -1,5 +1,6 @@ // Copyright (c) Six Labors. // Licensed under the Six Labors Split License. +#nullable disable using System.Numerics; using SixLabors.ImageSharp.Metadata.Profiles.Icc; diff --git a/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/LutEntryCalculator.cs b/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/LutEntryCalculator.cs index a5645266fc..5d9d426fec 100644 --- a/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/LutEntryCalculator.cs +++ b/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/LutEntryCalculator.cs @@ -1,5 +1,6 @@ // Copyright (c) Six Labors. // Licensed under the Six Labors Split License. +#nullable disable using System.Numerics; using System.Runtime.CompilerServices; diff --git a/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/IccConverterBase.Checks.cs b/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/IccConverterBase.Checks.cs index 59ff612bd0..2b078e09fe 100644 --- a/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/IccConverterBase.Checks.cs +++ b/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/IccConverterBase.Checks.cs @@ -1,5 +1,6 @@ // Copyright (c) Six Labors. // Licensed under the Six Labors Split License. +#nullable disable using SixLabors.ImageSharp.Metadata.Profiles.Icc; diff --git a/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/IccConverterbase.cs b/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/IccConverterbase.cs index 79f04229e1..42babd8055 100644 --- a/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/IccConverterbase.cs +++ b/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/IccConverterbase.cs @@ -1,5 +1,6 @@ // Copyright (c) Six Labors. // Licensed under the Six Labors Split License. +#nullable disable using System.Numerics; using System.Runtime.CompilerServices; From 66554cba676aa93edaec909f0d5cdd0e8537dcec Mon Sep 17 00:00:00 2001 From: James Jackson-South Date: Wed, 4 Jan 2023 23:53:02 +1000 Subject: [PATCH 18/42] Add ability to convert ICC profile on decode --- .../Implementation/Icc/IccProfileConverter.cs | 34 ++++++++-- .../Icc/SrgbV4Profile.Generated.cs | 45 +++++++++++++ .../Formats/ColorProfileHandling.cs | 4 +- src/ImageSharp/Formats/DecoderOptions.cs | 5 ++ src/ImageSharp/Formats/ImageDecoder.cs | 65 +++++++++++++++---- .../Formats/SpecializedImageDecoder{T}.cs | 42 ++++++++---- .../Icc/IccProfileConverterTests.cs | 16 +++-- .../TestUtilities/ImagingTestCaseUtility.cs | 8 +-- .../TestUtilities/TestImageExtensions.cs | 4 +- 9 files changed, 178 insertions(+), 45 deletions(-) create mode 100644 src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/SrgbV4Profile.Generated.cs diff --git a/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/IccProfileConverter.cs b/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/IccProfileConverter.cs index 6325c5ce19..8676f4afb9 100644 --- a/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/IccProfileConverter.cs +++ b/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/IccProfileConverter.cs @@ -12,10 +12,19 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion.Implementation.Icc; /// -/// Allows the copnversion between ICC profiles. +/// Allows the conversion between ICC profiles. /// internal static class IccProfileConverter { + /// + /// Performs a conversion of the image pixels based on the input and output ICC profiles. + /// + /// The image to convert. + /// The input ICC profile. + /// The output ICC profile. + public static void Convert(Image image, IccProfile? inputIccProfile, IccProfile? outputIccProfile) + => image.AcceptVisitor(new IccProfileConverterVisitor(inputIccProfile, outputIccProfile)); + /// /// Performs a conversion of the image pixels based on the input and output ICC profiles. /// @@ -23,11 +32,10 @@ internal static class IccProfileConverter /// The image to convert. /// The input ICC profile. /// The output ICC profile. - public static void Convert(Image image, IccProfile inputIccProfile, IccProfile outputIccProfile) - where TPixel : unmanaged, IPixel + public static void Convert(Image image, IccProfile? inputIccProfile, IccProfile? outputIccProfile) + where TPixel : unmanaged, IPixel { - // TODO: Is this the correct property? - if (inputIccProfile.Header.Id.Equals(outputIccProfile.Header.Id)) + if (inputIccProfile is null || outputIccProfile is null) { return; } @@ -55,7 +63,21 @@ public static void Convert(Image image, IccProfile inputIccProfi } }); - // TODO: Do not preserve the profile if we are converting to sRGB. image.Metadata.IccProfile = outputIccProfile; } + + private readonly struct IccProfileConverterVisitor : IImageVisitor + { + private readonly IccProfile? inputIccProfile; + private readonly IccProfile? outputIccProfile; + + public IccProfileConverterVisitor(IccProfile? inputIccProfile, IccProfile? outputIccProfile) + { + this.inputIccProfile = inputIccProfile; + this.outputIccProfile = outputIccProfile; + } + + public void Visit(Image image) + where TPixel : unmanaged, IPixel => Convert(image, this.inputIccProfile, this.outputIccProfile); + } } diff --git a/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/SrgbV4Profile.Generated.cs b/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/SrgbV4Profile.Generated.cs new file mode 100644 index 0000000000..45c231aa67 --- /dev/null +++ b/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/SrgbV4Profile.Generated.cs @@ -0,0 +1,45 @@ +// Copyright (c) Six Labors. +// Licensed under the Six Labors Split License. + +// + +using SixLabors.ImageSharp.Metadata.Profiles.Icc; + +namespace SixLabors.ImageSharp.ColorSpaces.Conversion.Icc; + +internal static class SrgbV4Profile +{ + // Generated using the sRGB-v4.icc profile found at https://github.com/saucecontrol/Compact-ICC-Profiles + private static ReadOnlySpan Data => new byte[] + { + 0, 0, 1, 224, 108, 99, 109, 115, 4, 32, 0, 0, 109, 110, 116, 114, 82, 71, 66, 32, 88, 89, 90, 32, 7, 226, 0, 3, 0, + 20, 0, 9, 0, 14, 0, 29, 97, 99, 115, 112, 77, 83, 70, 84, 0, 0, 0, 0, 115, 97, 119, 115, 99, 116, 114, 108, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 246, 214, 0, 1, 0, 0, 0, 0, 211, 45, 104, 97, 110, 100, 163, 178, 171, + 223, 92, 167, 3, 18, 168, 85, 164, 236, 53, 122, 209, 243, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 100, 101, 115, 99, 0, 0, 0, 252, 0, 0, 0, 36, 99, + 112, 114, 116, 0, 0, 1, 32, 0, 0, 0, 34, 119, 116, 112, 116, 0, 0, 1, 68, 0, 0, 0, 20, 99, 104, 97, 100, 0, 0, + 1, 88, 0, 0, 0, 44, 114, 88, 89, 90, 0, 0, 1, 132, 0, 0, 0, 20, 103, 88, 89, 90, 0, 0, 1, 152, 0, 0, 0, + 20, 98, 88, 89, 90, 0, 0, 1, 172, 0, 0, 0, 20, 114, 84, 82, 67, 0, 0, 1, 192, 0, 0, 0, 32, 103, 84, 82, 67, + 0, 0, 1, 192, 0, 0, 0, 32, 98, 84, 82, 67, 0, 0, 1, 192, 0, 0, 0, 32, 109, 108, 117, 99, 0, 0, 0, 0, 0, + 0, 0, 1, 0, 0, 0, 12, 101, 110, 85, 83, 0, 0, 0, 8, 0, 0, 0, 28, 0, 115, 0, 82, 0, 71, 0, 66, 109, 108, + 117, 99, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 12, 101, 110, 85, 83, 0, 0, 0, 6, 0, 0, 0, 28, 0, 67, 0, + 67, 0, 48, 0, 33, 88, 89, 90, 32, 0, 0, 0, 0, 0, 0, 246, 214, 0, 1, 0, 0, 0, 0, 211, 45, 115, 102, 51, 50, + 0, 0, 0, 0, 0, 1, 12, 63, 0, 0, 5, 221, 255, 255, 243, 38, 0, 0, 7, 144, 0, 0, 253, 146, 255, 255, 251, 161, 255, + 255, 253, 162, 0, 0, 3, 220, 0, 0, 192, 113, 88, 89, 90, 32, 0, 0, 0, 0, 0, 0, 111, 160, 0, 0, 56, 242, 0, 0, + 3, 143, 88, 89, 90, 32, 0, 0, 0, 0, 0, 0, 98, 150, 0, 0, 183, 137, 0, 0, 24, 218, 88, 89, 90, 32, 0, 0, 0, + 0, 0, 0, 36, 160, 0, 0, 15, 133, 0, 0, 182, 196, 112, 97, 114, 97, 0, 0, 0, 0, 0, 3, 0, 0, 0, 2, 102, 105, + 0, 0, 242, 167, 0, 0, 13, 89, 0, 0, 19, 208, 0, 0, 10, 91, + }; + + private static readonly Lazy LazyIccProfile = new(() => GetIccProfile()); + + public static IccProfile GetProfile() => LazyIccProfile.Value; + + private static IccProfile GetIccProfile() + { + byte[] buffer = new byte[Data.Length]; + Data.CopyTo(buffer); + return new IccProfile(buffer); + } +} + diff --git a/src/ImageSharp/Formats/ColorProfileHandling.cs b/src/ImageSharp/Formats/ColorProfileHandling.cs index de1a765a98..e6f4b0a6a0 100644 --- a/src/ImageSharp/Formats/ColorProfileHandling.cs +++ b/src/ImageSharp/Formats/ColorProfileHandling.cs @@ -14,8 +14,8 @@ public enum ColorProfileHandling Preserve, /// - /// Transforms the pixels of the image based on the conversion of any embedded ICC color profiles to sRGB. - /// The original profile is then removed. + /// Transforms the pixels of the image based on the conversion of any embedded ICC color profiles to sRGB V4 profile. + /// The original profile is then replaced. /// Convert } diff --git a/src/ImageSharp/Formats/DecoderOptions.cs b/src/ImageSharp/Formats/DecoderOptions.cs index 989fc49fc2..80c4f29336 100644 --- a/src/ImageSharp/Formats/DecoderOptions.cs +++ b/src/ImageSharp/Formats/DecoderOptions.cs @@ -44,4 +44,9 @@ public sealed class DecoderOptions /// Gets the maximum number of image frames to decode, inclusive. /// public uint MaxFrames { get => this.maxFrames; init => this.maxFrames = Math.Clamp(value, 1, int.MaxValue); } + + /// + /// Gets a value that controls how ICC profiles are handled during decode. + /// + public ColorProfileHandling ColorProfileHandling { get; init; } } diff --git a/src/ImageSharp/Formats/ImageDecoder.cs b/src/ImageSharp/Formats/ImageDecoder.cs index 591f85df2b..30a87acd65 100644 --- a/src/ImageSharp/Formats/ImageDecoder.cs +++ b/src/ImageSharp/Formats/ImageDecoder.cs @@ -2,6 +2,8 @@ // Licensed under the Six Labors Split License. #nullable disable +using SixLabors.ImageSharp.ColorSpaces.Conversion.Icc; +using SixLabors.ImageSharp.ColorSpaces.Conversion.Implementation.Icc; using SixLabors.ImageSharp.IO; using SixLabors.ImageSharp.PixelFormats; using SixLabors.ImageSharp.Processing; @@ -17,34 +19,54 @@ public abstract class ImageDecoder : IImageDecoder /// public Image Decode(DecoderOptions options, Stream stream) where TPixel : unmanaged, IPixel - => WithSeekableStream( - options, - stream, - s => this.Decode(options, s, default)); + { + Image image = WithSeekableStream( + options, + stream, + s => this.Decode(options, s, default)); + + TransformColorProfile(options, image); + return image; + } /// public Image Decode(DecoderOptions options, Stream stream) - => WithSeekableStream( - options, - stream, - s => this.Decode(options, s, default)); + { + Image image = WithSeekableStream( + options, + stream, + s => this.Decode(options, s, default)); + + TransformColorProfile(options, image); + return image; + } /// - public Task> DecodeAsync(DecoderOptions options, Stream stream, CancellationToken cancellationToken = default) + public async Task> DecodeAsync(DecoderOptions options, Stream stream, CancellationToken cancellationToken = default) where TPixel : unmanaged, IPixel - => WithSeekableMemoryStreamAsync( + { + Image image = await WithSeekableMemoryStreamAsync( options, stream, (s, ct) => this.Decode(options, s, ct), - cancellationToken); + cancellationToken).ConfigureAwait(false); + + TransformColorProfile(options, image); + return image; + } /// - public Task DecodeAsync(DecoderOptions options, Stream stream, CancellationToken cancellationToken = default) - => WithSeekableMemoryStreamAsync( + public async Task DecodeAsync(DecoderOptions options, Stream stream, CancellationToken cancellationToken = default) + { + Image image = await WithSeekableMemoryStreamAsync( options, stream, (s, ct) => this.Decode(options, s, ct), - cancellationToken); + cancellationToken).ConfigureAwait(false); + + TransformColorProfile(options, image); + return image; + } /// public IImageInfo Identify(DecoderOptions options, Stream stream) @@ -123,6 +145,21 @@ protected static void ScaleToTargetSize(DecoderOptions options, Image image) } } + /// + /// Converts the decoded image color profile if present to a V4 sRGB profile. + /// + /// The decoder options. + /// The image. + protected static void TransformColorProfile(DecoderOptions options, Image image) + { + if (options.ColorProfileHandling == ColorProfileHandling.Preserve) + { + return; + } + + IccProfileConverter.Convert(image, image.Metadata?.IccProfile, SrgbV4Profile.GetProfile()); + } + /// /// Determines whether the decoded image should be resized. /// diff --git a/src/ImageSharp/Formats/SpecializedImageDecoder{T}.cs b/src/ImageSharp/Formats/SpecializedImageDecoder{T}.cs index fa6461464b..ee602e7e26 100644 --- a/src/ImageSharp/Formats/SpecializedImageDecoder{T}.cs +++ b/src/ImageSharp/Formats/SpecializedImageDecoder{T}.cs @@ -17,34 +17,54 @@ public abstract class SpecializedImageDecoder : ImageDecoder, ISpecializedIma /// public Image Decode(T options, Stream stream) where TPixel : unmanaged, IPixel - => WithSeekableStream( - options.GeneralOptions, - stream, - s => this.Decode(options, s, default)); + { + Image image = WithSeekableStream( + options.GeneralOptions, + stream, + s => this.Decode(options, s, default)); + + TransformColorProfile(options.GeneralOptions, image); + return image; + } /// public Image Decode(T options, Stream stream) - => WithSeekableStream( + { + Image image = WithSeekableStream( options.GeneralOptions, stream, s => this.Decode(options, s, default)); + TransformColorProfile(options.GeneralOptions, image); + return image; + } + /// - public Task> DecodeAsync(T options, Stream stream, CancellationToken cancellationToken = default) + public async Task> DecodeAsync(T options, Stream stream, CancellationToken cancellationToken = default) where TPixel : unmanaged, IPixel - => WithSeekableMemoryStreamAsync( + { + Image image = await WithSeekableMemoryStreamAsync( options.GeneralOptions, stream, (s, ct) => this.Decode(options, s, ct), - cancellationToken); + cancellationToken).ConfigureAwait(false); + + TransformColorProfile(options.GeneralOptions, image); + return image; + } /// - public Task DecodeAsync(T options, Stream stream, CancellationToken cancellationToken = default) - => WithSeekableMemoryStreamAsync( + public async Task DecodeAsync(T options, Stream stream, CancellationToken cancellationToken = default) + { + Image image = await WithSeekableMemoryStreamAsync( options.GeneralOptions, stream, (s, ct) => this.Decode(options, s, ct), - cancellationToken); + cancellationToken).ConfigureAwait(false); + + TransformColorProfile(options.GeneralOptions, image); + return image; + } /// /// Decodes the image from the specified stream to an of a specific pixel type. diff --git a/tests/ImageSharp.Tests/Colorspaces/Icc/IccProfileConverterTests.cs b/tests/ImageSharp.Tests/Colorspaces/Icc/IccProfileConverterTests.cs index 67aa347b2f..964b2b41e5 100644 --- a/tests/ImageSharp.Tests/Colorspaces/Icc/IccProfileConverterTests.cs +++ b/tests/ImageSharp.Tests/Colorspaces/Icc/IccProfileConverterTests.cs @@ -1,6 +1,7 @@ // Copyright (c) Six Labors. // Licensed under the Six Labors Split License. +using SixLabors.ImageSharp.ColorSpaces.Conversion.Icc; using SixLabors.ImageSharp.ColorSpaces.Conversion.Implementation.Icc; using SixLabors.ImageSharp.Formats.Png; using SixLabors.ImageSharp.Metadata.Profiles.Icc; @@ -29,7 +30,7 @@ public void CanRoundTripProfile(TestImageProvider provider) IccProfileConverter.Convert(image, profile, profile); - image.DebugSave(provider, Encoder); + image.DebugSave(provider, extension: "png", appendPixelTypeToFileName: false, appendSourceFileOrDescription: true, encoder: Encoder); TPixel actual = image[0, 0]; @@ -38,19 +39,22 @@ public void CanRoundTripProfile(TestImageProvider provider) [Theory] [WithFile(TestImages.Jpeg.ICC.AdobeRgb, PixelTypes.Rgb24)] - public void CanConvertToWide(TestImageProvider provider) + [WithFile(TestImages.Jpeg.ICC.AppleRGB, PixelTypes.Rgb24)] + [WithFile(TestImages.Jpeg.ICC.ColorMatch, PixelTypes.Rgb24)] + [WithFile(TestImages.Jpeg.ICC.WideRGB, PixelTypes.Rgb24)] + [WithFile(TestImages.Jpeg.ICC.SRgb, PixelTypes.Rgb24)] + [WithFile(TestImages.Jpeg.ICC.ProPhoto, PixelTypes.Rgb24)] + public void CanConvertToSRGB(TestImageProvider provider) where TPixel : unmanaged, IPixel { using Image image = provider.GetImage(); IccProfile profile = image.Metadata.IccProfile; - string file = Path.Combine(TestEnvironment.InputImagesDirectoryFullPath, TestImages.Jpeg.ICC.SRgb); - IImageInfo i = Image.Identify(file); - IccProfile sRGBProfile = i.Metadata.IccProfile; + IccProfile sRGBProfile = SrgbV4Profile.GetProfile(); IccProfileConverter.Convert(image, profile, sRGBProfile); // TODO: Compare. - image.DebugSave(provider, Encoder); + image.DebugSave(provider, extension: "png", appendPixelTypeToFileName: false, appendSourceFileOrDescription: true, encoder: Encoder); } } diff --git a/tests/ImageSharp.Tests/TestUtilities/ImagingTestCaseUtility.cs b/tests/ImageSharp.Tests/TestUtilities/ImagingTestCaseUtility.cs index 460ecac85a..b3927de41f 100644 --- a/tests/ImageSharp.Tests/TestUtilities/ImagingTestCaseUtility.cs +++ b/tests/ImageSharp.Tests/TestUtilities/ImagingTestCaseUtility.cs @@ -49,8 +49,8 @@ private string GetTestOutputFileNameImpl( } string fn = appendSourceFileOrDescription - ? Path.GetFileNameWithoutExtension(this.SourceFileOrDescription) - : string.Empty; + ? Path.GetFileNameWithoutExtension(this.SourceFileOrDescription) + : string.Empty; if (string.IsNullOrWhiteSpace(extension)) { @@ -62,7 +62,7 @@ private string GetTestOutputFileNameImpl( extension = ".bmp"; } - extension = extension.ToLower(); + extension = extension.ToLowerInvariant(); if (extension[0] != '.') { @@ -86,7 +86,7 @@ private string GetTestOutputFileNameImpl( } } - details = details ?? string.Empty; + details ??= string.Empty; if (details != string.Empty) { details = '_' + details; diff --git a/tests/ImageSharp.Tests/TestUtilities/TestImageExtensions.cs b/tests/ImageSharp.Tests/TestUtilities/TestImageExtensions.cs index 31c9f541ea..30e76831dc 100644 --- a/tests/ImageSharp.Tests/TestUtilities/TestImageExtensions.cs +++ b/tests/ImageSharp.Tests/TestUtilities/TestImageExtensions.cs @@ -67,10 +67,10 @@ public static Image DebugSave( provider.Utility.SaveTestOutputFile( image, extension, + encoder: encoder, testOutputDetails: testOutputDetails, appendPixelTypeToFileName: appendPixelTypeToFileName, - appendSourceFileOrDescription: appendSourceFileOrDescription, - encoder: encoder); + appendSourceFileOrDescription: appendSourceFileOrDescription); return image; } From 8c580a735c7a8efa4b80005fe225ac0b9d239546 Mon Sep 17 00:00:00 2001 From: James Jackson-South Date: Thu, 5 Jan 2023 17:10:59 +1000 Subject: [PATCH 19/42] Handle nullability in decoder base --- .../Implementation/Icc/IccProfileConverter.cs | 15 +++++---------- src/ImageSharp/Formats/ImageDecoder.cs | 7 ++++++- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/IccProfileConverter.cs b/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/IccProfileConverter.cs index 8676f4afb9..51c34e4c79 100644 --- a/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/IccProfileConverter.cs +++ b/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/IccProfileConverter.cs @@ -22,7 +22,7 @@ internal static class IccProfileConverter /// The image to convert. /// The input ICC profile. /// The output ICC profile. - public static void Convert(Image image, IccProfile? inputIccProfile, IccProfile? outputIccProfile) + public static void Convert(Image image, IccProfile inputIccProfile, IccProfile outputIccProfile) => image.AcceptVisitor(new IccProfileConverterVisitor(inputIccProfile, outputIccProfile)); /// @@ -32,14 +32,9 @@ public static void Convert(Image image, IccProfile? inputIccProfile, IccProfile? /// The image to convert. /// The input ICC profile. /// The output ICC profile. - public static void Convert(Image image, IccProfile? inputIccProfile, IccProfile? outputIccProfile) + public static void Convert(Image image, IccProfile inputIccProfile, IccProfile outputIccProfile) where TPixel : unmanaged, IPixel { - if (inputIccProfile is null || outputIccProfile is null) - { - return; - } - IccDataToPcsConverter converterDataToPcs = new(inputIccProfile); IccPcsToDataConverter converterPcsToData = new(outputIccProfile); Configuration configuration = image.GetConfiguration(); @@ -68,10 +63,10 @@ public static void Convert(Image image, IccProfile? inputIccProf private readonly struct IccProfileConverterVisitor : IImageVisitor { - private readonly IccProfile? inputIccProfile; - private readonly IccProfile? outputIccProfile; + private readonly IccProfile inputIccProfile; + private readonly IccProfile outputIccProfile; - public IccProfileConverterVisitor(IccProfile? inputIccProfile, IccProfile? outputIccProfile) + public IccProfileConverterVisitor(IccProfile inputIccProfile, IccProfile outputIccProfile) { this.inputIccProfile = inputIccProfile; this.outputIccProfile = outputIccProfile; diff --git a/src/ImageSharp/Formats/ImageDecoder.cs b/src/ImageSharp/Formats/ImageDecoder.cs index 30a87acd65..92eef0e9ac 100644 --- a/src/ImageSharp/Formats/ImageDecoder.cs +++ b/src/ImageSharp/Formats/ImageDecoder.cs @@ -5,6 +5,7 @@ using SixLabors.ImageSharp.ColorSpaces.Conversion.Icc; using SixLabors.ImageSharp.ColorSpaces.Conversion.Implementation.Icc; using SixLabors.ImageSharp.IO; +using SixLabors.ImageSharp.Metadata.Profiles.Icc; using SixLabors.ImageSharp.PixelFormats; using SixLabors.ImageSharp.Processing; @@ -157,7 +158,11 @@ protected static void TransformColorProfile(DecoderOptions options, Image image) return; } - IccProfileConverter.Convert(image, image.Metadata?.IccProfile, SrgbV4Profile.GetProfile()); + IccProfile profile = image.Metadata?.IccProfile; + if (profile is not null) + { + IccProfileConverter.Convert(image, profile, SrgbV4Profile.GetProfile()); + } } /// From a81dac9adc355dc67cd840032e3a1ca42a4f4f6f Mon Sep 17 00:00:00 2001 From: James Jackson-South Date: Mon, 9 Jan 2023 21:43:03 +1000 Subject: [PATCH 20/42] Add reference files. --- .../Colorspaces/Icc/IccProfileConverterTests.cs | 5 ++++- .../CanConvertToSRGB_Momiji-AdobeRGB-yes.png | 3 +++ .../CanConvertToSRGB_Momiji-AppleRGB-yes.png | 3 +++ .../CanConvertToSRGB_Momiji-ColorMatch-yes.png | 3 +++ .../CanConvertToSRGB_Momiji-ProPhoto-yes.png | 3 +++ .../CanConvertToSRGB_Momiji-WideRGB-yes.png | 3 +++ .../CanConvertToSRGB_Momiji-sRGB-yes.png | 3 +++ 7 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 tests/Images/External/ReferenceOutput/IccProfileConverterTests/CanConvertToSRGB_Momiji-AdobeRGB-yes.png create mode 100644 tests/Images/External/ReferenceOutput/IccProfileConverterTests/CanConvertToSRGB_Momiji-AppleRGB-yes.png create mode 100644 tests/Images/External/ReferenceOutput/IccProfileConverterTests/CanConvertToSRGB_Momiji-ColorMatch-yes.png create mode 100644 tests/Images/External/ReferenceOutput/IccProfileConverterTests/CanConvertToSRGB_Momiji-ProPhoto-yes.png create mode 100644 tests/Images/External/ReferenceOutput/IccProfileConverterTests/CanConvertToSRGB_Momiji-WideRGB-yes.png create mode 100644 tests/Images/External/ReferenceOutput/IccProfileConverterTests/CanConvertToSRGB_Momiji-sRGB-yes.png diff --git a/tests/ImageSharp.Tests/Colorspaces/Icc/IccProfileConverterTests.cs b/tests/ImageSharp.Tests/Colorspaces/Icc/IccProfileConverterTests.cs index 964b2b41e5..cd1fe1d60b 100644 --- a/tests/ImageSharp.Tests/Colorspaces/Icc/IccProfileConverterTests.cs +++ b/tests/ImageSharp.Tests/Colorspaces/Icc/IccProfileConverterTests.cs @@ -6,6 +6,7 @@ using SixLabors.ImageSharp.Formats.Png; using SixLabors.ImageSharp.Metadata.Profiles.Icc; using SixLabors.ImageSharp.PixelFormats; +using SixLabors.ImageSharp.Tests.TestUtilities.ImageComparison; namespace SixLabors.ImageSharp.Tests.Colorspaces.Icc; public class IccProfileConverterTests @@ -54,7 +55,9 @@ public void CanConvertToSRGB(TestImageProvider provider) IccProfileConverter.Convert(image, profile, sRGBProfile); - // TODO: Compare. + Assert.Equal(image.Metadata.IccProfile, sRGBProfile); + image.DebugSave(provider, extension: "png", appendPixelTypeToFileName: false, appendSourceFileOrDescription: true, encoder: Encoder); + image.CompareToReferenceOutput(ImageComparer.Exact, provider, appendPixelTypeToFileName: false); } } diff --git a/tests/Images/External/ReferenceOutput/IccProfileConverterTests/CanConvertToSRGB_Momiji-AdobeRGB-yes.png b/tests/Images/External/ReferenceOutput/IccProfileConverterTests/CanConvertToSRGB_Momiji-AdobeRGB-yes.png new file mode 100644 index 0000000000..46d728c8d6 --- /dev/null +++ b/tests/Images/External/ReferenceOutput/IccProfileConverterTests/CanConvertToSRGB_Momiji-AdobeRGB-yes.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:650256637c7039c59e135bbdabd31bee1ad99c9d9ff014562300945d41b6ac3a +size 459515 diff --git a/tests/Images/External/ReferenceOutput/IccProfileConverterTests/CanConvertToSRGB_Momiji-AppleRGB-yes.png b/tests/Images/External/ReferenceOutput/IccProfileConverterTests/CanConvertToSRGB_Momiji-AppleRGB-yes.png new file mode 100644 index 0000000000..3c856c2c32 --- /dev/null +++ b/tests/Images/External/ReferenceOutput/IccProfileConverterTests/CanConvertToSRGB_Momiji-AppleRGB-yes.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:4e2d477de13a3767a364260b7b54b1f2a46c833e8df7aa1fded7990a3ac60563 +size 483943 diff --git a/tests/Images/External/ReferenceOutput/IccProfileConverterTests/CanConvertToSRGB_Momiji-ColorMatch-yes.png b/tests/Images/External/ReferenceOutput/IccProfileConverterTests/CanConvertToSRGB_Momiji-ColorMatch-yes.png new file mode 100644 index 0000000000..408f52e11e --- /dev/null +++ b/tests/Images/External/ReferenceOutput/IccProfileConverterTests/CanConvertToSRGB_Momiji-ColorMatch-yes.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:7ee8f5c7f658b11a380e6da2130dc8563da3255f3ff5d9fd9cc98ec87bb1852b +size 465348 diff --git a/tests/Images/External/ReferenceOutput/IccProfileConverterTests/CanConvertToSRGB_Momiji-ProPhoto-yes.png b/tests/Images/External/ReferenceOutput/IccProfileConverterTests/CanConvertToSRGB_Momiji-ProPhoto-yes.png new file mode 100644 index 0000000000..714340ad6f --- /dev/null +++ b/tests/Images/External/ReferenceOutput/IccProfileConverterTests/CanConvertToSRGB_Momiji-ProPhoto-yes.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:c702f52b08ac5be9eb65fd1f4e841fc46c897db45c709974954265b93d46b854 +size 478310 diff --git a/tests/Images/External/ReferenceOutput/IccProfileConverterTests/CanConvertToSRGB_Momiji-WideRGB-yes.png b/tests/Images/External/ReferenceOutput/IccProfileConverterTests/CanConvertToSRGB_Momiji-WideRGB-yes.png new file mode 100644 index 0000000000..c678bf52b3 --- /dev/null +++ b/tests/Images/External/ReferenceOutput/IccProfileConverterTests/CanConvertToSRGB_Momiji-WideRGB-yes.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:f06f61eca4187823cfb76255caaa9f9f9d43e9ea56da3cd0fac830f6198d9d8a +size 469400 diff --git a/tests/Images/External/ReferenceOutput/IccProfileConverterTests/CanConvertToSRGB_Momiji-sRGB-yes.png b/tests/Images/External/ReferenceOutput/IccProfileConverterTests/CanConvertToSRGB_Momiji-sRGB-yes.png new file mode 100644 index 0000000000..786937c2bb --- /dev/null +++ b/tests/Images/External/ReferenceOutput/IccProfileConverterTests/CanConvertToSRGB_Momiji-sRGB-yes.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:dc3657d9aa0e36beee1d24144ace5bdd1198c0249ac661f302ae38b7d478d374 +size 436479 From 902ed9926d16d1190bbc3d2e3308ac73336e7876 Mon Sep 17 00:00:00 2001 From: James Jackson-South Date: Mon, 9 Jan 2023 22:00:27 +1000 Subject: [PATCH 21/42] Add tolerance for Mac --- .../Colorspaces/Icc/IccProfileConverterTests.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/ImageSharp.Tests/Colorspaces/Icc/IccProfileConverterTests.cs b/tests/ImageSharp.Tests/Colorspaces/Icc/IccProfileConverterTests.cs index cd1fe1d60b..a2e8cbc2d6 100644 --- a/tests/ImageSharp.Tests/Colorspaces/Icc/IccProfileConverterTests.cs +++ b/tests/ImageSharp.Tests/Colorspaces/Icc/IccProfileConverterTests.cs @@ -58,6 +58,8 @@ public void CanConvertToSRGB(TestImageProvider provider) Assert.Equal(image.Metadata.IccProfile, sRGBProfile); image.DebugSave(provider, extension: "png", appendPixelTypeToFileName: false, appendSourceFileOrDescription: true, encoder: Encoder); - image.CompareToReferenceOutput(ImageComparer.Exact, provider, appendPixelTypeToFileName: false); + + // Mac reports a difference of 0.0000% + image.CompareToReferenceOutput(ImageComparer.Tolerant(0.0001F), provider, appendPixelTypeToFileName: false); } } From 6e3dc810df8c300eb8bf4aba2b2aad36995ca90d Mon Sep 17 00:00:00 2001 From: James Jackson-South Date: Mon, 16 Jan 2023 09:27:48 +1000 Subject: [PATCH 22/42] Update decoder bases following merge --- src/ImageSharp/Formats/ImageDecoder.cs | 2 +- src/ImageSharp/Formats/SpecializedImageDecoder{T}.cs | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/ImageSharp/Formats/ImageDecoder.cs b/src/ImageSharp/Formats/ImageDecoder.cs index 6aae33630d..af999e77d7 100644 --- a/src/ImageSharp/Formats/ImageDecoder.cs +++ b/src/ImageSharp/Formats/ImageDecoder.cs @@ -177,7 +177,7 @@ protected static void TransformColorProfile(DecoderOptions options, Image image) return; } - IccProfile profile = image.Metadata?.IccProfile; + IccProfile? profile = image.Metadata?.IccProfile; if (profile is not null) { IccProfileConverter.Convert(image, profile, SrgbV4Profile.GetProfile()); diff --git a/src/ImageSharp/Formats/SpecializedImageDecoder{T}.cs b/src/ImageSharp/Formats/SpecializedImageDecoder{T}.cs index 028620d755..2fb15aed29 100644 --- a/src/ImageSharp/Formats/SpecializedImageDecoder{T}.cs +++ b/src/ImageSharp/Formats/SpecializedImageDecoder{T}.cs @@ -25,7 +25,7 @@ public Image Decode(T options, Stream stream) TransformColorProfile(options.GeneralOptions, image); this.SetDecoderFormat(options.GeneralOptions.Configuration, image); - + return image; } @@ -39,7 +39,7 @@ public Image Decode(T options, Stream stream) TransformColorProfile(options.GeneralOptions, image); this.SetDecoderFormat(options.GeneralOptions.Configuration, image); - + return image; } @@ -55,7 +55,7 @@ public async Task> DecodeAsync(T options, Stream stream, C TransformColorProfile(options.GeneralOptions, image); this.SetDecoderFormat(options.GeneralOptions.Configuration, image); - + return image; } @@ -70,7 +70,7 @@ public async Task DecodeAsync(T options, Stream stream, CancellationToken TransformColorProfile(options.GeneralOptions, image); this.SetDecoderFormat(options.GeneralOptions.Configuration, image); - + return image; } From c3984aa3bfea9d1aa8a1490eb2470bfc6fde0386 Mon Sep 17 00:00:00 2001 From: James Jackson-South Date: Mon, 16 Jan 2023 22:58:11 +1000 Subject: [PATCH 23/42] Add failing tests --- .../Icc/Calculators/ClutCalculator.cs | 13 ++++++++----- .../Colorspaces/Icc/IccProfileConverterTests.cs | 2 ++ tests/ImageSharp.Tests/TestImages.cs | 1 + tests/Images/Input/Jpg/icc-profiles/issue-129.jpg | 3 +++ 4 files changed, 14 insertions(+), 5 deletions(-) create mode 100644 tests/Images/Input/Jpg/icc-profiles/issue-129.jpg diff --git a/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/ClutCalculator.cs b/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/ClutCalculator.cs index a1891d127c..e3742bcc3c 100644 --- a/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/ClutCalculator.cs +++ b/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/ClutCalculator.cs @@ -14,6 +14,7 @@ internal class ClutCalculator : IVector4Calculator private readonly byte[] gridPointCount; private readonly int[] indexFactor; private readonly int nodeCount; + private readonly float[][] nodes; public ClutCalculator(IccClut clut) { @@ -25,6 +26,7 @@ public ClutCalculator(IccClut clut) this.gridPointCount = clut.GridPointCount; this.indexFactor = CalculateIndexFactor(clut.InputChannelCount, clut.GridPointCount); this.nodeCount = (int)Math.Pow(2, clut.InputChannelCount); + this.nodes = new float[this.nodeCount][]; } public unsafe Vector4 Calculate(Vector4 value) @@ -50,8 +52,7 @@ private static int[] CalculateIndexFactor(int inputCount, byte[] gridPointCount) private unsafe void Interpolate(float* values, int valueLength, float* result, int resultLength) { - float[][] nodes = new float[this.nodeCount][]; - for (int i = 0; i < nodes.Length; i++) + for (int i = 0; i < this.nodes.Length; i++) { int index = 0; for (int j = 0; j < valueLength; j++) @@ -61,7 +62,9 @@ private unsafe void Interpolate(float* values, int valueLength, float* result, i index += (int)((this.indexFactor[j] * (position * fraction)) + 0.5f); } - nodes[i] = this.lut[index]; + // TODO: The CMYK profile in our tests causes an out of range exception + // against 'lut'. Clamping the index leads to incorrect results. + this.nodes[i] = this.lut[index]; } Span factors = stackalloc float[this.nodeCount]; @@ -92,9 +95,9 @@ private unsafe void Interpolate(float* values, int valueLength, float* result, i for (int i = 0; i < resultLength; i++) { - for (int j = 0; j < nodes.Length; j++) + for (int j = 0; j < this.nodes.Length; j++) { - result[i] += nodes[j][i] * factors[j]; + result[i] += this.nodes[j][i] * factors[j]; } } } diff --git a/tests/ImageSharp.Tests/Colorspaces/Icc/IccProfileConverterTests.cs b/tests/ImageSharp.Tests/Colorspaces/Icc/IccProfileConverterTests.cs index a2e8cbc2d6..2153f14201 100644 --- a/tests/ImageSharp.Tests/Colorspaces/Icc/IccProfileConverterTests.cs +++ b/tests/ImageSharp.Tests/Colorspaces/Icc/IccProfileConverterTests.cs @@ -20,6 +20,7 @@ public class IccProfileConverterTests [WithFile(TestImages.Jpeg.ICC.WideRGB, PixelTypes.Rgb24)] [WithFile(TestImages.Jpeg.ICC.SRgb, PixelTypes.Rgb24)] [WithFile(TestImages.Jpeg.ICC.ProPhoto, PixelTypes.Rgb24)] + [WithFile(TestImages.Jpeg.ICC.CMYK, PixelTypes.Rgb24)] public void CanRoundTripProfile(TestImageProvider provider) where TPixel : unmanaged, IPixel { @@ -45,6 +46,7 @@ public void CanRoundTripProfile(TestImageProvider provider) [WithFile(TestImages.Jpeg.ICC.WideRGB, PixelTypes.Rgb24)] [WithFile(TestImages.Jpeg.ICC.SRgb, PixelTypes.Rgb24)] [WithFile(TestImages.Jpeg.ICC.ProPhoto, PixelTypes.Rgb24)] + [WithFile(TestImages.Jpeg.ICC.CMYK, PixelTypes.Rgb24)] public void CanConvertToSRGB(TestImageProvider provider) where TPixel : unmanaged, IPixel { diff --git a/tests/ImageSharp.Tests/TestImages.cs b/tests/ImageSharp.Tests/TestImages.cs index f114e862ac..0129c5850b 100644 --- a/tests/ImageSharp.Tests/TestImages.cs +++ b/tests/ImageSharp.Tests/TestImages.cs @@ -176,6 +176,7 @@ public static class ICC public const string ProPhoto = "Jpg/icc-profiles/Momiji-ProPhoto-yes.jpg"; public const string WideRGB = "Jpg/icc-profiles/Momiji-WideRGB-yes.jpg"; public const string AppleRGB = "Jpg/icc-profiles/Momiji-AppleRGB-yes.jpg"; + public const string CMYK = "Jpg/icc-profiles/issue-129.jpg"; } public static class Progressive diff --git a/tests/Images/Input/Jpg/icc-profiles/issue-129.jpg b/tests/Images/Input/Jpg/icc-profiles/issue-129.jpg new file mode 100644 index 0000000000..98949f43f1 --- /dev/null +++ b/tests/Images/Input/Jpg/icc-profiles/issue-129.jpg @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:e1728dd548d862ef3f960c82528716e0ad1b8eb0119a5eed4dfde51026d7bb74 +size 2903429 From 0fff06d3c4f0acb61e77bc1aba23c1895541504d Mon Sep 17 00:00:00 2001 From: Brian Popow Date: Sun, 22 Jan 2023 12:40:43 +0100 Subject: [PATCH 24/42] Port 1d, 2d, 3d, 4d and nd interpolation from reference implementation --- .../Icc/Calculators/ClutCalculator.cs | 476 ++++++++++++++++-- 1 file changed, 439 insertions(+), 37 deletions(-) diff --git a/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/ClutCalculator.cs b/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/ClutCalculator.cs index e3742bcc3c..dc857bcd01 100644 --- a/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/ClutCalculator.cs +++ b/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/ClutCalculator.cs @@ -6,99 +6,501 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion.Icc; +/// +/// Implements interpolation methods for color profile lookup tables. +/// Adapted from ICC Reference implementation: +/// https://github.com/InternationalColorConsortium/DemoIccMAX/blob/79ecb74135ad47bac7d42692905a079839b7e105/IccProfLib/IccTagLut.cpp +/// internal class ClutCalculator : IVector4Calculator { private readonly int inputCount; private readonly int outputCount; private readonly float[][] lut; + private readonly float[] lutFlat; private readonly byte[] gridPointCount; private readonly int[] indexFactor; + private readonly int[] dimSize; private readonly int nodeCount; private readonly float[][] nodes; + float[] g; + uint[] ig; + float[] s; + float[] df; + private uint[] nPower; + private int n000; + private int n001; + private int n010; + private int n011; + private int n100; + private int n101; + private int n110; + private int n111; + private int n1000; public ClutCalculator(IccClut clut) { Guard.NotNull(clut, nameof(clut)); + Guard.MustBeGreaterThan(clut.InputChannelCount, 1, nameof(clut.InputChannelCount)); + Guard.MustBeGreaterThan(clut.OutputChannelCount, 1, nameof(clut.OutputChannelCount)); this.inputCount = clut.InputChannelCount; this.outputCount = clut.OutputChannelCount; + this.g = new float[this.inputCount]; + this.ig = new uint[this.inputCount]; + this.s = new float[this.inputCount]; + this.df = new float[this.nodeCount]; + this.nPower = new uint[16]; this.lut = clut.Values; this.gridPointCount = clut.GridPointCount; - this.indexFactor = CalculateIndexFactor(clut.InputChannelCount, clut.GridPointCount); this.nodeCount = (int)Math.Pow(2, clut.InputChannelCount); this.nodes = new float[this.nodeCount][]; + this.dimSize = new int[this.inputCount]; + this.dimSize[this.inputCount - 1] = this.outputCount; + for (int i = this.inputCount - 2; i >= 0; i--) + { + this.dimSize[i] = this.dimSize[i + 1] * this.gridPointCount[i + 1]; + } + + this.indexFactor = this.CalculateIndexFactor(); + + this.lutFlat = new float[this.lut.Length * 3]; + int offset = 0; + for (int i = 0; i < this.lut.Length; i++) + { + this.lutFlat[offset++] = this.lut[i][0]; + this.lutFlat[offset++] = this.lut[i][1]; + this.lutFlat[offset++] = this.lut[i][2]; + } } public unsafe Vector4 Calculate(Vector4 value) { Vector4 result = default; - this.Interpolate((float*)&value, this.inputCount, (float*)&result, this.outputCount); + switch (this.inputCount) + { + case 1: + this.Interpolate1d((float*)&value, (float*)&result); + break; + case 2: + this.Interpolate2d((float*)&value, (float*)&result); + break; + case 3: + this.Interpolate3d((float*)&value, (float*)&result); + break; + case 4: + this.Interpolate4d((float*)&value, (float*)&result); + break; + default: + this.InterpolateNd((float*)&value, (float*)&result); + break; + } return result; } - private static int[] CalculateIndexFactor(int inputCount, byte[] gridPointCount) + private int[] CalculateIndexFactor() { - int[] factors = new int[inputCount]; - int gpc = 1; - for (int j = inputCount - 1; j >= 0; j--) + int[] factors = new int[16]; + switch (this.inputCount) { - factors[j] = gpc * (gridPointCount[j] - 1); - gpc *= gridPointCount[j]; + case 1: + factors[0] = this.n000 = 0; + factors[1] = this.n001 = this.dimSize[0]; + break; + case 2: + factors[0] = this.n000 = 0; + factors[1] = this.n001 = this.dimSize[0]; + factors[2] = this.n010 = this.dimSize[1]; + factors[3] = this.n011 = this.n001 + this.n010; + break; + case 3: + factors[0] = this.n000 = 0; + factors[1] = this.n001 = this.dimSize[0]; + factors[2] = this.n010 = this.dimSize[1]; + factors[3] = this.n011 = this.n001 + this.n010; + factors[4] = this.n100 = this.dimSize[2]; + factors[5] = this.n101 = this.n100 + this.n001; + factors[6] = this.n110 = this.n100 + this.n010; + factors[7] = this.n111 = this.n110 + this.n001; + break; + case 4: + factors[0] = 0; + factors[1] = this.n001 = this.dimSize[0]; + factors[2] = this.n010 = this.dimSize[1]; + factors[3] = factors[2] + factors[1]; + factors[4] = this.n100 = this.dimSize[2]; + factors[5] = factors[4] + factors[1]; + factors[6] = factors[4] + factors[2]; + factors[7] = factors[4] + factors[3]; + factors[8] = this.n1000 = this.dimSize[3]; + factors[9] = factors[8] + factors[1]; + factors[10] = factors[8] + factors[2]; + factors[11] = factors[8] + factors[3]; + factors[12] = factors[8] + factors[4]; + factors[13] = factors[8] + factors[5]; + factors[14] = factors[8] + factors[6]; + factors[15] = factors[8] + factors[7]; + break; + default: + // Initialize ND interpolation variables. + factors[0] = 0; + int count; + for (count = 0; count < this.inputCount; count++) + { + this.nPower[count] = (uint)(1 << (this.inputCount - 1 - count)); + } + + uint[] nPower = { 0, 1 }; + count = 0; + int nFlag = 1; + for (uint j = 1; j < this.nodeCount; j++) + { + if (j == nPower[1]) + { + factors[j] = this.dimSize[count]; + nPower[0] = (uint)(1 << count); + count++; + nPower[1] = (uint)(1 << count); + nFlag = 1; + } + else + { + factors[j] = factors[nPower[0]] + factors[nFlag]; + nFlag++; + } + } + + break; } return factors; } - private unsafe void Interpolate(float* values, int valueLength, float* result, int resultLength) + /// + /// One dimensional interpolation function. + /// + /// The input pixel values, which will be interpolated. + /// The interpolated output pixels. + private unsafe void Interpolate1d(float* srcPixel, float* destPixel) + { + byte mx = this.gridPointCount[0]; + + float x = UnitClip(srcPixel[0]) * mx; + + uint ix = (uint)x; + + float u = x - ix; + + if (ix == mx) + { + ix--; + u = 1.0f; + } + + float nu = (float)(1.0 - u); + + int i; + Span p = this.lutFlat.AsSpan((int)(ix * this.n001)); + + // Normalize grid units. + float dF0 = nu; + float dF1 = u; + + int offset = 0; + for (i = 0; i < this.outputCount; i++) + { + float pv = (p[offset + this.n000] * dF0) + (p[offset + this.n001] * dF1); + + destPixel[i] = pv; + offset++; + } + } + + /// + /// Two dimensional interpolation function. + /// + /// The input pixel values, which will be interpolated. + /// The interpolated output pixels. + private unsafe void Interpolate2d(float* srcPixel, float* destPixel) + { + byte mx = this.gridPointCount[0]; + byte my = this.gridPointCount[1]; + + float x = UnitClip(srcPixel[0]) * mx; + float y = UnitClip(srcPixel[1]) * my; + + uint ix = (uint)x; + uint iy = (uint)y; + + float u = x - ix; + float t = y - iy; + + if (ix == mx) + { + ix--; + u = 1.0f; + } + if (iy == my) + { + iy--; + t = 1.0f; + } + + float nt = (float)(1.0 - t); + float nu = (float)(1.0 - u); + + int i; + Span p = this.lutFlat.AsSpan((int)((ix * this.n001) + (iy * this.n010))); + + // Normalize grid units. + float dF0 = nt * nu; + float dF1 = nt * u; + float dF2 = t * nu; + float dF3 = t * u; + + int offset = 0; + for (i = 0; i < this.outputCount; i++) + { + float pv = (p[offset + this.n000] * dF0) + (p[offset + this.n001] * dF1) + (p[ offset + this.n010] * dF2) + (p[offset + this.n011] * dF3); + + destPixel[i] = pv; + offset++; + } + } + + /// + /// Three dimensional interpolation function. + /// + /// The input pixel values, which will be interpolated. + /// The interpolated output pixels. + private unsafe void Interpolate3d(float* srcPixel, float* destPixel) { - for (int i = 0; i < this.nodes.Length; i++) + byte mx = this.gridPointCount[0]; + byte my = this.gridPointCount[1]; + byte mz = this.gridPointCount[2]; + + float x = UnitClip(srcPixel[0]) * mx; + float y = UnitClip(srcPixel[1]) * my; + float z = UnitClip(srcPixel[2]) * mz; + + uint ix = (uint)x; + uint iy = (uint)y; + uint iz = (uint)z; + + float u = x - ix; + float t = y - iy; + float s = z - iz; + + if (ix == mx) { - int index = 0; - for (int j = 0; j < valueLength; j++) + ix--; + u = 1.0f; + } + + if (iy == my) + { + iy--; + t = 1.0f; + } + + if (iz == mz) + { + iz--; + s = 1.0f; + } + + float ns = (float)(1.0 - s); + float nt = (float)(1.0 - t); + float nu = (float)(1.0 - u); + + Span p = this.lutFlat.AsSpan((int)((ix * this.n001) + (iy * this.n010) + (iz * this.n100))); + + // Normalize grid units + float dF0 = ns * nt * nu; + float dF1 = ns * nt * u; + float dF2 = ns * t * nu; + float dF3 = ns * t * u; + float dF4 = s * nt * nu; + float dF5 = s * nt * u; + float dF6 = s * t * nu; + float dF7 = s * t * u; + + int offset = 0; + for (int i = 0; i < this.outputCount; i++) + { + float pv = (p[offset + this.n000] * dF0) + (p[offset + this.n001] * dF1) + (p[offset + this.n010] * dF2) + (p[offset + this.n011] * dF3) + + (p[offset + this.n100] * dF4) + (p[offset + this.n101] * dF5) + (p[offset + this.n110] * dF6) + (p[offset + this.n111] * dF7); + + destPixel[i] = pv; + offset++; + } + } + + /// + /// Four dimensional interpolation function. + /// + /// The input pixel values, which will be interpolated. + /// The interpolated output pixels. + private unsafe void Interpolate4d(float* srcPixel, float* destPixel) + { + byte mw = this.gridPointCount[0]; + byte mx = this.gridPointCount[1]; + byte my = this.gridPointCount[2]; + byte mz = this.gridPointCount[3]; + + float w = UnitClip(srcPixel[0]) * mw; + float x = UnitClip(srcPixel[1]) * mx; + float y = UnitClip(srcPixel[2]) * my; + float z = UnitClip(srcPixel[3]) * mz; + + uint iw = (uint)w; + uint ix = (uint)x; + uint iy = (uint)y; + uint iz = (uint)z; + + float v = w - iw; + float u = x - ix; + float t = y - iy; + float s = z - iz; + + if (iw == mw) + { + iw--; + v = 1.0f; + } + + if (ix == mx) + { + ix--; + u = 1.0f; + } + + if (iy == my) + { + iy--; + t = 1.0f; + } + + if (iz == mz) + { + iz--; + s = 1.0f; + } + + float ns = (float)(1.0 - s); + float nt = (float)(1.0 - t); + float nu = (float)(1.0 - u); + float nv = (float)(1.0 - v); + + Span p = this.lutFlat.AsSpan((int)((iw * n001) + (ix * n010) + (iy * n100) + (iz * n1000))); + + // Normalize grid units. + float[] dF = new float[16]; + dF[0] = ns * nt * nu * nv; + dF[1] = ns * nt * nu * v; + dF[2] = ns * nt * u * nv; + dF[3] = ns * nt * u * v; + dF[4] = ns * t * nu * nv; + dF[5] = ns * t * nu * v; + dF[6] = ns * t * u * nv; + dF[7] = ns * t * u * v; + dF[8] = s * nt * nu * nv; + dF[9] = s * nt * nu * v; + dF[10] = s * nt * u * nv; + dF[11] = s * nt * u * v; + dF[12] = s * t * nu * nv; + dF[13] = s * t * nu * v; + dF[14] = s * t * u * nv; + dF[15] = s * t * u * v; + + int offset = 0; + for (int i = 0; i < this.outputCount; i++) + { + float pv = 0.0f; + for (int j = 0; j < 16; j++) { - float fraction = 1f / (this.gridPointCount[j] - 1); - int position = (int)(values[j] / fraction) + ((i >> j) & 1); - index += (int)((this.indexFactor[j] * (position * fraction)) + 0.5f); + pv += p[offset + this.indexFactor[j]] * dF[j]; } - // TODO: The CMYK profile in our tests causes an out of range exception - // against 'lut'. Clamping the index leads to incorrect results. - this.nodes[i] = this.lut[index]; + destPixel[i] = pv; + offset++; } + } - Span factors = stackalloc float[this.nodeCount]; - for (int i = 0; i < factors.Length; i++) + /// + /// Generic N-dimensional interpolation function. + /// + /// The input pixel values, which will be interpolated. + /// The interpolated output pixels. + private unsafe void InterpolateNd(float* srcPixel, float* destPixel) + { + int index = 0; + for (int i = 0; i < this.inputCount; i++) { - float factor = 1; - for (int j = 0; j < valueLength; j++) + this.g[i] = UnitClip(srcPixel[i]) * this.gridPointCount[i]; + this.ig[i] = (uint)this.g[i]; + this.s[this.inputCount - 1 - i] = this.g[i] - this.ig[i]; + if (this.ig[i] == this.gridPointCount[i]) { - float fraction = 1f / (this.gridPointCount[j] - 1); - int position = (int)(values[j] / fraction); + this.ig[i]--; + this.s[this.inputCount - 1 - i] = 1.0f; + } - float low = position * fraction; - float high = (position + 1) * fraction; - float percentage = (high - values[j]) / (high - low); + index += (int)this.ig[i] * this.dimSize[i]; + } - if (((i >> j) & 1) == 1) - { - factor *= percentage; - } - else + Span p = this.lutFlat.AsSpan(index); + float[] temp = new float[2]; + bool nFlag = false; + + for (int i = 0; i < this.nodeCount; i++) + { + this.df[i] = 1.0f; + } + + for (int i = 0; i < this.inputCount; i++) + { + temp[0] = 1.0f - this.s[i]; + temp[1] = this.s[i]; + index = (int)this.nPower[i]; + for (int j = 0; j < this.nodeCount; j++) + { + this.df[j] *= temp[nFlag ? 1 : 0]; + if ((j + 1) % index == 0) { - factor *= 1 - percentage; + nFlag = !nFlag; } } - factors[i] = factor; + nFlag = false; } - for (int i = 0; i < resultLength; i++) + int offset = 0; + for (int i = 0; i < this.outputCount; i++) { - for (int j = 0; j < this.nodes.Length; j++) + float pv = 0; + for (int j = 0; j < this.nodeCount; j++) { - result[i] += this.nodes[j][i] * factors[j]; + pv += p[offset + this.indexFactor[j]] * this.df[j]; } + + destPixel[i] = pv; + offset++; } } + + private static float UnitClip(float v) + { + if (v < 0) + { + return 0; + } + + if (v > 1.0) + { + return 1.0f; + } + + return v; + } } From f1c05eec693047c01db7ff0b7a79cc497a80af81 Mon Sep 17 00:00:00 2001 From: Brian Popow Date: Sun, 22 Jan 2023 12:42:44 +0100 Subject: [PATCH 25/42] Remove not used IccClut constructors --- .../Icc/Calculators/ClutCalculator.cs | 2 + .../Metadata/Profiles/ICC/Various/IccClut.cs | 83 +++---------------- 2 files changed, 13 insertions(+), 72 deletions(-) diff --git a/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/ClutCalculator.cs b/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/ClutCalculator.cs index dc857bcd01..fe47328985 100644 --- a/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/ClutCalculator.cs +++ b/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/ClutCalculator.cs @@ -63,6 +63,8 @@ public ClutCalculator(IccClut clut) this.indexFactor = this.CalculateIndexFactor(); + // TODO: Using here a flat array instead of a jagged array to match the reference implementation. + // Maybe consider changing the clut values from jagged to a flat in IccClut to avoid this allocation. this.lutFlat = new float[this.lut.Length * 3]; int offset = 0; for (int i = 0; i < this.lut.Length; i++) diff --git a/src/ImageSharp/Metadata/Profiles/ICC/Various/IccClut.cs b/src/ImageSharp/Metadata/Profiles/ICC/Various/IccClut.cs index 26a882810e..68b9beefea 100644 --- a/src/ImageSharp/Metadata/Profiles/ICC/Various/IccClut.cs +++ b/src/ImageSharp/Metadata/Profiles/ICC/Various/IccClut.cs @@ -1,19 +1,19 @@ -// Copyright (c) Six Labors. +// Copyright (c) Six Labors. // Licensed under the Six Labors Split License. namespace SixLabors.ImageSharp.Metadata.Profiles.Icc; /// -/// Color Lookup Table +/// Color Lookup Table. /// internal sealed class IccClut : IEquatable { /// /// Initializes a new instance of the class. /// - /// The CLUT values - /// The gridpoint count - /// The data type of this CLUT + /// The CLUT values. + /// The gridpoint count. + /// The data type of this CLUT. public IccClut(float[][] values, byte[] gridPointCount, IccClutDataType type) { Guard.NotNull(values, nameof(values)); @@ -28,85 +28,27 @@ public IccClut(float[][] values, byte[] gridPointCount, IccClutDataType type) } /// - /// Initializes a new instance of the class. - /// - /// The CLUT values - /// The gridpoint count - public IccClut(ushort[][] values, byte[] gridPointCount) - { - Guard.NotNull(values, nameof(values)); - Guard.NotNull(gridPointCount, nameof(gridPointCount)); - - const float Max = ushort.MaxValue; - - this.Values = new float[values.Length][]; - for (int i = 0; i < values.Length; i++) - { - this.Values[i] = new float[values[i].Length]; - for (int j = 0; j < values[i].Length; j++) - { - this.Values[i][j] = values[i][j] / Max; - } - } - - this.DataType = IccClutDataType.UInt16; - this.InputChannelCount = gridPointCount.Length; - this.OutputChannelCount = values[0].Length; - this.GridPointCount = gridPointCount; - this.CheckValues(); - } - - /// - /// Initializes a new instance of the class. - /// - /// The CLUT values - /// The gridpoint count - public IccClut(byte[][] values, byte[] gridPointCount) - { - Guard.NotNull(values, nameof(values)); - Guard.NotNull(gridPointCount, nameof(gridPointCount)); - - const float Max = byte.MaxValue; - - this.Values = new float[values.Length][]; - for (int i = 0; i < values.Length; i++) - { - this.Values[i] = new float[values[i].Length]; - for (int j = 0; j < values[i].Length; j++) - { - this.Values[i][j] = values[i][j] / Max; - } - } - - this.DataType = IccClutDataType.UInt8; - this.InputChannelCount = gridPointCount.Length; - this.OutputChannelCount = values[0].Length; - this.GridPointCount = gridPointCount; - this.CheckValues(); - } - - /// - /// Gets the values that make up this table + /// Gets the values that make up this table. /// public float[][] Values { get; } /// - /// Gets the CLUT data type (important when writing a profile) + /// Gets the CLUT data type (important when writing a profile). /// public IccClutDataType DataType { get; } /// - /// Gets the number of input channels + /// Gets the number of input channels. /// public int InputChannelCount { get; } /// - /// Gets the number of output channels + /// Gets the number of output channels. /// public int OutputChannelCount { get; } /// - /// Gets the number of grid points per input channel + /// Gets the number of grid points per input channel. /// public byte[] GridPointCount { get; } @@ -134,15 +76,12 @@ public bool Equals(IccClut? other) public override bool Equals(object? obj) => obj is IccClut other && this.Equals(other); /// - public override int GetHashCode() - { - return HashCode.Combine( + public override int GetHashCode() => HashCode.Combine( this.Values, this.DataType, this.InputChannelCount, this.OutputChannelCount, this.GridPointCount); - } private bool EqualsValuesArray(IccClut other) { From 3be31c38cd8651e06c5ae970dbfa5cad1a8d5828 Mon Sep 17 00:00:00 2001 From: James Jackson-South Date: Sun, 22 Jan 2023 22:13:53 +1000 Subject: [PATCH 26/42] Preserve alpha component --- .../Conversion/Implementation/Icc/Calculators/ClutCalculator.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/ClutCalculator.cs b/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/ClutCalculator.cs index fe47328985..3aff4248bc 100644 --- a/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/ClutCalculator.cs +++ b/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/ClutCalculator.cs @@ -77,7 +77,7 @@ public ClutCalculator(IccClut clut) public unsafe Vector4 Calculate(Vector4 value) { - Vector4 result = default; + Vector4 result = value; switch (this.inputCount) { case 1: From 6c2ee909f22a0012409fb0d24534e32a0bc42abf Mon Sep 17 00:00:00 2001 From: James Jackson-South Date: Sun, 22 Jan 2023 22:19:35 +1000 Subject: [PATCH 27/42] Fix CieLab docs --- src/ImageSharp/ColorSpaces/CieLab.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ImageSharp/ColorSpaces/CieLab.cs b/src/ImageSharp/ColorSpaces/CieLab.cs index 2346b395c0..5e03b910fb 100644 --- a/src/ImageSharp/ColorSpaces/CieLab.cs +++ b/src/ImageSharp/ColorSpaces/CieLab.cs @@ -79,13 +79,13 @@ public CieLab(Vector3 vector, CieXyz whitePoint) /// /// Gets the a color component. - /// A value usually ranging from -100 to 100. Negative is green, positive magenta. + /// A value usually ranging from −128 to 127. Negative is green, positive magenta. /// public readonly float A { get; } /// /// Gets the b color component. - /// A value usually ranging from -100 to 100. Negative is blue, positive is yellow + /// A value usually ranging from −128 to 127. Negative is blue, positive is yellow /// public readonly float B { get; } From 20e9b7fdf7a27aa738931e454664d19725ab2542 Mon Sep 17 00:00:00 2001 From: Brian Popow Date: Sun, 22 Jan 2023 16:14:28 +0100 Subject: [PATCH 28/42] Fix out of bounds error --- .../Icc/Calculators/ClutCalculator.cs | 31 ++++++++++++------- 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/ClutCalculator.cs b/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/ClutCalculator.cs index 3aff4248bc..9769db3bc3 100644 --- a/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/ClutCalculator.cs +++ b/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/ClutCalculator.cs @@ -18,6 +18,7 @@ internal class ClutCalculator : IVector4Calculator private readonly float[][] lut; private readonly float[] lutFlat; private readonly byte[] gridPointCount; + private readonly byte[] maxGridPoint; private readonly int[] indexFactor; private readonly int[] dimSize; private readonly int nodeCount; @@ -51,10 +52,16 @@ public ClutCalculator(IccClut clut) this.df = new float[this.nodeCount]; this.nPower = new uint[16]; this.lut = clut.Values; - this.gridPointCount = clut.GridPointCount; this.nodeCount = (int)Math.Pow(2, clut.InputChannelCount); this.nodes = new float[this.nodeCount][]; this.dimSize = new int[this.inputCount]; + this.gridPointCount = clut.GridPointCount; + this.maxGridPoint = new byte[this.inputCount]; + for (int i = 0; i < this.inputCount; i++) + { + this.maxGridPoint[i] = (byte)(this.gridPointCount[i] - 1); + } + this.dimSize[this.inputCount - 1] = this.outputCount; for (int i = this.inputCount - 2; i >= 0; i--) { @@ -185,7 +192,7 @@ private int[] CalculateIndexFactor() /// The interpolated output pixels. private unsafe void Interpolate1d(float* srcPixel, float* destPixel) { - byte mx = this.gridPointCount[0]; + byte mx = this.maxGridPoint[0]; float x = UnitClip(srcPixel[0]) * mx; @@ -225,8 +232,8 @@ private unsafe void Interpolate1d(float* srcPixel, float* destPixel) /// The interpolated output pixels. private unsafe void Interpolate2d(float* srcPixel, float* destPixel) { - byte mx = this.gridPointCount[0]; - byte my = this.gridPointCount[1]; + byte mx = this.maxGridPoint[0]; + byte my = this.maxGridPoint[1]; float x = UnitClip(srcPixel[0]) * mx; float y = UnitClip(srcPixel[1]) * my; @@ -277,9 +284,9 @@ private unsafe void Interpolate2d(float* srcPixel, float* destPixel) /// The interpolated output pixels. private unsafe void Interpolate3d(float* srcPixel, float* destPixel) { - byte mx = this.gridPointCount[0]; - byte my = this.gridPointCount[1]; - byte mz = this.gridPointCount[2]; + byte mx = this.maxGridPoint[0]; + byte my = this.maxGridPoint[1]; + byte mz = this.maxGridPoint[2]; float x = UnitClip(srcPixel[0]) * mx; float y = UnitClip(srcPixel[1]) * my; @@ -345,10 +352,10 @@ private unsafe void Interpolate3d(float* srcPixel, float* destPixel) /// The interpolated output pixels. private unsafe void Interpolate4d(float* srcPixel, float* destPixel) { - byte mw = this.gridPointCount[0]; - byte mx = this.gridPointCount[1]; - byte my = this.gridPointCount[2]; - byte mz = this.gridPointCount[3]; + byte mw = this.maxGridPoint[0]; + byte mx = this.maxGridPoint[1]; + byte my = this.maxGridPoint[2]; + byte mz = this.maxGridPoint[3]; float w = UnitClip(srcPixel[0]) * mw; float x = UnitClip(srcPixel[1]) * mx; @@ -394,7 +401,7 @@ private unsafe void Interpolate4d(float* srcPixel, float* destPixel) float nu = (float)(1.0 - u); float nv = (float)(1.0 - v); - Span p = this.lutFlat.AsSpan((int)((iw * n001) + (ix * n010) + (iy * n100) + (iz * n1000))); + Span p = this.lutFlat.AsSpan((int)((iw * this.n001) + (ix * this.n010) + (iy * this.n100) + (iz * this.n1000))); // Normalize grid units. float[] dF = new float[16]; From d6fbc01446b8eb2441e135ff917b612ef1756298 Mon Sep 17 00:00:00 2001 From: Brian Popow Date: Sun, 22 Jan 2023 19:19:50 +0100 Subject: [PATCH 29/42] Change clut values from jagged array to flat array --- .../Icc/Calculators/ClutCalculator.cs | 24 +-- .../Icc/IccConverterbase.Conversions.cs | 8 +- .../ICC/DataReader/IccDataReader.Lut.cs | 101 ++++------ .../DataReader/IccDataReader.TagDataEntry.cs | 126 ++++++------- .../ICC/DataWriter/IccDataWriter.Lut.cs | 59 +++--- .../DataWriter/IccDataWriter.TagDataEntry.cs | 2 +- .../Metadata/Profiles/ICC/Various/IccClut.cs | 14 +- .../Conversion/IccConversionDataClut.cs | 174 +++++++++--------- .../IccConversionDataMultiProcessElement.cs | 19 +- .../TestDataIcc/IccTestDataLut.cs | 63 ++++--- 10 files changed, 268 insertions(+), 322 deletions(-) diff --git a/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/ClutCalculator.cs b/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/ClutCalculator.cs index 9769db3bc3..4828deef70 100644 --- a/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/ClutCalculator.cs +++ b/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/ClutCalculator.cs @@ -15,8 +15,7 @@ internal class ClutCalculator : IVector4Calculator { private readonly int inputCount; private readonly int outputCount; - private readonly float[][] lut; - private readonly float[] lutFlat; + private readonly float[] lut; private readonly byte[] gridPointCount; private readonly byte[] maxGridPoint; private readonly int[] indexFactor; @@ -69,17 +68,6 @@ public ClutCalculator(IccClut clut) } this.indexFactor = this.CalculateIndexFactor(); - - // TODO: Using here a flat array instead of a jagged array to match the reference implementation. - // Maybe consider changing the clut values from jagged to a flat in IccClut to avoid this allocation. - this.lutFlat = new float[this.lut.Length * 3]; - int offset = 0; - for (int i = 0; i < this.lut.Length; i++) - { - this.lutFlat[offset++] = this.lut[i][0]; - this.lutFlat[offset++] = this.lut[i][1]; - this.lutFlat[offset++] = this.lut[i][2]; - } } public unsafe Vector4 Calculate(Vector4 value) @@ -209,7 +197,7 @@ private unsafe void Interpolate1d(float* srcPixel, float* destPixel) float nu = (float)(1.0 - u); int i; - Span p = this.lutFlat.AsSpan((int)(ix * this.n001)); + Span p = this.lut.AsSpan((int)(ix * this.n001)); // Normalize grid units. float dF0 = nu; @@ -259,7 +247,7 @@ private unsafe void Interpolate2d(float* srcPixel, float* destPixel) float nu = (float)(1.0 - u); int i; - Span p = this.lutFlat.AsSpan((int)((ix * this.n001) + (iy * this.n010))); + Span p = this.lut.AsSpan((int)((ix * this.n001) + (iy * this.n010))); // Normalize grid units. float dF0 = nt * nu; @@ -322,7 +310,7 @@ private unsafe void Interpolate3d(float* srcPixel, float* destPixel) float nt = (float)(1.0 - t); float nu = (float)(1.0 - u); - Span p = this.lutFlat.AsSpan((int)((ix * this.n001) + (iy * this.n010) + (iz * this.n100))); + Span p = this.lut.AsSpan((int)((ix * this.n001) + (iy * this.n010) + (iz * this.n100))); // Normalize grid units float dF0 = ns * nt * nu; @@ -401,7 +389,7 @@ private unsafe void Interpolate4d(float* srcPixel, float* destPixel) float nu = (float)(1.0 - u); float nv = (float)(1.0 - v); - Span p = this.lutFlat.AsSpan((int)((iw * this.n001) + (ix * this.n010) + (iy * this.n100) + (iz * this.n1000))); + Span p = this.lut.AsSpan((int)((iw * this.n001) + (ix * this.n010) + (iy * this.n100) + (iz * this.n1000))); // Normalize grid units. float[] dF = new float[16]; @@ -458,7 +446,7 @@ private unsafe void InterpolateNd(float* srcPixel, float* destPixel) index += (int)this.ig[i] * this.dimSize[i]; } - Span p = this.lutFlat.AsSpan(index); + Span p = this.lut.AsSpan(index); float[] temp = new float[2]; bool nFlag = false; diff --git a/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/IccConverterbase.Conversions.cs b/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/IccConverterbase.Conversions.cs index 9d2390ac79..1a09390247 100644 --- a/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/IccConverterbase.Conversions.cs +++ b/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/IccConverterbase.Conversions.cs @@ -13,11 +13,11 @@ internal abstract partial class IccConverterBase private IVector4Calculator calculator; /// - /// Checks the profile for available conversion methods and gathers all the informations necessary for it + /// Checks the profile for available conversion methods and gathers all the information's necessary for it. /// - /// The profile to use for the conversion - /// True if the conversion is to the Profile Connection Space - /// The wanted rendering intent. Can be ignored if not available + /// The profile to use for the conversion. + /// True if the conversion is to the Profile Connection Space. + /// The wanted rendering intent. Can be ignored if not available. /// Invalid conversion method. protected void Init(IccProfile profile, bool toPcs, IccRenderingIntent renderingIntent) => this.calculator = GetConversionMethod(profile, renderingIntent) switch diff --git a/src/ImageSharp/Metadata/Profiles/ICC/DataReader/IccDataReader.Lut.cs b/src/ImageSharp/Metadata/Profiles/ICC/DataReader/IccDataReader.Lut.cs index e88dd8d9e1..f16b4d1d17 100644 --- a/src/ImageSharp/Metadata/Profiles/ICC/DataReader/IccDataReader.Lut.cs +++ b/src/ImageSharp/Metadata/Profiles/ICC/DataReader/IccDataReader.Lut.cs @@ -4,24 +4,21 @@ namespace SixLabors.ImageSharp.Metadata.Profiles.Icc; /// -/// Provides methods to read ICC data types +/// Provides methods to read ICC data types. /// internal sealed partial class IccDataReader { /// - /// Reads an 8bit lookup table + /// Reads an 8bit lookup table. /// - /// The read LUT - public IccLut ReadLut8() - { - return new IccLut(this.ReadBytes(256)); - } + /// The read LUT. + public IccLut ReadLut8() => new(this.ReadBytes(256)); /// - /// Reads a 16bit lookup table + /// Reads a 16bit lookup table. /// - /// The number of entries - /// The read LUT + /// The number of entries. + /// The read LUT. public IccLut ReadLut16(int count) { var values = new ushort[count]; @@ -34,16 +31,16 @@ public IccLut ReadLut16(int count) } /// - /// Reads a CLUT depending on type + /// Reads a CLUT depending on type. /// - /// Input channel count - /// Output channel count + /// Input channel count. + /// Output channel count. /// If true, it's read as CLUTf32, - /// else read as either CLUT8 or CLUT16 depending on embedded information - /// The read CLUT + /// else read as either CLUT8 or CLUT16 depending on embedded information. + /// The read CLUT. public IccClut ReadClut(int inChannelCount, int outChannelCount, bool isFloat) { - // Grid-points are always 16 bytes long but only 0-inChCount are used + // Grid-points are always 16 bytes long but only 0-inChCount are used. var gridPointCount = new byte[inChannelCount]; Buffer.BlockCopy(this.data, this.AddIndex(16), gridPointCount, 0, inChannelCount); @@ -67,12 +64,12 @@ public IccClut ReadClut(int inChannelCount, int outChannelCount, bool isFloat) } /// - /// Reads an 8 bit CLUT + /// Reads an 8 bit CLUT. /// - /// Input channel count - /// Output channel count - /// Grid point count for each CLUT channel - /// The read CLUT8 + /// Input channel count. + /// Output channel count. + /// Grid point count for each CLUT channel. + /// The read CLUT8. public IccClut ReadClut8(int inChannelCount, int outChannelCount, byte[] gridPointCount) { int start = this.currentIndex; @@ -82,31 +79,25 @@ public IccClut ReadClut8(int inChannelCount, int outChannelCount, byte[] gridPoi length += (int)Math.Pow(gridPointCount[i], inChannelCount); } - length /= inChannelCount; - const float Max = byte.MaxValue; - var values = new float[length][]; + var values = new float[length]; for (int i = 0; i < length; i++) { - values[i] = new float[outChannelCount]; - for (int j = 0; j < outChannelCount; j++) - { - values[i][j] = this.data[this.currentIndex++] / Max; - } + values[i] = this.data[this.currentIndex++] / Max; } - this.currentIndex = start + (length * outChannelCount); - return new IccClut(values, gridPointCount, IccClutDataType.UInt8); + this.currentIndex = start + length; + return new IccClut(values, gridPointCount, IccClutDataType.UInt8, outChannelCount); } /// - /// Reads a 16 bit CLUT + /// Reads a 16 bit CLUT. /// - /// Input channel count - /// Output channel count - /// Grid point count for each CLUT channel - /// The read CLUT16 + /// Input channel count. + /// Output channel count. + /// Grid point count for each CLUT channel. + /// The read CLUT16. public IccClut ReadClut16(int inChannelCount, int outChannelCount, byte[] gridPointCount) { int start = this.currentIndex; @@ -116,31 +107,25 @@ public IccClut ReadClut16(int inChannelCount, int outChannelCount, byte[] gridPo length += (int)Math.Pow(gridPointCount[i], inChannelCount); } - length /= inChannelCount; - const float Max = ushort.MaxValue; - var values = new float[length][]; + var values = new float[length]; for (int i = 0; i < length; i++) { - values[i] = new float[outChannelCount]; - for (int j = 0; j < outChannelCount; j++) - { - values[i][j] = this.ReadUInt16() / Max; - } + values[i] = this.ReadUInt16() / Max; } - this.currentIndex = start + (length * outChannelCount * 2); - return new IccClut(values, gridPointCount, IccClutDataType.UInt16); + this.currentIndex = start + (length * 2); + return new IccClut(values, gridPointCount, IccClutDataType.UInt16, outChannelCount); } /// - /// Reads a 32bit floating point CLUT + /// Reads a 32bit floating point CLUT. /// - /// Input channel count - /// Output channel count - /// Grid point count for each CLUT channel - /// The read CLUTf32 + /// Input channel count. + /// Output channel count. + /// Grid point count for each CLUT channel. + /// The read CLUTf32. public IccClut ReadClutF32(int inChCount, int outChCount, byte[] gridPointCount) { int start = this.currentIndex; @@ -150,19 +135,13 @@ public IccClut ReadClutF32(int inChCount, int outChCount, byte[] gridPointCount) length += (int)Math.Pow(gridPointCount[i], inChCount); } - length /= inChCount; - - var values = new float[length][]; + var values = new float[length]; for (int i = 0; i < length; i++) { - values[i] = new float[outChCount]; - for (int j = 0; j < outChCount; j++) - { - values[i][j] = this.ReadSingle(); - } + values[i] = this.ReadSingle(); } - this.currentIndex = start + (length * outChCount * 4); - return new IccClut(values, gridPointCount, IccClutDataType.Float); + this.currentIndex = start + (length * 4); + return new IccClut(values, gridPointCount, IccClutDataType.Float, outChCount); } } diff --git a/src/ImageSharp/Metadata/Profiles/ICC/DataReader/IccDataReader.TagDataEntry.cs b/src/ImageSharp/Metadata/Profiles/ICC/DataReader/IccDataReader.TagDataEntry.cs index a830aa98c0..559f77609a 100644 --- a/src/ImageSharp/Metadata/Profiles/ICC/DataReader/IccDataReader.TagDataEntry.cs +++ b/src/ImageSharp/Metadata/Profiles/ICC/DataReader/IccDataReader.TagDataEntry.cs @@ -8,15 +8,15 @@ namespace SixLabors.ImageSharp.Metadata.Profiles.Icc; /// -/// Provides methods to read ICC data types +/// Provides methods to read ICC data types. /// internal sealed partial class IccDataReader { /// - /// Reads a tag data entry + /// Reads a tag data entry. /// - /// The table entry with reading information - /// the tag data entry + /// The table entry with reading information. + /// The tag data entry. public IccTagDataEntry ReadTagDataEntry(IccTagTableEntry info) { this.currentIndex = (int)info.Offset; @@ -101,7 +101,7 @@ public IccTagDataEntry ReadTagDataEntry(IccTagTableEntry info) /// /// Reads the header of a /// - /// The read signature + /// The read signature. public IccTypeSignature ReadTagDataEntryHeader() { IccTypeSignature type = (IccTypeSignature)this.ReadUInt32(); @@ -112,7 +112,7 @@ public IccTypeSignature ReadTagDataEntryHeader() /// /// Reads the header of a and checks if it's the expected value /// - /// expected value to check against + /// The expected value to check against. public void ReadCheckTagDataEntryHeader(IccTypeSignature expected) { IccTypeSignature type = this.ReadTagDataEntryHeader(); @@ -125,8 +125,8 @@ public void ReadCheckTagDataEntryHeader(IccTypeSignature expected) /// /// Reads a with an unknown /// - /// The size of the entry in bytes - /// The read entry + /// The size of the entry in bytes. + /// The read entry. public IccUnknownTagDataEntry ReadUnknownTagDataEntry(uint size) { int count = (int)size - 8; // 8 is the tag header size @@ -136,7 +136,7 @@ public IccUnknownTagDataEntry ReadUnknownTagDataEntry(uint size) /// /// Reads a /// - /// The read entry + /// The read entry. public IccChromaticityTagDataEntry ReadChromaticityTagDataEntry() { ushort channelCount = this.ReadUInt16(); @@ -150,7 +150,7 @@ public IccChromaticityTagDataEntry ReadChromaticityTagDataEntry() } else { - // The type is not know, so the values need be read + // The type is not know, so the values need be read. double[][] values = new double[channelCount][]; for (int i = 0; i < channelCount; i++) { @@ -164,7 +164,7 @@ public IccChromaticityTagDataEntry ReadChromaticityTagDataEntry() /// /// Reads a /// - /// The read entry + /// The read entry. public IccColorantOrderTagDataEntry ReadColorantOrderTagDataEntry() { uint colorantCount = this.ReadUInt32(); @@ -175,7 +175,7 @@ public IccColorantOrderTagDataEntry ReadColorantOrderTagDataEntry() /// /// Reads a /// - /// The read entry + /// The read entry. public IccColorantTableTagDataEntry ReadColorantTableTagDataEntry() { uint colorantCount = this.ReadUInt32(); @@ -191,7 +191,7 @@ public IccColorantTableTagDataEntry ReadColorantTableTagDataEntry() /// /// Reads a /// - /// The read entry + /// The read entry. public IccCurveTagDataEntry ReadCurveTagDataEntry() { uint pointCount = this.ReadUInt32(); @@ -220,7 +220,7 @@ public IccCurveTagDataEntry ReadCurveTagDataEntry() /// /// Reads a /// - /// The size of the entry in bytes + /// The size of the entry in bytes. /// The read entry public IccDataTagDataEntry ReadDataTagDataEntry(uint size) { @@ -238,16 +238,13 @@ public IccDataTagDataEntry ReadDataTagDataEntry(uint size) /// /// Reads a /// - /// The read entry - public IccDateTimeTagDataEntry ReadDateTimeTagDataEntry() - { - return new IccDateTimeTagDataEntry(this.ReadDateTime()); - } + /// The read entry. + public IccDateTimeTagDataEntry ReadDateTimeTagDataEntry() => new IccDateTimeTagDataEntry(this.ReadDateTime()); /// /// Reads a /// - /// The read entry + /// The read entry. public IccLut16TagDataEntry ReadLut16TagDataEntry() { byte inChCount = this.data[this.AddIndex(1)]; @@ -285,7 +282,7 @@ public IccLut16TagDataEntry ReadLut16TagDataEntry() /// /// Reads a /// - /// The read entry + /// The read entry. public IccLut8TagDataEntry ReadLut8TagDataEntry() { byte inChCount = this.data[this.AddIndex(1)]; @@ -320,7 +317,7 @@ public IccLut8TagDataEntry ReadLut8TagDataEntry() /// /// Reads a /// - /// The read entry + /// The read entry. public IccLutAToBTagDataEntry ReadLutAtoBTagDataEntry() { int start = this.currentIndex - 8; // 8 is the tag header size @@ -379,7 +376,7 @@ public IccLutAToBTagDataEntry ReadLutAtoBTagDataEntry() /// /// Reads a /// - /// The read entry + /// The read entry. public IccLutBToATagDataEntry ReadLutBtoATagDataEntry() { int start = this.currentIndex - 8; // 8 is the tag header size @@ -438,21 +435,18 @@ public IccLutBToATagDataEntry ReadLutBtoATagDataEntry() /// /// Reads a /// - /// The read entry - public IccMeasurementTagDataEntry ReadMeasurementTagDataEntry() - { - return new IccMeasurementTagDataEntry( + /// The read entry. + public IccMeasurementTagDataEntry ReadMeasurementTagDataEntry() => new( observer: (IccStandardObserver)this.ReadUInt32(), xyzBacking: this.ReadXyzNumber(), geometry: (IccMeasurementGeometry)this.ReadUInt32(), flare: this.ReadUFix16(), illuminant: (IccStandardIlluminant)this.ReadUInt32()); - } /// /// Reads a /// - /// The read entry + /// The read entry. public IccMultiLocalizedUnicodeTagDataEntry ReadMultiLocalizedUnicodeTagDataEntry() { int start = this.currentIndex - 8; // 8 is the tag header size @@ -517,7 +511,7 @@ CultureInfo ReadCulture(string language, string country) /// /// Reads a /// - /// The read entry + /// The read entry. public IccMultiProcessElementsTagDataEntry ReadMultiProcessElementsTagDataEntry() { int start = this.currentIndex - 8; @@ -545,7 +539,7 @@ public IccMultiProcessElementsTagDataEntry ReadMultiProcessElementsTagDataEntry( /// /// Reads a /// - /// The read entry + /// The read entry. public IccNamedColor2TagDataEntry ReadNamedColor2TagDataEntry() { int vendorFlag = this.ReadInt32(); @@ -567,15 +561,12 @@ public IccNamedColor2TagDataEntry ReadNamedColor2TagDataEntry() /// Reads a /// /// The read entry - public IccParametricCurveTagDataEntry ReadParametricCurveTagDataEntry() - { - return new IccParametricCurveTagDataEntry(this.ReadParametricCurve()); - } + public IccParametricCurveTagDataEntry ReadParametricCurveTagDataEntry() => new(this.ReadParametricCurve()); /// /// Reads a /// - /// The read entry + /// The read entry. public IccProfileSequenceDescTagDataEntry ReadProfileSequenceDescTagDataEntry() { uint count = this.ReadUInt32(); @@ -591,7 +582,7 @@ public IccProfileSequenceDescTagDataEntry ReadProfileSequenceDescTagDataEntry() /// /// Reads a /// - /// The read entry + /// The read entry. public IccProfileSequenceIdentifierTagDataEntry ReadProfileSequenceIdentifierTagDataEntry() { int start = this.currentIndex - 8; // 8 is the tag header size @@ -618,7 +609,7 @@ public IccProfileSequenceIdentifierTagDataEntry ReadProfileSequenceIdentifierTag /// /// Reads a /// - /// The read entry + /// The read entry. public IccResponseCurveSet16TagDataEntry ReadResponseCurveSet16TagDataEntry() { int start = this.currentIndex - 8; // 8 is the tag header size @@ -644,8 +635,8 @@ public IccResponseCurveSet16TagDataEntry ReadResponseCurveSet16TagDataEntry() /// /// Reads a /// - /// The size of the entry in bytes - /// The read entry + /// The size of the entry in bytes. + /// The read entry. public IccFix16ArrayTagDataEntry ReadFix16ArrayTagDataEntry(uint size) { uint count = (size - 8) / 4; @@ -661,27 +652,21 @@ public IccFix16ArrayTagDataEntry ReadFix16ArrayTagDataEntry(uint size) /// /// Reads a /// - /// The read entry - public IccSignatureTagDataEntry ReadSignatureTagDataEntry() - { - return new IccSignatureTagDataEntry(this.ReadAsciiString(4)); - } + /// The read entry. + public IccSignatureTagDataEntry ReadSignatureTagDataEntry() => new(this.ReadAsciiString(4)); /// /// Reads a /// - /// The size of the entry in bytes - /// The read entry - public IccTextTagDataEntry ReadTextTagDataEntry(uint size) - { - return new IccTextTagDataEntry(this.ReadAsciiString((int)size - 8)); // 8 is the tag header size - } + /// The size of the entry in bytes. + /// The read entry. + public IccTextTagDataEntry ReadTextTagDataEntry(uint size) => new(this.ReadAsciiString((int)size - 8)); // 8 is the tag header size /// /// Reads a /// - /// The size of the entry in bytes - /// The read entry + /// The size of the entry in bytes. + /// The read entry. public IccUFix16ArrayTagDataEntry ReadUFix16ArrayTagDataEntry(uint size) { uint count = (size - 8) / 4; @@ -697,8 +682,8 @@ public IccUFix16ArrayTagDataEntry ReadUFix16ArrayTagDataEntry(uint size) /// /// Reads a /// - /// The size of the entry in bytes - /// The read entry + /// The size of the entry in bytes. + /// The read entry. public IccUInt16ArrayTagDataEntry ReadUInt16ArrayTagDataEntry(uint size) { uint count = (size - 8) / 2; @@ -714,8 +699,8 @@ public IccUInt16ArrayTagDataEntry ReadUInt16ArrayTagDataEntry(uint size) /// /// Reads a /// - /// The size of the entry in bytes - /// The read entry + /// The size of the entry in bytes. + /// The read entry. public IccUInt32ArrayTagDataEntry ReadUInt32ArrayTagDataEntry(uint size) { uint count = (size - 8) / 4; @@ -731,8 +716,8 @@ public IccUInt32ArrayTagDataEntry ReadUInt32ArrayTagDataEntry(uint size) /// /// Reads a /// - /// The size of the entry in bytes - /// The read entry + /// The size of the entry in bytes. + /// The read entry. public IccUInt64ArrayTagDataEntry ReadUInt64ArrayTagDataEntry(uint size) { uint count = (size - 8) / 8; @@ -748,8 +733,8 @@ public IccUInt64ArrayTagDataEntry ReadUInt64ArrayTagDataEntry(uint size) /// /// Reads a /// - /// The size of the entry in bytes - /// The read entry + /// The size of the entry in bytes. + /// The read entry. public IccUInt8ArrayTagDataEntry ReadUInt8ArrayTagDataEntry(uint size) { int count = (int)size - 8; // 8 is the tag header size @@ -761,20 +746,17 @@ public IccUInt8ArrayTagDataEntry ReadUInt8ArrayTagDataEntry(uint size) /// /// Reads a /// - /// The read entry - public IccViewingConditionsTagDataEntry ReadViewingConditionsTagDataEntry() - { - return new IccViewingConditionsTagDataEntry( + /// The read entry. + public IccViewingConditionsTagDataEntry ReadViewingConditionsTagDataEntry() => new( illuminantXyz: this.ReadXyzNumber(), surroundXyz: this.ReadXyzNumber(), illuminant: (IccStandardIlluminant)this.ReadUInt32()); - } /// /// Reads a /// - /// The size of the entry in bytes - /// The read entry + /// The size of the entry in bytes. + /// The read entry. public IccXyzTagDataEntry ReadXyzTagDataEntry(uint size) { uint count = (size - 8) / 12; @@ -790,7 +772,7 @@ public IccXyzTagDataEntry ReadXyzTagDataEntry(uint size) /// /// Reads a /// - /// The read entry + /// The read entry. public IccTextDescriptionTagDataEntry ReadTextDescriptionTagDataEntry() { string unicodeValue, scriptcodeValue; @@ -830,7 +812,7 @@ public IccTextDescriptionTagDataEntry ReadTextDescriptionTagDataEntry() /// /// Reads a /// - /// The read entry + /// The read entry. public IccCrdInfoTagDataEntry ReadCrdInfoTagDataEntry() { uint productNameCount = this.ReadUInt32(); @@ -854,7 +836,7 @@ public IccCrdInfoTagDataEntry ReadCrdInfoTagDataEntry() /// /// Reads a /// - /// The read entry + /// The read entry. public IccScreeningTagDataEntry ReadScreeningTagDataEntry() { var flags = (IccScreeningFlag)this.ReadInt32(); @@ -871,7 +853,7 @@ public IccScreeningTagDataEntry ReadScreeningTagDataEntry() /// /// Reads a /// - /// The size of the entry in bytes + /// The size of the entry in bytes. /// The read entry public IccUcrBgTagDataEntry ReadUcrBgTagDataEntry(uint size) { diff --git a/src/ImageSharp/Metadata/Profiles/ICC/DataWriter/IccDataWriter.Lut.cs b/src/ImageSharp/Metadata/Profiles/ICC/DataWriter/IccDataWriter.Lut.cs index 703a3896bb..29394c0820 100644 --- a/src/ImageSharp/Metadata/Profiles/ICC/DataWriter/IccDataWriter.Lut.cs +++ b/src/ImageSharp/Metadata/Profiles/ICC/DataWriter/IccDataWriter.Lut.cs @@ -4,15 +4,15 @@ namespace SixLabors.ImageSharp.Metadata.Profiles.Icc; /// -/// Provides methods to write ICC data types +/// Provides methods to write ICC data types. /// internal sealed partial class IccDataWriter { /// - /// Writes an 8bit lookup table + /// Writes an 8bit lookup table. /// - /// The LUT to write - /// The number of bytes written + /// The LUT to write. + /// The number of bytes written. public int WriteLut8(IccLut value) { foreach (float item in value.Values) @@ -24,10 +24,10 @@ public int WriteLut8(IccLut value) } /// - /// Writes an 16bit lookup table + /// Writes an 16bit lookup table. /// - /// The LUT to write - /// The number of bytes written + /// The LUT to write. + /// The number of bytes written. public int WriteLut16(IccLut value) { foreach (float item in value.Values) @@ -39,10 +39,10 @@ public int WriteLut16(IccLut value) } /// - /// Writes an color lookup table + /// Writes an color lookup table. /// - /// The CLUT to write - /// The number of bytes written + /// The CLUT to write. + /// The number of bytes written. public int WriteClut(IccClut value) { int count = this.WriteArray(value.GridPointCount); @@ -67,57 +67,48 @@ public int WriteClut(IccClut value) } /// - /// Writes a 8bit color lookup table + /// Writes a 8bit color lookup table. /// - /// The CLUT to write - /// The number of bytes written + /// The CLUT to write. + /// The number of bytes written. public int WriteClut8(IccClut value) { int count = 0; - foreach (float[] inArray in value.Values) + foreach (float item in value.Values) { - foreach (float item in inArray) - { - count += this.WriteByte((byte)Numerics.Clamp((item * byte.MaxValue) + 0.5F, 0, byte.MaxValue)); - } + count += this.WriteByte((byte)Numerics.Clamp((item * byte.MaxValue) + 0.5F, 0, byte.MaxValue)); } return count; } /// - /// Writes a 16bit color lookup table + /// Writes a 16bit color lookup table. /// - /// The CLUT to write - /// The number of bytes written + /// The CLUT to write. + /// The number of bytes written. public int WriteClut16(IccClut value) { int count = 0; - foreach (float[] inArray in value.Values) + foreach (float item in value.Values) { - foreach (float item in inArray) - { - count += this.WriteUInt16((ushort)Numerics.Clamp((item * ushort.MaxValue) + 0.5F, 0, ushort.MaxValue)); - } + count += this.WriteUInt16((ushort)Numerics.Clamp((item * ushort.MaxValue) + 0.5F, 0, ushort.MaxValue)); } return count; } /// - /// Writes a 32bit float color lookup table + /// Writes a 32bit float color lookup table. /// - /// The CLUT to write - /// The number of bytes written + /// The CLUT to write. + /// The number of bytes written. public int WriteClutF32(IccClut value) { int count = 0; - foreach (float[] inArray in value.Values) + foreach (float item in value.Values) { - foreach (float item in inArray) - { - count += this.WriteSingle(item); - } + count += this.WriteSingle(item); } return count; diff --git a/src/ImageSharp/Metadata/Profiles/ICC/DataWriter/IccDataWriter.TagDataEntry.cs b/src/ImageSharp/Metadata/Profiles/ICC/DataWriter/IccDataWriter.TagDataEntry.cs index 1f9c101fb5..6019a0bff7 100644 --- a/src/ImageSharp/Metadata/Profiles/ICC/DataWriter/IccDataWriter.TagDataEntry.cs +++ b/src/ImageSharp/Metadata/Profiles/ICC/DataWriter/IccDataWriter.TagDataEntry.cs @@ -231,7 +231,7 @@ public int WriteLut8TagDataEntry(IccLut8TagDataEntry value) { int count = this.WriteByte((byte)value.InputChannelCount); count += this.WriteByte((byte)value.OutputChannelCount); - count += this.WriteByte((byte)value.ClutValues.Values[0].Length); + count += this.WriteByte((byte)value.ClutValues.OutputChannelCount); count += this.WriteEmpty(1); count += this.WriteMatrix(value.Matrix, false); diff --git a/src/ImageSharp/Metadata/Profiles/ICC/Various/IccClut.cs b/src/ImageSharp/Metadata/Profiles/ICC/Various/IccClut.cs index 68b9beefea..b6818df1d3 100644 --- a/src/ImageSharp/Metadata/Profiles/ICC/Various/IccClut.cs +++ b/src/ImageSharp/Metadata/Profiles/ICC/Various/IccClut.cs @@ -14,7 +14,8 @@ internal sealed class IccClut : IEquatable /// The CLUT values. /// The gridpoint count. /// The data type of this CLUT. - public IccClut(float[][] values, byte[] gridPointCount, IccClutDataType type) + /// The output channels count. + public IccClut(float[] values, byte[] gridPointCount, IccClutDataType type, int outputChannelCount) { Guard.NotNull(values, nameof(values)); Guard.NotNull(gridPointCount, nameof(gridPointCount)); @@ -22,7 +23,7 @@ public IccClut(float[][] values, byte[] gridPointCount, IccClutDataType type) this.Values = values; this.DataType = type; this.InputChannelCount = gridPointCount.Length; - this.OutputChannelCount = values[0].Length; + this.OutputChannelCount = outputChannelCount; this.GridPointCount = gridPointCount; this.CheckValues(); } @@ -30,7 +31,7 @@ public IccClut(float[][] values, byte[] gridPointCount, IccClutDataType type) /// /// Gets the values that make up this table. /// - public float[][] Values { get; } + public float[] Values { get; } /// /// Gets the CLUT data type (important when writing a profile). @@ -92,7 +93,7 @@ private bool EqualsValuesArray(IccClut other) for (int i = 0; i < this.Values.Length; i++) { - if (!this.Values[i].AsSpan().SequenceEqual(other.Values[i])) + if (!this.Values.SequenceEqual(other.Values)) { return false; } @@ -106,17 +107,12 @@ private void CheckValues() Guard.MustBeBetweenOrEqualTo(this.InputChannelCount, 1, 15, nameof(this.InputChannelCount)); Guard.MustBeBetweenOrEqualTo(this.OutputChannelCount, 1, 15, nameof(this.OutputChannelCount)); - bool isLengthDifferent = this.Values.Any(t => t.Length != this.OutputChannelCount); - Guard.IsFalse(isLengthDifferent, nameof(this.Values), "The number of output values varies"); - int length = 0; for (int i = 0; i < this.InputChannelCount; i++) { length += (int)Math.Pow(this.GridPointCount[i], this.InputChannelCount); } - length /= this.InputChannelCount; - Guard.IsTrue(this.Values.Length == length, nameof(this.Values), "Length of values array does not match the grid points"); } } diff --git a/tests/ImageSharp.Tests/TestDataIcc/Conversion/IccConversionDataClut.cs b/tests/ImageSharp.Tests/TestDataIcc/Conversion/IccConversionDataClut.cs index dadbc5262b..bcf87c5fcd 100644 --- a/tests/ImageSharp.Tests/TestDataIcc/Conversion/IccConversionDataClut.cs +++ b/tests/ImageSharp.Tests/TestDataIcc/Conversion/IccConversionDataClut.cs @@ -11,142 +11,148 @@ public class IccConversionDataClut internal static IccClut Clut3x2 = new( new[] { - new[] { 0.1f, 0.1f }, - new[] { 0.2f, 0.2f }, - new[] { 0.3f, 0.3f }, + 0.1f, 0.1f, + 0.2f, 0.2f, + 0.3f, 0.3f, - new[] { 0.11f, 0.11f }, - new[] { 0.21f, 0.21f }, - new[] { 0.31f, 0.31f }, + 0.11f, 0.11f, + 0.21f, 0.21f, + 0.31f, 0.31f, - new[] { 0.12f, 0.12f }, - new[] { 0.22f, 0.22f }, - new[] { 0.32f, 0.32f }, + 0.12f, 0.12f, + 0.22f, 0.22f, + 0.32f, 0.32f, - new[] { 0.13f, 0.13f }, - new[] { 0.23f, 0.23f }, - new[] { 0.33f, 0.33f }, + 0.13f, 0.13f, + 0.23f, 0.23f, + 0.33f, 0.33f, - new[] { 0.14f, 0.14f }, - new[] { 0.24f, 0.24f }, - new[] { 0.34f, 0.34f }, + 0.14f, 0.14f, + 0.24f, 0.24f, + 0.34f, 0.34f, - new[] { 0.15f, 0.15f }, - new[] { 0.25f, 0.25f }, - new[] { 0.35f, 0.35f }, + 0.15f, 0.15f, + 0.25f, 0.25f, + 0.35f, 0.35f, - new[] { 0.16f, 0.16f }, - new[] { 0.26f, 0.26f }, - new[] { 0.36f, 0.36f }, + 0.16f, 0.16f, + 0.26f, 0.26f, + 0.36f, 0.36f, - new[] { 0.17f, 0.17f }, - new[] { 0.27f, 0.27f }, - new[] { 0.37f, 0.37f }, + 0.17f, 0.17f, + 0.27f, 0.27f, + 0.37f, 0.37f, - new[] { 0.18f, 0.18f }, - new[] { 0.28f, 0.28f }, - new[] { 0.38f, 0.38f }, + 0.18f, 0.18f, + 0.28f, 0.28f, + 0.38f, 0.38f, }, new byte[] { 3, 3, 3 }, - IccClutDataType.Float); + IccClutDataType.Float, + outputChannelCount: 3); internal static IccClut Clut3x1 = new( new[] { - new[] { 0.10f }, - new[] { 0.20f }, - new[] { 0.30f }, + 0.10f, + 0.20f, + 0.30f, - new[] { 0.11f }, - new[] { 0.21f }, - new[] { 0.31f }, + 0.11f, + 0.21f, + 0.31f, - new[] { 0.12f }, - new[] { 0.22f }, - new[] { 0.32f }, + 0.12f, + 0.22f, + 0.32f, - new[] { 0.13f }, - new[] { 0.23f }, - new[] { 0.33f }, + 0.13f, + 0.23f, + 0.33f, - new[] { 0.14f }, - new[] { 0.24f }, - new[] { 0.34f }, + 0.14f, + 0.24f, + 0.34f, - new[] { 0.15f }, - new[] { 0.25f }, - new[] { 0.35f }, + 0.15f, + 0.25f, + 0.35f, - new[] { 0.16f }, - new[] { 0.26f }, - new[] { 0.36f }, + 0.16f, + 0.26f, + 0.36f, - new[] { 0.17f }, - new[] { 0.27f }, - new[] { 0.37f }, + 0.17f, + 0.27f, + 0.37f, - new[] { 0.18f }, - new[] { 0.28f }, - new[] { 0.38f }, + 0.18f, + 0.28f, + 0.38f, }, new byte[] { 3, 3, 3 }, - IccClutDataType.Float); + IccClutDataType.Float, + outputChannelCount: 3); internal static IccClut Clut2x2 = new( new[] { - new[] { 0.1f, 0.9f }, - new[] { 0.2f, 0.8f }, - new[] { 0.3f, 0.7f }, + 0.1f, 0.9f, + 0.2f, 0.8f, + 0.3f, 0.7f, - new[] { 0.4f, 0.6f }, - new[] { 0.5f, 0.5f }, - new[] { 0.6f, 0.4f }, + 0.4f, 0.6f, + 0.5f, 0.5f, + 0.6f, 0.4f, - new[] { 0.7f, 0.3f }, - new[] { 0.8f, 0.2f }, - new[] { 0.9f, 0.1f }, + 0.7f, 0.3f, + 0.8f, 0.2f, + 0.9f, 0.1f, }, new byte[] { 3, 3 }, - IccClutDataType.Float); + IccClutDataType.Float, + outputChannelCount: 3); internal static IccClut Clut2x1 = new( new[] { - new[] { 0.1f }, - new[] { 0.2f }, - new[] { 0.3f }, + 0.1f, + 0.2f, + 0.3f, - new[] { 0.4f }, - new[] { 0.5f }, - new[] { 0.6f }, + 0.4f, + 0.5f, + 0.6f, - new[] { 0.7f }, - new[] { 0.8f }, - new[] { 0.9f }, + 0.7f, + 0.8f, + 0.9f, }, new byte[] { 3, 3 }, - IccClutDataType.Float); + IccClutDataType.Float, + outputChannelCount: 3); internal static IccClut Clut1x2 = new( new[] { - new[] { 0f, 0.5f }, - new[] { 0.25f, 0.75f, }, - new[] { 0.5f, 1f }, + 0f, 0.5f, + 0.25f, 0.75f, + 0.5f, 1f, }, new byte[] { 3 }, - IccClutDataType.Float); + IccClutDataType.Float, + outputChannelCount: 3); internal static IccClut Clut1x1 = new( new[] { - new[] { 0f }, - new[] { 0.5f }, - new[] { 1f }, + 0f, + 0.5f, + 1f, }, new byte[] { 3 }, - IccClutDataType.Float); + IccClutDataType.Float, + outputChannelCount: 3); public static object[][] ClutConversionTestData = { diff --git a/tests/ImageSharp.Tests/TestDataIcc/Conversion/IccConversionDataMultiProcessElement.cs b/tests/ImageSharp.Tests/TestDataIcc/Conversion/IccConversionDataMultiProcessElement.cs index 3c3e576fe2..e4adba078d 100644 --- a/tests/ImageSharp.Tests/TestDataIcc/Conversion/IccConversionDataMultiProcessElement.cs +++ b/tests/ImageSharp.Tests/TestDataIcc/Conversion/IccConversionDataMultiProcessElement.cs @@ -18,20 +18,21 @@ public class IccConversionDataMultiProcessElement private static readonly IccClut Clut = new( new[] { - new[] { 0.2f, 0.3f }, - new[] { 0.4f, 0.5f }, + 0.2f, 0.3f, + 0.4f, 0.2f, - new[] { 0.21f, 0.31f }, - new[] { 0.41f, 0.51f }, + 0.21f, 0.31f, + 0.41f, 0.51f, - new[] { 0.22f, 0.32f }, - new[] { 0.42f, 0.52f }, + 0.22f, 0.32f, + 0.42f, 0.52f, - new[] { 0.23f, 0.33f }, - new[] { 0.43f, 0.53f }, + 0.23f, 0.33f, + 0.43f, 0.53f, }, new byte[] { 2, 2, 2 }, - IccClutDataType.Float); + IccClutDataType.Float, + outputChannelCount: 2); private static readonly IccFormulaCurveElement FormulaCurveElement1 = new(IccFormulaCurveType.Type1, 2.2f, 0.7f, 0.2f, 0.3f, 0, 0); private static readonly IccFormulaCurveElement FormulaCurveElement2 = new(IccFormulaCurveType.Type2, 2.2f, 0.9f, 0.9f, 0.02f, 0.1f, 0); diff --git a/tests/ImageSharp.Tests/TestDataIcc/IccTestDataLut.cs b/tests/ImageSharp.Tests/TestDataIcc/IccTestDataLut.cs index ea4a756007..2bd47e4497 100644 --- a/tests/ImageSharp.Tests/TestDataIcc/IccTestDataLut.cs +++ b/tests/ImageSharp.Tests/TestDataIcc/IccTestDataLut.cs @@ -73,20 +73,21 @@ private static byte[] CreateLut8() public static readonly IccClut Clut8ValGrad = new( new[] { - new[] { 1f / byte.MaxValue, 2f / byte.MaxValue, 3f / byte.MaxValue }, - new[] { 4f / byte.MaxValue, 5f / byte.MaxValue, 6f / byte.MaxValue }, - new[] { 7f / byte.MaxValue, 8f / byte.MaxValue, 9f / byte.MaxValue }, + 1f / byte.MaxValue, 2f / byte.MaxValue, 3f / byte.MaxValue, + 4f / byte.MaxValue, 5f / byte.MaxValue, 6f / byte.MaxValue, + 7f / byte.MaxValue, 8f / byte.MaxValue, 9f / byte.MaxValue, - new[] { 10f / byte.MaxValue, 11f / byte.MaxValue, 12f / byte.MaxValue }, - new[] { 13f / byte.MaxValue, 14f / byte.MaxValue, 15f / byte.MaxValue }, - new[] { 16f / byte.MaxValue, 17f / byte.MaxValue, 18f / byte.MaxValue }, + 10f / byte.MaxValue, 11f / byte.MaxValue, 12f / byte.MaxValue, + 13f / byte.MaxValue, 14f / byte.MaxValue, 15f / byte.MaxValue, + 16f / byte.MaxValue, 17f / byte.MaxValue, 18f / byte.MaxValue, - new[] { 19f / byte.MaxValue, 20f / byte.MaxValue, 21f / byte.MaxValue }, - new[] { 22f / byte.MaxValue, 23f / byte.MaxValue, 24f / byte.MaxValue }, - new[] { 25f / byte.MaxValue, 26f / byte.MaxValue, 27f / byte.MaxValue }, + 19f / byte.MaxValue, 20f / byte.MaxValue, 21f / byte.MaxValue, + 22f / byte.MaxValue, 23f / byte.MaxValue, 24f / byte.MaxValue, + 25f / byte.MaxValue, 26f / byte.MaxValue, 27f / byte.MaxValue, }, new byte[] { 3, 3 }, - IccClutDataType.UInt8); + IccClutDataType.UInt8, + outputChannelCount: 3); /// /// Input Channel Count: 2 @@ -116,20 +117,21 @@ private static byte[] CreateLut8() public static readonly IccClut Clut16ValGrad = new( new[] { - new[] { 1f / ushort.MaxValue, 2f / ushort.MaxValue, 3f / ushort.MaxValue }, - new[] { 4f / ushort.MaxValue, 5f / ushort.MaxValue, 6f / ushort.MaxValue }, - new[] { 7f / ushort.MaxValue, 8f / ushort.MaxValue, 9f / ushort.MaxValue }, + 1f / ushort.MaxValue, 2f / ushort.MaxValue, 3f / ushort.MaxValue, + 4f / ushort.MaxValue, 5f / ushort.MaxValue, 6f / ushort.MaxValue, + 7f / ushort.MaxValue, 8f / ushort.MaxValue, 9f / ushort.MaxValue, - new[] { 10f / ushort.MaxValue, 11f / ushort.MaxValue, 12f / ushort.MaxValue }, - new[] { 13f / ushort.MaxValue, 14f / ushort.MaxValue, 15f / ushort.MaxValue }, - new[] { 16f / ushort.MaxValue, 17f / ushort.MaxValue, 18f / ushort.MaxValue }, + 10f / ushort.MaxValue, 11f / ushort.MaxValue, 12f / ushort.MaxValue, + 13f / ushort.MaxValue, 14f / ushort.MaxValue, 15f / ushort.MaxValue, + 16f / ushort.MaxValue, 17f / ushort.MaxValue, 18f / ushort.MaxValue, - new[] { 19f / ushort.MaxValue, 20f / ushort.MaxValue, 21f / ushort.MaxValue }, - new[] { 22f / ushort.MaxValue, 23f / ushort.MaxValue, 24f / ushort.MaxValue }, - new[] { 25f / ushort.MaxValue, 26f / ushort.MaxValue, 27f / ushort.MaxValue }, + 19f / ushort.MaxValue, 20f / ushort.MaxValue, 21f / ushort.MaxValue, + 22f / ushort.MaxValue, 23f / ushort.MaxValue, 24f / ushort.MaxValue, + 25f / ushort.MaxValue, 26f / ushort.MaxValue, 27f / ushort.MaxValue, }, new byte[] { 3, 3 }, - IccClutDataType.UInt16); + IccClutDataType.UInt16, + outputChannelCount: 3); /// /// Input Channel Count: 2 @@ -159,20 +161,21 @@ private static byte[] CreateLut8() public static readonly IccClut CluTf32ValGrad = new( new[] { - new[] { 1f, 2f, 3f }, - new[] { 4f, 5f, 6f }, - new[] { 7f, 8f, 9f }, + 1f, 2f, 3f, + 4f, 5f, 6f, + 7f, 8f, 9f, - new[] { 1f, 2f, 3f }, - new[] { 4f, 5f, 6f }, - new[] { 7f, 8f, 9f }, + 1f, 2f, 3f, + 4f, 5f, 6f, + 7f, 8f, 9f, - new[] { 1f, 2f, 3f }, - new[] { 4f, 5f, 6f }, - new[] { 7f, 8f, 9f }, + 1f, 2f, 3f, + 4f, 5f, 6f, + 7f, 8f, 9f, }, new byte[] { 3, 3 }, - IccClutDataType.Float); + IccClutDataType.Float, + outputChannelCount: 3); /// /// Input Channel Count: 2 From 67ed4ce6141267b78e747d832caf41bcb8a42e6c Mon Sep 17 00:00:00 2001 From: Brian Popow Date: Sun, 22 Jan 2023 19:24:55 +0100 Subject: [PATCH 30/42] Fix warnings --- .../Icc/Calculators/ClutCalculator.cs | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/ClutCalculator.cs b/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/ClutCalculator.cs index 4828deef70..5464937b41 100644 --- a/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/ClutCalculator.cs +++ b/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/ClutCalculator.cs @@ -22,11 +22,11 @@ internal class ClutCalculator : IVector4Calculator private readonly int[] dimSize; private readonly int nodeCount; private readonly float[][] nodes; - float[] g; - uint[] ig; - float[] s; - float[] df; - private uint[] nPower; + private readonly float[] g; + private readonly uint[] ig; + private readonly float[] s; + private readonly float[] df; + private readonly uint[] nPower; private int n000; private int n001; private int n010; @@ -237,6 +237,7 @@ private unsafe void Interpolate2d(float* srcPixel, float* destPixel) ix--; u = 1.0f; } + if (iy == my) { iy--; @@ -258,7 +259,7 @@ private unsafe void Interpolate2d(float* srcPixel, float* destPixel) int offset = 0; for (i = 0; i < this.outputCount; i++) { - float pv = (p[offset + this.n000] * dF0) + (p[offset + this.n001] * dF1) + (p[ offset + this.n010] * dF2) + (p[offset + this.n011] * dF3); + float pv = (p[offset + this.n000] * dF0) + (p[offset + this.n001] * dF1) + (p[offset + this.n010] * dF2) + (p[offset + this.n011] * dF3); destPixel[i] = pv; offset++; From b036cc36d1af86a3392546d31b33e6cdbc003f55 Mon Sep 17 00:00:00 2001 From: Brian Popow Date: Sun, 22 Jan 2023 21:19:24 +0100 Subject: [PATCH 31/42] Fix mistake reading the clut values --- .../ICC/DataReader/IccDataReader.Lut.cs | 36 +++++++++++++------ .../DataReader/IccDataReader.Primitives.cs | 35 ++++-------------- .../Metadata/Profiles/ICC/Various/IccClut.cs | 3 +- 3 files changed, 35 insertions(+), 39 deletions(-) diff --git a/src/ImageSharp/Metadata/Profiles/ICC/DataReader/IccDataReader.Lut.cs b/src/ImageSharp/Metadata/Profiles/ICC/DataReader/IccDataReader.Lut.cs index f16b4d1d17..f3ce6cd79c 100644 --- a/src/ImageSharp/Metadata/Profiles/ICC/DataReader/IccDataReader.Lut.cs +++ b/src/ImageSharp/Metadata/Profiles/ICC/DataReader/IccDataReader.Lut.cs @@ -72,22 +72,26 @@ public IccClut ReadClut(int inChannelCount, int outChannelCount, bool isFloat) /// The read CLUT8. public IccClut ReadClut8(int inChannelCount, int outChannelCount, byte[] gridPointCount) { - int start = this.currentIndex; int length = 0; for (int i = 0; i < inChannelCount; i++) { length += (int)Math.Pow(gridPointCount[i], inChannelCount); } + length /= inChannelCount; + const float Max = byte.MaxValue; - var values = new float[length]; + float[] values = new float[length * outChannelCount]; + int offset = 0; for (int i = 0; i < length; i++) { - values[i] = this.data[this.currentIndex++] / Max; + for (int j = 0; j < outChannelCount; j++) + { + values[offset++] = this.data[this.currentIndex++] / Max; + } } - this.currentIndex = start + length; return new IccClut(values, gridPointCount, IccClutDataType.UInt8, outChannelCount); } @@ -107,15 +111,21 @@ public IccClut ReadClut16(int inChannelCount, int outChannelCount, byte[] gridPo length += (int)Math.Pow(gridPointCount[i], inChannelCount); } + length /= inChannelCount; + const float Max = ushort.MaxValue; - var values = new float[length]; + float[] values = new float[length * outChannelCount]; + int offset = 0; for (int i = 0; i < length; i++) { - values[i] = this.ReadUInt16() / Max; + for (int j = 0; j < outChannelCount; j++) + { + values[offset++] = this.ReadUInt16() / Max; + } } - this.currentIndex = start + (length * 2); + this.currentIndex = start + (length * outChannelCount * 2); return new IccClut(values, gridPointCount, IccClutDataType.UInt16, outChannelCount); } @@ -135,13 +145,19 @@ public IccClut ReadClutF32(int inChCount, int outChCount, byte[] gridPointCount) length += (int)Math.Pow(gridPointCount[i], inChCount); } - var values = new float[length]; + length /= inChCount; + + float[] values = new float[length * outChCount]; + int offset = 0; for (int i = 0; i < length; i++) { - values[i] = this.ReadSingle(); + for (int j = 0; j < outChCount; j++) + { + values[offset++] = this.ReadSingle(); + } } - this.currentIndex = start + (length * 4); + this.currentIndex = start + (length * outChCount * 4); return new IccClut(values, gridPointCount, IccClutDataType.Float, outChCount); } } diff --git a/src/ImageSharp/Metadata/Profiles/ICC/DataReader/IccDataReader.Primitives.cs b/src/ImageSharp/Metadata/Profiles/ICC/DataReader/IccDataReader.Primitives.cs index 47d946d443..7a526ef1af 100644 --- a/src/ImageSharp/Metadata/Profiles/ICC/DataReader/IccDataReader.Primitives.cs +++ b/src/ImageSharp/Metadata/Profiles/ICC/DataReader/IccDataReader.Primitives.cs @@ -16,55 +16,37 @@ internal sealed partial class IccDataReader /// Reads an ushort /// /// the value - public ushort ReadUInt16() - { - return BinaryPrimitives.ReadUInt16BigEndian(this.data.AsSpan(this.AddIndex(2), 2)); - } + public ushort ReadUInt16() => BinaryPrimitives.ReadUInt16BigEndian(this.data.AsSpan(this.AddIndex(2), 2)); /// /// Reads a short /// /// the value - public short ReadInt16() - { - return BinaryPrimitives.ReadInt16BigEndian(this.data.AsSpan(this.AddIndex(2), 2)); - } + public short ReadInt16() => BinaryPrimitives.ReadInt16BigEndian(this.data.AsSpan(this.AddIndex(2), 2)); /// /// Reads an uint /// /// the value - public uint ReadUInt32() - { - return BinaryPrimitives.ReadUInt32BigEndian(this.data.AsSpan(this.AddIndex(4), 4)); - } + public uint ReadUInt32() => BinaryPrimitives.ReadUInt32BigEndian(this.data.AsSpan(this.AddIndex(4), 4)); /// /// Reads an int /// /// the value - public int ReadInt32() - { - return BinaryPrimitives.ReadInt32BigEndian(this.data.AsSpan(this.AddIndex(4), 4)); - } + public int ReadInt32() => BinaryPrimitives.ReadInt32BigEndian(this.data.AsSpan(this.AddIndex(4), 4)); /// /// Reads an ulong /// /// the value - public ulong ReadUInt64() - { - return BinaryPrimitives.ReadUInt64BigEndian(this.data.AsSpan(this.AddIndex(8), 8)); - } + public ulong ReadUInt64() => BinaryPrimitives.ReadUInt64BigEndian(this.data.AsSpan(this.AddIndex(8), 8)); /// /// Reads a long /// /// the value - public long ReadInt64() - { - return BinaryPrimitives.ReadInt64BigEndian(this.data.AsSpan(this.AddIndex(8), 8)); - } + public long ReadInt64() => BinaryPrimitives.ReadInt64BigEndian(this.data.AsSpan(this.AddIndex(8), 8)); /// /// Reads a float. @@ -152,10 +134,7 @@ public string ReadUnicodeString(int length) /// Reads an unsigned 16bit number with 8 value bits and 8 fractional bits. /// /// The number as double - public float ReadUFix8() - { - return this.ReadUInt16() / 256f; - } + public float ReadUFix8() => this.ReadUInt16() / 256f; /// /// Reads a number of bytes and advances the index. diff --git a/src/ImageSharp/Metadata/Profiles/ICC/Various/IccClut.cs b/src/ImageSharp/Metadata/Profiles/ICC/Various/IccClut.cs index b6818df1d3..546da28767 100644 --- a/src/ImageSharp/Metadata/Profiles/ICC/Various/IccClut.cs +++ b/src/ImageSharp/Metadata/Profiles/ICC/Various/IccClut.cs @@ -113,6 +113,7 @@ private void CheckValues() length += (int)Math.Pow(this.GridPointCount[i], this.InputChannelCount); } - Guard.IsTrue(this.Values.Length == length, nameof(this.Values), "Length of values array does not match the grid points"); + // TODO: Disabled this check, not sure if this check is correct. + // Guard.IsTrue(this.Values.Length == length, nameof(this.Values), "Length of values array does not match the grid points"); } } From 52f88c8e6bafb40e2ef3f7f3c033728e289291e5 Mon Sep 17 00:00:00 2001 From: James Jackson-South Date: Mon, 23 Jan 2023 10:56:50 +1000 Subject: [PATCH 32/42] Fix oob in n-dimension calculator. --- .../Implementation/Icc/Calculators/ClutCalculator.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/ClutCalculator.cs b/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/ClutCalculator.cs index 5464937b41..5aa208ee6a 100644 --- a/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/ClutCalculator.cs +++ b/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/ClutCalculator.cs @@ -48,10 +48,10 @@ public ClutCalculator(IccClut clut) this.g = new float[this.inputCount]; this.ig = new uint[this.inputCount]; this.s = new float[this.inputCount]; - this.df = new float[this.nodeCount]; this.nPower = new uint[16]; this.lut = clut.Values; this.nodeCount = (int)Math.Pow(2, clut.InputChannelCount); + this.df = new float[this.nodeCount]; this.nodes = new float[this.nodeCount][]; this.dimSize = new int[this.inputCount]; this.gridPointCount = clut.GridPointCount; @@ -435,10 +435,10 @@ private unsafe void InterpolateNd(float* srcPixel, float* destPixel) int index = 0; for (int i = 0; i < this.inputCount; i++) { - this.g[i] = UnitClip(srcPixel[i]) * this.gridPointCount[i]; + this.g[i] = UnitClip(srcPixel[i]) * this.maxGridPoint[i]; this.ig[i] = (uint)this.g[i]; this.s[this.inputCount - 1 - i] = this.g[i] - this.ig[i]; - if (this.ig[i] == this.gridPointCount[i]) + if (this.ig[i] == this.maxGridPoint[i]) { this.ig[i]--; this.s[this.inputCount - 1 - i] = 1.0f; From ed476785dcfabd9837c5e182f9ca7e4939b4b23c Mon Sep 17 00:00:00 2001 From: James Jackson-South Date: Mon, 23 Jan 2023 10:57:53 +1000 Subject: [PATCH 33/42] Add Lab<=>Xyz conversion --- .../Implementation/Icc/IccProfileConverter.cs | 56 ++++++++++++++++++- 1 file changed, 53 insertions(+), 3 deletions(-) diff --git a/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/IccProfileConverter.cs b/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/IccProfileConverter.cs index 51c34e4c79..632ffa4f05 100644 --- a/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/IccProfileConverter.cs +++ b/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/IccProfileConverter.cs @@ -48,10 +48,44 @@ public static void Convert(Image image, IccProfile inputIccProfi Span row = accessor.GetRowSpan(y); PixelOperations.Instance.ToVector4(configuration, row, vectorsSpan, PixelConversionModifiers.Scale); - for (int x = 0; x < vectorsSpan.Length; x++) + if (inputIccProfile.Header.ProfileConnectionSpace == IccColorSpaceType.CieLab + && outputIccProfile.Header.ProfileConnectionSpace == IccColorSpaceType.CieXyz) { - Vector4 pcs = converterDataToPcs.Calculate(vectorsSpan[x]); - vectorsSpan[x] = converterPcsToData.Calculate(pcs); + ColorSpaceConverter converter = new(); + for (int x = 0; x < vectorsSpan.Length; x++) + { + Vector4 pcs = converterDataToPcs.Calculate(vectorsSpan[x]); + pcs = PcsToLab(pcs); + CieXyz xyz = converter.ToCieXyz(new CieLab(pcs.X, pcs.Y, pcs.Z, new CieXyz(inputIccProfile.Header.PcsIlluminant))); + pcs = new Vector4(xyz.X, xyz.Y, xyz.Z, pcs.W); + + vectorsSpan[x] = converterPcsToData.Calculate(pcs); + } + } + else if (inputIccProfile.Header.ProfileConnectionSpace == IccColorSpaceType.CieXyz + && outputIccProfile.Header.ProfileConnectionSpace == IccColorSpaceType.CieLab) + { + Vector3 illuminant = outputIccProfile.Header.PcsIlluminant; + ColorSpaceConverter converter = new(new ColorSpaceConverterOptions() + { + WhitePoint = new(illuminant), + }); + + for (int x = 0; x < vectorsSpan.Length; x++) + { + Vector4 pcs = converterDataToPcs.Calculate(vectorsSpan[x]); + CieLab lab = converter.ToCieLab(new CieXyz(pcs.X, pcs.Y, pcs.Z)); + pcs = LabToPcs(pcs, lab); + vectorsSpan[x] = converterPcsToData.Calculate(pcs); + } + } + else + { + for (int x = 0; x < vectorsSpan.Length; x++) + { + Vector4 pcs = converterDataToPcs.Calculate(vectorsSpan[x]); + vectorsSpan[x] = converterPcsToData.Calculate(pcs); + } } PixelOperations.Instance.FromVector4Destructive(configuration, vectorsSpan, row); @@ -61,6 +95,22 @@ public static void Convert(Image image, IccProfile inputIccProfi image.Metadata.IccProfile = outputIccProfile; } + private static unsafe Vector4 PcsToLab(Vector4 input) + { + Vector3* v = (Vector3*)&input; + v[0] *= 100F; + v[0] -= new Vector3(0, 128F, 128F); + return input; + } + + private static unsafe Vector4 LabToPcs(Vector4 input, CieLab lab) + { + Vector3* v = (Vector3*)&input; + v[0] = new Vector3(lab.L, lab.A + 128F, lab.B + 128F); + v[0] /= 100F; + return input; + } + private readonly struct IccProfileConverterVisitor : IImageVisitor { private readonly IccProfile inputIccProfile; From 10bea860ecf42ea00a88c2b533a1a7149c894abf Mon Sep 17 00:00:00 2001 From: Brian Popow Date: Mon, 23 Jan 2023 20:00:14 +0100 Subject: [PATCH 34/42] Add ICC reader tests --- .../ICC/DataReader/IccDataReaderTests.cs | 5 +---- .../Metadata/Profiles/ICC/IccReaderTests.cs | 22 +++++++++++++++++++ 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataReader/IccDataReaderTests.cs b/tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataReader/IccDataReaderTests.cs index f2150cc03a..6f2e868c56 100644 --- a/tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataReader/IccDataReaderTests.cs +++ b/tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataReader/IccDataReaderTests.cs @@ -9,8 +9,5 @@ namespace SixLabors.ImageSharp.Tests.Metadata.Profiles.ICC.DataReader; public class IccDataReaderTests { [Fact] - public void ConstructorThrowsNullException() - { - Assert.Throws(() => new IccDataReader(null)); - } + public void ConstructorThrowsNullException() => Assert.Throws(() => new IccDataReader(null)); } diff --git a/tests/ImageSharp.Tests/Metadata/Profiles/ICC/IccReaderTests.cs b/tests/ImageSharp.Tests/Metadata/Profiles/ICC/IccReaderTests.cs index 78b3567872..2a80ae9e9c 100644 --- a/tests/ImageSharp.Tests/Metadata/Profiles/ICC/IccReaderTests.cs +++ b/tests/ImageSharp.Tests/Metadata/Profiles/ICC/IccReaderTests.cs @@ -2,6 +2,7 @@ // Licensed under the Six Labors Split License. using SixLabors.ImageSharp.Metadata.Profiles.Icc; +using SixLabors.ImageSharp.PixelFormats; using SixLabors.ImageSharp.Tests.TestDataIcc; namespace SixLabors.ImageSharp.Tests.Metadata.Profiles.Icc; @@ -9,6 +10,27 @@ namespace SixLabors.ImageSharp.Tests.Metadata.Profiles.Icc; [Trait("Profile", "Icc")] public class IccReaderTests { + [Theory] + [WithFile(TestImages.Jpeg.ICC.AdobeRgb, PixelTypes.Rgb24, 10, IccColorSpaceType.Rgb, IccColorSpaceType.CieXyz, 560)] + [WithFile(TestImages.Jpeg.ICC.AppleRGB, PixelTypes.Rgb24, 10, IccColorSpaceType.Rgb, IccColorSpaceType.CieXyz, 552)] + [WithFile(TestImages.Jpeg.ICC.ColorMatch, PixelTypes.Rgb24, 10, IccColorSpaceType.Rgb, IccColorSpaceType.CieXyz, 560)] + [WithFile(TestImages.Jpeg.ICC.WideRGB, PixelTypes.Rgb24, 10, IccColorSpaceType.Rgb, IccColorSpaceType.CieXyz, 560)] + [WithFile(TestImages.Jpeg.ICC.SRgb, PixelTypes.Rgb24, 17, IccColorSpaceType.Rgb, IccColorSpaceType.CieXyz, 3144)] + [WithFile(TestImages.Jpeg.ICC.ProPhoto, PixelTypes.Rgb24, 12, IccColorSpaceType.Rgb, IccColorSpaceType.CieXyz, 940)] + [WithFile(TestImages.Jpeg.ICC.CMYK, PixelTypes.Rgb24, 10, IccColorSpaceType.Cmyk, IccColorSpaceType.CieLab, 557168)] + public void ReadProfile_Works(TestImageProvider provider, int expectedEntries, IccColorSpaceType expectedDataColorSpace, IccColorSpaceType expectedConnectionSpace, uint expectedDataSize) + where TPixel : unmanaged, IPixel + { + using Image image = provider.GetImage(); + IccProfile profile = image.Metadata.IccProfile; + + Assert.NotNull(profile); + Assert.Equal(expectedEntries, profile.Entries.Length); + Assert.Equal(expectedDataColorSpace, profile.Header.DataColorSpace); + Assert.Equal(expectedConnectionSpace, profile.Header.ProfileConnectionSpace); + Assert.Equal(expectedDataSize, profile.Header.Size); + } + [Fact] public void ReadProfile_NoEntries() { From 5b131ade0bdc9d37218c3c79680609daf5121ea9 Mon Sep 17 00:00:00 2001 From: Brian Popow Date: Fri, 3 Feb 2023 13:52:38 +0100 Subject: [PATCH 35/42] Add reference output for issue-129 --- .../IccProfileConverterTests/CanConvertToSRGB_issue-129.png | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 tests/Images/External/ReferenceOutput/IccProfileConverterTests/CanConvertToSRGB_issue-129.png diff --git a/tests/Images/External/ReferenceOutput/IccProfileConverterTests/CanConvertToSRGB_issue-129.png b/tests/Images/External/ReferenceOutput/IccProfileConverterTests/CanConvertToSRGB_issue-129.png new file mode 100644 index 0000000000..52dd0e0f3a --- /dev/null +++ b/tests/Images/External/ReferenceOutput/IccProfileConverterTests/CanConvertToSRGB_issue-129.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:d423959ad2f5c9a3fc8df0ca1ff9b3d6d6751bb552cee65dbda29623581cb816 +size 2043144 From 3e06687f53d7dc4e50eafa71e781c98152cd392a Mon Sep 17 00:00:00 2001 From: James Jackson-South Date: Wed, 1 Nov 2023 19:02:47 +1000 Subject: [PATCH 36/42] Update IccReader.cs --- src/ImageSharp/Metadata/Profiles/ICC/IccReader.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/ImageSharp/Metadata/Profiles/ICC/IccReader.cs b/src/ImageSharp/Metadata/Profiles/ICC/IccReader.cs index 7898ca7a9f..45074c9a6e 100644 --- a/src/ImageSharp/Metadata/Profiles/ICC/IccReader.cs +++ b/src/ImageSharp/Metadata/Profiles/ICC/IccReader.cs @@ -83,6 +83,7 @@ private static IccTagDataEntry[] ReadTagData(IccDataReader reader) { IccTagTableEntry[] tagTable = ReadTagTable(reader); List entries = new(tagTable.Length); + Dictionary store = new(); foreach (IccTagTableEntry tag in tagTable) { @@ -102,6 +103,8 @@ private static IccTagDataEntry[] ReadTagData(IccDataReader reader) // Ignore tags that could not be read continue; } + + store.Add(tag.Offset, entry); } entry.TagSignature = tag.Signature; From c1ebbfedc165218cf82c35d90b43612cfab2ba83 Mon Sep 17 00:00:00 2001 From: James Jackson-South Date: Wed, 1 Nov 2023 19:12:55 +1000 Subject: [PATCH 37/42] Fix build --- .../Implementation/Icc/IccProfileConverter.cs | 2 +- .../Metadata/Profiles/ICC/Various/IccClut.cs | 2 +- .../Icc/Calculators/CurveCalculatorTests.cs | 27 +++++++++---------- .../Icc/Calculators/LutCalculatorTests.cs | 2 +- .../ParametricCurveCalculatorTests.cs | 2 +- 5 files changed, 17 insertions(+), 18 deletions(-) diff --git a/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/IccProfileConverter.cs b/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/IccProfileConverter.cs index 632ffa4f05..66ec0b4340 100644 --- a/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/IccProfileConverter.cs +++ b/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/IccProfileConverter.cs @@ -37,7 +37,7 @@ public static void Convert(Image image, IccProfile inputIccProfi { IccDataToPcsConverter converterDataToPcs = new(inputIccProfile); IccPcsToDataConverter converterPcsToData = new(outputIccProfile); - Configuration configuration = image.GetConfiguration(); + Configuration configuration = image.Configuration; image.ProcessPixelRows(accessor => { diff --git a/src/ImageSharp/Metadata/Profiles/ICC/Various/IccClut.cs b/src/ImageSharp/Metadata/Profiles/ICC/Various/IccClut.cs index 546da28767..bbec7ce43e 100644 --- a/src/ImageSharp/Metadata/Profiles/ICC/Various/IccClut.cs +++ b/src/ImageSharp/Metadata/Profiles/ICC/Various/IccClut.cs @@ -113,7 +113,7 @@ private void CheckValues() length += (int)Math.Pow(this.GridPointCount[i], this.InputChannelCount); } - // TODO: Disabled this check, not sure if this check is correct. + // TODO: Disabled this check, not sure if this check is correct. // Guard.IsTrue(this.Values.Length == length, nameof(this.Values), "Length of values array does not match the grid points"); } } diff --git a/tests/ImageSharp.Tests/Colorspaces/Icc/Calculators/CurveCalculatorTests.cs b/tests/ImageSharp.Tests/Colorspaces/Icc/Calculators/CurveCalculatorTests.cs index 65d41f2df6..7e8e49d47f 100644 --- a/tests/ImageSharp.Tests/Colorspaces/Icc/Calculators/CurveCalculatorTests.cs +++ b/tests/ImageSharp.Tests/Colorspaces/Icc/Calculators/CurveCalculatorTests.cs @@ -5,23 +5,22 @@ using SixLabors.ImageSharp.Metadata.Profiles.Icc; using SixLabors.ImageSharp.Tests.TestDataIcc.Conversion; -namespace SixLabors.ImageSharp.Tests.Colorspaces.Icc.Calculators +namespace SixLabors.ImageSharp.Tests.Colorspaces.Icc.Calculators; + +/// +/// Tests ICC +/// +[Trait("Color", "Conversion")] +public class CurveCalculatorTests { - /// - /// Tests ICC - /// - [Trait("Color", "Conversion")] - public class CurveCalculatorTests + [Theory] + [MemberData(nameof(IccConversionDataTrc.CurveConversionTestData), MemberType = typeof(IccConversionDataTrc))] + internal void CurveCalculator_WithCurveEntry_ReturnsResult(IccCurveTagDataEntry curve, bool inverted, float input, float expected) { - [Theory] - [MemberData(nameof(IccConversionDataTrc.CurveConversionTestData), MemberType = typeof(IccConversionDataTrc))] - internal void CurveCalculator_WithCurveEntry_ReturnsResult(IccCurveTagDataEntry curve, bool inverted, float input, float expected) - { - CurveCalculator calculator = new(curve, inverted); + CurveCalculator calculator = new(curve, inverted); - float result = calculator.Calculate(input); + float result = calculator.Calculate(input); - Assert.Equal(expected, result, 4); - } + Assert.Equal(expected, result, 4f); } } diff --git a/tests/ImageSharp.Tests/Colorspaces/Icc/Calculators/LutCalculatorTests.cs b/tests/ImageSharp.Tests/Colorspaces/Icc/Calculators/LutCalculatorTests.cs index 2c6317d605..bce04cf709 100644 --- a/tests/ImageSharp.Tests/Colorspaces/Icc/Calculators/LutCalculatorTests.cs +++ b/tests/ImageSharp.Tests/Colorspaces/Icc/Calculators/LutCalculatorTests.cs @@ -20,7 +20,7 @@ internal void LutCalculator_WithLut_ReturnsResult(float[] lut, bool inverted, fl float result = calculator.Calculate(input); - Assert.Equal(expected, result, 4); + Assert.Equal(expected, result, 4f); } } } diff --git a/tests/ImageSharp.Tests/Colorspaces/Icc/Calculators/ParametricCurveCalculatorTests.cs b/tests/ImageSharp.Tests/Colorspaces/Icc/Calculators/ParametricCurveCalculatorTests.cs index c2387613c9..5a7511ba06 100644 --- a/tests/ImageSharp.Tests/Colorspaces/Icc/Calculators/ParametricCurveCalculatorTests.cs +++ b/tests/ImageSharp.Tests/Colorspaces/Icc/Calculators/ParametricCurveCalculatorTests.cs @@ -21,7 +21,7 @@ internal void ParametricCurveCalculator_WithCurveEntry_ReturnsResult(IccParametr float result = calculator.Calculate(input); - Assert.Equal(expected, result, 4); + Assert.Equal(expected, result, 4f); } } } From d89d8c5b19cbbd3563b694ba67c2e804d2d24a5a Mon Sep 17 00:00:00 2001 From: James Jackson-South Date: Wed, 1 Nov 2023 19:21:17 +1000 Subject: [PATCH 38/42] Update IccReader.cs --- .../Metadata/Profiles/ICC/IccReader.cs | 21 ++++++------------- 1 file changed, 6 insertions(+), 15 deletions(-) diff --git a/src/ImageSharp/Metadata/Profiles/ICC/IccReader.cs b/src/ImageSharp/Metadata/Profiles/ICC/IccReader.cs index 45074c9a6e..074712d302 100644 --- a/src/ImageSharp/Metadata/Profiles/ICC/IccReader.cs +++ b/src/ImageSharp/Metadata/Profiles/ICC/IccReader.cs @@ -83,28 +83,19 @@ private static IccTagDataEntry[] ReadTagData(IccDataReader reader) { IccTagTableEntry[] tagTable = ReadTagTable(reader); List entries = new(tagTable.Length); - Dictionary store = new(); foreach (IccTagTableEntry tag in tagTable) { IccTagDataEntry entry; - if (store.TryGetValue(tag.Offset, out IccTagDataEntry? value)) + + try { - entry = value; + entry = reader.ReadTagDataEntry(tag); } - else + catch { - try - { - entry = reader.ReadTagDataEntry(tag); - } - catch - { - // Ignore tags that could not be read - continue; - } - - store.Add(tag.Offset, entry); + // Ignore tags that could not be read + continue; } entry.TagSignature = tag.Signature; From 63c89ca9da9668fe7c14634806befb533aad60f4 Mon Sep 17 00:00:00 2001 From: James Jackson-South Date: Wed, 1 Nov 2023 20:25:39 +1000 Subject: [PATCH 39/42] Use scaled Vector4 conversion and optimize --- .../Implementation/Icc/IccProfileConverter.cs | 15 +++++++-------- .../Colorspaces/Icc/IccProfileConverterTests.cs | 1 + 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/IccProfileConverter.cs b/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/IccProfileConverter.cs index 66ec0b4340..2c11b0bc43 100644 --- a/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/IccProfileConverter.cs +++ b/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/IccProfileConverter.cs @@ -41,6 +41,12 @@ public static void Convert(Image image, IccProfile inputIccProfi image.ProcessPixelRows(accessor => { + Vector3 illuminant = outputIccProfile.Header.PcsIlluminant; + ColorSpaceConverter converter = new(new ColorSpaceConverterOptions() + { + WhitePoint = new(illuminant), + }); + using IMemoryOwner vectors = configuration.MemoryAllocator.Allocate(accessor.Width); Span vectorsSpan = vectors.GetSpan(); for (int y = 0; y < accessor.Height; y++) @@ -51,7 +57,6 @@ public static void Convert(Image image, IccProfile inputIccProfi if (inputIccProfile.Header.ProfileConnectionSpace == IccColorSpaceType.CieLab && outputIccProfile.Header.ProfileConnectionSpace == IccColorSpaceType.CieXyz) { - ColorSpaceConverter converter = new(); for (int x = 0; x < vectorsSpan.Length; x++) { Vector4 pcs = converterDataToPcs.Calculate(vectorsSpan[x]); @@ -65,12 +70,6 @@ public static void Convert(Image image, IccProfile inputIccProfi else if (inputIccProfile.Header.ProfileConnectionSpace == IccColorSpaceType.CieXyz && outputIccProfile.Header.ProfileConnectionSpace == IccColorSpaceType.CieLab) { - Vector3 illuminant = outputIccProfile.Header.PcsIlluminant; - ColorSpaceConverter converter = new(new ColorSpaceConverterOptions() - { - WhitePoint = new(illuminant), - }); - for (int x = 0; x < vectorsSpan.Length; x++) { Vector4 pcs = converterDataToPcs.Calculate(vectorsSpan[x]); @@ -88,7 +87,7 @@ public static void Convert(Image image, IccProfile inputIccProfi } } - PixelOperations.Instance.FromVector4Destructive(configuration, vectorsSpan, row); + PixelOperations.Instance.FromVector4Destructive(configuration, vectorsSpan, row, PixelConversionModifiers.Scale); } }); diff --git a/tests/ImageSharp.Tests/Colorspaces/Icc/IccProfileConverterTests.cs b/tests/ImageSharp.Tests/Colorspaces/Icc/IccProfileConverterTests.cs index 2153f14201..1decff7712 100644 --- a/tests/ImageSharp.Tests/Colorspaces/Icc/IccProfileConverterTests.cs +++ b/tests/ImageSharp.Tests/Colorspaces/Icc/IccProfileConverterTests.cs @@ -34,6 +34,7 @@ public void CanRoundTripProfile(TestImageProvider provider) image.DebugSave(provider, extension: "png", appendPixelTypeToFileName: false, appendSourceFileOrDescription: true, encoder: Encoder); + // TODO: This is comparing the input image. It should compare the output. TPixel actual = image[0, 0]; Assert.Equal(expected, actual); From 3389d7af8f8c15ece19dba56b05945b8716c735a Mon Sep 17 00:00:00 2001 From: James Jackson-South Date: Thu, 9 Nov 2023 21:21:08 +1000 Subject: [PATCH 40/42] Add some debugging helpers to the converter --- .../Implementation/Icc/IccProfileConverter.cs | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/IccProfileConverter.cs b/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/IccProfileConverter.cs index 2c11b0bc43..671e9aa4c0 100644 --- a/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/IccProfileConverter.cs +++ b/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/IccProfileConverter.cs @@ -47,8 +47,15 @@ public static void Convert(Image image, IccProfile inputIccProfi WhitePoint = new(illuminant), }); + // TODO: Our Xxy/Lab conversion are dependent on the version number. We are applying the conversion using V4 + // but we should use the correct algorithm per version. This includes Lab/Lab Xyz/Xyz. using IMemoryOwner vectors = configuration.MemoryAllocator.Allocate(accessor.Width); Span vectorsSpan = vectors.GetSpan(); + + // TODO: For debugging - remove. + // It appears we have a scaling problem. The pcs values differ by on average 0.000001. + Span temp = new Vector4[vectorsSpan.Length]; + for (int y = 0; y < accessor.Height; y++) { Span row = accessor.GetRowSpan(y); @@ -60,9 +67,10 @@ public static void Convert(Image image, IccProfile inputIccProfi for (int x = 0; x < vectorsSpan.Length; x++) { Vector4 pcs = converterDataToPcs.Calculate(vectorsSpan[x]); + temp[x] = pcs; pcs = PcsToLab(pcs); CieXyz xyz = converter.ToCieXyz(new CieLab(pcs.X, pcs.Y, pcs.Z, new CieXyz(inputIccProfile.Header.PcsIlluminant))); - pcs = new Vector4(xyz.X, xyz.Y, xyz.Z, pcs.W); + pcs = XyzToPcs(pcs, xyz); vectorsSpan[x] = converterPcsToData.Calculate(pcs); } @@ -97,7 +105,7 @@ public static void Convert(Image image, IccProfile inputIccProfi private static unsafe Vector4 PcsToLab(Vector4 input) { Vector3* v = (Vector3*)&input; - v[0] *= 100F; + v[0] *= new Vector3(100f, 255, 255); v[0] -= new Vector3(0, 128F, 128F); return input; } @@ -110,6 +118,13 @@ private static unsafe Vector4 LabToPcs(Vector4 input, CieLab lab) return input; } + private static unsafe Vector4 XyzToPcs(Vector4 input, CieXyz xyz) + { + Vector3* v = (Vector3*)&input; + v[0] *= 32768 / 65535f; + return input; + } + private readonly struct IccProfileConverterVisitor : IImageVisitor { private readonly IccProfile inputIccProfile; From 5f975e528ded3423ee0e5523c627bc6d9b4ab7d8 Mon Sep 17 00:00:00 2001 From: James Jackson-South Date: Tue, 9 Jul 2024 16:28:00 +1000 Subject: [PATCH 41/42] Update to latest main build --- .../Icc/Calculators/ClutCalculator.cs | 48 +++++++++---------- .../Icc/Calculators/ColorTrcCalculator.cs | 2 +- .../CurveCalculator.CalculationType.cs | 0 .../Icc/Calculators/CurveCalculator.cs | 1 + .../Icc/Calculators/GrayTrcCalculator.cs | 2 +- .../Icc/Calculators/ISingleCalculator.cs | 2 +- .../Icc/Calculators/IVector4Calculator.cs | 2 +- .../LutABCalculator.CalculationType.cs | 0 .../Icc/Calculators/LutABCalculator.cs | 1 + .../Icc/Calculators/LutCalculator.cs | 2 +- .../Icc/Calculators/LutEntryCalculator.cs | 2 +- .../Icc/Calculators/MatrixCalculator.cs | 2 +- .../Calculators/ParametricCurveCalculator.cs | 2 +- .../Icc/Calculators/TrcCalculator.cs | 3 +- .../Icc/IccConverterBase.Checks.cs | 0 .../Icc/IccConverterBase.ConversionMethod.cs | 0 .../Icc/IccConverterbase.Conversions.cs | 12 ++--- .../Icc/IccConverterbase.cs | 0 .../Icc/IccDataToDataConverter.cs | 3 +- .../Icc/IccDataToPcsConverter.cs | 3 +- .../Icc/IccPcsToDataConverter.cs | 3 +- .../Icc/IccPcsToPcsConverter.cs | 3 +- .../Icc/IccProfileConverter.cs | 24 +++++----- .../Icc/SrgbV4Profile.Generated.cs | 0 src/ImageSharp/Formats/ImageDecoder.cs | 2 +- .../Icc/Calculators/ClutCalculatorTests.cs | 4 +- .../Icc/Calculators/CurveCalculatorTests.cs | 2 +- .../Icc/Calculators/LutABCalculatorTests.cs | 2 +- .../Icc/Calculators/LutCalculatorTests.cs | 4 +- .../Calculators/LutEntryCalculatorTests.cs | 4 +- .../Icc/Calculators/MatrixCalculatorTests.cs | 4 +- .../ParametricCurveCalculatorTests.cs | 4 +- .../Icc/Calculators/TrcCalculatorTests.cs | 4 +- .../Icc/IccProfileConverterTests.cs | 5 +- .../ImageSharp.Tests/ImageSharp.Tests.csproj | 4 ++ 35 files changed, 83 insertions(+), 73 deletions(-) rename src/ImageSharp/{ColorSpaces/Conversion/Implementation => ColorProfiles}/Icc/Calculators/ClutCalculator.cs (93%) rename src/ImageSharp/{ColorSpaces/Conversion/Implementation => ColorProfiles}/Icc/Calculators/ColorTrcCalculator.cs (96%) rename src/ImageSharp/{ColorSpaces/Conversion/Implementation => ColorProfiles}/Icc/Calculators/CurveCalculator.CalculationType.cs (100%) rename src/ImageSharp/{ColorSpaces/Conversion/Implementation => ColorProfiles}/Icc/Calculators/CurveCalculator.cs (96%) rename src/ImageSharp/{ColorSpaces/Conversion/Implementation => ColorProfiles}/Icc/Calculators/GrayTrcCalculator.cs (90%) rename src/ImageSharp/{ColorSpaces/Conversion/Implementation => ColorProfiles}/Icc/Calculators/ISingleCalculator.cs (87%) rename src/ImageSharp/{ColorSpaces/Conversion/Implementation => ColorProfiles}/Icc/Calculators/IVector4Calculator.cs (88%) rename src/ImageSharp/{ColorSpaces/Conversion/Implementation => ColorProfiles}/Icc/Calculators/LutABCalculator.CalculationType.cs (100%) rename src/ImageSharp/{ColorSpaces/Conversion/Implementation => ColorProfiles}/Icc/Calculators/LutABCalculator.cs (98%) rename src/ImageSharp/{ColorSpaces/Conversion/Implementation => ColorProfiles}/Icc/Calculators/LutCalculator.cs (96%) rename src/ImageSharp/{ColorSpaces/Conversion/Implementation => ColorProfiles}/Icc/Calculators/LutEntryCalculator.cs (97%) rename src/ImageSharp/{ColorSpaces/Conversion/Implementation => ColorProfiles}/Icc/Calculators/MatrixCalculator.cs (91%) rename src/ImageSharp/{ColorSpaces/Conversion/Implementation => ColorProfiles}/Icc/Calculators/ParametricCurveCalculator.cs (98%) rename src/ImageSharp/{ColorSpaces/Conversion/Implementation => ColorProfiles}/Icc/Calculators/TrcCalculator.cs (91%) rename src/ImageSharp/{ColorSpaces/Conversion/Implementation => ColorProfiles}/Icc/IccConverterBase.Checks.cs (100%) rename src/ImageSharp/{ColorSpaces/Conversion/Implementation => ColorProfiles}/Icc/IccConverterBase.ConversionMethod.cs (100%) rename src/ImageSharp/{ColorSpaces/Conversion/Implementation => ColorProfiles}/Icc/IccConverterbase.Conversions.cs (93%) rename src/ImageSharp/{ColorSpaces/Conversion/Implementation => ColorProfiles}/Icc/IccConverterbase.cs (100%) rename src/ImageSharp/{ColorSpaces/Conversion/Implementation => ColorProfiles}/Icc/IccDataToDataConverter.cs (85%) rename src/ImageSharp/{ColorSpaces/Conversion/Implementation => ColorProfiles}/Icc/IccDataToPcsConverter.cs (84%) rename src/ImageSharp/{ColorSpaces/Conversion/Implementation => ColorProfiles}/Icc/IccPcsToDataConverter.cs (84%) rename src/ImageSharp/{ColorSpaces/Conversion/Implementation => ColorProfiles}/Icc/IccPcsToPcsConverter.cs (83%) rename src/ImageSharp/{ColorSpaces/Conversion/Implementation => ColorProfiles}/Icc/IccProfileConverter.cs (85%) rename src/ImageSharp/{ColorSpaces/Conversion/Implementation => ColorProfiles}/Icc/SrgbV4Profile.Generated.cs (100%) rename tests/ImageSharp.Tests/{Colorspaces => ColorProfiles}/Icc/Calculators/ClutCalculatorTests.cs (85%) rename tests/ImageSharp.Tests/{Colorspaces => ColorProfiles}/Icc/Calculators/CurveCalculatorTests.cs (92%) rename tests/ImageSharp.Tests/{Colorspaces => ColorProfiles}/Icc/Calculators/LutABCalculatorTests.cs (95%) rename tests/ImageSharp.Tests/{Colorspaces => ColorProfiles}/Icc/Calculators/LutCalculatorTests.cs (85%) rename tests/ImageSharp.Tests/{Colorspaces => ColorProfiles}/Icc/Calculators/LutEntryCalculatorTests.cs (91%) rename tests/ImageSharp.Tests/{Colorspaces => ColorProfiles}/Icc/Calculators/MatrixCalculatorTests.cs (86%) rename tests/ImageSharp.Tests/{Colorspaces => ColorProfiles}/Icc/Calculators/ParametricCurveCalculatorTests.cs (87%) rename tests/ImageSharp.Tests/{Colorspaces => ColorProfiles}/Icc/Calculators/TrcCalculatorTests.cs (87%) rename tests/ImageSharp.Tests/{Colorspaces => ColorProfiles}/Icc/IccProfileConverterTests.cs (95%) diff --git a/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/ClutCalculator.cs b/src/ImageSharp/ColorProfiles/Icc/Calculators/ClutCalculator.cs similarity index 93% rename from src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/ClutCalculator.cs rename to src/ImageSharp/ColorProfiles/Icc/Calculators/ClutCalculator.cs index 5aa208ee6a..d809c26c61 100644 --- a/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/ClutCalculator.cs +++ b/src/ImageSharp/ColorProfiles/Icc/Calculators/ClutCalculator.cs @@ -4,7 +4,7 @@ using System.Numerics; using SixLabors.ImageSharp.Metadata.Profiles.Icc; -namespace SixLabors.ImageSharp.ColorSpaces.Conversion.Icc; +namespace SixLabors.ImageSharp.ColorProfiles.Icc.Calculators; /// /// Implements interpolation methods for color profile lookup tables. @@ -147,7 +147,7 @@ private int[] CalculateIndexFactor() this.nPower[count] = (uint)(1 << (this.inputCount - 1 - count)); } - uint[] nPower = { 0, 1 }; + uint[] nPower = [0, 1]; count = 0; int nFlag = 1; for (uint j = 1; j < this.nodeCount; j++) @@ -206,9 +206,7 @@ private unsafe void Interpolate1d(float* srcPixel, float* destPixel) int offset = 0; for (i = 0; i < this.outputCount; i++) { - float pv = (p[offset + this.n000] * dF0) + (p[offset + this.n001] * dF1); - - destPixel[i] = pv; + destPixel[i] = (float)((p[offset + this.n000] * dF0) + (p[offset + this.n001] * dF1)); offset++; } } @@ -259,9 +257,7 @@ private unsafe void Interpolate2d(float* srcPixel, float* destPixel) int offset = 0; for (i = 0; i < this.outputCount; i++) { - float pv = (p[offset + this.n000] * dF0) + (p[offset + this.n001] * dF1) + (p[offset + this.n010] * dF2) + (p[offset + this.n011] * dF3); - - destPixel[i] = pv; + destPixel[i] = (float)((p[offset + this.n000] * dF0) + (p[offset + this.n001] * dF1) + (p[offset + this.n010] * dF2) + (p[offset + this.n011] * dF3)); offset++; } } @@ -393,23 +389,25 @@ private unsafe void Interpolate4d(float* srcPixel, float* destPixel) Span p = this.lut.AsSpan((int)((iw * this.n001) + (ix * this.n010) + (iy * this.n100) + (iz * this.n1000))); // Normalize grid units. - float[] dF = new float[16]; - dF[0] = ns * nt * nu * nv; - dF[1] = ns * nt * nu * v; - dF[2] = ns * nt * u * nv; - dF[3] = ns * nt * u * v; - dF[4] = ns * t * nu * nv; - dF[5] = ns * t * nu * v; - dF[6] = ns * t * u * nv; - dF[7] = ns * t * u * v; - dF[8] = s * nt * nu * nv; - dF[9] = s * nt * nu * v; - dF[10] = s * nt * u * nv; - dF[11] = s * nt * u * v; - dF[12] = s * t * nu * nv; - dF[13] = s * t * nu * v; - dF[14] = s * t * u * nv; - dF[15] = s * t * u * v; + float[] dF = + [ + ns * nt * nu * nv, + ns * nt * nu * v, + ns * nt * u * nv, + ns * nt * u * v, + ns * t * nu * nv, + ns * t * nu * v, + ns * t * u * nv, + ns * t * u * v, + s * nt * nu * nv, + s * nt * nu * v, + s * nt * u * nv, + s * nt * u * v, + s * t * nu * nv, + s * t * nu * v, + s * t * u * nv, + s * t * u * v, + ]; int offset = 0; for (int i = 0; i < this.outputCount; i++) diff --git a/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/ColorTrcCalculator.cs b/src/ImageSharp/ColorProfiles/Icc/Calculators/ColorTrcCalculator.cs similarity index 96% rename from src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/ColorTrcCalculator.cs rename to src/ImageSharp/ColorProfiles/Icc/Calculators/ColorTrcCalculator.cs index ef557cc862..865deae422 100644 --- a/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/ColorTrcCalculator.cs +++ b/src/ImageSharp/ColorProfiles/Icc/Calculators/ColorTrcCalculator.cs @@ -5,7 +5,7 @@ using System.Runtime.CompilerServices; using SixLabors.ImageSharp.Metadata.Profiles.Icc; -namespace SixLabors.ImageSharp.ColorSpaces.Conversion.Icc; +namespace SixLabors.ImageSharp.ColorProfiles.Icc.Calculators; internal class ColorTrcCalculator : IVector4Calculator { diff --git a/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/CurveCalculator.CalculationType.cs b/src/ImageSharp/ColorProfiles/Icc/Calculators/CurveCalculator.CalculationType.cs similarity index 100% rename from src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/CurveCalculator.CalculationType.cs rename to src/ImageSharp/ColorProfiles/Icc/Calculators/CurveCalculator.CalculationType.cs diff --git a/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/CurveCalculator.cs b/src/ImageSharp/ColorProfiles/Icc/Calculators/CurveCalculator.cs similarity index 96% rename from src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/CurveCalculator.cs rename to src/ImageSharp/ColorProfiles/Icc/Calculators/CurveCalculator.cs index cb73f464d1..232f4349c2 100644 --- a/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/CurveCalculator.cs +++ b/src/ImageSharp/ColorProfiles/Icc/Calculators/CurveCalculator.cs @@ -2,6 +2,7 @@ // Licensed under the Six Labors Split License. #nullable disable +using SixLabors.ImageSharp.ColorProfiles.Icc.Calculators; using SixLabors.ImageSharp.Metadata.Profiles.Icc; namespace SixLabors.ImageSharp.ColorSpaces.Conversion.Icc; diff --git a/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/GrayTrcCalculator.cs b/src/ImageSharp/ColorProfiles/Icc/Calculators/GrayTrcCalculator.cs similarity index 90% rename from src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/GrayTrcCalculator.cs rename to src/ImageSharp/ColorProfiles/Icc/Calculators/GrayTrcCalculator.cs index 4df47950ec..8d823c1e95 100644 --- a/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/GrayTrcCalculator.cs +++ b/src/ImageSharp/ColorProfiles/Icc/Calculators/GrayTrcCalculator.cs @@ -5,7 +5,7 @@ using System.Runtime.CompilerServices; using SixLabors.ImageSharp.Metadata.Profiles.Icc; -namespace SixLabors.ImageSharp.ColorSpaces.Conversion.Icc; +namespace SixLabors.ImageSharp.ColorProfiles.Icc.Calculators; internal class GrayTrcCalculator : IVector4Calculator { diff --git a/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/ISingleCalculator.cs b/src/ImageSharp/ColorProfiles/Icc/Calculators/ISingleCalculator.cs similarity index 87% rename from src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/ISingleCalculator.cs rename to src/ImageSharp/ColorProfiles/Icc/Calculators/ISingleCalculator.cs index 3b4b4b51dd..ce9b7d2f9b 100644 --- a/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/ISingleCalculator.cs +++ b/src/ImageSharp/ColorProfiles/Icc/Calculators/ISingleCalculator.cs @@ -1,7 +1,7 @@ // Copyright (c) Six Labors. // Licensed under the Six Labors Split License. -namespace SixLabors.ImageSharp.ColorSpaces.Conversion.Icc; +namespace SixLabors.ImageSharp.ColorProfiles.Icc.Calculators; /// /// Represents an ICC calculator with a single floating point value and result diff --git a/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/IVector4Calculator.cs b/src/ImageSharp/ColorProfiles/Icc/Calculators/IVector4Calculator.cs similarity index 88% rename from src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/IVector4Calculator.cs rename to src/ImageSharp/ColorProfiles/Icc/Calculators/IVector4Calculator.cs index 5baa4666cb..9beea79503 100644 --- a/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/IVector4Calculator.cs +++ b/src/ImageSharp/ColorProfiles/Icc/Calculators/IVector4Calculator.cs @@ -3,7 +3,7 @@ using System.Numerics; -namespace SixLabors.ImageSharp.ColorSpaces.Conversion.Icc; +namespace SixLabors.ImageSharp.ColorProfiles.Icc.Calculators; /// /// Represents an ICC calculator with values and results diff --git a/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/LutABCalculator.CalculationType.cs b/src/ImageSharp/ColorProfiles/Icc/Calculators/LutABCalculator.CalculationType.cs similarity index 100% rename from src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/LutABCalculator.CalculationType.cs rename to src/ImageSharp/ColorProfiles/Icc/Calculators/LutABCalculator.CalculationType.cs diff --git a/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/LutABCalculator.cs b/src/ImageSharp/ColorProfiles/Icc/Calculators/LutABCalculator.cs similarity index 98% rename from src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/LutABCalculator.cs rename to src/ImageSharp/ColorProfiles/Icc/Calculators/LutABCalculator.cs index bc1cb73476..f891f66749 100644 --- a/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/LutABCalculator.cs +++ b/src/ImageSharp/ColorProfiles/Icc/Calculators/LutABCalculator.cs @@ -3,6 +3,7 @@ #nullable disable using System.Numerics; +using SixLabors.ImageSharp.ColorProfiles.Icc.Calculators; using SixLabors.ImageSharp.Metadata.Profiles.Icc; namespace SixLabors.ImageSharp.ColorSpaces.Conversion.Icc; diff --git a/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/LutCalculator.cs b/src/ImageSharp/ColorProfiles/Icc/Calculators/LutCalculator.cs similarity index 96% rename from src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/LutCalculator.cs rename to src/ImageSharp/ColorProfiles/Icc/Calculators/LutCalculator.cs index f15cc16588..824310b3ad 100644 --- a/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/LutCalculator.cs +++ b/src/ImageSharp/ColorProfiles/Icc/Calculators/LutCalculator.cs @@ -3,7 +3,7 @@ using System.Runtime.CompilerServices; -namespace SixLabors.ImageSharp.ColorSpaces.Conversion.Icc; +namespace SixLabors.ImageSharp.ColorProfiles.Icc.Calculators; internal class LutCalculator : ISingleCalculator { diff --git a/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/LutEntryCalculator.cs b/src/ImageSharp/ColorProfiles/Icc/Calculators/LutEntryCalculator.cs similarity index 97% rename from src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/LutEntryCalculator.cs rename to src/ImageSharp/ColorProfiles/Icc/Calculators/LutEntryCalculator.cs index 5d9d426fec..ea3d50ce79 100644 --- a/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/LutEntryCalculator.cs +++ b/src/ImageSharp/ColorProfiles/Icc/Calculators/LutEntryCalculator.cs @@ -6,7 +6,7 @@ using System.Runtime.CompilerServices; using SixLabors.ImageSharp.Metadata.Profiles.Icc; -namespace SixLabors.ImageSharp.ColorSpaces.Conversion.Icc; +namespace SixLabors.ImageSharp.ColorProfiles.Icc.Calculators; internal class LutEntryCalculator : IVector4Calculator { diff --git a/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/MatrixCalculator.cs b/src/ImageSharp/ColorProfiles/Icc/Calculators/MatrixCalculator.cs similarity index 91% rename from src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/MatrixCalculator.cs rename to src/ImageSharp/ColorProfiles/Icc/Calculators/MatrixCalculator.cs index 5997a9cdc8..6be1fdbf95 100644 --- a/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/MatrixCalculator.cs +++ b/src/ImageSharp/ColorProfiles/Icc/Calculators/MatrixCalculator.cs @@ -4,7 +4,7 @@ using System.Numerics; using System.Runtime.CompilerServices; -namespace SixLabors.ImageSharp.ColorSpaces.Conversion.Icc; +namespace SixLabors.ImageSharp.ColorProfiles.Icc.Calculators; internal class MatrixCalculator : IVector4Calculator { diff --git a/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/ParametricCurveCalculator.cs b/src/ImageSharp/ColorProfiles/Icc/Calculators/ParametricCurveCalculator.cs similarity index 98% rename from src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/ParametricCurveCalculator.cs rename to src/ImageSharp/ColorProfiles/Icc/Calculators/ParametricCurveCalculator.cs index b38c6ecdce..2a3945e270 100644 --- a/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/ParametricCurveCalculator.cs +++ b/src/ImageSharp/ColorProfiles/Icc/Calculators/ParametricCurveCalculator.cs @@ -4,7 +4,7 @@ using System.Runtime.CompilerServices; using SixLabors.ImageSharp.Metadata.Profiles.Icc; -namespace SixLabors.ImageSharp.ColorSpaces.Conversion.Icc; +namespace SixLabors.ImageSharp.ColorProfiles.Icc.Calculators; internal class ParametricCurveCalculator : ISingleCalculator { diff --git a/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/TrcCalculator.cs b/src/ImageSharp/ColorProfiles/Icc/Calculators/TrcCalculator.cs similarity index 91% rename from src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/TrcCalculator.cs rename to src/ImageSharp/ColorProfiles/Icc/Calculators/TrcCalculator.cs index a064610380..b4b5028ed7 100644 --- a/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/TrcCalculator.cs +++ b/src/ImageSharp/ColorProfiles/Icc/Calculators/TrcCalculator.cs @@ -3,9 +3,10 @@ using System.Numerics; using System.Runtime.CompilerServices; +using SixLabors.ImageSharp.ColorSpaces.Conversion.Icc; using SixLabors.ImageSharp.Metadata.Profiles.Icc; -namespace SixLabors.ImageSharp.ColorSpaces.Conversion.Icc; +namespace SixLabors.ImageSharp.ColorProfiles.Icc.Calculators; internal class TrcCalculator : IVector4Calculator { diff --git a/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/IccConverterBase.Checks.cs b/src/ImageSharp/ColorProfiles/Icc/IccConverterBase.Checks.cs similarity index 100% rename from src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/IccConverterBase.Checks.cs rename to src/ImageSharp/ColorProfiles/Icc/IccConverterBase.Checks.cs diff --git a/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/IccConverterBase.ConversionMethod.cs b/src/ImageSharp/ColorProfiles/Icc/IccConverterBase.ConversionMethod.cs similarity index 100% rename from src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/IccConverterBase.ConversionMethod.cs rename to src/ImageSharp/ColorProfiles/Icc/IccConverterBase.ConversionMethod.cs diff --git a/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/IccConverterbase.Conversions.cs b/src/ImageSharp/ColorProfiles/Icc/IccConverterbase.Conversions.cs similarity index 93% rename from src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/IccConverterbase.Conversions.cs rename to src/ImageSharp/ColorProfiles/Icc/IccConverterbase.Conversions.cs index 1a09390247..b67eccd03e 100644 --- a/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/IccConverterbase.Conversions.cs +++ b/src/ImageSharp/ColorProfiles/Icc/IccConverterbase.Conversions.cs @@ -1,6 +1,7 @@ // Copyright (c) Six Labors. // Licensed under the Six Labors Split License. +using SixLabors.ImageSharp.ColorProfiles.Icc.Calculators; using SixLabors.ImageSharp.Metadata.Profiles.Icc; namespace SixLabors.ImageSharp.ColorSpaces.Conversion.Icc; @@ -60,16 +61,13 @@ private static IVector4Calculator InitA(IccProfile profile, IccProfileTag tag) private static IVector4Calculator InitD(IccProfile profile, IccProfileTag tag) { - IccMultiProcessElementsTagDataEntry entry = GetTag(profile, tag); - if (entry == null) - { - throw new InvalidIccProfileException("Entry is null."); - } + IccMultiProcessElementsTagDataEntry entry = GetTag(profile, tag) + ?? throw new InvalidIccProfileException("Entry is null."); throw new NotImplementedException("Multi process elements are not supported"); } - private static IVector4Calculator InitColorTrc(IccProfile profile, bool toPcs) + private static ColorTrcCalculator InitColorTrc(IccProfile profile, bool toPcs) { IccXyzTagDataEntry redMatrixColumn = GetTag(profile, IccProfileTag.RedMatrixColumn); IccXyzTagDataEntry greenMatrixColumn = GetTag(profile, IccProfileTag.GreenMatrixColumn); @@ -99,7 +97,7 @@ private static IVector4Calculator InitColorTrc(IccProfile profile, bool toPcs) toPcs); } - private static IVector4Calculator InitGrayTrc(IccProfile profile, bool toPcs) + private static GrayTrcCalculator InitGrayTrc(IccProfile profile, bool toPcs) { IccTagDataEntry entry = GetTag(profile, IccProfileTag.GrayTrc); return new GrayTrcCalculator(entry, toPcs); diff --git a/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/IccConverterbase.cs b/src/ImageSharp/ColorProfiles/Icc/IccConverterbase.cs similarity index 100% rename from src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/IccConverterbase.cs rename to src/ImageSharp/ColorProfiles/Icc/IccConverterbase.cs diff --git a/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/IccDataToDataConverter.cs b/src/ImageSharp/ColorProfiles/Icc/IccDataToDataConverter.cs similarity index 85% rename from src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/IccDataToDataConverter.cs rename to src/ImageSharp/ColorProfiles/Icc/IccDataToDataConverter.cs index 86e73b54df..173948a6eb 100644 --- a/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/IccDataToDataConverter.cs +++ b/src/ImageSharp/ColorProfiles/Icc/IccDataToDataConverter.cs @@ -1,9 +1,10 @@ // Copyright (c) Six Labors. // Licensed under the Six Labors Split License. +using SixLabors.ImageSharp.ColorSpaces.Conversion.Icc; using SixLabors.ImageSharp.Metadata.Profiles.Icc; -namespace SixLabors.ImageSharp.ColorSpaces.Conversion.Icc; +namespace SixLabors.ImageSharp.ColorProfiles.Icc; /// /// Color converter for ICC profiles diff --git a/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/IccDataToPcsConverter.cs b/src/ImageSharp/ColorProfiles/Icc/IccDataToPcsConverter.cs similarity index 84% rename from src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/IccDataToPcsConverter.cs rename to src/ImageSharp/ColorProfiles/Icc/IccDataToPcsConverter.cs index 86ed81240b..d9e42a8d97 100644 --- a/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/IccDataToPcsConverter.cs +++ b/src/ImageSharp/ColorProfiles/Icc/IccDataToPcsConverter.cs @@ -1,9 +1,10 @@ // Copyright (c) Six Labors. // Licensed under the Six Labors Split License. +using SixLabors.ImageSharp.ColorSpaces.Conversion.Icc; using SixLabors.ImageSharp.Metadata.Profiles.Icc; -namespace SixLabors.ImageSharp.ColorSpaces.Conversion.Icc; +namespace SixLabors.ImageSharp.ColorProfiles.Icc; /// /// Color converter for ICC profiles diff --git a/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/IccPcsToDataConverter.cs b/src/ImageSharp/ColorProfiles/Icc/IccPcsToDataConverter.cs similarity index 84% rename from src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/IccPcsToDataConverter.cs rename to src/ImageSharp/ColorProfiles/Icc/IccPcsToDataConverter.cs index c38f7b64e0..d174529b65 100644 --- a/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/IccPcsToDataConverter.cs +++ b/src/ImageSharp/ColorProfiles/Icc/IccPcsToDataConverter.cs @@ -1,9 +1,10 @@ // Copyright (c) Six Labors. // Licensed under the Six Labors Split License. +using SixLabors.ImageSharp.ColorSpaces.Conversion.Icc; using SixLabors.ImageSharp.Metadata.Profiles.Icc; -namespace SixLabors.ImageSharp.ColorSpaces.Conversion.Icc; +namespace SixLabors.ImageSharp.ColorProfiles.Icc; /// /// Color converter for ICC profiles diff --git a/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/IccPcsToPcsConverter.cs b/src/ImageSharp/ColorProfiles/Icc/IccPcsToPcsConverter.cs similarity index 83% rename from src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/IccPcsToPcsConverter.cs rename to src/ImageSharp/ColorProfiles/Icc/IccPcsToPcsConverter.cs index 7d85203df5..98e069e401 100644 --- a/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/IccPcsToPcsConverter.cs +++ b/src/ImageSharp/ColorProfiles/Icc/IccPcsToPcsConverter.cs @@ -1,9 +1,10 @@ // Copyright (c) Six Labors. // Licensed under the Six Labors Split License. +using SixLabors.ImageSharp.ColorSpaces.Conversion.Icc; using SixLabors.ImageSharp.Metadata.Profiles.Icc; -namespace SixLabors.ImageSharp.ColorSpaces.Conversion.Icc; +namespace SixLabors.ImageSharp.ColorProfiles.Icc; /// /// Color converter for ICC profiles diff --git a/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/IccProfileConverter.cs b/src/ImageSharp/ColorProfiles/Icc/IccProfileConverter.cs similarity index 85% rename from src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/IccProfileConverter.cs rename to src/ImageSharp/ColorProfiles/Icc/IccProfileConverter.cs index 671e9aa4c0..6ce8178ded 100644 --- a/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/IccProfileConverter.cs +++ b/src/ImageSharp/ColorProfiles/Icc/IccProfileConverter.cs @@ -4,12 +4,11 @@ using System.Buffers; using System.Numerics; using SixLabors.ImageSharp.Advanced; -using SixLabors.ImageSharp.ColorSpaces.Conversion.Icc; using SixLabors.ImageSharp.Memory; using SixLabors.ImageSharp.Metadata.Profiles.Icc; using SixLabors.ImageSharp.PixelFormats; -namespace SixLabors.ImageSharp.ColorSpaces.Conversion.Implementation.Icc; +namespace SixLabors.ImageSharp.ColorProfiles.Icc; /// /// Allows the conversion between ICC profiles. @@ -41,10 +40,10 @@ public static void Convert(Image image, IccProfile inputIccProfi image.ProcessPixelRows(accessor => { - Vector3 illuminant = outputIccProfile.Header.PcsIlluminant; - ColorSpaceConverter converter = new(new ColorSpaceConverterOptions() + ColorProfileConverter converter = new(new ColorConversionOptions() { - WhitePoint = new(illuminant), + WhitePoint = new CieXyz(inputIccProfile.Header.PcsIlluminant), + TargetWhitePoint = new CieXyz(outputIccProfile.Header.PcsIlluminant), }); // TODO: Our Xxy/Lab conversion are dependent on the version number. We are applying the conversion using V4 @@ -61,27 +60,29 @@ public static void Convert(Image image, IccProfile inputIccProfi Span row = accessor.GetRowSpan(y); PixelOperations.Instance.ToVector4(configuration, row, vectorsSpan, PixelConversionModifiers.Scale); - if (inputIccProfile.Header.ProfileConnectionSpace == IccColorSpaceType.CieLab - && outputIccProfile.Header.ProfileConnectionSpace == IccColorSpaceType.CieXyz) + if (inputIccProfile.Header.ProfileConnectionSpace == IccColorSpaceType.CieLab && + outputIccProfile.Header.ProfileConnectionSpace == IccColorSpaceType.CieXyz) { for (int x = 0; x < vectorsSpan.Length; x++) { Vector4 pcs = converterDataToPcs.Calculate(vectorsSpan[x]); temp[x] = pcs; pcs = PcsToLab(pcs); - CieXyz xyz = converter.ToCieXyz(new CieLab(pcs.X, pcs.Y, pcs.Z, new CieXyz(inputIccProfile.Header.PcsIlluminant))); + CieLab lab = new(pcs.X, pcs.Y, pcs.Z); + CieXyz xyz = converter.Convert(in lab); pcs = XyzToPcs(pcs, xyz); vectorsSpan[x] = converterPcsToData.Calculate(pcs); } } - else if (inputIccProfile.Header.ProfileConnectionSpace == IccColorSpaceType.CieXyz - && outputIccProfile.Header.ProfileConnectionSpace == IccColorSpaceType.CieLab) + else if (inputIccProfile.Header.ProfileConnectionSpace == IccColorSpaceType.CieXyz && + outputIccProfile.Header.ProfileConnectionSpace == IccColorSpaceType.CieLab) { for (int x = 0; x < vectorsSpan.Length; x++) { Vector4 pcs = converterDataToPcs.Calculate(vectorsSpan[x]); - CieLab lab = converter.ToCieLab(new CieXyz(pcs.X, pcs.Y, pcs.Z)); + CieXyz xyz = new(pcs.X, pcs.Y, pcs.Z); + CieLab lab = converter.Convert(in xyz); pcs = LabToPcs(pcs, lab); vectorsSpan[x] = converterPcsToData.Calculate(pcs); } @@ -121,6 +122,7 @@ private static unsafe Vector4 LabToPcs(Vector4 input, CieLab lab) private static unsafe Vector4 XyzToPcs(Vector4 input, CieXyz xyz) { Vector3* v = (Vector3*)&input; + v[0] = xyz.ToVector3(); v[0] *= 32768 / 65535f; return input; } diff --git a/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/SrgbV4Profile.Generated.cs b/src/ImageSharp/ColorProfiles/Icc/SrgbV4Profile.Generated.cs similarity index 100% rename from src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/SrgbV4Profile.Generated.cs rename to src/ImageSharp/ColorProfiles/Icc/SrgbV4Profile.Generated.cs diff --git a/src/ImageSharp/Formats/ImageDecoder.cs b/src/ImageSharp/Formats/ImageDecoder.cs index af999e77d7..721fb2ec35 100644 --- a/src/ImageSharp/Formats/ImageDecoder.cs +++ b/src/ImageSharp/Formats/ImageDecoder.cs @@ -1,8 +1,8 @@ // Copyright (c) Six Labors. // Licensed under the Six Labors Split License. +using SixLabors.ImageSharp.ColorProfiles.Icc; using SixLabors.ImageSharp.ColorSpaces.Conversion.Icc; -using SixLabors.ImageSharp.ColorSpaces.Conversion.Implementation.Icc; using SixLabors.ImageSharp.IO; using SixLabors.ImageSharp.Metadata.Profiles.Icc; using SixLabors.ImageSharp.PixelFormats; diff --git a/tests/ImageSharp.Tests/Colorspaces/Icc/Calculators/ClutCalculatorTests.cs b/tests/ImageSharp.Tests/ColorProfiles/Icc/Calculators/ClutCalculatorTests.cs similarity index 85% rename from tests/ImageSharp.Tests/Colorspaces/Icc/Calculators/ClutCalculatorTests.cs rename to tests/ImageSharp.Tests/ColorProfiles/Icc/Calculators/ClutCalculatorTests.cs index 9ca24f8b1d..249e7f4ed1 100644 --- a/tests/ImageSharp.Tests/Colorspaces/Icc/Calculators/ClutCalculatorTests.cs +++ b/tests/ImageSharp.Tests/ColorProfiles/Icc/Calculators/ClutCalculatorTests.cs @@ -2,11 +2,11 @@ // Licensed under the Six Labors Split License. using System.Numerics; -using SixLabors.ImageSharp.ColorSpaces.Conversion.Icc; +using SixLabors.ImageSharp.ColorProfiles.Icc.Calculators; using SixLabors.ImageSharp.Metadata.Profiles.Icc; using SixLabors.ImageSharp.Tests.TestDataIcc.Conversion; -namespace SixLabors.ImageSharp.Tests.Colorspaces.Icc.Calculators; +namespace SixLabors.ImageSharp.Tests.ColorProfiles.Icc.Calculators; /// /// Tests ICC diff --git a/tests/ImageSharp.Tests/Colorspaces/Icc/Calculators/CurveCalculatorTests.cs b/tests/ImageSharp.Tests/ColorProfiles/Icc/Calculators/CurveCalculatorTests.cs similarity index 92% rename from tests/ImageSharp.Tests/Colorspaces/Icc/Calculators/CurveCalculatorTests.cs rename to tests/ImageSharp.Tests/ColorProfiles/Icc/Calculators/CurveCalculatorTests.cs index 7e8e49d47f..0608637619 100644 --- a/tests/ImageSharp.Tests/Colorspaces/Icc/Calculators/CurveCalculatorTests.cs +++ b/tests/ImageSharp.Tests/ColorProfiles/Icc/Calculators/CurveCalculatorTests.cs @@ -5,7 +5,7 @@ using SixLabors.ImageSharp.Metadata.Profiles.Icc; using SixLabors.ImageSharp.Tests.TestDataIcc.Conversion; -namespace SixLabors.ImageSharp.Tests.Colorspaces.Icc.Calculators; +namespace SixLabors.ImageSharp.Tests.ColorProfiles.Icc.Calculators; /// /// Tests ICC diff --git a/tests/ImageSharp.Tests/Colorspaces/Icc/Calculators/LutABCalculatorTests.cs b/tests/ImageSharp.Tests/ColorProfiles/Icc/Calculators/LutABCalculatorTests.cs similarity index 95% rename from tests/ImageSharp.Tests/Colorspaces/Icc/Calculators/LutABCalculatorTests.cs rename to tests/ImageSharp.Tests/ColorProfiles/Icc/Calculators/LutABCalculatorTests.cs index 4b0ec9af1a..5be984b4b9 100644 --- a/tests/ImageSharp.Tests/Colorspaces/Icc/Calculators/LutABCalculatorTests.cs +++ b/tests/ImageSharp.Tests/ColorProfiles/Icc/Calculators/LutABCalculatorTests.cs @@ -6,7 +6,7 @@ using SixLabors.ImageSharp.Metadata.Profiles.Icc; using SixLabors.ImageSharp.Tests.TestDataIcc.Conversion; -namespace SixLabors.ImageSharp.Tests.Colorspaces.Icc.Calculators +namespace SixLabors.ImageSharp.Tests.ColorProfiles.Icc.Calculators { /// /// Tests ICC diff --git a/tests/ImageSharp.Tests/Colorspaces/Icc/Calculators/LutCalculatorTests.cs b/tests/ImageSharp.Tests/ColorProfiles/Icc/Calculators/LutCalculatorTests.cs similarity index 85% rename from tests/ImageSharp.Tests/Colorspaces/Icc/Calculators/LutCalculatorTests.cs rename to tests/ImageSharp.Tests/ColorProfiles/Icc/Calculators/LutCalculatorTests.cs index bce04cf709..d5d2736f71 100644 --- a/tests/ImageSharp.Tests/Colorspaces/Icc/Calculators/LutCalculatorTests.cs +++ b/tests/ImageSharp.Tests/ColorProfiles/Icc/Calculators/LutCalculatorTests.cs @@ -1,10 +1,10 @@ // Copyright (c) Six Labors. // Licensed under the Six Labors Split License. -using SixLabors.ImageSharp.ColorSpaces.Conversion.Icc; +using SixLabors.ImageSharp.ColorProfiles.Icc.Calculators; using SixLabors.ImageSharp.Tests.TestDataIcc.Conversion; -namespace SixLabors.ImageSharp.Tests.Colorspaces.Icc.Calculators +namespace SixLabors.ImageSharp.Tests.ColorProfiles.Icc.Calculators { /// /// Tests ICC diff --git a/tests/ImageSharp.Tests/Colorspaces/Icc/Calculators/LutEntryCalculatorTests.cs b/tests/ImageSharp.Tests/ColorProfiles/Icc/Calculators/LutEntryCalculatorTests.cs similarity index 91% rename from tests/ImageSharp.Tests/Colorspaces/Icc/Calculators/LutEntryCalculatorTests.cs rename to tests/ImageSharp.Tests/ColorProfiles/Icc/Calculators/LutEntryCalculatorTests.cs index e275b66634..0493521140 100644 --- a/tests/ImageSharp.Tests/Colorspaces/Icc/Calculators/LutEntryCalculatorTests.cs +++ b/tests/ImageSharp.Tests/ColorProfiles/Icc/Calculators/LutEntryCalculatorTests.cs @@ -2,11 +2,11 @@ // Licensed under the Six Labors Split License. using System.Numerics; -using SixLabors.ImageSharp.ColorSpaces.Conversion.Icc; +using SixLabors.ImageSharp.ColorProfiles.Icc.Calculators; using SixLabors.ImageSharp.Metadata.Profiles.Icc; using SixLabors.ImageSharp.Tests.TestDataIcc.Conversion; -namespace SixLabors.ImageSharp.Tests.Colorspaces.Icc.Calculators +namespace SixLabors.ImageSharp.Tests.ColorProfiles.Icc.Calculators { /// /// Tests ICC diff --git a/tests/ImageSharp.Tests/Colorspaces/Icc/Calculators/MatrixCalculatorTests.cs b/tests/ImageSharp.Tests/ColorProfiles/Icc/Calculators/MatrixCalculatorTests.cs similarity index 86% rename from tests/ImageSharp.Tests/Colorspaces/Icc/Calculators/MatrixCalculatorTests.cs rename to tests/ImageSharp.Tests/ColorProfiles/Icc/Calculators/MatrixCalculatorTests.cs index 1770b2e9fb..22b25b84d1 100644 --- a/tests/ImageSharp.Tests/Colorspaces/Icc/Calculators/MatrixCalculatorTests.cs +++ b/tests/ImageSharp.Tests/ColorProfiles/Icc/Calculators/MatrixCalculatorTests.cs @@ -2,10 +2,10 @@ // Licensed under the Six Labors Split License. using System.Numerics; -using SixLabors.ImageSharp.ColorSpaces.Conversion.Icc; +using SixLabors.ImageSharp.ColorProfiles.Icc.Calculators; using SixLabors.ImageSharp.Tests.TestDataIcc.Conversion; -namespace SixLabors.ImageSharp.Tests.Colorspaces.Icc.Calculators +namespace SixLabors.ImageSharp.Tests.ColorProfiles.Icc.Calculators { /// /// Tests ICC diff --git a/tests/ImageSharp.Tests/Colorspaces/Icc/Calculators/ParametricCurveCalculatorTests.cs b/tests/ImageSharp.Tests/ColorProfiles/Icc/Calculators/ParametricCurveCalculatorTests.cs similarity index 87% rename from tests/ImageSharp.Tests/Colorspaces/Icc/Calculators/ParametricCurveCalculatorTests.cs rename to tests/ImageSharp.Tests/ColorProfiles/Icc/Calculators/ParametricCurveCalculatorTests.cs index 5a7511ba06..ca3608b8cf 100644 --- a/tests/ImageSharp.Tests/Colorspaces/Icc/Calculators/ParametricCurveCalculatorTests.cs +++ b/tests/ImageSharp.Tests/ColorProfiles/Icc/Calculators/ParametricCurveCalculatorTests.cs @@ -1,11 +1,11 @@ // Copyright (c) Six Labors. // Licensed under the Six Labors Split License. -using SixLabors.ImageSharp.ColorSpaces.Conversion.Icc; +using SixLabors.ImageSharp.ColorProfiles.Icc.Calculators; using SixLabors.ImageSharp.Metadata.Profiles.Icc; using SixLabors.ImageSharp.Tests.TestDataIcc.Conversion; -namespace SixLabors.ImageSharp.Tests.Colorspaces.Icc.Calculators +namespace SixLabors.ImageSharp.Tests.ColorProfiles.Icc.Calculators { /// /// Tests ICC diff --git a/tests/ImageSharp.Tests/Colorspaces/Icc/Calculators/TrcCalculatorTests.cs b/tests/ImageSharp.Tests/ColorProfiles/Icc/Calculators/TrcCalculatorTests.cs similarity index 87% rename from tests/ImageSharp.Tests/Colorspaces/Icc/Calculators/TrcCalculatorTests.cs rename to tests/ImageSharp.Tests/ColorProfiles/Icc/Calculators/TrcCalculatorTests.cs index 4029cc326d..d86e32453d 100644 --- a/tests/ImageSharp.Tests/Colorspaces/Icc/Calculators/TrcCalculatorTests.cs +++ b/tests/ImageSharp.Tests/ColorProfiles/Icc/Calculators/TrcCalculatorTests.cs @@ -2,11 +2,11 @@ // Licensed under the Six Labors Split License. using System.Numerics; -using SixLabors.ImageSharp.ColorSpaces.Conversion.Icc; +using SixLabors.ImageSharp.ColorProfiles.Icc.Calculators; using SixLabors.ImageSharp.Metadata.Profiles.Icc; using SixLabors.ImageSharp.Tests.TestDataIcc.Conversion; -namespace SixLabors.ImageSharp.Tests.Colorspaces.Icc.Calculators +namespace SixLabors.ImageSharp.Tests.ColorProfiles.Icc.Calculators { /// /// Tests ICC diff --git a/tests/ImageSharp.Tests/Colorspaces/Icc/IccProfileConverterTests.cs b/tests/ImageSharp.Tests/ColorProfiles/Icc/IccProfileConverterTests.cs similarity index 95% rename from tests/ImageSharp.Tests/Colorspaces/Icc/IccProfileConverterTests.cs rename to tests/ImageSharp.Tests/ColorProfiles/Icc/IccProfileConverterTests.cs index 1decff7712..84549c0ee4 100644 --- a/tests/ImageSharp.Tests/Colorspaces/Icc/IccProfileConverterTests.cs +++ b/tests/ImageSharp.Tests/ColorProfiles/Icc/IccProfileConverterTests.cs @@ -1,14 +1,15 @@ // Copyright (c) Six Labors. // Licensed under the Six Labors Split License. +using SixLabors.ImageSharp.ColorProfiles.Icc; using SixLabors.ImageSharp.ColorSpaces.Conversion.Icc; -using SixLabors.ImageSharp.ColorSpaces.Conversion.Implementation.Icc; using SixLabors.ImageSharp.Formats.Png; using SixLabors.ImageSharp.Metadata.Profiles.Icc; using SixLabors.ImageSharp.PixelFormats; using SixLabors.ImageSharp.Tests.TestUtilities.ImageComparison; -namespace SixLabors.ImageSharp.Tests.Colorspaces.Icc; +namespace SixLabors.ImageSharp.Tests.ColorProfiles.Icc; + public class IccProfileConverterTests { private static readonly PngEncoder Encoder = new(); diff --git a/tests/ImageSharp.Tests/ImageSharp.Tests.csproj b/tests/ImageSharp.Tests/ImageSharp.Tests.csproj index 41e6e525f8..f59da8361c 100644 --- a/tests/ImageSharp.Tests/ImageSharp.Tests.csproj +++ b/tests/ImageSharp.Tests/ImageSharp.Tests.csproj @@ -80,5 +80,9 @@ + + + + From 79f5dfa3e3f987b697e2a229898e49ad9e61fcdb Mon Sep 17 00:00:00 2001 From: James Jackson-South Date: Tue, 9 Jul 2024 16:29:57 +1000 Subject: [PATCH 42/42] Update IccProfileConverterTests.cs --- .../ColorProfiles/Icc/IccProfileConverterTests.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/ImageSharp.Tests/ColorProfiles/Icc/IccProfileConverterTests.cs b/tests/ImageSharp.Tests/ColorProfiles/Icc/IccProfileConverterTests.cs index 84549c0ee4..00f1c5f9b7 100644 --- a/tests/ImageSharp.Tests/ColorProfiles/Icc/IccProfileConverterTests.cs +++ b/tests/ImageSharp.Tests/ColorProfiles/Icc/IccProfileConverterTests.cs @@ -35,7 +35,6 @@ public void CanRoundTripProfile(TestImageProvider provider) image.DebugSave(provider, extension: "png", appendPixelTypeToFileName: false, appendSourceFileOrDescription: true, encoder: Encoder); - // TODO: This is comparing the input image. It should compare the output. TPixel actual = image[0, 0]; Assert.Equal(expected, actual);