Browse Source

Merge remote-tracking branch 'origin/master' into pixel-conversion-refactor

pull/242/head
Anton Firszov 9 years ago
parent
commit
fde96c5334
  1. 49
      src/ImageSharp/MetaData/Profiles/ICC/Curves/IccParametricCurve.cs
  2. 30
      src/ImageSharp/MetaData/Profiles/ICC/Curves/IccResponseCurve.cs
  3. 33
      src/ImageSharp/MetaData/Profiles/ICC/IccTagDataEntry.cs
  4. 1
      src/ImageSharp/MetaData/Profiles/ICC/IccWriter.cs
  5. 88
      src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccChromaticityTagDataEntry.cs
  6. 47
      src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccColorantOrderTagDataEntry.cs
  7. 47
      src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccColorantTableTagDataEntry.cs
  8. 60
      src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccCrdInfoTagDataEntry.cs
  9. 74
      src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccCurveTagDataEntry.cs
  10. 60
      src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccDataTagDataEntry.cs
  11. 47
      src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccDateTimeTagDataEntry.cs
  12. 47
      src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccFix16ArrayTagDataEntry.cs
  13. 67
      src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccLut16TagDataEntry.cs
  14. 67
      src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccLut8TagDataEntry.cs
  15. 69
      src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccLutAToBTagDataEntry.cs
  16. 69
      src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccLutBToATagDataEntry.cs
  17. 60
      src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccMeasurementTagDataEntry.cs
  18. 45
      src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccMultiLocalizedUnicodeTagDataEntry.cs
  19. 56
      src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccMultiProcessElementsTagDataEntry.cs
  20. 60
      src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccNamedColor2TagDataEntry.cs
  21. 43
      src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccParametricCurveTagDataEntry.cs
  22. 43
      src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccProfileSequenceDescTagDataEntry.cs
  23. 43
      src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccProfileSequenceIdentifierTagDataEntry.cs
  24. 51
      src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccResponseCurveSet16TagDataEntry.cs
  25. 49
      src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccScreeningTagDataEntry.cs
  26. 43
      src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccSignatureTagDataEntry.cs
  27. 81
      src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccTextDescriptionTagDataEntry.cs
  28. 45
      src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccTextTagDataEntry.cs
  29. 47
      src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUFix16ArrayTagDataEntry.cs
  30. 45
      src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUInt16ArrayTagDataEntry.cs
  31. 47
      src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUInt32ArrayTagDataEntry.cs
  32. 47
      src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUInt64ArrayTagDataEntry.cs
  33. 47
      src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUInt8ArrayTagDataEntry.cs
  34. 56
      src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUcrBgTagDataEntry.cs
  35. 47
      src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUnknownTagDataEntry.cs
  36. 54
      src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccViewingConditionsTagDataEntry.cs
  37. 48
      src/ImageSharp/MetaData/Profiles/ICC/Various/IccClut.cs
  38. 38
      src/ImageSharp/MetaData/Profiles/ICC/Various/IccProfileDescription.cs
  39. 33
      src/ImageSharp/MetaData/Profiles/ICC/Various/IccProfileSequenceIdentifier.cs
  40. 18
      src/ImageSharp/MetaData/Profiles/ICC/Various/IccScreeningChannel.cs

49
src/ImageSharp/MetaData/Profiles/ICC/Curves/IccParametricCurve.cs

@ -127,7 +127,7 @@ namespace ImageSharp
/// <inheritdoc/>
public bool Equals(IccParametricCurve other)
{
if (other == null)
if (ReferenceEquals(null, other))
{
return false;
}
@ -138,13 +138,46 @@ namespace ImageSharp
}
return this.Type == other.Type
&& this.G == other.G
&& this.A == other.A
&& this.B == other.B
&& this.C == other.C
&& this.D == other.D
&& this.E == other.E
&& this.F == other.F;
&& this.G.Equals(other.G)
&& this.A.Equals(other.A)
&& this.B.Equals(other.B)
&& this.C.Equals(other.C)
&& this.D.Equals(other.D)
&& this.E.Equals(other.E)
&& this.F.Equals(other.F);
}
/// <inheritdoc/>
public override bool Equals(object obj)
{
if (ReferenceEquals(null, obj))
{
return false;
}
if (ReferenceEquals(this, obj))
{
return true;
}
return obj is IccParametricCurve && this.Equals((IccParametricCurve)obj);
}
/// <inheritdoc/>
public override int GetHashCode()
{
unchecked
{
int hashCode = (int)this.Type;
hashCode = (hashCode * 397) ^ this.G.GetHashCode();
hashCode = (hashCode * 397) ^ this.A.GetHashCode();
hashCode = (hashCode * 397) ^ this.B.GetHashCode();
hashCode = (hashCode * 397) ^ this.C.GetHashCode();
hashCode = (hashCode * 397) ^ this.D.GetHashCode();
hashCode = (hashCode * 397) ^ this.E.GetHashCode();
hashCode = (hashCode * 397) ^ this.F.GetHashCode();
return hashCode;
}
}
}
}

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

@ -51,7 +51,7 @@ namespace ImageSharp
/// <inheritdoc/>
public bool Equals(IccResponseCurve other)
{
if (other == null)
if (ReferenceEquals(null, other))
{
return false;
}
@ -66,6 +66,34 @@ namespace ImageSharp
&& this.EqualsResponseArray(other);
}
/// <inheritdoc />
public override bool Equals(object obj)
{
if (ReferenceEquals(null, obj))
{
return false;
}
if (ReferenceEquals(this, obj))
{
return true;
}
return obj is IccResponseCurve && this.Equals((IccResponseCurve)obj);
}
/// <inheritdoc />
public override int GetHashCode()
{
unchecked
{
int hashCode = (int)this.CurveType;
hashCode = (hashCode * 397) ^ (this.XyzValues != null ? this.XyzValues.GetHashCode() : 0);
hashCode = (hashCode * 397) ^ (this.ResponseArrays != null ? this.ResponseArrays.GetHashCode() : 0);
return hashCode;
}
}
private bool EqualsResponseArray(IccResponseCurve other)
{
if (this.ResponseArrays.Length != other.ResponseArrays.Length)

33
src/ImageSharp/MetaData/Profiles/ICC/IccTagDataEntry.cs

@ -43,10 +43,36 @@ namespace ImageSharp
/// </summary>
public IccProfileTag TagSignature { get; set; }
/// <inheritdoc/>
public override bool Equals(object obj)
{
if (ReferenceEquals(null, obj))
{
return false;
}
if (ReferenceEquals(this, obj))
{
return true;
}
var entry = obj as IccTagDataEntry;
return entry != null && this.Equals(entry);
}
/// <inheritdoc/>
public override int GetHashCode()
{
unchecked
{
return (int)this.Signature * 397;
}
}
/// <inheritdoc/>
public virtual bool Equals(IccTagDataEntry other)
{
if (other == null)
if (ReferenceEquals(null, other))
{
return false;
}
@ -56,8 +82,7 @@ namespace ImageSharp
return true;
}
return this.Signature == other.Signature
&& this.TagSignature == other.TagSignature;
return this.Signature == other.Signature;
}
}
}
}

1
src/ImageSharp/MetaData/Profiles/ICC/IccWriter.cs

@ -79,7 +79,6 @@ namespace ImageSharp
var inData = new List<IccTagDataEntry>(entries);
var dupData = new List<IccTagDataEntry[]>();
// Filter out duplicate entries. They only need to be defined once but can be used multiple times
while (inData.Count > 0)
{
IccTagDataEntry[] items = inData.Where(t => inData[0].Equals(t)).ToArray();

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

@ -69,10 +69,7 @@ namespace ImageSharp
/// <summary>
/// Gets the number of channels
/// </summary>
public int ChannelCount
{
get { return this.ChannelValues.Length; }
}
public int ChannelCount => this.ChannelValues.Length;
/// <summary>
/// Gets the colorant type
@ -84,22 +81,55 @@ namespace ImageSharp
/// </summary>
public double[][] ChannelValues { get; }
/// <inheritdoc />
/// <inheritdoc/>
public override bool Equals(IccTagDataEntry other)
{
if (base.Equals(other) && other is IccChromaticityTagDataEntry entry)
var entry = other as IccChromaticityTagDataEntry;
return entry != null && this.Equals(entry);
}
/// <inheritdoc/>
public bool Equals(IccChromaticityTagDataEntry other)
{
if (ReferenceEquals(null, other))
{
return this.ColorantType == entry.ColorantType
&& this.EqualsChannelValues(entry);
return false;
}
if (ReferenceEquals(this, other))
{
return true;
}
return false;
return base.Equals(other) && this.ColorantType == other.ColorantType && this.EqualsChannelValues(other);
}
/// <inheritdoc />
public bool Equals(IccChromaticityTagDataEntry other)
/// <inheritdoc/>
public override bool Equals(object obj)
{
return this.Equals((IccTagDataEntry)other);
if (ReferenceEquals(null, obj))
{
return false;
}
if (ReferenceEquals(this, obj))
{
return true;
}
return obj is IccChromaticityTagDataEntry && this.Equals((IccChromaticityTagDataEntry)obj);
}
/// <inheritdoc/>
public override int GetHashCode()
{
unchecked
{
int hashCode = base.GetHashCode();
hashCode = (hashCode * 397) ^ (int)this.ColorantType;
hashCode = (hashCode * 397) ^ (this.ChannelValues != null ? this.ChannelValues.GetHashCode() : 0);
return hashCode;
}
}
private static double[][] GetColorantArray(IccColorantEncoding colorantType)
@ -107,32 +137,32 @@ namespace ImageSharp
switch (colorantType)
{
case IccColorantEncoding.EbuTech3213E:
return new double[][]
return new[]
{
new double[] { 0.640, 0.330 },
new double[] { 0.290, 0.600 },
new double[] { 0.150, 0.060 },
new[] { 0.640, 0.330 },
new[] { 0.290, 0.600 },
new[] { 0.150, 0.060 },
};
case IccColorantEncoding.ItuRBt709_2:
return new double[][]
return new[]
{
new double[] { 0.640, 0.330 },
new double[] { 0.300, 0.600 },
new double[] { 0.150, 0.060 },
new[] { 0.640, 0.330 },
new[] { 0.300, 0.600 },
new[] { 0.150, 0.060 },
};
case IccColorantEncoding.P22:
return new double[][]
return new[]
{
new double[] { 0.625, 0.340 },
new double[] { 0.280, 0.605 },
new double[] { 0.155, 0.070 },
new[] { 0.625, 0.340 },
new[] { 0.280, 0.605 },
new[] { 0.155, 0.070 },
};
case IccColorantEncoding.SmpteRp145:
return new double[][]
return new[]
{
new double[] { 0.630, 0.340 },
new double[] { 0.310, 0.595 },
new double[] { 0.155, 0.070 },
new[] { 0.630, 0.340 },
new[] { 0.310, 0.595 },
new[] { 0.155, 0.070 },
};
default:
throw new ArgumentException("Unrecognized colorant encoding");
@ -157,4 +187,4 @@ namespace ImageSharp
return true;
}
}
}
}

