Browse Source

fix wrong usage of Guard.IsTrue/IsFalse

af/merge-core
Johannes Bildstein 9 years ago
parent
commit
22ffa1193a
  1. 4
      src/ImageSharp/MetaData/Profiles/ICC/Curves/IccOneDimensionalCurve.cs
  2. 2
      src/ImageSharp/MetaData/Profiles/ICC/Curves/IccResponseCurve.cs
  3. 2
      src/ImageSharp/MetaData/Profiles/ICC/Curves/IccSampledCurveElement.cs
  4. 2
      src/ImageSharp/MetaData/Profiles/ICC/IccProfile.cs
  5. 6
      src/ImageSharp/MetaData/Profiles/ICC/IccReader.cs
  6. 4
      src/ImageSharp/MetaData/Profiles/ICC/MultiProcessElements/IccMatrixProcessElement.cs
  7. 2
      src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccChromaticityTagDataEntry.cs
  8. 8
      src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccLut16TagDataEntry.cs
  9. 12
      src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccLut8TagDataEntry.cs
  10. 24
      src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccLutAToBTagDataEntry.cs
  11. 24
      src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccLutBToATagDataEntry.cs
  12. 4
      src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccMultiProcessElementsTagDataEntry.cs
  13. 2
      src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccNamedColor2TagDataEntry.cs
  14. 4
      src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccResponseCurveSet16TagDataEntry.cs
  15. 2
      src/ImageSharp/MetaData/Profiles/ICC/Various/IccNamedColor.cs

4
src/ImageSharp/MetaData/Profiles/ICC/Curves/IccOneDimensionalCurve.cs

@ -18,8 +18,8 @@
Guard.NotNull(breakPoints, nameof(breakPoints)); Guard.NotNull(breakPoints, nameof(breakPoints));
Guard.NotNull(segments, nameof(segments)); Guard.NotNull(segments, nameof(segments));
bool isWrongSize = breakPoints.Length != segments.Length - 1; bool isSizeCorrect = breakPoints.Length == segments.Length - 1;
Guard.IsTrue(isWrongSize, $"{nameof(breakPoints)},{nameof(segments)}", "Number of BreakPoints must be one less than number of Segments"); Guard.IsTrue(isSizeCorrect, $"{nameof(breakPoints)},{nameof(segments)}", "Number of BreakPoints must be one less than number of Segments");
this.BreakPoints = breakPoints; this.BreakPoints = breakPoints;
this.Segments = segments; this.Segments = segments;

2
src/ImageSharp/MetaData/Profiles/ICC/Curves/IccResponseCurve.cs

@ -20,7 +20,7 @@
Guard.NotNull(xyzValues, nameof(xyzValues)); Guard.NotNull(xyzValues, nameof(xyzValues));
Guard.NotNull(responseArrays, nameof(responseArrays)); Guard.NotNull(responseArrays, nameof(responseArrays));
Guard.IsTrue(xyzValues.Length != responseArrays.Length, $"{nameof(xyzValues)},{nameof(responseArrays)}", "Arrays must have same length"); Guard.IsTrue(xyzValues.Length == responseArrays.Length, $"{nameof(xyzValues)},{nameof(responseArrays)}", "Arrays must have same length");
Guard.MustBeBetweenOrEqualTo(xyzValues.Length, 1, 15, nameof(xyzValues)); Guard.MustBeBetweenOrEqualTo(xyzValues.Length, 1, 15, nameof(xyzValues));
this.CurveType = curveType; this.CurveType = curveType;

2
src/ImageSharp/MetaData/Profiles/ICC/Curves/IccSampledCurveElement.cs

@ -15,7 +15,7 @@
: base(IccCurveSegmentSignature.SampledCurve) : base(IccCurveSegmentSignature.SampledCurve)
{ {
Guard.NotNull(curveEntries, nameof(curveEntries)); Guard.NotNull(curveEntries, nameof(curveEntries));
Guard.IsTrue(curveEntries.Length < 1, nameof(curveEntries), "There must be at least one value"); Guard.IsTrue(curveEntries.Length > 0, nameof(curveEntries), "There must be at least one value");
this.CurveEntries = curveEntries; this.CurveEntries = curveEntries;
} }

