Browse Source

Merge branch 'master' into ifc-docs

af/merge-core
James Jackson-South 8 years ago
committed by GitHub
parent
commit
a9bc664097
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      src/ImageSharp/ColorSpaces/CieLch.cs
  2. 2
      src/ImageSharp/ColorSpaces/CieLchuv.cs
  3. 2
      src/ImageSharp/ColorSpaces/CieLuv.cs
  4. 2
      src/ImageSharp/ColorSpaces/CieXyChromaticityCoordinates.cs
  5. 2
      src/ImageSharp/ColorSpaces/CieXyy.cs
  6. 2
      src/ImageSharp/ColorSpaces/CieXyz.cs
  7. 2
      src/ImageSharp/ColorSpaces/Cmyk.cs
  8. 21
      src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.CieLab.cs
  9. 24
      src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.CieLch.cs
  10. 26
      src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.CieLchuv.cs
  11. 26
      src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.CieLuv.cs
  12. 27
      src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.Cmyk.cs
  13. 27
      src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.Hsl.cs
  14. 26
      src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.HunterLab.cs
  15. 24
      src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.LinearRgb.cs
  16. 27
      src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.Lms.cs
  17. 24
      src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.Rgb.cs
  18. 27
      src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.YCbCr.cs
  19. 1
      src/ImageSharp/ColorSpaces/Conversion/Implementation/CieXyy/CieXyzAndCieXyyConverter.cs
  20. 1
      src/ImageSharp/ColorSpaces/Conversion/Implementation/Cmyk/CmykAndRgbConverter.cs
  21. 1
      src/ImageSharp/ColorSpaces/Conversion/Implementation/Hsl/HslAndRgbConverter.cs
  22. 1
      src/ImageSharp/ColorSpaces/Conversion/Implementation/Hsv/HsvAndRgbConverter.cs
  23. 2
      src/ImageSharp/ColorSpaces/Conversion/Implementation/HunterLab/CieXyzAndHunterLabConverterBase.cs
  24. 1
      src/ImageSharp/ColorSpaces/Conversion/Implementation/HunterLab/CieXyzToHunterLabConverter.cs
  25. 3
      src/ImageSharp/ColorSpaces/Conversion/Implementation/HunterLab/HunterLabToCieXyzConverter.cs
  26. 5
      src/ImageSharp/ColorSpaces/Conversion/Implementation/Lms/CieXyzAndLmsConverter.cs
  27. 2
      src/ImageSharp/ColorSpaces/Conversion/Implementation/Rgb/LCompanding.cs
  28. 5
      src/ImageSharp/ColorSpaces/Conversion/Implementation/Rgb/LinearRgbAndCieXyzConverterBase.cs
  29. 2
      src/ImageSharp/ColorSpaces/Conversion/Implementation/Rgb/RgbToLinearRgbConverter.cs
  30. 1
      src/ImageSharp/ColorSpaces/Conversion/Implementation/YCbCr/YCbCrAndRgbConverter.cs
  31. 5
      src/ImageSharp/ColorSpaces/Conversion/VonKriesChromaticAdaptation.cs
  32. 2
      src/ImageSharp/ColorSpaces/Hsl.cs
  33. 2
      src/ImageSharp/ColorSpaces/Hsv.cs
  34. 2
      src/ImageSharp/ColorSpaces/HunterLab.cs
  35. 2
      src/ImageSharp/ColorSpaces/LinearRgb.cs
  36. 2
      src/ImageSharp/ColorSpaces/Lms.cs
  37. 2
      src/ImageSharp/ColorSpaces/Rgb.cs
  38. 2
      src/ImageSharp/ColorSpaces/YCbCr.cs
  39. 7
      src/ImageSharp/Common/Exceptions/ImageFormatException.cs
  40. 9
      src/ImageSharp/Common/Exceptions/ImageProcessingException.cs
  41. 2
      src/ImageSharp/Common/Helpers/ImageMaths.cs
  42. 2
      src/ImageSharp/MetaData/Profiles/ICC/Curves/IccFormulaCurveElement.cs
  43. 2
      src/ImageSharp/MetaData/Profiles/ICC/Curves/IccOneDimensionalCurve.cs
  44. 4
      src/ImageSharp/MetaData/Profiles/ICC/Curves/IccParametricCurve.cs
  45. 8
      src/ImageSharp/MetaData/Profiles/ICC/Curves/IccResponseCurve.cs
  46. 2
      src/ImageSharp/MetaData/Profiles/ICC/DataReader/IccDataReader.Curves.cs
  47. 31
      src/ImageSharp/MetaData/Profiles/ICC/DataReader/IccDataReader.Primitives.cs
  48. 34
      src/ImageSharp/MetaData/Profiles/ICC/DataReader/IccDataReader.TagDataEntry.cs
  49. 18
      src/ImageSharp/MetaData/Profiles/ICC/DataWriter/IccDataWriter.TagDataEntry.cs
  50. 9
      src/ImageSharp/MetaData/Profiles/ICC/Exceptions/InvalidIccProfileException.cs
  51. 4
      src/ImageSharp/MetaData/Profiles/ICC/IccReader.cs
  52. 7
      src/ImageSharp/MetaData/Profiles/ICC/IccTagDataEntry.cs
  53. 2
      src/ImageSharp/MetaData/Profiles/ICC/MultiProcessElements/IccCurveSetProcessElement.cs
  54. 4
      src/ImageSharp/MetaData/Profiles/ICC/MultiProcessElements/IccMultiProcessElement.cs
  55. 7
      src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccChromaticityTagDataEntry.cs
  56. 11
      src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccColorantOrderTagDataEntry.cs
  57. 11
      src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccColorantTableTagDataEntry.cs
  58. 19
      src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccCrdInfoTagDataEntry.cs
  59. 15
      src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccCurveTagDataEntry.cs
  60. 11
      src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccDataTagDataEntry.cs
  61. 7
      src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccDateTimeTagDataEntry.cs
  62. 11
      src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccFix16ArrayTagDataEntry.cs
  63. 13
      src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccLut16TagDataEntry.cs
  64. 13
      src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccLut8TagDataEntry.cs
  65. 17
      src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccLutAToBTagDataEntry.cs
  66. 17
      src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccLutBToATagDataEntry.cs
  67. 5
      src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccMeasurementTagDataEntry.cs
  68. 9
      src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccMultiLocalizedUnicodeTagDataEntry.cs
  69. 6
      src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccMultiProcessElementsTagDataEntry.cs
  70. 11
      src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccNamedColor2TagDataEntry.cs
  71. 7
      src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccParametricCurveTagDataEntry.cs
  72. 9
      src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccProfileSequenceDescTagDataEntry.cs
  73. 7
      src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccProfileSequenceIdentifierTagDataEntry.cs
  74. 5
      src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccResponseCurveSet16TagDataEntry.cs
  75. 7
      src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccScreeningTagDataEntry.cs
  76. 7
      src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccSignatureTagDataEntry.cs
  77. 11
      src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccTextDescriptionTagDataEntry.cs
  78. 7
      src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccTextTagDataEntry.cs
  79. 11
      src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUFix16ArrayTagDataEntry.cs
  80. 7
      src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUInt16ArrayTagDataEntry.cs
  81. 9
      src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUInt32ArrayTagDataEntry.cs
  82. 9
      src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUInt64ArrayTagDataEntry.cs
  83. 13
      src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUInt8ArrayTagDataEntry.cs
  84. 15
      src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUcrBgTagDataEntry.cs
  85. 13
      src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUnknownTagDataEntry.cs
  86. 9
      src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccViewingConditionsTagDataEntry.cs
  87. 14
      src/ImageSharp/MetaData/Profiles/ICC/Various/IccClut.cs
  88. 4
      src/ImageSharp/MetaData/Profiles/ICC/Various/IccColorantTableEntry.cs
  89. 25
      src/ImageSharp/MetaData/Profiles/ICC/Various/IccLocalizedString.cs
  90. 15
      src/ImageSharp/MetaData/Profiles/ICC/Various/IccLut.cs
  91. 14
      src/ImageSharp/MetaData/Profiles/ICC/Various/IccNamedColor.cs
  92. 12
      src/ImageSharp/MetaData/Profiles/ICC/Various/IccPositionNumber.cs
  93. 58
      src/ImageSharp/MetaData/Profiles/ICC/Various/IccProfileDescription.cs
  94. 16
      src/ImageSharp/MetaData/Profiles/ICC/Various/IccProfileId.cs
  95. 41
      src/ImageSharp/MetaData/Profiles/ICC/Various/IccProfileSequenceIdentifier.cs
  96. 12
      src/ImageSharp/MetaData/Profiles/ICC/Various/IccResponseNumber.cs
  97. 10
      src/ImageSharp/MetaData/Profiles/ICC/Various/IccScreeningChannel.cs
  98. 14
      src/ImageSharp/MetaData/Profiles/ICC/Various/IccTagTableEntry.cs
  99. 24
      src/ImageSharp/PixelFormats/Alpha8.cs
  100. 238
      src/ImageSharp/PixelFormats/Argb32.cs

2
src/ImageSharp/ColorSpaces/CieLch.cs

@ -23,7 +23,7 @@ namespace SixLabors.ImageSharp.ColorSpaces
/// <summary> /// <summary>
/// Represents a <see cref="CieLch"/> that has L, C, H values set to zero. /// Represents a <see cref="CieLch"/> that has L, C, H values set to zero.
/// </summary> /// </summary>
public static readonly CieLch Empty = default(CieLch); public static readonly CieLch Empty = default;
/// <summary> /// <summary>
/// The backing vector for SIMD support. /// The backing vector for SIMD support.

2
src/ImageSharp/ColorSpaces/CieLchuv.cs

@ -23,7 +23,7 @@ namespace SixLabors.ImageSharp.ColorSpaces
/// <summary> /// <summary>
/// Represents a <see cref="CieLchuv"/> that has L, C, H values set to zero. /// Represents a <see cref="CieLchuv"/> that has L, C, H values set to zero.
/// </summary> /// </summary>
public static readonly CieLchuv Empty = default(CieLchuv); public static readonly CieLchuv Empty = default;
/// <summary> /// <summary>
/// The backing vector for SIMD support. /// The backing vector for SIMD support.

2
src/ImageSharp/ColorSpaces/CieLuv.cs

@ -25,7 +25,7 @@ namespace SixLabors.ImageSharp.ColorSpaces
/// <summary> /// <summary>
/// Represents a <see cref="CieLuv"/> that has L, U, and V values set to zero. /// Represents a <see cref="CieLuv"/> that has L, U, and V values set to zero.
/// </summary> /// </summary>
public static readonly CieLuv Empty = default(CieLuv); public static readonly CieLuv Empty = default;
/// <summary> /// <summary>
/// The backing vector for SIMD support. /// The backing vector for SIMD support.

2
src/ImageSharp/ColorSpaces/CieXyChromaticityCoordinates.cs

@ -17,7 +17,7 @@ namespace SixLabors.ImageSharp.ColorSpaces
/// <summary> /// <summary>
/// Represents a <see cref="CieXyChromaticityCoordinates"/> that has X, Y values set to zero. /// Represents a <see cref="CieXyChromaticityCoordinates"/> that has X, Y values set to zero.
/// </summary> /// </summary>
public static readonly CieXyChromaticityCoordinates Empty = default(CieXyChromaticityCoordinates); public static readonly CieXyChromaticityCoordinates Empty = default;
/// <summary> /// <summary>
/// The backing vector for SIMD support. /// The backing vector for SIMD support.

2
src/ImageSharp/ColorSpaces/CieXyy.cs

@ -17,7 +17,7 @@ namespace SixLabors.ImageSharp.ColorSpaces
/// <summary> /// <summary>
/// Represents a <see cref="CieXyy"/> that has X, Y, and Y values set to zero. /// Represents a <see cref="CieXyy"/> that has X, Y, and Y values set to zero.
/// </summary> /// </summary>
public static readonly CieXyy Empty = default(CieXyy); public static readonly CieXyy Empty = default;
/// <summary> /// <summary>
/// The backing vector for SIMD support. /// The backing vector for SIMD support.

2
src/ImageSharp/ColorSpaces/CieXyz.cs

@ -17,7 +17,7 @@ namespace SixLabors.ImageSharp.ColorSpaces
/// <summary> /// <summary>
/// Represents a <see cref="CieXyz"/> that has X, Y, and Z values set to zero. /// Represents a <see cref="CieXyz"/> that has X, Y, and Z values set to zero.
/// </summary> /// </summary>
public static readonly CieXyz Empty = default(CieXyz); public static readonly CieXyz Empty = default;
/// <summary> /// <summary>
/// The backing vector for SIMD support. /// The backing vector for SIMD support.

2
src/ImageSharp/ColorSpaces/Cmyk.cs

@ -16,7 +16,7 @@ namespace SixLabors.ImageSharp.ColorSpaces
/// <summary> /// <summary>
/// Represents a <see cref="Cmyk"/> that has C, M, Y, and K values set to zero. /// Represents a <see cref="Cmyk"/> that has C, M, Y, and K values set to zero.
/// </summary> /// </summary>
public static readonly Cmyk Empty = default(Cmyk); public static readonly Cmyk Empty = default;
/// <summary> /// <summary>
/// The backing vector for SIMD support. /// The backing vector for SIMD support.

21
src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.CieLab.cs

@ -1,7 +1,6 @@
// Copyright (c) Six Labors and contributors. // Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0. // Licensed under the Apache License, Version 2.0.
using SixLabors.ImageSharp.ColorSpaces;
using SixLabors.ImageSharp.ColorSpaces.Conversion.Implementation.CieLabColorSapce; using SixLabors.ImageSharp.ColorSpaces.Conversion.Implementation.CieLabColorSapce;
using SixLabors.ImageSharp.ColorSpaces.Conversion.Implementation.CieLchColorSapce; using SixLabors.ImageSharp.ColorSpaces.Conversion.Implementation.CieLchColorSapce;
@ -45,8 +44,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// <returns>The <see cref="CieLab"/></returns> /// <returns>The <see cref="CieLab"/></returns>
public CieLab ToCieLab(CieLchuv color) public CieLab ToCieLab(CieLchuv color)
{ {
Guard.NotNull(color, nameof(color));
CieXyz xyzColor = this.ToCieXyz(color); CieXyz xyzColor = this.ToCieXyz(color);
return this.ToCieLab(xyzColor); return this.ToCieLab(xyzColor);
} }
@ -58,8 +55,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// <returns>The <see cref="CieLab"/></returns> /// <returns>The <see cref="CieLab"/></returns>
public CieLab ToCieLab(CieLuv color) public CieLab ToCieLab(CieLuv color)
{ {
Guard.NotNull(color, nameof(color));
CieXyz xyzColor = this.ToCieXyz(color); CieXyz xyzColor = this.ToCieXyz(color);
return this.ToCieLab(xyzColor); return this.ToCieLab(xyzColor);
} }
@ -71,8 +66,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// <returns>The <see cref="CieLab"/></returns> /// <returns>The <see cref="CieLab"/></returns>
public CieLab ToCieLab(CieXyy color) public CieLab ToCieLab(CieXyy color)
{ {
Guard.NotNull(color, nameof(color));
CieXyz xyzColor = this.ToCieXyz(color); CieXyz xyzColor = this.ToCieXyz(color);
return this.ToCieLab(xyzColor); return this.ToCieLab(xyzColor);
} }
@ -92,7 +85,7 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
: color; : color;
// Conversion // Conversion
CieXyzToCieLabConverter converter = new CieXyzToCieLabConverter(this.TargetLabWhitePoint); var converter = new CieXyzToCieLabConverter(this.TargetLabWhitePoint);
return converter.Convert(adapted); return converter.Convert(adapted);
} }
@ -116,8 +109,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// <returns>The <see cref="CieLab"/></returns> /// <returns>The <see cref="CieLab"/></returns>
public CieLab ToCieLab(Hsl color) public CieLab ToCieLab(Hsl color)
{ {
Guard.NotNull(color, nameof(color));
CieXyz xyzColor = this.ToCieXyz(color); CieXyz xyzColor = this.ToCieXyz(color);
return this.ToCieLab(xyzColor); return this.ToCieLab(xyzColor);
} }
@ -142,8 +133,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// <returns>The <see cref="CieLab"/></returns> /// <returns>The <see cref="CieLab"/></returns>
public CieLab ToCieLab(HunterLab color) public CieLab ToCieLab(HunterLab color)
{ {
Guard.NotNull(color, nameof(color));
CieXyz xyzColor = this.ToCieXyz(color); CieXyz xyzColor = this.ToCieXyz(color);
return this.ToCieLab(xyzColor); return this.ToCieLab(xyzColor);
} }
@ -155,8 +144,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// <returns>The <see cref="CieLab"/></returns> /// <returns>The <see cref="CieLab"/></returns>
public CieLab ToCieLab(Lms color) public CieLab ToCieLab(Lms color)
{ {
Guard.NotNull(color, nameof(color));
CieXyz xyzColor = this.ToCieXyz(color); CieXyz xyzColor = this.ToCieXyz(color);
return this.ToCieLab(xyzColor); return this.ToCieLab(xyzColor);
} }
@ -168,8 +155,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// <returns>The <see cref="CieLab"/></returns> /// <returns>The <see cref="CieLab"/></returns>
public CieLab ToCieLab(LinearRgb color) public CieLab ToCieLab(LinearRgb color)
{ {
Guard.NotNull(color, nameof(color));
CieXyz xyzColor = this.ToCieXyz(color); CieXyz xyzColor = this.ToCieXyz(color);
return this.ToCieLab(xyzColor); return this.ToCieLab(xyzColor);
} }
@ -181,8 +166,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// <returns>The <see cref="CieLab"/></returns> /// <returns>The <see cref="CieLab"/></returns>
public CieLab ToCieLab(Rgb color) public CieLab ToCieLab(Rgb color)
{ {
Guard.NotNull(color, nameof(color));
CieXyz xyzColor = this.ToCieXyz(color); CieXyz xyzColor = this.ToCieXyz(color);
return this.ToCieLab(xyzColor); return this.ToCieLab(xyzColor);
} }
@ -194,8 +177,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// <returns>The <see cref="CieLab"/></returns> /// <returns>The <see cref="CieLab"/></returns>
public CieLab ToCieLab(YCbCr color) public CieLab ToCieLab(YCbCr color)
{ {
Guard.NotNull(color, nameof(color));
CieXyz xyzColor = this.ToCieXyz(color); CieXyz xyzColor = this.ToCieXyz(color);
return this.ToCieLab(xyzColor); return this.ToCieLab(xyzColor);
} }

24
src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.CieLch.cs

