Browse Source

use identity matrix instead of null

af/merge-core
Johannes Bildstein 9 years ago
parent
commit
afbea7728a
  1. 12
      src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccLut16TagDataEntry.cs
  2. 16
      src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccLut8TagDataEntry.cs

12
src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccLut16TagDataEntry.cs

@ -15,6 +15,8 @@ namespace ImageSharp
/// </summary>
internal sealed class IccLut16TagDataEntry : IccTagDataEntry, IEquatable<IccLut16TagDataEntry>
{
private static readonly float[,] IdentityMatrix = { { 1, 0, 0 }, { 0, 1, 0 }, { 0, 0, 1 } };
/// <summary>
/// Initializes a new instance of the <see cref="IccLut16TagDataEntry"/> class.
/// </summary>
@ -22,7 +24,7 @@ namespace ImageSharp
/// <param name="clutValues">CLUT</param>
/// <param name="outputValues">Output LUT</param>
public IccLut16TagDataEntry(IccLut[] inputValues, IccClut clutValues, IccLut[] outputValues)
: this(null, inputValues, clutValues, outputValues, IccProfileTag.Unknown)
: this(IdentityMatrix, inputValues, clutValues, outputValues, IccProfileTag.Unknown)
{
}
@ -34,7 +36,7 @@ namespace ImageSharp
/// <param name="outputValues">Output LUT</param>
/// <param name="tagSignature">Tag Signature</param>
public IccLut16TagDataEntry(IccLut[] inputValues, IccClut clutValues, IccLut[] outputValues, IccProfileTag tagSignature)
: this(null, inputValues, clutValues, outputValues, tagSignature)
: this(IdentityMatrix, inputValues, clutValues, outputValues, tagSignature)
{
}
@ -69,13 +71,13 @@ namespace ImageSharp
bool is3By3 = matrix.GetLength(0) == 3 && matrix.GetLength(1) == 3;
Guard.IsTrue(is3By3, nameof(matrix), "Matrix must have a size of three by three");
Guard.IsTrue(this.InputChannelCount == clutValues.InputChannelCount, nameof(clutValues), "Input channel count does not match the CLUT size");
Guard.IsTrue(this.OutputChannelCount == clutValues.OutputChannelCount, nameof(clutValues), "Output channel count does not match the CLUT size");
this.Matrix = this.CreateMatrix(matrix);
this.InputValues = inputValues;
this.ClutValues = clutValues;
this.OutputValues = outputValues;
Guard.IsTrue(this.InputChannelCount == clutValues.InputChannelCount, nameof(clutValues), "Input channel count does not match the CLUT size");
Guard.IsTrue(this.OutputChannelCount == clutValues.OutputChannelCount, nameof(clutValues), "Output channel count does not match the CLUT size");
}
/// <summary>

16
src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccLut8TagDataEntry.cs

@ -15,6 +15,8 @@ namespace ImageSharp
/// </summary>
internal sealed class IccLut8TagDataEntry : IccTagDataEntry, IEquatable<IccLut8TagDataEntry>
{
private static readonly float[,] IdentityMatrix = { { 1, 0, 0 }, { 0, 1, 0 }, { 0, 0, 1 } };
/// <summary>
/// Initializes a new instance of the <see cref="IccLut8TagDataEntry"/> class.
/// </summary>
@ -22,7 +24,7 @@ namespace ImageSharp
/// <param name="clutValues">CLUT</param>
/// <param name="outputValues">Output LUT</param>
public IccLut8TagDataEntry(IccLut[] inputValues, IccClut clutValues, IccLut[] outputValues)
: this(null, inputValues, clutValues, outputValues, IccProfileTag.Unknown)
: this(IdentityMatrix, inputValues, clutValues, outputValues, IccProfileTag.Unknown)
{
}
@ -34,7 +36,7 @@ namespace ImageSharp
/// <param name="outputValues">Output LUT</param>
/// <param name="tagSignature">Tag Signature</param>
public IccLut8TagDataEntry(IccLut[] inputValues, IccClut clutValues, IccLut[] outputValues, IccProfileTag tagSignature)
: this(null, inputValues, clutValues, outputValues, tagSignature)
: this(IdentityMatrix, inputValues, clutValues, outputValues, tagSignature)
{
}
@ -69,16 +71,16 @@ namespace ImageSharp
bool is3By3 = matrix.GetLength(0) == 3 && matrix.GetLength(1) == 3;
Guard.IsTrue(is3By3, nameof(matrix), "Matrix must have a size of three by three");
this.Matrix = this.CreateMatrix(matrix);
this.InputValues = inputValues;
this.ClutValues = clutValues;
this.OutputValues = outputValues;
Guard.IsTrue(this.InputChannelCount == clutValues.InputChannelCount, nameof(clutValues), "Input channel count does not match the CLUT size");
Guard.IsTrue(this.OutputChannelCount == clutValues.OutputChannelCount, nameof(clutValues), "Output channel count does not match the CLUT size");
Guard.IsFalse(inputValues.Any(t => t.Values.Length != 256), nameof(inputValues), "Input lookup table has to have a length of 256");
Guard.IsFalse(outputValues.Any(t => t.Values.Length != 256), nameof(outputValues), "Output lookup table has to have a length of 256");
this.Matrix = this.CreateMatrix(matrix);
this.InputValues = inputValues;
this.ClutValues = clutValues;
this.OutputValues = outputValues;
}
/// <summary>

Loading…
Cancel
Save