Browse Source

Cleanup ToString() and remove unused operator

af/merge-core
James Jackson-South 8 years ago
parent
commit
7a9efabaea
  1. 18
      src/ImageSharp/ColorSpaces/CieLab.cs
  2. 22
      src/ImageSharp/ColorSpaces/CieLch.cs
  3. 16
      src/ImageSharp/ColorSpaces/CieLchuv.cs
  4. 18
      src/ImageSharp/ColorSpaces/CieLuv.cs
  5. 14
      src/ImageSharp/ColorSpaces/CieXyChromaticityCoordinates.cs
  6. 14
      src/ImageSharp/ColorSpaces/CieXyy.cs
  7. 14
      src/ImageSharp/ColorSpaces/CieXyz.cs
  8. 16
      src/ImageSharp/ColorSpaces/Cmyk.cs
  9. 16
      src/ImageSharp/ColorSpaces/Hsl.cs
  10. 66
      src/ImageSharp/ColorSpaces/Hsv.cs
  11. 18
      src/ImageSharp/ColorSpaces/HunterLab.cs
  12. 22
      src/ImageSharp/ColorSpaces/LinearRgb.cs
  13. 16
      src/ImageSharp/ColorSpaces/Lms.cs
  14. 24
      src/ImageSharp/ColorSpaces/Rgb.cs
  15. 14
      src/ImageSharp/ColorSpaces/YCbCr.cs

18
src/ImageSharp/ColorSpaces/CieLab.cs