@ -22,8 +22,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// <returns>The <see cref="CieLch"/></returns> /// <returns>The <see cref="CieLch"/></returns>
public CieLch ToCieLch(CieLab color) public CieLch ToCieLch(CieLab color)
{ {
Guard.NotNull(color, nameof(color));
// Adaptation // Adaptation
CieLab adapted = this.IsChromaticAdaptationPerformed ? this.Adapt(color) : color; CieLab adapted = this.IsChromaticAdaptationPerformed ? this.Adapt(color) : color;
@ -38,8 +36,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// <returns>The <see cref="CieLch"/></returns> /// <returns>The <see cref="CieLch"/></returns>
public CieLch ToCieLch(CieLchuv color) public CieLch ToCieLch(CieLchuv color)
{ {
Guard.NotNull(color, nameof(color));
CieXyz xyzColor = this.ToCieXyz(color); CieXyz xyzColor = this.ToCieXyz(color);
return this.ToCieLch(xyzColor); return this.ToCieLch(xyzColor);
} }
@ -51,8 +47,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// <returns>The <see cref="CieLch"/></returns> /// <returns>The <see cref="CieLch"/></returns>
public CieLch ToCieLch(CieLuv color) public CieLch ToCieLch(CieLuv color)
{ {
Guard.NotNull(color, nameof(color));
CieXyz xyzColor = this.ToCieXyz(color); CieXyz xyzColor = this.ToCieXyz(color);
return this.ToCieLch(xyzColor); return this.ToCieLch(xyzColor);
} }
@ -64,8 +58,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// <returns>The <see cref="CieLch"/></returns> /// <returns>The <see cref="CieLch"/></returns>
public CieLch ToCieLch(CieXyy color) public CieLch ToCieLch(CieXyy color)
{ {
Guard.NotNull(color, nameof(color));
CieXyz xyzColor = this.ToCieXyz(color); CieXyz xyzColor = this.ToCieXyz(color);
return this.ToCieLch(xyzColor); return this.ToCieLch(xyzColor);
} }
@ -77,8 +69,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// <returns>The <see cref="CieLch"/></returns> /// <returns>The <see cref="CieLch"/></returns>
public CieLch ToCieLch(CieXyz color) public CieLch ToCieLch(CieXyz color)
{ {
Guard.NotNull(color, nameof(color));
CieLab labColor = this.ToCieLab(color); CieLab labColor = this.ToCieLab(color);
return this.ToCieLch(labColor); return this.ToCieLch(labColor);
} }
@ -103,8 +93,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// <returns>The <see cref="CieLch"/></returns> /// <returns>The <see cref="CieLch"/></returns>
public CieLch ToCieLch(Hsl color) public CieLch ToCieLch(Hsl color)
{ {
Guard.NotNull(color, nameof(color));
CieXyz xyzColor = this.ToCieXyz(color); CieXyz xyzColor = this.ToCieXyz(color);
return this.ToCieLch(xyzColor); return this.ToCieLch(xyzColor);
} }
@ -116,8 +104,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// <returns>The <see cref="CieLch"/></returns> /// <returns>The <see cref="CieLch"/></returns>
public CieLch ToCieLch(Hsv color) public CieLch ToCieLch(Hsv color)
{ {
Guard.NotNull(color, nameof(color));
CieXyz xyzColor = this.ToCieXyz(color); CieXyz xyzColor = this.ToCieXyz(color);
return this.ToCieLch(xyzColor); return this.ToCieLch(xyzColor);
} }
@ -129,8 +115,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// <returns>The <see cref="CieLch"/></returns> /// <returns>The <see cref="CieLch"/></returns>
public CieLch ToCieLch(HunterLab color) public CieLch ToCieLch(HunterLab color)
{ {
Guard.NotNull(color, nameof(color));
CieXyz xyzColor = this.ToCieXyz(color); CieXyz xyzColor = this.ToCieXyz(color);
return this.ToCieLch(xyzColor); return this.ToCieLch(xyzColor);
} }
@ -142,8 +126,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// <returns>The <see cref="CieLch"/></returns> /// <returns>The <see cref="CieLch"/></returns>
public CieLch ToCieLch(LinearRgb color) public CieLch ToCieLch(LinearRgb color)
{ {
Guard.NotNull(color, nameof(color));
CieXyz xyzColor = this.ToCieXyz(color); CieXyz xyzColor = this.ToCieXyz(color);
return this.ToCieLch(xyzColor); return this.ToCieLch(xyzColor);
} }
@ -155,8 +137,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// <returns>The <see cref="CieLch"/></returns> /// <returns>The <see cref="CieLch"/></returns>
public CieLch ToCieLch(Lms color) public CieLch ToCieLch(Lms color)
{ {
Guard.NotNull(color, nameof(color));
CieXyz xyzColor = this.ToCieXyz(color); CieXyz xyzColor = this.ToCieXyz(color);
return this.ToCieLch(xyzColor); return this.ToCieLch(xyzColor);
} }
@ -168,8 +148,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// <returns>The <see cref="CieLch"/></returns> /// <returns>The <see cref="CieLch"/></returns>
public CieLch ToCieLch(Rgb color) public CieLch ToCieLch(Rgb color)
{ {
Guard.NotNull(color, nameof(color));
CieXyz xyzColor = this.ToCieXyz(color); CieXyz xyzColor = this.ToCieXyz(color);
return this.ToCieLch(xyzColor); return this.ToCieLch(xyzColor);
} }
@ -181,8 +159,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// <returns>The <see cref="CieLch"/></returns> /// <returns>The <see cref="CieLch"/></returns>
public CieLch ToCieLch(YCbCr color) public CieLch ToCieLch(YCbCr color)
{ {
Guard.NotNull(color, nameof(color));
CieXyz xyzColor = this.ToCieXyz(color); CieXyz xyzColor = this.ToCieXyz(color);
return this.ToCieLch(xyzColor); return this.ToCieLch(xyzColor);
} }

26
src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.CieLchuv.cs

@ -22,8 +22,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// <returns>The <see cref="CieLchuv"/></returns> /// <returns>The <see cref="CieLchuv"/></returns>
public CieLchuv ToCieLchuv(CieLab color) public CieLchuv ToCieLchuv(CieLab color)
{ {
Guard.NotNull(color, nameof(color));
CieXyz xyzColor = this.ToCieXyz(color); CieXyz xyzColor = this.ToCieXyz(color);
return this.ToCieLchuv(xyzColor); return this.ToCieLchuv(xyzColor);
} }
@ -35,8 +33,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// <returns>The <see cref="CieLchuv"/></returns> /// <returns>The <see cref="CieLchuv"/></returns>
public CieLchuv ToCieLchuv(CieLch color) public CieLchuv ToCieLchuv(CieLch color)
{ {
Guard.NotNull(color, nameof(color));
CieXyz xyzColor = this.ToCieXyz(color); CieXyz xyzColor = this.ToCieXyz(color);
return this.ToCieLchuv(xyzColor); return this.ToCieLchuv(xyzColor);
} }
@ -48,8 +44,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// <returns>The <see cref="CieLchuv"/></returns> /// <returns>The <see cref="CieLchuv"/></returns>
public CieLchuv ToCieLchuv(CieLuv color) public CieLchuv ToCieLchuv(CieLuv color)
{ {
Guard.NotNull(color, nameof(color));
// Adaptation // Adaptation
CieLuv adapted = this.IsChromaticAdaptationPerformed ? this.Adapt(color) : color; CieLuv adapted = this.IsChromaticAdaptationPerformed ? this.Adapt(color) : color;
@ -64,8 +58,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// <returns>The <see cref="CieLchuv"/></returns> /// <returns>The <see cref="CieLchuv"/></returns>
public CieLchuv ToCieLchuv(CieXyy color) public CieLchuv ToCieLchuv(CieXyy color)
{ {
Guard.NotNull(color, nameof(color));
CieXyz xyzColor = this.ToCieXyz(color); CieXyz xyzColor = this.ToCieXyz(color);
return this.ToCieLchuv(xyzColor); return this.ToCieLchuv(xyzColor);
} }
@ -77,8 +69,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// <returns>The <see cref="CieLchuv"/></returns> /// <returns>The <see cref="CieLchuv"/></returns>
public CieLchuv ToCieLchuv(CieXyz color) public CieLchuv ToCieLchuv(CieXyz color)
{ {
Guard.NotNull(color, nameof(color));
CieLab labColor = this.ToCieLab(color); CieLab labColor = this.ToCieLab(color);
return this.ToCieLchuv(labColor); return this.ToCieLchuv(labColor);
} }
@ -90,8 +80,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// <returns>The <see cref="CieLchuv"/></returns> /// <returns>The <see cref="CieLchuv"/></returns>
public CieLchuv ToCieLchuv(Cmyk color) public CieLchuv ToCieLchuv(Cmyk color)
{ {
Guard.NotNull(color, nameof(color));
CieXyz xyzColor = this.ToCieXyz(color); CieXyz xyzColor = this.ToCieXyz(color);
return this.ToCieLchuv(xyzColor); return this.ToCieLchuv(xyzColor);
} }
@ -103,8 +91,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// <returns>The <see cref="CieLchuv"/></returns> /// <returns>The <see cref="CieLchuv"/></returns>
public CieLchuv ToCieLchuv(Hsl color) public CieLchuv ToCieLchuv(Hsl color)
{ {
Guard.NotNull(color, nameof(color));
CieXyz xyzColor = this.ToCieXyz(color); CieXyz xyzColor = this.ToCieXyz(color);
return this.ToCieLchuv(xyzColor); return this.ToCieLchuv(xyzColor);
} }
@ -116,8 +102,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// <returns>The <see cref="CieLchuv"/></returns> /// <returns>The <see cref="CieLchuv"/></returns>
public CieLchuv ToCieLchuv(Hsv color) public CieLchuv ToCieLchuv(Hsv color)
{ {
Guard.NotNull(color, nameof(color));
CieXyz xyzColor = this.ToCieXyz(color); CieXyz xyzColor = this.ToCieXyz(color);
return this.ToCieLchuv(xyzColor); return this.ToCieLchuv(xyzColor);
} }
@ -129,8 +113,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// <returns>The <see cref="CieLchuv"/></returns> /// <returns>The <see cref="CieLchuv"/></returns>
public CieLchuv ToCieLchuv(HunterLab color) public CieLchuv ToCieLchuv(HunterLab color)
{ {
Guard.NotNull(color, nameof(color));
CieXyz xyzColor = this.ToCieXyz(color); CieXyz xyzColor = this.ToCieXyz(color);
return this.ToCieLchuv(xyzColor); return this.ToCieLchuv(xyzColor);
} }
@ -142,8 +124,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// <returns>The <see cref="CieLchuv"/></returns> /// <returns>The <see cref="CieLchuv"/></returns>
public CieLchuv ToCieLchuv(LinearRgb color) public CieLchuv ToCieLchuv(LinearRgb color)
{ {
Guard.NotNull(color, nameof(color));
CieXyz xyzColor = this.ToCieXyz(color); CieXyz xyzColor = this.ToCieXyz(color);
return this.ToCieLchuv(xyzColor); return this.ToCieLchuv(xyzColor);
} }
@ -155,8 +135,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// <returns>The <see cref="CieLchuv"/></returns> /// <returns>The <see cref="CieLchuv"/></returns>
public CieLchuv ToCieLchuv(Lms color) public CieLchuv ToCieLchuv(Lms color)
{ {
Guard.NotNull(color, nameof(color));
CieXyz xyzColor = this.ToCieXyz(color); CieXyz xyzColor = this.ToCieXyz(color);
return this.ToCieLchuv(xyzColor); return this.ToCieLchuv(xyzColor);
} }
@ -168,8 +146,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// <returns>The <see cref="CieLchuv"/></returns> /// <returns>The <see cref="CieLchuv"/></returns>
public CieLchuv ToCieLchuv(Rgb color) public CieLchuv ToCieLchuv(Rgb color)
{ {
Guard.NotNull(color, nameof(color));
CieXyz xyzColor = this.ToCieXyz(color); CieXyz xyzColor = this.ToCieXyz(color);
return this.ToCieLchuv(xyzColor); return this.ToCieLchuv(xyzColor);
} }
@ -181,8 +157,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// <returns>The <see cref="CieLchuv"/></returns> /// <returns>The <see cref="CieLchuv"/></returns>
public CieLchuv ToCieLchuv(YCbCr color) public CieLchuv ToCieLchuv(YCbCr color)
{ {
Guard.NotNull(color, nameof(color));
CieXyz xyzColor = this.ToCieXyz(color); CieXyz xyzColor = this.ToCieXyz(color);
return this.ToCieLchuv(xyzColor); return this.ToCieLchuv(xyzColor);
} }

26
src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.CieLuv.cs

@ -21,8 +21,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// <returns>The <see cref="CieLuv"/></returns> /// <returns>The <see cref="CieLuv"/></returns>
public CieLuv ToCieLuv(CieLab color) public CieLuv ToCieLuv(CieLab color)
{ {
Guard.NotNull(color, nameof(color));
var xyzColor = this.ToCieXyz(color); var xyzColor = this.ToCieXyz(color);
return this.ToCieLuv(xyzColor); return this.ToCieLuv(xyzColor);
} }
@ -34,8 +32,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// <returns>The <see cref="CieLuv"/></returns> /// <returns>The <see cref="CieLuv"/></returns>
public CieLuv ToCieLuv(CieLch color) public CieLuv ToCieLuv(CieLch color)
{ {
Guard.NotNull(color, nameof(color));
var xyzColor = this.ToCieXyz(color); var xyzColor = this.ToCieXyz(color);
return this.ToCieLuv(xyzColor); return this.ToCieLuv(xyzColor);
} }
@ -47,8 +43,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// <returns>The <see cref="CieLab"/></returns> /// <returns>The <see cref="CieLab"/></returns>
public CieLuv ToCieLuv(CieLchuv color) public CieLuv ToCieLuv(CieLchuv color)
{ {
Guard.NotNull(color, nameof(color));
// Conversion (perserving white point) // Conversion (perserving white point)
CieLuv unadapted = CieLchuvToCieLuvConverter.Convert(color); CieLuv unadapted = CieLchuvToCieLuvConverter.Convert(color);
@ -68,8 +62,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// <returns>The <see cref="CieLuv"/></returns> /// <returns>The <see cref="CieLuv"/></returns>
public CieLuv ToCieLuv(CieXyy color) public CieLuv ToCieLuv(CieXyy color)
{ {
Guard.NotNull(color, nameof(color));
var xyzColor = this.ToCieXyz(color); var xyzColor = this.ToCieXyz(color);
return this.ToCieLuv(xyzColor); return this.ToCieLuv(xyzColor);
} }
@ -81,8 +73,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// <returns>The <see cref="CieLuv"/></returns> /// <returns>The <see cref="CieLuv"/></returns>
public CieLuv ToCieLuv(CieXyz color) public CieLuv ToCieLuv(CieXyz color)
{ {
Guard.NotNull(color, nameof(color));
// Adaptation // Adaptation
CieXyz adapted = !this.WhitePoint.Equals(this.TargetLabWhitePoint) && this.IsChromaticAdaptationPerformed CieXyz adapted = !this.WhitePoint.Equals(this.TargetLabWhitePoint) && this.IsChromaticAdaptationPerformed
? this.ChromaticAdaptation.Transform(color, this.WhitePoint, this.TargetLabWhitePoint) ? this.ChromaticAdaptation.Transform(color, this.WhitePoint, this.TargetLabWhitePoint)
@ -100,8 +90,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// <returns>The <see cref="CieLuv"/></returns> /// <returns>The <see cref="CieLuv"/></returns>
public CieLuv ToCieLuv(Cmyk color) public CieLuv ToCieLuv(Cmyk color)
{ {
Guard.NotNull(color, nameof(color));
var xyzColor = this.ToCieXyz(color); var xyzColor = this.ToCieXyz(color);
return this.ToCieLuv(xyzColor); return this.ToCieLuv(xyzColor);
} }
@ -113,8 +101,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// <returns>The <see cref="CieLuv"/></returns> /// <returns>The <see cref="CieLuv"/></returns>
public CieLuv ToCieLuv(Hsl color) public CieLuv ToCieLuv(Hsl color)
{ {
Guard.NotNull(color, nameof(color));
var xyzColor = this.ToCieXyz(color); var xyzColor = this.ToCieXyz(color);
return this.ToCieLuv(xyzColor); return this.ToCieLuv(xyzColor);
} }
@ -126,8 +112,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// <returns>The <see cref="CieLuv"/></returns> /// <returns>The <see cref="CieLuv"/></returns>
public CieLuv ToCieLuv(Hsv color) public CieLuv ToCieLuv(Hsv color)
{ {
Guard.NotNull(color, nameof(color));
var xyzColor = this.ToCieXyz(color); var xyzColor = this.ToCieXyz(color);
return this.ToCieLuv(xyzColor); return this.ToCieLuv(xyzColor);
} }
@ -139,8 +123,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// <returns>The <see cref="CieLuv"/></returns> /// <returns>The <see cref="CieLuv"/></returns>
public CieLuv ToCieLuv(HunterLab color) public CieLuv ToCieLuv(HunterLab color)
{ {
Guard.NotNull(color, nameof(color));
var xyzColor = this.ToCieXyz(color); var xyzColor = this.ToCieXyz(color);
return this.ToCieLuv(xyzColor); return this.ToCieLuv(xyzColor);
} }
@ -152,8 +134,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// <returns>The <see cref="CieLuv"/></returns> /// <returns>The <see cref="CieLuv"/></returns>
public CieLuv ToCieLuv(Lms color) public CieLuv ToCieLuv(Lms color)
{ {
Guard.NotNull(color, nameof(color));
var xyzColor = this.ToCieXyz(color); var xyzColor = this.ToCieXyz(color);
return this.ToCieLuv(xyzColor); return this.ToCieLuv(xyzColor);
} }
@ -165,8 +145,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// <returns>The <see cref="CieLuv"/></returns> /// <returns>The <see cref="CieLuv"/></returns>
public CieLuv ToCieLuv(LinearRgb color) public CieLuv ToCieLuv(LinearRgb color)
{ {
Guard.NotNull(color, nameof(color));
var xyzColor = this.ToCieXyz(color); var xyzColor = this.ToCieXyz(color);
return this.ToCieLuv(xyzColor); return this.ToCieLuv(xyzColor);
} }
@ -178,8 +156,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// <returns>The <see cref="CieLuv"/></returns> /// <returns>The <see cref="CieLuv"/></returns>
public CieLuv ToCieLuv(Rgb color) public CieLuv ToCieLuv(Rgb color)
{ {
Guard.NotNull(color, nameof(color));
var xyzColor = this.ToCieXyz(color); var xyzColor = this.ToCieXyz(color);
return this.ToCieLuv(xyzColor); return this.ToCieLuv(xyzColor);
} }
@ -191,8 +167,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// <returns>The <see cref="CieLuv"/></returns> /// <returns>The <see cref="CieLuv"/></returns>
public CieLuv ToCieLuv(YCbCr color) public CieLuv ToCieLuv(YCbCr color)
{ {
Guard.NotNull(color, nameof(color));
var xyzColor = this.ToCieXyz(color); var xyzColor = this.ToCieXyz(color);
return this.ToCieLuv(xyzColor); return this.ToCieLuv(xyzColor);
} }

27
src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.Cmyk.cs

@ -1,7 +1,6 @@
// Copyright (c) Six Labors and contributors. // Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0. // Licensed under the Apache License, Version 2.0.
using SixLabors.ImageSharp.ColorSpaces;
using SixLabors.ImageSharp.ColorSpaces.Conversion.Implementation.CmykColorSapce; using SixLabors.ImageSharp.ColorSpaces.Conversion.Implementation.CmykColorSapce;
namespace SixLabors.ImageSharp.ColorSpaces.Conversion namespace SixLabors.ImageSharp.ColorSpaces.Conversion
@ -20,8 +19,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// <returns>The <see cref="Cmyk"/></returns> /// <returns>The <see cref="Cmyk"/></returns>
public Cmyk ToCmyk(CieLab color) public Cmyk ToCmyk(CieLab color)
{ {
Guard.NotNull(color, nameof(color));
var xyzColor = this.ToCieXyz(color); var xyzColor = this.ToCieXyz(color);
return this.ToCmyk(xyzColor); return this.ToCmyk(xyzColor);
@ -34,8 +31,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// <returns>The <see cref="Cmyk"/></returns> /// <returns>The <see cref="Cmyk"/></returns>
public Cmyk ToCmyk(CieLch color) public Cmyk ToCmyk(CieLch color)
{ {
Guard.NotNull(color, nameof(color));
var xyzColor = this.ToCieXyz(color); var xyzColor = this.ToCieXyz(color);
return this.ToCmyk(xyzColor); return this.ToCmyk(xyzColor);
@ -48,8 +43,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// <returns>The <see cref="Cmyk"/></returns> /// <returns>The <see cref="Cmyk"/></returns>
public Cmyk ToCmyk(CieLchuv color) public Cmyk ToCmyk(CieLchuv color)
{ {
Guard.NotNull(color, nameof(color));
var xyzColor = this.ToCieXyz(color); var xyzColor = this.ToCieXyz(color);
return this.ToCmyk(xyzColor); return this.ToCmyk(xyzColor);
@ -62,8 +55,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// <returns>The <see cref="Cmyk"/></returns> /// <returns>The <see cref="Cmyk"/></returns>
public Cmyk ToCmyk(CieLuv color) public Cmyk ToCmyk(CieLuv color)
{ {
Guard.NotNull(color, nameof(color));
var xyzColor = this.ToCieXyz(color); var xyzColor = this.ToCieXyz(color);
return this.ToCmyk(xyzColor); return this.ToCmyk(xyzColor);
@ -76,8 +67,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// <returns>The <see cref="Cmyk"/></returns> /// <returns>The <see cref="Cmyk"/></returns>
public Cmyk ToCmyk(CieXyy color) public Cmyk ToCmyk(CieXyy color)
{ {
Guard.NotNull(color, nameof(color));
var xyzColor = this.ToCieXyz(color); var xyzColor = this.ToCieXyz(color);
return this.ToCmyk(xyzColor); return this.ToCmyk(xyzColor);
@ -90,8 +79,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// <returns>The <see cref="Cmyk"/></returns> /// <returns>The <see cref="Cmyk"/></returns>
public Cmyk ToCmyk(CieXyz color) public Cmyk ToCmyk(CieXyz color)
{ {
Guard.NotNull(color, nameof(color));
var rgb = this.ToRgb(color); var rgb = this.ToRgb(color);
return CmykAndRgbConverter.Convert(rgb); return CmykAndRgbConverter.Convert(rgb);
@ -104,8 +91,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// <returns>The <see cref="Cmyk"/></returns> /// <returns>The <see cref="Cmyk"/></returns>
public Cmyk ToCmyk(Hsl color) public Cmyk ToCmyk(Hsl color)
{ {
Guard.NotNull(color, nameof(color));
var rgb = this.ToRgb(color); var rgb = this.ToRgb(color);
return CmykAndRgbConverter.Convert(rgb); return CmykAndRgbConverter.Convert(rgb);
@ -118,8 +103,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// <returns>The <see cref="Cmyk"/></returns> /// <returns>The <see cref="Cmyk"/></returns>
public Cmyk ToCmyk(Hsv color) public Cmyk ToCmyk(Hsv color)
{ {
Guard.NotNull(color, nameof(color));
var rgb = this.ToRgb(color); var rgb = this.ToRgb(color);
return CmykAndRgbConverter.Convert(rgb); return CmykAndRgbConverter.Convert(rgb);
@ -132,8 +115,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// <returns>The <see cref="Cmyk"/></returns> /// <returns>The <see cref="Cmyk"/></returns>
public Cmyk ToCmyk(HunterLab color) public Cmyk ToCmyk(HunterLab color)
{ {
Guard.NotNull(color, nameof(color));
var xyzColor = this.ToCieXyz(color); var xyzColor = this.ToCieXyz(color);
return this.ToCmyk(xyzColor); return this.ToCmyk(xyzColor);
@ -146,8 +127,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// <returns>The <see cref="Cmyk"/></returns> /// <returns>The <see cref="Cmyk"/></returns>
public Cmyk ToCmyk(LinearRgb color) public Cmyk ToCmyk(LinearRgb color)
{ {
Guard.NotNull(color, nameof(color));
var rgb = this.ToRgb(color); var rgb = this.ToRgb(color);
return CmykAndRgbConverter.Convert(rgb); return CmykAndRgbConverter.Convert(rgb);
@ -160,8 +139,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// <returns>The <see cref="Cmyk"/></returns> /// <returns>The <see cref="Cmyk"/></returns>
public Cmyk ToCmyk(Lms color) public Cmyk ToCmyk(Lms color)
{ {
Guard.NotNull(color, nameof(color));
var xyzColor = this.ToCieXyz(color); var xyzColor = this.ToCieXyz(color);
return this.ToCmyk(xyzColor); return this.ToCmyk(xyzColor);
@ -174,8 +151,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// <returns>The <see cref="Cmyk"/></returns> /// <returns>The <see cref="Cmyk"/></returns>
public Cmyk ToCmyk(Rgb color) public Cmyk ToCmyk(Rgb color)
{ {
Guard.NotNull(color, nameof(color));
return CmykAndRgbConverter.Convert(color); return CmykAndRgbConverter.Convert(color);
} }
@ -186,8 +161,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// <returns>The <see cref="Cmyk"/></returns> /// <returns>The <see cref="Cmyk"/></returns>
public Cmyk ToCmyk(YCbCr color) public Cmyk ToCmyk(YCbCr color)
{ {
Guard.NotNull(color, nameof(color));
var rgb = this.ToRgb(color); var rgb = this.ToRgb(color);
return CmykAndRgbConverter.Convert(rgb); return CmykAndRgbConverter.Convert(rgb);

27
src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.Hsl.cs

@ -1,7 +1,6 @@
// Copyright (c) Six Labors and contributors. // Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0. // Licensed under the Apache License, Version 2.0.
using SixLabors.ImageSharp.ColorSpaces;
using SixLabors.ImageSharp.ColorSpaces.Conversion.Implementation.HslColorSapce; using SixLabors.ImageSharp.ColorSpaces.Conversion.Implementation.HslColorSapce;
namespace SixLabors.ImageSharp.ColorSpaces.Conversion namespace SixLabors.ImageSharp.ColorSpaces.Conversion
@ -20,8 +19,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// <returns>The <see cref="Hsl"/></returns> /// <returns>The <see cref="Hsl"/></returns>
public Hsl ToHsl(CieLab color) public Hsl ToHsl(CieLab color)
{ {
Guard.NotNull(color, nameof(color));
var xyzColor = this.ToCieXyz(color); var xyzColor = this.ToCieXyz(color);
return this.ToHsl(xyzColor); return this.ToHsl(xyzColor);
@ -34,8 +31,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// <returns>The <see cref="Hsl"/></returns> /// <returns>The <see cref="Hsl"/></returns>
public Hsl ToHsl(CieLch color) public Hsl ToHsl(CieLch color)
{ {
Guard.NotNull(color, nameof(color));
var xyzColor = this.ToCieXyz(color); var xyzColor = this.ToCieXyz(color);
return this.ToHsl(xyzColor); return this.ToHsl(xyzColor);
@ -48,8 +43,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// <returns>The <see cref="Hsl"/></returns> /// <returns>The <see cref="Hsl"/></returns>
public Hsl ToHsl(CieLchuv color) public Hsl ToHsl(CieLchuv color)
{ {
Guard.NotNull(color, nameof(color));
var xyzColor = this.ToCieXyz(color); var xyzColor = this.ToCieXyz(color);
return this.ToHsl(xyzColor); return this.ToHsl(xyzColor);
@ -62,8 +55,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// <returns>The <see cref="Hsl"/></returns> /// <returns>The <see cref="Hsl"/></returns>
public Hsl ToHsl(CieLuv color) public Hsl ToHsl(CieLuv color)
{ {
Guard.NotNull(color, nameof(color));
var xyzColor = this.ToCieXyz(color); var xyzColor = this.ToCieXyz(color);
return this.ToHsl(xyzColor); return this.ToHsl(xyzColor);
@ -76,8 +67,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// <returns>The <see cref="Hsl"/></returns> /// <returns>The <see cref="Hsl"/></returns>
public Hsl ToHsl(CieXyy color) public Hsl ToHsl(CieXyy color)
{ {
Guard.NotNull(color, nameof(color));
var xyzColor = this.ToCieXyz(color); var xyzColor = this.ToCieXyz(color);
return this.ToHsl(xyzColor); return this.ToHsl(xyzColor);
@ -90,8 +79,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// <returns>The <see cref="Hsl"/></returns> /// <returns>The <see cref="Hsl"/></returns>
public Hsl ToHsl(CieXyz color) public Hsl ToHsl(CieXyz color)
{ {
Guard.NotNull(color, nameof(color));
var rgb = this.ToRgb(color); var rgb = this.ToRgb(color);
return HslAndRgbConverter.Convert(rgb); return HslAndRgbConverter.Convert(rgb);
@ -104,8 +91,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// <returns>The <see cref="Hsl"/></returns> /// <returns>The <see cref="Hsl"/></returns>
public Hsl ToHsl(Cmyk color) public Hsl ToHsl(Cmyk color)
{ {
Guard.NotNull(color, nameof(color));
var rgb = this.ToRgb(color); var rgb = this.ToRgb(color);
return HslAndRgbConverter.Convert(rgb); return HslAndRgbConverter.Convert(rgb);
@ -118,8 +103,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// <returns>The <see cref="Hsl"/></returns> /// <returns>The <see cref="Hsl"/></returns>
public Hsl ToHsl(Hsv color) public Hsl ToHsl(Hsv color)
{ {
Guard.NotNull(color, nameof(color));
var rgb = this.ToRgb(color); var rgb = this.ToRgb(color);
return HslAndRgbConverter.Convert(rgb); return HslAndRgbConverter.Convert(rgb);
@ -132,8 +115,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// <returns>The <see cref="Hsl"/></returns> /// <returns>The <see cref="Hsl"/></returns>
public Hsl ToHsl(HunterLab color) public Hsl ToHsl(HunterLab color)
{ {
Guard.NotNull(color, nameof(color));
var xyzColor = this.ToCieXyz(color); var xyzColor = this.ToCieXyz(color);
return this.ToHsl(xyzColor); return this.ToHsl(xyzColor);
@ -146,8 +127,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// <returns>The <see cref="Hsl"/></returns> /// <returns>The <see cref="Hsl"/></returns>
public Hsl ToHsl(LinearRgb color) public Hsl ToHsl(LinearRgb color)
{ {
Guard.NotNull(color, nameof(color));
var rgb = this.ToRgb(color); var rgb = this.ToRgb(color);
return HslAndRgbConverter.Convert(rgb); return HslAndRgbConverter.Convert(rgb);
@ -160,8 +139,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// <returns>The <see cref="Hsl"/></returns> /// <returns>The <see cref="Hsl"/></returns>
public Hsl ToHsl(Lms color) public Hsl ToHsl(Lms color)
{ {
Guard.NotNull(color, nameof(color));
var xyzColor = this.ToCieXyz(color); var xyzColor = this.ToCieXyz(color);
return this.ToHsl(xyzColor); return this.ToHsl(xyzColor);
@ -174,8 +151,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// <returns>The <see cref="Hsl"/></returns> /// <returns>The <see cref="Hsl"/></returns>
public Hsl ToHsl(Rgb color) public Hsl ToHsl(Rgb color)
{ {
Guard.NotNull(color, nameof(color));
return HslAndRgbConverter.Convert(color); return HslAndRgbConverter.Convert(color);
} }
@ -186,8 +161,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// <returns>The <see cref="Hsl"/></returns> /// <returns>The <see cref="Hsl"/></returns>
public Hsl ToHsl(YCbCr color) public Hsl ToHsl(YCbCr color)
{ {
Guard.NotNull(color, nameof(color));
var rgb = this.ToRgb(color); var rgb = this.ToRgb(color);
return HslAndRgbConverter.Convert(rgb); return HslAndRgbConverter.Convert(rgb);

26
src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.HunterLab.cs

@ -17,8 +17,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// <returns>The <see cref="HunterLab"/></returns> /// <returns>The <see cref="HunterLab"/></returns>
public HunterLab ToHunterLab(CieLab color) public HunterLab ToHunterLab(CieLab color)
{ {
Guard.NotNull(color, nameof(color));
var xyzColor = this.ToCieXyz(color); var xyzColor = this.ToCieXyz(color);
return this.ToHunterLab(xyzColor); return this.ToHunterLab(xyzColor);
} }
@ -30,8 +28,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// <returns>The <see cref="HunterLab"/></returns> /// <returns>The <see cref="HunterLab"/></returns>
public HunterLab ToHunterLab(CieLch color) public HunterLab ToHunterLab(CieLch color)
{ {
Guard.NotNull(color, nameof(color));
var xyzColor = this.ToCieXyz(color); var xyzColor = this.ToCieXyz(color);
return this.ToHunterLab(xyzColor); return this.ToHunterLab(xyzColor);
} }
@ -43,8 +39,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// <returns>The <see cref="HunterLab"/></returns> /// <returns>The <see cref="HunterLab"/></returns>
public HunterLab ToHunterLab(CieLchuv color) public HunterLab ToHunterLab(CieLchuv color)
{ {
Guard.NotNull(color, nameof(color));
var xyzColor = this.ToCieXyz(color); var xyzColor = this.ToCieXyz(color);
return this.ToHunterLab(xyzColor); return this.ToHunterLab(xyzColor);
} }
@ -56,8 +50,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// <returns>The <see cref="HunterLab"/></returns> /// <returns>The <see cref="HunterLab"/></returns>
public HunterLab ToHunterLab(CieLuv color) public HunterLab ToHunterLab(CieLuv color)
{ {
Guard.NotNull(color, nameof(color));
var xyzColor = this.ToCieXyz(color); var xyzColor = this.ToCieXyz(color);
return this.ToHunterLab(xyzColor); return this.ToHunterLab(xyzColor);
} }
@ -69,8 +61,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// <returns>The <see cref="HunterLab"/></returns> /// <returns>The <see cref="HunterLab"/></returns>
public HunterLab ToHunterLab(CieXyy color) public HunterLab ToHunterLab(CieXyy color)
{ {
Guard.NotNull(color, nameof(color));
var xyzColor = this.ToCieXyz(color); var xyzColor = this.ToCieXyz(color);
return this.ToHunterLab(xyzColor); return this.ToHunterLab(xyzColor);
} }
@ -82,8 +72,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// <returns>The <see cref="HunterLab"/></returns> /// <returns>The <see cref="HunterLab"/></returns>
public HunterLab ToHunterLab(CieXyz color) public HunterLab ToHunterLab(CieXyz color)
{ {
Guard.NotNull(color, nameof(color));
// Adaptation // Adaptation
CieXyz adapted = !this.WhitePoint.Equals(this.TargetHunterLabWhitePoint) && this.IsChromaticAdaptationPerformed CieXyz adapted = !this.WhitePoint.Equals(this.TargetHunterLabWhitePoint) && this.IsChromaticAdaptationPerformed
? this.ChromaticAdaptation.Transform(color, this.WhitePoint, this.TargetHunterLabWhitePoint) ? this.ChromaticAdaptation.Transform(color, this.WhitePoint, this.TargetHunterLabWhitePoint)
@ -100,8 +88,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// <returns>The <see cref="HunterLab"/></returns> /// <returns>The <see cref="HunterLab"/></returns>
public HunterLab ToHunterLab(Cmyk color) public HunterLab ToHunterLab(Cmyk color)
{ {
Guard.NotNull(color, nameof(color));
var xyzColor = this.ToCieXyz(color); var xyzColor = this.ToCieXyz(color);
return this.ToHunterLab(xyzColor); return this.ToHunterLab(xyzColor);
} }
@ -113,8 +99,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// <returns>The <see cref="HunterLab"/></returns> /// <returns>The <see cref="HunterLab"/></returns>
public HunterLab ToHunterLab(Hsl color) public HunterLab ToHunterLab(Hsl color)
{ {
Guard.NotNull(color, nameof(color));
var xyzColor = this.ToCieXyz(color); var xyzColor = this.ToCieXyz(color);
return this.ToHunterLab(xyzColor); return this.ToHunterLab(xyzColor);
} }
@ -126,8 +110,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// <returns>The <see cref="HunterLab"/></returns> /// <returns>The <see cref="HunterLab"/></returns>
public HunterLab ToHunterLab(Hsv color) public HunterLab ToHunterLab(Hsv color)
{ {
Guard.NotNull(color, nameof(color));
var xyzColor = this.ToCieXyz(color); var xyzColor = this.ToCieXyz(color);
return this.ToHunterLab(xyzColor); return this.ToHunterLab(xyzColor);
} }
@ -139,8 +121,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// <returns>The <see cref="HunterLab"/></returns> /// <returns>The <see cref="HunterLab"/></returns>
public HunterLab ToHunterLab(LinearRgb color) public HunterLab ToHunterLab(LinearRgb color)
{ {
Guard.NotNull(color, nameof(color));
var xyzColor = this.ToCieXyz(color); var xyzColor = this.ToCieXyz(color);
return this.ToHunterLab(xyzColor); return this.ToHunterLab(xyzColor);
} }
@ -152,8 +132,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// <returns>The <see cref="HunterLab"/></returns> /// <returns>The <see cref="HunterLab"/></returns>
public HunterLab ToHunterLab(Lms color) public HunterLab ToHunterLab(Lms color)
{ {
Guard.NotNull(color, nameof(color));
var xyzColor = this.ToCieXyz(color); var xyzColor = this.ToCieXyz(color);
return this.ToHunterLab(xyzColor); return this.ToHunterLab(xyzColor);
} }
@ -165,8 +143,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// <returns>The <see cref="HunterLab"/></returns> /// <returns>The <see cref="HunterLab"/></returns>
public HunterLab ToHunterLab(Rgb color) public HunterLab ToHunterLab(Rgb color)
{ {
Guard.NotNull(color, nameof(color));
var xyzColor = this.ToCieXyz(color); var xyzColor = this.ToCieXyz(color);
return this.ToHunterLab(xyzColor); return this.ToHunterLab(xyzColor);
} }
@ -178,8 +154,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// <returns>The <see cref="HunterLab"/></returns> /// <returns>The <see cref="HunterLab"/></returns>
public HunterLab ToHunterLab(YCbCr color) public HunterLab ToHunterLab(YCbCr color)
{ {
Guard.NotNull(color, nameof(color));
var xyzColor = this.ToCieXyz(color); var xyzColor = this.ToCieXyz(color);
return this.ToHunterLab(xyzColor); return this.ToHunterLab(xyzColor);
} }

24
src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.LinearRgb.cs

@ -21,8 +21,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// <returns>The <see cref="LinearRgb"/></returns> /// <returns>The <see cref="LinearRgb"/></returns>
public LinearRgb ToLinearRgb(CieLab color) public LinearRgb ToLinearRgb(CieLab color)
{ {
Guard.NotNull(color, nameof(color));
var xyzColor = this.ToCieXyz(color); var xyzColor = this.ToCieXyz(color);
return this.ToLinearRgb(xyzColor); return this.ToLinearRgb(xyzColor);
} }
@ -34,8 +32,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// <returns>The <see cref="LinearRgb"/></returns> /// <returns>The <see cref="LinearRgb"/></returns>
public LinearRgb ToLinearRgb(CieLch color) public LinearRgb ToLinearRgb(CieLch color)
{ {
Guard.NotNull(color, nameof(color));
var xyzColor = this.ToCieXyz(color); var xyzColor = this.ToCieXyz(color);
return this.ToLinearRgb(xyzColor); return this.ToLinearRgb(xyzColor);
} }
@ -47,8 +43,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// <returns>The <see cref="LinearRgb"/></returns> /// <returns>The <see cref="LinearRgb"/></returns>
public LinearRgb ToLinearRgb(CieLchuv color) public LinearRgb ToLinearRgb(CieLchuv color)
{ {
Guard.NotNull(color, nameof(color));
var xyzColor = this.ToCieXyz(color); var xyzColor = this.ToCieXyz(color);
return this.ToLinearRgb(xyzColor); return this.ToLinearRgb(xyzColor);
} }
@ -60,8 +54,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// <returns>The <see cref="LinearRgb"/></returns> /// <returns>The <see cref="LinearRgb"/></returns>
public LinearRgb ToLinearRgb(CieLuv color) public LinearRgb ToLinearRgb(CieLuv color)
{ {
Guard.NotNull(color, nameof(color));
var xyzColor = this.ToCieXyz(color); var xyzColor = this.ToCieXyz(color);
return this.ToLinearRgb(xyzColor); return this.ToLinearRgb(xyzColor);
} }
@ -73,8 +65,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// <returns>The <see cref="LinearRgb"/></returns> /// <returns>The <see cref="LinearRgb"/></returns>
public LinearRgb ToLinearRgb(CieXyy color) public LinearRgb ToLinearRgb(CieXyy color)
{ {
Guard.NotNull(color, nameof(color));
var xyzColor = this.ToCieXyz(color); var xyzColor = this.ToCieXyz(color);
return this.ToLinearRgb(xyzColor); return this.ToLinearRgb(xyzColor);
} }
@ -86,8 +76,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// <returns>The <see cref="LinearRgb"/></returns> /// <returns>The <see cref="LinearRgb"/></returns>
public LinearRgb ToLinearRgb(CieXyz color) public LinearRgb ToLinearRgb(CieXyz color)
{ {
Guard.NotNull(color, nameof(color));
// Adaptation // Adaptation
CieXyz adapted = this.TargetRgbWorkingSpace.WhitePoint.Equals(this.WhitePoint) || !this.IsChromaticAdaptationPerformed CieXyz adapted = this.TargetRgbWorkingSpace.WhitePoint.Equals(this.WhitePoint) || !this.IsChromaticAdaptationPerformed
? color ? color
@ -105,8 +93,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// <returns>The <see cref="LinearRgb"/></returns> /// <returns>The <see cref="LinearRgb"/></returns>
public LinearRgb ToLinearRgb(Cmyk color) public LinearRgb ToLinearRgb(Cmyk color)
{ {
Guard.NotNull(color, nameof(color));
var rgb = this.ToRgb(color); var rgb = this.ToRgb(color);
return this.ToLinearRgb(rgb); return this.ToLinearRgb(rgb);
} }
@ -118,8 +104,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// <returns>The <see cref="LinearRgb"/></returns> /// <returns>The <see cref="LinearRgb"/></returns>
public LinearRgb ToLinearRgb(Hsl color) public LinearRgb ToLinearRgb(Hsl color)
{ {
Guard.NotNull(color, nameof(color));
var rgb = this.ToRgb(color); var rgb = this.ToRgb(color);
return this.ToLinearRgb(rgb); return this.ToLinearRgb(rgb);
} }
@ -144,8 +128,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// <returns>The <see cref="LinearRgb"/></returns> /// <returns>The <see cref="LinearRgb"/></returns>
public LinearRgb ToLinearRgb(HunterLab color) public LinearRgb ToLinearRgb(HunterLab color)
{ {
Guard.NotNull(color, nameof(color));
var xyzColor = this.ToCieXyz(color); var xyzColor = this.ToCieXyz(color);
return this.ToLinearRgb(xyzColor); return this.ToLinearRgb(xyzColor);
} }
@ -157,8 +139,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// <returns>The <see cref="LinearRgb"/></returns> /// <returns>The <see cref="LinearRgb"/></returns>
public LinearRgb ToLinearRgb(Lms color) public LinearRgb ToLinearRgb(Lms color)
{ {
Guard.NotNull(color, nameof(color));
var xyzColor = this.ToCieXyz(color); var xyzColor = this.ToCieXyz(color);
return this.ToLinearRgb(xyzColor); return this.ToLinearRgb(xyzColor);
} }
@ -170,8 +150,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// <returns>The <see cref="LinearRgb"/></returns> /// <returns>The <see cref="LinearRgb"/></returns>
public LinearRgb ToLinearRgb(Rgb color) public LinearRgb ToLinearRgb(Rgb color)
{ {
Guard.NotNull(color, nameof(color));
// Conversion // Conversion
return RgbToLinearRgbConverter.Convert(color); return RgbToLinearRgbConverter.Convert(color);
} }
@ -183,8 +161,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// <returns>The <see cref="LinearRgb"/></returns> /// <returns>The <see cref="LinearRgb"/></returns>
public LinearRgb ToLinearRgb(YCbCr color) public LinearRgb ToLinearRgb(YCbCr color)
{ {
Guard.NotNull(color, nameof(color));
var rgb = this.ToRgb(color); var rgb = this.ToRgb(color);
return this.ToLinearRgb(rgb); return this.ToLinearRgb(rgb);
} }

27
src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.Lms.cs

@ -17,8 +17,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// <returns>The <see cref="Lms"/></returns> /// <returns>The <see cref="Lms"/></returns>
public Lms ToLms(CieLab color) public Lms ToLms(CieLab color)
{ {
Guard.NotNull(color, nameof(color));
var xyzColor = this.ToCieXyz(color); var xyzColor = this.ToCieXyz(color);
return this.ToLms(xyzColor); return this.ToLms(xyzColor);
} }
@ -30,8 +28,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// <returns>The <see cref="Lms"/></returns> /// <returns>The <see cref="Lms"/></returns>
public Lms ToLms(CieLch color) public Lms ToLms(CieLch color)
{ {
Guard.NotNull(color, nameof(color));
var xyzColor = this.ToCieXyz(color); var xyzColor = this.ToCieXyz(color);
return this.ToLms(xyzColor); return this.ToLms(xyzColor);
} }
@ -43,8 +39,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// <returns>The <see cref="Lms"/></returns> /// <returns>The <see cref="Lms"/></returns>
public Lms ToLms(CieLchuv color) public Lms ToLms(CieLchuv color)
{ {
Guard.NotNull(color, nameof(color));
var xyzColor = this.ToCieXyz(color); var xyzColor = this.ToCieXyz(color);
return this.ToLms(xyzColor); return this.ToLms(xyzColor);
} }
@ -56,8 +50,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// <returns>The <see cref="Lms"/></returns> /// <returns>The <see cref="Lms"/></returns>
public Lms ToLms(CieLuv color) public Lms ToLms(CieLuv color)
{ {
Guard.NotNull(color, nameof(color));
var xyzColor = this.ToCieXyz(color); var xyzColor = this.ToCieXyz(color);
return this.ToLms(xyzColor); return this.ToLms(xyzColor);
} }
@ -69,8 +61,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// <returns>The <see cref="Lms"/></returns> /// <returns>The <see cref="Lms"/></returns>
public Lms ToLms(CieXyy color) public Lms ToLms(CieXyy color)
{ {
Guard.NotNull(color, nameof(color));
var xyzColor = this.ToCieXyz(color); var xyzColor = this.ToCieXyz(color);
return this.ToLms(xyzColor); return this.ToLms(xyzColor);
} }
@ -82,9 +72,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// <returns>The <see cref="Lms"/></returns> /// <returns>The <see cref="Lms"/></returns>
public Lms ToLms(CieXyz color) public Lms ToLms(CieXyz color)
{ {
Guard.NotNull(color, nameof(color));
// Conversion
return this.cachedCieXyzAndLmsConverter.Convert(color); return this.cachedCieXyzAndLmsConverter.Convert(color);
} }
@ -95,8 +82,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// <returns>The <see cref="Lms"/></returns> /// <returns>The <see cref="Lms"/></returns>
public Lms ToLms(Cmyk color) public Lms ToLms(Cmyk color)
{ {
Guard.NotNull(color, nameof(color));
var xyzColor = this.ToCieXyz(color); var xyzColor = this.ToCieXyz(color);
return this.ToLms(xyzColor); return this.ToLms(xyzColor);
} }
@ -108,8 +93,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// <returns>The <see cref="Lms"/></returns> /// <returns>The <see cref="Lms"/></returns>
public Lms ToLms(Hsl color) public Lms ToLms(Hsl color)
{ {
Guard.NotNull(color, nameof(color));
var xyzColor = this.ToCieXyz(color); var xyzColor = this.ToCieXyz(color);
return this.ToLms(xyzColor); return this.ToLms(xyzColor);
} }
@ -121,8 +104,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// <returns>The <see cref="Lms"/></returns> /// <returns>The <see cref="Lms"/></returns>
public Lms ToLms(Hsv color) public Lms ToLms(Hsv color)
{ {
Guard.NotNull(color, nameof(color));
var xyzColor = this.ToCieXyz(color); var xyzColor = this.ToCieXyz(color);
return this.ToLms(xyzColor); return this.ToLms(xyzColor);
} }
@ -134,8 +115,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// <returns>The <see cref="Lms"/></returns> /// <returns>The <see cref="Lms"/></returns>
public Lms ToLms(HunterLab color) public Lms ToLms(HunterLab color)
{ {
Guard.NotNull(color, nameof(color));
var xyzColor = this.ToCieXyz(color); var xyzColor = this.ToCieXyz(color);
return this.ToLms(xyzColor); return this.ToLms(xyzColor);
} }
@ -147,8 +126,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// <returns>The <see cref="Lms"/></returns> /// <returns>The <see cref="Lms"/></returns>
public Lms ToLms(LinearRgb color) public Lms ToLms(LinearRgb color)
{ {
Guard.NotNull(color, nameof(color));
var xyzColor = this.ToCieXyz(color); var xyzColor = this.ToCieXyz(color);
return this.ToLms(xyzColor); return this.ToLms(xyzColor);
} }
@ -160,8 +137,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// <returns>The <see cref="Lms"/></returns> /// <returns>The <see cref="Lms"/></returns>
public Lms ToLms(Rgb color) public Lms ToLms(Rgb color)
{ {
Guard.NotNull(color, nameof(color));
var xyzColor = this.ToCieXyz(color); var xyzColor = this.ToCieXyz(color);
return this.ToLms(xyzColor); return this.ToLms(xyzColor);
} }
@ -173,8 +148,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// <returns>The <see cref="Lms"/></returns> /// <returns>The <see cref="Lms"/></returns>
public Lms ToLms(YCbCr color) public Lms ToLms(YCbCr color)
{ {
Guard.NotNull(color, nameof(color));
var xyzColor = this.ToCieXyz(color); var xyzColor = this.ToCieXyz(color);
return this.ToLms(xyzColor); return this.ToLms(xyzColor);
} }

24
src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.Rgb.cs

@ -19,8 +19,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// <returns>The <see cref="Rgb"/></returns> /// <returns>The <see cref="Rgb"/></returns>
public Rgb ToRgb(CieLab color) public Rgb ToRgb(CieLab color)
{ {
Guard.NotNull(color, nameof(color));
var xyzColor = this.ToCieXyz(color); var xyzColor = this.ToCieXyz(color);
return this.ToRgb(xyzColor); return this.ToRgb(xyzColor);
} }
@ -32,8 +30,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// <returns>The <see cref="Rgb"/></returns> /// <returns>The <see cref="Rgb"/></returns>
public Rgb ToRgb(CieLch color) public Rgb ToRgb(CieLch color)
{ {
Guard.NotNull(color, nameof(color));
var xyzColor = this.ToCieXyz(color); var xyzColor = this.ToCieXyz(color);
return this.ToRgb(xyzColor); return this.ToRgb(xyzColor);
} }
@ -45,8 +41,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// <returns>The <see cref="Rgb"/></returns> /// <returns>The <see cref="Rgb"/></returns>
public Rgb ToRgb(CieLchuv color) public Rgb ToRgb(CieLchuv color)
{ {
Guard.NotNull(color, nameof(color));
var xyzColor = this.ToCieXyz(color); var xyzColor = this.ToCieXyz(color);
return this.ToRgb(xyzColor); return this.ToRgb(xyzColor);
} }
@ -58,8 +52,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// <returns>The <see cref="Rgb"/></returns> /// <returns>The <see cref="Rgb"/></returns>
public Rgb ToRgb(CieLuv color) public Rgb ToRgb(CieLuv color)
{ {
Guard.NotNull(color, nameof(color));
var xyzColor = this.ToCieXyz(color); var xyzColor = this.ToCieXyz(color);
return this.ToRgb(xyzColor); return this.ToRgb(xyzColor);
} }
@ -71,8 +63,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// <returns>The <see cref="Rgb"/></returns> /// <returns>The <see cref="Rgb"/></returns>
public Rgb ToRgb(CieXyy color) public Rgb ToRgb(CieXyy color)
{ {
Guard.NotNull(color, nameof(color));
var xyzColor = this.ToCieXyz(color); var xyzColor = this.ToCieXyz(color);
return this.ToRgb(xyzColor); return this.ToRgb(xyzColor);
} }
@ -84,8 +74,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// <returns>The <see cref="Rgb"/></returns> /// <returns>The <see cref="Rgb"/></returns>
public Rgb ToRgb(CieXyz color) public Rgb ToRgb(CieXyz color)
{ {
Guard.NotNull(color, nameof(color));
// Conversion // Conversion
var linear = this.ToLinearRgb(color); var linear = this.ToLinearRgb(color);
@ -100,8 +88,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// <returns>The <see cref="Rgb"/></returns> /// <returns>The <see cref="Rgb"/></returns>
public Rgb ToRgb(Cmyk color) public Rgb ToRgb(Cmyk color)
{ {
Guard.NotNull(color, nameof(color));
// Conversion // Conversion
return CmykAndRgbConverter.Convert(color); return CmykAndRgbConverter.Convert(color);
} }
@ -113,8 +99,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// <returns>The <see cref="Rgb"/></returns> /// <returns>The <see cref="Rgb"/></returns>
public Rgb ToRgb(Hsv color) public Rgb ToRgb(Hsv color)
{ {
Guard.NotNull(color, nameof(color));
// Conversion // Conversion
return HsvAndRgbConverter.Convert(color); return HsvAndRgbConverter.Convert(color);
} }
@ -139,8 +123,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// <returns>The <see cref="Rgb"/></returns> /// <returns>The <see cref="Rgb"/></returns>
public Rgb ToRgb(HunterLab color) public Rgb ToRgb(HunterLab color)
{ {
Guard.NotNull(color, nameof(color));
var xyzColor = this.ToCieXyz(color); var xyzColor = this.ToCieXyz(color);
return this.ToRgb(xyzColor); return this.ToRgb(xyzColor);
} }
@ -152,8 +134,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// <returns>The <see cref="Rgb"/></returns> /// <returns>The <see cref="Rgb"/></returns>
public Rgb ToRgb(LinearRgb color) public Rgb ToRgb(LinearRgb color)
{ {
Guard.NotNull(color, nameof(color));
// Conversion // Conversion
return LinearRgbToRgbConverter.Convert(color); return LinearRgbToRgbConverter.Convert(color);
} }
@ -165,8 +145,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// <returns>The <see cref="Rgb"/></returns> /// <returns>The <see cref="Rgb"/></returns>
public Rgb ToRgb(Lms color) public Rgb ToRgb(Lms color)
{ {
Guard.NotNull(color, nameof(color));
var xyzColor = this.ToCieXyz(color); var xyzColor = this.ToCieXyz(color);
return this.ToRgb(xyzColor); return this.ToRgb(xyzColor);
} }
@ -178,8 +156,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// <returns>The <see cref="Rgb"/></returns> /// <returns>The <see cref="Rgb"/></returns>
public Rgb ToRgb(YCbCr color) public Rgb ToRgb(YCbCr color)
{ {
Guard.NotNull(color, nameof(color));
// Conversion // Conversion
Rgb rgb = YCbCrAndRgbConverter.Convert(color); Rgb rgb = YCbCrAndRgbConverter.Convert(color);

27
src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.YCbCr.cs

@ -1,7 +1,6 @@
// Copyright (c) Six Labors and contributors. // Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0. // Licensed under the Apache License, Version 2.0.
using SixLabors.ImageSharp.ColorSpaces;
using SixLabors.ImageSharp.ColorSpaces.Conversion.Implementation.YCbCrColorSapce; using SixLabors.ImageSharp.ColorSpaces.Conversion.Implementation.YCbCrColorSapce;
namespace SixLabors.ImageSharp.ColorSpaces.Conversion namespace SixLabors.ImageSharp.ColorSpaces.Conversion
@ -20,8 +19,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// <returns>The <see cref="YCbCr"/></returns> /// <returns>The <see cref="YCbCr"/></returns>
public YCbCr ToYCbCr(CieLab color) public YCbCr ToYCbCr(CieLab color)
{ {
Guard.NotNull(color, nameof(color));
var xyzColor = this.ToCieXyz(color); var xyzColor = this.ToCieXyz(color);
return this.ToYCbCr(xyzColor); return this.ToYCbCr(xyzColor);
@ -34,8 +31,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// <returns>The <see cref="YCbCr"/></returns> /// <returns>The <see cref="YCbCr"/></returns>
public YCbCr ToYCbCr(CieLch color) public YCbCr ToYCbCr(CieLch color)
{ {
Guard.NotNull(color, nameof(color));
var xyzColor = this.ToCieXyz(color); var xyzColor = this.ToCieXyz(color);
return this.ToYCbCr(xyzColor); return this.ToYCbCr(xyzColor);
@ -48,8 +43,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// <returns>The <see cref="YCbCr"/></returns> /// <returns>The <see cref="YCbCr"/></returns>
public YCbCr ToYCbCr(CieLchuv color) public YCbCr ToYCbCr(CieLchuv color)
{ {
Guard.NotNull(color, nameof(color));
var xyzColor = this.ToCieXyz(color); var xyzColor = this.ToCieXyz(color);
return this.ToYCbCr(xyzColor); return this.ToYCbCr(xyzColor);
@ -62,8 +55,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// <returns>The <see cref="YCbCr"/></returns> /// <returns>The <see cref="YCbCr"/></returns>
public YCbCr ToYCbCr(CieLuv color) public YCbCr ToYCbCr(CieLuv color)
{ {
Guard.NotNull(color, nameof(color));
var xyzColor = this.ToCieXyz(color); var xyzColor = this.ToCieXyz(color);
return this.ToYCbCr(xyzColor); return this.ToYCbCr(xyzColor);
@ -76,8 +67,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// <returns>The <see cref="YCbCr"/></returns> /// <returns>The <see cref="YCbCr"/></returns>
public YCbCr ToYCbCr(CieXyy color) public YCbCr ToYCbCr(CieXyy color)
{ {
Guard.NotNull(color, nameof(color));
var xyzColor = this.ToCieXyz(color); var xyzColor = this.ToCieXyz(color);
return this.ToYCbCr(xyzColor); return this.ToYCbCr(xyzColor);
@ -90,8 +79,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// <returns>The <see cref="YCbCr"/></returns> /// <returns>The <see cref="YCbCr"/></returns>
public YCbCr ToYCbCr(CieXyz color) public YCbCr ToYCbCr(CieXyz color)
{ {
Guard.NotNull(color, nameof(color));
var rgb = this.ToRgb(color); var rgb = this.ToRgb(color);
return YCbCrAndRgbConverter.Convert(rgb); return YCbCrAndRgbConverter.Convert(rgb);
@ -104,8 +91,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// <returns>The <see cref="YCbCr"/></returns> /// <returns>The <see cref="YCbCr"/></returns>
public YCbCr ToYCbCr(Cmyk color) public YCbCr ToYCbCr(Cmyk color)
{ {
Guard.NotNull(color, nameof(color));
var rgb = this.ToRgb(color); var rgb = this.ToRgb(color);
return YCbCrAndRgbConverter.Convert(rgb); return YCbCrAndRgbConverter.Convert(rgb);
@ -118,8 +103,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// <returns>The <see cref="YCbCr"/></returns> /// <returns>The <see cref="YCbCr"/></returns>
public YCbCr ToYCbCr(Hsl color) public YCbCr ToYCbCr(Hsl color)
{ {
Guard.NotNull(color, nameof(color));
var rgb = this.ToRgb(color); var rgb = this.ToRgb(color);
return YCbCrAndRgbConverter.Convert(rgb); return YCbCrAndRgbConverter.Convert(rgb);
@ -132,8 +115,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// <returns>The <see cref="YCbCr"/></returns> /// <returns>The <see cref="YCbCr"/></returns>
public YCbCr ToYCbCr(Hsv color) public YCbCr ToYCbCr(Hsv color)
{ {
Guard.NotNull(color, nameof(color));
var rgb = this.ToRgb(color); var rgb = this.ToRgb(color);
return YCbCrAndRgbConverter.Convert(rgb); return YCbCrAndRgbConverter.Convert(rgb);
@ -146,8 +127,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// <returns>The <see cref="YCbCr"/></returns> /// <returns>The <see cref="YCbCr"/></returns>
public YCbCr ToYCbCr(HunterLab color) public YCbCr ToYCbCr(HunterLab color)
{ {
Guard.NotNull(color, nameof(color));
var xyzColor = this.ToCieXyz(color); var xyzColor = this.ToCieXyz(color);
return this.ToYCbCr(xyzColor); return this.ToYCbCr(xyzColor);
@ -160,8 +139,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// <returns>The <see cref="YCbCr"/></returns> /// <returns>The <see cref="YCbCr"/></returns>
public YCbCr ToYCbCr(LinearRgb color) public YCbCr ToYCbCr(LinearRgb color)
{ {
Guard.NotNull(color, nameof(color));
var rgb = this.ToRgb(color); var rgb = this.ToRgb(color);
return YCbCrAndRgbConverter.Convert(rgb); return YCbCrAndRgbConverter.Convert(rgb);
@ -174,8 +151,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// <returns>The <see cref="YCbCr"/></returns> /// <returns>The <see cref="YCbCr"/></returns>
public YCbCr ToYCbCr(Lms color) public YCbCr ToYCbCr(Lms color)
{ {
Guard.NotNull(color, nameof(color));
var xyzColor = this.ToCieXyz(color); var xyzColor = this.ToCieXyz(color);
return this.ToYCbCr(xyzColor); return this.ToYCbCr(xyzColor);
@ -188,8 +163,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// <returns>The <see cref="YCbCr"/></returns> /// <returns>The <see cref="YCbCr"/></returns>
public YCbCr ToYCbCr(Rgb color) public YCbCr ToYCbCr(Rgb color)
{ {
Guard.NotNull(color, nameof(color));
return YCbCrAndRgbConverter.Convert(color); return YCbCrAndRgbConverter.Convert(color);
} }
} }

1
src/ImageSharp/ColorSpaces/Conversion/Implementation/CieXyy/CieXyzAndCieXyyConverter.cs

@ -3,7 +3,6 @@
using System; using System;
using System.Runtime.CompilerServices; using System.Runtime.CompilerServices;
using SixLabors.ImageSharp.ColorSpaces;
namespace SixLabors.ImageSharp.ColorSpaces.Conversion.Implementation.CieXyyColorSapce namespace SixLabors.ImageSharp.ColorSpaces.Conversion.Implementation.CieXyyColorSapce
{ {

1
src/ImageSharp/ColorSpaces/Conversion/Implementation/Cmyk/CmykAndRgbConverter.cs

@ -3,7 +3,6 @@
using System; using System;
using System.Runtime.CompilerServices; using System.Runtime.CompilerServices;
using SixLabors.ImageSharp.ColorSpaces;
namespace SixLabors.ImageSharp.ColorSpaces.Conversion.Implementation.CmykColorSapce namespace SixLabors.ImageSharp.ColorSpaces.Conversion.Implementation.CmykColorSapce
{ {

1
src/ImageSharp/ColorSpaces/Conversion/Implementation/Hsl/HslAndRgbConverter.cs

@ -3,7 +3,6 @@
using System; using System;
using System.Runtime.CompilerServices; using System.Runtime.CompilerServices;
using SixLabors.ImageSharp.ColorSpaces;
namespace SixLabors.ImageSharp.ColorSpaces.Conversion.Implementation.HslColorSapce namespace SixLabors.ImageSharp.ColorSpaces.Conversion.Implementation.HslColorSapce
{ {

1
src/ImageSharp/ColorSpaces/Conversion/Implementation/Hsv/HsvAndRgbConverter.cs

@ -3,7 +3,6 @@
using System; using System;
using System.Runtime.CompilerServices; using System.Runtime.CompilerServices;
using SixLabors.ImageSharp.ColorSpaces;
namespace SixLabors.ImageSharp.ColorSpaces.Conversion.Implementation.HsvColorSapce namespace SixLabors.ImageSharp.ColorSpaces.Conversion.Implementation.HsvColorSapce
{ {

2
src/ImageSharp/ColorSpaces/Conversion/Implementation/HunterLab/CieXyzAndHunterLabConverterBase.cs

@ -18,8 +18,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion.Implementation.HunterLabCo
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static float ComputeKa(CieXyz whitePoint) public static float ComputeKa(CieXyz whitePoint)
{ {
DebugGuard.NotNull(whitePoint, nameof(whitePoint));
if (whitePoint.Equals(Illuminants.C)) if (whitePoint.Equals(Illuminants.C))
{ {
return 175F; return 175F;

1
src/ImageSharp/ColorSpaces/Conversion/Implementation/HunterLab/CieXyzToHunterLabConverter.cs

@ -3,7 +3,6 @@
using System; using System;
using System.Runtime.CompilerServices; using System.Runtime.CompilerServices;
using SixLabors.ImageSharp.ColorSpaces;
namespace SixLabors.ImageSharp.ColorSpaces.Conversion.Implementation.HunterLabColorSapce namespace SixLabors.ImageSharp.ColorSpaces.Conversion.Implementation.HunterLabColorSapce
{ {

3
src/ImageSharp/ColorSpaces/Conversion/Implementation/HunterLab/HunterLabToCieXyzConverter.cs

@ -3,7 +3,6 @@
using System; using System;
using System.Runtime.CompilerServices; using System.Runtime.CompilerServices;
using SixLabors.ImageSharp.ColorSpaces;
namespace SixLabors.ImageSharp.ColorSpaces.Conversion.Implementation.HunterLabColorSapce namespace SixLabors.ImageSharp.ColorSpaces.Conversion.Implementation.HunterLabColorSapce
{ {
@ -16,8 +15,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion.Implementation.HunterLabCo
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public CieXyz Convert(HunterLab input) public CieXyz Convert(HunterLab input)
{ {
DebugGuard.NotNull(input, nameof(input));
// Conversion algorithm described here: http://en.wikipedia.org/wiki/Lab_color_space#Hunter_Lab // Conversion algorithm described here: http://en.wikipedia.org/wiki/Lab_color_space#Hunter_Lab
float l = input.L, a = input.A, b = input.B; float l = input.L, a = input.A, b = input.B;
float xn = input.WhitePoint.X, yn = input.WhitePoint.Y, zn = input.WhitePoint.Z; float xn = input.WhitePoint.X, yn = input.WhitePoint.Y, zn = input.WhitePoint.Z;

5
src/ImageSharp/ColorSpaces/Conversion/Implementation/Lms/CieXyzAndLmsConverter.cs

@ -3,7 +3,6 @@
using System.Numerics; using System.Numerics;
using System.Runtime.CompilerServices; using System.Runtime.CompilerServices;
using SixLabors.ImageSharp.ColorSpaces;
namespace SixLabors.ImageSharp.ColorSpaces.Conversion.Implementation.LmsColorSapce namespace SixLabors.ImageSharp.ColorSpaces.Conversion.Implementation.LmsColorSapce
{ {
@ -63,8 +62,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion.Implementation.LmsColorSap
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public Lms Convert(CieXyz input) public Lms Convert(CieXyz input)
{ {
DebugGuard.NotNull(input, nameof(input));
Vector3 vector = Vector3.Transform(input.Vector, this.transformationMatrix); Vector3 vector = Vector3.Transform(input.Vector, this.transformationMatrix);
return new Lms(vector); return new Lms(vector);
} }
@ -73,8 +70,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion.Implementation.LmsColorSap
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public CieXyz Convert(Lms input) public CieXyz Convert(Lms input)
{ {
DebugGuard.NotNull(input, nameof(input));
Vector3 vector = Vector3.Transform(input.Vector, this.inverseTransformationMatrix); Vector3 vector = Vector3.Transform(input.Vector, this.inverseTransformationMatrix);
return new CieXyz(vector); return new CieXyz(vector);
} }

2
src/ImageSharp/ColorSpaces/Conversion/Implementation/Rgb/LCompanding.cs

@ -32,4 +32,4 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion.Implementation.RgbColorSap
: MathF.Pow(1.16F * channel, 0.3333333F) - 0.16F; : MathF.Pow(1.16F * channel, 0.3333333F) - 0.16F;
} }
} }
} }

5
src/ImageSharp/ColorSpaces/Conversion/Implementation/Rgb/LinearRgbAndCieXyzConverterBase.cs

@ -40,7 +40,7 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion.Implementation.RgbColorSap
const float Yb = 1; const float Yb = 1;
float mZb = (1 - xb - yb) / yb; float mZb = (1 - xb - yb) / yb;
Matrix4x4 xyzMatrix = new Matrix4x4 var xyzMatrix = new Matrix4x4
{ {
M11 = mXr, M21 = mXg, M31 = mXb, M11 = mXr, M21 = mXg, M31 = mXb,
M12 = Yr, M22 = Yg, M32 = Yb, M12 = Yr, M22 = Yg, M32 = Yb,
@ -48,8 +48,7 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion.Implementation.RgbColorSap
M44 = 1F M44 = 1F
}; };
Matrix4x4 inverseXyzMatrix; Matrix4x4.Invert(xyzMatrix, out Matrix4x4 inverseXyzMatrix);
Matrix4x4.Invert(xyzMatrix, out inverseXyzMatrix);
Vector3 vector = Vector3.Transform(workingSpace.WhitePoint.Vector, inverseXyzMatrix); Vector3 vector = Vector3.Transform(workingSpace.WhitePoint.Vector, inverseXyzMatrix);

2
src/ImageSharp/ColorSpaces/Conversion/Implementation/Rgb/RgbToLinearRgbConverter.cs

@ -13,8 +13,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion.Implementation.RgbColorSap
/// <inheritdoc/> /// <inheritdoc/>
public LinearRgb Convert(Rgb input) public LinearRgb Convert(Rgb input)
{ {
Guard.NotNull(input, nameof(input));
Vector3 vector = input.Vector; Vector3 vector = input.Vector;
vector.X = input.WorkingSpace.Companding.Expand(vector.X); vector.X = input.WorkingSpace.Companding.Expand(vector.X);
vector.Y = input.WorkingSpace.Companding.Expand(vector.Y); vector.Y = input.WorkingSpace.Companding.Expand(vector.Y);

1
src/ImageSharp/ColorSpaces/Conversion/Implementation/YCbCr/YCbCrAndRgbConverter.cs

@ -4,7 +4,6 @@
using System; using System;
using System.Numerics; using System.Numerics;
using System.Runtime.CompilerServices; using System.Runtime.CompilerServices;
using SixLabors.ImageSharp.ColorSpaces;
namespace SixLabors.ImageSharp.ColorSpaces.Conversion.Implementation.YCbCrColorSapce namespace SixLabors.ImageSharp.ColorSpaces.Conversion.Implementation.YCbCrColorSapce
{ {

5
src/ImageSharp/ColorSpaces/Conversion/VonKriesChromaticAdaptation.cs

@ -2,7 +2,6 @@
// Licensed under the Apache License, Version 2.0. // Licensed under the Apache License, Version 2.0.
using System.Numerics; using System.Numerics;
using SixLabors.ImageSharp.ColorSpaces;
using SixLabors.ImageSharp.ColorSpaces.Conversion.Implementation.LmsColorSapce; using SixLabors.ImageSharp.ColorSpaces.Conversion.Implementation.LmsColorSapce;
namespace SixLabors.ImageSharp.ColorSpaces.Conversion namespace SixLabors.ImageSharp.ColorSpaces.Conversion
@ -50,10 +49,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// <inheritdoc/> /// <inheritdoc/>
public CieXyz Transform(CieXyz sourceColor, CieXyz sourceWhitePoint, CieXyz targetWhitePoint) public CieXyz Transform(CieXyz sourceColor, CieXyz sourceWhitePoint, CieXyz targetWhitePoint)
{ {
Guard.NotNull(sourceColor, nameof(sourceColor));
Guard.NotNull(sourceWhitePoint, nameof(sourceWhitePoint));
Guard.NotNull(targetWhitePoint, nameof(targetWhitePoint));
if (sourceWhitePoint.Equals(targetWhitePoint)) if (sourceWhitePoint.Equals(targetWhitePoint))
{ {
return sourceColor; return sourceColor;

2
src/ImageSharp/ColorSpaces/Hsl.cs

@ -16,7 +16,7 @@ namespace SixLabors.ImageSharp.ColorSpaces
/// <summary> /// <summary>
/// Represents a <see cref="Hsl"/> that has H, S, and L values set to zero. /// Represents a <see cref="Hsl"/> that has H, S, and L values set to zero.
/// </summary> /// </summary>
public static readonly Hsl Empty = default(Hsl); public static readonly Hsl Empty = default;
/// <summary> /// <summary>
/// Max range used for clamping /// Max range used for clamping

2
src/ImageSharp/ColorSpaces/Hsv.cs

@ -18,7 +18,7 @@ namespace SixLabors.ImageSharp.ColorSpaces
/// <summary> /// <summary>
/// Represents a <see cref="Hsv"/> that has H, S, and V values set to zero. /// Represents a <see cref="Hsv"/> that has H, S, and V values set to zero.
/// </summary> /// </summary>
public static readonly Hsv Empty = default(Hsv); public static readonly Hsv Empty = default;
/// <summary> /// <summary>
/// Max range used for clamping /// Max range used for clamping

2
src/ImageSharp/ColorSpaces/HunterLab.cs

@ -23,7 +23,7 @@ namespace SixLabors.ImageSharp.ColorSpaces
/// <summary> /// <summary>
/// Represents a <see cref="HunterLab"/> that has L, A, B values set to zero. /// Represents a <see cref="HunterLab"/> that has L, A, B values set to zero.
/// </summary> /// </summary>
public static readonly HunterLab Empty = default(HunterLab); public static readonly HunterLab Empty = default;
/// <summary> /// <summary>
/// The backing vector for SIMD support. /// The backing vector for SIMD support.

2
src/ImageSharp/ColorSpaces/LinearRgb.cs

@ -16,7 +16,7 @@ namespace SixLabors.ImageSharp.ColorSpaces
/// <summary> /// <summary>
/// Represents a <see cref="LinearRgb"/> that has R, G, and B values set to zero. /// Represents a <see cref="LinearRgb"/> that has R, G, and B values set to zero.
/// </summary> /// </summary>
public static readonly LinearRgb Empty = default(LinearRgb); public static readonly LinearRgb Empty = default;
/// <summary> /// <summary>
/// The default LinearRgb working space /// The default LinearRgb working space

2
src/ImageSharp/ColorSpaces/Lms.cs

@ -18,7 +18,7 @@ namespace SixLabors.ImageSharp.ColorSpaces
/// <summary> /// <summary>
/// Represents a <see cref="Lms"/> that has L, M, and S values set to zero. /// Represents a <see cref="Lms"/> that has L, M, and S values set to zero.
/// </summary> /// </summary>
public static readonly Lms Empty = default(Lms); public static readonly Lms Empty = default;
/// <summary> /// <summary>
/// The backing vector for SIMD support. /// The backing vector for SIMD support.

2
src/ImageSharp/ColorSpaces/Rgb.cs

@ -18,7 +18,7 @@ namespace SixLabors.ImageSharp.ColorSpaces
/// <summary> /// <summary>
/// Represents a <see cref="Rgb"/> that has R, G, and B values set to zero. /// Represents a <see cref="Rgb"/> that has R, G, and B values set to zero.
/// </summary> /// </summary>
public static readonly Rgb Empty = default(Rgb); public static readonly Rgb Empty = default;
/// <summary> /// <summary>
/// The default rgb working space /// The default rgb working space

2
src/ImageSharp/ColorSpaces/YCbCr.cs

@ -18,7 +18,7 @@ namespace SixLabors.ImageSharp.ColorSpaces
/// <summary> /// <summary>
/// Represents a <see cref="YCbCr"/> that has Y, Cb, and Cr values set to zero. /// Represents a <see cref="YCbCr"/> that has Y, Cb, and Cr values set to zero.
/// </summary> /// </summary>
public static readonly YCbCr Empty = default(YCbCr); public static readonly YCbCr Empty = default;
/// <summary> /// <summary>
/// Vector which is used in clamping to the max value /// Vector which is used in clamping to the max value

7
src/ImageSharp/Common/Exceptions/ImageFormatException.cs

@ -11,13 +11,6 @@ namespace SixLabors.ImageSharp
/// </summary> /// </summary>
public sealed class ImageFormatException : Exception public sealed class ImageFormatException : Exception
{ {
/// <summary>
/// Initializes a new instance of the <see cref="ImageFormatException"/> class.
/// </summary>
public ImageFormatException()
{
}
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="ImageFormatException"/> class with the name of the /// Initializes a new instance of the <see cref="ImageFormatException"/> class with the name of the
/// parameter that causes this exception. /// parameter that causes this exception.

9
src/ImageSharp/Common/Exceptions/ImageProcessingException.cs

@ -10,13 +10,6 @@ namespace SixLabors.ImageSharp
/// </summary> /// </summary>
public sealed class ImageProcessingException : Exception public sealed class ImageProcessingException : Exception
{ {
/// <summary>
/// Initializes a new instance of the <see cref="ImageProcessingException"/> class.
/// </summary>
public ImageProcessingException()
{
}
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="ImageProcessingException"/> class with the name of the /// Initializes a new instance of the <see cref="ImageProcessingException"/> class with the name of the
/// parameter that causes this exception. /// parameter that causes this exception.
@ -39,4 +32,4 @@ namespace SixLabors.ImageSharp
{ {
} }
} }
} }

2
src/ImageSharp/Common/Helpers/ImageMaths.cs

@ -2,8 +2,6 @@
// Licensed under the Apache License, Version 2.0. // Licensed under the Apache License, Version 2.0.
using System; using System;
using System.Linq;
using System.Numerics;
using System.Runtime.CompilerServices; using System.Runtime.CompilerServices;
using SixLabors.ImageSharp.PixelFormats; using SixLabors.ImageSharp.PixelFormats;
using SixLabors.Primitives; using SixLabors.Primitives;

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

@ -90,4 +90,4 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
return this.Equals((IccCurveSegment)other); return this.Equals((IccCurveSegment)other);
} }
} }
} }

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

@ -7,7 +7,7 @@ using System.Linq;
namespace SixLabors.ImageSharp.MetaData.Profiles.Icc namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
{ {
/// <summary> /// <summary>
/// A one dimensional curve /// A one dimensional ICC curve.
/// </summary> /// </summary>
internal sealed class IccOneDimensionalCurve : IEquatable<IccOneDimensionalCurve> internal sealed class IccOneDimensionalCurve : IEquatable<IccOneDimensionalCurve>
{ {

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

@ -125,7 +125,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
/// <inheritdoc/> /// <inheritdoc/>
public bool Equals(IccParametricCurve other) public bool Equals(IccParametricCurve other)
{ {
if (ReferenceEquals(null, other)) if (other == null)
{ {
return false; return false;
} }
@ -148,7 +148,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
/// <inheritdoc/> /// <inheritdoc/>
public override bool Equals(object obj) public override bool Equals(object obj)
{ {
if (ReferenceEquals(null, obj)) if (obj == null)
{ {
return false; return false;
} }

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

@ -49,7 +49,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
/// <inheritdoc/> /// <inheritdoc/>
public bool Equals(IccResponseCurve other) public bool Equals(IccResponseCurve other)
{ {
if (ReferenceEquals(null, other)) if (other == null)
{ {
return false; return false;
} }
@ -67,7 +67,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
/// <inheritdoc /> /// <inheritdoc />
public override bool Equals(object obj) public override bool Equals(object obj)
{ {
if (ReferenceEquals(null, obj)) if (obj == null)
{ {
return false; return false;
} }
@ -86,8 +86,8 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
unchecked unchecked
{ {
int hashCode = (int)this.CurveType; int hashCode = (int)this.CurveType;
hashCode = (hashCode * 397) ^ (this.XyzValues != null ? this.XyzValues.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (this.XyzValues?.GetHashCode() ?? 0);
hashCode = (hashCode * 397) ^ (this.ResponseArrays != null ? this.ResponseArrays.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (this.ResponseArrays?.GetHashCode() ?? 0);
return hashCode; return hashCode;
} }
} }

2
src/ImageSharp/MetaData/Profiles/ICC/DataReader/IccDataReader.Curves.cs

@ -191,7 +191,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
/// <returns>The curve data</returns> /// <returns>The curve data</returns>
private IccTagDataEntry[] ReadCurves(int count) private IccTagDataEntry[] ReadCurves(int count)
{ {
IccTagDataEntry[] tdata = new IccTagDataEntry[count]; var tdata = new IccTagDataEntry[count];
for (int i = 0; i < count; i++) for (int i = 0; i < count; i++)
{ {
IccTypeSignature type = this.ReadTagDataEntryHeader(); IccTypeSignature type = this.ReadTagDataEntryHeader();

31
src/ImageSharp/MetaData/Profiles/ICC/DataReader/IccDataReader.Primitives.cs

@ -67,7 +67,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
} }
/// <summary> /// <summary>
/// Reads a float /// Reads a float.
/// </summary> /// </summary>
/// <returns>the value</returns> /// <returns>the value</returns>
public unsafe float ReadSingle() public unsafe float ReadSingle()
@ -89,7 +89,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
} }
/// <summary> /// <summary>
/// Reads an ASCII encoded string /// Reads an ASCII encoded string.
/// </summary> /// </summary>
/// <param name="length">number of bytes to read</param> /// <param name="length">number of bytes to read</param>
/// <returns>The value as a string</returns> /// <returns>The value as a string</returns>
@ -114,7 +114,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
} }
/// <summary> /// <summary>
/// Reads an UTF-16 big-endian encoded string /// Reads an UTF-16 big-endian encoded string.
/// </summary> /// </summary>
/// <param name="length">number of bytes to read</param> /// <param name="length">number of bytes to read</param>
/// <returns>The value as a string</returns> /// <returns>The value as a string</returns>
@ -131,34 +131,25 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
} }
/// <summary> /// <summary>
/// Reads a signed 32bit number with 1 sign bit, 15 value bits and 16 fractional bits /// Reads a signed 32bit number with 1 sign bit, 15 value bits and 16 fractional bits.
/// </summary> /// </summary>
/// <returns>The number as double</returns> /// <returns>The number as double</returns>
public float ReadFix16() public float ReadFix16() => this.ReadInt32() / 65536f;
{
return this.ReadInt32() / 65536f;
}
/// <summary> /// <summary>
/// Reads an unsigned 32bit number with 16 value bits and 16 fractional bits /// Reads an unsigned 32bit number with 16 value bits and 16 fractional bits.
/// </summary> /// </summary>
/// <returns>The number as double</returns> /// <returns>The number as double</returns>
public float ReadUFix16() public float ReadUFix16() => this.ReadUInt32() / 65536f;
{
return this.ReadUInt32() / 65536f;
}
/// <summary> /// <summary>
/// Reads an unsigned 16bit number with 1 value bit and 15 fractional bits /// Reads an unsigned 16bit number with 1 value bit and 15 fractional bits.
/// </summary> /// </summary>
/// <returns>The number as double</returns> /// <returns>The number as double</returns>
public float ReadU1Fix15() public float ReadU1Fix15() => this.ReadUInt16() / 32768f;
{
return this.ReadUInt16() / 32768f;
}
/// <summary> /// <summary>
/// Reads an unsigned 16bit number with 8 value bits and 8 fractional bits /// Reads an unsigned 16bit number with 8 value bits and 8 fractional bits.
/// </summary> /// </summary>
/// <returns>The number as double</returns> /// <returns>The number as double</returns>
public float ReadUFix8() public float ReadUFix8()
@ -167,7 +158,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
} }
/// <summary> /// <summary>
/// Reads a number of bytes and advances the index /// Reads a number of bytes and advances the index.
/// </summary> /// </summary>
/// <param name="count">The number of bytes to read</param> /// <param name="count">The number of bytes to read</param>
/// <returns>The read bytes</returns> /// <returns>The read bytes</returns>

34
src/ImageSharp/MetaData/Profiles/ICC/DataReader/IccDataReader.TagDataEntry.cs

@ -183,7 +183,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
public IccColorantTableTagDataEntry ReadColorantTableTagDataEntry() public IccColorantTableTagDataEntry ReadColorantTableTagDataEntry()
{ {
uint colorantCount = this.ReadUInt32(); uint colorantCount = this.ReadUInt32();
IccColorantTableEntry[] cdata = new IccColorantTableEntry[colorantCount]; var cdata = new IccColorantTableEntry[colorantCount];
for (int i = 0; i < colorantCount; i++) for (int i = 0; i < colorantCount; i++)
{ {
cdata[i] = this.ReadColorantTableEntry(); cdata[i] = this.ReadColorantTableEntry();
@ -265,7 +265,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
ushort outTableCount = this.ReadUInt16(); ushort outTableCount = this.ReadUInt16();
// Input LUT // Input LUT
IccLut[] inValues = new IccLut[inChCount]; var inValues = new IccLut[inChCount];
byte[] gridPointCount = new byte[inChCount]; byte[] gridPointCount = new byte[inChCount];
for (int i = 0; i < inChCount; i++) for (int i = 0; i < inChCount; i++)
{ {
@ -277,7 +277,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
IccClut clut = this.ReadClut16(inChCount, outChCount, gridPointCount); IccClut clut = this.ReadClut16(inChCount, outChCount, gridPointCount);
// Output LUT // Output LUT
IccLut[] outValues = new IccLut[outChCount]; var outValues = new IccLut[outChCount];
for (int i = 0; i < outChCount; i++) for (int i = 0; i < outChCount; i++)
{ {
outValues[i] = this.ReadLut16(outTableCount); outValues[i] = this.ReadLut16(outTableCount);
@ -300,7 +300,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
float[,] matrix = this.ReadMatrix(3, 3, false); float[,] matrix = this.ReadMatrix(3, 3, false);
// Input LUT // Input LUT
IccLut[] inValues = new IccLut[inChCount]; var inValues = new IccLut[inChCount];
byte[] gridPointCount = new byte[inChCount]; byte[] gridPointCount = new byte[inChCount];
for (int i = 0; i < inChCount; i++) for (int i = 0; i < inChCount; i++)
{ {
@ -312,7 +312,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
IccClut clut = this.ReadClut8(inChCount, outChCount, gridPointCount); IccClut clut = this.ReadClut8(inChCount, outChCount, gridPointCount);
// Output LUT // Output LUT
IccLut[] outValues = new IccLut[outChCount]; var outValues = new IccLut[outChCount];
for (int i = 0; i < outChCount; i++) for (int i = 0; i < outChCount; i++)
{ {
outValues[i] = this.ReadLut8(); outValues[i] = this.ReadLut8();
@ -463,9 +463,9 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
uint recordCount = this.ReadUInt32(); uint recordCount = this.ReadUInt32();
this.ReadUInt32(); // Record size (always 12) this.ReadUInt32(); // Record size (always 12)
IccLocalizedString[] text = new IccLocalizedString[recordCount]; var text = new IccLocalizedString[recordCount];
CultureInfo[] culture = new CultureInfo[recordCount]; var culture = new CultureInfo[recordCount];
uint[] length = new uint[recordCount]; uint[] length = new uint[recordCount];
uint[] offset = new uint[recordCount]; uint[] offset = new uint[recordCount];
@ -531,13 +531,13 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
ushort outChannelCount = this.ReadUInt16(); ushort outChannelCount = this.ReadUInt16();
uint elementCount = this.ReadUInt32(); uint elementCount = this.ReadUInt32();
IccPositionNumber[] positionTable = new IccPositionNumber[elementCount]; var positionTable = new IccPositionNumber[elementCount];
for (int i = 0; i < elementCount; i++) for (int i = 0; i < elementCount; i++)
{ {
positionTable[i] = this.ReadPositionNumber(); positionTable[i] = this.ReadPositionNumber();
} }
IccMultiProcessElement[] elements = new IccMultiProcessElement[elementCount]; var elements = new IccMultiProcessElement[elementCount];
for (int i = 0; i < elementCount; i++) for (int i = 0; i < elementCount; i++)
{ {
this.currentIndex = (int)positionTable[i].Offset + start; this.currentIndex = (int)positionTable[i].Offset + start;
@ -559,7 +559,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
string prefix = this.ReadAsciiString(32); string prefix = this.ReadAsciiString(32);
string suffix = this.ReadAsciiString(32); string suffix = this.ReadAsciiString(32);
IccNamedColor[] colors = new IccNamedColor[colorCount]; var colors = new IccNamedColor[colorCount];
for (int i = 0; i < colorCount; i++) for (int i = 0; i < colorCount; i++)
{ {
colors[i] = this.ReadNamedColor(coordCount); colors[i] = this.ReadNamedColor(coordCount);
@ -584,7 +584,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
public IccProfileSequenceDescTagDataEntry ReadProfileSequenceDescTagDataEntry() public IccProfileSequenceDescTagDataEntry ReadProfileSequenceDescTagDataEntry()
{ {
uint count = this.ReadUInt32(); uint count = this.ReadUInt32();
IccProfileDescription[] description = new IccProfileDescription[count]; var description = new IccProfileDescription[count];
for (int i = 0; i < count; i++) for (int i = 0; i < count; i++)
{ {
description[i] = this.ReadProfileDescription(); description[i] = this.ReadProfileDescription();
@ -601,13 +601,13 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
{ {
int start = this.currentIndex - 8; // 8 is the tag header size int start = this.currentIndex - 8; // 8 is the tag header size
uint count = this.ReadUInt32(); uint count = this.ReadUInt32();
IccPositionNumber[] table = new IccPositionNumber[count]; var table = new IccPositionNumber[count];
for (int i = 0; i < count; i++) for (int i = 0; i < count; i++)
{ {
table[i] = this.ReadPositionNumber(); table[i] = this.ReadPositionNumber();
} }
IccProfileSequenceIdentifier[] entries = new IccProfileSequenceIdentifier[count]; var entries = new IccProfileSequenceIdentifier[count];
for (int i = 0; i < count; i++) for (int i = 0; i < count; i++)
{ {
this.currentIndex = (int)(start + table[i].Offset); this.currentIndex = (int)(start + table[i].Offset);
@ -636,7 +636,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
offset[i] = this.ReadUInt32(); offset[i] = this.ReadUInt32();
} }
IccResponseCurve[] curves = new IccResponseCurve[measurmentCount]; var curves = new IccResponseCurve[measurmentCount];
for (int i = 0; i < measurmentCount; i++) for (int i = 0; i < measurmentCount; i++)
{ {
this.currentIndex = (int)(start + offset[i]); this.currentIndex = (int)(start + offset[i]);
@ -783,7 +783,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
public IccXyzTagDataEntry ReadXyzTagDataEntry(uint size) public IccXyzTagDataEntry ReadXyzTagDataEntry(uint size)
{ {
uint count = (size - 8) / 12; uint count = (size - 8) / 12;
Vector3[] arrayData = new Vector3[count]; var arrayData = new Vector3[count];
for (int i = 0; i < count; i++) for (int i = 0; i < count; i++)
{ {
arrayData[i] = this.ReadXyzNumber(); arrayData[i] = this.ReadXyzNumber();
@ -864,7 +864,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
{ {
var flags = (IccScreeningFlag)this.ReadInt32(); var flags = (IccScreeningFlag)this.ReadInt32();
uint channelCount = this.ReadUInt32(); uint channelCount = this.ReadUInt32();
IccScreeningChannel[] channels = new IccScreeningChannel[channelCount]; var channels = new IccScreeningChannel[channelCount];
for (int i = 0; i < channels.Length; i++) for (int i = 0; i < channels.Length; i++)
{ {
channels[i] = this.ReadScreeningChannel(); channels[i] = this.ReadScreeningChannel();
@ -902,4 +902,4 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
return new IccUcrBgTagDataEntry(ucrCurve, bgCurve, description); return new IccUcrBgTagDataEntry(ucrCurve, bgCurve, description);
} }
} }
} }

18
src/ImageSharp/MetaData/Profiles/ICC/DataWriter/IccDataWriter.TagDataEntry.cs

@ -206,8 +206,11 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
public int WriteColorantTableTagDataEntry(IccColorantTableTagDataEntry value) public int WriteColorantTableTagDataEntry(IccColorantTableTagDataEntry value)
{ {
int count = this.WriteUInt32((uint)value.ColorantData.Length); int count = this.WriteUInt32((uint)value.ColorantData.Length);
foreach (IccColorantTableEntry colorant in value.ColorantData)
for (int i = 0; i < value.ColorantData.Length; i++)
{ {
ref IccColorantTableEntry colorant = ref value.ColorantData[i];
count += this.WriteAsciiString(colorant.Name, 32, true); count += this.WriteAsciiString(colorant.Name, 32, true);
count += this.WriteUInt16(colorant.Pcs1); count += this.WriteUInt16(colorant.Pcs1);
count += this.WriteUInt16(colorant.Pcs2); count += this.WriteUInt16(colorant.Pcs2);
@ -683,8 +686,11 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
public int WriteProfileSequenceDescTagDataEntry(IccProfileSequenceDescTagDataEntry value) public int WriteProfileSequenceDescTagDataEntry(IccProfileSequenceDescTagDataEntry value)
{ {
int count = this.WriteUInt32((uint)value.Descriptions.Length); int count = this.WriteUInt32((uint)value.Descriptions.Length);
foreach (IccProfileDescription desc in value.Descriptions)
for (int i = 0; i < value.Descriptions.Length; i++)
{ {
ref IccProfileDescription desc = ref value.Descriptions[i];
count += this.WriteProfileDescription(desc); count += this.WriteProfileDescription(desc);
} }
@ -706,13 +712,15 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
// Jump over position table // Jump over position table
long tablePosition = this.dataStream.Position; long tablePosition = this.dataStream.Position;
this.dataStream.Position += length * 8; this.dataStream.Position += length * 8;
IccPositionNumber[] table = new IccPositionNumber[length]; var table = new IccPositionNumber[length];
for (int i = 0; i < length; i++) for (int i = 0; i < length; i++)
{ {
ref IccProfileSequenceIdentifier sequenceIdentifier = ref value.Data[i];
uint offset = (uint)(this.dataStream.Position - start); uint offset = (uint)(this.dataStream.Position - start);
int size = this.WriteProfileId(value.Data[i].Id); int size = this.WriteProfileId(sequenceIdentifier.Id);
size += this.WriteTagDataEntry(new IccMultiLocalizedUnicodeTagDataEntry(value.Data[i].Description)); size += this.WriteTagDataEntry(new IccMultiLocalizedUnicodeTagDataEntry(sequenceIdentifier.Description));
size += this.WritePadding(); size += this.WritePadding();
table[i] = new IccPositionNumber(offset, (uint)size); table[i] = new IccPositionNumber(offset, (uint)size);
count += size; count += size;

9
src/ImageSharp/MetaData/Profiles/ICC/Exceptions/InvalidIccProfileException.cs

@ -10,13 +10,6 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
/// </summary> /// </summary>
public class InvalidIccProfileException : Exception public class InvalidIccProfileException : Exception
{ {
/// <summary>
/// Initializes a new instance of the <see cref="InvalidIccProfileException"/> class.
/// </summary>
public InvalidIccProfileException()
{
}
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="InvalidIccProfileException"/> class. /// Initializes a new instance of the <see cref="InvalidIccProfileException"/> class.
/// </summary> /// </summary>
@ -37,4 +30,4 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
{ {
} }
} }
} }

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

@ -84,7 +84,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
private IccTagDataEntry[] ReadTagData(IccDataReader reader) private IccTagDataEntry[] ReadTagData(IccDataReader reader)
{ {
IccTagTableEntry[] tagTable = this.ReadTagTable(reader); IccTagTableEntry[] tagTable = this.ReadTagTable(reader);
IccTagDataEntry[] entries = new IccTagDataEntry[tagTable.Length]; var entries = new IccTagDataEntry[tagTable.Length];
var store = new Dictionary<uint, IccTagDataEntry>(); var store = new Dictionary<uint, IccTagDataEntry>();
for (int i = 0; i < tagTable.Length; i++) for (int i = 0; i < tagTable.Length; i++)
{ {
@ -112,7 +112,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
reader.SetIndex(128); // An ICC header is 128 bytes long reader.SetIndex(128); // An ICC header is 128 bytes long
uint tagCount = reader.ReadUInt32(); uint tagCount = reader.ReadUInt32();
IccTagTableEntry[] table = new IccTagTableEntry[tagCount]; var table = new IccTagTableEntry[tagCount];
for (int i = 0; i < tagCount; i++) for (int i = 0; i < tagCount; i++)
{ {

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

@ -44,7 +44,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
/// <inheritdoc/> /// <inheritdoc/>
public override bool Equals(object obj) public override bool Equals(object obj)
{ {
if (ReferenceEquals(null, obj)) if (obj == null)
{ {
return false; return false;
} }
@ -54,8 +54,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
return true; return true;
} }
var entry = obj as IccTagDataEntry; return obj is IccTagDataEntry entry && this.Equals(entry);
return entry != null && this.Equals(entry);
} }
/// <inheritdoc/> /// <inheritdoc/>
@ -70,7 +69,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
/// <inheritdoc/> /// <inheritdoc/>
public virtual bool Equals(IccTagDataEntry other) public virtual bool Equals(IccTagDataEntry other)
{ {
if (ReferenceEquals(null, other)) if (other == null)
{ {
return false; return false;
} }

2
src/ImageSharp/MetaData/Profiles/ICC/MultiProcessElements/IccCurveSetProcessElement.cs

@ -44,4 +44,4 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
return this.Equals((IccMultiProcessElement)other); return this.Equals((IccMultiProcessElement)other);
} }
} }
} }

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

@ -27,7 +27,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
} }
/// <summary> /// <summary>
/// Gets the signature of this element /// Gets the signature of this element,
/// </summary> /// </summary>
public IccMultiProcessElementSignature Signature { get; } public IccMultiProcessElementSignature Signature { get; }
@ -37,7 +37,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
public int InputChannelCount { get; } public int InputChannelCount { get; }
/// <summary> /// <summary>
/// Gets the number of output channels /// Gets the number of output channels.
/// </summary> /// </summary>
public int OutputChannelCount { get; } public int OutputChannelCount { get; }

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

@ -82,8 +82,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
/// <inheritdoc/> /// <inheritdoc/>
public override bool Equals(IccTagDataEntry other) public override bool Equals(IccTagDataEntry other)
{ {
var entry = other as IccChromaticityTagDataEntry; return other is IccChromaticityTagDataEntry entry && this.Equals(entry);
return entry != null && this.Equals(entry);
} }
/// <inheritdoc/> /// <inheritdoc/>
@ -105,7 +104,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
/// <inheritdoc/> /// <inheritdoc/>
public override bool Equals(object obj) public override bool Equals(object obj)
{ {
if (ReferenceEquals(null, obj)) if (obj == null)
{ {
return false; return false;
} }
@ -125,7 +124,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
{ {
int hashCode = base.GetHashCode(); int hashCode = base.GetHashCode();
hashCode = (hashCode * 397) ^ (int)this.ColorantType; hashCode = (hashCode * 397) ^ (int)this.ColorantType;
hashCode = (hashCode * 397) ^ (this.ChannelValues != null ? this.ChannelValues.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (this.ChannelValues?.GetHashCode() ?? 0);
return hashCode; return hashCode;
} }
} }

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

@ -43,14 +43,13 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
/// <inheritdoc/> /// <inheritdoc/>
public override bool Equals(IccTagDataEntry other) public override bool Equals(IccTagDataEntry other)
{ {
var entry = other as IccColorantOrderTagDataEntry; return other is IccColorantOrderTagDataEntry entry && this.Equals(entry);
return entry != null && this.Equals(entry);
} }
/// <inheritdoc/> /// <inheritdoc/>
public bool Equals(IccColorantOrderTagDataEntry other) public bool Equals(IccColorantOrderTagDataEntry other)
{ {
if (ReferenceEquals(null, other)) if (other == null)
{ {
return false; return false;
} }
@ -66,7 +65,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
/// <inheritdoc/> /// <inheritdoc/>
public override bool Equals(object obj) public override bool Equals(object obj)
{ {
if (ReferenceEquals(null, obj)) if (obj == null)
{ {
return false; return false;
} }
@ -76,7 +75,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
return true; return true;
} }
return obj is IccColorantOrderTagDataEntry && this.Equals((IccColorantOrderTagDataEntry)obj); return obj is IccColorantOrderTagDataEntry other && this.Equals(other);
} }
/// <inheritdoc/> /// <inheritdoc/>
@ -84,7 +83,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
{ {
unchecked unchecked
{ {
return (base.GetHashCode() * 397) ^ (this.ColorantNumber != null ? this.ColorantNumber.GetHashCode() : 0); return (base.GetHashCode() * 397) ^ (this.ColorantNumber?.GetHashCode() ?? 0);
} }
} }
} }

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

@ -44,14 +44,13 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
/// <inheritdoc/> /// <inheritdoc/>
public override bool Equals(IccTagDataEntry other) public override bool Equals(IccTagDataEntry other)
{ {
var entry = other as IccColorantTableTagDataEntry; return other is IccColorantTableTagDataEntry entry && this.Equals(entry);
return entry != null && this.Equals(entry);
} }
/// <inheritdoc/> /// <inheritdoc/>
public bool Equals(IccColorantTableTagDataEntry other) public bool Equals(IccColorantTableTagDataEntry other)
{ {
if (ReferenceEquals(null, other)) if (other == null)
{ {
return false; return false;
} }
@ -67,7 +66,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
/// <inheritdoc/> /// <inheritdoc/>
public override bool Equals(object obj) public override bool Equals(object obj)
{ {
if (ReferenceEquals(null, obj)) if (obj == null)
{ {
return false; return false;
} }
@ -77,7 +76,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
return true; return true;
} }
return obj is IccColorantTableTagDataEntry && this.Equals((IccColorantTableTagDataEntry)obj); return obj is IccColorantTableTagDataEntry other && this.Equals(other);
} }
/// <inheritdoc/> /// <inheritdoc/>
@ -85,7 +84,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
{ {
unchecked unchecked
{ {
return (base.GetHashCode() * 397) ^ (this.ColorantData != null ? this.ColorantData.GetHashCode() : 0); return (base.GetHashCode() * 397) ^ (this.ColorantData?.GetHashCode() ?? 0);
} }
} }
} }

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

@ -88,14 +88,13 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
/// <inheritdoc/> /// <inheritdoc/>
public override bool Equals(IccTagDataEntry other) public override bool Equals(IccTagDataEntry other)
{ {
var entry = other as IccCrdInfoTagDataEntry; return other is IccCrdInfoTagDataEntry entry && this.Equals(entry);
return entry != null && this.Equals(entry);
} }
/// <inheritdoc/> /// <inheritdoc/>
public bool Equals(IccCrdInfoTagDataEntry other) public bool Equals(IccCrdInfoTagDataEntry other)
{ {
if (ReferenceEquals(null, other)) if (other == null)
{ {
return false; return false;
} }
@ -116,7 +115,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
/// <inheritdoc/> /// <inheritdoc/>
public override bool Equals(object obj) public override bool Equals(object obj)
{ {
if (ReferenceEquals(null, obj)) if (obj == null)
{ {
return false; return false;
} }
@ -126,7 +125,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
return true; return true;
} }
return obj is IccCrdInfoTagDataEntry && this.Equals((IccCrdInfoTagDataEntry)obj); return obj is IccCrdInfoTagDataEntry other && this.Equals(other);
} }
/// <inheritdoc/> /// <inheritdoc/>
@ -135,11 +134,11 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
unchecked unchecked
{ {
int hashCode = base.GetHashCode(); int hashCode = base.GetHashCode();
hashCode = (hashCode * 397) ^ (this.PostScriptProductName != null ? this.PostScriptProductName.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (this.PostScriptProductName?.GetHashCode() ?? 0);
hashCode = (hashCode * 397) ^ (this.RenderingIntent0Crd != null ? this.RenderingIntent0Crd.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (this.RenderingIntent0Crd?.GetHashCode() ?? 0);
hashCode = (hashCode * 397) ^ (this.RenderingIntent1Crd != null ? this.RenderingIntent1Crd.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (this.RenderingIntent1Crd?.GetHashCode() ?? 0);
hashCode = (hashCode * 397) ^ (this.RenderingIntent2Crd != null ? this.RenderingIntent2Crd.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (this.RenderingIntent2Crd?.GetHashCode() ?? 0);
hashCode = (hashCode * 397) ^ (this.RenderingIntent3Crd != null ? this.RenderingIntent3Crd.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (this.RenderingIntent3Crd?.GetHashCode() ?? 0);
return hashCode; return hashCode;
} }
} }

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

@ -79,26 +79,25 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
public float Gamma => this.IsGamma ? this.CurveData[0] : 0; public float Gamma => this.IsGamma ? this.CurveData[0] : 0;
/// <summary> /// <summary>
/// Gets a value indicating whether the curve maps input directly to output /// Gets a value indicating whether the curve maps input directly to output.
/// </summary> /// </summary>
public bool IsIdentityResponse => this.CurveData.Length == 0; public bool IsIdentityResponse => this.CurveData.Length == 0;
/// <summary> /// <summary>
/// Gets a value indicating whether the curve is a gamma curve /// Gets a value indicating whether the curve is a gamma curve.
/// </summary> /// </summary>
public bool IsGamma => this.CurveData.Length == 1; public bool IsGamma => this.CurveData.Length == 1;
/// <inheritdoc/> /// <inheritdoc/>
public override bool Equals(IccTagDataEntry other) public override bool Equals(IccTagDataEntry other)
{ {
var entry = other as IccCurveTagDataEntry; return other is IccCurveTagDataEntry entry && this.Equals(entry);
return entry != null && this.Equals(entry);
} }
/// <inheritdoc/> /// <inheritdoc/>
public bool Equals(IccCurveTagDataEntry other) public bool Equals(IccCurveTagDataEntry other)
{ {
if (ReferenceEquals(null, other)) if (other == null)
{ {
return false; return false;
} }
@ -114,7 +113,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
/// <inheritdoc/> /// <inheritdoc/>
public override bool Equals(object obj) public override bool Equals(object obj)
{ {
if (ReferenceEquals(null, obj)) if (obj == null)
{ {
return false; return false;
} }
@ -124,7 +123,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
return true; return true;
} }
return obj is IccCurveTagDataEntry && this.Equals((IccCurveTagDataEntry)obj); return obj is IccCurveTagDataEntry other && this.Equals(other);
} }
/// <inheritdoc/> /// <inheritdoc/>
@ -132,7 +131,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
{ {
unchecked unchecked
{ {
return (base.GetHashCode() * 397) ^ (this.CurveData != null ? this.CurveData.GetHashCode() : 0); return (base.GetHashCode() * 397) ^ (this.CurveData?.GetHashCode() ?? 0);
} }
} }
} }

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

@ -67,14 +67,13 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
/// <inheritdoc/> /// <inheritdoc/>
public override bool Equals(IccTagDataEntry other) public override bool Equals(IccTagDataEntry other)
{ {
var entry = other as IccDataTagDataEntry; return other is IccDataTagDataEntry entry && this.Equals(entry);
return entry != null && this.Equals(entry);
} }
/// <inheritdoc/> /// <inheritdoc/>
public bool Equals(IccDataTagDataEntry other) public bool Equals(IccDataTagDataEntry other)
{ {
if (ReferenceEquals(null, other)) if (other == null)
{ {
return false; return false;
} }
@ -90,7 +89,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
/// <inheritdoc/> /// <inheritdoc/>
public override bool Equals(object obj) public override bool Equals(object obj)
{ {
if (ReferenceEquals(null, obj)) if (obj == null)
{ {
return false; return false;
} }
@ -100,7 +99,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
return true; return true;
} }
return obj is IccDataTagDataEntry && this.Equals((IccDataTagDataEntry)obj); return obj is IccDataTagDataEntry other && this.Equals(other);
} }
/// <inheritdoc/> /// <inheritdoc/>
@ -109,7 +108,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
unchecked unchecked
{ {
int hashCode = base.GetHashCode(); int hashCode = base.GetHashCode();
hashCode = (hashCode * 397) ^ (this.Data != null ? this.Data.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (this.Data?.GetHashCode() ?? 0);
hashCode = (hashCode * 397) ^ this.IsAscii.GetHashCode(); hashCode = (hashCode * 397) ^ this.IsAscii.GetHashCode();
return hashCode; return hashCode;
} }

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

@ -38,14 +38,13 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
/// <inheritdoc/> /// <inheritdoc/>
public override bool Equals(IccTagDataEntry other) public override bool Equals(IccTagDataEntry other)
{ {
var entry = other as IccDateTimeTagDataEntry; return other is IccDateTimeTagDataEntry entry && this.Equals(entry);
return entry != null && this.Equals(entry);
} }
/// <inheritdoc/> /// <inheritdoc/>
public bool Equals(IccDateTimeTagDataEntry other) public bool Equals(IccDateTimeTagDataEntry other)
{ {
if (ReferenceEquals(null, other)) if (other == null)
{ {
return false; return false;
} }
@ -61,7 +60,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
/// <inheritdoc/> /// <inheritdoc/>
public override bool Equals(object obj) public override bool Equals(object obj)
{ {
if (ReferenceEquals(null, obj)) if (obj == null)
{ {
return false; return false;
} }

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

@ -40,14 +40,13 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
/// <inheritdoc/> /// <inheritdoc/>
public override bool Equals(IccTagDataEntry other) public override bool Equals(IccTagDataEntry other)
{ {
var entry = other as IccFix16ArrayTagDataEntry; return other is IccFix16ArrayTagDataEntry entry && this.Equals(entry);
return entry != null && this.Equals(entry);
} }
/// <inheritdoc/> /// <inheritdoc/>
public bool Equals(IccFix16ArrayTagDataEntry other) public bool Equals(IccFix16ArrayTagDataEntry other)
{ {
if (ReferenceEquals(null, other)) if (other == null)
{ {
return false; return false;
} }
@ -63,7 +62,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
/// <inheritdoc/> /// <inheritdoc/>
public override bool Equals(object obj) public override bool Equals(object obj)
{ {
if (ReferenceEquals(null, obj)) if (obj == null)
{ {
return false; return false;
} }
@ -73,7 +72,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
return true; return true;
} }
return obj is IccFix16ArrayTagDataEntry && this.Equals((IccFix16ArrayTagDataEntry)obj); return obj is IccFix16ArrayTagDataEntry other && this.Equals(other);
} }
/// <inheritdoc/> /// <inheritdoc/>
@ -81,7 +80,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
{ {
unchecked unchecked
{ {
return (base.GetHashCode() * 397) ^ (this.Data != null ? this.Data.GetHashCode() : 0); return (base.GetHashCode() * 397) ^ (this.Data?.GetHashCode() ?? 0);
} }
} }
} }

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

@ -111,14 +111,13 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
/// <inheritdoc/> /// <inheritdoc/>
public override bool Equals(IccTagDataEntry other) public override bool Equals(IccTagDataEntry other)
{ {
var entry = other as IccLut16TagDataEntry; return other is IccLut16TagDataEntry entry && this.Equals(entry);
return entry != null && this.Equals(entry);
} }
/// <inheritdoc/> /// <inheritdoc/>
public bool Equals(IccLut16TagDataEntry other) public bool Equals(IccLut16TagDataEntry other)
{ {
if (ReferenceEquals(null, other)) if (other == null)
{ {
return false; return false;
} }
@ -138,7 +137,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
/// <inheritdoc/> /// <inheritdoc/>
public override bool Equals(object obj) public override bool Equals(object obj)
{ {
if (ReferenceEquals(null, obj)) if (obj == null)
{ {
return false; return false;
} }
@ -158,9 +157,9 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
{ {
int hashCode = base.GetHashCode(); int hashCode = base.GetHashCode();
hashCode = (hashCode * 397) ^ this.Matrix.GetHashCode(); hashCode = (hashCode * 397) ^ this.Matrix.GetHashCode();
hashCode = (hashCode * 397) ^ (this.InputValues != null ? this.InputValues.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (this.InputValues?.GetHashCode() ?? 0);
hashCode = (hashCode * 397) ^ (this.ClutValues != null ? this.ClutValues.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (this.ClutValues?.GetHashCode() ?? 0);
hashCode = (hashCode * 397) ^ (this.OutputValues != null ? this.OutputValues.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (this.OutputValues?.GetHashCode() ?? 0);
return hashCode; return hashCode;
} }
} }

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

@ -114,14 +114,13 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
/// <inheritdoc/> /// <inheritdoc/>
public override bool Equals(IccTagDataEntry other) public override bool Equals(IccTagDataEntry other)
{ {
var entry = other as IccLut8TagDataEntry; return other is IccLut8TagDataEntry entry && this.Equals(entry);
return entry != null && this.Equals(entry);
} }
/// <inheritdoc/> /// <inheritdoc/>
public bool Equals(IccLut8TagDataEntry other) public bool Equals(IccLut8TagDataEntry other)
{ {
if (ReferenceEquals(null, other)) if (other == null)
{ {
return false; return false;
} }
@ -141,7 +140,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
/// <inheritdoc/> /// <inheritdoc/>
public override bool Equals(object obj) public override bool Equals(object obj)
{ {
if (ReferenceEquals(null, obj)) if (obj == null)
{ {
return false; return false;
} }
@ -161,9 +160,9 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
{ {
int hashCode = base.GetHashCode(); int hashCode = base.GetHashCode();
hashCode = (hashCode * 397) ^ this.Matrix.GetHashCode(); hashCode = (hashCode * 397) ^ this.Matrix.GetHashCode();
hashCode = (hashCode * 397) ^ (this.InputValues != null ? this.InputValues.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (this.InputValues?.GetHashCode() ?? 0);
hashCode = (hashCode * 397) ^ (this.ClutValues != null ? this.ClutValues.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (this.ClutValues?.GetHashCode() ?? 0);
hashCode = (hashCode * 397) ^ (this.OutputValues != null ? this.OutputValues.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (this.OutputValues?.GetHashCode() ?? 0);
return hashCode; return hashCode;
} }
} }

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

@ -147,14 +147,13 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
/// <inheritdoc/> /// <inheritdoc/>
public override bool Equals(IccTagDataEntry other) public override bool Equals(IccTagDataEntry other)
{ {
var entry = other as IccLutAToBTagDataEntry; return other is IccLutAToBTagDataEntry entry && this.Equals(entry);
return entry != null && this.Equals(entry);
} }
/// <inheritdoc/> /// <inheritdoc/>
public bool Equals(IccLutAToBTagDataEntry other) public bool Equals(IccLutAToBTagDataEntry other)
{ {
if (ReferenceEquals(null, other)) if (other == null)
{ {
return false; return false;
} }
@ -178,7 +177,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
/// <inheritdoc/> /// <inheritdoc/>
public override bool Equals(object obj) public override bool Equals(object obj)
{ {
if (ReferenceEquals(null, obj)) if (obj == null)
{ {
return false; return false;
} }
@ -188,7 +187,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
return true; return true;
} }
return obj is IccLutAToBTagDataEntry && this.Equals((IccLutAToBTagDataEntry)obj); return obj is IccLutAToBTagDataEntry other && this.Equals(other);
} }
/// <inheritdoc/> /// <inheritdoc/>
@ -201,10 +200,10 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
hashCode = (hashCode * 397) ^ this.OutputChannelCount; hashCode = (hashCode * 397) ^ this.OutputChannelCount;
hashCode = (hashCode * 397) ^ this.Matrix3x3.GetHashCode(); hashCode = (hashCode * 397) ^ this.Matrix3x3.GetHashCode();
hashCode = (hashCode * 397) ^ this.Matrix3x1.GetHashCode(); hashCode = (hashCode * 397) ^ this.Matrix3x1.GetHashCode();
hashCode = (hashCode * 397) ^ (this.ClutValues != null ? this.ClutValues.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (this.ClutValues?.GetHashCode() ?? 0);
hashCode = (hashCode * 397) ^ (this.CurveB != null ? this.CurveB.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (this.CurveB?.GetHashCode() ?? 0);
hashCode = (hashCode * 397) ^ (this.CurveM != null ? this.CurveM.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (this.CurveM?.GetHashCode() ?? 0);
hashCode = (hashCode * 397) ^ (this.CurveA != null ? this.CurveA.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (this.CurveA?.GetHashCode() ?? 0);
return hashCode; return hashCode;
} }
} }

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

@ -147,14 +147,13 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
/// <inheritdoc/> /// <inheritdoc/>
public override bool Equals(IccTagDataEntry other) public override bool Equals(IccTagDataEntry other)
{ {
var entry = other as IccLutBToATagDataEntry; return other is IccLutBToATagDataEntry entry && this.Equals(entry);
return entry != null && this.Equals(entry);
} }
/// <inheritdoc/> /// <inheritdoc/>
public bool Equals(IccLutBToATagDataEntry other) public bool Equals(IccLutBToATagDataEntry other)
{ {
if (ReferenceEquals(null, other)) if (other == null)
{ {
return false; return false;
} }
@ -178,7 +177,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
/// <inheritdoc/> /// <inheritdoc/>
public override bool Equals(object obj) public override bool Equals(object obj)
{ {
if (ReferenceEquals(null, obj)) if (obj == null)
{ {
return false; return false;
} }
@ -188,7 +187,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
return true; return true;
} }
return obj is IccLutBToATagDataEntry && this.Equals((IccLutBToATagDataEntry)obj); return obj is IccLutBToATagDataEntry other && this.Equals(other);
} }
/// <inheritdoc/> /// <inheritdoc/>
@ -201,10 +200,10 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
hashCode = (hashCode * 397) ^ this.OutputChannelCount; hashCode = (hashCode * 397) ^ this.OutputChannelCount;
hashCode = (hashCode * 397) ^ this.Matrix3x3.GetHashCode(); hashCode = (hashCode * 397) ^ this.Matrix3x3.GetHashCode();
hashCode = (hashCode * 397) ^ this.Matrix3x1.GetHashCode(); hashCode = (hashCode * 397) ^ this.Matrix3x1.GetHashCode();
hashCode = (hashCode * 397) ^ (this.ClutValues != null ? this.ClutValues.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (this.ClutValues?.GetHashCode() ?? 0);
hashCode = (hashCode * 397) ^ (this.CurveB != null ? this.CurveB.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (this.CurveB?.GetHashCode() ?? 0);
hashCode = (hashCode * 397) ^ (this.CurveM != null ? this.CurveM.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (this.CurveM?.GetHashCode() ?? 0);
hashCode = (hashCode * 397) ^ (this.CurveA != null ? this.CurveA.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (this.CurveA?.GetHashCode() ?? 0);
return hashCode; return hashCode;
} }
} }

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

@ -73,14 +73,13 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
/// <inheritdoc/> /// <inheritdoc/>
public override bool Equals(IccTagDataEntry other) public override bool Equals(IccTagDataEntry other)
{ {
var entry = other as IccMeasurementTagDataEntry; return other is IccMeasurementTagDataEntry entry && this.Equals(entry);
return entry != null && this.Equals(entry);
} }
/// <inheritdoc/> /// <inheritdoc/>
public bool Equals(IccMeasurementTagDataEntry other) public bool Equals(IccMeasurementTagDataEntry other)
{ {
if (ReferenceEquals(null, other)) if (other == null)
{ {
return false; return false;
} }

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

@ -41,14 +41,13 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
/// <inheritdoc/> /// <inheritdoc/>
public override bool Equals(IccTagDataEntry other) public override bool Equals(IccTagDataEntry other)
{ {
var entry = other as IccMultiLocalizedUnicodeTagDataEntry; return other is IccMultiLocalizedUnicodeTagDataEntry entry && this.Equals(entry);
return entry != null && this.Equals(entry);
} }
/// <inheritdoc/> /// <inheritdoc/>
public bool Equals(IccMultiLocalizedUnicodeTagDataEntry other) public bool Equals(IccMultiLocalizedUnicodeTagDataEntry other)
{ {
if (ReferenceEquals(null, other)) if (other == null)
{ {
return false; return false;
} }
@ -64,7 +63,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
/// <inheritdoc/> /// <inheritdoc/>
public override bool Equals(object obj) public override bool Equals(object obj)
{ {
if (ReferenceEquals(null, obj)) if (obj == null)
{ {
return false; return false;
} }
@ -82,7 +81,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
{ {
unchecked unchecked
{ {
return (base.GetHashCode() * 397) ^ (this.Texts != null ? this.Texts.GetHashCode() : 0); return (base.GetHashCode() * 397) ^ (this.Texts?.GetHashCode() ?? 0);
} }
} }
} }

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

@ -65,7 +65,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
/// <inheritdoc/> /// <inheritdoc/>
public bool Equals(IccMultiProcessElementsTagDataEntry other) public bool Equals(IccMultiProcessElementsTagDataEntry other)
{ {
if (ReferenceEquals(null, other)) if (other == null)
{ {
return false; return false;
} }
@ -94,7 +94,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
return true; return true;
} }
return obj is IccMultiProcessElementsTagDataEntry && this.Equals((IccMultiProcessElementsTagDataEntry)obj); return obj is IccMultiProcessElementsTagDataEntry other && this.Equals(other);
} }
/// <inheritdoc/> /// <inheritdoc/>
@ -105,7 +105,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
int hashCode = base.GetHashCode(); int hashCode = base.GetHashCode();
hashCode = (hashCode * 397) ^ this.InputChannelCount; hashCode = (hashCode * 397) ^ this.InputChannelCount;
hashCode = (hashCode * 397) ^ this.OutputChannelCount; hashCode = (hashCode * 397) ^ this.OutputChannelCount;
hashCode = (hashCode * 397) ^ (this.Data != null ? this.Data.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (this.Data?.GetHashCode() ?? 0);
return hashCode; return hashCode;
} }
} }

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

@ -121,8 +121,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
/// <inheritdoc/> /// <inheritdoc/>
public override bool Equals(IccTagDataEntry other) public override bool Equals(IccTagDataEntry other)
{ {
var entry = other as IccNamedColor2TagDataEntry; return other is IccNamedColor2TagDataEntry entry && this.Equals(entry);
return entry != null && this.Equals(entry);
} }
/// <inheritdoc/> /// <inheritdoc/>
@ -159,7 +158,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
return true; return true;
} }
return obj is IccNamedColor2TagDataEntry && this.Equals((IccNamedColor2TagDataEntry)obj); return obj is IccNamedColor2TagDataEntry other && this.Equals(other);
} }
/// <inheritdoc/> /// <inheritdoc/>
@ -169,10 +168,10 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
{ {
int hashCode = base.GetHashCode(); int hashCode = base.GetHashCode();
hashCode = (hashCode * 397) ^ this.CoordinateCount; hashCode = (hashCode * 397) ^ this.CoordinateCount;
hashCode = (hashCode * 397) ^ (this.Prefix != null ? this.Prefix.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (this.Prefix?.GetHashCode() ?? 0);
hashCode = (hashCode * 397) ^ (this.Suffix != null ? this.Suffix.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (this.Suffix?.GetHashCode() ?? 0);
hashCode = (hashCode * 397) ^ this.VendorFlags; hashCode = (hashCode * 397) ^ this.VendorFlags;
hashCode = (hashCode * 397) ^ (this.Colors != null ? this.Colors.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (this.Colors?.GetHashCode() ?? 0);
return hashCode; return hashCode;
} }
} }

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

@ -39,8 +39,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
/// <inheritdoc/> /// <inheritdoc/>
public override bool Equals(IccTagDataEntry other) public override bool Equals(IccTagDataEntry other)
{ {
var entry = other as IccParametricCurveTagDataEntry; return other is IccParametricCurveTagDataEntry entry && this.Equals(entry);
return entry != null && this.Equals(entry);
} }
/// <inheritdoc/> /// <inheritdoc/>
@ -72,7 +71,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
return true; return true;
} }
return obj is IccParametricCurveTagDataEntry && this.Equals((IccParametricCurveTagDataEntry)obj); return obj is IccParametricCurveTagDataEntry other && this.Equals(other);
} }
/// <inheritdoc /> /// <inheritdoc />
@ -80,7 +79,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
{ {
unchecked unchecked
{ {
return (base.GetHashCode() * 397) ^ (this.Curve != null ? this.Curve.GetHashCode() : 0); return (base.GetHashCode() * 397) ^ (this.Curve?.GetHashCode() ?? 0);
} }
} }
} }

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

@ -42,8 +42,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
/// <inheritdoc/> /// <inheritdoc/>
public override bool Equals(IccTagDataEntry other) public override bool Equals(IccTagDataEntry other)
{ {
var entry = other as IccProfileSequenceDescTagDataEntry; return other is IccProfileSequenceDescTagDataEntry entry && this.Equals(entry);
return entry != null && this.Equals(entry);
} }
/// <inheritdoc /> /// <inheritdoc />
@ -65,7 +64,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
/// <inheritdoc/> /// <inheritdoc/>
public override bool Equals(object obj) public override bool Equals(object obj)
{ {
if (ReferenceEquals(null, obj)) if (obj == null)
{ {
return false; return false;
} }
@ -75,7 +74,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
return true; return true;
} }
return obj is IccProfileSequenceDescTagDataEntry && this.Equals((IccProfileSequenceDescTagDataEntry)obj); return obj is IccProfileSequenceDescTagDataEntry other && this.Equals(other);
} }
/// <inheritdoc /> /// <inheritdoc />
@ -83,7 +82,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
{ {
unchecked unchecked
{ {
return (base.GetHashCode() * 397) ^ (this.Descriptions != null ? this.Descriptions.GetHashCode() : 0); return (base.GetHashCode() * 397) ^ (this.Descriptions?.GetHashCode() ?? 0);
} }
} }
} }

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

@ -41,8 +41,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
/// <inheritdoc/> /// <inheritdoc/>
public override bool Equals(IccTagDataEntry other) public override bool Equals(IccTagDataEntry other)
{ {
var entry = other as IccProfileSequenceIdentifierTagDataEntry; return other is IccProfileSequenceIdentifierTagDataEntry entry && this.Equals(entry);
return entry != null && this.Equals(entry);
} }
/// <inheritdoc /> /// <inheritdoc />
@ -74,7 +73,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
return true; return true;
} }
return obj is IccProfileSequenceIdentifierTagDataEntry && this.Equals((IccProfileSequenceIdentifierTagDataEntry)obj); return obj is IccProfileSequenceIdentifierTagDataEntry other && this.Equals(other);
} }
/// <inheritdoc /> /// <inheritdoc />
@ -82,7 +81,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
{ {
unchecked unchecked
{ {
return (base.GetHashCode() * 397) ^ (this.Data != null ? this.Data.GetHashCode() : 0); return (base.GetHashCode() * 397) ^ (this.Data?.GetHashCode() ?? 0);
} }
} }
} }

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

@ -53,8 +53,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
/// <inheritdoc/> /// <inheritdoc/>
public override bool Equals(IccTagDataEntry other) public override bool Equals(IccTagDataEntry other)
{ {
var entry = other as IccResponseCurveSet16TagDataEntry; return other is IccResponseCurveSet16TagDataEntry entry && this.Equals(entry);
return entry != null && this.Equals(entry);
} }
/// <inheritdoc /> /// <inheritdoc />
@ -98,7 +97,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
{ {
int hashCode = base.GetHashCode(); int hashCode = base.GetHashCode();
hashCode = (hashCode * 397) ^ this.ChannelCount.GetHashCode(); hashCode = (hashCode * 397) ^ this.ChannelCount.GetHashCode();
hashCode = (hashCode * 397) ^ (this.Curves != null ? this.Curves.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (this.Curves?.GetHashCode() ?? 0);
return hashCode; return hashCode;
} }
} }

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

@ -50,8 +50,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
/// <inheritdoc/> /// <inheritdoc/>
public override bool Equals(IccTagDataEntry other) public override bool Equals(IccTagDataEntry other)
{ {
var entry = other as IccScreeningTagDataEntry; return other is IccScreeningTagDataEntry entry && this.Equals(entry);
return entry != null && this.Equals(entry);
} }
/// <inheritdoc /> /// <inheritdoc />
@ -85,7 +84,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
return true; return true;
} }
return obj is IccScreeningTagDataEntry && this.Equals((IccScreeningTagDataEntry)obj); return obj is IccScreeningTagDataEntry other && this.Equals(other);
} }
/// <inheritdoc/> /// <inheritdoc/>
@ -95,7 +94,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
{ {
int hashCode = base.GetHashCode(); int hashCode = base.GetHashCode();
hashCode = (hashCode * 397) ^ (int)this.Flags; hashCode = (hashCode * 397) ^ (int)this.Flags;
hashCode = (hashCode * 397) ^ (this.Channels != null ? this.Channels.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (this.Channels?.GetHashCode() ?? 0);
return hashCode; return hashCode;
} }
} }

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

@ -40,8 +40,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
/// <inheritdoc/> /// <inheritdoc/>
public override bool Equals(IccTagDataEntry other) public override bool Equals(IccTagDataEntry other)
{ {
var entry = other as IccSignatureTagDataEntry; return other is IccSignatureTagDataEntry entry && this.Equals(entry);
return entry != null && this.Equals(entry);
} }
/// <inheritdoc /> /// <inheritdoc />
@ -73,7 +72,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
return true; return true;
} }
return obj is IccSignatureTagDataEntry && this.Equals((IccSignatureTagDataEntry)obj); return obj is IccSignatureTagDataEntry other && this.Equals(other);
} }
/// <inheritdoc /> /// <inheritdoc />
@ -81,7 +80,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
{ {
unchecked unchecked
{ {
return (base.GetHashCode() * 397) ^ (this.SignatureData != null ? this.SignatureData.GetHashCode() : 0); return (base.GetHashCode() * 397) ^ (this.SignatureData?.GetHashCode() ?? 0);
} }
} }
} }

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

@ -133,8 +133,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
/// <inheritdoc/> /// <inheritdoc/>
public override bool Equals(IccTagDataEntry other) public override bool Equals(IccTagDataEntry other)
{ {
var entry = other as IccTextDescriptionTagDataEntry; return other is IccTextDescriptionTagDataEntry entry && this.Equals(entry);
return entry != null && this.Equals(entry);
} }
/// <inheritdoc /> /// <inheritdoc />
@ -161,7 +160,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
/// <inheritdoc /> /// <inheritdoc />
public override bool Equals(object obj) public override bool Equals(object obj)
{ {
if (ReferenceEquals(null, obj)) if (obj == null)
{ {
return false; return false;
} }
@ -180,9 +179,9 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
unchecked unchecked
{ {
int hashCode = base.GetHashCode(); int hashCode = base.GetHashCode();
hashCode = (hashCode * 397) ^ (this.Ascii != null ? this.Ascii.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (this.Ascii?.GetHashCode() ?? 0);
hashCode = (hashCode * 397) ^ (this.Unicode != null ? this.Unicode.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (this.Unicode?.GetHashCode() ?? 0);
hashCode = (hashCode * 397) ^ (this.ScriptCode != null ? this.ScriptCode.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (this.ScriptCode?.GetHashCode() ?? 0);
hashCode = (hashCode * 397) ^ (int)this.UnicodeLanguageCode; hashCode = (hashCode * 397) ^ (int)this.UnicodeLanguageCode;
hashCode = (hashCode * 397) ^ this.ScriptCodeCode.GetHashCode(); hashCode = (hashCode * 397) ^ this.ScriptCodeCode.GetHashCode();
return hashCode; return hashCode;

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

@ -39,8 +39,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
/// <inheritdoc/> /// <inheritdoc/>
public override bool Equals(IccTagDataEntry other) public override bool Equals(IccTagDataEntry other)
{ {
var entry = other as IccTextTagDataEntry; return other is IccTextTagDataEntry entry && this.Equals(entry);
return entry != null && this.Equals(entry);
} }
/// <inheritdoc /> /// <inheritdoc />
@ -72,7 +71,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
return true; return true;
} }
return obj is IccTextTagDataEntry && this.Equals((IccTextTagDataEntry)obj); return obj is IccTextTagDataEntry other && this.Equals(other);
} }
/// <inheritdoc /> /// <inheritdoc />
@ -80,7 +79,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
{ {
unchecked unchecked
{ {
return (base.GetHashCode() * 397) ^ (this.Text != null ? this.Text.GetHashCode() : 0); return (base.GetHashCode() * 397) ^ (this.Text?.GetHashCode() ?? 0);
} }
} }
} }

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

@ -33,15 +33,14 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
} }
/// <summary> /// <summary>
/// Gets the array data /// Gets the array data.
/// </summary> /// </summary>
public float[] Data { get; } public float[] Data { get; }
/// <inheritdoc/> /// <inheritdoc/>
public override bool Equals(IccTagDataEntry other) public override bool Equals(IccTagDataEntry other)
{ {
var entry = other as IccUFix16ArrayTagDataEntry; return other is IccUFix16ArrayTagDataEntry entry && this.Equals(entry);
return entry != null && this.Equals(entry);
} }
/// <inheritdoc/> /// <inheritdoc/>
@ -63,7 +62,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
/// <inheritdoc/> /// <inheritdoc/>
public override bool Equals(object obj) public override bool Equals(object obj)
{ {
if (ReferenceEquals(null, obj)) if (obj == null)
{ {
return false; return false;
} }
@ -73,7 +72,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
return true; return true;
} }
return obj is IccUFix16ArrayTagDataEntry && this.Equals((IccUFix16ArrayTagDataEntry)obj); return obj is IccUFix16ArrayTagDataEntry other && this.Equals(other);
} }
/// <inheritdoc/> /// <inheritdoc/>
@ -81,7 +80,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
{ {
unchecked unchecked
{ {
return (base.GetHashCode() * 397) ^ (this.Data != null ? this.Data.GetHashCode() : 0); return (base.GetHashCode() * 397) ^ (this.Data?.GetHashCode() ?? 0);
} }
} }
} }

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

@ -40,8 +40,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
/// <inheritdoc/> /// <inheritdoc/>
public override bool Equals(IccTagDataEntry other) public override bool Equals(IccTagDataEntry other)
{ {
var entry = other as IccUInt16ArrayTagDataEntry; return other is IccUInt16ArrayTagDataEntry entry && this.Equals(entry);
return entry != null && this.Equals(entry);
} }
/// <inheritdoc/> /// <inheritdoc/>
@ -73,7 +72,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
return true; return true;
} }
return obj is IccUInt16ArrayTagDataEntry && this.Equals((IccUInt16ArrayTagDataEntry)obj); return obj is IccUInt16ArrayTagDataEntry other && this.Equals(other);
} }
/// <inheritdoc/> /// <inheritdoc/>
@ -81,7 +80,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
{ {
unchecked unchecked
{ {
return (base.GetHashCode() * 397) ^ (this.Data != null ? this.Data.GetHashCode() : 0); return (base.GetHashCode() * 397) ^ (this.Data?.GetHashCode() ?? 0);
} }
} }
} }

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

@ -40,14 +40,13 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
/// <inheritdoc/> /// <inheritdoc/>
public override bool Equals(IccTagDataEntry other) public override bool Equals(IccTagDataEntry other)
{ {
var entry = other as IccUInt32ArrayTagDataEntry; return other is IccUInt32ArrayTagDataEntry entry && this.Equals(entry);
return entry != null && this.Equals(entry);
} }
/// <inheritdoc/> /// <inheritdoc/>
public bool Equals(IccUInt32ArrayTagDataEntry other) public bool Equals(IccUInt32ArrayTagDataEntry other)
{ {
if (ReferenceEquals(null, other)) if (other == null)
{ {
return false; return false;
} }
@ -63,7 +62,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
/// <inheritdoc/> /// <inheritdoc/>
public override bool Equals(object obj) public override bool Equals(object obj)
{ {
if (ReferenceEquals(null, obj)) if (obj == null)
{ {
return false; return false;
} }
@ -81,7 +80,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
{ {
unchecked unchecked
{ {
return (base.GetHashCode() * 397) ^ (this.Data != null ? this.Data.GetHashCode() : 0); return (base.GetHashCode() * 397) ^ (this.Data?.GetHashCode() ?? 0);
} }
} }
} }

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

@ -40,14 +40,13 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
/// <inheritdoc/> /// <inheritdoc/>
public override bool Equals(IccTagDataEntry other) public override bool Equals(IccTagDataEntry other)
{ {
var entry = other as IccUInt64ArrayTagDataEntry; return other is IccUInt64ArrayTagDataEntry entry && this.Equals(entry);
return entry != null && this.Equals(entry);
} }
/// <inheritdoc/> /// <inheritdoc/>
public bool Equals(IccUInt64ArrayTagDataEntry other) public bool Equals(IccUInt64ArrayTagDataEntry other)
{ {
if (ReferenceEquals(null, other)) if (other == null)
{ {
return false; return false;
} }
@ -63,7 +62,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
/// <inheritdoc/> /// <inheritdoc/>
public override bool Equals(object obj) public override bool Equals(object obj)
{ {
if (ReferenceEquals(null, obj)) if (obj == null)
{ {
return false; return false;
} }
@ -81,7 +80,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
{ {
unchecked unchecked
{ {
return (base.GetHashCode() * 397) ^ (this.Data != null ? this.Data.GetHashCode() : 0); return (base.GetHashCode() * 397) ^ (this.Data?.GetHashCode() ?? 0);
} }
} }
} }

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

@ -33,21 +33,20 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
} }
/// <summary> /// <summary>
/// Gets the array data /// Gets the array data.
/// </summary> /// </summary>
public byte[] Data { get; } public byte[] Data { get; }
/// <inheritdoc/> /// <inheritdoc/>
public override bool Equals(IccTagDataEntry other) public override bool Equals(IccTagDataEntry other)
{ {
var entry = other as IccUInt8ArrayTagDataEntry; return other is IccUInt8ArrayTagDataEntry entry && this.Equals(entry);
return entry != null && this.Equals(entry);
} }
/// <inheritdoc/> /// <inheritdoc/>
public bool Equals(IccUInt8ArrayTagDataEntry other) public bool Equals(IccUInt8ArrayTagDataEntry other)
{ {
if (ReferenceEquals(null, other)) if (other == null)
{ {
return false; return false;
} }
@ -63,7 +62,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
/// <inheritdoc/> /// <inheritdoc/>
public override bool Equals(object obj) public override bool Equals(object obj)
{ {
if (ReferenceEquals(null, obj)) if (obj == null)
{ {
return false; return false;
} }
@ -73,7 +72,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
return true; return true;
} }
return obj is IccUInt8ArrayTagDataEntry && this.Equals((IccUInt8ArrayTagDataEntry)obj); return obj is IccUInt8ArrayTagDataEntry other && this.Equals(other);
} }
/// <inheritdoc/> /// <inheritdoc/>
@ -81,7 +80,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
{ {
unchecked unchecked
{ {
return (base.GetHashCode() * 397) ^ (this.Data != null ? this.Data.GetHashCode() : 0); return (base.GetHashCode() * 397) ^ (this.Data?.GetHashCode() ?? 0);
} }
} }
} }

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

@ -60,14 +60,13 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
/// <inheritdoc/> /// <inheritdoc/>
public override bool Equals(IccTagDataEntry other) public override bool Equals(IccTagDataEntry other)
{ {
var entry = other as IccUcrBgTagDataEntry; return other is IccUcrBgTagDataEntry entry && this.Equals(entry);
return entry != null && this.Equals(entry);
} }
/// <inheritdoc/> /// <inheritdoc/>
public bool Equals(IccUcrBgTagDataEntry other) public bool Equals(IccUcrBgTagDataEntry other)
{ {
if (ReferenceEquals(null, other)) if (other == null)
{ {
return false; return false;
} }
@ -86,7 +85,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
/// <inheritdoc/> /// <inheritdoc/>
public override bool Equals(object obj) public override bool Equals(object obj)
{ {
if (ReferenceEquals(null, obj)) if (obj == null)
{ {
return false; return false;
} }
@ -96,7 +95,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
return true; return true;
} }
return obj is IccUcrBgTagDataEntry && this.Equals((IccUcrBgTagDataEntry)obj); return obj is IccUcrBgTagDataEntry other && this.Equals(other);
} }
/// <inheritdoc/> /// <inheritdoc/>
@ -105,9 +104,9 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
unchecked unchecked
{ {
int hashCode = base.GetHashCode(); int hashCode = base.GetHashCode();
hashCode = (hashCode * 397) ^ (this.UcrCurve != null ? this.UcrCurve.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (this.UcrCurve?.GetHashCode() ?? 0);
hashCode = (hashCode * 397) ^ (this.BgCurve != null ? this.BgCurve.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (this.BgCurve?.GetHashCode() ?? 0);
hashCode = (hashCode * 397) ^ (this.Description != null ? this.Description.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (this.Description?.GetHashCode() ?? 0);
return hashCode; return hashCode;
} }
} }

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

@ -33,21 +33,20 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
} }
/// <summary> /// <summary>
/// Gets the raw data of the entry /// Gets the raw data of the entry.
/// </summary> /// </summary>
public byte[] Data { get; } public byte[] Data { get; }
/// <inheritdoc/> /// <inheritdoc/>
public override bool Equals(IccTagDataEntry other) public override bool Equals(IccTagDataEntry other)
{ {
var entry = other as IccUnknownTagDataEntry; return other is IccUnknownTagDataEntry entry && this.Equals(entry);
return entry != null && this.Equals(entry);
} }
/// <inheritdoc/> /// <inheritdoc/>
public bool Equals(IccUnknownTagDataEntry other) public bool Equals(IccUnknownTagDataEntry other)
{ {
if (ReferenceEquals(null, other)) if (other == null)
{ {
return false; return false;
} }
@ -63,7 +62,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
/// <inheritdoc/> /// <inheritdoc/>
public override bool Equals(object obj) public override bool Equals(object obj)
{ {
if (ReferenceEquals(null, obj)) if (obj == null)
{ {
return false; return false;
} }
@ -73,7 +72,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
return true; return true;
} }
return obj is IccUnknownTagDataEntry && this.Equals((IccUnknownTagDataEntry)obj); return obj is IccUnknownTagDataEntry other && this.Equals(other);
} }
/// <inheritdoc/> /// <inheritdoc/>
@ -81,7 +80,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
{ {
unchecked unchecked
{ {
return (base.GetHashCode() * 397) ^ (this.Data != null ? this.Data.GetHashCode() : 0); return (base.GetHashCode() * 397) ^ (this.Data?.GetHashCode() ?? 0);
} }
} }
} }

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

@ -38,7 +38,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
} }
/// <summary> /// <summary>
/// Gets the XYZ values of Illuminant /// Gets the XYZ values of illuminant.
/// </summary> /// </summary>
public Vector3 IlluminantXyz { get; } public Vector3 IlluminantXyz { get; }
@ -48,15 +48,14 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
public Vector3 SurroundXyz { get; } public Vector3 SurroundXyz { get; }
/// <summary> /// <summary>
/// Gets the illuminant /// Gets the illuminant.
/// </summary> /// </summary>
public IccStandardIlluminant Illuminant { get; } public IccStandardIlluminant Illuminant { get; }
/// <inheritdoc/> /// <inheritdoc/>
public override bool Equals(IccTagDataEntry other) public override bool Equals(IccTagDataEntry other)
{ {
var entry = other as IccViewingConditionsTagDataEntry; return other is IccViewingConditionsTagDataEntry entry && this.Equals(entry);
return entry != null && this.Equals(entry);
} }
/// <inheritdoc/> /// <inheritdoc/>
@ -81,7 +80,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
/// <inheritdoc/> /// <inheritdoc/>
public override bool Equals(object obj) public override bool Equals(object obj)
{ {
if (ReferenceEquals(null, obj)) if (obj == null)
{ {
return false; return false;
} }

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

@ -94,9 +94,9 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
public float[][] Values { get; } public float[][] Values { get; }
/// <summary> /// <summary>
/// Gets or sets the CLUT data type (important when writing a profile) /// Gets the CLUT data type (important when writing a profile)
/// </summary> /// </summary>
public IccClutDataType DataType { get; set; } public IccClutDataType DataType { get; }
/// <summary> /// <summary>
/// Gets the number of input channels /// Gets the number of input channels
@ -116,7 +116,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
/// <inheritdoc/> /// <inheritdoc/>
public bool Equals(IccClut other) public bool Equals(IccClut other)
{ {
if (ReferenceEquals(null, other)) if (other == null)
{ {
return false; return false;
} }
@ -136,7 +136,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
/// <inheritdoc/> /// <inheritdoc/>
public override bool Equals(object obj) public override bool Equals(object obj)
{ {
if (ReferenceEquals(null, obj)) if (obj == null)
{ {
return false; return false;
} }
@ -146,7 +146,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
return true; return true;
} }
return obj is IccClut && this.Equals((IccClut)obj); return obj is IccClut other && this.Equals(other);
} }
/// <inheritdoc/> /// <inheritdoc/>
@ -154,11 +154,11 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
{ {
unchecked unchecked
{ {
int hashCode = this.Values != null ? this.Values.GetHashCode() : 0; int hashCode = this.Values?.GetHashCode() ?? 0;
hashCode = (hashCode * 397) ^ (int)this.DataType; hashCode = (hashCode * 397) ^ (int)this.DataType;
hashCode = (hashCode * 397) ^ this.InputChannelCount; hashCode = (hashCode * 397) ^ this.InputChannelCount;
hashCode = (hashCode * 397) ^ this.OutputChannelCount; hashCode = (hashCode * 397) ^ this.OutputChannelCount;
hashCode = (hashCode * 397) ^ (this.GridPointCount != null ? this.GridPointCount.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (this.GridPointCount?.GetHashCode() ?? 0);
return hashCode; return hashCode;
} }
} }

4
src/ImageSharp/MetaData/Profiles/ICC/Various/IccColorantTableEntry.cs

@ -87,9 +87,9 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
} }
/// <inheritdoc/> /// <inheritdoc/>
public override bool Equals(object other) public override bool Equals(object obj)
{ {
return (other is IccColorantTableEntry) && this.Equals((IccColorantTableEntry)other); return obj is IccColorantTableEntry other && this.Equals(other);
} }
/// <inheritdoc/> /// <inheritdoc/>

25
src/ImageSharp/MetaData/Profiles/ICC/Various/IccLocalizedString.cs

@ -7,12 +7,12 @@ using System.Globalization;
namespace SixLabors.ImageSharp.MetaData.Profiles.Icc namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
{ {
/// <summary> /// <summary>
/// A string with a specific locale /// A string with a specific locale.
/// </summary> /// </summary>
internal sealed class IccLocalizedString : IEquatable<IccLocalizedString> internal readonly struct IccLocalizedString : IEquatable<IccLocalizedString>
{ {
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="IccLocalizedString"/> class. /// Initializes a new instance of the <see cref="IccLocalizedString"/> struct.
/// The culture will be <see cref="CultureInfo.CurrentCulture"/> /// The culture will be <see cref="CultureInfo.CurrentCulture"/>
/// </summary> /// </summary>
/// <param name="text">The text value of this string</param> /// <param name="text">The text value of this string</param>
@ -22,7 +22,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
} }
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="IccLocalizedString"/> class. /// Initializes a new instance of the <see cref="IccLocalizedString"/> struct.
/// The culture will be <see cref="CultureInfo.CurrentCulture"/> /// The culture will be <see cref="CultureInfo.CurrentCulture"/>
/// </summary> /// </summary>
/// <param name="culture">The culture of this string</param> /// <param name="culture">The culture of this string</param>
@ -37,26 +37,19 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
} }
/// <summary> /// <summary>
/// Gets the actual text value /// Gets the text value.
/// </summary> /// </summary>
public string Text { get; } public string Text { get; }
/// <summary> /// <summary>
/// Gets the culture of the text /// Gets the culture of text.
/// </summary> /// </summary>
public CultureInfo Culture { get; } public CultureInfo Culture { get; }
/// <inheritdoc /> /// <inheritdoc />
public bool Equals(IccLocalizedString other) public bool Equals(IccLocalizedString other) =>
{ this.Culture.Equals(other.Culture) &&
if (ReferenceEquals(this, other)) this.Text == other.Text;
{
return true;
}
return this.Culture.Equals(other.Culture)
&& this.Text == other.Text;
}
/// <inheritdoc /> /// <inheritdoc />
public override string ToString() public override string ToString()

15
src/ImageSharp/MetaData/Profiles/ICC/Various/IccLut.cs

@ -9,10 +9,10 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
/// <summary> /// <summary>
/// Lookup Table /// Lookup Table
/// </summary> /// </summary>
internal sealed class IccLut : IEquatable<IccLut> internal readonly struct IccLut : IEquatable<IccLut>
{ {
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="IccLut"/> class. /// Initializes a new instance of the <see cref="IccLut"/> struct.
/// </summary> /// </summary>
/// <param name="values">The LUT values</param> /// <param name="values">The LUT values</param>
public IccLut(float[] values) public IccLut(float[] values)
@ -22,7 +22,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
} }
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="IccLut"/> class. /// Initializes a new instance of the <see cref="IccLut"/> struct.
/// </summary> /// </summary>
/// <param name="values">The LUT values</param> /// <param name="values">The LUT values</param>
public IccLut(ushort[] values) public IccLut(ushort[] values)
@ -39,7 +39,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
} }
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="IccLut"/> class. /// Initializes a new instance of the <see cref="IccLut"/> struct.
/// </summary> /// </summary>
/// <param name="values">The LUT values</param> /// <param name="values">The LUT values</param>
public IccLut(byte[] values) public IccLut(byte[] values)
@ -63,12 +63,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
/// <inheritdoc/> /// <inheritdoc/>
public bool Equals(IccLut other) public bool Equals(IccLut other)
{ {
if (other == null) if (ReferenceEquals(this.Values, other.Values))
{
return false;
}
if (ReferenceEquals(this, other))
{ {
return true; return true;
} }

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

@ -74,18 +74,16 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
} }
/// <inheritdoc/> /// <inheritdoc/>
public override bool Equals(object other) public override bool Equals(object obj)
{ {
return (other is IccNamedColor) && this.Equals((IccNamedColor)other); return obj is IccNamedColor other && this.Equals(other);
} }
/// <inheritdoc/> /// <inheritdoc/>
public bool Equals(IccNamedColor other) public bool Equals(IccNamedColor other) =>
{ this.Name == other.Name &&
return this.Name == other.Name this.PcsCoordinates.SequenceEqual(other.PcsCoordinates) &&
&& this.PcsCoordinates.SequenceEqual(other.PcsCoordinates) this.DeviceCoordinates.SequenceEqual(other.DeviceCoordinates);
&& this.DeviceCoordinates.SequenceEqual(other.DeviceCoordinates);
}
/// <inheritdoc/> /// <inheritdoc/>
public override int GetHashCode() public override int GetHashCode()

12
src/ImageSharp/MetaData/Profiles/ICC/Various/IccPositionNumber.cs

@ -62,17 +62,15 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
} }
/// <inheritdoc/> /// <inheritdoc/>
public override bool Equals(object other) public override bool Equals(object obj)
{ {
return (other is IccPositionNumber) && this.Equals((IccPositionNumber)other); return obj is IccPositionNumber other && this.Equals(other);
} }
/// <inheritdoc/> /// <inheritdoc/>
public bool Equals(IccPositionNumber other) public bool Equals(IccPositionNumber other) =>
{ this.Offset == other.Offset &&
return this.Offset == other.Offset this.Size == other.Size;
&& this.Size == other.Size;
}
/// <inheritdoc/> /// <inheritdoc/>
public override int GetHashCode() public override int GetHashCode()

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

@ -9,10 +9,10 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
/// <summary> /// <summary>
/// ICC Profile description /// ICC Profile description
/// </summary> /// </summary>
internal sealed class IccProfileDescription : IEquatable<IccProfileDescription> internal readonly struct IccProfileDescription : IEquatable<IccProfileDescription>
{ {
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="IccProfileDescription"/> class. /// Initializes a new instance of the <see cref="IccProfileDescription"/> struct.
/// </summary> /// </summary>
/// <param name="deviceManufacturer">Device Manufacturer</param> /// <param name="deviceManufacturer">Device Manufacturer</param>
/// <param name="deviceModel">Device Model</param> /// <param name="deviceModel">Device Model</param>
@ -40,70 +40,48 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
} }
/// <summary> /// <summary>
/// Gets the device manufacturer /// Gets the device manufacturer.
/// </summary> /// </summary>
public uint DeviceManufacturer { get; } public uint DeviceManufacturer { get; }
/// <summary> /// <summary>
/// Gets the device model /// Gets the device model.
/// </summary> /// </summary>
public uint DeviceModel { get; } public uint DeviceModel { get; }
/// <summary> /// <summary>
/// Gets the device attributes /// Gets the device attributes.
/// </summary> /// </summary>
public IccDeviceAttribute DeviceAttributes { get; } public IccDeviceAttribute DeviceAttributes { get; }
/// <summary> /// <summary>
/// Gets the technology information /// Gets the technology information.
/// </summary> /// </summary>
public IccProfileTag TechnologyInformation { get; } public IccProfileTag TechnologyInformation { get; }
/// <summary> /// <summary>
/// Gets the device manufacturer info /// Gets the device manufacturer info.
/// </summary> /// </summary>
public IccLocalizedString[] DeviceManufacturerInfo { get; } public IccLocalizedString[] DeviceManufacturerInfo { get; }
/// <summary> /// <summary>
/// Gets the device model info /// Gets the device model info.
/// </summary> /// </summary>
public IccLocalizedString[] DeviceModelInfo { get; } public IccLocalizedString[] DeviceModelInfo { get; }
/// <inheritdoc/> /// <inheritdoc/>
public bool Equals(IccProfileDescription other) public bool Equals(IccProfileDescription other) =>
{ this.DeviceManufacturer == other.DeviceManufacturer &&
if (ReferenceEquals(null, other)) this.DeviceModel == other.DeviceModel &&
{ this.DeviceAttributes == other.DeviceAttributes &&
return false; this.TechnologyInformation == other.TechnologyInformation &&
} this.DeviceManufacturerInfo.SequenceEqual(other.DeviceManufacturerInfo) &&
this.DeviceModelInfo.SequenceEqual(other.DeviceModelInfo);
if (ReferenceEquals(this, other))
{
return true;
}
return this.DeviceManufacturer == other.DeviceManufacturer
&& this.DeviceModel == other.DeviceModel
&& this.DeviceAttributes == other.DeviceAttributes
&& this.TechnologyInformation == other.TechnologyInformation
&& this.DeviceManufacturerInfo.SequenceEqual(other.DeviceManufacturerInfo)
&& this.DeviceModelInfo.SequenceEqual(other.DeviceModelInfo);
}
/// <inheritdoc /> /// <inheritdoc />
public override bool Equals(object obj) public override bool Equals(object obj)
{ {
if (ReferenceEquals(null, obj)) return obj is IccProfileDescription other && this.Equals(other);
{
return false;
}
if (ReferenceEquals(this, obj))
{
return true;
}
return obj is IccProfileDescription && this.Equals((IccProfileDescription)obj);
} }
/// <inheritdoc /> /// <inheritdoc />
@ -115,8 +93,8 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
hashCode = (hashCode * 397) ^ (int)this.DeviceModel; hashCode = (hashCode * 397) ^ (int)this.DeviceModel;
hashCode = (hashCode * 397) ^ this.DeviceAttributes.GetHashCode(); hashCode = (hashCode * 397) ^ this.DeviceAttributes.GetHashCode();
hashCode = (hashCode * 397) ^ (int)this.TechnologyInformation; hashCode = (hashCode * 397) ^ (int)this.TechnologyInformation;
hashCode = (hashCode * 397) ^ (this.DeviceManufacturerInfo != null ? this.DeviceManufacturerInfo.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (this.DeviceManufacturerInfo?.GetHashCode() ?? 0);
hashCode = (hashCode * 397) ^ (this.DeviceModelInfo != null ? this.DeviceModelInfo.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (this.DeviceModelInfo?.GetHashCode() ?? 0);
return hashCode; return hashCode;
} }
} }

16
src/ImageSharp/MetaData/Profiles/ICC/Various/IccProfileId.cs

@ -95,19 +95,17 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
} }
/// <inheritdoc/> /// <inheritdoc/>
public override bool Equals(object other) public override bool Equals(object obj)
{ {
return (other is IccProfileId) && this.Equals((IccProfileId)other); return obj is IccProfileId other && this.Equals(other);
} }
/// <inheritdoc/> /// <inheritdoc/>
public bool Equals(IccProfileId other) public bool Equals(IccProfileId other) =>
{ this.Part1 == other.Part1 &&
return this.Part1 == other.Part1 this.Part2 == other.Part2 &&
&& this.Part2 == other.Part2 this.Part3 == other.Part3 &&
&& this.Part3 == other.Part3 this.Part4 == other.Part4;
&& this.Part4 == other.Part4;
}
/// <inheritdoc/> /// <inheritdoc/>
public override int GetHashCode() public override int GetHashCode()

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

@ -7,12 +7,12 @@ using System.Linq;
namespace SixLabors.ImageSharp.MetaData.Profiles.Icc namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
{ {
/// <summary> /// <summary>
/// Description of a profile within a sequence /// Description of a profile within a sequence.
/// </summary> /// </summary>
internal sealed class IccProfileSequenceIdentifier : IEquatable<IccProfileSequenceIdentifier> internal readonly struct IccProfileSequenceIdentifier : IEquatable<IccProfileSequenceIdentifier>
{ {
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="IccProfileSequenceIdentifier"/> class. /// Initializes a new instance of the <see cref="IccProfileSequenceIdentifier"/> struct.
/// </summary> /// </summary>
/// <param name="id">ID of the profile</param> /// <param name="id">ID of the profile</param>
/// <param name="description">Description of the profile</param> /// <param name="description">Description of the profile</param>
@ -25,45 +25,24 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
} }
/// <summary> /// <summary>
/// Gets the ID of the profile /// Gets the ID of the profile.
/// </summary> /// </summary>
public IccProfileId Id { get; } public IccProfileId Id { get; }
/// <summary> /// <summary>
/// Gets the description of the profile /// Gets the description of the profile.
/// </summary> /// </summary>
public IccLocalizedString[] Description { get; } public IccLocalizedString[] Description { get; }
/// <inheritdoc /> /// <inheritdoc />
public bool Equals(IccProfileSequenceIdentifier other) public bool Equals(IccProfileSequenceIdentifier other) =>
{ this.Id.Equals(other.Id) &&
if (ReferenceEquals(null, other)) this.Description.SequenceEqual(other.Description);
{
return false;
}
if (ReferenceEquals(this, other))
{
return true;
}
return this.Id.Equals(other.Id) && this.Description.SequenceEqual(other.Description);
}
/// <inheritdoc /> /// <inheritdoc />
public override bool Equals(object obj) public override bool Equals(object obj)
{ {
if (ReferenceEquals(null, obj)) return obj is IccProfileSequenceIdentifier other && this.Equals(other);
{
return false;
}
if (ReferenceEquals(this, obj))
{
return true;
}
return obj is IccProfileSequenceIdentifier && this.Equals((IccProfileSequenceIdentifier)obj);
} }
/// <inheritdoc /> /// <inheritdoc />
@ -71,7 +50,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
{ {
unchecked unchecked
{ {
return (this.Id.GetHashCode() * 397) ^ (this.Description != null ? this.Description.GetHashCode() : 0); return (this.Id.GetHashCode() * 397) ^ (this.Description?.GetHashCode() ?? 0);
} }
} }
} }

12
src/ImageSharp/MetaData/Profiles/ICC/Various/IccResponseNumber.cs

@ -62,17 +62,15 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
} }
/// <inheritdoc/> /// <inheritdoc/>
public override bool Equals(object other) public override bool Equals(object obj)
{ {
return (other is IccResponseNumber) && this.Equals((IccResponseNumber)other); return obj is IccResponseNumber other && this.Equals(other);
} }
/// <inheritdoc/> /// <inheritdoc/>
public bool Equals(IccResponseNumber other) public bool Equals(IccResponseNumber other) =>
{ this.DeviceCode == other.DeviceCode &&
return this.DeviceCode == other.DeviceCode this.MeasurementValue == other.MeasurementValue;
&& this.MeasurementValue == other.MeasurementValue;
}
/// <inheritdoc/> /// <inheritdoc/>
public override int GetHashCode() public override int GetHashCode()

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

@ -69,12 +69,10 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
} }
/// <inheritdoc /> /// <inheritdoc />
public bool Equals(IccScreeningChannel other) public bool Equals(IccScreeningChannel other) =>
{ this.Frequency == other.Frequency &&
return this.Frequency.Equals(other.Frequency) this.Angle == other.Angle &&
&& this.Angle.Equals(other.Angle) this.SpotShape == other.SpotShape;
&& this.SpotShape == other.SpotShape;
}
/// <inheritdoc/> /// <inheritdoc/>
public override bool Equals(object obj) public override bool Equals(object obj)

14
src/ImageSharp/MetaData/Profiles/ICC/Various/IccTagTableEntry.cs

@ -69,18 +69,16 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
} }
/// <inheritdoc/> /// <inheritdoc/>
public override bool Equals(object other) public override bool Equals(object obj)
{ {
return (other is IccTagTableEntry) && this.Equals((IccTagTableEntry)other); return obj is IccTagTableEntry other && this.Equals(other);
} }
/// <inheritdoc/> /// <inheritdoc/>
public bool Equals(IccTagTableEntry other) public bool Equals(IccTagTableEntry other) =>
{ this.Signature == other.Signature &&
return this.Signature == other.Signature this.Offset == other.Offset &&
&& this.Offset == other.Offset this.DataSize == other.DataSize;
&& this.DataSize == other.DataSize;
}
/// <inheritdoc/> /// <inheritdoc/>
public override int GetHashCode() public override int GetHashCode()

24
src/ImageSharp/PixelFormats/Alpha8.cs

@ -97,6 +97,20 @@ namespace SixLabors.ImageSharp.PixelFormats
this.PackedValue = source.A; this.PackedValue = source.A;
} }
/// <inheritdoc/>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void PackFromArgb32(Argb32 source)
{
this.PackedValue = source.A;
}
/// <inheritdoc/>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void PackFromBgra32(Bgra32 source)
{
this.PackedValue = source.A;
}
/// <inheritdoc /> /// <inheritdoc />
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public void ToRgb24(ref Rgb24 dest) public void ToRgb24(ref Rgb24 dest)
@ -114,6 +128,16 @@ namespace SixLabors.ImageSharp.PixelFormats
dest.A = this.PackedValue; dest.A = this.PackedValue;
} }
/// <inheritdoc />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void ToArgb32(ref Argb32 dest)
{
dest.R = 0;
dest.G = 0;
dest.B = 0;
dest.A = this.PackedValue;
}
/// <inheritdoc /> /// <inheritdoc />
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public void ToBgr24(ref Bgr24 dest) public void ToBgr24(ref Bgr24 dest)

238
src/ImageSharp/PixelFormats/Argb32.cs

@ -1,15 +1,15 @@
// Copyright (c) Six Labors and contributors. // Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0. // Licensed under the Apache License, Version 2.0.
using System;
using System.Numerics; using System.Numerics;
using System.Runtime.CompilerServices; using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
namespace SixLabors.ImageSharp.PixelFormats namespace SixLabors.ImageSharp.PixelFormats
{ {
/// <summary> /// <summary>
/// Packed pixel type containing four 8-bit unsigned normalized values ranging from 0 to 255. /// Packed pixel type containing four 8-bit unsigned normalized values ranging from 0 to 255.
/// The color components are stored in alpha, red, green, and blue order. /// The color components are stored in alpha, red, green, and blue order (least significant to most significant byte).
/// <para> /// <para>
/// Ranges from [0, 0, 0, 0] to [1, 1, 1, 1] in vector form. /// Ranges from [0, 0, 0, 0] to [1, 1, 1, 1] in vector form.
/// </para> /// </para>
@ -18,27 +18,28 @@ namespace SixLabors.ImageSharp.PixelFormats
/// This struct is fully mutable. This is done (against the guidelines) for the sake of performance, /// This struct is fully mutable. This is done (against the guidelines) for the sake of performance,
/// as it avoids the need to create new values for modification operations. /// as it avoids the need to create new values for modification operations.
/// </remarks> /// </remarks>
[StructLayout(LayoutKind.Sequential)]
public struct Argb32 : IPixel<Argb32>, IPackedVector<uint> public struct Argb32 : IPixel<Argb32>, IPackedVector<uint>
{ {
/// <summary> /// <summary>
/// The shift count for the blue component /// Gets or sets the alpha component.
/// </summary> /// </summary>
private const int BlueShift = 0; public byte A;
/// <summary> /// <summary>
/// The shift count for the green component /// Gets or sets the red component.
/// </summary> /// </summary>
private const int GreenShift = 8; public byte R;
/// <summary> /// <summary>
/// The shift count for the red component /// Gets or sets the green component.
/// </summary> /// </summary>
private const int RedShift = 16; public byte G;
/// <summary> /// <summary>
/// The shift count for the alpha component /// Gets or sets the blue component.
/// </summary> /// </summary>
private const int AlphaShift = 24; public byte B;
/// <summary> /// <summary>
/// The maximum byte value. /// The maximum byte value.
@ -56,11 +57,13 @@ namespace SixLabors.ImageSharp.PixelFormats
/// <param name="r">The red component.</param> /// <param name="r">The red component.</param>
/// <param name="g">The green component.</param> /// <param name="g">The green component.</param>
/// <param name="b">The blue component.</param> /// <param name="b">The blue component.</param>
/// <param name="a">The alpha component.</param>
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public Argb32(byte r, byte g, byte b, byte a) public Argb32(byte r, byte g, byte b)
{ {
this.PackedValue = Pack(r, g, b, a); this.R = r;
this.G = g;
this.B = b;
this.A = 255;
} }
/// <summary> /// <summary>
@ -69,10 +72,14 @@ namespace SixLabors.ImageSharp.PixelFormats
/// <param name="r">The red component.</param> /// <param name="r">The red component.</param>
/// <param name="g">The green component.</param> /// <param name="g">The green component.</param>
/// <param name="b">The blue component.</param> /// <param name="b">The blue component.</param>
/// <param name="a">The alpha component.</param>
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public Argb32(byte r, byte g, byte b) public Argb32(byte r, byte g, byte b, byte a)
{ {
this.PackedValue = Pack(r, g, b, 255); this.R = r;
this.G = g;
this.B = b;
this.A = a;
} }
/// <summary> /// <summary>
@ -82,9 +89,11 @@ namespace SixLabors.ImageSharp.PixelFormats
/// <param name="g">The green component.</param> /// <param name="g">The green component.</param>
/// <param name="b">The blue component.</param> /// <param name="b">The blue component.</param>
/// <param name="a">The alpha component.</param> /// <param name="a">The alpha component.</param>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public Argb32(float r, float g, float b, float a = 1) public Argb32(float r, float g, float b, float a = 1)
: this()
{ {
this.PackedValue = Pack(r, g, b, a); this.Pack(r, g, b, a);
} }
/// <summary> /// <summary>
@ -93,9 +102,11 @@ namespace SixLabors.ImageSharp.PixelFormats
/// <param name="vector"> /// <param name="vector">
/// The vector containing the components for the packed vector. /// The vector containing the components for the packed vector.
/// </param> /// </param>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public Argb32(Vector3 vector) public Argb32(Vector3 vector)
: this()
{ {
this.PackedValue = Pack(ref vector); this.Pack(ref vector);
} }
/// <summary> /// <summary>
@ -104,9 +115,11 @@ namespace SixLabors.ImageSharp.PixelFormats
/// <param name="vector"> /// <param name="vector">
/// The vector containing the components for the packed vector. /// The vector containing the components for the packed vector.
/// </param> /// </param>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public Argb32(Vector4 vector) public Argb32(Vector4 vector)
: this()
{ {
this.PackedValue = Pack(ref vector); this.Pack(ref vector);
} }
/// <summary> /// <summary>
@ -115,84 +128,30 @@ namespace SixLabors.ImageSharp.PixelFormats
/// <param name="packed"> /// <param name="packed">
/// The packed value. /// The packed value.
/// </param> /// </param>
public Argb32(uint packed = 0) [MethodImpl(MethodImplOptions.AggressiveInlining)]
{ public Argb32(uint packed)
this.PackedValue = packed; : this()
}
/// <inheritdoc/>
public uint PackedValue { get; set; }
/// <summary>
/// Gets or sets the red component.
/// </summary>
public byte R
{ {
[MethodImpl(MethodImplOptions.AggressiveInlining)] this.Argb = packed;
get
{
return (byte)(this.PackedValue >> RedShift);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
set
{
this.PackedValue = this.PackedValue & 0xFF00FFFF | (uint)value << RedShift;
}
} }
/// <summary> /// <summary>
/// Gets or sets the green component. /// Gets or sets the packed representation of the Argb32 struct.
/// </summary> /// </summary>
public byte G public uint Argb
{ {
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
get get => Unsafe.As<Argb32, uint>(ref this);
{
return (byte)(this.PackedValue >> GreenShift);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
set set => Unsafe.As<Argb32, uint>(ref this) = value;
{
this.PackedValue = this.PackedValue & 0xFFFF00FF | (uint)value << GreenShift;
}
} }
/// <summary> /// <inheritdoc/>
/// Gets or sets the blue component. public uint PackedValue
/// </summary>
public byte B
{ {
[MethodImpl(MethodImplOptions.AggressiveInlining)] get => this.Argb;
get set => this.Argb = value;
{
return (byte)(this.PackedValue >> BlueShift);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
set
{
this.PackedValue = this.PackedValue & 0xFFFFFF00 | (uint)value << BlueShift;
}
}
/// <summary>
/// Gets or sets the alpha component.
/// </summary>
public byte A
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
get
{
return (byte)(this.PackedValue >> AlphaShift);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
set
{
this.PackedValue = this.PackedValue & 0x00FFFFFF | (uint)value << AlphaShift;
}
} }
/// <summary> /// <summary>
@ -210,7 +169,7 @@ namespace SixLabors.ImageSharp.PixelFormats
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool operator ==(Argb32 left, Argb32 right) public static bool operator ==(Argb32 left, Argb32 right)
{ {
return left.PackedValue == right.PackedValue; return left.Argb == right.Argb;
} }
/// <summary> /// <summary>
@ -224,14 +183,14 @@ namespace SixLabors.ImageSharp.PixelFormats
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool operator !=(Argb32 left, Argb32 right) public static bool operator !=(Argb32 left, Argb32 right)
{ {
return left.PackedValue != right.PackedValue; return left.Argb != right.Argb;
} }
/// <inheritdoc/> /// <inheritdoc/>
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public void PackFromVector4(Vector4 vector) public void PackFromVector4(Vector4 vector)
{ {
this.PackedValue = Pack(ref vector); this.Pack(ref vector);
} }
/// <inheritdoc /> /// <inheritdoc />
@ -262,7 +221,27 @@ namespace SixLabors.ImageSharp.PixelFormats
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public void PackFromRgba32(Rgba32 source) public void PackFromRgba32(Rgba32 source)
{ {
this.PackedValue = Pack(source.R, source.G, source.B, source.A); this.R = source.R;
this.G = source.G;
this.B = source.B;
this.A = source.A;
}
/// <inheritdoc/>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void PackFromArgb32(Argb32 source)
{
this.PackedValue = source.PackedValue;
}
/// <inheritdoc/>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void PackFromBgra32(Bgra32 source)
{
this.R = source.R;
this.G = source.G;
this.B = source.B;
this.A = source.A;
} }
/// <inheritdoc /> /// <inheritdoc />
@ -284,6 +263,13 @@ namespace SixLabors.ImageSharp.PixelFormats
dest.A = this.A; dest.A = this.A;
} }
/// <inheritdoc />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void ToArgb32(ref Argb32 dest)
{
dest = this;
}
/// <inheritdoc /> /// <inheritdoc />
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public void ToBgr24(ref Bgr24 dest) public void ToBgr24(ref Bgr24 dest)
@ -303,17 +289,47 @@ namespace SixLabors.ImageSharp.PixelFormats
dest.A = this.A; dest.A = this.A;
} }
/// <summary>
/// Converts the pixel to <see cref="Rgba32"/> format.
/// </summary>
/// <returns>The RGBA value</returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public Rgba32 ToRgba32() => new Rgba32(this.R, this.G, this.B, this.A);
/// <summary>
/// Converts the pixel to <see cref="Bgra32"/> format.
/// </summary>
/// <returns>The RGBA value</returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public Bgra32 ToBgra32() => new Bgra32(this.R, this.G, this.B, this.A);
/// <summary>
/// Converts the pixel to <see cref="Argb32"/> format.
/// </summary>
/// <returns>The RGBA value</returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public Argb32 ToArgb32() => this;
/// <inheritdoc/> /// <inheritdoc/>
public override bool Equals(object obj) public override bool Equals(object obj)
{ {
return obj is Argb32 && this.Equals((Argb32)obj); return obj is Argb32 argb32 && this.Equals(argb32);
} }
/// <inheritdoc/> /// <inheritdoc/>
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public bool Equals(Argb32 other) public bool Equals(Argb32 other)
{ {
return this.PackedValue == other.PackedValue; return this.Argb == other.Argb;
}
/// <summary>
/// Gets a string representation of the packed vector.
/// </summary>
/// <returns>A string representation of the packed vector.</returns>
public override string ToString()
{
return $"({this.R},{this.G},{this.B},{this.A})";
} }
/// <inheritdoc/> /// <inheritdoc/>
@ -321,65 +337,59 @@ namespace SixLabors.ImageSharp.PixelFormats
public override int GetHashCode() public override int GetHashCode()
{ {
// ReSharper disable once NonReadonlyMemberInGetHashCode // ReSharper disable once NonReadonlyMemberInGetHashCode
return this.PackedValue.GetHashCode(); return this.Argb.GetHashCode();
} }
/// <summary> /// <summary>
/// Packs the four floats into a <see cref="uint"/>. /// Gets the <see cref="Vector4"/> representation without normalizing to [0, 1]
/// </summary> /// </summary>
/// <param name="x">The x-component</param> /// <returns>A <see cref="Vector4"/> of values in [0, 255] </returns>
/// <param name="y">The y-component</param>
/// <param name="z">The z-component</param>
/// <param name="w">The w-component</param>
/// <returns>The <see cref="uint"/></returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
private static uint Pack(float x, float y, float z, float w) internal Vector4 ToByteScaledVector4()
{ {
var value = new Vector4(x, y, z, w); return new Vector4(this.R, this.G, this.B, this.A);
return Pack(ref value);
} }
/// <summary> /// <summary>
/// Packs the four floats into a <see cref="uint"/>. /// Packs the four floats into a color.
/// </summary> /// </summary>
/// <param name="x">The x-component</param> /// <param name="x">The x-component</param>
/// <param name="y">The y-component</param> /// <param name="y">The y-component</param>
/// <param name="z">The z-component</param> /// <param name="z">The z-component</param>
/// <param name="w">The w-component</param> /// <param name="w">The w-component</param>
/// <returns>The <see cref="uint"/></returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
private static uint Pack(byte x, byte y, byte z, byte w) private void Pack(float x, float y, float z, float w)
{ {
return (uint)(x << RedShift | y << GreenShift | z << BlueShift | w << AlphaShift); var value = new Vector4(x, y, z, w);
this.Pack(ref value);
} }
/// <summary> /// <summary>
/// Packs a <see cref="Vector3"/> into a uint. /// Packs a <see cref="Vector3"/> into a uint.
/// </summary> /// </summary>
/// <param name="vector">The vector containing the values to pack.</param> /// <param name="vector">The vector containing the values to pack.</param>
/// <returns>The <see cref="uint"/> containing the packed values.</returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
private static uint Pack(ref Vector3 vector) private void Pack(ref Vector3 vector)
{ {
var value = new Vector4(vector, 1); var value = new Vector4(vector, 1);
return Pack(ref value); this.Pack(ref value);
} }
/// <summary> /// <summary>
/// Packs a <see cref="Vector4"/> into a uint. /// Packs a <see cref="Vector4"/> into a color.
/// </summary> /// </summary>
/// <param name="vector">The vector containing the values to pack.</param> /// <param name="vector">The vector containing the values to pack.</param>
/// <returns>The <see cref="uint"/> containing the packed values.</returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
private static uint Pack(ref Vector4 vector) private void Pack(ref Vector4 vector)
{ {
vector *= MaxBytes; vector *= MaxBytes;
vector += Half; vector += Half;
vector = Vector4.Clamp(vector, Vector4.Zero, MaxBytes); vector = Vector4.Clamp(vector, Vector4.Zero, MaxBytes);
return (uint)(((byte)vector.X << RedShift)
| ((byte)vector.Y << GreenShift) this.R = (byte)vector.X;
| ((byte)vector.Z << BlueShift) this.G = (byte)vector.Y;
| (byte)vector.W << AlphaShift); this.B = (byte)vector.Z;
this.A = (byte)vector.W;
} }
} }
} }

Some files were not shown because too many files changed in this diff

Loading…
Cancel
Save