47
src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccColorantOrderTagDataEntry.cs

@ -42,21 +42,52 @@ namespace ImageSharp
/// </summary>
public byte[] ColorantNumber { get; }
/// <inheritdoc />
/// <inheritdoc/>
public override bool Equals(IccTagDataEntry other)
{
if (base.Equals(other) && other is IccColorantOrderTagDataEntry entry)
var entry = other as IccColorantOrderTagDataEntry;
return entry != null && this.Equals(entry);
}
/// <inheritdoc/>
public bool Equals(IccColorantOrderTagDataEntry other)
{
if (ReferenceEquals(null, other))
{
return false;
}
if (ReferenceEquals(this, other))
{
return this.ColorantNumber.SequenceEqual(entry.ColorantNumber);
return true;
}
return false;
return base.Equals(other) && this.ColorantNumber.SequenceEqual(other.ColorantNumber);
}
/// <inheritdoc />
public bool Equals(IccColorantOrderTagDataEntry other)
/// <inheritdoc/>
public override bool Equals(object obj)
{
return this.Equals((IccTagDataEntry)other);
if (ReferenceEquals(null, obj))
{
return false;
}
if (ReferenceEquals(this, obj))
{
return true;
}
return obj is IccColorantOrderTagDataEntry && this.Equals((IccColorantOrderTagDataEntry)obj);
}
/// <inheritdoc/>
public override int GetHashCode()
{
unchecked
{
return (base.GetHashCode() * 397) ^ (this.ColorantNumber != null ? this.ColorantNumber.GetHashCode() : 0);
}
}
}
}
}

47
src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccColorantTableTagDataEntry.cs

@ -43,21 +43,52 @@ namespace ImageSharp
/// </summary>
public IccColorantTableEntry[] ColorantData { get; }
/// <inheritdoc />
/// <inheritdoc/>
public override bool Equals(IccTagDataEntry other)
{
if (base.Equals(other) && other is IccColorantTableTagDataEntry entry)
var entry = other as IccColorantTableTagDataEntry;
return entry != null && this.Equals(entry);
}
/// <inheritdoc/>
public bool Equals(IccColorantTableTagDataEntry other)
{
if (ReferenceEquals(null, other))
{
return false;
}
if (ReferenceEquals(this, other))
{
return this.ColorantData.SequenceEqual(entry.ColorantData);
return true;
}
return false;
return base.Equals(other) && this.ColorantData.SequenceEqual(other.ColorantData);
}
/// <inheritdoc />
public bool Equals(IccColorantTableTagDataEntry other)
/// <inheritdoc/>
public override bool Equals(object obj)
{
return this.Equals((IccTagDataEntry)other);
if (ReferenceEquals(null, obj))
{
return false;
}
if (ReferenceEquals(this, obj))
{
return true;
}
return obj is IccColorantTableTagDataEntry && this.Equals((IccColorantTableTagDataEntry)obj);
}
/// <inheritdoc/>
public override int GetHashCode()
{
unchecked
{
return (base.GetHashCode() * 397) ^ (this.ColorantData != null ? this.ColorantData.GetHashCode() : 0);
}
}
}
}
}

60
src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccCrdInfoTagDataEntry.cs

@ -87,25 +87,63 @@ namespace ImageSharp
/// </summary>
public string RenderingIntent3Crd { get; }
/// <inheritdoc />
/// <inheritdoc/>
public override bool Equals(IccTagDataEntry other)
{
if (base.Equals(other) && other is IccCrdInfoTagDataEntry entry)
var entry = other as IccCrdInfoTagDataEntry;
return entry != null && this.Equals(entry);
}
/// <inheritdoc/>
public bool Equals(IccCrdInfoTagDataEntry other)
{
if (ReferenceEquals(null, other))
{
return false;
}
if (ReferenceEquals(this, other))
{
return this.PostScriptProductName == entry.PostScriptProductName
&& this.RenderingIntent0Crd == entry.RenderingIntent0Crd
&& this.RenderingIntent1Crd == entry.RenderingIntent1Crd
&& this.RenderingIntent2Crd == entry.RenderingIntent2Crd
&& this.RenderingIntent3Crd == entry.RenderingIntent3Crd;
return true;
}
return false;
return base.Equals(other)
&& string.Equals(this.PostScriptProductName, other.PostScriptProductName)
&& string.Equals(this.RenderingIntent0Crd, other.RenderingIntent0Crd)
&& string.Equals(this.RenderingIntent1Crd, other.RenderingIntent1Crd)
&& string.Equals(this.RenderingIntent2Crd, other.RenderingIntent2Crd)
&& string.Equals(this.RenderingIntent3Crd, other.RenderingIntent3Crd);
}
/// <inheritdoc />
public bool Equals(IccCrdInfoTagDataEntry other)
/// <inheritdoc/>
public override bool Equals(object obj)
{
return this.Equals((IccTagDataEntry)other);
if (ReferenceEquals(null, obj))
{
return false;
}
if (ReferenceEquals(this, obj))
{
return true;
}
return obj is IccCrdInfoTagDataEntry && this.Equals((IccCrdInfoTagDataEntry)obj);
}
/// <inheritdoc/>
public override int GetHashCode()
{
unchecked
{
int hashCode = base.GetHashCode();
hashCode = (hashCode * 397) ^ (this.PostScriptProductName != null ? this.PostScriptProductName.GetHashCode() : 0);
hashCode = (hashCode * 397) ^ (this.RenderingIntent0Crd != null ? this.RenderingIntent0Crd.GetHashCode() : 0);
hashCode = (hashCode * 397) ^ (this.RenderingIntent1Crd != null ? this.RenderingIntent1Crd.GetHashCode() : 0);
hashCode = (hashCode * 397) ^ (this.RenderingIntent2Crd != null ? this.RenderingIntent2Crd.GetHashCode() : 0);
hashCode = (hashCode * 397) ^ (this.RenderingIntent3Crd != null ? this.RenderingIntent3Crd.GetHashCode() : 0);
return hashCode;
}
}
}
}

74
src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccCurveTagDataEntry.cs

@ -26,7 +26,7 @@ namespace ImageSharp
/// </summary>
/// <param name="gamma">Gamma value</param>
public IccCurveTagDataEntry(float gamma)
: this(new float[] { gamma }, IccProfileTag.Unknown)
: this(new[] { gamma }, IccProfileTag.Unknown)
{
}
@ -54,7 +54,7 @@ namespace ImageSharp
/// <param name="gamma">Gamma value</param>
/// <param name="tagSignature">Tag Signature</param>
public IccCurveTagDataEntry(float gamma, IccProfileTag tagSignature)
: this(new float[] { gamma }, tagSignature)
: this(new[] { gamma }, tagSignature)
{
}
@ -78,52 +78,64 @@ namespace ImageSharp
/// Gets the gamma value.
/// Only valid if <see cref="IsGamma"/> is true
/// </summary>
public float Gamma
{
get
{
if (this.IsGamma)
{
return this.CurveData[0];
}
else
{
return 0;
}
}
}
public float Gamma => this.IsGamma ? this.CurveData[0] : 0;
/// <summary>
/// Gets a value indicating whether the curve maps input directly to output
/// </summary>
public bool IsIdentityResponse
{
get { return this.CurveData.Length == 0; }
}
public bool IsIdentityResponse => this.CurveData.Length == 0;
/// <summary>
/// Gets a value indicating whether the curve is a gamma curve
/// </summary>
public bool IsGamma
public bool IsGamma => this.CurveData.Length == 1;
/// <inheritdoc/>
public override bool Equals(IccTagDataEntry other)
{
get { return this.CurveData.Length == 1; }
var entry = other as IccCurveTagDataEntry;
return entry != null && this.Equals(entry);
}
/// <inheritdoc />
public override bool Equals(IccTagDataEntry other)
/// <inheritdoc/>
public bool Equals(IccCurveTagDataEntry other)
{
if (base.Equals(other) && other is IccCurveTagDataEntry entry)
if (ReferenceEquals(null, other))
{
return false;
}
if (ReferenceEquals(this, other))
{
return this.CurveData.SequenceEqual(entry.CurveData);
return true;
}
return false;
return base.Equals(other) && this.CurveData.SequenceEqual(other.CurveData);
}
/// <inheritdoc />
public bool Equals(IccCurveTagDataEntry other)
/// <inheritdoc/>
public override bool Equals(object obj)
{
if (ReferenceEquals(null, obj))
{
return false;
}
if (ReferenceEquals(this, obj))
{
return true;
}
return obj is IccCurveTagDataEntry && this.Equals((IccCurveTagDataEntry)obj);
}
/// <inheritdoc/>
public override int GetHashCode()
{
return this.Equals((IccTagDataEntry)other);
unchecked
{
return (base.GetHashCode() * 397) ^ (this.CurveData != null ? this.CurveData.GetHashCode() : 0);
}
}
}
}
}