@ -49,7 +49,7 @@ namespace SixLabors.ImageSharp.ColorSpaces
/// <param name="a">The a (green - magenta) component.</param>
/// <param name="b">The b (blue - yellow) component.</param>
/// <remarks>Uses <see cref="DefaultWhitePoint"/> as white point.</remarks>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
[MethodImpl(InliningOptions.ShortMethod)]
public CieLab(float l, float a, float b)
: this(l, a, b, DefaultWhitePoint)
{
@ -62,7 +62,7 @@ namespace SixLabors.ImageSharp.ColorSpaces
/// <param name="a">The a (green - magenta) component.</param>
/// <param name="b">The b (blue - yellow) component.</param>
/// <param name="whitePoint">The reference white point. <see cref="Illuminants"/></param>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
[MethodImpl(InliningOptions.ShortMethod)]
public CieLab(float l, float a, float b, CieXyz whitePoint)
{
this.L = l;
@ -76,7 +76,7 @@ namespace SixLabors.ImageSharp.ColorSpaces
/// </summary>
/// <param name="vector">The vector representing the l, a, b components.</param>
/// <remarks>Uses <see cref="DefaultWhitePoint"/> as white point.</remarks>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
[MethodImpl(InliningOptions.ShortMethod)]
public CieLab(Vector3 vector)
: this(vector, DefaultWhitePoint)
{
@ -87,7 +87,7 @@ namespace SixLabors.ImageSharp.ColorSpaces
/// </summary>
/// <param name="vector">The vector representing the l, a, b components.</param>
/// <param name="whitePoint">The reference white point. <see cref="Illuminants"/></param>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
[MethodImpl(InliningOptions.ShortMethod)]
public CieLab(Vector3 vector, CieXyz whitePoint)
: this()
{
@ -105,7 +105,7 @@ namespace SixLabors.ImageSharp.ColorSpaces
/// <returns>
/// True if the current left is equal to the <paramref name="right"/> parameter; otherwise, false.
/// </returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
[MethodImpl(InliningOptions.ShortMethod)]
public static bool operator ==(CieLab left, CieLab right) => left.Equals(right);
/// <summary>
@ -116,7 +116,7 @@ namespace SixLabors.ImageSharp.ColorSpaces
/// <returns>
/// True if the current left is unequal to the <paramref name="right"/> parameter; otherwise, false.
/// </returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
[MethodImpl(InliningOptions.ShortMethod)]
public static bool operator !=(CieLab left, CieLab right) => !left.Equals(right);
/// <inheritdoc/>
@ -131,16 +131,14 @@ namespace SixLabors.ImageSharp.ColorSpaces
/// <inheritdoc/>
public override string ToString()
{
return this.Equals(default)
? "CieLab [Empty]"
: $"CieLab [ L={this.L:#0.##}, A={this.A:#0.##}, B={this.B:#0.##}]";
return $"CieLab [ L={this.L:#0.##}, A={this.A:#0.##}, B={this.B:#0.##}]";
}
/// <inheritdoc/>
public override bool Equals(object obj) => obj is CieLab other && this.Equals(other);
/// <inheritdoc/>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
[MethodImpl(InliningOptions.ShortMethod)]
public bool Equals(CieLab other)
{
return this.L.Equals(other.L)

22
src/ImageSharp/ColorSpaces/CieLch.cs

@ -49,7 +49,7 @@ namespace SixLabors.ImageSharp.ColorSpaces
/// <param name="c">The chroma, relative saturation.</param>
/// <param name="h">The hue in degrees.</param>
/// <remarks>Uses <see cref="DefaultWhitePoint"/> as white point.</remarks>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
[MethodImpl(InliningOptions.ShortMethod)]
public CieLch(float l, float c, float h)
: this(l, c, h, DefaultWhitePoint)
{
@ -62,7 +62,7 @@ namespace SixLabors.ImageSharp.ColorSpaces
/// <param name="c">The chroma, relative saturation.</param>
/// <param name="h">The hue in degrees.</param>
/// <param name="whitePoint">The reference white point. <see cref="Illuminants"/></param>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
[MethodImpl(InliningOptions.ShortMethod)]
public CieLch(float l, float c, float h, CieXyz whitePoint)
{
this.L = l;
@ -76,7 +76,7 @@ namespace SixLabors.ImageSharp.ColorSpaces
/// </summary>
/// <param name="vector">The vector representing the l, c, h components.</param>
/// <remarks>Uses <see cref="DefaultWhitePoint"/> as white point.</remarks>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
[MethodImpl(InliningOptions.ShortMethod)]
public CieLch(Vector3 vector)
: this(vector, DefaultWhitePoint)
{
@ -87,7 +87,7 @@ namespace SixLabors.ImageSharp.ColorSpaces
/// </summary>
/// <param name="vector">The vector representing the l, c, h components.</param>
/// <param name="whitePoint">The reference white point. <see cref="Illuminants"/></param>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
[MethodImpl(InliningOptions.ShortMethod)]
public CieLch(Vector3 vector, CieXyz whitePoint)
{
this.L = vector.X;
@ -104,7 +104,7 @@ namespace SixLabors.ImageSharp.ColorSpaces
/// <returns>
/// True if the current left is equal to the <paramref name="right"/> parameter; otherwise, false.
/// </returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
[MethodImpl(InliningOptions.ShortMethod)]
public static bool operator ==(CieLch left, CieLch right)
{
return left.Equals(right);
@ -118,7 +118,7 @@ namespace SixLabors.ImageSharp.ColorSpaces
/// <returns>
/// True if the current left is unequal to the <paramref name="right"/> parameter; otherwise, false.
/// </returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
[MethodImpl(InliningOptions.ShortMethod)]
public static bool operator !=(CieLch left, CieLch right) => !left.Equals(right);
/// <inheritdoc/>
@ -133,17 +133,15 @@ namespace SixLabors.ImageSharp.ColorSpaces
/// <inheritdoc/>
public override string ToString()
{
return this.Equals(default)
? "CieLch [Empty]"
: $"CieLch [ L={this.L:#0.##}, C={this.C:#0.##}, H={this.H:#0.##}]";
return $"CieLch [ L={this.L:#0.##}, C={this.C:#0.##}, H={this.H:#0.##}]";
}
/// <inheritdoc/>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
[MethodImpl(InliningOptions.ShortMethod)]
public override bool Equals(object obj) => obj is CieLch other && this.Equals(other);
/// <inheritdoc/>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
[MethodImpl(InliningOptions.ShortMethod)]
public bool Equals(CieLch other)
{
return this.L.Equals(other.L)
@ -159,7 +157,7 @@ namespace SixLabors.ImageSharp.ColorSpaces
/// A value ranging from 0 to 100.
/// </remarks>
/// <returns>The <see cref="float"/></returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
[MethodImpl(InliningOptions.ShortMethod)]
public float Saturation()
{
float result = 100 * (this.C / this.L);

16
src/ImageSharp/ColorSpaces/CieLchuv.cs

@ -49,7 +49,7 @@ namespace SixLabors.ImageSharp.ColorSpaces
/// <param name="c">The chroma, relative saturation.</param>
/// <param name="h">The hue in degrees.</param>
/// <remarks>Uses <see cref="DefaultWhitePoint"/> as white point.</remarks>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
[MethodImpl(InliningOptions.ShortMethod)]
public CieLchuv(float l, float c, float h)
: this(l, c, h, DefaultWhitePoint)
{
@ -62,7 +62,7 @@ namespace SixLabors.ImageSharp.ColorSpaces
/// <param name="c">The chroma, relative saturation.</param>
/// <param name="h">The hue in degrees.</param>
/// <param name="whitePoint">The reference white point. <see cref="Illuminants"/></param>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
[MethodImpl(InliningOptions.ShortMethod)]
public CieLchuv(float l, float c, float h, CieXyz whitePoint)
{
this.L = l;
@ -76,7 +76,7 @@ namespace SixLabors.ImageSharp.ColorSpaces
/// </summary>
/// <param name="vector">The vector representing the l, c, h components.</param>
/// <remarks>Uses <see cref="DefaultWhitePoint"/> as white point.</remarks>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
[MethodImpl(InliningOptions.ShortMethod)]
public CieLchuv(Vector3 vector)
: this(vector, DefaultWhitePoint)
{
@ -87,7 +87,7 @@ namespace SixLabors.ImageSharp.ColorSpaces
/// </summary>
/// <param name="vector">The vector representing the l, c, h components.</param>
/// <param name="whitePoint">The reference white point. <see cref="Illuminants"/></param>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
[MethodImpl(InliningOptions.ShortMethod)]
public CieLchuv(Vector3 vector, CieXyz whitePoint)
: this()
{
@ -129,16 +129,14 @@ namespace SixLabors.ImageSharp.ColorSpaces
/// <inheritdoc/>
public override string ToString()
{
return this.Equals(default)
? "CieLchuv [Empty]"
: $"CieLchuv [ L={this.L:#0.##}, C={this.C:#0.##}, H={this.H:#0.##}";
return $"CieLchuv [ L={this.L:#0.##}, C={this.C:#0.##}, H={this.H:#0.##}";
}
/// <inheritdoc/>
public override bool Equals(object obj) => obj is CieLchuv other && this.Equals(other);
/// <inheritdoc/>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
[MethodImpl(InliningOptions.ShortMethod)]
public bool Equals(CieLchuv other)
{
return this.L.Equals(other.L)
@ -154,7 +152,7 @@ namespace SixLabors.ImageSharp.ColorSpaces
/// A value ranging from 0 to 100.
/// </remarks>
/// <returns>The <see cref="float"/></returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
[MethodImpl(InliningOptions.ShortMethod)]
public float Saturation()
{
float result = 100 * (this.C / this.L);

18
src/ImageSharp/ColorSpaces/CieLuv.cs

@ -51,7 +51,7 @@ namespace SixLabors.ImageSharp.ColorSpaces
/// <param name="u">The blue-yellow chromaticity coordinate of the given whitepoint.</param>
/// <param name="v">The red-green chromaticity coordinate of the given whitepoint.</param>
/// <remarks>Uses <see cref="DefaultWhitePoint"/> as white point.</remarks>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
[MethodImpl(InliningOptions.ShortMethod)]
public CieLuv(float l, float u, float v)
: this(l, u, v, DefaultWhitePoint)
{
@ -64,7 +64,7 @@ namespace SixLabors.ImageSharp.ColorSpaces
/// <param name="u">The blue-yellow chromaticity coordinate of the given whitepoint.</param>
/// <param name="v">The red-green chromaticity coordinate of the given whitepoint.</param>
/// <param name="whitePoint">The reference white point. <see cref="Illuminants"/></param>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
[MethodImpl(InliningOptions.ShortMethod)]
public CieLuv(float l, float u, float v, CieXyz whitePoint)
{
this.L = l;
@ -78,7 +78,7 @@ namespace SixLabors.ImageSharp.ColorSpaces
/// </summary>
/// <param name="vector">The vector representing the l, u, v components.</param>
/// <remarks>Uses <see cref="DefaultWhitePoint"/> as white point.</remarks>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
[MethodImpl(InliningOptions.ShortMethod)]
public CieLuv(Vector3 vector)
: this(vector, DefaultWhitePoint)
{
@ -89,7 +89,7 @@ namespace SixLabors.ImageSharp.ColorSpaces
/// </summary>
/// <param name="vector">The vector representing the l, u, v components.</param>
/// <param name="whitePoint">The reference white point. <see cref="Illuminants"/></param>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
[MethodImpl(InliningOptions.ShortMethod)]
public CieLuv(Vector3 vector, CieXyz whitePoint)
{
this.L = vector.X;
@ -106,7 +106,7 @@ namespace SixLabors.ImageSharp.ColorSpaces
/// <returns>
/// True if the current left is equal to the <paramref name="right"/> parameter; otherwise, false.
/// </returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
[MethodImpl(InliningOptions.ShortMethod)]
public static bool operator ==(CieLuv left, CieLuv right) => left.Equals(right);
/// <summary>
@ -117,7 +117,7 @@ namespace SixLabors.ImageSharp.ColorSpaces
/// <returns>
/// True if the current left is unequal to the <paramref name="right"/> parameter; otherwise, false.
/// </returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
[MethodImpl(InliningOptions.ShortMethod)]
public static bool operator !=(CieLuv left, CieLuv right) => !left.Equals(right);
/// <inheritdoc/>
@ -132,16 +132,14 @@ namespace SixLabors.ImageSharp.ColorSpaces
/// <inheritdoc/>
public override string ToString()
{
return this.Equals(default)
? "CieLuv [ Empty ]"
: $"CieLuv [ L={this.L:#0.##}, U={this.U:#0.##}, V={this.V:#0.##} ]";
return $"CieLuv [ L={this.L:#0.##}, U={this.U:#0.##}, V={this.V:#0.##} ]";
}
/// <inheritdoc/>
public override bool Equals(object obj) => obj is CieLuv other && this.Equals(other);
/// <inheritdoc/>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
[MethodImpl(InliningOptions.ShortMethod)]
public bool Equals(CieLuv other)
{
return this.L.Equals(other.L)

14
src/ImageSharp/ColorSpaces/CieXyChromaticityCoordinates.cs

@ -33,7 +33,7 @@ namespace SixLabors.ImageSharp.ColorSpaces
/// </summary>
/// <param name="x">Chromaticity coordinate x (usually from 0 to 1)</param>
/// <param name="y">Chromaticity coordinate y (usually from 0 to 1)</param>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
[MethodImpl(InliningOptions.ShortMethod)]
public CieXyChromaticityCoordinates(float x, float y)
{
this.X = x;
@ -48,7 +48,7 @@ namespace SixLabors.ImageSharp.ColorSpaces
/// <returns>
/// True if the current left is equal to the <paramref name="right"/> parameter; otherwise, false.
/// </returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
[MethodImpl(InliningOptions.ShortMethod)]
public static bool operator ==(CieXyChromaticityCoordinates left, CieXyChromaticityCoordinates right)
{
return left.Equals(right);
@ -62,29 +62,27 @@ namespace SixLabors.ImageSharp.ColorSpaces
/// <returns>
/// True if the current left is unequal to the <paramref name="right"/> parameter; otherwise, false.
/// </returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
[MethodImpl(InliningOptions.ShortMethod)]
public static bool operator !=(CieXyChromaticityCoordinates left, CieXyChromaticityCoordinates right)
{
return !left.Equals(right);
}
/// <inheritdoc />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
[MethodImpl(InliningOptions.ShortMethod)]
public override int GetHashCode() => HashHelpers.Combine(this.X.GetHashCode(), this.Y.GetHashCode());
/// <inheritdoc/>
public override string ToString()
{
return this.Equals(default)
? "CieXyChromaticityCoordinates [Empty]"
: $"CieXyChromaticityCoordinates [ X={this.X:#0.##}, Y={this.Y:#0.##}]";
return $"CieXyChromaticityCoordinates [ X={this.X:#0.##}, Y={this.Y:#0.##}]";
}
/// <inheritdoc/>
public override bool Equals(object obj) => obj is CieXyChromaticityCoordinates other && this.Equals(other);
/// <inheritdoc/>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
[MethodImpl(InliningOptions.ShortMethod)]
public bool Equals(CieXyChromaticityCoordinates other) => this.X.Equals(other.X) && this.Y.Equals(other.Y);
}
}

14
src/ImageSharp/ColorSpaces/CieXyy.cs

@ -37,7 +37,7 @@ namespace SixLabors.ImageSharp.ColorSpaces
/// <param name="x">The x chroma component.</param>
/// <param name="y">The y chroma component.</param>
/// <param name="yl">The y luminance component.</param>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
[MethodImpl(InliningOptions.ShortMethod)]
public CieXyy(float x, float y, float yl)
{
// Not clamping as documentation about this space seems to indicate "usual" ranges
@ -50,7 +50,7 @@ namespace SixLabors.ImageSharp.ColorSpaces
/// Initializes a new instance of the <see cref="CieXyy"/> struct.
/// </summary>
/// <param name="vector">The vector representing the x, y, Y components.</param>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
[MethodImpl(InliningOptions.ShortMethod)]
public CieXyy(Vector3 vector)
: this()
{
@ -68,7 +68,7 @@ namespace SixLabors.ImageSharp.ColorSpaces
/// <returns>
/// True if the current left is equal to the <paramref name="right"/> parameter; otherwise, false.
/// </returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
[MethodImpl(InliningOptions.ShortMethod)]
public static bool operator ==(CieXyy left, CieXyy right) => left.Equals(right);
/// <summary>
@ -79,7 +79,7 @@ namespace SixLabors.ImageSharp.ColorSpaces
/// <returns>
/// True if the current left is unequal to the <paramref name="right"/> parameter; otherwise, false.
/// </returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
[MethodImpl(InliningOptions.ShortMethod)]
public static bool operator !=(CieXyy left, CieXyy right) => !left.Equals(right);
/// <inheritdoc/>
@ -93,9 +93,7 @@ namespace SixLabors.ImageSharp.ColorSpaces
/// <inheritdoc/>
public override string ToString()
{
return this.Equals(default)
? "CieXyy [ Empty ]"
: $"CieXyy [ X={this.X:#0.##}, Y={this.Y:#0.##}, Yl={this.Yl:#0.##} ]";
return $"CieXyy [ X={this.X:#0.##}, Y={this.Y:#0.##}, Yl={this.Yl:#0.##} ]";
}
/// <inheritdoc/>
@ -105,7 +103,7 @@ namespace SixLabors.ImageSharp.ColorSpaces
}
/// <inheritdoc/>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
[MethodImpl(InliningOptions.ShortMethod)]
public bool Equals(CieXyy other)
{
return this.X.Equals(other.X)

14
src/ImageSharp/ColorSpaces/CieXyz.cs

@ -38,7 +38,7 @@ namespace SixLabors.ImageSharp.ColorSpaces
/// <param name="x">X is a mix (a linear combination) of cone response curves chosen to be nonnegative</param>
/// <param name="y">The y luminance component.</param>
/// <param name="z">Z is quasi-equal to blue stimulation, or the S cone of the human eye.</param>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
[MethodImpl(InliningOptions.ShortMethod)]
public CieXyz(float x, float y, float z)
: this(new Vector3(x, y, z))
{
@ -69,7 +69,7 @@ namespace SixLabors.ImageSharp.ColorSpaces
/// <returns>
/// True if the current left is equal to the <paramref name="right"/> parameter; otherwise, false.
/// </returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
[MethodImpl(InliningOptions.ShortMethod)]
public static bool operator ==(CieXyz left, CieXyz right)
{
return left.Equals(right);
@ -83,7 +83,7 @@ namespace SixLabors.ImageSharp.ColorSpaces
/// <returns>
/// True if the current left is unequal to the <paramref name="right"/> parameter; otherwise, false.
/// </returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
[MethodImpl(InliningOptions.ShortMethod)]
public static bool operator !=(CieXyz left, CieXyz right)
{
return !left.Equals(right);
@ -93,7 +93,7 @@ namespace SixLabors.ImageSharp.ColorSpaces
/// Returns a new <see cref="Vector3"/> representing this instance.
/// </summary>
/// <returns>The <see cref="Vector3"/>.</returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
[MethodImpl(InliningOptions.ShortMethod)]
public Vector3 ToVector3() => new Vector3(this.X, this.Y, this.Z);
/// <inheritdoc/>
@ -107,16 +107,14 @@ namespace SixLabors.ImageSharp.ColorSpaces
/// <inheritdoc/>
public override string ToString()
{
return this.Equals(default)
? "CieXyz [ Empty ]"
: $"CieXyz [ X={this.X:#0.##}, Y={this.Y:#0.##}, Z={this.Z:#0.##} ]";
return $"CieXyz [ X={this.X:#0.##}, Y={this.Y:#0.##}, Z={this.Z:#0.##} ]";
}
/// <inheritdoc/>
public override bool Equals(object obj) => obj is CieXyz other && this.Equals(other);
/// <inheritdoc/>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
[MethodImpl(InliningOptions.ShortMethod)]
public bool Equals(CieXyz other)
{
return this.X.Equals(other.X)

16
src/ImageSharp/ColorSpaces/Cmyk.cs

@ -43,7 +43,7 @@ namespace SixLabors.ImageSharp.ColorSpaces
/// <param name="m">The magenta component.</param>
/// <param name="y">The yellow component.</param>
/// <param name="k">The keyline black component.</param>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
[MethodImpl(InliningOptions.ShortMethod)]
public Cmyk(float c, float m, float y, float k)
: this(new Vector4(c, m, y, k))
{
@ -53,7 +53,7 @@ namespace SixLabors.ImageSharp.ColorSpaces
/// Initializes a new instance of the <see cref="Cmyk"/> struct.
/// </summary>
/// <param name="vector">The vector representing the c, m, y, k components.</param>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
[MethodImpl(InliningOptions.ShortMethod)]
public Cmyk(Vector4 vector)
{
vector = Vector4.Clamp(vector, Vector4.Zero, Vector4.One);
@ -71,7 +71,7 @@ namespace SixLabors.ImageSharp.ColorSpaces
/// <returns>
/// True if the current left is equal to the <paramref name="right"/> parameter; otherwise, false.
/// </returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
[MethodImpl(InliningOptions.ShortMethod)]
public static bool operator ==(Cmyk left, Cmyk right) => left.Equals(right);
/// <summary>
@ -82,11 +82,11 @@ namespace SixLabors.ImageSharp.ColorSpaces
/// <returns>
/// True if the current left is unequal to the <paramref name="right"/> parameter; otherwise, false.
/// </returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
[MethodImpl(InliningOptions.ShortMethod)]
public static bool operator !=(Cmyk left, Cmyk right) => !left.Equals(right);
/// <inheritdoc/>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
[MethodImpl(InliningOptions.ShortMethod)]
public override int GetHashCode()
{
int hash = this.C.GetHashCode();
@ -98,16 +98,14 @@ namespace SixLabors.ImageSharp.ColorSpaces
/// <inheritdoc/>
public override string ToString()
{
return this.Equals(default)
? "Cmyk [Empty]"
: $"Cmyk [ C={this.C:#0.##}, M={this.M:#0.##}, Y={this.Y:#0.##}, K={this.K:#0.##}]";
return $"Cmyk [ C={this.C:#0.##}, M={this.M:#0.##}, Y={this.Y:#0.##}, K={this.K:#0.##}]";
}
/// <inheritdoc/>
public override bool Equals(object obj) => obj is Cmyk other && this.Equals(other);
/// <inheritdoc/>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
[MethodImpl(InliningOptions.ShortMethod)]
public bool Equals(Cmyk other)
{
return this.C.Equals(other.C)

16
src/ImageSharp/ColorSpaces/Hsl.cs

@ -41,7 +41,7 @@ namespace SixLabors.ImageSharp.ColorSpaces
/// <param name="h">The h hue component.</param>
/// <param name="s">The s saturation component.</param>
/// <param name="l">The l value (lightness) component.</param>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
[MethodImpl(InliningOptions.ShortMethod)]
public Hsl(float h, float s, float l)
: this(new Vector3(h, s, l))
{
@ -51,7 +51,7 @@ namespace SixLabors.ImageSharp.ColorSpaces
/// Initializes a new instance of the <see cref="Hsl"/> struct.
/// </summary>
/// <param name="vector">The vector representing the h, s, l components.</param>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
[MethodImpl(InliningOptions.ShortMethod)]
public Hsl(Vector3 vector)
{
vector = Vector3.Clamp(vector, Vector3.Zero, VectorMax);
@ -70,7 +70,7 @@ namespace SixLabors.ImageSharp.ColorSpaces
/// <returns>
/// True if the current left is equal to the <paramref name="right"/> parameter; otherwise, false.
/// </returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
[MethodImpl(InliningOptions.ShortMethod)]
public static bool operator ==(Hsl left, Hsl right) => left.Equals(right);
/// <summary>
@ -81,11 +81,11 @@ namespace SixLabors.ImageSharp.ColorSpaces
/// <returns>
/// True if the current left is unequal to the <paramref name="right"/> parameter; otherwise, false.
/// </returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
[MethodImpl(InliningOptions.ShortMethod)]
public static bool operator !=(Hsl left, Hsl right) => !left.Equals(right);
/// <inheritdoc/>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
[MethodImpl(InliningOptions.ShortMethod)]
public override int GetHashCode()
{
int hash = this.H.GetHashCode();
@ -96,16 +96,14 @@ namespace SixLabors.ImageSharp.ColorSpaces
/// <inheritdoc/>
public override string ToString()
{
return this.Equals(default)
? "Hsl [ Empty ]"
: $"Hsl [ H={this.H:#0.##}, S={this.S:#0.##}, L={this.L:#0.##} ]";
return $"Hsl [ H={this.H:#0.##}, S={this.S:#0.##}, L={this.L:#0.##} ]";
}
/// <inheritdoc/>
public override bool Equals(object obj) => obj is Hsl other && this.Equals(other);
/// <inheritdoc/>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
[MethodImpl(InliningOptions.ShortMethod)]
public bool Equals(Hsl other)
{
return this.H.Equals(other.H)

66
src/ImageSharp/ColorSpaces/Hsv.cs

@ -44,7 +44,7 @@ namespace SixLabors.ImageSharp.ColorSpaces
/// <param name="h">The h hue component.</param>
/// <param name="s">The s saturation component.</param>
/// <param name="v">The v value (brightness) component.</param>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
[MethodImpl(InliningOptions.ShortMethod)]
public Hsv(float h, float s, float v)
: this(new Vector3(h, s, v))
{
@ -54,7 +54,7 @@ namespace SixLabors.ImageSharp.ColorSpaces
/// Initializes a new instance of the <see cref="Hsv"/> struct.
/// </summary>
/// <param name="vector">The vector representing the h, s, v components.</param>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
[MethodImpl(InliningOptions.ShortMethod)]
public Hsv(Vector3 vector)
{
vector = Vector3.Clamp(vector, Vector3.Zero, VectorMax);
@ -63,56 +63,6 @@ namespace SixLabors.ImageSharp.ColorSpaces
this.V = vector.Z;
}
/// <summary>
/// Allows the implicit conversion of an instance of <see cref="Rgba32"/> to a
/// <see cref="Hsv"/>.
/// </summary>
/// <param name="color">The instance of <see cref="Rgba32"/> to convert.</param>
/// <returns>
/// An instance of <see cref="Hsv"/>.
/// </returns>
public static implicit operator Hsv(Rgba32 color)
{
float r = color.R / 255F;
float g = color.G / 255F;
float b = color.B / 255F;
float max = MathF.Max(r, MathF.Max(g, b));
float min = MathF.Min(r, MathF.Min(g, b));
float chroma = max - min;
float h = 0;
float s = 0;
float v = max;
if (MathF.Abs(chroma) < Constants.Epsilon)
{
return new Hsv(0, s, v);
}
if (MathF.Abs(r - max) < Constants.Epsilon)
{
h = (g - b) / chroma;
}
else if (MathF.Abs(g - max) < Constants.Epsilon)
{
h = 2 + ((b - r) / chroma);
}
else if (MathF.Abs(b - max) < Constants.Epsilon)
{
h = 4 + ((r - g) / chroma);
}
h *= 60;
if (h < 0.0)
{
h += 360;
}
s = chroma / v;
return new Hsv(h, s, v);
}
/// <summary>
/// Compares two <see cref="Hsv"/> objects for equality.
/// </summary>
@ -121,7 +71,7 @@ namespace SixLabors.ImageSharp.ColorSpaces
/// <returns>
/// True if the current left is equal to the <paramref name="right"/> parameter; otherwise, false.
/// </returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
[MethodImpl(InliningOptions.ShortMethod)]
public static bool operator ==(Hsv left, Hsv right) => left.Equals(right);
/// <summary>
@ -132,11 +82,11 @@ namespace SixLabors.ImageSharp.ColorSpaces
/// <returns>
/// True if the current left is unequal to the <paramref name="right"/> parameter; otherwise, false.
/// </returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
[MethodImpl(InliningOptions.ShortMethod)]
public static bool operator !=(Hsv left, Hsv right) => !left.Equals(right);
/// <inheritdoc/>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
[MethodImpl(InliningOptions.ShortMethod)]
public override int GetHashCode()
{
int hash = this.H.GetHashCode();
@ -147,16 +97,14 @@ namespace SixLabors.ImageSharp.ColorSpaces
/// <inheritdoc/>
public override string ToString()
{
return this.Equals(default)
? "Hsv [ Empty ]"
: $"Hsv [ H={this.H:#0.##}, S={this.S:#0.##}, V={this.V:#0.##} ]";
return $"Hsv [ H={this.H:#0.##}, S={this.S:#0.##}, V={this.V:#0.##} ]";
}
/// <inheritdoc/>
public override bool Equals(object obj) => obj is Hsv other && this.Equals(other);
/// <inheritdoc/>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
[MethodImpl(InliningOptions.ShortMethod)]
public bool Equals(Hsv other)
{
return this.H.Equals(other.H)

18
src/ImageSharp/ColorSpaces/HunterLab.cs

@ -50,7 +50,7 @@ namespace SixLabors.ImageSharp.ColorSpaces
/// <param name="a">The a (green - magenta) component.</param>
/// <param name="b">The b (blue - yellow) component.</param>
/// <remarks>Uses <see cref="DefaultWhitePoint"/> as white point.</remarks>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
[MethodImpl(InliningOptions.ShortMethod)]
public HunterLab(float l, float a, float b)
: this(new Vector3(l, a, b), DefaultWhitePoint)
{
@ -63,7 +63,7 @@ namespace SixLabors.ImageSharp.ColorSpaces
/// <param name="a">The a (green - magenta) component.</param>
/// <param name="b">The b (blue - yellow) component.</param>
/// <param name="whitePoint">The reference white point. <see cref="Illuminants"/></param>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
[MethodImpl(InliningOptions.ShortMethod)]
public HunterLab(float l, float a, float b, CieXyz whitePoint)
: this(new Vector3(l, a, b), whitePoint)
{
@ -74,7 +74,7 @@ namespace SixLabors.ImageSharp.ColorSpaces
/// </summary>
/// <param name="vector">The vector representing the l, a, b components.</param>
/// <remarks>Uses <see cref="DefaultWhitePoint"/> as white point.</remarks>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
[MethodImpl(InliningOptions.ShortMethod)]
public HunterLab(Vector3 vector)
: this(vector, DefaultWhitePoint)
{
@ -85,7 +85,7 @@ namespace SixLabors.ImageSharp.ColorSpaces
/// </summary>
/// <param name="vector">The vector representing the l a b components.</param>
/// <param name="whitePoint">The reference white point. <see cref="Illuminants"/></param>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
[MethodImpl(InliningOptions.ShortMethod)]
public HunterLab(Vector3 vector, CieXyz whitePoint)
{
// TODO: Clamp?
@ -113,11 +113,11 @@ namespace SixLabors.ImageSharp.ColorSpaces
/// <returns>
/// True if the current left is unequal to the <paramref name="right"/> parameter; otherwise, false.
/// </returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
[MethodImpl(InliningOptions.ShortMethod)]
public static bool operator !=(HunterLab left, HunterLab right) => !left.Equals(right);
/// <inheritdoc/>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
[MethodImpl(InliningOptions.ShortMethod)]
public override int GetHashCode()
{
int hash = this.L.GetHashCode();
@ -129,16 +129,14 @@ namespace SixLabors.ImageSharp.ColorSpaces
/// <inheritdoc/>
public override string ToString()
{
return this.Equals(default)
? "HunterLab [Empty]"
: $"HunterLab [ L={this.L:#0.##}, A={this.A:#0.##}, B={this.B:#0.##}]";
return $"HunterLab [ L={this.L:#0.##}, A={this.A:#0.##}, B={this.B:#0.##}]";
}
/// <inheritdoc/>
public override bool Equals(object obj) => obj is HunterLab other && this.Equals(other);
/// <inheritdoc/>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
[MethodImpl(InliningOptions.ShortMethod)]
public bool Equals(HunterLab other)
{
return this.L.Equals(other.L)

22
src/ImageSharp/ColorSpaces/LinearRgb.cs

@ -47,7 +47,7 @@ namespace SixLabors.ImageSharp.ColorSpaces
/// <param name="r">The red component ranging between 0 and 1.</param>
/// <param name="g">The green component ranging between 0 and 1.</param>
/// <param name="b">The blue component ranging between 0 and 1.</param>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
[MethodImpl(InliningOptions.ShortMethod)]
public LinearRgb(float r, float g, float b)
: this(new Vector3(r, g, b))
{
@ -60,7 +60,7 @@ namespace SixLabors.ImageSharp.ColorSpaces
/// <param name="g">The green component ranging between 0 and 1.</param>
/// <param name="b">The blue component ranging between 0 and 1.</param>
/// <param name="workingSpace">The rgb working space.</param>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
[MethodImpl(InliningOptions.ShortMethod)]
public LinearRgb(float r, float g, float b, RgbWorkingSpace workingSpace)
: this(new Vector3(r, g, b), workingSpace)
{
@ -70,7 +70,7 @@ namespace SixLabors.ImageSharp.ColorSpaces
/// Initializes a new instance of the <see cref="LinearRgb"/> struct.
/// </summary>
/// <param name="vector">The vector representing the r, g, b components.</param>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
[MethodImpl(InliningOptions.ShortMethod)]
public LinearRgb(Vector3 vector)
: this(vector, DefaultWorkingSpace)
{
@ -81,7 +81,7 @@ namespace SixLabors.ImageSharp.ColorSpaces
/// </summary>
/// <param name="vector">The vector representing the r, g, b components.</param>
/// <param name="workingSpace">The LinearRgb working space.</param>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
[MethodImpl(InliningOptions.ShortMethod)]
public LinearRgb(Vector3 vector, RgbWorkingSpace workingSpace)
{
// Clamp to 0-1 range.
@ -100,7 +100,7 @@ namespace SixLabors.ImageSharp.ColorSpaces
/// <returns>
/// True if the current left is equal to the <paramref name="right"/> parameter; otherwise, false.
/// </returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
[MethodImpl(InliningOptions.ShortMethod)]
public static bool operator ==(LinearRgb left, LinearRgb right) => left.Equals(right);
/// <summary>
@ -111,18 +111,18 @@ namespace SixLabors.ImageSharp.ColorSpaces
/// <returns>
/// True if the current left is unequal to the <paramref name="right"/> parameter; otherwise, false.
/// </returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
[MethodImpl(InliningOptions.ShortMethod)]
public static bool operator !=(LinearRgb left, LinearRgb right) => !left.Equals(right);
/// <summary>
/// Returns a new <see cref="Vector3"/> representing this instance.
/// </summary>
/// <returns>The <see cref="Vector3"/>.</returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
[MethodImpl(InliningOptions.ShortMethod)]
public Vector3 ToVector3() => new Vector3(this.R, this.G, this.B);
/// <inheritdoc/>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
[MethodImpl(InliningOptions.ShortMethod)]
public override int GetHashCode()
{
int hash = this.R.GetHashCode();
@ -133,16 +133,14 @@ namespace SixLabors.ImageSharp.ColorSpaces
/// <inheritdoc/>
public override string ToString()
{
return this.Equals(default)
? "LinearRgb [ Empty ]"
: $"LinearRgb [ R={this.R:#0.##}, G={this.G:#0.##}, B={this.B:#0.##} ]";
return $"LinearRgb [ R={this.R:#0.##}, G={this.G:#0.##}, B={this.B:#0.##} ]";
}
/// <inheritdoc/>
public override bool Equals(object obj) => obj is LinearRgb other && this.Equals(other);
/// <inheritdoc/>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
[MethodImpl(InliningOptions.ShortMethod)]
public bool Equals(LinearRgb other)
{
return this.R.Equals(other.R)

16
src/ImageSharp/ColorSpaces/Lms.cs

@ -38,7 +38,7 @@ namespace SixLabors.ImageSharp.ColorSpaces
/// <param name="l">L represents the responsivity at long wavelengths.</param>
/// <param name="m">M represents the responsivity at medium wavelengths.</param>
/// <param name="s">S represents the responsivity at short wavelengths.</param>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
[MethodImpl(InliningOptions.ShortMethod)]
public Lms(float l, float m, float s)
{
this.L = l;
@ -50,7 +50,7 @@ namespace SixLabors.ImageSharp.ColorSpaces
/// Initializes a new instance of the <see cref="Lms"/> struct.
/// </summary>
/// <param name="vector">The vector representing the l, m, s components.</param>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
[MethodImpl(InliningOptions.ShortMethod)]
public Lms(Vector3 vector)
{
// Not clamping as documentation about this space seems to indicate "usual" ranges
@ -67,7 +67,7 @@ namespace SixLabors.ImageSharp.ColorSpaces
/// <returns>
/// True if the current left is equal to the <paramref name="right"/> parameter; otherwise, false.
/// </returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
[MethodImpl(InliningOptions.ShortMethod)]
public static bool operator ==(Lms left, Lms right) => left.Equals(right);
/// <summary>
@ -78,14 +78,14 @@ namespace SixLabors.ImageSharp.ColorSpaces
/// <returns>
/// True if the current left is unequal to the <paramref name="right"/> parameter; otherwise, false.
/// </returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
[MethodImpl(InliningOptions.ShortMethod)]
public static bool operator !=(Lms left, Lms right) => !left.Equals(right);
/// <summary>
/// Returns a new <see cref="Vector3"/> representing this instance.
/// </summary>
/// <returns>The <see cref="Vector3"/>.</returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
[MethodImpl(InliningOptions.ShortMethod)]
public Vector3 ToVector3() => new Vector3(this.L, this.M, this.S);
/// <inheritdoc/>
@ -99,16 +99,14 @@ namespace SixLabors.ImageSharp.ColorSpaces
/// <inheritdoc/>
public override string ToString()
{
return this.Equals(default)
? "Lms [ Empty ]"
: $"Lms [ L={this.L:#0.##}, M={this.M:#0.##}, S={this.S:#0.##} ]";
return $"Lms [ L={this.L:#0.##}, M={this.M:#0.##}, S={this.S:#0.##} ]";
}
/// <inheritdoc/>
public override bool Equals(object obj) => obj is Lms other && this.Equals(other);
/// <inheritdoc/>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
[MethodImpl(InliningOptions.ShortMethod)]
public bool Equals(Lms other)
{
return this.L.Equals(other.L)

24
src/ImageSharp/ColorSpaces/Rgb.cs

@ -48,7 +48,7 @@ namespace SixLabors.ImageSharp.ColorSpaces
/// <param name="r">The red component ranging between 0 and 1.</param>
/// <param name="g">The green component ranging between 0 and 1.</param>
/// <param name="b">The blue component ranging between 0 and 1.</param>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
[MethodImpl(InliningOptions.ShortMethod)]
public Rgb(float r, float g, float b)
: this(r, g, b, DefaultWorkingSpace)
{
@ -61,7 +61,7 @@ namespace SixLabors.ImageSharp.ColorSpaces
/// <param name="g">The green component ranging between 0 and 1.</param>
/// <param name="b">The blue component ranging between 0 and 1.</param>
/// <param name="workingSpace">The rgb working space.</param>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
[MethodImpl(InliningOptions.ShortMethod)]
public Rgb(float r, float g, float b, RgbWorkingSpace workingSpace)
{
// Clamp to 0-1 range.
@ -75,7 +75,7 @@ namespace SixLabors.ImageSharp.ColorSpaces
/// Initializes a new instance of the <see cref="Rgb"/> struct.
/// </summary>
/// <param name="vector">The vector representing the r, g, b components.</param>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
[MethodImpl(InliningOptions.ShortMethod)]
public Rgb(Vector3 vector)
: this(vector, DefaultWorkingSpace)
{
@ -86,7 +86,7 @@ namespace SixLabors.ImageSharp.ColorSpaces
/// </summary>
/// <param name="vector">The vector representing the r, g, b components.</param>
/// <param name="workingSpace">The rgb working space.</param>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
[MethodImpl(InliningOptions.ShortMethod)]
public Rgb(Vector3 vector, RgbWorkingSpace workingSpace)
{
// Clamp to 0-1 range.
@ -103,7 +103,7 @@ namespace SixLabors.ImageSharp.ColorSpaces
/// </summary>
/// <param name="color">The instance of <see cref="Rgba32"/> to convert.</param>
/// <returns>An instance of <see cref="Rgb"/>.</returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
[MethodImpl(InliningOptions.ShortMethod)]
public static implicit operator Rgb(Rgb24 color)
{
return new Rgb(color.R / 255F, color.G / 255F, color.B / 255F);
@ -115,7 +115,7 @@ namespace SixLabors.ImageSharp.ColorSpaces
/// </summary>
/// <param name="color">The instance of <see cref="Rgba32"/> to convert.</param>
/// <returns>An instance of <see cref="Rgb"/>.</returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
[MethodImpl(InliningOptions.ShortMethod)]
public static implicit operator Rgb(Rgba32 color)
{
return new Rgba32(color.R / 255F, color.G / 255F, color.B / 255F);
@ -133,7 +133,7 @@ namespace SixLabors.ImageSharp.ColorSpaces
/// <returns>
/// True if the current left is equal to the <paramref name="right"/> parameter; otherwise, false.
/// </returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
[MethodImpl(InliningOptions.ShortMethod)]
public static bool operator ==(Rgb left, Rgb right) => left.Equals(right);
/// <summary>
@ -144,14 +144,14 @@ namespace SixLabors.ImageSharp.ColorSpaces
/// <returns>
/// True if the current left is unequal to the <paramref name="right"/> parameter; otherwise, false.
/// </returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
[MethodImpl(InliningOptions.ShortMethod)]
public static bool operator !=(Rgb left, Rgb right) => !left.Equals(right);
/// <summary>
/// Returns a new <see cref="Vector3"/> representing this instance.
/// </summary>
/// <returns>The <see cref="Vector3"/>.</returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
[MethodImpl(InliningOptions.ShortMethod)]
public Vector3 ToVector3() => new Vector3(this.R, this.G, this.B);
/// <inheritdoc/>
@ -165,16 +165,14 @@ namespace SixLabors.ImageSharp.ColorSpaces
/// <inheritdoc/>
public override string ToString()
{
return this.Equals(default)
? "Rgb [ Empty ]"
: $"Rgb [ R={this.R:#0.##}, G={this.G:#0.##}, B={this.B:#0.##} ]";
return $"Rgb [ R={this.R:#0.##}, G={this.G:#0.##}, B={this.B:#0.##} ]";
}
/// <inheritdoc/>
public override bool Equals(object obj) => obj is Rgb other && this.Equals(other);
/// <inheritdoc/>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
[MethodImpl(InliningOptions.ShortMethod)]
public bool Equals(Rgb other)
{
return this.R.Equals(other.R)

14
src/ImageSharp/ColorSpaces/YCbCr.cs

@ -43,7 +43,7 @@ namespace SixLabors.ImageSharp.ColorSpaces
/// <param name="y">The y luminance component.</param>
/// <param name="cb">The cb chroma component.</param>
/// <param name="cr">The cr chroma component.</param>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
[MethodImpl(InliningOptions.ShortMethod)]
public YCbCr(float y, float cb, float cr)
: this(new Vector3(y, cb, cr))
{
@ -53,7 +53,7 @@ namespace SixLabors.ImageSharp.ColorSpaces
/// Initializes a new instance of the <see cref="YCbCr"/> struct.
/// </summary>
/// <param name="vector">The vector representing the y, cb, cr components.</param>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
[MethodImpl(InliningOptions.ShortMethod)]
public YCbCr(Vector3 vector)
{
vector = Vector3.Clamp(vector, Vector3.Zero, VectorMax);
@ -80,11 +80,11 @@ namespace SixLabors.ImageSharp.ColorSpaces
/// <returns>
/// True if the current left is unequal to the <paramref name="right"/> parameter; otherwise, false.
/// </returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
[MethodImpl(InliningOptions.ShortMethod)]
public static bool operator !=(YCbCr left, YCbCr right) => !left.Equals(right);
/// <inheritdoc/>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
[MethodImpl(InliningOptions.ShortMethod)]
public override int GetHashCode()
{
int hash = this.Y.GetHashCode();
@ -95,16 +95,14 @@ namespace SixLabors.ImageSharp.ColorSpaces
/// <inheritdoc/>
public override string ToString()
{
return this.Equals(default)
? "YCbCr [ Empty ]"
: $"YCbCr [ Y={this.Y}, Cb={this.Cb}, Cr={this.Cr} ]";
return $"YCbCr [ Y={this.Y}, Cb={this.Cb}, Cr={this.Cr} ]";
}
/// <inheritdoc/>
public override bool Equals(object obj) => obj is YCbCr other && this.Equals(other);
/// <inheritdoc/>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
[MethodImpl(InliningOptions.ShortMethod)]
public bool Equals(YCbCr other)
{
return this.Y.Equals(other.Y)

Loading…
Cancel
Save