diff --git a/tests/ImageSharp.Tests/MetaData/Profiles/ICC/DataReader/IccDataReader.CurvesTests.cs b/tests/ImageSharp.Tests/MetaData/Profiles/ICC/DataReader/IccDataReader.CurvesTests.cs
new file mode 100644
index 000000000..2bde12543
--- /dev/null
+++ b/tests/ImageSharp.Tests/MetaData/Profiles/ICC/DataReader/IccDataReader.CurvesTests.cs
@@ -0,0 +1,83 @@
+//
+// Copyright (c) James Jackson-South and contributors.
+// Licensed under the Apache License, Version 2.0.
+//
+
+namespace ImageSharp.Tests.Icc
+{
+ using Xunit;
+
+ public class IccDataReaderCurvesTests
+ {
+ [Theory]
+ [MemberData(nameof(IccTestDataCurves.OneDimensionalCurveTestData), MemberType = typeof(IccTestDataCurves))]
+ internal void ReadOneDimensionalCurve(byte[] data, IccOneDimensionalCurve expected)
+ {
+ IccDataReader reader = CreateReader(data);
+
+ IccOneDimensionalCurve output = reader.ReadOneDimensionalCurve();
+
+ Assert.Equal(expected, output);
+ }
+
+ [Theory]
+ [MemberData(nameof(IccTestDataCurves.ResponseCurveTestData), MemberType = typeof(IccTestDataCurves))]
+ internal void ReadResponseCurve(byte[] data, IccResponseCurve expected, int channelCount)
+ {
+ IccDataReader reader = CreateReader(data);
+
+ IccResponseCurve output = reader.ReadResponseCurve(channelCount);
+
+ Assert.Equal(expected, output);
+ }
+
+ [Theory]
+ [MemberData(nameof(IccTestDataCurves.ParametricCurveTestData), MemberType = typeof(IccTestDataCurves))]
+ internal void ReadParametricCurve(byte[] data, IccParametricCurve expected)
+ {
+ IccDataReader reader = CreateReader(data);
+
+ IccParametricCurve output = reader.ReadParametricCurve();
+
+ Assert.Equal(expected, output);
+ }
+
+ [Theory]
+ [MemberData(nameof(IccTestDataCurves.CurveSegmentTestData), MemberType = typeof(IccTestDataCurves))]
+ internal void ReadCurveSegment(byte[] data, IccCurveSegment expected)
+ {
+ IccDataReader reader = CreateReader(data);
+
+ IccCurveSegment output = reader.ReadCurveSegment();
+
+ Assert.Equal(expected, output);
+ }
+
+ [Theory]
+ [MemberData(nameof(IccTestDataCurves.FormulaCurveSegmentTestData), MemberType = typeof(IccTestDataCurves))]
+ internal void ReadFormulaCurveElement(byte[] data, IccFormulaCurveElement expected)
+ {
+ IccDataReader reader = CreateReader(data);
+
+ IccFormulaCurveElement output = reader.ReadFormulaCurveElement();
+
+ Assert.Equal(expected, output);
+ }
+
+ [Theory]
+ [MemberData(nameof(IccTestDataCurves.SampledCurveSegmentTestData), MemberType = typeof(IccTestDataCurves))]
+ internal void ReadSampledCurveElement(byte[] data, IccSampledCurveElement expected)
+ {
+ IccDataReader reader = CreateReader(data);
+
+ IccSampledCurveElement output = reader.ReadSampledCurveElement();
+
+ Assert.Equal(expected, output);
+ }
+
+ private IccDataReader CreateReader(byte[] data)
+ {
+ return new IccDataReader(data);
+ }
+ }
+}
diff --git a/tests/ImageSharp.Tests/MetaData/Profiles/ICC/DataReader/IccDataReader.LutTests.cs b/tests/ImageSharp.Tests/MetaData/Profiles/ICC/DataReader/IccDataReader.LutTests.cs
new file mode 100644
index 000000000..52c67ba53
--- /dev/null
+++ b/tests/ImageSharp.Tests/MetaData/Profiles/ICC/DataReader/IccDataReader.LutTests.cs
@@ -0,0 +1,83 @@
+//
+// Copyright (c) James Jackson-South and contributors.
+// Licensed under the Apache License, Version 2.0.
+//
+
+namespace ImageSharp.Tests.Icc
+{
+ using Xunit;
+
+ public class IccDataReaderLutTests
+ {
+ [Theory]
+ [MemberData(nameof(IccTestDataLut.ClutTestData), MemberType = typeof(IccTestDataLut))]
+ internal void ReadClut(byte[] data, IccClut expected, int inChannelCount, int outChannelCount, bool isFloat)
+ {
+ IccDataReader reader = CreateReader(data);
+
+ IccClut output = reader.ReadClut(inChannelCount, outChannelCount, isFloat);
+
+ Assert.Equal(expected, output);
+ }
+
+ [Theory]
+ [MemberData(nameof(IccTestDataLut.Clut8TestData), MemberType = typeof(IccTestDataLut))]
+ internal void ReadClut8(byte[] data, IccClut expected, int inChannelCount, int outChannelCount, byte[] gridPointCount)
+ {
+ IccDataReader reader = CreateReader(data);
+
+ IccClut output = reader.ReadClut8(inChannelCount, outChannelCount, gridPointCount);
+
+ Assert.Equal(expected, output);
+ }
+
+ [Theory]
+ [MemberData(nameof(IccTestDataLut.Clut16TestData), MemberType = typeof(IccTestDataLut))]
+ internal void ReadClut16(byte[] data, IccClut expected, int inChannelCount, int outChannelCount, byte[] gridPointCount)
+ {
+ IccDataReader reader = CreateReader(data);
+
+ IccClut output = reader.ReadClut16(inChannelCount, outChannelCount, gridPointCount);
+
+ Assert.Equal(expected, output);
+ }
+
+ [Theory]
+ [MemberData(nameof(IccTestDataLut.ClutF32TestData), MemberType = typeof(IccTestDataLut))]
+ internal void ReadClutF32(byte[] data, IccClut expected, int inChannelCount, int outChannelCount, byte[] gridPointCount)
+ {
+ IccDataReader reader = CreateReader(data);
+
+ IccClut output = reader.ReadClutF32(inChannelCount, outChannelCount, gridPointCount);
+
+ Assert.Equal(expected, output);
+ }
+
+ [Theory]
+ [MemberData(nameof(IccTestDataLut.Lut8TestData), MemberType = typeof(IccTestDataLut))]
+ internal void ReadLut8(byte[] data, IccLut expected)
+ {
+ IccDataReader reader = CreateReader(data);
+
+ IccLut output = reader.ReadLut8();
+
+ Assert.Equal(expected, output);
+ }
+
+ [Theory]
+ [MemberData(nameof(IccTestDataLut.Lut16TestData), MemberType = typeof(IccTestDataLut))]
+ internal void ReadLut16(byte[] data, IccLut expected, int count)
+ {
+ IccDataReader reader = CreateReader(data);
+
+ IccLut output = reader.ReadLut16(count);
+
+ Assert.Equal(expected, output);
+ }
+
+ private IccDataReader CreateReader(byte[] data)
+ {
+ return new IccDataReader(data);
+ }
+ }
+}
diff --git a/tests/ImageSharp.Tests/MetaData/Profiles/ICC/DataReader/IccDataReader.MatrixTests.cs b/tests/ImageSharp.Tests/MetaData/Profiles/ICC/DataReader/IccDataReader.MatrixTests.cs
new file mode 100644
index 000000000..9d148ec94
--- /dev/null
+++ b/tests/ImageSharp.Tests/MetaData/Profiles/ICC/DataReader/IccDataReader.MatrixTests.cs
@@ -0,0 +1,39 @@
+//
+// Copyright (c) James Jackson-South and contributors.
+// Licensed under the Apache License, Version 2.0.
+//
+
+namespace ImageSharp.Tests.Icc
+{
+ using Xunit;
+
+ public class IccDataReaderMatrixTests
+ {
+ [Theory]
+ [MemberData(nameof(IccTestDataMatrix.Matrix2D_FloatArrayTestData), MemberType = typeof(IccTestDataMatrix))]
+ public void ReadMatrix2D(byte[] data, int xCount, int yCount, bool isSingle, float[,] expected)
+ {
+ IccDataReader reader = CreateReader(data);
+
+ float[,] output = reader.ReadMatrix(xCount, yCount, isSingle);
+
+ Assert.Equal(expected, output);
+ }
+
+ [Theory]
+ [MemberData(nameof(IccTestDataMatrix.Matrix1D_ArrayTestData), MemberType = typeof(IccTestDataMatrix))]
+ public void ReadMatrix1D(byte[] data, int yCount, bool isSingle, float[] expected)
+ {
+ IccDataReader reader = CreateReader(data);
+
+ float[] output = reader.ReadMatrix(yCount, isSingle);
+
+ Assert.Equal(expected, output);
+ }
+
+ private IccDataReader CreateReader(byte[] data)
+ {
+ return new IccDataReader(data);
+ }
+ }
+}
diff --git a/tests/ImageSharp.Tests/MetaData/Profiles/ICC/DataReader/IccDataReader.MultiProcessElementTests.cs b/tests/ImageSharp.Tests/MetaData/Profiles/ICC/DataReader/IccDataReader.MultiProcessElementTests.cs
new file mode 100644
index 000000000..c02ef40e3
--- /dev/null
+++ b/tests/ImageSharp.Tests/MetaData/Profiles/ICC/DataReader/IccDataReader.MultiProcessElementTests.cs
@@ -0,0 +1,61 @@
+//
+// Copyright (c) James Jackson-South and contributors.
+// Licensed under the Apache License, Version 2.0.
+//
+
+namespace ImageSharp.Tests.Icc
+{
+ using Xunit;
+
+ public class IccDataReaderMultiProcessElementTests
+ {
+ [Theory]
+ [MemberData(nameof(IccTestDataMultiProcessElement.MultiProcessElementTestData), MemberType = typeof(IccTestDataMultiProcessElement))]
+ internal void ReadMultiProcessElement(byte[] data, IccMultiProcessElement expected)
+ {
+ IccDataReader reader = CreateReader(data);
+
+ IccMultiProcessElement output = reader.ReadMultiProcessElement();
+
+ Assert.Equal(expected, output);
+ }
+
+ [Theory]
+ [MemberData(nameof(IccTestDataMultiProcessElement.CurveSetTestData), MemberType = typeof(IccTestDataMultiProcessElement))]
+ internal void ReadCurveSetProcessElement(byte[] data, IccCurveSetProcessElement expected, int inChannelCount, int outChannelCount)
+ {
+ IccDataReader reader = CreateReader(data);
+
+ IccCurveSetProcessElement output = reader.ReadCurveSetProcessElement(inChannelCount, outChannelCount);
+
+ Assert.Equal(expected, output);
+ }
+
+ [Theory]
+ [MemberData(nameof(IccTestDataMultiProcessElement.MatrixTestData), MemberType = typeof(IccTestDataMultiProcessElement))]
+ internal void ReadMatrixProcessElement(byte[] data, IccMatrixProcessElement expected, int inChannelCount, int outChannelCount)
+ {
+ IccDataReader reader = CreateReader(data);
+
+ IccMatrixProcessElement output = reader.ReadMatrixProcessElement(inChannelCount, outChannelCount);
+
+ Assert.Equal(expected, output);
+ }
+
+ [Theory]
+ [MemberData(nameof(IccTestDataMultiProcessElement.ClutTestData), MemberType = typeof(IccTestDataMultiProcessElement))]
+ internal void ReadClutProcessElement(byte[] data, IccClutProcessElement expected, int inChannelCount, int outChannelCount)
+ {
+ IccDataReader reader = CreateReader(data);
+
+ IccClutProcessElement output = reader.ReadClutProcessElement(inChannelCount, outChannelCount);
+
+ Assert.Equal(expected, output);
+ }
+
+ private IccDataReader CreateReader(byte[] data)
+ {
+ return new IccDataReader(data);
+ }
+ }
+}
diff --git a/tests/ImageSharp.Tests/MetaData/Profiles/ICC/DataReader/IccDataReader.NonPrimitivesTests.cs b/tests/ImageSharp.Tests/MetaData/Profiles/ICC/DataReader/IccDataReader.NonPrimitivesTests.cs
new file mode 100644
index 000000000..2c1113c38
--- /dev/null
+++ b/tests/ImageSharp.Tests/MetaData/Profiles/ICC/DataReader/IccDataReader.NonPrimitivesTests.cs
@@ -0,0 +1,118 @@
+//
+// Copyright (c) James Jackson-South and contributors.
+// Licensed under the Apache License, Version 2.0.
+//
+
+namespace ImageSharp.Tests.Icc
+{
+ using System;
+ using System.Numerics;
+ using Xunit;
+
+ public class IccDataReaderNonPrimitivesTests
+ {
+ [Theory]
+ [MemberData(nameof(IccTestDataNonPrimitives.DateTimeTestData), MemberType = typeof(IccTestDataNonPrimitives))]
+ public void ReadDateTime(byte[] data, DateTime expected)
+ {
+ IccDataReader reader = CreateReader(data);
+
+ DateTime output = reader.ReadDateTime();
+
+ Assert.Equal(expected, output);
+ }
+
+ [Theory]
+ [MemberData(nameof(IccTestDataNonPrimitives.VersionNumberTestData), MemberType = typeof(IccTestDataNonPrimitives))]
+ public void ReadVersionNumber(byte[] data, Version expected)
+ {
+ IccDataReader reader = CreateReader(data);
+
+ Version output = reader.ReadVersionNumber();
+
+ Assert.Equal(expected, output);
+ }
+
+ [Theory]
+ [MemberData(nameof(IccTestDataNonPrimitives.XyzNumberTestData), MemberType = typeof(IccTestDataNonPrimitives))]
+ public void ReadXyzNumber(byte[] data, Vector3 expected)
+ {
+ IccDataReader reader = CreateReader(data);
+
+ Vector3 output = reader.ReadXyzNumber();
+
+ Assert.Equal(expected, output);
+ }
+
+ [Theory]
+ [MemberData(nameof(IccTestDataNonPrimitives.ProfileIdTestData), MemberType = typeof(IccTestDataNonPrimitives))]
+ internal void ReadProfileId(byte[] data, IccProfileId expected)
+ {
+ IccDataReader reader = CreateReader(data);
+
+ IccProfileId output = reader.ReadProfileId();
+
+ Assert.Equal(expected, output);
+ }
+
+ [Theory]
+ [MemberData(nameof(IccTestDataNonPrimitives.PositionNumberTestData), MemberType = typeof(IccTestDataNonPrimitives))]
+ internal void ReadPositionNumber(byte[] data, IccPositionNumber expected)
+ {
+ IccDataReader reader = CreateReader(data);
+
+ IccPositionNumber output = reader.ReadPositionNumber();
+
+ Assert.Equal(expected, output);
+ }
+
+ [Theory]
+ [MemberData(nameof(IccTestDataNonPrimitives.ResponseNumberTestData), MemberType = typeof(IccTestDataNonPrimitives))]
+ internal void ReadResponseNumber(byte[] data, IccResponseNumber expected)
+ {
+ IccDataReader reader = CreateReader(data);
+
+ IccResponseNumber output = reader.ReadResponseNumber();
+
+ Assert.Equal(expected, output);
+ }
+
+ [Theory]
+ [MemberData(nameof(IccTestDataNonPrimitives.NamedColorTestData), MemberType = typeof(IccTestDataNonPrimitives))]
+ internal void ReadNamedColor(byte[] data, IccNamedColor expected, uint coordinateCount)
+ {
+ IccDataReader reader = CreateReader(data);
+
+ IccNamedColor output = reader.ReadNamedColor(coordinateCount);
+
+ Assert.Equal(expected, output);
+ }
+
+ [Theory]
+ [MemberData(nameof(IccTestDataNonPrimitives.ProfileDescriptionTestData), MemberType = typeof(IccTestDataNonPrimitives))]
+ internal void ReadProfileDescription(byte[] data, IccProfileDescription expected)
+ {
+ IccDataReader reader = CreateReader(data);
+
+ IccProfileDescription output = reader.ReadProfileDescription();
+
+ Assert.Equal(expected, output);
+ }
+
+ [Theory]
+ [MemberData(nameof(IccTestDataNonPrimitives.ColorantTableEntryTestData), MemberType = typeof(IccTestDataNonPrimitives))]
+ internal void ReadColorantTableEntry(byte[] data, IccColorantTableEntry expected)
+ {
+ IccDataReader reader = CreateReader(data);
+
+ IccColorantTableEntry output = reader.ReadColorantTableEntry();
+
+ Assert.Equal(expected, output);
+ }
+
+ private IccDataReader CreateReader(byte[] data)
+ {
+ return new IccDataReader(data);
+ }
+ }
+}
diff --git a/tests/ImageSharp.Tests/MetaData/Profiles/ICC/DataReader/IccDataReader.PrimitivesTests.cs b/tests/ImageSharp.Tests/MetaData/Profiles/ICC/DataReader/IccDataReader.PrimitivesTests.cs
new file mode 100644
index 000000000..b9b0c6655
--- /dev/null
+++ b/tests/ImageSharp.Tests/MetaData/Profiles/ICC/DataReader/IccDataReader.PrimitivesTests.cs
@@ -0,0 +1,89 @@
+//
+// Copyright (c) James Jackson-South and contributors.
+// Licensed under the Apache License, Version 2.0.
+//
+
+namespace ImageSharp.Tests.Icc
+{
+ using System;
+ using Xunit;
+
+ public class IccDataReaderPrimitivesTests
+ {
+ [Theory]
+ [MemberData(nameof(IccTestDataPrimitives.AsciiTestData), MemberType = typeof(IccTestDataPrimitives))]
+ public void ReadAsciiString(byte[] textBytes, int length, string expected)
+ {
+ IccDataReader reader = CreateReader(textBytes);
+
+ string output = reader.ReadAsciiString(length);
+
+ Assert.Equal(expected, output);
+ }
+
+ [Fact]
+ public void ReadAsciiStringWithNegativeLenghtThrowsArgumentException()
+ {
+ IccDataReader reader = CreateReader(new byte[4]);
+
+ Assert.Throws(() => reader.ReadAsciiString(-1));
+ }
+
+ [Fact]
+ public void ReadUnicodeStringWithNegativeLenghtThrowsArgumentException()
+ {
+ IccDataReader reader = CreateReader(new byte[4]);
+
+ Assert.Throws(() => reader.ReadUnicodeString(-1));
+ }
+
+ [Theory]
+ [MemberData(nameof(IccTestDataPrimitives.Fix16TestData), MemberType = typeof(IccTestDataPrimitives))]
+ public void ReadFix16(byte[] data, float expected)
+ {
+ IccDataReader reader = CreateReader(data);
+
+ float output = reader.ReadFix16();
+
+ Assert.Equal(expected, output);
+ }
+
+ [Theory]
+ [MemberData(nameof(IccTestDataPrimitives.UFix16TestData), MemberType = typeof(IccTestDataPrimitives))]
+ public void ReadUFix16(byte[] data, float expected)
+ {
+ IccDataReader reader = CreateReader(data);
+
+ float output = reader.ReadUFix16();
+
+ Assert.Equal(expected, output);
+ }
+
+ [Theory]
+ [MemberData(nameof(IccTestDataPrimitives.U1Fix15TestData), MemberType = typeof(IccTestDataPrimitives))]
+ public void ReadU1Fix15(byte[] data, float expected)
+ {
+ IccDataReader reader = CreateReader(data);
+
+ float output = reader.ReadU1Fix15();
+
+ Assert.Equal(expected, output);
+ }
+
+ [Theory]
+ [MemberData(nameof(IccTestDataPrimitives.UFix8TestData), MemberType = typeof(IccTestDataPrimitives))]
+ public void ReadUFix8(byte[] data, float expected)
+ {
+ IccDataReader reader = CreateReader(data);
+
+ float output = reader.ReadUFix8();
+
+ Assert.Equal(expected, output);
+ }
+
+ private IccDataReader CreateReader(byte[] data)
+ {
+ return new IccDataReader(data);
+ }
+ }
+}
diff --git a/tests/ImageSharp.Tests/MetaData/Profiles/ICC/DataReader/IccDataReader.TagDataEntryTests.cs b/tests/ImageSharp.Tests/MetaData/Profiles/ICC/DataReader/IccDataReader.TagDataEntryTests.cs
new file mode 100644
index 000000000..fe628c1ad
--- /dev/null
+++ b/tests/ImageSharp.Tests/MetaData/Profiles/ICC/DataReader/IccDataReader.TagDataEntryTests.cs
@@ -0,0 +1,347 @@
+//
+// Copyright (c) James Jackson-South and contributors.
+// Licensed under the Apache License, Version 2.0.
+//
+
+namespace ImageSharp.Tests.Icc
+{
+ using Xunit;
+
+ public class IccDataReaderTagDataEntryTests
+ {
+ [Theory]
+ [MemberData(nameof(IccTestDataTagDataEntry.UnknownTagDataEntryTestData), MemberType = typeof(IccTestDataTagDataEntry))]
+ internal void ReadUnknownTagDataEntry(byte[] data, IccUnknownTagDataEntry expected, uint size)
+ {
+ IccDataReader reader = CreateReader(data);
+
+ IccUnknownTagDataEntry output = reader.ReadUnknownTagDataEntry(size);
+
+ Assert.Equal(expected, output);
+ }
+
+ [Theory]
+ [MemberData(nameof(IccTestDataTagDataEntry.ChromaticityTagDataEntryTestData), MemberType = typeof(IccTestDataTagDataEntry))]
+ internal void ReadChromaticityTagDataEntry(byte[] data, IccChromaticityTagDataEntry expected)
+ {
+ IccDataReader reader = CreateReader(data);
+
+ IccChromaticityTagDataEntry output = reader.ReadChromaticityTagDataEntry();
+
+ Assert.Equal(expected, output);
+ }
+
+ [Theory]
+ [MemberData(nameof(IccTestDataTagDataEntry.ColorantOrderTagDataEntryTestData), MemberType = typeof(IccTestDataTagDataEntry))]
+ internal void ReadColorantOrderTagDataEntry(byte[] data, IccColorantOrderTagDataEntry expected)
+ {
+ IccDataReader reader = CreateReader(data);
+
+ IccColorantOrderTagDataEntry output = reader.ReadColorantOrderTagDataEntry();
+
+ Assert.Equal(expected, output);
+ }
+
+ [Theory]
+ [MemberData(nameof(IccTestDataTagDataEntry.ColorantTableTagDataEntryTestData), MemberType = typeof(IccTestDataTagDataEntry))]
+ internal void ReadColorantTableTagDataEntry(byte[] data, IccColorantTableTagDataEntry expected)
+ {
+ IccDataReader reader = CreateReader(data);
+
+ IccColorantTableTagDataEntry output = reader.ReadColorantTableTagDataEntry();
+
+ Assert.Equal(expected, output);
+ }
+
+ [Theory]
+ [MemberData(nameof(IccTestDataTagDataEntry.CurveTagDataEntryTestData), MemberType = typeof(IccTestDataTagDataEntry))]
+ internal void ReadCurveTagDataEntry(byte[] data, IccCurveTagDataEntry expected)
+ {
+ IccDataReader reader = CreateReader(data);
+
+ IccCurveTagDataEntry output = reader.ReadCurveTagDataEntry();
+
+ Assert.Equal(expected, output);
+ }
+
+ [Theory]
+ [MemberData(nameof(IccTestDataTagDataEntry.DataTagDataEntryTestData), MemberType = typeof(IccTestDataTagDataEntry))]
+ internal void ReadDataTagDataEntry(byte[] data, IccDataTagDataEntry expected, uint size)
+ {
+ IccDataReader reader = CreateReader(data);
+
+ IccDataTagDataEntry output = reader.ReadDataTagDataEntry(size);
+
+ Assert.Equal(expected, output);
+ }
+
+ [Theory]
+ [MemberData(nameof(IccTestDataTagDataEntry.DateTimeTagDataEntryTestData), MemberType = typeof(IccTestDataTagDataEntry))]
+ internal void ReadDateTimeTagDataEntry(byte[] data, IccDateTimeTagDataEntry expected)
+ {
+ IccDataReader reader = CreateReader(data);
+
+ IccDateTimeTagDataEntry output = reader.ReadDateTimeTagDataEntry();
+
+ Assert.Equal(expected, output);
+ }
+
+ [Theory]
+ [MemberData(nameof(IccTestDataTagDataEntry.Lut16TagDataEntryTestData), MemberType = typeof(IccTestDataTagDataEntry))]
+ internal void ReadLut16TagDataEntry(byte[] data, IccLut16TagDataEntry expected)
+ {
+ IccDataReader reader = CreateReader(data);
+
+ IccLut16TagDataEntry output = reader.ReadLut16TagDataEntry();
+
+ Assert.Equal(expected, output);
+ }
+
+ [Theory]
+ [MemberData(nameof(IccTestDataTagDataEntry.Lut8TagDataEntryTestData), MemberType = typeof(IccTestDataTagDataEntry))]
+ internal void ReadLut8TagDataEntry(byte[] data, IccLut8TagDataEntry expected)
+ {
+ IccDataReader reader = CreateReader(data);
+
+ IccLut8TagDataEntry output = reader.ReadLut8TagDataEntry();
+
+ Assert.Equal(expected, output);
+ }
+
+ [Theory]
+ [MemberData(nameof(IccTestDataTagDataEntry.LutAToBTagDataEntryTestData), MemberType = typeof(IccTestDataTagDataEntry))]
+ internal void ReadLutAToBTagDataEntry(byte[] data, IccLutAToBTagDataEntry expected)
+ {
+ IccDataReader reader = CreateReader(data);
+
+ IccLutAToBTagDataEntry output = reader.ReadLutAToBTagDataEntry();
+
+ Assert.Equal(expected, output);
+ }
+
+ [Theory]
+ [MemberData(nameof(IccTestDataTagDataEntry.LutBToATagDataEntryTestData), MemberType = typeof(IccTestDataTagDataEntry))]
+ internal void ReadLutBToATagDataEntry(byte[] data, IccLutBToATagDataEntry expected)
+ {
+ IccDataReader reader = CreateReader(data);
+
+ IccLutBToATagDataEntry output = reader.ReadLutBToATagDataEntry();
+
+ Assert.Equal(expected, output);
+ }
+
+ [Theory]
+ [MemberData(nameof(IccTestDataTagDataEntry.MeasurementTagDataEntryTestData), MemberType = typeof(IccTestDataTagDataEntry))]
+ internal void ReadMeasurementTagDataEntry(byte[] data, IccMeasurementTagDataEntry expected)
+ {
+ IccDataReader reader = CreateReader(data);
+
+ IccMeasurementTagDataEntry output = reader.ReadMeasurementTagDataEntry();
+
+ Assert.Equal(expected, output);
+ }
+
+ [Theory]
+ [MemberData(nameof(IccTestDataTagDataEntry.MultiLocalizedUnicodeTagDataEntryTestData), MemberType = typeof(IccTestDataTagDataEntry))]
+ internal void ReadMultiLocalizedUnicodeTagDataEntry(byte[] data, IccMultiLocalizedUnicodeTagDataEntry expected)
+ {
+ IccDataReader reader = CreateReader(data);
+
+ IccMultiLocalizedUnicodeTagDataEntry output = reader.ReadMultiLocalizedUnicodeTagDataEntry();
+
+ Assert.Equal(expected, output);
+ }
+
+ [Theory]
+ [MemberData(nameof(IccTestDataTagDataEntry.MultiProcessElementsTagDataEntryTestData), MemberType = typeof(IccTestDataTagDataEntry))]
+ internal void ReadMultiProcessElementsTagDataEntry(byte[] data, IccMultiProcessElementsTagDataEntry expected)
+ {
+ IccDataReader reader = CreateReader(data);
+
+ IccMultiProcessElementsTagDataEntry output = reader.ReadMultiProcessElementsTagDataEntry();
+
+ Assert.Equal(expected, output);
+ }
+
+ [Theory]
+ [MemberData(nameof(IccTestDataTagDataEntry.NamedColor2TagDataEntryTestData), MemberType = typeof(IccTestDataTagDataEntry))]
+ internal void ReadNamedColor2TagDataEntry(byte[] data, IccNamedColor2TagDataEntry expected)
+ {
+ IccDataReader reader = CreateReader(data);
+
+ IccNamedColor2TagDataEntry output = reader.ReadNamedColor2TagDataEntry();
+
+ Assert.Equal(expected, output);
+ }
+
+ [Theory]
+ [MemberData(nameof(IccTestDataTagDataEntry.ParametricCurveTagDataEntryTestData), MemberType = typeof(IccTestDataTagDataEntry))]
+ internal void ReadParametricCurveTagDataEntry(byte[] data, IccParametricCurveTagDataEntry expected)
+ {
+ IccDataReader reader = CreateReader(data);
+
+ IccParametricCurveTagDataEntry output = reader.ReadParametricCurveTagDataEntry();
+
+ Assert.Equal(expected, output);
+ }
+
+ [Theory]
+ [MemberData(nameof(IccTestDataTagDataEntry.ProfileSequenceDescTagDataEntryTestData), MemberType = typeof(IccTestDataTagDataEntry))]
+ internal void ReadProfileSequenceDescTagDataEntry(byte[] data, IccProfileSequenceDescTagDataEntry expected)
+ {
+ IccDataReader reader = CreateReader(data);
+
+ IccProfileSequenceDescTagDataEntry output = reader.ReadProfileSequenceDescTagDataEntry();
+
+ Assert.Equal(expected, output);
+ }
+
+ [Theory]
+ [MemberData(nameof(IccTestDataTagDataEntry.ProfileSequenceIdentifierTagDataEntryTestData), MemberType = typeof(IccTestDataTagDataEntry))]
+ internal void ReadProfileSequenceIdentifierTagDataEntry(byte[] data, IccProfileSequenceIdentifierTagDataEntry expected)
+ {
+ IccDataReader reader = CreateReader(data);
+
+ IccProfileSequenceIdentifierTagDataEntry output = reader.ReadProfileSequenceIdentifierTagDataEntry();
+
+ Assert.Equal(expected, output);
+ }
+
+ [Theory]
+ [MemberData(nameof(IccTestDataTagDataEntry.ResponseCurveSet16TagDataEntryTestData), MemberType = typeof(IccTestDataTagDataEntry))]
+ internal void ReadResponseCurveSet16TagDataEntry(byte[] data, IccResponseCurveSet16TagDataEntry expected)
+ {
+ IccDataReader reader = CreateReader(data);
+
+ IccResponseCurveSet16TagDataEntry output = reader.ReadResponseCurveSet16TagDataEntry();
+
+ Assert.Equal(expected, output);
+ }
+
+ [Theory]
+ [MemberData(nameof(IccTestDataTagDataEntry.Fix16ArrayTagDataEntryTestData), MemberType = typeof(IccTestDataTagDataEntry))]
+ internal void ReadFix16ArrayTagDataEntry(byte[] data, IccFix16ArrayTagDataEntry expected, uint size)
+ {
+ IccDataReader reader = CreateReader(data);
+
+ IccFix16ArrayTagDataEntry output = reader.ReadFix16ArrayTagDataEntry(size);
+
+ Assert.Equal(expected, output);
+ }
+
+ [Theory]
+ [MemberData(nameof(IccTestDataTagDataEntry.SignatureTagDataEntryTestData), MemberType = typeof(IccTestDataTagDataEntry))]
+ internal void ReadSignatureTagDataEntry(byte[] data, IccSignatureTagDataEntry expected)
+ {
+ IccDataReader reader = CreateReader(data);
+
+ IccSignatureTagDataEntry output = reader.ReadSignatureTagDataEntry();
+
+ Assert.Equal(expected, output);
+ }
+
+ [Theory]
+ [MemberData(nameof(IccTestDataTagDataEntry.TextTagDataEntryTestData), MemberType = typeof(IccTestDataTagDataEntry))]
+ internal void ReadTextTagDataEntry(byte[] data, IccTextTagDataEntry expected, uint size)
+ {
+ IccDataReader reader = CreateReader(data);
+
+ IccTextTagDataEntry output = reader.ReadTextTagDataEntry(size);
+
+ Assert.Equal(expected, output);
+ }
+
+ [Theory]
+ [MemberData(nameof(IccTestDataTagDataEntry.UFix16ArrayTagDataEntryTestData), MemberType = typeof(IccTestDataTagDataEntry))]
+ internal void ReadUFix16ArrayTagDataEntry(byte[] data, IccUFix16ArrayTagDataEntry expected, uint size)
+ {
+ IccDataReader reader = CreateReader(data);
+
+ IccUFix16ArrayTagDataEntry output = reader.ReadUFix16ArrayTagDataEntry(size);
+
+ Assert.Equal(expected, output);
+ }
+
+ [Theory]
+ [MemberData(nameof(IccTestDataTagDataEntry.UInt16ArrayTagDataEntryTestData), MemberType = typeof(IccTestDataTagDataEntry))]
+ internal void ReadUInt16ArrayTagDataEntry(byte[] data, IccUInt16ArrayTagDataEntry expected, uint size)
+ {
+ IccDataReader reader = CreateReader(data);
+
+ IccUInt16ArrayTagDataEntry output = reader.ReadUInt16ArrayTagDataEntry(size);
+
+ Assert.Equal(expected, output);
+ }
+
+ [Theory]
+ [MemberData(nameof(IccTestDataTagDataEntry.UInt32ArrayTagDataEntryTestData), MemberType = typeof(IccTestDataTagDataEntry))]
+ internal void ReadUInt32ArrayTagDataEntry(byte[] data, IccUInt32ArrayTagDataEntry expected, uint size)
+ {
+ IccDataReader reader = CreateReader(data);
+
+ IccUInt32ArrayTagDataEntry output = reader.ReadUInt32ArrayTagDataEntry(size);
+
+ Assert.Equal(expected, output);
+ }
+
+ [Theory]
+ [MemberData(nameof(IccTestDataTagDataEntry.UInt64ArrayTagDataEntryTestData), MemberType = typeof(IccTestDataTagDataEntry))]
+ internal void ReadUInt64ArrayTagDataEntry(byte[] data, IccUInt64ArrayTagDataEntry expected, uint size)
+ {
+ IccDataReader reader = CreateReader(data);
+
+ IccUInt64ArrayTagDataEntry output = reader.ReadUInt64ArrayTagDataEntry(size);
+
+ Assert.Equal(expected, output);
+ }
+
+ [Theory]
+ [MemberData(nameof(IccTestDataTagDataEntry.UInt8ArrayTagDataEntryTestData), MemberType = typeof(IccTestDataTagDataEntry))]
+ internal void ReadUInt8ArrayTagDataEntry(byte[] data, IccUInt8ArrayTagDataEntry expected, uint size)
+ {
+ IccDataReader reader = CreateReader(data);
+
+ IccUInt8ArrayTagDataEntry output = reader.ReadUInt8ArrayTagDataEntry(size);
+
+ Assert.Equal(expected, output);
+ }
+
+ [Theory]
+ [MemberData(nameof(IccTestDataTagDataEntry.ViewingConditionsTagDataEntryTestData), MemberType = typeof(IccTestDataTagDataEntry))]
+ internal void ReadViewingConditionsTagDataEntry(byte[] data, IccViewingConditionsTagDataEntry expected)
+ {
+ IccDataReader reader = CreateReader(data);
+
+ IccViewingConditionsTagDataEntry output = reader.ReadViewingConditionsTagDataEntry();
+
+ Assert.Equal(expected, output);
+ }
+
+ [Theory]
+ [MemberData(nameof(IccTestDataTagDataEntry.XYZTagDataEntryTestData), MemberType = typeof(IccTestDataTagDataEntry))]
+ internal void ReadXyzTagDataEntry(byte[] data, IccXyzTagDataEntry expected, uint size)
+ {
+ IccDataReader reader = CreateReader(data);
+
+ IccXyzTagDataEntry output = reader.ReadXyzTagDataEntry(size);
+
+ Assert.Equal(expected, output);
+ }
+
+ [Theory]
+ [MemberData(nameof(IccTestDataTagDataEntry.TextDescriptionTagDataEntryTestData), MemberType = typeof(IccTestDataTagDataEntry))]
+ internal void ReadTextDescriptionTagDataEntry(byte[] data, IccTextDescriptionTagDataEntry expected)
+ {
+ IccDataReader reader = CreateReader(data);
+
+ IccTextDescriptionTagDataEntry output = reader.ReadTextDescriptionTagDataEntry();
+
+ Assert.Equal(expected, output);
+ }
+
+ private IccDataReader CreateReader(byte[] data)
+ {
+ return new IccDataReader(data);
+ }
+ }
+}
diff --git a/tests/ImageSharp.Tests/MetaData/Profiles/ICC/DataReader/IccDataReaderTests.cs b/tests/ImageSharp.Tests/MetaData/Profiles/ICC/DataReader/IccDataReaderTests.cs
new file mode 100644
index 000000000..635ce6168
--- /dev/null
+++ b/tests/ImageSharp.Tests/MetaData/Profiles/ICC/DataReader/IccDataReaderTests.cs
@@ -0,0 +1,19 @@
+//
+// Copyright (c) James Jackson-South and contributors.
+// Licensed under the Apache License, Version 2.0.
+//
+
+namespace ImageSharp.Tests.Icc
+{
+ using System;
+ using Xunit;
+
+ public class IccDataReaderTests
+ {
+ [Fact]
+ public void ConstructorThrowsNullException()
+ {
+ Assert.Throws(() => new IccDataReader(null));
+ }
+ }
+}
diff --git a/tests/ImageSharp.Tests/MetaData/Profiles/ICC/DataWriter/IccDataWriter.CurvesTests.cs b/tests/ImageSharp.Tests/MetaData/Profiles/ICC/DataWriter/IccDataWriter.CurvesTests.cs
new file mode 100644
index 000000000..c04401f6d
--- /dev/null
+++ b/tests/ImageSharp.Tests/MetaData/Profiles/ICC/DataWriter/IccDataWriter.CurvesTests.cs
@@ -0,0 +1,89 @@
+//
+// Copyright (c) James Jackson-South and contributors.
+// Licensed under the Apache License, Version 2.0.
+//
+
+namespace ImageSharp.Tests.Icc
+{
+ using Xunit;
+
+ public class IccDataWriterCurvesTests
+ {
+ [Theory]
+ [MemberData(nameof(IccTestDataCurves.OneDimensionalCurveTestData), MemberType = typeof(IccTestDataCurves))]
+ internal void WriteOneDimensionalCurve(byte[] expected, IccOneDimensionalCurve data)
+ {
+ IccDataWriter writer = CreateWriter();
+
+ writer.WriteOneDimensionalCurve(data);
+ byte[] output = writer.GetData();
+
+ Assert.Equal(expected, output);
+ }
+
+ [Theory]
+ [MemberData(nameof(IccTestDataCurves.ResponseCurveTestData), MemberType = typeof(IccTestDataCurves))]
+ internal void WriteResponseCurve(byte[] expected, IccResponseCurve data, int channelCount)
+ {
+ IccDataWriter writer = CreateWriter();
+
+ writer.WriteResponseCurve(data);
+ byte[] output = writer.GetData();
+
+ Assert.Equal(expected, output);
+ }
+
+ [Theory]
+ [MemberData(nameof(IccTestDataCurves.ParametricCurveTestData), MemberType = typeof(IccTestDataCurves))]
+ internal void WriteParametricCurve(byte[] expected, IccParametricCurve data)
+ {
+ IccDataWriter writer = CreateWriter();
+
+ writer.WriteParametricCurve(data);
+ byte[] output = writer.GetData();
+
+ Assert.Equal(expected, output);
+ }
+
+ [Theory]
+ [MemberData(nameof(IccTestDataCurves.CurveSegmentTestData), MemberType = typeof(IccTestDataCurves))]
+ internal void WriteCurveSegment(byte[] expected, IccCurveSegment data)
+ {
+ IccDataWriter writer = CreateWriter();
+
+ writer.WriteCurveSegment(data);
+ byte[] output = writer.GetData();
+
+ Assert.Equal(expected, output);
+ }
+
+ [Theory]
+ [MemberData(nameof(IccTestDataCurves.FormulaCurveSegmentTestData), MemberType = typeof(IccTestDataCurves))]
+ internal void WriteFormulaCurveElement(byte[] expected, IccFormulaCurveElement data)
+ {
+ IccDataWriter writer = CreateWriter();
+
+ writer.WriteFormulaCurveElement(data);
+ byte[] output = writer.GetData();
+
+ Assert.Equal(expected, output);
+ }
+
+ [Theory]
+ [MemberData(nameof(IccTestDataCurves.SampledCurveSegmentTestData), MemberType = typeof(IccTestDataCurves))]
+ internal void WriteSampledCurveElement(byte[] expected, IccSampledCurveElement data)
+ {
+ IccDataWriter writer = CreateWriter();
+
+ writer.WriteSampledCurveElement(data);
+ byte[] output = writer.GetData();
+
+ Assert.Equal(expected, output);
+ }
+
+ private IccDataWriter CreateWriter()
+ {
+ return new IccDataWriter();
+ }
+ }
+}
diff --git a/tests/ImageSharp.Tests/MetaData/Profiles/ICC/DataWriter/IccDataWriter.LutTests.cs b/tests/ImageSharp.Tests/MetaData/Profiles/ICC/DataWriter/IccDataWriter.LutTests.cs
new file mode 100644
index 000000000..4fcc55d01
--- /dev/null
+++ b/tests/ImageSharp.Tests/MetaData/Profiles/ICC/DataWriter/IccDataWriter.LutTests.cs
@@ -0,0 +1,89 @@
+//
+// Copyright (c) James Jackson-South and contributors.
+// Licensed under the Apache License, Version 2.0.
+//
+
+namespace ImageSharp.Tests.Icc
+{
+ using Xunit;
+
+ public class IccDataWriterLutTests
+ {
+ [Theory]
+ [MemberData(nameof(IccTestDataLut.ClutTestData), MemberType = typeof(IccTestDataLut))]
+ internal void WriteClutAll(byte[] expected, IccClut data, int inChannelCount, int outChannelCount, bool isFloat)
+ {
+ IccDataWriter writer = CreateWriter();
+
+ writer.WriteClut(data);
+ byte[] output = writer.GetData();
+
+ Assert.Equal(expected, output);
+ }
+
+ [Theory]
+ [MemberData(nameof(IccTestDataLut.Clut8TestData), MemberType = typeof(IccTestDataLut))]
+ internal void WriteClut8(byte[] expected, IccClut data, int inChannelCount, int outChannelCount, byte[] gridPointCount)
+ {
+ IccDataWriter writer = CreateWriter();
+
+ writer.WriteClut8(data);
+ byte[] output = writer.GetData();
+
+ Assert.Equal(expected, output);
+ }
+
+ [Theory]
+ [MemberData(nameof(IccTestDataLut.Clut16TestData), MemberType = typeof(IccTestDataLut))]
+ internal void WriteClut16(byte[] expected, IccClut data, int inChannelCount, int outChannelCount, byte[] gridPointCount)
+ {
+ IccDataWriter writer = CreateWriter();
+
+ writer.WriteClut16(data);
+ byte[] output = writer.GetData();
+
+ Assert.Equal(expected, output);
+ }
+
+ [Theory]
+ [MemberData(nameof(IccTestDataLut.ClutF32TestData), MemberType = typeof(IccTestDataLut))]
+ internal void WriteClutF32(byte[] expected, IccClut data, int inChannelCount, int outChannelCount, byte[] gridPointCount)
+ {
+ IccDataWriter writer = CreateWriter();
+
+ writer.WriteClutF32(data);
+ byte[] output = writer.GetData();
+
+ Assert.Equal(expected, output);
+ }
+
+ [Theory]
+ [MemberData(nameof(IccTestDataLut.Lut8TestData), MemberType = typeof(IccTestDataLut))]
+ internal void WriteLut8(byte[] expected, IccLut data)
+ {
+ IccDataWriter writer = CreateWriter();
+
+ writer.WriteLut8(data);
+ byte[] output = writer.GetData();
+
+ Assert.Equal(expected, output);
+ }
+
+ [Theory]
+ [MemberData(nameof(IccTestDataLut.Lut16TestData), MemberType = typeof(IccTestDataLut))]
+ internal void WriteLut16(byte[] expected, IccLut data, int count)
+ {
+ IccDataWriter writer = CreateWriter();
+
+ writer.WriteLut16(data);
+ byte[] output = writer.GetData();
+
+ Assert.Equal(expected, output);
+ }
+
+ private IccDataWriter CreateWriter()
+ {
+ return new IccDataWriter();
+ }
+ }
+}
diff --git a/tests/ImageSharp.Tests/MetaData/Profiles/ICC/DataWriter/IccDataWriter.MatrixTests.cs b/tests/ImageSharp.Tests/MetaData/Profiles/ICC/DataWriter/IccDataWriter.MatrixTests.cs
new file mode 100644
index 000000000..b254f3c2c
--- /dev/null
+++ b/tests/ImageSharp.Tests/MetaData/Profiles/ICC/DataWriter/IccDataWriter.MatrixTests.cs
@@ -0,0 +1,78 @@
+//
+// Copyright (c) James Jackson-South and contributors.
+// Licensed under the Apache License, Version 2.0.
+//
+
+namespace ImageSharp.Tests.Icc
+{
+ using System.Numerics;
+ using Xunit;
+
+ public class IccDataWriterMatrixTests
+ {
+ [Theory]
+ [MemberData(nameof(IccTestDataMatrix.Matrix2D_FloatArrayTestData), MemberType = typeof(IccTestDataMatrix))]
+ public void WriteMatrix2D_Array(byte[] expected, int xCount, int yCount, bool isSingle, float[,] data)
+ {
+ IccDataWriter writer = CreateWriter();
+
+ writer.WriteMatrix(data, isSingle);
+ byte[] output = writer.GetData();
+
+ Assert.Equal(expected, output);
+ }
+
+ [Theory]
+ [MemberData(nameof(IccTestDataMatrix.Matrix2D_Matrix4x4TestData), MemberType = typeof(IccTestDataMatrix))]
+ public void WriteMatrix2D_Matrix4x4(byte[] expected, int xCount, int yCount, bool isSingle, Matrix4x4 data)
+ {
+ IccDataWriter writer = CreateWriter();
+
+ writer.WriteMatrix(data, isSingle);
+ byte[] output = writer.GetData();
+
+ Assert.Equal(expected, output);
+ }
+
+ [Theory]
+ [MemberData(nameof(IccTestDataMatrix.Matrix2D_Fast2DArrayTestData), MemberType = typeof(IccTestDataMatrix))]
+ internal void WriteMatrix2D_Fast2DArray(byte[] expected, int xCount, int yCount, bool isSingle, Fast2DArray data)
+ {
+ IccDataWriter writer = CreateWriter();
+
+ writer.WriteMatrix(data, isSingle);
+ byte[] output = writer.GetData();
+
+ Assert.Equal(expected, output);
+ }
+
+ [Theory]
+ [MemberData(nameof(IccTestDataMatrix.Matrix1D_ArrayTestData), MemberType = typeof(IccTestDataMatrix))]
+ public void WriteMatrix1D_Array(byte[] expected, int yCount, bool isSingle, float[] data)
+ {
+ IccDataWriter writer = CreateWriter();
+
+ writer.WriteMatrix(data, isSingle);
+ byte[] output = writer.GetData();
+
+ Assert.Equal(expected, output);
+ }
+
+ [Theory]
+ [MemberData(nameof(IccTestDataMatrix.Matrix1D_Vector3TestData), MemberType = typeof(IccTestDataMatrix))]
+ public void WriteMatrix1D_Vector3(byte[] expected, int yCount, bool isSingle, Vector3 data)
+ {
+ IccDataWriter writer = CreateWriter();
+
+ writer.WriteMatrix(data, isSingle);
+ byte[] output = writer.GetData();
+
+ Assert.Equal(expected, output);
+ }
+
+ private IccDataWriter CreateWriter()
+ {
+ return new IccDataWriter();
+ }
+ }
+}
diff --git a/tests/ImageSharp.Tests/MetaData/Profiles/ICC/DataWriter/IccDataWriter.MultiProcessElementTests.cs b/tests/ImageSharp.Tests/MetaData/Profiles/ICC/DataWriter/IccDataWriter.MultiProcessElementTests.cs
new file mode 100644
index 000000000..e3bc37574
--- /dev/null
+++ b/tests/ImageSharp.Tests/MetaData/Profiles/ICC/DataWriter/IccDataWriter.MultiProcessElementTests.cs
@@ -0,0 +1,65 @@
+//
+// Copyright (c) James Jackson-South and contributors.
+// Licensed under the Apache License, Version 2.0.
+//
+
+namespace ImageSharp.Tests.Icc
+{
+ using Xunit;
+
+ public class IccDataWriterMultiProcessElementTests
+ {
+ [Theory]
+ [MemberData(nameof(IccTestDataMultiProcessElement.MultiProcessElementTestData), MemberType = typeof(IccTestDataMultiProcessElement))]
+ internal void WriteMultiProcessElement(byte[] expected, IccMultiProcessElement data)
+ {
+ IccDataWriter writer = CreateWriter();
+
+ writer.WriteMultiProcessElement(data);
+ byte[] output = writer.GetData();
+
+ Assert.Equal(expected, output);
+ }
+
+ [Theory]
+ [MemberData(nameof(IccTestDataMultiProcessElement.CurveSetTestData), MemberType = typeof(IccTestDataMultiProcessElement))]
+ internal void WriteCurveSetProcessElement(byte[] expected, IccCurveSetProcessElement data, int inChannelCount, int outChannelCount)
+ {
+ IccDataWriter writer = CreateWriter();
+
+ writer.WriteCurveSetProcessElement(data);
+ byte[] output = writer.GetData();
+
+ Assert.Equal(expected, output);
+ }
+
+ [Theory]
+ [MemberData(nameof(IccTestDataMultiProcessElement.MatrixTestData), MemberType = typeof(IccTestDataMultiProcessElement))]
+ internal void WriteMatrixProcessElement(byte[] expected, IccMatrixProcessElement data, int inChannelCount, int outChannelCount)
+ {
+ IccDataWriter writer = CreateWriter();
+
+ writer.WriteMatrixProcessElement(data);
+ byte[] output = writer.GetData();
+
+ Assert.Equal(expected, output);
+ }
+
+ [Theory]
+ [MemberData(nameof(IccTestDataMultiProcessElement.ClutTestData), MemberType = typeof(IccTestDataMultiProcessElement))]
+ internal void WriteClutProcessElement(byte[] expected, IccClutProcessElement data, int inChannelCount, int outChannelCount)
+ {
+ IccDataWriter writer = CreateWriter();
+
+ writer.WriteClutProcessElement(data);
+ byte[] output = writer.GetData();
+
+ Assert.Equal(expected, output);
+ }
+
+ private IccDataWriter CreateWriter()
+ {
+ return new IccDataWriter();
+ }
+ }
+}
diff --git a/tests/ImageSharp.Tests/MetaData/Profiles/ICC/DataWriter/IccDataWriter.NonPrimitivesTests.cs b/tests/ImageSharp.Tests/MetaData/Profiles/ICC/DataWriter/IccDataWriter.NonPrimitivesTests.cs
new file mode 100644
index 000000000..ae3ab748b
--- /dev/null
+++ b/tests/ImageSharp.Tests/MetaData/Profiles/ICC/DataWriter/IccDataWriter.NonPrimitivesTests.cs
@@ -0,0 +1,115 @@
+//
+// Copyright (c) James Jackson-South and contributors.
+// Licensed under the Apache License, Version 2.0.
+//
+
+namespace ImageSharp.Tests.Icc
+{
+ using System;
+ using System.Numerics;
+ using Xunit;
+
+ public class IccDataWriterNonPrimitivesTests
+ {
+ [Theory]
+ [MemberData(nameof(IccTestDataNonPrimitives.DateTimeTestData), MemberType = typeof(IccTestDataNonPrimitives))]
+ public void WriteDateTime(byte[] expected, DateTime data)
+ {
+ IccDataWriter writer = CreateWriter();
+
+ writer.WriteDateTime(data);
+ byte[] output = writer.GetData();
+
+ Assert.Equal(expected, output);
+ }
+
+ [Theory]
+ [MemberData(nameof(IccTestDataNonPrimitives.VersionNumberTestData), MemberType = typeof(IccTestDataNonPrimitives))]
+ public void WriteVersionNumber(byte[] expected, Version data)
+ {
+ IccDataWriter writer = CreateWriter();
+
+ writer.WriteVersionNumber(data);
+ byte[] output = writer.GetData();
+
+ Assert.Equal(expected, output);
+ }
+
+ [Theory]
+ [MemberData(nameof(IccTestDataNonPrimitives.XyzNumberTestData), MemberType = typeof(IccTestDataNonPrimitives))]
+ public void WriteXyzNumber(byte[] expected, Vector3 data)
+ {
+ IccDataWriter writer = CreateWriter();
+
+ writer.WriteXyzNumber(data);
+ byte[] output = writer.GetData();
+
+ Assert.Equal(expected, output);
+ }
+
+ [Theory]
+ [MemberData(nameof(IccTestDataNonPrimitives.ProfileIdTestData), MemberType = typeof(IccTestDataNonPrimitives))]
+ internal void WriteProfileId(byte[] expected, IccProfileId data)
+ {
+ IccDataWriter writer = CreateWriter();
+
+ writer.WriteProfileId(data);
+ byte[] output = writer.GetData();
+
+ Assert.Equal(expected, output);
+ }
+
+ [Theory]
+ [MemberData(nameof(IccTestDataNonPrimitives.PositionNumberTestData), MemberType = typeof(IccTestDataNonPrimitives))]
+ internal void WritePositionNumber(byte[] expected, IccPositionNumber data)
+ {
+ IccDataWriter writer = CreateWriter();
+
+ writer.WritePositionNumber(data);
+ byte[] output = writer.GetData();
+
+ Assert.Equal(expected, output);
+ }
+
+ [Theory]
+ [MemberData(nameof(IccTestDataNonPrimitives.ResponseNumberTestData), MemberType = typeof(IccTestDataNonPrimitives))]
+ internal void WriteResponseNumber(byte[] expected, IccResponseNumber data)
+ {
+ IccDataWriter writer = CreateWriter();
+
+ writer.WriteResponseNumber(data);
+ byte[] output = writer.GetData();
+
+ Assert.Equal(expected, output);
+ }
+
+ [Theory]
+ [MemberData(nameof(IccTestDataNonPrimitives.NamedColorTestData), MemberType = typeof(IccTestDataNonPrimitives))]
+ internal void WriteNamedColor(byte[] expected, IccNamedColor data, uint coordinateCount)
+ {
+ IccDataWriter writer = CreateWriter();
+
+ writer.WriteNamedColor(data);
+ byte[] output = writer.GetData();
+
+ Assert.Equal(expected, output);
+ }
+
+ [Theory]
+ [MemberData(nameof(IccTestDataNonPrimitives.ProfileDescriptionTestData), MemberType = typeof(IccTestDataNonPrimitives))]
+ internal void WriteProfileDescription(byte[] expected, IccProfileDescription data)
+ {
+ IccDataWriter writer = CreateWriter();
+
+ writer.WriteProfileDescription(data);
+ byte[] output = writer.GetData();
+
+ Assert.Equal(expected, output);
+ }
+
+ private IccDataWriter CreateWriter()
+ {
+ return new IccDataWriter();
+ }
+ }
+}
diff --git a/tests/ImageSharp.Tests/MetaData/Profiles/ICC/DataWriter/IccDataWriter.PrimitivesTests.cs b/tests/ImageSharp.Tests/MetaData/Profiles/ICC/DataWriter/IccDataWriter.PrimitivesTests.cs
new file mode 100644
index 000000000..8d0cd32ab
--- /dev/null
+++ b/tests/ImageSharp.Tests/MetaData/Profiles/ICC/DataWriter/IccDataWriter.PrimitivesTests.cs
@@ -0,0 +1,122 @@
+//
+// Copyright (c) James Jackson-South and contributors.
+// Licensed under the Apache License, Version 2.0.
+//
+
+namespace ImageSharp.Tests.Icc
+{
+ using System;
+ using Xunit;
+
+ public class IccDataWriterPrimitivesTests
+ {
+ [Theory]
+ [MemberData(nameof(IccTestDataPrimitives.AsciiWriteTestData), MemberType = typeof(IccTestDataPrimitives))]
+ public void WriteAsciiString(byte[] expected, string data)
+ {
+ IccDataWriter writer = CreateWriter();
+
+ writer.WriteAsciiString(data);
+ byte[] output = writer.GetData();
+
+ Assert.Equal(expected, output);
+ }
+
+ [Theory]
+ [MemberData(nameof(IccTestDataPrimitives.AsciiPaddingTestData), MemberType = typeof(IccTestDataPrimitives))]
+ public void WriteAsciiStringPadded(byte[] expected, int length, string data, bool ensureNullTerminator)
+ {
+ IccDataWriter writer = CreateWriter();
+
+ writer.WriteAsciiString(data, length, ensureNullTerminator);
+ byte[] output = writer.GetData();
+
+ Assert.Equal(expected, output);
+ }
+
+ [Fact]
+ public void WriteAsciiStringWithNullWritesEmpty()
+ {
+ IccDataWriter writer = CreateWriter();
+
+ int count = writer.WriteAsciiString(null);
+ byte[] output = writer.GetData();
+
+ Assert.Equal(0, count);
+ Assert.Equal(new byte[0], output);
+ }
+
+ [Fact]
+ public void WriteAsciiStringWithNegativeLenghtThrowsArgumentException()
+ {
+ IccDataWriter writer = CreateWriter();
+
+ Assert.Throws(() => writer.WriteAsciiString("abcd", -1, false));
+ }
+
+ [Fact]
+ public void WriteUnicodeStringWithNullWritesEmpty()
+ {
+ IccDataWriter writer = CreateWriter();
+
+ int count = writer.WriteUnicodeString(null);
+ byte[] output = writer.GetData();
+
+ Assert.Equal(0, count);
+ Assert.Equal(new byte[0], output);
+ }
+
+ [Theory]
+ [MemberData(nameof(IccTestDataPrimitives.Fix16TestData), MemberType = typeof(IccTestDataPrimitives))]
+ public void WriteFix16(byte[] expected, float data)
+ {
+ IccDataWriter writer = CreateWriter();
+
+ writer.WriteFix16(data);
+ byte[] output = writer.GetData();
+
+ Assert.Equal(expected, output);
+ }
+
+ [Theory]
+ [MemberData(nameof(IccTestDataPrimitives.UFix16TestData), MemberType = typeof(IccTestDataPrimitives))]
+ public void WriteUFix16(byte[] expected, float data)
+ {
+ IccDataWriter writer = CreateWriter();
+
+ writer.WriteUFix16(data);
+ byte[] output = writer.GetData();
+
+ Assert.Equal(expected, output);
+ }
+
+ [Theory]
+ [MemberData(nameof(IccTestDataPrimitives.U1Fix15TestData), MemberType = typeof(IccTestDataPrimitives))]
+ public void WriteU1Fix15(byte[] expected, float data)
+ {
+ IccDataWriter writer = CreateWriter();
+
+ writer.WriteU1Fix15(data);
+ byte[] output = writer.GetData();
+
+ Assert.Equal(expected, output);
+ }
+
+ [Theory]
+ [MemberData(nameof(IccTestDataPrimitives.UFix8TestData), MemberType = typeof(IccTestDataPrimitives))]
+ public void WriteUFix8(byte[] expected, float data)
+ {
+ IccDataWriter writer = CreateWriter();
+
+ writer.WriteUFix8(data);
+ byte[] output = writer.GetData();
+
+ Assert.Equal(expected, output);
+ }
+
+ private IccDataWriter CreateWriter()
+ {
+ return new IccDataWriter();
+ }
+ }
+}
diff --git a/tests/ImageSharp.Tests/MetaData/Profiles/ICC/DataWriter/IccDataWriter.TagDataEntryTests.cs b/tests/ImageSharp.Tests/MetaData/Profiles/ICC/DataWriter/IccDataWriter.TagDataEntryTests.cs
new file mode 100644
index 000000000..8c953a0aa
--- /dev/null
+++ b/tests/ImageSharp.Tests/MetaData/Profiles/ICC/DataWriter/IccDataWriter.TagDataEntryTests.cs
@@ -0,0 +1,377 @@
+//
+// Copyright (c) James Jackson-South and contributors.
+// Licensed under the Apache License, Version 2.0.
+//
+
+namespace ImageSharp.Tests.Icc
+{
+ using Xunit;
+
+ public class IccDataWriterTagDataEntryTests
+ {
+ [Theory]
+ [MemberData(nameof(IccTestDataTagDataEntry.UnknownTagDataEntryTestData), MemberType = typeof(IccTestDataTagDataEntry))]
+ internal void WriteUnknownTagDataEntry(byte[] expected, IccUnknownTagDataEntry data, uint size)
+ {
+ IccDataWriter writer = CreateWriter();
+
+ writer.WriteUnknownTagDataEntry(data);
+ byte[] output = writer.GetData();
+
+ Assert.Equal(expected, output);
+ }
+
+ [Theory]
+ [MemberData(nameof(IccTestDataTagDataEntry.ChromaticityTagDataEntryTestData), MemberType = typeof(IccTestDataTagDataEntry))]
+ internal void WriteChromaticityTagDataEntry(byte[] expected, IccChromaticityTagDataEntry data)
+ {
+ IccDataWriter writer = CreateWriter();
+
+ writer.WriteChromaticityTagDataEntry(data);
+ byte[] output = writer.GetData();
+
+ Assert.Equal(expected, output);
+ }
+
+ [Theory]
+ [MemberData(nameof(IccTestDataTagDataEntry.ColorantOrderTagDataEntryTestData), MemberType = typeof(IccTestDataTagDataEntry))]
+ internal void WriteColorantOrderTagDataEntry(byte[] expected, IccColorantOrderTagDataEntry data)
+ {
+ IccDataWriter writer = CreateWriter();
+
+ writer.WriteColorantOrderTagDataEntry(data);
+ byte[] output = writer.GetData();
+
+ Assert.Equal(expected, output);
+ }
+
+ [Theory]
+ [MemberData(nameof(IccTestDataTagDataEntry.ColorantTableTagDataEntryTestData), MemberType = typeof(IccTestDataTagDataEntry))]
+ internal void WriteColorantTableTagDataEntry(byte[] expected, IccColorantTableTagDataEntry data)
+ {
+ IccDataWriter writer = CreateWriter();
+
+ writer.WriteColorantTableTagDataEntry(data);
+ byte[] output = writer.GetData();
+
+ Assert.Equal(expected, output);
+ }
+
+ [Theory]
+ [MemberData(nameof(IccTestDataTagDataEntry.CurveTagDataEntryTestData), MemberType = typeof(IccTestDataTagDataEntry))]
+ internal void WriteCurveTagDataEntry(byte[] expected, IccCurveTagDataEntry data)
+ {
+ IccDataWriter writer = CreateWriter();
+
+ writer.WriteCurveTagDataEntry(data);
+ byte[] output = writer.GetData();
+
+ Assert.Equal(expected, output);
+ }
+
+ [Theory]
+ [MemberData(nameof(IccTestDataTagDataEntry.DataTagDataEntryTestData), MemberType = typeof(IccTestDataTagDataEntry))]
+ internal void WriteDataTagDataEntry(byte[] expected, IccDataTagDataEntry data, uint size)
+ {
+ IccDataWriter writer = CreateWriter();
+
+ writer.WriteDataTagDataEntry(data);
+ byte[] output = writer.GetData();
+
+ Assert.Equal(expected, output);
+ }
+
+ [Theory]
+ [MemberData(nameof(IccTestDataTagDataEntry.DateTimeTagDataEntryTestData), MemberType = typeof(IccTestDataTagDataEntry))]
+ internal void WriteDateTimeTagDataEntry(byte[] expected, IccDateTimeTagDataEntry data)
+ {
+ IccDataWriter writer = CreateWriter();
+
+ writer.WriteDateTimeTagDataEntry(data);
+ byte[] output = writer.GetData();
+
+ Assert.Equal(expected, output);
+ }
+
+ [Theory]
+ [MemberData(nameof(IccTestDataTagDataEntry.Lut16TagDataEntryTestData), MemberType = typeof(IccTestDataTagDataEntry))]
+ internal void WriteLut16TagDataEntry(byte[] expected, IccLut16TagDataEntry data)
+ {
+ IccDataWriter writer = CreateWriter();
+
+ writer.WriteLut16TagDataEntry(data);
+ byte[] output = writer.GetData();
+
+ Assert.Equal(expected, output);
+ }
+
+ [Theory]
+ [MemberData(nameof(IccTestDataTagDataEntry.Lut8TagDataEntryTestData), MemberType = typeof(IccTestDataTagDataEntry))]
+ internal void WriteLut8TagDataEntry(byte[] expected, IccLut8TagDataEntry data)
+ {
+ IccDataWriter writer = CreateWriter();
+
+ writer.WriteLut8TagDataEntry(data);
+ byte[] output = writer.GetData();
+
+ Assert.Equal(expected, output);
+ }
+
+ [Theory]
+ [MemberData(nameof(IccTestDataTagDataEntry.LutAToBTagDataEntryTestData), MemberType = typeof(IccTestDataTagDataEntry))]
+ internal void WriteLutAToBTagDataEntry(byte[] expected, IccLutAToBTagDataEntry data)
+ {
+ IccDataWriter writer = CreateWriter();
+
+ writer.WriteLutAToBTagDataEntry(data);
+ byte[] output = writer.GetData();
+
+ Assert.Equal(expected, output);
+ }
+
+ [Theory]
+ [MemberData(nameof(IccTestDataTagDataEntry.LutBToATagDataEntryTestData), MemberType = typeof(IccTestDataTagDataEntry))]
+ internal void WriteLutBToATagDataEntry(byte[] expected, IccLutBToATagDataEntry data)
+ {
+ IccDataWriter writer = CreateWriter();
+
+ writer.WriteLutBToATagDataEntry(data);
+ byte[] output = writer.GetData();
+
+ Assert.Equal(expected, output);
+ }
+
+ [Theory]
+ [MemberData(nameof(IccTestDataTagDataEntry.MeasurementTagDataEntryTestData), MemberType = typeof(IccTestDataTagDataEntry))]
+ internal void WriteMeasurementTagDataEntry(byte[] expected, IccMeasurementTagDataEntry data)
+ {
+ IccDataWriter writer = CreateWriter();
+
+ writer.WriteMeasurementTagDataEntry(data);
+ byte[] output = writer.GetData();
+
+ Assert.Equal(expected, output);
+ }
+
+ [Theory]
+ [MemberData(nameof(IccTestDataTagDataEntry.MultiLocalizedUnicodeTagDataEntryTestData), MemberType = typeof(IccTestDataTagDataEntry))]
+ internal void WriteMultiLocalizedUnicodeTagDataEntry(byte[] expected, IccMultiLocalizedUnicodeTagDataEntry data)
+ {
+ IccDataWriter writer = CreateWriter();
+
+ writer.WriteMultiLocalizedUnicodeTagDataEntry(data);
+ byte[] output = writer.GetData();
+
+ Assert.Equal(expected, output);
+ }
+
+ [Theory]
+ [MemberData(nameof(IccTestDataTagDataEntry.MultiProcessElementsTagDataEntryTestData), MemberType = typeof(IccTestDataTagDataEntry))]
+ internal void WriteMultiProcessElementsTagDataEntry(byte[] expected, IccMultiProcessElementsTagDataEntry data)
+ {
+ IccDataWriter writer = CreateWriter();
+
+ writer.WriteMultiProcessElementsTagDataEntry(data);
+ byte[] output = writer.GetData();
+
+ Assert.Equal(expected, output);
+ }
+
+ [Theory]
+ [MemberData(nameof(IccTestDataTagDataEntry.NamedColor2TagDataEntryTestData), MemberType = typeof(IccTestDataTagDataEntry))]
+ internal void WriteNamedColor2TagDataEntry(byte[] expected, IccNamedColor2TagDataEntry data)
+ {
+ IccDataWriter writer = CreateWriter();
+
+ writer.WriteNamedColor2TagDataEntry(data);
+ byte[] output = writer.GetData();
+
+ Assert.Equal(expected, output);
+ }
+
+ [Theory]
+ [MemberData(nameof(IccTestDataTagDataEntry.ParametricCurveTagDataEntryTestData), MemberType = typeof(IccTestDataTagDataEntry))]
+ internal void WriteParametricCurveTagDataEntry(byte[] expected, IccParametricCurveTagDataEntry data)
+ {
+ IccDataWriter writer = CreateWriter();
+
+ writer.WriteParametricCurveTagDataEntry(data);
+ byte[] output = writer.GetData();
+
+ Assert.Equal(expected, output);
+ }
+
+ [Theory]
+ [MemberData(nameof(IccTestDataTagDataEntry.ProfileSequenceDescTagDataEntryTestData), MemberType = typeof(IccTestDataTagDataEntry))]
+ internal void WriteProfileSequenceDescTagDataEntry(byte[] expected, IccProfileSequenceDescTagDataEntry data)
+ {
+ IccDataWriter writer = CreateWriter();
+
+ writer.WriteProfileSequenceDescTagDataEntry(data);
+ byte[] output = writer.GetData();
+
+ Assert.Equal(expected, output);
+ }
+
+ [Theory]
+ [MemberData(nameof(IccTestDataTagDataEntry.ProfileSequenceIdentifierTagDataEntryTestData), MemberType = typeof(IccTestDataTagDataEntry))]
+ internal void WriteProfileSequenceIdentifierTagDataEntry(byte[] expected, IccProfileSequenceIdentifierTagDataEntry data)
+ {
+ IccDataWriter writer = CreateWriter();
+
+ writer.WriteProfileSequenceIdentifierTagDataEntry(data);
+ byte[] output = writer.GetData();
+
+ Assert.Equal(expected, output);
+ }
+
+ [Theory]
+ [MemberData(nameof(IccTestDataTagDataEntry.ResponseCurveSet16TagDataEntryTestData), MemberType = typeof(IccTestDataTagDataEntry))]
+ internal void WriteResponseCurveSet16TagDataEntry(byte[] expected, IccResponseCurveSet16TagDataEntry data)
+ {
+ IccDataWriter writer = CreateWriter();
+
+ writer.WriteResponseCurveSet16TagDataEntry(data);
+ byte[] output = writer.GetData();
+
+ Assert.Equal(expected, output);
+ }
+
+ [Theory]
+ [MemberData(nameof(IccTestDataTagDataEntry.Fix16ArrayTagDataEntryTestData), MemberType = typeof(IccTestDataTagDataEntry))]
+ internal void WriteFix16ArrayTagDataEntry(byte[] expected, IccFix16ArrayTagDataEntry data, uint size)
+ {
+ IccDataWriter writer = CreateWriter();
+
+ writer.WriteFix16ArrayTagDataEntry(data);
+ byte[] output = writer.GetData();
+
+ Assert.Equal(expected, output);
+ }
+
+ [Theory]
+ [MemberData(nameof(IccTestDataTagDataEntry.SignatureTagDataEntryTestData), MemberType = typeof(IccTestDataTagDataEntry))]
+ internal void WriteSignatureTagDataEntry(byte[] expected, IccSignatureTagDataEntry data)
+ {
+ IccDataWriter writer = CreateWriter();
+
+ writer.WriteSignatureTagDataEntry(data);
+ byte[] output = writer.GetData();
+
+ Assert.Equal(expected, output);
+ }
+
+ [Theory]
+ [MemberData(nameof(IccTestDataTagDataEntry.TextTagDataEntryTestData), MemberType = typeof(IccTestDataTagDataEntry))]
+ internal void WriteTextTagDataEntry(byte[] expected, IccTextTagDataEntry data, uint size)
+ {
+ IccDataWriter writer = CreateWriter();
+
+ writer.WriteTextTagDataEntry(data);
+ byte[] output = writer.GetData();
+
+ Assert.Equal(expected, output);
+ }
+
+ [Theory]
+ [MemberData(nameof(IccTestDataTagDataEntry.UFix16ArrayTagDataEntryTestData), MemberType = typeof(IccTestDataTagDataEntry))]
+ internal void WriteUFix16ArrayTagDataEntry(byte[] expected, IccUFix16ArrayTagDataEntry data, uint size)
+ {
+ IccDataWriter writer = CreateWriter();
+
+ writer.WriteUFix16ArrayTagDataEntry(data);
+ byte[] output = writer.GetData();
+
+ Assert.Equal(expected, output);
+ }
+
+ [Theory]
+ [MemberData(nameof(IccTestDataTagDataEntry.UInt16ArrayTagDataEntryTestData), MemberType = typeof(IccTestDataTagDataEntry))]
+ internal void WriteUInt16ArrayTagDataEntry(byte[] expected, IccUInt16ArrayTagDataEntry data, uint size)
+ {
+ IccDataWriter writer = CreateWriter();
+
+ writer.WriteUInt16ArrayTagDataEntry(data);
+ byte[] output = writer.GetData();
+
+ Assert.Equal(expected, output);
+ }
+
+ [Theory]
+ [MemberData(nameof(IccTestDataTagDataEntry.UInt32ArrayTagDataEntryTestData), MemberType = typeof(IccTestDataTagDataEntry))]
+ internal void WriteUInt32ArrayTagDataEntry(byte[] expected, IccUInt32ArrayTagDataEntry data, uint size)
+ {
+ IccDataWriter writer = CreateWriter();
+
+ writer.WriteUInt32ArrayTagDataEntry(data);
+ byte[] output = writer.GetData();
+
+ Assert.Equal(expected, output);
+ }
+
+ [Theory]
+ [MemberData(nameof(IccTestDataTagDataEntry.UInt64ArrayTagDataEntryTestData), MemberType = typeof(IccTestDataTagDataEntry))]
+ internal void WriteUInt64ArrayTagDataEntry(byte[] expected, IccUInt64ArrayTagDataEntry data, uint size)
+ {
+ IccDataWriter writer = CreateWriter();
+
+ writer.WriteUInt64ArrayTagDataEntry(data);
+ byte[] output = writer.GetData();
+
+ Assert.Equal(expected, output);
+ }
+
+ [Theory]
+ [MemberData(nameof(IccTestDataTagDataEntry.UInt8ArrayTagDataEntryTestData), MemberType = typeof(IccTestDataTagDataEntry))]
+ internal void WriteUInt8ArrayTagDataEntry(byte[] expected, IccUInt8ArrayTagDataEntry data, uint size)
+ {
+ IccDataWriter writer = CreateWriter();
+
+ writer.WriteUInt8ArrayTagDataEntry(data);
+ byte[] output = writer.GetData();
+
+ Assert.Equal(expected, output);
+ }
+
+ [Theory]
+ [MemberData(nameof(IccTestDataTagDataEntry.ViewingConditionsTagDataEntryTestData), MemberType = typeof(IccTestDataTagDataEntry))]
+ internal void WriteViewingConditionsTagDataEntry(byte[] expected, IccViewingConditionsTagDataEntry data)
+ {
+ IccDataWriter writer = CreateWriter();
+
+ writer.WriteViewingConditionsTagDataEntry(data);
+ byte[] output = writer.GetData();
+
+ Assert.Equal(expected, output);
+ }
+
+ [Theory]
+ [MemberData(nameof(IccTestDataTagDataEntry.XYZTagDataEntryTestData), MemberType = typeof(IccTestDataTagDataEntry))]
+ internal void WriteXyzTagDataEntry(byte[] expected, IccXyzTagDataEntry data, uint size)
+ {
+ IccDataWriter writer = CreateWriter();
+
+ writer.WriteXyzTagDataEntry(data);
+ byte[] output = writer.GetData();
+
+ Assert.Equal(expected, output);
+ }
+
+ [Theory]
+ [MemberData(nameof(IccTestDataTagDataEntry.TextDescriptionTagDataEntryTestData), MemberType = typeof(IccTestDataTagDataEntry))]
+ internal void WriteTextDescriptionTagDataEntry(byte[] expected, IccTextDescriptionTagDataEntry data)
+ {
+ IccDataWriter writer = CreateWriter();
+
+ writer.WriteTextDescriptionTagDataEntry(data);
+ byte[] output = writer.GetData();
+
+ Assert.Equal(expected, output);
+ }
+
+ private IccDataWriter CreateWriter()
+ {
+ return new IccDataWriter();
+ }
+ }
+}
diff --git a/tests/ImageSharp.Tests/MetaData/Profiles/ICC/DataWriter/IccDataWriterTests.cs b/tests/ImageSharp.Tests/MetaData/Profiles/ICC/DataWriter/IccDataWriterTests.cs
new file mode 100644
index 000000000..5239d7cd5
--- /dev/null
+++ b/tests/ImageSharp.Tests/MetaData/Profiles/ICC/DataWriter/IccDataWriterTests.cs
@@ -0,0 +1,114 @@
+//
+// Copyright (c) James Jackson-South and contributors.
+// Licensed under the Apache License, Version 2.0.
+//
+
+namespace ImageSharp.Tests.Icc
+{
+ using Xunit;
+
+ public class IccDataWriterTests
+ {
+ [Fact]
+ public void WriteEmpty()
+ {
+ IccDataWriter writer = CreateWriter();
+
+ writer.WriteEmpty(4);
+ byte[] output = writer.GetData();
+
+ Assert.Equal(new byte[4], output);
+ }
+
+ [Theory]
+ [InlineData(1, 4)]
+ [InlineData(4, 4)]
+ public void WritePadding(int writePosition, int expectedLength)
+ {
+ IccDataWriter writer = CreateWriter();
+
+ writer.WriteEmpty(writePosition);
+ writer.WritePadding();
+ byte[] output = writer.GetData();
+
+ Assert.Equal(new byte[expectedLength], output);
+ }
+
+ [Theory]
+ [MemberData(nameof(IccTestDataArray.UInt8TestData), MemberType = typeof(IccTestDataArray))]
+ public void WriteArrayUInt8(byte[] data, byte[] expected)
+ {
+ IccDataWriter writer = CreateWriter();
+
+ writer.WriteArray(data);
+ byte[] output = writer.GetData();
+
+ Assert.Equal(expected, output);
+ }
+
+ [Theory]
+ [MemberData(nameof(IccTestDataArray.UInt16TestData), MemberType = typeof(IccTestDataArray))]
+ public void WriteArrayUInt16(byte[] expected, ushort[] data)
+ {
+ IccDataWriter writer = CreateWriter();
+
+ writer.WriteArray(data);
+ byte[] output = writer.GetData();
+
+ Assert.Equal(expected, output);
+ }
+
+ [Theory]
+ [MemberData(nameof(IccTestDataArray.Int16TestData), MemberType = typeof(IccTestDataArray))]
+ public void WriteArrayInt16(byte[] expected, short[] data)
+ {
+ IccDataWriter writer = CreateWriter();
+
+ writer.WriteArray(data);
+ byte[] output = writer.GetData();
+
+ Assert.Equal(expected, output);
+ }
+
+ [Theory]
+ [MemberData(nameof(IccTestDataArray.UInt32TestData), MemberType = typeof(IccTestDataArray))]
+ public void WriteArrayUInt32(byte[] expected, uint[] data)
+ {
+ IccDataWriter writer = CreateWriter();
+
+ writer.WriteArray(data);
+ byte[] output = writer.GetData();
+
+ Assert.Equal(expected, output);
+ }
+
+ [Theory]
+ [MemberData(nameof(IccTestDataArray.Int32TestData), MemberType = typeof(IccTestDataArray))]
+ public void WriteArrayInt32(byte[] expected, int[] data)
+ {
+ IccDataWriter writer = CreateWriter();
+
+ writer.WriteArray(data);
+ byte[] output = writer.GetData();
+
+ Assert.Equal(expected, output);
+ }
+
+ [Theory]
+ [MemberData(nameof(IccTestDataArray.UInt64TestData), MemberType = typeof(IccTestDataArray))]
+ public void WriteArrayUInt64(byte[] expected, ulong[] data)
+ {
+ IccDataWriter writer = CreateWriter();
+
+ writer.WriteArray(data);
+ byte[] output = writer.GetData();
+
+ Assert.Equal(expected, output);
+ }
+
+ private IccDataWriter CreateWriter()
+ {
+ return new IccDataWriter();
+ }
+ }
+}
diff --git a/tests/ImageSharp.Tests/MetaData/Profiles/ICC/IccReaderTests.cs b/tests/ImageSharp.Tests/MetaData/Profiles/ICC/IccReaderTests.cs
new file mode 100644
index 000000000..0db64c47f
--- /dev/null
+++ b/tests/ImageSharp.Tests/MetaData/Profiles/ICC/IccReaderTests.cs
@@ -0,0 +1,48 @@
+//
+// Copyright (c) James Jackson-South and contributors.
+// Licensed under the Apache License, Version 2.0.
+//
+
+namespace ImageSharp.Tests.Icc
+{
+ using Xunit;
+
+ public class IccReaderTests
+ {
+ [Fact]
+ public void ReadProfile()
+ {
+ IccReader reader = CreateReader();
+
+ IccProfile output = reader.Read(IccTestDataProfiles.Header_Random_Array);
+
+ Assert.Equal(0, output.Entries.Count);
+ Assert.NotNull(output.Header);
+
+ IccProfileHeader header = output.Header;
+ IccProfileHeader expected = IccTestDataProfiles.Header_Random_Read;
+ Assert.Equal(header.Class, expected.Class);
+ Assert.Equal(header.CmmType, expected.CmmType);
+ Assert.Equal(header.CreationDate, expected.CreationDate);
+ Assert.Equal(header.CreatorSignature, expected.CreatorSignature);
+ Assert.Equal(header.DataColorSpace, expected.DataColorSpace);
+ Assert.Equal(header.DeviceAttributes, expected.DeviceAttributes);
+ Assert.Equal(header.DeviceManufacturer, expected.DeviceManufacturer);
+ Assert.Equal(header.DeviceModel, expected.DeviceModel);
+ Assert.Equal(header.FileSignature, expected.FileSignature);
+ Assert.Equal(header.Flags, expected.Flags);
+ Assert.Equal(header.Id, expected.Id);
+ Assert.Equal(header.PcsIlluminant, expected.PcsIlluminant);
+ Assert.Equal(header.PrimaryPlatformSignature, expected.PrimaryPlatformSignature);
+ Assert.Equal(header.ProfileConnectionSpace, expected.ProfileConnectionSpace);
+ Assert.Equal(header.RenderingIntent, expected.RenderingIntent);
+ Assert.Equal(header.Size, expected.Size);
+ Assert.Equal(header.Version, expected.Version);
+ }
+
+ 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
new file mode 100644
index 000000000..6192e6eae
--- /dev/null
+++ b/tests/ImageSharp.Tests/MetaData/Profiles/ICC/IccWriterTests.cs
@@ -0,0 +1,31 @@
+//
+// Copyright (c) James Jackson-South and contributors.
+// Licensed under the Apache License, Version 2.0.
+//
+
+namespace ImageSharp.Tests.Icc
+{
+ using Xunit;
+
+ public class IccWriterTests
+ {
+ [Fact]
+ public void WriteProfile()
+ {
+ IccWriter writer = CreateWriter();
+
+ IccProfile profile = new IccProfile()
+ {
+ Header = IccTestDataProfiles.Header_Random_Write
+ };
+ byte[] output = writer.Write(profile);
+
+ Assert.Equal(IccTestDataProfiles.Header_Random_Array, output);
+ }
+
+ private IccWriter CreateWriter()
+ {
+ return new IccWriter();
+ }
+ }
+}
diff --git a/tests/ImageSharp.Tests/TestDataIcc/IccTestDataArray.cs b/tests/ImageSharp.Tests/TestDataIcc/IccTestDataArray.cs
new file mode 100644
index 000000000..a14433f1e
--- /dev/null
+++ b/tests/ImageSharp.Tests/TestDataIcc/IccTestDataArray.cs
@@ -0,0 +1,146 @@
+//
+// Copyright (c) James Jackson-South and contributors.
+// Licensed under the Apache License, Version 2.0.
+//
+
+namespace ImageSharp.Tests
+{
+ internal static class IccTestDataArray
+ {
+ #region Byte
+
+ public static readonly byte[] UInt8 = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
+
+ public static readonly object[][] UInt8TestData =
+ {
+ new object[] { UInt8, UInt8 }
+ };
+
+ #endregion
+
+ #region UInt16
+
+ 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 object[][] UInt16TestData =
+ {
+ new object[] { UInt16_Arr, UInt16_Val }
+ };
+
+ #endregion
+
+ #region Int16
+
+ public static readonly short[] Int16_Val = { 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 object[][] Int16TestData =
+ {
+ new object[] { Int16_Arr, Int16_Val }
+ };
+
+ #endregion
+
+ #region UInt32
+
+ public static readonly uint[] UInt32_Val = { 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 object[][] UInt32TestData =
+ {
+ new object[] { UInt32_Arr, UInt32_Val }
+ };
+
+ #endregion
+
+ #region Int32
+
+ public static readonly int[] Int32_Val = { 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 object[][] Int32TestData =
+ {
+ new object[] { Int32_Arr, Int32_Val }
+ };
+
+ #endregion
+
+ #region UInt64
+
+ public static readonly ulong[] UInt64_Val = { 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 object[][] UInt64TestData =
+ {
+ new object[] { UInt64_Arr, UInt64_Val }
+ };
+
+ #endregion
+ }
+}
diff --git a/tests/ImageSharp.Tests/TestDataIcc/IccTestDataCurves.cs b/tests/ImageSharp.Tests/TestDataIcc/IccTestDataCurves.cs
new file mode 100644
index 000000000..c8d517aac
--- /dev/null
+++ b/tests/ImageSharp.Tests/TestDataIcc/IccTestDataCurves.cs
@@ -0,0 +1,386 @@
+//
+// Copyright (c) James Jackson-South and contributors.
+// Licensed under the Apache License, Version 2.0.
+//
+
+namespace ImageSharp.Tests
+{
+ using System.Numerics;
+
+ internal static class IccTestDataCurves
+ {
+ #region Response
+
+ ///
+ /// Channels: 3
+ ///
+ public static readonly IccResponseCurve Response_ValGrad = new IccResponseCurve
+ (
+ IccCurveMeasurementEncodings.StatusA,
+ new Vector3[]
+ {
+ IccTestDataNonPrimitives.XyzNumber_ValVar1,
+ IccTestDataNonPrimitives.XyzNumber_ValVar2,
+ IccTestDataNonPrimitives.XyzNumber_ValVar3,
+ },
+ new IccResponseNumber[][]
+ {
+ new IccResponseNumber[] { IccTestDataNonPrimitives.ResponseNumber_Val1, IccTestDataNonPrimitives.ResponseNumber_Val2 },
+ new IccResponseNumber[] { IccTestDataNonPrimitives.ResponseNumber_Val3, IccTestDataNonPrimitives.ResponseNumber_Val4 },
+ new IccResponseNumber[] { IccTestDataNonPrimitives.ResponseNumber_Val5, IccTestDataNonPrimitives.ResponseNumber_Val6 },
+ }
+ );
+
+ ///
+ /// Channels: 3
+ ///
+ public static readonly byte[] Response_Grad = 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
+ );
+
+ public static readonly object[][] ResponseCurveTestData =
+ {
+ new object[] { Response_Grad, Response_ValGrad, 3 },
+ };
+
+ #endregion
+
+ #region Parametric
+
+ 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 byte[] Parametric_Var1 = ArrayHelper.Concat
+ (
+ new byte[]
+ {
+ 0x00, 0x00,
+ 0x00, 0x00,
+ },
+ IccTestDataPrimitives.Fix16_1
+ );
+
+ public static readonly byte[] Parametric_Var2 = ArrayHelper.Concat
+ (
+ new byte[]
+ {
+ 0x00, 0x01,
+ 0x00, 0x00,
+ },
+ IccTestDataPrimitives.Fix16_1,
+ IccTestDataPrimitives.Fix16_2,
+ IccTestDataPrimitives.Fix16_3
+ );
+
+ public static readonly byte[] Parametric_Var3 = ArrayHelper.Concat
+ (
+ new byte[]
+ {
+ 0x00, 0x02,
+ 0x00, 0x00,
+ },
+ IccTestDataPrimitives.Fix16_1,
+ IccTestDataPrimitives.Fix16_2,
+ IccTestDataPrimitives.Fix16_3,
+ IccTestDataPrimitives.Fix16_4
+ );
+
+ public static readonly byte[] Parametric_Var4 = ArrayHelper.Concat
+ (
+ new byte[]
+ {
+ 0x00, 0x03,
+ 0x00, 0x00,
+ },
+ IccTestDataPrimitives.Fix16_1,
+ IccTestDataPrimitives.Fix16_2,
+ IccTestDataPrimitives.Fix16_3,
+ IccTestDataPrimitives.Fix16_4,
+ IccTestDataPrimitives.Fix16_5
+ );
+
+ public static readonly byte[] Parametric_Var5 = 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
+ );
+
+ 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 },
+ };
+
+ #endregion
+
+ #region 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 byte[] Formula_Var1 = ArrayHelper.Concat
+ (
+ new byte[]
+ {
+ 0x00, 0x00,
+ 0x00, 0x00,
+ },
+ IccTestDataPrimitives.Single_1,
+ IccTestDataPrimitives.Single_2,
+ IccTestDataPrimitives.Single_3,
+ IccTestDataPrimitives.Single_4
+ );
+
+ public static readonly byte[] Formula_Var2 = ArrayHelper.Concat
+ (
+ new byte[]
+ {
+ 0x00, 0x01,
+ 0x00, 0x00,
+ },
+ IccTestDataPrimitives.Single_1,
+ IccTestDataPrimitives.Single_2,
+ IccTestDataPrimitives.Single_3,
+ IccTestDataPrimitives.Single_4,
+ IccTestDataPrimitives.Single_5
+ );
+
+ public static readonly byte[] Formula_Var3 = ArrayHelper.Concat
+ (
+ new byte[]
+ {
+ 0x00, 0x02,
+ 0x00, 0x00,
+ },
+ IccTestDataPrimitives.Single_2,
+ IccTestDataPrimitives.Single_3,
+ IccTestDataPrimitives.Single_4,
+ IccTestDataPrimitives.Single_5,
+ IccTestDataPrimitives.Single_6
+ );
+
+ public static readonly object[][] FormulaCurveSegmentTestData =
+ {
+ new object[] { Formula_Var1, Formula_ValVar1 },
+ new object[] { Formula_Var2, Formula_ValVar2 },
+ new object[] { Formula_Var3, Formula_ValVar3 },
+ };
+
+ #endregion
+
+ #region 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 object[][] SampledCurveSegmentTestData =
+ {
+ new object[] { Sampled_Grad1, Sampled_ValGrad1 },
+ new object[] { Sampled_Grad2, Sampled_ValGrad2 },
+ };
+
+ #endregion
+
+ #region Segment
+
+ 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 byte[] Segment_Formula1 = ArrayHelper.Concat
+ (
+ new byte[]
+ {
+ 0x70, 0x61, 0x72, 0x66,
+ 0x00, 0x00, 0x00, 0x00,
+ },
+ Formula_Var1
+ );
+
+ public static readonly byte[] Segment_Formula2 = ArrayHelper.Concat
+ (
+ new byte[]
+ {
+ 0x70, 0x61, 0x72, 0x66,
+ 0x00, 0x00, 0x00, 0x00,
+ },
+ Formula_Var2
+ );
+
+ public static readonly byte[] Segment_Formula3 = ArrayHelper.Concat
+ (
+ new byte[]
+ {
+ 0x70, 0x61, 0x72, 0x66,
+ 0x00, 0x00, 0x00, 0x00,
+ },
+ Formula_Var3
+ );
+
+ public static readonly byte[] Segment_Sampled1 = ArrayHelper.Concat
+ (
+ new byte[]
+ {
+ 0x73, 0x61, 0x6D, 0x66,
+ 0x00, 0x00, 0x00, 0x00,
+ },
+ Sampled_Grad1
+ );
+
+ public static readonly byte[] Segment_Sampled2 = ArrayHelper.Concat
+ (
+ new byte[]
+ {
+ 0x73, 0x61, 0x6D, 0x66,
+ 0x00, 0x00, 0x00, 0x00,
+ },
+ Sampled_Grad2
+ );
+
+ 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 },
+ };
+
+ #endregion
+
+ #region One Dimensional
+
+ public static readonly IccOneDimensionalCurve OneDimensional_ValFormula1 = new IccOneDimensionalCurve
+ (
+ new float[] { 0, 1 },
+ new IccCurveSegment[] { Segment_ValFormula1, Segment_ValFormula2, Segment_ValFormula3 }
+ );
+ public static readonly IccOneDimensionalCurve OneDimensional_ValFormula2 = new IccOneDimensionalCurve
+ (
+ new float[] { 0, 1 },
+ new IccCurveSegment[] { Segment_ValFormula3, Segment_ValFormula2, Segment_ValFormula1 }
+ );
+ public static readonly IccOneDimensionalCurve OneDimensional_ValSampled = new IccOneDimensionalCurve
+ (
+ new float[] { 0, 1 },
+ new IccCurveSegment[] { Segment_ValSampled1, Segment_ValSampled2, Segment_ValSampled1 }
+ );
+
+ public static readonly byte[] OneDimensional_Formula1 = ArrayHelper.Concat
+ (
+ new byte[]
+ {
+ 0x00, 0x03,
+ 0x00, 0x00,
+ },
+ IccTestDataPrimitives.Single_0,
+ IccTestDataPrimitives.Single_1,
+ Segment_Formula1,
+ Segment_Formula2,
+ Segment_Formula3
+ );
+
+ public static readonly byte[] OneDimensional_Formula2 = ArrayHelper.Concat
+ (
+ new byte[]
+ {
+ 0x00, 0x03,
+ 0x00, 0x00,
+ },
+ IccTestDataPrimitives.Single_0,
+ IccTestDataPrimitives.Single_1,
+ Segment_Formula3,
+ Segment_Formula2,
+ Segment_Formula1
+ );
+
+ public static readonly byte[] OneDimensional_Sampled = ArrayHelper.Concat
+ (
+ new byte[]
+ {
+ 0x00, 0x03,
+ 0x00, 0x00,
+ },
+ IccTestDataPrimitives.Single_0,
+ IccTestDataPrimitives.Single_1,
+ Segment_Sampled1,
+ Segment_Sampled2,
+ Segment_Sampled1
+ );
+
+ public static readonly object[][] OneDimensionalCurveTestData =
+ {
+ new object[] { OneDimensional_Formula1, OneDimensional_ValFormula1 },
+ new object[] { OneDimensional_Formula2, OneDimensional_ValFormula2 },
+ new object[] { OneDimensional_Sampled, OneDimensional_ValSampled },
+ };
+
+ #endregion
+ }
+}
diff --git a/tests/ImageSharp.Tests/TestDataIcc/IccTestDataLut.cs b/tests/ImageSharp.Tests/TestDataIcc/IccTestDataLut.cs
new file mode 100644
index 000000000..cc2dfc6e9
--- /dev/null
+++ b/tests/ImageSharp.Tests/TestDataIcc/IccTestDataLut.cs
@@ -0,0 +1,254 @@
+//
+// Copyright (c) James Jackson-South and contributors.
+// Licensed under the Apache License, Version 2.0.
+//
+
+namespace ImageSharp.Tests
+{
+ internal static class IccTestDataLut
+ {
+ #region LUT8
+
+ public static readonly IccLut LUT8_ValGrad = CreateLUT8Val();
+ public static readonly byte[] LUT8_Grad = CreateLUT8();
+
+ private static IccLut CreateLUT8Val()
+ {
+ float[] result = new float[256];
+ for (int i = 0; i < 256; i++) { result[i] = i / 255f; }
+ return new IccLut(result);
+ }
+
+ private static byte[] CreateLUT8()
+ {
+ byte[] result = new byte[256];
+ for (int i = 0; i < 256; i++) { result[i] = (byte)i; }
+ return result;
+ }
+
+ public static readonly object[][] Lut8TestData =
+ {
+ new object[] { LUT8_Grad, LUT8_ValGrad },
+ };
+
+ #endregion
+
+ #region LUT16
+
+ public static readonly IccLut LUT16_ValGrad = new IccLut(new float[]
+ {
+ 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,
+ 32768f / ushort.MaxValue,
+ 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 object[][] Lut16TestData =
+ {
+ new object[] { LUT16_Grad, LUT16_ValGrad, 11 },
+ };
+
+ #endregion
+
+ #region CLUT8
+
+ public static readonly IccClut CLUT8_ValGrad = new IccClut
+ (
+ new float[][]
+ {
+ 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 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 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 byte[] { 3, 3 }, IccClutDataType.UInt8
+ );
+
+ ///
+ /// Input Channel Count: 2
+ /// Output Channel Count: 3
+ /// Grid-point Count: { 3, 3 }
+ ///
+ public static readonly byte[] CLUT8_Grad =
+ {
+ 0x01, 0x02, 0x03,
+ 0x04, 0x05, 0x06,
+ 0x07, 0x08, 0x09,
+
+ 0x0A, 0x0B, 0x0C,
+ 0x0D, 0x0E, 0x0F,
+ 0x10, 0x11, 0x12,
+
+ 0x13, 0x14, 0x15,
+ 0x16, 0x17, 0x18,
+ 0x19, 0x1A, 0x1B,
+ };
+
+ public static readonly object[][] Clut8TestData =
+ {
+ new object[] { CLUT8_Grad, CLUT8_ValGrad, 2, 3, new byte[] { 3, 3 } },
+ };
+
+ #endregion
+
+ #region CLUT16
+
+ public static readonly IccClut CLUT16_ValGrad = new IccClut
+ (
+ new float[][]
+ {
+ 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 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 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 byte[] { 3, 3 }, IccClutDataType.UInt16
+ );
+
+ ///
+ /// Input Channel Count: 2
+ /// Output Channel Count: 3
+ /// Grid-point Count: { 3, 3 }
+ ///
+ public static readonly byte[] CLUT16_Grad =
+ {
+ 0x00, 0x01, 0x00, 0x02, 0x00, 0x03,
+ 0x00, 0x04, 0x00, 0x05, 0x00, 0x06,
+ 0x00, 0x07, 0x00, 0x08, 0x00, 0x09,
+
+ 0x00, 0x0A, 0x00, 0x0B, 0x00, 0x0C,
+ 0x00, 0x0D, 0x00, 0x0E, 0x00, 0x0F,
+ 0x00, 0x10, 0x00, 0x11, 0x00, 0x12,
+
+ 0x00, 0x13, 0x00, 0x14, 0x00, 0x15,
+ 0x00, 0x16, 0x00, 0x17, 0x00, 0x18,
+ 0x00, 0x19, 0x00, 0x1A, 0x00, 0x1B,
+ };
+
+ public static readonly object[][] Clut16TestData =
+ {
+ new object[] { CLUT16_Grad, CLUT16_ValGrad, 2, 3, new byte[] { 3, 3 } },
+ };
+
+ #endregion
+
+ #region CLUTf32
+
+ public static readonly IccClut CLUTf32_ValGrad = new IccClut
+ (
+ new float[][]
+ {
+ new float[] { 1f, 2f, 3f },
+ new float[] { 4f, 5f, 6f },
+ new float[] { 7f, 8f, 9f },
+
+ new float[] { 1f, 2f, 3f },
+ new float[] { 4f, 5f, 6f },
+ new float[] { 7f, 8f, 9f },
+
+ new float[] { 1f, 2f, 3f },
+ new float[] { 4f, 5f, 6f },
+ new float[] { 7f, 8f, 9f },
+ },
+ new byte[] { 3, 3 }, IccClutDataType.Float
+ );
+
+ ///
+ /// Input Channel Count: 2
+ /// 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 object[][] ClutF32TestData =
+ {
+ new object[] { CLUTf32_Grad, CLUTf32_ValGrad, 2, 3, new byte[] { 3, 3 } },
+ };
+
+ #endregion
+
+ #region CLUT
+
+ 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 byte[] CLUT_8 = 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
+ );
+
+ public static readonly byte[] CLUT_16 = 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
+ );
+
+ public static readonly byte[] CLUT_f32 = ArrayHelper.Concat
+ (
+ new byte[16] { 0x03, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
+ CLUTf32_Grad
+ );
+
+ 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 },
+ };
+
+ #endregion
+ }
+}
diff --git a/tests/ImageSharp.Tests/TestDataIcc/IccTestDataMatrix.cs b/tests/ImageSharp.Tests/TestDataIcc/IccTestDataMatrix.cs
new file mode 100644
index 000000000..0a1be5154
--- /dev/null
+++ b/tests/ImageSharp.Tests/TestDataIcc/IccTestDataMatrix.cs
@@ -0,0 +1,175 @@
+//
+// Copyright (c) James Jackson-South and contributors.
+// Licensed under the Apache License, Version 2.0.
+//
+
+using System.Numerics;
+
+namespace ImageSharp.Tests
+{
+ internal static class IccTestDataMatrix
+ {
+ #region 2D
+
+ ///
+ /// 3x3 Matrix
+ ///
+ public static readonly float[,] Single_2DArray_ValGrad =
+ {
+ { 1, 2, 3 },
+ { 4, 5, 6 },
+ { 7, 8, 9 },
+ };
+ ///
+ /// 3x3 Matrix
+ ///
+ public static readonly float[,] Single_2DArray_ValIdentity =
+ {
+ { 1, 0, 0 },
+ { 0, 1, 0 },
+ { 0, 0, 1 },
+ };
+
+ ///
+ /// 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);
+
+ ///
+ /// 3x3 Matrix
+ ///
+ public static readonly Matrix4x4 Single_Matrix4x4_ValIdentity = Matrix4x4.Identity;
+
+ ///
+ /// 3x3 Matrix
+ ///
+ public static readonly Fast2DArray Single_Fast2DArray_ValGrad = new Fast2DArray(Single_2DArray_ValGrad);
+
+ ///
+ /// 3x3 Matrix
+ ///
+ public static readonly Fast2DArray Single_Fast2DArray_ValIdentity = new Fast2DArray(Single_2DArray_ValIdentity);
+
+ ///
+ /// 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
+ );
+
+ ///
+ /// 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
+ );
+
+ ///
+ /// 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 =
+ {
+ 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 },
+ };
+
+ public static readonly object[][] Matrix2D_Fast2DArrayTestData =
+ {
+ new object[] { Fix16_2D_Grad, 3, 3, false, Single_Fast2DArray_ValGrad },
+ new object[] { Fix16_2D_Identity, 3, 3, false, Single_Fast2DArray_ValIdentity },
+ new object[] { Single_2D_Grad, 3, 3, true, Single_Fast2DArray_ValGrad },
+ };
+
+ public static readonly object[][] Matrix2D_Matrix4x4TestData =
+ {
+ 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 },
+ };
+
+ #endregion
+
+ #region 1D
+
+ ///
+ /// 3x1 Matrix
+ ///
+ public static readonly float[] Single_1DArray_ValGrad = { 1, 4, 7 };
+ ///
+ /// 3x1 Matrix
+ ///
+ public static readonly Vector3 Single_Vector3_ValGrad = new Vector3(1, 4, 7);
+
+ ///
+ /// 3x1 Matrix
+ ///
+ public static readonly byte[] Fix16_1D_Grad = ArrayHelper.Concat
+ (
+ IccTestDataPrimitives.Fix16_1,
+ IccTestDataPrimitives.Fix16_4,
+ IccTestDataPrimitives.Fix16_7
+ );
+
+ ///
+ /// 3x1 Matrix
+ ///
+ public static readonly byte[] Single_1D_Grad = ArrayHelper.Concat
+ (
+ IccTestDataPrimitives.Single_1,
+ IccTestDataPrimitives.Single_4,
+ IccTestDataPrimitives.Single_7
+ );
+
+ public static readonly object[][] Matrix1D_ArrayTestData =
+ {
+ new object[] { Fix16_1D_Grad, 3, false, Single_1DArray_ValGrad },
+ new object[] { Single_1D_Grad, 3, true, Single_1DArray_ValGrad },
+ };
+
+ public static readonly object[][] Matrix1D_Vector3TestData =
+ {
+ new object[] { Fix16_1D_Grad, 3, false, Single_Vector3_ValGrad },
+ new object[] { Single_1D_Grad, 3, true, Single_Vector3_ValGrad },
+ };
+
+ #endregion
+ }
+}
diff --git a/tests/ImageSharp.Tests/TestDataIcc/IccTestDataMultiProcessElements.cs b/tests/ImageSharp.Tests/TestDataIcc/IccTestDataMultiProcessElements.cs
new file mode 100644
index 000000000..49e9550df
--- /dev/null
+++ b/tests/ImageSharp.Tests/TestDataIcc/IccTestDataMultiProcessElements.cs
@@ -0,0 +1,157 @@
+//
+// Copyright (c) James Jackson-South and contributors.
+// Licensed under the Apache License, Version 2.0.
+//
+
+namespace ImageSharp.Tests
+{
+ internal static class IccTestDataMultiProcessElement
+ {
+ #region CurveSet
+
+ ///
+ /// Input Channel Count: 3
+ /// Output Channel Count: 3
+ ///
+ public static readonly IccCurveSetProcessElement CurvePE_ValGrad = new IccCurveSetProcessElement(new IccOneDimensionalCurve[]
+ {
+ IccTestDataCurves.OneDimensional_ValFormula1,
+ IccTestDataCurves.OneDimensional_ValFormula2,
+ IccTestDataCurves.OneDimensional_ValFormula1
+ });
+ ///
+ /// 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 object[][] CurveSetTestData =
+ {
+ new object[] { CurvePE_Grad, CurvePE_ValGrad, 3, 3 },
+ };
+
+ #endregion
+
+ #region Matrix
+
+ ///
+ /// Input Channel Count: 3
+ /// Output Channel Count: 3
+ ///
+ public static readonly IccMatrixProcessElement MatrixPE_ValGrad = new IccMatrixProcessElement
+ (
+ IccTestDataMatrix.Single_2DArray_ValGrad,
+ IccTestDataMatrix.Single_1DArray_ValGrad
+ );
+ ///
+ /// 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 object[][] MatrixTestData =
+ {
+ new object[] { MatrixPE_Grad, MatrixPE_ValGrad, 3, 3 },
+ };
+
+
+ #endregion
+
+ #region CLUT
+
+ ///
+ /// Input Channel Count: 2
+ /// Output Channel Count: 3
+ ///
+ public static readonly IccClutProcessElement CLUTPE_ValGrad = new IccClutProcessElement(IccTestDataLut.CLUT_Valf32);
+ ///
+ /// Input Channel Count: 2
+ /// Output Channel Count: 3
+ ///
+ public static readonly byte[] CLUTPE_Grad = IccTestDataLut.CLUT_f32;
+
+ public static readonly object[][] ClutTestData =
+ {
+ new object[] { CLUTPE_Grad, CLUTPE_ValGrad, 2, 3 },
+ };
+
+ #endregion
+
+ #region MultiProcessElement
+
+ 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 byte[] MPE_Matrix = ArrayHelper.Concat
+ (
+ new byte[]
+ {
+ 0x6D, 0x61, 0x74, 0x66,
+ 0x00, 0x03,
+ 0x00, 0x03,
+ },
+ MatrixPE_Grad
+ );
+
+ public static readonly byte[] MPE_CLUT = ArrayHelper.Concat
+ (
+ new byte[]
+ {
+ 0x63, 0x6C, 0x75, 0x74,
+ 0x00, 0x02,
+ 0x00, 0x03,
+ },
+ CLUTPE_Grad
+ );
+
+ public static readonly byte[] MPE_Curve = ArrayHelper.Concat
+ (
+ new byte[]
+ {
+ 0x6D, 0x66, 0x6C, 0x74,
+ 0x00, 0x03,
+ 0x00, 0x03,
+ },
+ CurvePE_Grad
+ );
+
+ public static readonly byte[] MPE_bACS =
+ {
+ 0x62, 0x41, 0x43, 0x53,
+ 0x00, 0x03,
+ 0x00, 0x03,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ };
+
+ public static readonly byte[] MPE_eACS =
+ {
+ 0x65, 0x41, 0x43, 0x53,
+ 0x00, 0x03,
+ 0x00, 0x03,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ };
+
+ 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 },
+ };
+
+ #endregion
+ }
+}
diff --git a/tests/ImageSharp.Tests/TestDataIcc/IccTestDataNonPrimitives.cs b/tests/ImageSharp.Tests/TestDataIcc/IccTestDataNonPrimitives.cs
new file mode 100644
index 000000000..da5f6c9d7
--- /dev/null
+++ b/tests/ImageSharp.Tests/TestDataIcc/IccTestDataNonPrimitives.cs
@@ -0,0 +1,334 @@
+namespace ImageSharp.Tests
+{
+ using System;
+ using System.Globalization;
+ using System.Numerics;
+
+ internal static class IccTestDataNonPrimitives
+ {
+ #region DateTime
+
+ 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 byte[] DateTime_Min =
+ {
+ 0x00, 0x01, // Year 1
+ 0x00, 0x01, // Month 1
+ 0x00, 0x01, // Day 1
+ 0x00, 0x00, // Hour 0
+ 0x00, 0x00, // Minute 0
+ 0x00, 0x00, // Second 0
+ };
+
+ public static readonly byte[] DateTime_Max =
+ {
+ 0x27, 0x0F, // Year 9999
+ 0x00, 0x0C, // Month 12
+ 0x00, 0x1F, // Day 31
+ 0x00, 0x17, // Hour 23
+ 0x00, 0x3B, // Minute 59
+ 0x00, 0x3B, // Second 59
+ };
+
+ public static readonly byte[] DateTime_Invalid =
+ {
+ 0xFF, 0xFF, // Year 65535
+ 0x00, 0x0E, // Month 14
+ 0x00, 0x21, // Day 33
+ 0x00, 0x19, // Hour 25
+ 0x00, 0x3D, // Minute 61
+ 0x00, 0x3D, // Second 61
+ };
+
+ public static readonly byte[] DateTime_Rand1 =
+ {
+ 0x07, 0xC6, // Year 1990
+ 0x00, 0x0B, // Month 11
+ 0x00, 0x1A, // Day 26
+ 0x00, 0x03, // Hour 3
+ 0x00, 0x13, // Minute 19
+ 0x00, 0x2F, // Second 47
+ };
+
+ public static readonly object[][] DateTimeTestData =
+ {
+ new object[] { DateTime_Min, DateTime_ValMin },
+ new object[] { DateTime_Max, DateTime_ValMax },
+ new object[] { DateTime_Rand1, DateTime_ValRand1 },
+ };
+
+ #endregion
+
+ #region VersionNumber
+
+ public static readonly Version VersionNumber_ValMin = new Version(0, 0, 0);
+ public static readonly Version VersionNumber_Val211 = new Version(2, 1, 1);
+ public static readonly Version VersionNumber_Val430 = new Version(4, 3, 0);
+ public static readonly Version VersionNumber_ValMax = new Version(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 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 },
+ };
+
+ #endregion
+
+ #region XyzNumber
+
+ 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 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 },
+ };
+
+ #endregion
+
+ #region ProfileId
+
+ 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 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 object[][] ProfileIdTestData =
+ {
+ new object[] { ProfileId_Min, ProfileId_ValMin },
+ new object[] { ProfileId_Rand, ProfileId_ValRand },
+ new object[] { ProfileId_Max, ProfileId_ValMax },
+ };
+
+ #endregion
+
+ #region PositionNumber
+
+ 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 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 object[][] PositionNumberTestData =
+ {
+ new object[] { PositionNumber_Min, PositionNumber_ValMin },
+ new object[] { PositionNumber_Rand, PositionNumber_ValRand },
+ new object[] { PositionNumber_Max, PositionNumber_ValMax },
+ };
+
+ #endregion
+
+ #region ResponseNumber
+
+ 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 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 },
+ };
+
+ #endregion
+
+ #region NamedColor
+
+ public static readonly IccNamedColor NamedColor_ValMin = new IccNamedColor
+ (
+ ArrayHelper.Fill('A', 31),
+ new ushort[] { 0, 0, 0 },
+ new ushort[] { 0, 0, 0 }
+ );
+ public static readonly IccNamedColor NamedColor_ValRand = new IccNamedColor
+ (
+ ArrayHelper.Fill('5', 31),
+ new ushort[] { 10794, 10794, 10794 },
+ new ushort[] { 17219, 17219, 17219, 17219, 17219 }
+ );
+ public static readonly IccNamedColor NamedColor_ValMax = new IccNamedColor
+ (
+ ArrayHelper.Fill('4', 31),
+ new ushort[] { ushort.MaxValue, ushort.MaxValue, ushort.MaxValue },
+ new ushort[] { 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);
+
+ 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++)
+ {
+ if (i < 31) { data[i] = name; } // Name
+ else if (i == 31) { data[i] = 0x00; } // Name null terminator
+ else if (i < 32 + 6) { data[i] = PCS; } // PCS Coordinates
+ else { data[i] = device; } // Device Coordinates
+ }
+ return data;
+ }
+
+ 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 },
+ };
+
+ #endregion
+
+ #region ProfileDescription
+
+ private static readonly CultureInfo CultureEnUs = new CultureInfo("en-US");
+ private static readonly CultureInfo CultureDeAT = new CultureInfo("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[] LocalizedString_RandArr1 = new IccLocalizedString[]
+ {
+ LocalizedString_Rand1,
+ LocalizedString_Rand2,
+ };
+ private static readonly IccLocalizedString[] LocalizedString_RandArr2 = new IccLocalizedString[]
+ {
+ LocalizedString_Rand2,
+ LocalizedString_Rand1,
+ };
+
+ private static readonly IccMultiLocalizedUnicodeTagDataEntry MultiLocalizedUnicode_Val = new IccMultiLocalizedUnicodeTagDataEntry(LocalizedString_RandArr1);
+ private static readonly byte[] MultiLocalizedUnicode_Arr = ArrayHelper.Concat
+ (
+ IccTestDataPrimitives.UInt32_2,
+ new byte[] { 0x00, 0x00, 0x00, 0x0C }, // 12
+
+ new byte[] { (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[] { 0x00, 0x00, 0x00, 0x0E }, // 14
+ new byte[] { 0x00, 0x00, 0x00, 0x34 }, // 52
+
+ IccTestDataPrimitives.Unicode_Rand2,
+ IccTestDataPrimitives.Unicode_Rand3
+ );
+
+ public static readonly IccProfileDescription ProfileDescription_ValRand1 = new IccProfileDescription
+ (
+ 1, 2,
+ IccDeviceAttribute.ChromaBlackWhite | IccDeviceAttribute.ReflectivityMatte,
+ IccProfileTag.ProfileDescription,
+ MultiLocalizedUnicode_Val.Texts,
+ MultiLocalizedUnicode_Val.Texts
+ );
+
+ public static readonly byte[] ProfileDescription_Rand1 = ArrayHelper.Concat
+ (
+ IccTestDataPrimitives.UInt32_1,
+ IccTestDataPrimitives.UInt32_2,
+ 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,
+ new byte[] { 0x6D, 0x6C, 0x75, 0x63 },
+ new byte[] { 0x00, 0x00, 0x00, 0x00 },
+ MultiLocalizedUnicode_Arr
+ );
+
+ public static readonly object[][] ProfileDescriptionTestData =
+ {
+ new object[] { ProfileDescription_Rand1, ProfileDescription_ValRand1 },
+ };
+
+ #endregion
+
+ #region ColorantTableEntry
+
+ 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 byte[] ColorantTableEntry_Rand1 = ArrayHelper.Concat
+ (
+ ArrayHelper.Fill((byte)0x41, 31),
+ new byte[1], // null terminator
+ IccTestDataPrimitives.UInt16_1,
+ IccTestDataPrimitives.UInt16_2,
+ IccTestDataPrimitives.UInt16_3
+ );
+
+ public static readonly byte[] ColorantTableEntry_Rand2 = ArrayHelper.Concat
+ (
+ ArrayHelper.Fill((byte)0x34, 31),
+ new byte[1], // null terminator
+ IccTestDataPrimitives.UInt16_4,
+ IccTestDataPrimitives.UInt16_5,
+ IccTestDataPrimitives.UInt16_6
+ );
+
+ public static readonly object[][] ColorantTableEntryTestData =
+ {
+ new object[] { ColorantTableEntry_Rand1, ColorantTableEntry_ValRand1 },
+ new object[] { ColorantTableEntry_Rand2, ColorantTableEntry_ValRand2 },
+ };
+
+ #endregion
+ }
+}
diff --git a/tests/ImageSharp.Tests/TestDataIcc/IccTestDataPrimitives.cs b/tests/ImageSharp.Tests/TestDataIcc/IccTestDataPrimitives.cs
new file mode 100644
index 000000000..8b69646f3
--- /dev/null
+++ b/tests/ImageSharp.Tests/TestDataIcc/IccTestDataPrimitives.cs
@@ -0,0 +1,324 @@
+//
+// Copyright (c) James Jackson-South and contributors.
+// Licensed under the Apache License, Version 2.0.
+//
+
+namespace ImageSharp.Tests
+{
+ internal static class IccTestDataPrimitives
+ {
+ #region UInt16
+
+ 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 };
+
+ #endregion
+
+ #region Int16
+
+ 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 };
+
+ #endregion
+
+ #region UInt32
+
+ 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 };
+
+ #endregion
+
+ #region Int32
+
+ 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 };
+
+ #endregion
+
+ #region UInt64
+
+ 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 };
+
+ #endregion
+
+ #region Int64
+
+ 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 };
+
+ #endregion
+
+ #region Single
+
+ 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 };
+
+ #endregion
+
+ #region Double
+
+ 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 };
+
+ #endregion
+
+ #region Fix16
+
+ 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 object[][] Fix16TestData =
+ {
+ new object[] { Fix16_Min, Fix16_ValMin },
+ new object[] { Fix16_0, 0 },
+ new object[] { Fix16_4, 4 },
+ new object[] { Fix16_Max, Fix16_ValMax },
+ };
+
+ #endregion
+
+ #region UFix16
+
+ 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 static readonly object[][] UFix16TestData =
+ {
+ new object[] { UFix16_0, 0 },
+ new object[] { UFix16_4, 4 },
+ new object[] { UFix16_Max, UFix16_ValMax },
+ };
+
+ #endregion
+
+ #region U1Fix15
+
+ public const float U1Fix15_ValMin = 0;
+ public const float U1Fix15_ValMax = 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 object[][] U1Fix15TestData =
+ {
+ new object[] { U1Fix15_0, 0 },
+ new object[] { U1Fix15_1, 1 },
+ new object[] { U1Fix15_Max, U1Fix15_ValMax },
+ };
+
+ #endregion
+
+ #region UFix8
+
+ 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 static readonly object[][] UFix8TestData =
+ {
+ new object[] { UFix8_0, 0 },
+ new object[] { UFix8_4, 4 },
+ new object[] { UFix8_Max, UFix8_ValMax },
+ };
+
+ #endregion
+
+ #region ASCII String
+
+ public const string Ascii_ValRand = "aBcdEf1234";
+ 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_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 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 },
+ };
+
+ public static readonly object[][] AsciiWriteTestData =
+ {
+ new object[] { Ascii_Rand, Ascii_ValRand },
+ new object[] { Ascii_NullRand, Ascii_ValNullRand },
+ };
+
+ public static readonly object[][] AsciiPaddingTestData =
+ {
+ new object[] { Ascii_PaddedRand, Ascii_PaddedRand_Length, Ascii_ValRand, true },
+ new object[] { Ascii_RandLength4, 4, Ascii_ValRand, false },
+ };
+
+ #endregion
+
+ #region Unicode String
+
+ public const string Unicode_ValRand1 = ".6Abäñ$€β𐐷𤭢";
+ public const string Unicode_ValRand2 = ".6Abäñ";
+ public const string Unicode_ValRand3 = "$€β𐐷𤭢";
+
+ public static readonly byte[] Unicode_Rand1 =
+ {
+ 0x00, 0x2e, // .
+ 0x00, 0x36, // 6
+ 0x00, 0x41, // A
+ 0x00, 0x62, // b
+ 0x00, 0xe4, // ä
+ 0x00, 0xf1, // ñ
+ 0x00, 0x24, // $
+ 0x20, 0xAC, // €
+ 0x03, 0xb2, // β
+ 0xD8, 0x01, 0xDC, 0x37, // 𐐷
+ 0xD8, 0x52, 0xDF, 0x62, // 𤭢
+ };
+
+ public static readonly byte[] Unicode_Rand2 =
+ {
+ 0x00, 0x2e, // .
+ 0x00, 0x36, // 6
+ 0x00, 0x41, // A
+ 0x00, 0x62, // b
+ 0x00, 0xe4, // ä
+ 0x00, 0xf1, // ñ
+ };
+
+ public static readonly byte[] Unicode_Rand3 =
+ {
+ 0x00, 0x24, // $
+ 0x20, 0xAC, // €
+ 0x03, 0xb2, // β
+ 0xD8, 0x01, 0xDC, 0x37, // 𐐷
+ 0xD8, 0x52, 0xDF, 0x62, // 𤭢
+ };
+
+ #endregion
+ }
+}
diff --git a/tests/ImageSharp.Tests/TestDataIcc/IccTestDataProfiles.cs b/tests/ImageSharp.Tests/TestDataIcc/IccTestDataProfiles.cs
new file mode 100644
index 000000000..20fff50a8
--- /dev/null
+++ b/tests/ImageSharp.Tests/TestDataIcc/IccTestDataProfiles.cs
@@ -0,0 +1,92 @@
+//
+// Copyright (c) James Jackson-South and contributors.
+// Licensed under the Apache License, Version 2.0.
+//
+
+using System;
+using System.Numerics;
+
+namespace ImageSharp.Tests
+{
+ internal static class IccTestDataProfiles
+ {
+ public static readonly IccProfileHeader Header_Random_Write = 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 = "ijkl", // should be overwritten to "acsp"
+ Flags = IccProfileFlag.Embedded | IccProfileFlag.Independent,
+ Id = new IccProfileId(1, 2, 3, 4), // should be overwritten
+ PcsIlluminant = new Vector3(4, 5, 6),
+ PrimaryPlatformSignature = IccPrimaryPlatformType.MicrosoftCorporation,
+ ProfileConnectionSpace = IccColorSpaceType.CieXyz,
+ RenderingIntent = IccRenderingIntent.AbsoluteColorimetric,
+ Size = 562, // should be overwritten
+ Version = new Version(4, 3, 0),
+ };
+
+ public static readonly IccProfileHeader Header_Random_Read = 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,
+#if !NETSTANDARD1_1
+ Id = new IccProfileId(2931428592, 418415738, 3086756963, 2237536530),
+#else
+ Id = IccProfileId.Zero,
+#endif
+ PcsIlluminant = new Vector3(4, 5, 6),
+ PrimaryPlatformSignature = IccPrimaryPlatformType.MicrosoftCorporation,
+ ProfileConnectionSpace = IccColorSpaceType.CieXyz,
+ RenderingIntent = IccRenderingIntent.AbsoluteColorimetric,
+ Size = 132,
+ Version = new Version(4, 3, 0),
+ };
+
+ public static readonly byte[] Header_Random_Array =
+ {
+ 0x00, 0x00, 0x00, 0x84, // Size (132)
+ 0x61, 0x62, 0x63, 0x64, // CmmType
+ 0x04, 0x30, 0x00, 0x00, // Version
+ 0x6D, 0x6E, 0x74, 0x72, // Class
+ 0x52, 0x47, 0x42, 0x20, // DataColorSpace
+ 0x58, 0x59, 0x5A, 0x20, // ProfileConnectionSpace
+ 0x07, 0xC6, 0x00, 0x0B, 0x00, 0x1A, 0x00, 0x07, 0x00, 0x15, 0x00, 0x2A, // CreationDate
+ 0x61, 0x63, 0x73, 0x70, // FileSignature
+ 0x4D, 0x53, 0x46, 0x54, // PrimaryPlatformSignature
+ 0x00, 0x00, 0x00, 0x01, // Flags
+ 0x07, 0x5B, 0xCD, 0x15, // DeviceManufacturer
+ 0x3A, 0xDE, 0x68, 0xB1, // DeviceModel
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x09, // DeviceAttributes
+ 0x00, 0x00, 0x00, 0x03, // RenderingIntent
+ 0x00, 0x04, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, // PcsIlluminant
+ 0x64, 0x63, 0x62, 0x61, // CreatorSignature
+
+#if !NETSTANDARD1_1
+ 0xAE, 0xBA, 0x0C, 0xF0, 0x18, 0xF0, 0x84, 0x7A, 0xB7, 0xFC, 0x2C, 0x63, 0x85, 0x5E, 0x19, 0x12, // Id
+#else
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Id
+#endif
+ // Padding
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00,
+ // Nr of tag table entries (0)
+ 0x00, 0x00, 0x00, 0x00,
+ };
+ }
+}
diff --git a/tests/ImageSharp.Tests/TestDataIcc/IccTestDataTagDataEntry.cs b/tests/ImageSharp.Tests/TestDataIcc/IccTestDataTagDataEntry.cs
new file mode 100644
index 000000000..6863ce719
--- /dev/null
+++ b/tests/ImageSharp.Tests/TestDataIcc/IccTestDataTagDataEntry.cs
@@ -0,0 +1,913 @@
+//
+// Copyright (c) James Jackson-South and contributors.
+// Licensed under the Apache License, Version 2.0.
+//
+
+namespace ImageSharp.Tests
+{
+ using System.Globalization;
+ using System.Numerics;
+
+ internal static class IccTestDataTagDataEntry
+ {
+ #region TagDataEntry Header
+
+ public static readonly IccTypeSignature TagDataEntryHeader_UnknownVal = IccTypeSignature.Unknown;
+ public static readonly byte[] TagDataEntryHeader_UnknownArr =
+ {
+ 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00,
+ };
+
+ public static readonly IccTypeSignature TagDataEntryHeader_MultiLocalizedUnicodeVal = IccTypeSignature.MultiLocalizedUnicode;
+ public static readonly byte[] TagDataEntryHeader_MultiLocalizedUnicodeArr =
+ {
+ 0x6D, 0x6C, 0x75, 0x63,
+ 0x00, 0x00, 0x00, 0x00,
+ };
+
+ public static readonly IccTypeSignature TagDataEntryHeader_CurveVal = IccTypeSignature.Curve;
+ public static readonly byte[] TagDataEntryHeader_CurveArr =
+ {
+ 0x63, 0x75, 0x72, 0x76,
+ 0x00, 0x00, 0x00, 0x00,
+ };
+
+ public static readonly object[][] TagDataEntryHeaderTestData =
+ {
+ new object[] { TagDataEntryHeader_UnknownArr, TagDataEntryHeader_UnknownVal },
+ new object[] { TagDataEntryHeader_MultiLocalizedUnicodeArr, TagDataEntryHeader_MultiLocalizedUnicodeVal },
+ new object[] { TagDataEntryHeader_CurveArr, TagDataEntryHeader_CurveVal },
+ };
+
+ #endregion
+
+ #region UnknownTagDataEntry
+
+ public static readonly IccUnknownTagDataEntry Unknown_Val = new IccUnknownTagDataEntry(new byte[] { 0x00, 0x01, 0x02, 0x03 });
+ public static readonly byte[] Unknown_Arr = { 0x00, 0x01, 0x02, 0x03 };
+
+ public static readonly object[][] UnknownTagDataEntryTestData =
+ {
+ new object[] { Unknown_Arr, Unknown_Val, 12u },
+ };
+
+ #endregion
+
+ #region ChromaticityTagDataEntry
+
+ public static readonly IccChromaticityTagDataEntry Chromaticity_Val1 = new IccChromaticityTagDataEntry(IccColorantEncoding.ItuRBt709_2);
+ public static readonly byte[] Chromaticity_Arr1 = ArrayHelper.Concat
+ (
+ IccTestDataPrimitives.UInt16_3,
+ IccTestDataPrimitives.UInt16_1,
+
+ new byte[] { 0x00, 0x00, 0xA3, 0xD7 }, // 0.640
+ new byte[] { 0x00, 0x00, 0x54, 0x7B }, // 0.330
+
+ new byte[] { 0x00, 0x00, 0x4C, 0xCD }, // 0.300
+ new byte[] { 0x00, 0x00, 0x99, 0x9A }, // 0.600
+
+ new byte[] { 0x00, 0x00, 0x26, 0x66 }, // 0.150
+ new byte[] { 0x00, 0x00, 0x0F, 0x5C } // 0.060
+ );
+
+ public static readonly IccChromaticityTagDataEntry Chromaticity_Val2 = new IccChromaticityTagDataEntry
+ (
+ new double[][]
+ {
+ 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
+ );
+
+ ///
+ /// : channel count must be 3 for any enum other than
+ ///
+ public static readonly byte[] Chromaticity_ArrInvalid1 = ArrayHelper.Concat
+ (
+ IccTestDataPrimitives.UInt16_5,
+ IccTestDataPrimitives.UInt16_1
+ );
+
+ ///
+ /// : invalid enum value
+ ///
+ public static readonly byte[] Chromaticity_ArrInvalid2 = ArrayHelper.Concat
+ (
+ IccTestDataPrimitives.UInt16_3,
+ IccTestDataPrimitives.UInt16_9
+ );
+
+ public static readonly object[][] ChromaticityTagDataEntryTestData =
+ {
+ new object[] { Chromaticity_Arr1, Chromaticity_Val1 },
+ new object[] { Chromaticity_Arr2, Chromaticity_Val2 },
+ };
+
+ #endregion
+
+ #region ColorantOrderTagDataEntry
+
+ public static readonly IccColorantOrderTagDataEntry ColorantOrder_Val = new IccColorantOrderTagDataEntry(new byte[] { 0x00, 0x01, 0x02 });
+ public static readonly byte[] ColorantOrder_Arr = ArrayHelper.Concat(IccTestDataPrimitives.UInt32_3, new byte[] { 0x00, 0x01, 0x02 });
+
+ public static readonly object[][] ColorantOrderTagDataEntryTestData =
+ {
+ new object[] { ColorantOrder_Arr, ColorantOrder_Val },
+ };
+
+ #endregion
+
+ #region ColorantTableTagDataEntry
+
+ public static readonly IccColorantTableTagDataEntry ColorantTable_Val = new IccColorantTableTagDataEntry
+ (
+ new IccColorantTableEntry[]
+ {
+ IccTestDataNonPrimitives.ColorantTableEntry_ValRand1,
+ IccTestDataNonPrimitives.ColorantTableEntry_ValRand2
+ }
+ );
+ public static readonly byte[] ColorantTable_Arr = ArrayHelper.Concat
+ (
+ IccTestDataPrimitives.UInt32_2,
+ IccTestDataNonPrimitives.ColorantTableEntry_Rand1,
+ IccTestDataNonPrimitives.ColorantTableEntry_Rand2
+ );
+
+ public static readonly object[][] ColorantTableTagDataEntryTestData =
+ {
+ new object[] { ColorantTable_Arr, ColorantTable_Val },
+ };
+
+ #endregion
+
+ #region CurveTagDataEntry
+
+ public static readonly IccCurveTagDataEntry Curve_Val_0 = new IccCurveTagDataEntry();
+ public static readonly byte[] Curve_Arr_0 = IccTestDataPrimitives.UInt32_0;
+
+ public static readonly IccCurveTagDataEntry Curve_Val_1 = new IccCurveTagDataEntry(1f);
+ public static readonly byte[] Curve_Arr_1 = ArrayHelper.Concat
+ (
+ IccTestDataPrimitives.UInt32_1,
+ IccTestDataPrimitives.UFix8_1
+ );
+
+ public static readonly IccCurveTagDataEntry Curve_Val_2 = new IccCurveTagDataEntry(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 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 },
+ };
+
+ #endregion
+
+ #region DataTagDataEntry
+
+ public static readonly IccDataTagDataEntry Data_ValNoASCII = new IccDataTagDataEntry
+ (
+ new byte[] { 0x01, 0x02, 0x03, 0x04 },
+ false
+ );
+ public static readonly byte[] Data_ArrNoASCII =
+ {
+ 0x00, 0x00, 0x00, 0x00,
+ 0x01, 0x02, 0x03, 0x04
+ };
+
+ public static readonly IccDataTagDataEntry Data_ValASCII = new IccDataTagDataEntry
+ (
+ new byte[] { (byte)'A', (byte)'S', (byte)'C', (byte)'I', (byte)'I' },
+ true
+ );
+ public static readonly byte[] Data_ArrASCII =
+ {
+ 0x00, 0x00, 0x00, 0x01,
+ (byte)'A', (byte)'S', (byte)'C', (byte)'I', (byte)'I'
+ };
+
+ public static readonly object[][] DataTagDataEntryTestData =
+ {
+ new object[] { Data_ArrNoASCII, Data_ValNoASCII, 16u },
+ new object[] { Data_ArrASCII, Data_ValASCII, 17u },
+ };
+
+ #endregion
+
+ #region DateTimeTagDataEntry
+
+ public static readonly IccDateTimeTagDataEntry DateTime_Val = new IccDateTimeTagDataEntry(IccTestDataNonPrimitives.DateTime_ValRand1);
+ public static readonly byte[] DateTime_Arr = IccTestDataNonPrimitives.DateTime_Rand1;
+
+ public static readonly object[][] DateTimeTagDataEntryTestData =
+ {
+ new object[] { DateTime_Arr, DateTime_Val },
+ };
+
+ #endregion
+
+ #region Lut16TagDataEntry
+
+ public static readonly IccLut16TagDataEntry Lut16_Val = new IccLut16TagDataEntry
+ (
+ 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 byte[] Lut16_Arr = 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
+ );
+
+ public static readonly object[][] Lut16TagDataEntryTestData =
+ {
+ new object[] { Lut16_Arr, Lut16_Val },
+ };
+
+ #endregion
+
+ #region Lut8TagDataEntry
+
+ public static readonly IccLut8TagDataEntry Lut8_Val = new IccLut8TagDataEntry
+ (
+ 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 byte[] Lut8_Arr = 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
+ );
+
+ public static readonly object[][] Lut8TagDataEntryTestData =
+ {
+ new object[] { Lut8_Arr, Lut8_Val },
+ };
+
+ #endregion
+
+ #region LutAToBTagDataEntry
+
+ private static readonly byte[] CurveFull_0 = ArrayHelper.Concat
+ (
+ TagDataEntryHeader_CurveArr,
+ Curve_Arr_0
+ );
+ private static readonly byte[] CurveFull_1 = ArrayHelper.Concat
+ (
+ TagDataEntryHeader_CurveArr,
+ Curve_Arr_1
+ );
+ private static readonly byte[] CurveFull_2 = ArrayHelper.Concat
+ (
+ TagDataEntryHeader_CurveArr,
+ Curve_Arr_2
+ );
+
+ public static readonly IccLutAToBTagDataEntry LutAToB_Val = new IccLutAToBTagDataEntry
+ (
+ new IccCurveTagDataEntry[]
+ {
+ Curve_Val_0,
+ Curve_Val_1,
+ Curve_Val_2,
+ },
+ 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,
+ }
+ );
+ public static readonly byte[] LutAToB_Arr = ArrayHelper.Concat
+ (
+ new byte[] { 0x02, 0x03, 0x00, 0x00 },
+
+ new byte[] { 0x00, 0x00, 0x00, 0x20 }, // b: 32
+ new byte[] { 0x00, 0x00, 0x00, 0x50 }, // matrix: 80
+ new byte[] { 0x00, 0x00, 0x00, 0x80 }, // m: 128
+ new byte[] { 0x00, 0x00, 0x00, 0xB0 }, // clut: 176
+ new byte[] { 0x00, 0x00, 0x00, 0xFC }, // a: 252
+
+ // B
+ CurveFull_0, // 12 bytes
+ CurveFull_1, // 14 bytes
+ new byte[] { 0x00, 0x00 }, // Padding
+ CurveFull_2, // 18 bytes
+ new byte[] { 0x00, 0x00 }, // Padding
+
+ // Matrix
+ IccTestDataMatrix.Fix16_2D_Grad, // 36 bytes
+ IccTestDataMatrix.Fix16_1D_Grad, // 12 bytes
+
+ // M
+ CurveFull_1, // 14 bytes
+ new byte[] { 0x00, 0x00 }, // Padding
+ CurveFull_2, // 18 bytes
+ new byte[] { 0x00, 0x00 }, // Padding
+ CurveFull_0, // 12 bytes
+
+ // CLUT
+ IccTestDataLut.CLUT_16, // 74 bytes
+ new byte[] { 0x00, 0x00 }, // Padding
+
+ // A
+ CurveFull_2, // 18 bytes
+ new byte[] { 0x00, 0x00 }, // Padding
+ CurveFull_1, // 14 bytes
+ new byte[] { 0x00, 0x00 } // Padding
+ );
+
+ public static readonly object[][] LutAToBTagDataEntryTestData =
+ {
+ new object[] { LutAToB_Arr, LutAToB_Val },
+ };
+
+ #endregion
+
+ #region LutBToATagDataEntry
+
+ public static readonly IccLutBToATagDataEntry LutBToA_Val = new IccLutBToATagDataEntry
+ (
+ new IccCurveTagDataEntry[]
+ {
+ Curve_Val_0,
+ Curve_Val_1,
+ },
+ null,
+ null,
+ null,
+ IccTestDataLut.CLUT_Val16,
+ new IccCurveTagDataEntry[]
+ {
+ Curve_Val_2,
+ Curve_Val_1,
+ Curve_Val_0,
+ }
+ );
+ public static readonly byte[] LutBToA_Arr = ArrayHelper.Concat
+ (
+ new byte[] { 0x02, 0x03, 0x00, 0x00 },
+
+ new byte[] { 0x00, 0x00, 0x00, 0x20 }, // b: 32
+ new byte[] { 0x00, 0x00, 0x00, 0x00 }, // matrix: 0
+ new byte[] { 0x00, 0x00, 0x00, 0x00 }, // m: 0
+ new byte[] { 0x00, 0x00, 0x00, 0x3C }, // clut: 60
+ new byte[] { 0x00, 0x00, 0x00, 0x88 }, // a: 136
+
+ // B
+ CurveFull_0, //12 bytes
+ CurveFull_1, //14 bytes
+ new byte[] { 0x00, 0x00 }, // Padding
+
+ // CLUT
+ IccTestDataLut.CLUT_16, // 74 bytes
+ new byte[] { 0x00, 0x00 }, // Padding
+
+ // A
+ CurveFull_2, // 18 bytes
+ new byte[] { 0x00, 0x00 }, // Padding
+ CurveFull_1, // 14 bytes
+ new byte[] { 0x00, 0x00 }, // Padding
+ CurveFull_0 // 12 bytes
+ );
+
+ public static readonly object[][] LutBToATagDataEntryTestData =
+ {
+ new object[] { LutBToA_Arr, LutBToA_Val },
+ };
+
+ #endregion
+
+ #region MeasurementTagDataEntry
+
+ public static readonly IccMeasurementTagDataEntry Measurement_Val = new IccMeasurementTagDataEntry
+ (
+ IccStandardObserver.Cie1931Observer, IccTestDataNonPrimitives.XyzNumber_ValVar1,
+ 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 object[][] MeasurementTagDataEntryTestData =
+ {
+ new object[] { Measurement_Arr, Measurement_Val },
+ };
+
+ #endregion
+
+ #region MultiLocalizedUnicodeTagDataEntry
+
+ private static readonly IccLocalizedString LocalizedString_Rand1 = new IccLocalizedString(new CultureInfo("en-US"), IccTestDataPrimitives.Unicode_ValRand2);
+ private static readonly IccLocalizedString LocalizedString_Rand2 = new IccLocalizedString(new CultureInfo("de-DE"), IccTestDataPrimitives.Unicode_ValRand3);
+
+ private static readonly IccLocalizedString[] LocalizedString_RandArr1 = new IccLocalizedString[]
+ {
+ LocalizedString_Rand1,
+ LocalizedString_Rand2,
+ };
+ private static readonly IccLocalizedString[] LocalizedString_RandArr2 = new IccLocalizedString[]
+ {
+ LocalizedString_Rand2,
+ LocalizedString_Rand1,
+ };
+
+ public static readonly IccMultiLocalizedUnicodeTagDataEntry MultiLocalizedUnicode_Val = new IccMultiLocalizedUnicodeTagDataEntry(LocalizedString_RandArr1);
+ public static readonly byte[] MultiLocalizedUnicode_Arr = ArrayHelper.Concat
+ (
+ IccTestDataPrimitives.UInt32_2,
+ new byte[] { 0x00, 0x00, 0x00, 0x0C }, // 12
+
+ new byte[] { (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)'D', (byte)'E' },
+ new byte[] { 0x00, 0x00, 0x00, 0x0E }, // 14
+ new byte[] { 0x00, 0x00, 0x00, 0x34 }, // 52
+
+ IccTestDataPrimitives.Unicode_Rand2,
+ IccTestDataPrimitives.Unicode_Rand3
+ );
+
+ public static readonly object[][] MultiLocalizedUnicodeTagDataEntryTestData =
+ {
+ new object[] { MultiLocalizedUnicode_Arr, MultiLocalizedUnicode_Val },
+ };
+
+ #endregion
+
+ #region MultiProcessElementsTagDataEntry
+
+ public static readonly IccMultiProcessElementsTagDataEntry MultiProcessElements_Val = new IccMultiProcessElementsTagDataEntry
+ (
+ new IccMultiProcessElement[]
+ {
+ IccTestDataMultiProcessElement.MPE_ValCLUT,
+ IccTestDataMultiProcessElement.MPE_ValCLUT,
+ }
+ );
+ public static readonly byte[] MultiProcessElements_Arr = ArrayHelper.Concat
+ (
+ IccTestDataPrimitives.UInt16_2,
+ IccTestDataPrimitives.UInt16_3,
+ IccTestDataPrimitives.UInt32_2,
+
+ 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
+
+ IccTestDataMultiProcessElement.MPE_CLUT,
+ IccTestDataMultiProcessElement.MPE_CLUT
+ );
+
+ public static readonly object[][] MultiProcessElementsTagDataEntryTestData =
+ {
+ new object[] { MultiProcessElements_Arr, MultiProcessElements_Val },
+ };
+
+ #endregion
+
+ #region NamedColor2TagDataEntry
+
+ public static readonly IccNamedColor2TagDataEntry NamedColor2_Val = new IccNamedColor2TagDataEntry
+ (
+ 16909060,
+ ArrayHelper.Fill('A', 31), ArrayHelper.Fill('4', 31),
+ new IccNamedColor[]
+ {
+ IccTestDataNonPrimitives.NamedColor_ValMin,
+ IccTestDataNonPrimitives.NamedColor_ValMin
+ }
+ );
+ public static readonly byte[] NamedColor2_Arr = ArrayHelper.Concat
+ (
+ new byte[] { 0x01, 0x02, 0x03, 0x04 },
+ IccTestDataPrimitives.UInt32_2,
+ IccTestDataPrimitives.UInt32_3,
+ ArrayHelper.Fill((byte)0x41, 31),
+ new byte[] { 0x00 },
+ ArrayHelper.Fill((byte)0x34, 31),
+ new byte[] { 0x00 },
+ IccTestDataNonPrimitives.NamedColor_Min,
+ IccTestDataNonPrimitives.NamedColor_Min
+ );
+
+ public static readonly object[][] NamedColor2TagDataEntryTestData =
+ {
+ new object[] { NamedColor2_Arr, NamedColor2_Val },
+ };
+
+ #endregion
+
+ #region ParametricCurveTagDataEntry
+
+ public static readonly IccParametricCurveTagDataEntry ParametricCurve_Val = new IccParametricCurveTagDataEntry(IccTestDataCurves.Parametric_ValVar1);
+ public static readonly byte[] ParametricCurve_Arr = IccTestDataCurves.Parametric_Var1;
+
+ public static readonly object[][] ParametricCurveTagDataEntryTestData =
+ {
+ new object[] { ParametricCurve_Arr, ParametricCurve_Val },
+ };
+
+ #endregion
+
+ #region ProfileSequenceDescTagDataEntry
+
+ public static readonly IccProfileSequenceDescTagDataEntry ProfileSequenceDesc_Val = new IccProfileSequenceDescTagDataEntry
+ (
+ new IccProfileDescription[]
+ {
+ IccTestDataNonPrimitives.ProfileDescription_ValRand1,
+ IccTestDataNonPrimitives.ProfileDescription_ValRand1
+ }
+ );
+ public static readonly byte[] ProfileSequenceDesc_Arr = ArrayHelper.Concat
+ (
+ IccTestDataPrimitives.UInt32_2,
+ IccTestDataNonPrimitives.ProfileDescription_Rand1,
+ IccTestDataNonPrimitives.ProfileDescription_Rand1
+ );
+
+ public static readonly object[][] ProfileSequenceDescTagDataEntryTestData =
+ {
+ new object[] { ProfileSequenceDesc_Arr, ProfileSequenceDesc_Val },
+ };
+
+ #endregion
+
+ #region ProfileSequenceIdentifierTagDataEntry
+
+ public static readonly IccProfileSequenceIdentifierTagDataEntry ProfileSequenceIdentifier_Val = new IccProfileSequenceIdentifierTagDataEntry
+ (
+ new IccProfileSequenceIdentifier[]
+ {
+ new IccProfileSequenceIdentifier(IccTestDataNonPrimitives.ProfileId_ValRand, LocalizedString_RandArr1),
+ new IccProfileSequenceIdentifier(IccTestDataNonPrimitives.ProfileId_ValRand, LocalizedString_RandArr1),
+ }
+ );
+ public static readonly byte[] ProfileSequenceIdentifier_Arr = ArrayHelper.Concat
+ (
+ IccTestDataPrimitives.UInt32_2,
+
+ 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
+ new byte[] { 0x00, 0x00 }, // 2 bytes (padding)
+
+ IccTestDataNonPrimitives.ProfileId_Rand,
+ TagDataEntryHeader_MultiLocalizedUnicodeArr,
+ MultiLocalizedUnicode_Arr,
+ new byte[] { 0x00, 0x00 }
+ );
+
+ public static readonly object[][] ProfileSequenceIdentifierTagDataEntryTestData =
+ {
+ new object[] { ProfileSequenceIdentifier_Arr, ProfileSequenceIdentifier_Val },
+ };
+
+ #endregion
+
+ #region ResponseCurveSet16TagDataEntry
+
+ public static readonly IccResponseCurveSet16TagDataEntry ResponseCurveSet16_Val = new IccResponseCurveSet16TagDataEntry
+ (
+ new IccResponseCurve[]
+ {
+ IccTestDataCurves.Response_ValGrad,
+ IccTestDataCurves.Response_ValGrad,
+ }
+ );
+ public static readonly byte[] ResponseCurveSet16_Arr = ArrayHelper.Concat
+ (
+ IccTestDataPrimitives.UInt16_3,
+ IccTestDataPrimitives.UInt16_2,
+
+ new byte[] { 0x00, 0x00, 0x00, 0x14 }, // 20
+ new byte[] { 0x00, 0x00, 0x00, 0x6C }, // 108
+
+ IccTestDataCurves.Response_Grad, // 88 bytes
+ IccTestDataCurves.Response_Grad // 88 bytes
+ );
+
+ public static readonly object[][] ResponseCurveSet16TagDataEntryTestData =
+ {
+ new object[] { ResponseCurveSet16_Arr, ResponseCurveSet16_Val },
+ };
+
+ #endregion
+
+ #region Fix16ArrayTagDataEntry
+
+ public static readonly IccFix16ArrayTagDataEntry Fix16Array_Val = new IccFix16ArrayTagDataEntry(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 object[][] Fix16ArrayTagDataEntryTestData =
+ {
+ new object[] { Fix16Array_Arr, Fix16Array_Val, 20u },
+ };
+
+ #endregion
+
+ #region SignatureTagDataEntry
+
+ public static readonly IccSignatureTagDataEntry Signature_Val = new IccSignatureTagDataEntry("ABCD");
+ public static readonly byte[] Signature_Arr = { 0x41, 0x42, 0x43, 0x44, };
+
+ public static readonly object[][] SignatureTagDataEntryTestData =
+ {
+ new object[] { Signature_Arr, Signature_Val },
+ };
+
+ #endregion
+
+ #region TextTagDataEntry
+
+ public static readonly IccTextTagDataEntry Text_Val = new IccTextTagDataEntry("ABCD");
+ public static readonly byte[] Text_Arr = { 0x41, 0x42, 0x43, 0x44 };
+
+ public static readonly object[][] TextTagDataEntryTestData =
+ {
+ new object[] { Text_Arr, Text_Val, 12u },
+ };
+
+ #endregion
+
+ #region UFix16ArrayTagDataEntry
+
+ public static readonly IccUFix16ArrayTagDataEntry UFix16Array_Val = new IccUFix16ArrayTagDataEntry(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 object[][] UFix16ArrayTagDataEntryTestData =
+ {
+ new object[] { UFix16Array_Arr, UFix16Array_Val, 20u },
+ };
+
+ #endregion
+
+ #region UInt16ArrayTagDataEntry
+
+ public static readonly IccUInt16ArrayTagDataEntry UInt16Array_Val = new IccUInt16ArrayTagDataEntry(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 object[][] UInt16ArrayTagDataEntryTestData =
+ {
+ new object[] { UInt16Array_Arr, UInt16Array_Val, 14u },
+ };
+
+ #endregion
+
+ #region UInt32ArrayTagDataEntry
+
+ public static readonly IccUInt32ArrayTagDataEntry UInt32Array_Val = new IccUInt32ArrayTagDataEntry(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 object[][] UInt32ArrayTagDataEntryTestData =
+ {
+ new object[] { UInt32Array_Arr, UInt32Array_Val, 20u },
+ };
+
+ #endregion
+
+ #region UInt64ArrayTagDataEntry
+
+ public static readonly IccUInt64ArrayTagDataEntry UInt64Array_Val = new IccUInt64ArrayTagDataEntry(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 object[][] UInt64ArrayTagDataEntryTestData =
+ {
+ new object[] { UInt64Array_Arr, UInt64Array_Val, 32u },
+ };
+
+ #endregion
+
+ #region UInt8ArrayTagDataEntry
+
+ public static readonly IccUInt8ArrayTagDataEntry UInt8Array_Val = new IccUInt8ArrayTagDataEntry(new byte[] { 1, 2, 3 });
+ public static readonly byte[] UInt8Array_Arr = { 1, 2, 3 };
+
+ public static readonly object[][] UInt8ArrayTagDataEntryTestData =
+ {
+ new object[] { UInt8Array_Arr, UInt8Array_Val, 11u },
+ };
+
+ #endregion
+
+ #region ViewingConditionsTagDataEntry
+
+ public static readonly IccViewingConditionsTagDataEntry ViewingConditions_Val = new IccViewingConditionsTagDataEntry
+ (
+ IccTestDataNonPrimitives.XyzNumber_ValVar1,
+ IccTestDataNonPrimitives.XyzNumber_ValVar2,
+ IccStandardIlluminant.D50
+ );
+ public static readonly byte[] ViewingConditions_Arr = ArrayHelper.Concat
+ (
+ IccTestDataNonPrimitives.XyzNumber_Var1,
+ IccTestDataNonPrimitives.XyzNumber_Var2,
+ IccTestDataPrimitives.UInt32_1
+ );
+
+ public static readonly object[][] ViewingConditionsTagDataEntryTestData =
+ {
+ new object[] { ViewingConditions_Arr, ViewingConditions_Val },
+ };
+
+ #endregion
+
+ #region XYZTagDataEntry
+
+ public static readonly IccXyzTagDataEntry XYZ_Val = new IccXyzTagDataEntry(new Vector3[]
+ {
+ IccTestDataNonPrimitives.XyzNumber_ValVar1,
+ IccTestDataNonPrimitives.XyzNumber_ValVar2,
+ IccTestDataNonPrimitives.XyzNumber_ValVar3,
+ });
+ public static readonly byte[] XYZ_Arr = ArrayHelper.Concat
+ (
+ IccTestDataNonPrimitives.XyzNumber_Var1,
+ IccTestDataNonPrimitives.XyzNumber_Var2,
+ IccTestDataNonPrimitives.XyzNumber_Var3
+ );
+
+ public static readonly object[][] XYZTagDataEntryTestData =
+ {
+ new object[] { XYZ_Arr, XYZ_Val, 44u },
+ };
+
+ #endregion
+
+ #region TextDescriptionTagDataEntry
+
+ public static readonly IccTextDescriptionTagDataEntry TextDescription_Val1 = new IccTextDescriptionTagDataEntry
+ (
+ IccTestDataPrimitives.Ascii_ValRand, IccTestDataPrimitives.Unicode_ValRand1, ArrayHelper.Fill('A', 66),
+ 9, 2
+ );
+ public static readonly byte[] TextDescription_Arr1 = ArrayHelper.Concat
+ (
+ new byte[] { 0x00, 0x00, 0x00, 0x0B }, // 11
+ IccTestDataPrimitives.Ascii_Rand,
+ new byte[] { 0x00 }, // Null terminator
+
+ IccTestDataPrimitives.UInt32_9,
+ new byte[] { 0x00, 0x00, 0x00, 0x0E }, // 14
+ IccTestDataPrimitives.Unicode_Rand1,
+ 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 IccTextDescriptionTagDataEntry(IccTestDataPrimitives.Ascii_ValRand, null, null, 0, 0);
+ public static readonly byte[] TextDescription_Arr2 = ArrayHelper.Concat
+ (
+ new byte[] { 0x00, 0x00, 0x00, 0x0B }, // 11
+ IccTestDataPrimitives.Ascii_Rand,
+ new byte[] { 0x00 }, // Null terminator
+
+ IccTestDataPrimitives.UInt32_0,
+ IccTestDataPrimitives.UInt32_0,
+
+ 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 },
+ };
+
+ #endregion
+
+ #region TagDataEntry
+
+ public static readonly IccTagDataEntry TagDataEntry_CurveVal = Curve_Val_2;
+ public static readonly byte[] TagDataEntry_CurveArr = ArrayHelper.Concat
+ (
+ TagDataEntryHeader_CurveArr,
+ Curve_Arr_2,
+ 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,
+ new byte[] { 0x00, 0x00 } // padding
+ );
+
+ public static readonly IccTagTableEntry TagDataEntry_MultiLocalizedUnicodeTable = new IccTagTableEntry
+ (
+ IccProfileTag.Unknown, 0,
+ (uint)TagDataEntry_MultiLocalizedUnicodeArr.Length - 2
+ );
+
+ public static readonly IccTagTableEntry TagDataEntry_CurveTable = new IccTagTableEntry
+ (
+ IccProfileTag.Unknown, 0,
+ (uint)TagDataEntry_CurveArr.Length - 2
+ );
+
+ public static readonly object[][] TagDataEntryTestData =
+ {
+ new object[] { TagDataEntry_CurveArr, TagDataEntry_CurveVal },
+ new object[] { TagDataEntry_MultiLocalizedUnicodeArr, TagDataEntry_MultiLocalizedUnicodeVal },
+ };
+
+ #endregion
+ }
+}
diff --git a/tests/ImageSharp.Tests/TestUtilities/ArrayHelper.cs b/tests/ImageSharp.Tests/TestUtilities/ArrayHelper.cs
new file mode 100644
index 000000000..d3b4da9b9
--- /dev/null
+++ b/tests/ImageSharp.Tests/TestUtilities/ArrayHelper.cs
@@ -0,0 +1,58 @@
+//
+// Copyright (c) James Jackson-South and contributors.
+// Licensed under the Apache License, Version 2.0.
+//
+
+namespace ImageSharp.Tests
+{
+ using System.Linq;
+
+ public static class ArrayHelper
+ {
+ ///
+ /// Concatenates multiple arrays of the same type into one
+ ///
+ /// The array type
+ /// The arrays to concatenate. The order is kept
+ /// The concatenated array
+ public static T[] Concat(params T[][] arrs)
+ {
+ T[] result = new T[arrs.Sum(t => t.Length)];
+ int offset = 0;
+ for (int i = 0; i < arrs.Length; i++)
+ {
+ arrs[i].CopyTo(result, offset);
+ offset += arrs[i].Length;
+ }
+ return result;
+ }
+
+ ///
+ /// Creates an array filled with the given value
+ ///
+ /// The array type
+ /// The value to fill the array with
+ /// The wanted length of the array
+ /// The created array filled with the given value
+ public static T[] Fill(T value, int length)
+ {
+ T[] result = new T[length];
+ for (int i = 0; i < length; i++)
+ {
+ result[i] = value;
+ }
+ return result;
+ }
+
+ ///
+ /// Creates a string from a character with a given length
+ ///
+ /// The character to fill the string with
+ /// The wanted length of the string
+ /// The filled string
+ public static string Fill(char value, int length)
+ {
+ return "".PadRight(length, value);
+ }
+ }
+}