60
src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccDataTagDataEntry.cs

@ -64,37 +64,57 @@ namespace ImageSharp
/// Gets the <see cref="Data"/> decoded as 7bit ASCII.
/// If <see cref="IsAscii"/> is false, returns null
/// </summary>
public string AsciiString
public string AsciiString => this.IsAscii ? AsciiEncoding.GetString(this.Data, 0, this.Data.Length) : null;
/// <inheritdoc/>
public override bool Equals(IccTagDataEntry other)
{
get
var entry = other as IccDataTagDataEntry;
return entry != null && this.Equals(entry);
}
/// <inheritdoc/>
public bool Equals(IccDataTagDataEntry other)
{
if (ReferenceEquals(null, other))
{
return false;
}
if (ReferenceEquals(this, other))
{
if (this.IsAscii)
{
return AsciiEncoding.GetString(this.Data, 0, this.Data.Length);
}
else
{
return null;
}
return true;
}
return base.Equals(other) && this.Data.SequenceEqual(other.Data) && this.IsAscii == other.IsAscii;
}
/// <inheritdoc />
public override bool Equals(IccTagDataEntry other)
/// <inheritdoc/>
public override bool Equals(object obj)
{
if (base.Equals(other) && other is IccDataTagDataEntry entry)
if (ReferenceEquals(null, obj))
{
return false;
}
if (ReferenceEquals(this, obj))
{
return this.IsAscii == entry.IsAscii
&& this.Data.SequenceEqual(entry.Data);
return true;
}
return false;
return obj is IccDataTagDataEntry && this.Equals((IccDataTagDataEntry)obj);
}
/// <inheritdoc />
public bool Equals(IccDataTagDataEntry other)
/// <inheritdoc/>
public override int GetHashCode()
{
return this.Equals((IccTagDataEntry)other);
unchecked
{
int hashCode = base.GetHashCode();
hashCode = (hashCode * 397) ^ (this.Data != null ? this.Data.GetHashCode() : 0);
hashCode = (hashCode * 397) ^ this.IsAscii.GetHashCode();
return hashCode;
}
}
}
}
}

47
src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccDateTimeTagDataEntry.cs

@ -37,21 +37,52 @@ namespace ImageSharp
/// </summary>
public DateTime Value { get; }
/// <inheritdoc />
/// <inheritdoc/>
public override bool Equals(IccTagDataEntry other)
{
if (base.Equals(other) && other is IccDateTimeTagDataEntry entry)
var entry = other as IccDateTimeTagDataEntry;
return entry != null && this.Equals(entry);
}
/// <inheritdoc/>
public bool Equals(IccDateTimeTagDataEntry other)
{
if (ReferenceEquals(null, other))
{
return false;
}
if (ReferenceEquals(this, other))
{
return this.Value == entry.Value;
return true;
}
return false;
return base.Equals(other) && this.Value.Equals(other.Value);
}
/// <inheritdoc />
public bool Equals(IccDateTimeTagDataEntry other)
/// <inheritdoc/>
public override bool Equals(object obj)
{
return this.Equals((IccTagDataEntry)other);
if (ReferenceEquals(null, obj))
{
return false;
}
if (ReferenceEquals(this, obj))
{
return true;
}
return obj is IccDateTimeTagDataEntry && this.Equals((IccDateTimeTagDataEntry)obj);
}
/// <inheritdoc/>
public override int GetHashCode()
{
unchecked
{
return (base.GetHashCode() * 397) ^ this.Value.GetHashCode();
}
}
}
}
}

47
src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccFix16ArrayTagDataEntry.cs

@ -39,21 +39,52 @@ namespace ImageSharp
/// </summary>
public float[] Data { get; }
/// <inheritdoc />
/// <inheritdoc/>
public override bool Equals(IccTagDataEntry other)
{
if (base.Equals(other) && other is IccFix16ArrayTagDataEntry entry)
var entry = other as IccFix16ArrayTagDataEntry;
return entry != null && this.Equals(entry);
}
/// <inheritdoc/>
public bool Equals(IccFix16ArrayTagDataEntry other)
{
if (ReferenceEquals(null, other))
{
return false;
}
if (ReferenceEquals(this, other))
{
return this.Data.SequenceEqual(entry.Data);
return true;
}
return false;
return base.Equals(other) && this.Data.SequenceEqual(other.Data);
}
/// <inheritdoc />
public bool Equals(IccFix16ArrayTagDataEntry other)
/// <inheritdoc/>
public override bool Equals(object obj)
{
return this.Equals((IccTagDataEntry)other);
if (ReferenceEquals(null, obj))
{
return false;
}
if (ReferenceEquals(this, obj))
{
return true;
}
return obj is IccFix16ArrayTagDataEntry && this.Equals((IccFix16ArrayTagDataEntry)obj);
}
/// <inheritdoc/>
public override int GetHashCode()
{
unchecked
{
return (base.GetHashCode() * 397) ^ (this.Data != null ? this.Data.GetHashCode() : 0);
}
}
}
}
}

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

@ -83,18 +83,12 @@ namespace ImageSharp
/// <summary>
/// Gets the number of input channels
/// </summary>
public int InputChannelCount
{
get { return this.InputValues.Length; }
}
public int InputChannelCount => this.InputValues.Length;
/// <summary>
/// Gets the number of output channels
/// </summary>
public int OutputChannelCount
{
get { return this.OutputValues.Length; }
}
public int OutputChannelCount => this.OutputValues.Length;
/// <summary>
/// Gets the conversion matrix
@ -116,24 +110,61 @@ namespace ImageSharp
/// </summary>
public IccLut[] OutputValues { get; }
/// <inheritdoc />
/// <inheritdoc/>
public override bool Equals(IccTagDataEntry other)
{
if (base.Equals(other) && other is IccLut16TagDataEntry entry)
var entry = other as IccLut16TagDataEntry;
return entry != null && this.Equals(entry);
}
/// <inheritdoc/>
public bool Equals(IccLut16TagDataEntry other)
{
if (ReferenceEquals(null, other))
{
return false;
}
if (ReferenceEquals(this, other))
{
return this.ClutValues.Equals(entry.ClutValues)
&& this.Matrix == entry.Matrix
&& this.InputValues.SequenceEqual(entry.InputValues)
&& this.OutputValues.SequenceEqual(entry.OutputValues);
return true;
}
return false;
return base.Equals(other)
&& this.Matrix.Equals(other.Matrix)
&& this.InputValues.SequenceEqual(other.InputValues)
&& this.ClutValues.Equals(other.ClutValues)
&& this.OutputValues.SequenceEqual(other.OutputValues);
}
/// <inheritdoc />
public bool Equals(IccLut16TagDataEntry other)
/// <inheritdoc/>
public override bool Equals(object obj)
{
return this.Equals((IccTagDataEntry)other);
if (ReferenceEquals(null, obj))
{
return false;
}
if (ReferenceEquals(this, obj))
{
return true;
}
return obj is IccLut16TagDataEntry && this.Equals((IccLut16TagDataEntry)obj);
}
/// <inheritdoc/>
public override int GetHashCode()
{
unchecked
{
int hashCode = base.GetHashCode();
hashCode = (hashCode * 397) ^ this.Matrix.GetHashCode();
hashCode = (hashCode * 397) ^ (this.InputValues != null ? this.InputValues.GetHashCode() : 0);
hashCode = (hashCode * 397) ^ (this.ClutValues != null ? this.ClutValues.GetHashCode() : 0);
hashCode = (hashCode * 397) ^ (this.OutputValues != null ? this.OutputValues.GetHashCode() : 0);
return hashCode;
}
}
private Matrix4x4 CreateMatrix(float[,] matrix)

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

@ -86,18 +86,12 @@ namespace ImageSharp
/// <summary>
/// Gets the number of input channels
/// </summary>
public int InputChannelCount
{
get { return this.InputValues.Length; }
}
public int InputChannelCount => this.InputValues.Length;
/// <summary>
/// Gets the number of output channels
/// </summary>
public int OutputChannelCount
{
get { return this.OutputValues.Length; }
}
public int OutputChannelCount => this.OutputValues.Length;
/// <summary>
/// Gets the conversion matrix
@ -119,24 +113,61 @@ namespace ImageSharp
/// </summary>
public IccLut[] OutputValues { get; }
/// <inheritdoc />
/// <inheritdoc/>
public override bool Equals(IccTagDataEntry other)
{
if (base.Equals(other) && other is IccLut8TagDataEntry entry)
var entry = other as IccLut8TagDataEntry;
return entry != null && this.Equals(entry);
}
/// <inheritdoc/>
public bool Equals(IccLut8TagDataEntry other)
{
if (ReferenceEquals(null, other))
{
return false;
}
if (ReferenceEquals(this, other))
{
return this.ClutValues.Equals(entry.ClutValues)
&& this.Matrix == entry.Matrix
&& this.InputValues.SequenceEqual(entry.InputValues)
&& this.OutputValues.SequenceEqual(entry.OutputValues);
return true;
}
return false;
return base.Equals(other)
&& this.Matrix.Equals(other.Matrix)
&& this.InputValues.SequenceEqual(other.InputValues)
&& this.ClutValues.Equals(other.ClutValues)
&& this.OutputValues.SequenceEqual(other.OutputValues);
}
/// <inheritdoc />
public bool Equals(IccLut8TagDataEntry other)
/// <inheritdoc/>
public override bool Equals(object obj)
{
return this.Equals((IccTagDataEntry)other);
if (ReferenceEquals(null, obj))
{
return false;
}
if (ReferenceEquals(this, obj))
{
return true;
}
return obj is IccLut8TagDataEntry && this.Equals((IccLut8TagDataEntry)obj);
}
/// <inheritdoc/>
public override int GetHashCode()
{
unchecked
{
int hashCode = base.GetHashCode();
hashCode = (hashCode * 397) ^ this.Matrix.GetHashCode();
hashCode = (hashCode * 397) ^ (this.InputValues != null ? this.InputValues.GetHashCode() : 0);
hashCode = (hashCode * 397) ^ (this.ClutValues != null ? this.ClutValues.GetHashCode() : 0);
hashCode = (hashCode * 397) ^ (this.OutputValues != null ? this.OutputValues.GetHashCode() : 0);
return hashCode;
}
}
private Matrix4x4 CreateMatrix(float[,] matrix)

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