2
src/ImageSharp/MetaData/Profiles/ICC/IccProfile.cs

@ -81,7 +81,7 @@ namespace ImageSharp
public static IccProfileId CalculateHash(byte[] data) public static IccProfileId CalculateHash(byte[] data)
{ {
Guard.NotNull(data, nameof(data)); Guard.NotNull(data, nameof(data));
Guard.IsTrue(data.Length < 128, nameof(data), "Data length must be at least 128 to be a valid profile header"); Guard.IsTrue(data.Length >= 128, nameof(data), "Data length must be at least 128 to be a valid profile header");
byte[] header = new byte[128]; byte[] header = new byte[128];
Buffer.BlockCopy(data, 0, header, 0, 128); Buffer.BlockCopy(data, 0, header, 0, 128);

6
src/ImageSharp/MetaData/Profiles/ICC/IccReader.cs

@ -17,7 +17,7 @@ namespace ImageSharp
/// <returns>The read ICC profile</returns> /// <returns>The read ICC profile</returns>
public IccProfile Read(byte[] data) public IccProfile Read(byte[] data)
{ {
Guard.IsTrue(data.Length < 128, nameof(data), "Data length must be at least 128 to be a valid ICC profile"); Guard.IsTrue(data.Length >= 128, nameof(data), "Data length must be at least 128 to be a valid ICC profile");
IccDataReader reader = new IccDataReader(data); IccDataReader reader = new IccDataReader(data);
IccProfileHeader header = this.ReadHeader(reader); IccProfileHeader header = this.ReadHeader(reader);
@ -33,7 +33,7 @@ namespace ImageSharp
/// <returns>The read ICC profile header</returns> /// <returns>The read ICC profile header</returns>
public IccProfileHeader ReadHeader(byte[] data) public IccProfileHeader ReadHeader(byte[] data)
{ {
Guard.IsTrue(data.Length < 128, nameof(data), "Data length must be at least 128 to be a valid profile header"); Guard.IsTrue(data.Length >= 128, nameof(data), "Data length must be at least 128 to be a valid profile header");
IccDataReader reader = new IccDataReader(data); IccDataReader reader = new IccDataReader(data);
return this.ReadHeader(reader); return this.ReadHeader(reader);
@ -46,7 +46,7 @@ namespace ImageSharp
/// <returns>The read ICC profile tag data</returns> /// <returns>The read ICC profile tag data</returns>
public IccTagDataEntry[] ReadTagData(byte[] data) public IccTagDataEntry[] ReadTagData(byte[] data)
{ {
Guard.IsTrue(data.Length < 128, nameof(data), "Data length must be at least 128 to be a valid ICC profile"); Guard.IsTrue(data.Length >= 128, nameof(data), "Data length must be at least 128 to be a valid ICC profile");
IccDataReader reader = new IccDataReader(data); IccDataReader reader = new IccDataReader(data);
return this.ReadTagData(reader); return this.ReadTagData(reader);

4
src/ImageSharp/MetaData/Profiles/ICC/MultiProcessElements/IccMatrixProcessElement.cs

@ -23,8 +23,8 @@ namespace ImageSharp
Guard.NotNull(matrixIxO, nameof(matrixIxO)); Guard.NotNull(matrixIxO, nameof(matrixIxO));
Guard.NotNull(matrixOx1, nameof(matrixOx1)); Guard.NotNull(matrixOx1, nameof(matrixOx1));
bool wrongMatrixSize = matrixIxO.GetLength(1) != matrixOx1.Length; bool matrixSizeCorrect = matrixIxO.GetLength(1) == matrixOx1.Length;
Guard.IsTrue(wrongMatrixSize, $"{nameof(matrixIxO)},{nameof(matrixIxO)}", "Output channel length must match"); Guard.IsTrue(matrixSizeCorrect, $"{nameof(matrixIxO)},{nameof(matrixIxO)}", "Output channel length must match");
this.MatrixIxO = matrixIxO; this.MatrixIxO = matrixIxO;
this.MatrixOx1 = matrixOx1; this.MatrixOx1 = matrixOx1;

2
src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccChromaticityTagDataEntry.cs

@ -63,7 +63,7 @@ namespace ImageSharp
int channelLength = channelValues[0].Length; int channelLength = channelValues[0].Length;
bool channelsNotSame = channelValues.Any(t => t == null || t.Length != channelLength); bool channelsNotSame = channelValues.Any(t => t == null || t.Length != channelLength);
Guard.IsTrue(channelsNotSame, nameof(channelValues), "The number of values per channel is not the same for all channels"); Guard.IsFalse(channelsNotSame, nameof(channelValues), "The number of values per channel is not the same for all channels");
} }
/// <summary> /// <summary>

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

@ -66,12 +66,12 @@ namespace ImageSharp
if (matrix != null) if (matrix != null)
{ {
bool isNot3By3 = matrix.GetLength(0) != 3 || matrix.GetLength(1) != 3; bool is3By3 = matrix.GetLength(0) == 3 && matrix.GetLength(1) == 3;
Guard.IsTrue(isNot3By3, nameof(matrix), "Matrix must have a size of three by three"); 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.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.IsTrue(this.OutputChannelCount == clutValues.OutputChannelCount, nameof(clutValues), "Output channel count does not match the CLUT size");
this.Matrix = this.CreateMatrix(matrix); this.Matrix = this.CreateMatrix(matrix);
this.InputValues = inputValues; this.InputValues = inputValues;

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

@ -66,15 +66,15 @@ namespace ImageSharp
if (matrix != null) if (matrix != null)
{ {
bool isNot3By3 = matrix.GetLength(0) != 3 || matrix.GetLength(1) != 3; bool is3By3 = matrix.GetLength(0) == 3 && matrix.GetLength(1) == 3;
Guard.IsTrue(isNot3By3, nameof(matrix), "Matrix must have a size of three by three"); 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.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.IsTrue(this.OutputChannelCount == clutValues.OutputChannelCount, nameof(clutValues), "Output channel count does not match the CLUT size");
Guard.IsTrue(inputValues.Any(t => t.Values.Length != 256), nameof(inputValues), "Input lookup table has to have a length of 256"); Guard.IsFalse(inputValues.Any(t => t.Values.Length != 256), nameof(inputValues), "Input lookup table has to have a length of 256");
Guard.IsTrue(outputValues.Any(t => t.Values.Length != 256), nameof(outputValues), "Output 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.Matrix = this.CreateMatrix(matrix);
this.InputValues = inputValues; this.InputValues = inputValues;

24
src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccLutAToBTagDataEntry.cs

@ -68,20 +68,20 @@ namespace ImageSharp
if (this.IsAClutMMatrixB()) if (this.IsAClutMMatrixB())
{ {
Guard.IsTrue(this.CurveB.Length != 3, nameof(this.CurveB), $"{nameof(this.CurveB)} must have a length of three"); Guard.IsTrue(this.CurveB.Length == 3, nameof(this.CurveB), $"{nameof(this.CurveB)} must have a length of three");
Guard.IsTrue(this.CurveM.Length != 3, nameof(this.CurveM), $"{nameof(this.CurveM)} must have a length of three"); Guard.IsTrue(this.CurveM.Length == 3, nameof(this.CurveM), $"{nameof(this.CurveM)} must have a length of three");
Guard.MustBeBetweenOrEqualTo(this.CurveA.Length, 1, 15, nameof(this.CurveA)); Guard.MustBeBetweenOrEqualTo(this.CurveA.Length, 1, 15, nameof(this.CurveA));
this.InputChannelCount = curveA.Length; this.InputChannelCount = curveA.Length;
this.OutputChannelCount = 3; this.OutputChannelCount = 3;
Guard.IsTrue(this.InputChannelCount != clutValues.InputChannelCount, nameof(clutValues), "Input channel count does not match the CLUT size"); 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.IsTrue(this.OutputChannelCount == clutValues.OutputChannelCount, nameof(clutValues), "Output channel count does not match the CLUT size");
} }
else if (this.IsMMatrixB()) else if (this.IsMMatrixB())
{ {
Guard.IsTrue(this.CurveB.Length != 3, nameof(this.CurveB), $"{nameof(this.CurveB)} must have a length of three"); Guard.IsTrue(this.CurveB.Length == 3, nameof(this.CurveB), $"{nameof(this.CurveB)} must have a length of three");
Guard.IsTrue(this.CurveM.Length != 3, nameof(this.CurveM), $"{nameof(this.CurveM)} must have a length of three"); Guard.IsTrue(this.CurveM.Length == 3, nameof(this.CurveM), $"{nameof(this.CurveM)} must have a length of three");
this.InputChannelCount = this.OutputChannelCount = 3; this.InputChannelCount = this.OutputChannelCount = 3;
} }
@ -93,8 +93,8 @@ namespace ImageSharp
this.InputChannelCount = curveA.Length; this.InputChannelCount = curveA.Length;
this.OutputChannelCount = curveB.Length; this.OutputChannelCount = curveB.Length;
Guard.IsTrue(this.InputChannelCount != clutValues.InputChannelCount, nameof(clutValues), "Input channel count does not match the CLUT size"); 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.IsTrue(this.OutputChannelCount == clutValues.OutputChannelCount, nameof(clutValues), "Output channel count does not match the CLUT size");
} }
else if (this.IsB()) else if (this.IsB())
{ {
@ -217,7 +217,7 @@ namespace ImageSharp
if (curves != null) if (curves != null)
{ {
bool isNotCurve = curves.Any(t => !(t is IccParametricCurveTagDataEntry) && !(t is IccCurveTagDataEntry)); bool isNotCurve = curves.Any(t => !(t is IccParametricCurveTagDataEntry) && !(t is IccCurveTagDataEntry));
Guard.IsTrue(isNotCurve, nameof(name), $"{nameof(name)} must be of type {nameof(IccParametricCurveTagDataEntry)} or {nameof(IccCurveTagDataEntry)}"); Guard.IsFalse(isNotCurve, nameof(name), $"{nameof(name)} must be of type {nameof(IccParametricCurveTagDataEntry)} or {nameof(IccCurveTagDataEntry)}");
} }
} }
@ -225,13 +225,13 @@ namespace ImageSharp
{ {
if (matrix3x1 != null) if (matrix3x1 != null)
{ {
Guard.IsTrue(matrix3x1.Length != 3, nameof(matrix3x1), "Matrix must have a size of three"); Guard.IsTrue(matrix3x1.Length == 3, nameof(matrix3x1), "Matrix must have a size of three");
} }
if (matrix3x3 != null) if (matrix3x3 != null)
{ {
bool isNot3By3 = matrix3x3.GetLength(0) != 3 || matrix3x3.GetLength(1) != 3; bool is3By3 = matrix3x3.GetLength(0) == 3 && matrix3x3.GetLength(1) == 3;
Guard.IsTrue(isNot3By3, nameof(matrix3x3), "Matrix must have a size of three by three"); Guard.IsTrue(is3By3, nameof(matrix3x3), "Matrix must have a size of three by three");
} }
} }

24
src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccLutBToATagDataEntry.cs

@ -68,20 +68,20 @@ namespace ImageSharp
if (this.IsBMatrixMClutA()) if (this.IsBMatrixMClutA())
{ {
Guard.IsTrue(this.CurveB.Length != 3, nameof(this.CurveB), $"{nameof(this.CurveB)} must have a length of three"); Guard.IsTrue(this.CurveB.Length == 3, nameof(this.CurveB), $"{nameof(this.CurveB)} must have a length of three");
Guard.IsTrue(this.CurveM.Length != 3, nameof(this.CurveM), $"{nameof(this.CurveM)} must have a length of three"); Guard.IsTrue(this.CurveM.Length == 3, nameof(this.CurveM), $"{nameof(this.CurveM)} must have a length of three");
Guard.MustBeBetweenOrEqualTo(this.CurveA.Length, 1, 15, nameof(this.CurveA)); Guard.MustBeBetweenOrEqualTo(this.CurveA.Length, 1, 15, nameof(this.CurveA));
this.InputChannelCount = 3; this.InputChannelCount = 3;
this.OutputChannelCount = curveA.Length; this.OutputChannelCount = curveA.Length;
Guard.IsTrue(this.InputChannelCount != clutValues.InputChannelCount, nameof(clutValues), "Input channel count does not match the CLUT size"); 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.IsTrue(this.OutputChannelCount == clutValues.OutputChannelCount, nameof(clutValues), "Output channel count does not match the CLUT size");
} }
else if (this.IsBMatrixM()) else if (this.IsBMatrixM())
{ {
Guard.IsTrue(this.CurveB.Length != 3, nameof(this.CurveB), $"{nameof(this.CurveB)} must have a length of three"); Guard.IsTrue(this.CurveB.Length == 3, nameof(this.CurveB), $"{nameof(this.CurveB)} must have a length of three");
Guard.IsTrue(this.CurveM.Length != 3, nameof(this.CurveM), $"{nameof(this.CurveM)} must have a length of three"); Guard.IsTrue(this.CurveM.Length == 3, nameof(this.CurveM), $"{nameof(this.CurveM)} must have a length of three");
this.InputChannelCount = this.OutputChannelCount = 3; this.InputChannelCount = this.OutputChannelCount = 3;
} }
@ -93,8 +93,8 @@ namespace ImageSharp
this.InputChannelCount = curveB.Length; this.InputChannelCount = curveB.Length;
this.OutputChannelCount = curveA.Length; this.OutputChannelCount = curveA.Length;
Guard.IsTrue(this.InputChannelCount != clutValues.InputChannelCount, nameof(clutValues), "Input channel count does not match the CLUT size"); 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.IsTrue(this.OutputChannelCount == clutValues.OutputChannelCount, nameof(clutValues), "Output channel count does not match the CLUT size");
} }
else if (this.IsB()) else if (this.IsB())
{ {
@ -217,7 +217,7 @@ namespace ImageSharp
if (curves != null) if (curves != null)
{ {
bool isNotCurve = curves.Any(t => !(t is IccParametricCurveTagDataEntry) && !(t is IccCurveTagDataEntry)); bool isNotCurve = curves.Any(t => !(t is IccParametricCurveTagDataEntry) && !(t is IccCurveTagDataEntry));
Guard.IsTrue(isNotCurve, nameof(name), $"{nameof(name)} must be of type {nameof(IccParametricCurveTagDataEntry)} or {nameof(IccCurveTagDataEntry)}"); Guard.IsFalse(isNotCurve, nameof(name), $"{nameof(name)} must be of type {nameof(IccParametricCurveTagDataEntry)} or {nameof(IccCurveTagDataEntry)}");
} }
} }
@ -225,13 +225,13 @@ namespace ImageSharp
{ {
if (matrix3x1 != null) if (matrix3x1 != null)
{ {
Guard.IsTrue(matrix3x1.Length != 3, nameof(matrix3x1), "Matrix must have a size of three"); Guard.IsTrue(matrix3x1.Length == 3, nameof(matrix3x1), "Matrix must have a size of three");
} }
if (matrix3x3 != null) if (matrix3x3 != null)
{ {
bool isNot3By3 = matrix3x3.GetLength(0) != 3 || matrix3x3.GetLength(1) != 3; bool is3By3 = matrix3x3.GetLength(0) == 3 && matrix3x3.GetLength(1) == 3;
Guard.IsTrue(isNot3By3, nameof(matrix3x3), "Matrix must have a size of three by three"); Guard.IsTrue(is3By3, nameof(matrix3x3), "Matrix must have a size of three by three");
} }
} }

4
src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccMultiProcessElementsTagDataEntry.cs

@ -31,14 +31,14 @@ namespace ImageSharp
: base(IccTypeSignature.MultiProcessElements, tagSignature) : base(IccTypeSignature.MultiProcessElements, tagSignature)
{ {
Guard.NotNull(data, nameof(data)); Guard.NotNull(data, nameof(data));
Guard.IsTrue(data.Length < 1, nameof(data), $"{nameof(data)} must have at least one element"); Guard.IsTrue(data.Length > 0, nameof(data), $"{nameof(data)} must have at least one element");
this.InputChannelCount = data[0].InputChannelCount; this.InputChannelCount = data[0].InputChannelCount;
this.OutputChannelCount = data[0].OutputChannelCount; this.OutputChannelCount = data[0].OutputChannelCount;
this.Data = data; this.Data = data;
bool channelsNotSame = data.Any(t => t.InputChannelCount != this.InputChannelCount || t.OutputChannelCount != this.OutputChannelCount); bool channelsNotSame = data.Any(t => t.InputChannelCount != this.InputChannelCount || t.OutputChannelCount != this.OutputChannelCount);
Guard.IsTrue(channelsNotSame, nameof(data), "The number of input and output channels are not the same for all elements"); Guard.IsFalse(channelsNotSame, nameof(data), "The number of input and output channels are not the same for all elements");
} }
/// <summary> /// <summary>

2
src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccNamedColor2TagDataEntry.cs

@ -84,7 +84,7 @@ namespace ImageSharp
if (colors.Length > 0) if (colors.Length > 0)
{ {
coordinateCount = colors[0].DeviceCoordinates?.Length ?? 0; coordinateCount = colors[0].DeviceCoordinates?.Length ?? 0;
Guard.IsTrue(colors.Any(t => (t.DeviceCoordinates?.Length ?? 0) != coordinateCount), nameof(colors), "Device coordinate count must be the same for all colors"); Guard.IsFalse(colors.Any(t => (t.DeviceCoordinates?.Length ?? 0) != coordinateCount), nameof(colors), "Device coordinate count must be the same for all colors");
} }
this.VendorFlags = vendorFlags; this.VendorFlags = vendorFlags;

4
src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccResponseCurveSet16TagDataEntry.cs

@ -33,12 +33,12 @@ namespace ImageSharp
: base(IccTypeSignature.ResponseCurveSet16, tagSignature) : base(IccTypeSignature.ResponseCurveSet16, tagSignature)
{ {
Guard.NotNull(curves, nameof(curves)); Guard.NotNull(curves, nameof(curves));
Guard.IsTrue(curves.Length < 1, nameof(curves), $"{nameof(curves)} needs at least one element"); Guard.IsTrue(curves.Length > 0, nameof(curves), $"{nameof(curves)} needs at least one element");
this.Curves = curves; this.Curves = curves;
this.ChannelCount = (ushort)curves[0].ResponseArrays.Length; this.ChannelCount = (ushort)curves[0].ResponseArrays.Length;
Guard.IsTrue(curves.Any(t => t.ResponseArrays.Length != this.ChannelCount), nameof(curves), "All curves need to have the same number of channels"); Guard.IsFalse(curves.Any(t => t.ResponseArrays.Length != this.ChannelCount), nameof(curves), "All curves need to have the same number of channels");
} }
/// <summary> /// <summary>

2
src/ImageSharp/MetaData/Profiles/ICC/Various/IccNamedColor.cs

@ -23,7 +23,7 @@ namespace ImageSharp
{ {
Guard.NotNull(name, nameof(name)); Guard.NotNull(name, nameof(name));
Guard.NotNull(pcsCoordinates, nameof(pcsCoordinates)); Guard.NotNull(pcsCoordinates, nameof(pcsCoordinates));
Guard.IsTrue(pcsCoordinates.Length != 3, nameof(pcsCoordinates), "Must have a length of 3"); Guard.IsTrue(pcsCoordinates.Length == 3, nameof(pcsCoordinates), "Must have a length of 3");
this.Name = name; this.Name = name;
this.PcsCoordinates = pcsCoordinates; this.PcsCoordinates = pcsCoordinates;

Loading…
Cancel
Save