@ -146,28 +146,69 @@ namespace ImageSharp
/// </summary>
public IccTagDataEntry[] CurveA { get; }
/// <inheritdoc />
/// <inheritdoc/>
public override bool Equals(IccTagDataEntry other)
{
if (base.Equals(other) && other is IccLutAToBTagDataEntry entry)
var entry = other as IccLutAToBTagDataEntry;
return entry != null && this.Equals(entry);
}
/// <inheritdoc/>
public bool Equals(IccLutAToBTagDataEntry other)
{
if (ReferenceEquals(null, other))
{
return false;
}
if (ReferenceEquals(this, other))
{
return this.InputChannelCount == entry.InputChannelCount
&& this.OutputChannelCount == entry.OutputChannelCount
&& this.Matrix3x1 == entry.Matrix3x1
&& this.Matrix3x3 == entry.Matrix3x3
&& this.ClutValues.Equals(entry.ClutValues)
&& this.EqualsCurve(this.CurveA, entry.CurveA)
&& this.EqualsCurve(this.CurveB, entry.CurveB)
&& this.EqualsCurve(this.CurveM, entry.CurveM);
return true;
}
return false;
return base.Equals(other)
&& this.InputChannelCount == other.InputChannelCount
&& this.OutputChannelCount == other.OutputChannelCount
&& this.Matrix3x3.Equals(other.Matrix3x3)
&& this.Matrix3x1.Equals(other.Matrix3x1)
&& this.ClutValues.Equals(other.ClutValues)
&& this.EqualsCurve(this.CurveB, other.CurveB)
&& this.EqualsCurve(this.CurveM, other.CurveM)
&& this.EqualsCurve(this.CurveA, other.CurveA);
}
/// <inheritdoc />
public bool Equals(IccLutAToBTagDataEntry other)
/// <inheritdoc/>
public override bool Equals(object obj)
{
return this.Equals((IccTagDataEntry)other);
if (ReferenceEquals(null, obj))
{
return false;
}
if (ReferenceEquals(this, obj))
{
return true;
}
return obj is IccLutAToBTagDataEntry && this.Equals((IccLutAToBTagDataEntry)obj);
}
/// <inheritdoc/>
public override int GetHashCode()
{
unchecked
{
int hashCode = base.GetHashCode();
hashCode = (hashCode * 397) ^ this.InputChannelCount;
hashCode = (hashCode * 397) ^ this.OutputChannelCount;
hashCode = (hashCode * 397) ^ this.Matrix3x3.GetHashCode();
hashCode = (hashCode * 397) ^ this.Matrix3x1.GetHashCode();
hashCode = (hashCode * 397) ^ (this.ClutValues != null ? this.ClutValues.GetHashCode() : 0);
hashCode = (hashCode * 397) ^ (this.CurveB != null ? this.CurveB.GetHashCode() : 0);
hashCode = (hashCode * 397) ^ (this.CurveM != null ? this.CurveM.GetHashCode() : 0);
hashCode = (hashCode * 397) ^ (this.CurveA != null ? this.CurveA.GetHashCode() : 0);
return hashCode;
}
}
private bool EqualsCurve(IccTagDataEntry[] thisCurves, IccTagDataEntry[] entryCurves)

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

@ -146,28 +146,69 @@ namespace ImageSharp
/// </summary>
public IccTagDataEntry[] CurveA { get; }
/// <inheritdoc />
/// <inheritdoc/>
public override bool Equals(IccTagDataEntry other)
{
if (base.Equals(other) && other is IccLutBToATagDataEntry entry)
var entry = other as IccLutBToATagDataEntry;
return entry != null && this.Equals(entry);
}
/// <inheritdoc/>
public bool Equals(IccLutBToATagDataEntry other)
{
if (ReferenceEquals(null, other))
{
return false;
}
if (ReferenceEquals(this, other))
{
return this.InputChannelCount == entry.InputChannelCount
&& this.OutputChannelCount == entry.OutputChannelCount
&& this.Matrix3x1 == entry.Matrix3x1
&& this.Matrix3x3 == entry.Matrix3x3
&& this.ClutValues.Equals(entry.ClutValues)
&& this.EqualsCurve(this.CurveA, entry.CurveA)
&& this.EqualsCurve(this.CurveB, entry.CurveB)
&& this.EqualsCurve(this.CurveM, entry.CurveM);
return true;
}
return false;
return base.Equals(other)
&& this.InputChannelCount == other.InputChannelCount
&& this.OutputChannelCount == other.OutputChannelCount
&& this.Matrix3x3.Equals(other.Matrix3x3)
&& this.Matrix3x1.Equals(other.Matrix3x1)
&& this.ClutValues.Equals(other.ClutValues)
&& this.EqualsCurve(this.CurveB, other.CurveB)
&& this.EqualsCurve(this.CurveM, other.CurveM)
&& this.EqualsCurve(this.CurveA, other.CurveA);
}
/// <inheritdoc />
public bool Equals(IccLutBToATagDataEntry other)
/// <inheritdoc/>
public override bool Equals(object obj)
{
return this.Equals((IccTagDataEntry)other);
if (ReferenceEquals(null, obj))
{
return false;
}
if (ReferenceEquals(this, obj))
{
return true;
}
return obj is IccLutBToATagDataEntry && this.Equals((IccLutBToATagDataEntry)obj);
}
/// <inheritdoc/>
public override int GetHashCode()
{
unchecked
{
int hashCode = base.GetHashCode();
hashCode = (hashCode * 397) ^ this.InputChannelCount;
hashCode = (hashCode * 397) ^ this.OutputChannelCount;
hashCode = (hashCode * 397) ^ this.Matrix3x3.GetHashCode();
hashCode = (hashCode * 397) ^ this.Matrix3x1.GetHashCode();
hashCode = (hashCode * 397) ^ (this.ClutValues != null ? this.ClutValues.GetHashCode() : 0);
hashCode = (hashCode * 397) ^ (this.CurveB != null ? this.CurveB.GetHashCode() : 0);
hashCode = (hashCode * 397) ^ (this.CurveM != null ? this.CurveM.GetHashCode() : 0);
hashCode = (hashCode * 397) ^ (this.CurveA != null ? this.CurveA.GetHashCode() : 0);
return hashCode;
}
}
private bool EqualsCurve(IccTagDataEntry[] thisCurves, IccTagDataEntry[] entryCurves)

60
src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccMeasurementTagDataEntry.cs

@ -72,25 +72,63 @@ namespace ImageSharp
/// </summary>
public IccStandardIlluminant Illuminant { get; }
/// <inheritdoc />
/// <inheritdoc/>
public override bool Equals(IccTagDataEntry other)
{
if (base.Equals(other) && other is IccMeasurementTagDataEntry entry)
var entry = other as IccMeasurementTagDataEntry;
return entry != null && this.Equals(entry);
}
/// <inheritdoc/>
public bool Equals(IccMeasurementTagDataEntry other)
{
if (ReferenceEquals(null, other))
{
return false;
}
if (ReferenceEquals(this, other))
{
return this.Observer == entry.Observer
&& this.XyzBacking == entry.XyzBacking
&& this.Geometry == entry.Geometry
&& this.Flare == entry.Flare
&& this.Illuminant == entry.Illuminant;
return true;
}
return false;
return base.Equals(other)
&& this.Observer == other.Observer
&& this.XyzBacking.Equals(other.XyzBacking)
&& this.Geometry == other.Geometry
&& this.Flare.Equals(other.Flare)
&& this.Illuminant == other.Illuminant;
}
/// <inheritdoc />
public bool Equals(IccMeasurementTagDataEntry other)
/// <inheritdoc/>
public override bool Equals(object obj)
{
return this.Equals((IccTagDataEntry)other);
if (ReferenceEquals(null, obj))
{
return false;
}
if (ReferenceEquals(this, obj))
{
return true;
}
return obj is IccMeasurementTagDataEntry && this.Equals((IccMeasurementTagDataEntry)obj);
}
/// <inheritdoc/>
public override int GetHashCode()
{
unchecked
{
int hashCode = base.GetHashCode();
hashCode = (hashCode * 397) ^ (int)this.Observer;
hashCode = (hashCode * 397) ^ this.XyzBacking.GetHashCode();
hashCode = (hashCode * 397) ^ (int)this.Geometry;
hashCode = (hashCode * 397) ^ this.Flare.GetHashCode();
hashCode = (hashCode * 397) ^ (int)this.Illuminant;
return hashCode;
}
}
}
}

45
src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccMultiLocalizedUnicodeTagDataEntry.cs

@ -40,21 +40,52 @@ namespace ImageSharp
/// </summary>
public IccLocalizedString[] Texts { get; }
/// <inheritdoc />
/// <inheritdoc/>
public override bool Equals(IccTagDataEntry other)
{
if (base.Equals(other) && other is IccMultiLocalizedUnicodeTagDataEntry entry)
var entry = other as IccMultiLocalizedUnicodeTagDataEntry;
return entry != null && this.Equals(entry);
}
/// <inheritdoc/>
public bool Equals(IccMultiLocalizedUnicodeTagDataEntry other)
{
if (ReferenceEquals(null, other))
{
return false;
}
if (ReferenceEquals(this, other))
{
return true;
}
return base.Equals(other) && this.Texts.SequenceEqual(other.Texts);
}
/// <inheritdoc/>
public override bool Equals(object obj)
{
if (ReferenceEquals(null, obj))
{
return false;
}
if (ReferenceEquals(this, obj))
{
return this.Texts.SequenceEqual(entry.Texts);
return true;
}
return false;
return obj is IccMultiLocalizedUnicodeTagDataEntry && this.Equals((IccMultiLocalizedUnicodeTagDataEntry)obj);
}
/// <inheritdoc />
public bool Equals(IccMultiLocalizedUnicodeTagDataEntry other)
public override int GetHashCode()
{
return this.Equals((IccTagDataEntry)other);
unchecked
{
return (base.GetHashCode() * 397) ^ (this.Texts != null ? this.Texts.GetHashCode() : 0);
}
}
}
}
}

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

@ -57,23 +57,59 @@ namespace ImageSharp
/// </summary>
public IccMultiProcessElement[] Data { get; }
/// <inheritdoc />
/// <inheritdoc/>
public override bool Equals(IccTagDataEntry other)
{
if (base.Equals(other) && other is IccMultiProcessElementsTagDataEntry entry)
var entry = other as IccMultiProcessElementsTagDataEntry;
return entry != null && this.Equals(entry);
}
/// <inheritdoc/>
public bool Equals(IccMultiProcessElementsTagDataEntry other)
{
if (ReferenceEquals(null, other))
{
return false;
}
if (ReferenceEquals(this, other))
{
return this.InputChannelCount == entry.InputChannelCount
&& this.OutputChannelCount == entry.OutputChannelCount
&& this.Data.SequenceEqual(entry.Data);
return true;
}
return false;
return base.Equals(other)
&& this.InputChannelCount == other.InputChannelCount
&& this.OutputChannelCount == other.OutputChannelCount
&& this.Data.SequenceEqual(other.Data);
}
/// <inheritdoc />
public bool Equals(IccMultiProcessElementsTagDataEntry other)
/// <inheritdoc/>
public override bool Equals(object obj)
{
return this.Equals((IccTagDataEntry)other);
if (ReferenceEquals(null, obj))
{
return false;
}
if (ReferenceEquals(this, obj))
{
return true;
}
return obj is IccMultiProcessElementsTagDataEntry && this.Equals((IccMultiProcessElementsTagDataEntry)obj);
}
/// <inheritdoc/>
public override int GetHashCode()
{
unchecked
{
int hashCode = base.GetHashCode();
hashCode = (hashCode * 397) ^ this.InputChannelCount;
hashCode = (hashCode * 397) ^ this.OutputChannelCount;
hashCode = (hashCode * 397) ^ (this.Data != null ? this.Data.GetHashCode() : 0);
return hashCode;
}
}
}
}
}

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

@ -120,25 +120,63 @@ namespace ImageSharp
/// </summary>
public IccNamedColor[] Colors { get; }
/// <inheritdoc />
/// <inheritdoc/>
public override bool Equals(IccTagDataEntry other)
{
if (base.Equals(other) && other is IccNamedColor2TagDataEntry entry)
var entry = other as IccNamedColor2TagDataEntry;
return entry != null && this.Equals(entry);
}
/// <inheritdoc/>
public bool Equals(IccNamedColor2TagDataEntry other)
{
if (ReferenceEquals(null, other))
{
return false;
}
if (ReferenceEquals(this, other))
{
return this.CoordinateCount == entry.CoordinateCount
&& this.Prefix == entry.Prefix
&& this.Suffix == entry.Suffix
&& this.VendorFlags == entry.VendorFlags
&& this.Colors.SequenceEqual(entry.Colors);
return true;
}
return false;
return base.Equals(other)
&& this.CoordinateCount == other.CoordinateCount
&& string.Equals(this.Prefix, other.Prefix)
&& string.Equals(this.Suffix, other.Suffix)
&& this.VendorFlags == other.VendorFlags
&& this.Colors.SequenceEqual(other.Colors);
}
/// <inheritdoc />
public bool Equals(IccNamedColor2TagDataEntry other)
/// <inheritdoc/>
public override bool Equals(object obj)
{
return this.Equals((IccTagDataEntry)other);
if (ReferenceEquals(null, obj))
{
return false;
}
if (ReferenceEquals(this, obj))
{
return true;
}
return obj is IccNamedColor2TagDataEntry && this.Equals((IccNamedColor2TagDataEntry)obj);
}
/// <inheritdoc/>
public override int GetHashCode()
{
unchecked
{
int hashCode = base.GetHashCode();
hashCode = (hashCode * 397) ^ this.CoordinateCount;
hashCode = (hashCode * 397) ^ (this.Prefix != null ? this.Prefix.GetHashCode() : 0);
hashCode = (hashCode * 397) ^ (this.Suffix != null ? this.Suffix.GetHashCode() : 0);
hashCode = (hashCode * 397) ^ this.VendorFlags;
hashCode = (hashCode * 397) ^ (this.Colors != null ? this.Colors.GetHashCode() : 0);
return hashCode;
}
}
}
}

43
src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccParametricCurveTagDataEntry.cs

@ -38,21 +38,52 @@ namespace ImageSharp
/// </summary>
public IccParametricCurve Curve { get; }
/// <inheritdoc />
/// <inheritdoc/>
public override bool Equals(IccTagDataEntry other)
{
if (base.Equals(other) && other is IccParametricCurveTagDataEntry entry)
var entry = other as IccParametricCurveTagDataEntry;
return entry != null && this.Equals(entry);
}
/// <inheritdoc/>
public bool Equals(IccParametricCurveTagDataEntry other)
{
if (ReferenceEquals(null, other))
{
return false;
}
if (ReferenceEquals(this, other))
{
return true;
}
return base.Equals(other) && this.Curve.Equals(other.Curve);
}
/// <inheritdoc/>
public override bool Equals(object obj)
{
if (ReferenceEquals(null, obj))
{
return false;
}
if (ReferenceEquals(this, obj))
{
return this.Curve.Equals(entry.Curve);
return true;
}
return false;
return obj is IccParametricCurveTagDataEntry && this.Equals((IccParametricCurveTagDataEntry)obj);
}
/// <inheritdoc />
public bool Equals(IccParametricCurveTagDataEntry other)
public override int GetHashCode()
{
return this.Equals((IccTagDataEntry)other);
unchecked
{
return (base.GetHashCode() * 397) ^ (this.Curve != null ? this.Curve.GetHashCode() : 0);
}
}
}
}

43
src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccProfileSequenceDescTagDataEntry.cs

@ -41,21 +41,52 @@ namespace ImageSharp
/// </summary>
public IccProfileDescription[] Descriptions { get; }
/// <inheritdoc />
/// <inheritdoc/>
public override bool Equals(IccTagDataEntry other)
{
if (base.Equals(other) && other is IccProfileSequenceDescTagDataEntry entry)
var entry = other as IccProfileSequenceDescTagDataEntry;
return entry != null && this.Equals(entry);
}
/// <inheritdoc />
public bool Equals(IccProfileSequenceDescTagDataEntry other)
{
if (ReferenceEquals(null, other))
{
return this.Descriptions.SequenceEqual(entry.Descriptions);
return false;
}
return false;
if (ReferenceEquals(this, other))
{
return true;
}
return base.Equals(other) && this.Descriptions.SequenceEqual(other.Descriptions);
}
/// <inheritdoc/>
public override bool Equals(object obj)
{
if (ReferenceEquals(null, obj))
{
return false;
}
if (ReferenceEquals(this, obj))
{
return true;
}
return obj is IccProfileSequenceDescTagDataEntry && this.Equals((IccProfileSequenceDescTagDataEntry)obj);
}
/// <inheritdoc />
public bool Equals(IccProfileSequenceDescTagDataEntry other)
public override int GetHashCode()
{
return this.Equals((IccTagDataEntry)other);
unchecked
{
return (base.GetHashCode() * 397) ^ (this.Descriptions != null ? this.Descriptions.GetHashCode() : 0);
}
}
}
}

43
src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccProfileSequenceIdentifierTagDataEntry.cs

@ -40,21 +40,52 @@ namespace ImageSharp
/// </summary>
public IccProfileSequenceIdentifier[] Data { get; }
/// <inheritdoc />
/// <inheritdoc/>
public override bool Equals(IccTagDataEntry other)
{
if (base.Equals(other) && other is IccProfileSequenceIdentifierTagDataEntry entry)
var entry = other as IccProfileSequenceIdentifierTagDataEntry;
return entry != null && this.Equals(entry);
}
/// <inheritdoc />
public bool Equals(IccProfileSequenceIdentifierTagDataEntry other)
{
if (ReferenceEquals(null, other))
{
return this.Data.SequenceEqual(entry.Data);
return false;
}
return false;
if (ReferenceEquals(this, other))
{
return true;
}
return base.Equals(other) && this.Data.SequenceEqual(other.Data);
}
/// <inheritdoc />
public bool Equals(IccProfileSequenceIdentifierTagDataEntry other)
public override bool Equals(object obj)
{
if (ReferenceEquals(null, obj))
{
return false;
}
if (ReferenceEquals(this, obj))
{
return true;
}
return obj is IccProfileSequenceIdentifierTagDataEntry && this.Equals((IccProfileSequenceIdentifierTagDataEntry)obj);
}
/// <inheritdoc />
public override int GetHashCode()
{
return this.Equals((IccTagDataEntry)other);
unchecked
{
return (base.GetHashCode() * 397) ^ (this.Data != null ? this.Data.GetHashCode() : 0);
}
}
}
}

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

@ -52,22 +52,57 @@ namespace ImageSharp
/// </summary>
public IccResponseCurve[] Curves { get; }
/// <inheritdoc />
/// <inheritdoc/>
public override bool Equals(IccTagDataEntry other)
{
if (base.Equals(other) && other is IccResponseCurveSet16TagDataEntry entry)
var entry = other as IccResponseCurveSet16TagDataEntry;
return entry != null && this.Equals(entry);
}
/// <inheritdoc />
public bool Equals(IccResponseCurveSet16TagDataEntry other)
{
if (ReferenceEquals(null, other))
{
return this.ChannelCount == entry.ChannelCount
&& this.Curves.SequenceEqual(entry.Curves);
return false;
}
return false;
if (ReferenceEquals(this, other))
{
return true;
}
return base.Equals(other)
&& this.ChannelCount == other.ChannelCount
&& this.Curves.SequenceEqual(other.Curves);
}
/// <inheritdoc />
public bool Equals(IccResponseCurveSet16TagDataEntry other)
public override bool Equals(object obj)
{
if (ReferenceEquals(null, obj))
{
return false;
}
if (ReferenceEquals(this, obj))
{
return true;
}
return obj is IccResponseCurveSet16TagDataEntry && this.Equals((IccResponseCurveSet16TagDataEntry)obj);
}
/// <inheritdoc />
public override int GetHashCode()
{
return this.Equals((IccTagDataEntry)other);
unchecked
{
int hashCode = base.GetHashCode();
hashCode = (hashCode * 397) ^ this.ChannelCount.GetHashCode();
hashCode = (hashCode * 397) ^ (this.Curves != null ? this.Curves.GetHashCode() : 0);
return hashCode;
}
}
}
}
}

49
src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccScreeningTagDataEntry.cs

@ -49,22 +49,57 @@ namespace ImageSharp
/// </summary>
public IccScreeningChannel[] Channels { get; }
/// <inheritdoc />
/// <inheritdoc/>
public override bool Equals(IccTagDataEntry other)
{
if (base.Equals(other) && other is IccScreeningTagDataEntry entry)
var entry = other as IccScreeningTagDataEntry;
return entry != null && this.Equals(entry);
}
/// <inheritdoc />
public bool Equals(IccScreeningTagDataEntry other)
{
if (ReferenceEquals(null, other))
{
return this.Flags == entry.Flags
&& this.Channels.SequenceEqual(entry.Channels);
return false;
}
return false;
if (ReferenceEquals(this, other))
{
return true;
}
return base.Equals(other)
&& this.Flags == other.Flags
&& this.Channels.SequenceEqual(other.Channels);
}
/// <inheritdoc />
public bool Equals(IccScreeningTagDataEntry other)
public override bool Equals(object obj)
{
return this.Equals((IccTagDataEntry)other);
if (ReferenceEquals(null, obj))
{
return false;
}
if (ReferenceEquals(this, obj))
{
return true;
}
return obj is IccScreeningTagDataEntry && this.Equals((IccScreeningTagDataEntry)obj);
}
/// <inheritdoc/>
public override int GetHashCode()
{
unchecked
{
int hashCode = base.GetHashCode();
hashCode = (hashCode * 397) ^ (int)this.Flags;
hashCode = (hashCode * 397) ^ (this.Channels != null ? this.Channels.GetHashCode() : 0);
return hashCode;
}
}
}
}

43
src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccSignatureTagDataEntry.cs

@ -39,21 +39,52 @@ namespace ImageSharp
/// </summary>
public string SignatureData { get; }
/// <inheritdoc />
/// <inheritdoc/>
public override bool Equals(IccTagDataEntry other)
{
if (base.Equals(other) && other is IccSignatureTagDataEntry entry)
var entry = other as IccSignatureTagDataEntry;
return entry != null && this.Equals(entry);
}
/// <inheritdoc />
public bool Equals(IccSignatureTagDataEntry other)
{
if (ReferenceEquals(null, other))
{
return this.SignatureData == entry.SignatureData;
return false;
}
return false;
if (ReferenceEquals(this, other))
{
return true;
}
return base.Equals(other) && string.Equals(this.SignatureData, other.SignatureData);
}
/// <inheritdoc />
public bool Equals(IccSignatureTagDataEntry other)
public override bool Equals(object obj)
{
if (ReferenceEquals(null, obj))
{
return false;
}
if (ReferenceEquals(this, obj))
{
return true;
}
return obj is IccSignatureTagDataEntry && this.Equals((IccSignatureTagDataEntry)obj);
}
/// <inheritdoc />
public override int GetHashCode()
{
return this.Equals((IccTagDataEntry)other);
unchecked
{
return (base.GetHashCode() * 397) ^ (this.SignatureData != null ? this.SignatureData.GetHashCode() : 0);
}
}
}
}

81
src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccTextDescriptionTagDataEntry.cs

@ -87,14 +87,9 @@ namespace ImageSharp
if (!string.IsNullOrEmpty(textEntry.Unicode))
{
CultureInfo culture = GetCulture(textEntry.UnicodeLanguageCode);
if (culture != null)
{
localString = new IccLocalizedString(culture, textEntry.Unicode);
}
else
{
localString = new IccLocalizedString(textEntry.Unicode);
}
localString = culture != null
? new IccLocalizedString(culture, textEntry.Unicode)
: new IccLocalizedString(textEntry.Unicode);
}
else if (!string.IsNullOrEmpty(textEntry.Ascii))
{
@ -109,7 +104,7 @@ namespace ImageSharp
localString = new IccLocalizedString(string.Empty);
}
return new IccMultiLocalizedUnicodeTagDataEntry(new IccLocalizedString[] { localString }, textEntry.TagSignature);
return new IccMultiLocalizedUnicodeTagDataEntry(new[] { localString }, textEntry.TagSignature);
CultureInfo GetCulture(uint value)
{
@ -129,35 +124,71 @@ namespace ImageSharp
&& p3 >= 0x41 && p3 <= 0x5A
&& p4 >= 0x41 && p4 <= 0x5A)
{
string culture = new string(new char[] { (char)p1, (char)p2, '-', (char)p3, (char)p4 });
string culture = new string(new[] { (char)p1, (char)p2, '-', (char)p3, (char)p4 });
return new CultureInfo(culture);
}
else
{
return null;
}
return null;
}
}
/// <inheritdoc />
/// <inheritdoc/>
public override bool Equals(IccTagDataEntry other)
{
if (base.Equals(other) && other is IccTextDescriptionTagDataEntry entry)
var entry = other as IccTextDescriptionTagDataEntry;
return entry != null && this.Equals(entry);
}
/// <inheritdoc />
public bool Equals(IccTextDescriptionTagDataEntry other)
{
if (ReferenceEquals(null, other))
{
return this.Ascii == entry.Ascii
&& this.Unicode == entry.Unicode
&& this.ScriptCode == entry.ScriptCode
&& this.UnicodeLanguageCode == entry.UnicodeLanguageCode
&& this.ScriptCodeCode == entry.ScriptCodeCode;
return false;
}
return false;
if (ReferenceEquals(this, other))
{
return true;
}
return base.Equals(other)
&& string.Equals(this.Ascii, other.Ascii)
&& string.Equals(this.Unicode, other.Unicode)
&& string.Equals(this.ScriptCode, other.ScriptCode)
&& this.UnicodeLanguageCode == other.UnicodeLanguageCode
&& this.ScriptCodeCode == other.ScriptCodeCode;
}
/// <inheritdoc />
public bool Equals(IccTextDescriptionTagDataEntry other)
public override bool Equals(object obj)
{
return this.Equals((IccTagDataEntry)other);
if (ReferenceEquals(null, obj))
{
return false;
}
if (ReferenceEquals(this, obj))
{
return true;
}
return obj is IccTextDescriptionTagDataEntry && this.Equals((IccTextDescriptionTagDataEntry)obj);
}
/// <inheritdoc />
public override int GetHashCode()
{
unchecked
{
int hashCode = base.GetHashCode();
hashCode = (hashCode * 397) ^ (this.Ascii != null ? this.Ascii.GetHashCode() : 0);
hashCode = (hashCode * 397) ^ (this.Unicode != null ? this.Unicode.GetHashCode() : 0);
hashCode = (hashCode * 397) ^ (this.ScriptCode != null ? this.ScriptCode.GetHashCode() : 0);
hashCode = (hashCode * 397) ^ (int)this.UnicodeLanguageCode;
hashCode = (hashCode * 397) ^ this.ScriptCodeCode.GetHashCode();
return hashCode;
}
}
}
}
}

45
src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccTextTagDataEntry.cs

@ -38,21 +38,52 @@ namespace ImageSharp
/// </summary>
public string Text { get; }
/// <inheritdoc />
/// <inheritdoc/>
public override bool Equals(IccTagDataEntry other)
{
if (base.Equals(other) && other is IccTextTagDataEntry entry)
var entry = other as IccTextTagDataEntry;
return entry != null && this.Equals(entry);
}
/// <inheritdoc />
public bool Equals(IccTextTagDataEntry other)
{
if (ReferenceEquals(null, other))
{
return this.Text == entry.Text;
return false;
}
return false;
if (ReferenceEquals(this, other))
{
return true;
}
return base.Equals(other) && string.Equals(this.Text, other.Text);
}
/// <inheritdoc />
public bool Equals(IccTextTagDataEntry other)
public override bool Equals(object obj)
{
if (ReferenceEquals(null, obj))
{
return false;
}
if (ReferenceEquals(this, obj))
{
return true;
}
return obj is IccTextTagDataEntry && this.Equals((IccTextTagDataEntry)obj);
}
/// <inheritdoc />
public override int GetHashCode()
{
return this.Equals((IccTagDataEntry)other);
unchecked
{
return (base.GetHashCode() * 397) ^ (this.Text != null ? this.Text.GetHashCode() : 0);
}
}
}
}
}

47
src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUFix16ArrayTagDataEntry.cs

@ -39,21 +39,52 @@ namespace ImageSharp
/// </summary>
public float[] Data { get; }
/// <inheritdoc />
/// <inheritdoc/>
public override bool Equals(IccTagDataEntry other)
{
if (base.Equals(other) && other is IccUFix16ArrayTagDataEntry entry)
var entry = other as IccUFix16ArrayTagDataEntry;
return entry != null && this.Equals(entry);
}
/// <inheritdoc/>
public bool Equals(IccUFix16ArrayTagDataEntry other)
{
if (ReferenceEquals(null, other))
{
return false;
}
if (ReferenceEquals(this, other))
{
return this.Data.SequenceEqual(entry.Data);
return true;
}
return false;
return base.Equals(other) && this.Data.SequenceEqual(other.Data);
}
/// <inheritdoc />
public bool Equals(IccUFix16ArrayTagDataEntry other)
/// <inheritdoc/>
public override bool Equals(object obj)
{
return this.Equals((IccTagDataEntry)other);
if (ReferenceEquals(null, obj))
{
return false;
}
if (ReferenceEquals(this, obj))
{
return true;
}
return obj is IccUFix16ArrayTagDataEntry && this.Equals((IccUFix16ArrayTagDataEntry)obj);
}
/// <inheritdoc/>
public override int GetHashCode()
{
unchecked
{
return (base.GetHashCode() * 397) ^ (this.Data != null ? this.Data.GetHashCode() : 0);
}
}
}
}
}

45
src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUInt16ArrayTagDataEntry.cs

@ -39,21 +39,52 @@ namespace ImageSharp
/// </summary>
public ushort[] Data { get; }
/// <inheritdoc />
/// <inheritdoc/>
public override bool Equals(IccTagDataEntry other)
{
if (base.Equals(other) && other is IccUInt16ArrayTagDataEntry entry)
var entry = other as IccUInt16ArrayTagDataEntry;
return entry != null && this.Equals(entry);
}
/// <inheritdoc/>
public bool Equals(IccUInt16ArrayTagDataEntry other)
{
if (ReferenceEquals(null, other))
{
return false;
}
if (ReferenceEquals(this, other))
{
return this.Data.SequenceEqual(entry.Data);
return true;
}
return false;
return base.Equals(other) && this.Data.SequenceEqual(other.Data);
}
/// <inheritdoc />
public bool Equals(IccUInt16ArrayTagDataEntry other)
/// <inheritdoc/>
public override bool Equals(object obj)
{
return this.Equals((IccTagDataEntry)other);
if (ReferenceEquals(null, obj))
{
return false;
}
if (ReferenceEquals(this, obj))
{
return true;
}
return obj is IccUInt16ArrayTagDataEntry && this.Equals((IccUInt16ArrayTagDataEntry)obj);
}
/// <inheritdoc/>
public override int GetHashCode()
{
unchecked
{
return (base.GetHashCode() * 397) ^ (this.Data != null ? this.Data.GetHashCode() : 0);
}
}
}
}

47
src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUInt32ArrayTagDataEntry.cs

@ -39,21 +39,52 @@ namespace ImageSharp
/// </summary>
public uint[] Data { get; }
/// <inheritdoc />
/// <inheritdoc/>
public override bool Equals(IccTagDataEntry other)
{
if (base.Equals(other) && other is IccUInt32ArrayTagDataEntry entry)
var entry = other as IccUInt32ArrayTagDataEntry;
return entry != null && this.Equals(entry);
}
/// <inheritdoc/>
public bool Equals(IccUInt32ArrayTagDataEntry other)
{
if (ReferenceEquals(null, other))
{
return false;
}
if (ReferenceEquals(this, other))
{
return this.Data.SequenceEqual(entry.Data);
return true;
}
return false;
return base.Equals(other) && this.Data.SequenceEqual(other.Data);
}
/// <inheritdoc />
public bool Equals(IccUInt32ArrayTagDataEntry other)
/// <inheritdoc/>
public override bool Equals(object obj)
{
return this.Equals((IccTagDataEntry)other);
if (ReferenceEquals(null, obj))
{
return false;
}
if (ReferenceEquals(this, obj))
{
return true;
}
return obj is IccUInt32ArrayTagDataEntry && this.Equals((IccUInt32ArrayTagDataEntry)obj);
}
/// <inheritdoc/>
public override int GetHashCode()
{
unchecked
{
return (base.GetHashCode() * 397) ^ (this.Data != null ? this.Data.GetHashCode() : 0);
}
}
}
}
}

47
src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUInt64ArrayTagDataEntry.cs

@ -39,21 +39,52 @@ namespace ImageSharp
/// </summary>
public ulong[] Data { get; }
/// <inheritdoc />
/// <inheritdoc/>
public override bool Equals(IccTagDataEntry other)
{
if (base.Equals(other) && other is IccUInt64ArrayTagDataEntry entry)
var entry = other as IccUInt64ArrayTagDataEntry;
return entry != null && this.Equals(entry);
}
/// <inheritdoc/>
public bool Equals(IccUInt64ArrayTagDataEntry other)
{
if (ReferenceEquals(null, other))
{
return false;
}
if (ReferenceEquals(this, other))
{
return this.Data.SequenceEqual(entry.Data);
return true;
}
return false;
return base.Equals(other) && this.Data.SequenceEqual(other.Data);
}
/// <inheritdoc />
public bool Equals(IccUInt64ArrayTagDataEntry other)
/// <inheritdoc/>
public override bool Equals(object obj)
{
return this.Equals((IccTagDataEntry)other);
if (ReferenceEquals(null, obj))
{
return false;
}
if (ReferenceEquals(this, obj))
{
return true;
}
return obj is IccUInt64ArrayTagDataEntry && this.Equals((IccUInt64ArrayTagDataEntry)obj);
}
/// <inheritdoc/>
public override int GetHashCode()
{
unchecked
{
return (base.GetHashCode() * 397) ^ (this.Data != null ? this.Data.GetHashCode() : 0);
}
}
}
}
}

47
src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUInt8ArrayTagDataEntry.cs

@ -39,21 +39,52 @@ namespace ImageSharp
/// </summary>
public byte[] Data { get; }
/// <inheritdoc />
/// <inheritdoc/>
public override bool Equals(IccTagDataEntry other)
{
if (base.Equals(other) && other is IccUInt8ArrayTagDataEntry entry)
var entry = other as IccUInt8ArrayTagDataEntry;
return entry != null && this.Equals(entry);
}
/// <inheritdoc/>
public bool Equals(IccUInt8ArrayTagDataEntry other)
{
if (ReferenceEquals(null, other))
{
return false;
}
if (ReferenceEquals(this, other))
{
return this.Data.SequenceEqual(entry.Data);
return true;
}
return false;
return base.Equals(other) && this.Data.SequenceEqual(other.Data);
}
/// <inheritdoc />
public bool Equals(IccUInt8ArrayTagDataEntry other)
/// <inheritdoc/>
public override bool Equals(object obj)
{
return this.Equals((IccTagDataEntry)other);
if (ReferenceEquals(null, obj))
{
return false;
}
if (ReferenceEquals(this, obj))
{
return true;
}
return obj is IccUInt8ArrayTagDataEntry && this.Equals((IccUInt8ArrayTagDataEntry)obj);
}
/// <inheritdoc/>
public override int GetHashCode()
{
unchecked
{
return (base.GetHashCode() * 397) ^ (this.Data != null ? this.Data.GetHashCode() : 0);
}
}
}
}
}

56
src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUcrBgTagDataEntry.cs

@ -59,23 +59,59 @@ namespace ImageSharp
/// </summary>
public string Description { get; }
/// <inheritdoc />
/// <inheritdoc/>
public override bool Equals(IccTagDataEntry other)
{
if (base.Equals(other) && other is IccUcrBgTagDataEntry entry)
var entry = other as IccUcrBgTagDataEntry;
return entry != null && this.Equals(entry);
}
/// <inheritdoc/>
public bool Equals(IccUcrBgTagDataEntry other)
{
if (ReferenceEquals(null, other))
{
return false;
}
if (ReferenceEquals(this, other))
{
return this.Description == entry.Description
&& this.UcrCurve.SequenceEqual(entry.UcrCurve)
&& this.BgCurve.SequenceEqual(entry.BgCurve);
return true;
}
return false;
return base.Equals(other)
&& this.UcrCurve.SequenceEqual(other.UcrCurve)
&& this.BgCurve.SequenceEqual(other.BgCurve)
&& string.Equals(this.Description, other.Description);
}
/// <inheritdoc />
public bool Equals(IccUcrBgTagDataEntry other)
/// <inheritdoc/>
public override bool Equals(object obj)
{
return this.Equals((IccTagDataEntry)other);
if (ReferenceEquals(null, obj))
{
return false;
}
if (ReferenceEquals(this, obj))
{
return true;
}
return obj is IccUcrBgTagDataEntry && this.Equals((IccUcrBgTagDataEntry)obj);
}
/// <inheritdoc/>
public override int GetHashCode()
{
unchecked
{
int hashCode = base.GetHashCode();
hashCode = (hashCode * 397) ^ (this.UcrCurve != null ? this.UcrCurve.GetHashCode() : 0);
hashCode = (hashCode * 397) ^ (this.BgCurve != null ? this.BgCurve.GetHashCode() : 0);
hashCode = (hashCode * 397) ^ (this.Description != null ? this.Description.GetHashCode() : 0);
return hashCode;
}
}
}
}
}

47
src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUnknownTagDataEntry.cs

@ -39,21 +39,52 @@ namespace ImageSharp
/// </summary>
public byte[] Data { get; }
/// <inheritdoc />
/// <inheritdoc/>
public override bool Equals(IccTagDataEntry other)
{
if (base.Equals(other) && other is IccUnknownTagDataEntry entry)
var entry = other as IccUnknownTagDataEntry;
return entry != null && this.Equals(entry);
}
/// <inheritdoc/>
public bool Equals(IccUnknownTagDataEntry other)
{
if (ReferenceEquals(null, other))
{
return false;
}
if (ReferenceEquals(this, other))
{
return this.Data.SequenceEqual(entry.Data);
return true;
}
return false;
return base.Equals(other) && this.Data.SequenceEqual(other.Data);
}
/// <inheritdoc />
public bool Equals(IccUnknownTagDataEntry other)
/// <inheritdoc/>
public override bool Equals(object obj)
{
return this.Equals((IccTagDataEntry)other);
if (ReferenceEquals(null, obj))
{
return false;
}
if (ReferenceEquals(this, obj))
{
return true;
}
return obj is IccUnknownTagDataEntry && this.Equals((IccUnknownTagDataEntry)obj);
}
/// <inheritdoc/>
public override int GetHashCode()
{
unchecked
{
return (base.GetHashCode() * 397) ^ (this.Data != null ? this.Data.GetHashCode() : 0);
}
}
}
}
}

54
src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccViewingConditionsTagDataEntry.cs

@ -54,23 +54,59 @@ namespace ImageSharp
/// </summary>
public IccStandardIlluminant Illuminant { get; }
/// <inheritdoc />
/// <inheritdoc/>
public override bool Equals(IccTagDataEntry other)
{
if (base.Equals(other) && other is IccViewingConditionsTagDataEntry entry)
var entry = other as IccViewingConditionsTagDataEntry;
return entry != null && this.Equals(entry);
}
/// <inheritdoc/>
public bool Equals(IccViewingConditionsTagDataEntry other)
{
if (ReferenceEquals(null, other))
{
return false;
}
if (ReferenceEquals(this, other))
{
return this.IlluminantXyz == entry.IlluminantXyz
&& this.SurroundXyz == entry.SurroundXyz
&& this.Illuminant == entry.Illuminant;
return true;
}
return false;
return base.Equals(other)
&& this.IlluminantXyz.Equals(other.IlluminantXyz)
&& this.SurroundXyz.Equals(other.SurroundXyz)
&& this.Illuminant == other.Illuminant;
}
/// <inheritdoc />
public bool Equals(IccViewingConditionsTagDataEntry other)
/// <inheritdoc/>
public override bool Equals(object obj)
{
return this.Equals((IccTagDataEntry)other);
if (ReferenceEquals(null, obj))
{
return false;
}
if (ReferenceEquals(this, obj))
{
return true;
}
return obj is IccViewingConditionsTagDataEntry && this.Equals((IccViewingConditionsTagDataEntry)obj);
}
/// <inheritdoc/>
public override int GetHashCode()
{
unchecked
{
int hashCode = base.GetHashCode();
hashCode = (hashCode * 397) ^ this.IlluminantXyz.GetHashCode();
hashCode = (hashCode * 397) ^ this.SurroundXyz.GetHashCode();
hashCode = (hashCode * 397) ^ (int)this.Illuminant;
return hashCode;
}
}
}
}

48
src/ImageSharp/MetaData/Profiles/ICC/Various/IccClut.cs

@ -42,7 +42,7 @@ namespace ImageSharp
Guard.NotNull(values, nameof(values));
Guard.NotNull(gridPointCount, nameof(gridPointCount));
const float max = ushort.MaxValue;
const float Max = ushort.MaxValue;
this.Values = new float[values.Length][];
for (int i = 0; i < values.Length; i++)
@ -50,7 +50,7 @@ namespace ImageSharp
this.Values[i] = new float[values[i].Length];
for (int j = 0; j < values[i].Length; j++)
{
this.Values[i][j] = values[i][j] / max;
this.Values[i][j] = values[i][j] / Max;
}
}
@ -71,7 +71,7 @@ namespace ImageSharp
Guard.NotNull(values, nameof(values));
Guard.NotNull(gridPointCount, nameof(gridPointCount));
const float max = byte.MaxValue;
const float Max = byte.MaxValue;
this.Values = new float[values.Length][];
for (int i = 0; i < values.Length; i++)
@ -79,7 +79,7 @@ namespace ImageSharp
this.Values[i] = new float[values[i].Length];
for (int j = 0; j < values[i].Length; j++)
{
this.Values[i][j] = values[i][j] / max;
this.Values[i][j] = values[i][j] / Max;
}
}
@ -118,7 +118,7 @@ namespace ImageSharp
/// <inheritdoc/>
public bool Equals(IccClut other)
{
if (other == null)
if (ReferenceEquals(null, other))
{
return false;
}
@ -128,11 +128,41 @@ namespace ImageSharp
return true;
}
return this.DataType == other.DataType
return this.EqualsValuesArray(other)
&& this.DataType == other.DataType
&& this.InputChannelCount == other.InputChannelCount
&& this.OutputChannelCount == other.OutputChannelCount
&& this.GridPointCount.SequenceEqual(other.GridPointCount)
&& this.EqualsValuesArray(other);
&& this.GridPointCount.SequenceEqual(other.GridPointCount);
}
/// <inheritdoc/>
public override bool Equals(object obj)
{
if (ReferenceEquals(null, obj))
{
return false;
}
if (ReferenceEquals(this, obj))
{
return true;
}
return obj is IccClut && this.Equals((IccClut)obj);
}
/// <inheritdoc/>
public override int GetHashCode()
{
unchecked
{
int hashCode = this.Values != null ? this.Values.GetHashCode() : 0;
hashCode = (hashCode * 397) ^ (int)this.DataType;
hashCode = (hashCode * 397) ^ this.InputChannelCount;
hashCode = (hashCode * 397) ^ this.OutputChannelCount;
hashCode = (hashCode * 397) ^ (this.GridPointCount != null ? this.GridPointCount.GetHashCode() : 0);
return hashCode;
}
}
private bool EqualsValuesArray(IccClut other)
@ -172,4 +202,4 @@ namespace ImageSharp
Guard.IsTrue(this.Values.Length == length, nameof(this.Values), "Length of values array does not match the grid points");
}
}
}
}

38
src/ImageSharp/MetaData/Profiles/ICC/Various/IccProfileDescription.cs

@ -71,9 +71,14 @@ namespace ImageSharp
/// </summary>
public IccLocalizedString[] DeviceModelInfo { get; }
/// <inheritdoc />
/// <inheritdoc/>
public bool Equals(IccProfileDescription other)
{
if (ReferenceEquals(null, other))
{
return false;
}
if (ReferenceEquals(this, other))
{
return true;
@ -86,5 +91,36 @@ namespace ImageSharp
&& this.DeviceManufacturerInfo.SequenceEqual(other.DeviceManufacturerInfo)
&& this.DeviceModelInfo.SequenceEqual(other.DeviceModelInfo);
}
/// <inheritdoc />
public override bool Equals(object obj)
{
if (ReferenceEquals(null, obj))
{
return false;
}
if (ReferenceEquals(this, obj))
{
return true;
}
return obj is IccProfileDescription && this.Equals((IccProfileDescription)obj);
}
/// <inheritdoc />
public override int GetHashCode()
{
unchecked
{
int hashCode = (int)this.DeviceManufacturer;
hashCode = (hashCode * 397) ^ (int)this.DeviceModel;
hashCode = (hashCode * 397) ^ this.DeviceAttributes.GetHashCode();
hashCode = (hashCode * 397) ^ (int)this.TechnologyInformation;
hashCode = (hashCode * 397) ^ (this.DeviceManufacturerInfo != null ? this.DeviceManufacturerInfo.GetHashCode() : 0);
hashCode = (hashCode * 397) ^ (this.DeviceModelInfo != null ? this.DeviceModelInfo.GetHashCode() : 0);
return hashCode;
}
}
}
}

33
src/ImageSharp/MetaData/Profiles/ICC/Various/IccProfileSequenceIdentifier.cs

@ -39,13 +39,42 @@ namespace ImageSharp
/// <inheritdoc />
public bool Equals(IccProfileSequenceIdentifier other)
{
if (ReferenceEquals(null, other))
{
return false;
}
if (ReferenceEquals(this, other))
{
return true;
}
return this.Id.Equals(other.Id)
&& this.Description.SequenceEqual(other.Description);
return this.Id.Equals(other.Id) && this.Description.SequenceEqual(other.Description);
}
/// <inheritdoc />
public override bool Equals(object obj)
{
if (ReferenceEquals(null, obj))
{
return false;
}
if (ReferenceEquals(this, obj))
{
return true;
}
return obj is IccProfileSequenceIdentifier && this.Equals((IccProfileSequenceIdentifier)obj);
}
/// <inheritdoc />
public override int GetHashCode()
{
unchecked
{
return (this.Id.GetHashCode() * 397) ^ (this.Description != null ? this.Description.GetHashCode() : 0);
}
}
}
}

18
src/ImageSharp/MetaData/Profiles/ICC/Various/IccScreeningChannel.cs

@ -70,18 +70,18 @@ namespace ImageSharp
return !left.Equals(right);
}
/// <inheritdoc/>
public override bool Equals(object other)
/// <inheritdoc />
public bool Equals(IccScreeningChannel other)
{
return (other is IccScreeningChannel) && this.Equals((IccScreeningChannel)other);
return this.Frequency.Equals(other.Frequency)
&& this.Angle.Equals(other.Angle)
&& this.SpotShape == other.SpotShape;
}
/// <inheritdoc/>
public bool Equals(IccScreeningChannel other)
public override bool Equals(object obj)
{
return this.Frequency == other.Frequency
&& this.Angle == other.Angle
&& this.SpotShape == other.SpotShape;
return obj is IccScreeningChannel && this.Equals((IccScreeningChannel)obj);
}
/// <inheritdoc/>
@ -91,7 +91,7 @@ namespace ImageSharp
{
int hashCode = this.Frequency.GetHashCode();
hashCode = (hashCode * 397) ^ this.Angle.GetHashCode();
hashCode = (hashCode * 397) ^ this.SpotShape.GetHashCode();
hashCode = (hashCode * 397) ^ (int)this.SpotShape;
return hashCode;
}
}
@ -102,4 +102,4 @@ namespace ImageSharp
return $"{this.Frequency}Hz; {this.Angle}°; {this.SpotShape}";
}
}
}
}
Loading…
Cancel
Save