Browse Source

Inline space properties and methods

af/merge-core
James Jackson-South 9 years ago
parent
commit
fe29013ffb
  1. 40
      src/ImageSharp/ColorSpaces/CieLab.cs
  2. 41
      src/ImageSharp/ColorSpaces/CieLch.cs
  3. 20
      src/ImageSharp/ColorSpaces/CieXyChromaticityCoordinates.cs
  4. 32
      src/ImageSharp/ColorSpaces/CieXyy.cs
  5. 32
      src/ImageSharp/ColorSpaces/CieXyz.cs
  6. 32
      src/ImageSharp/ColorSpaces/Cmyk.cs
  7. 3
      src/ImageSharp/ColorSpaces/Conversion/Implementation/CieLab/CieLabToCieXyzConverter.cs
  8. 11
      src/ImageSharp/ColorSpaces/Conversion/Implementation/CieLab/CieXyzToCieLabConverter.cs
  9. 3
      src/ImageSharp/ColorSpaces/Conversion/Implementation/CieLch/CIeLchToCieLabConverter.cs
  10. 3
      src/ImageSharp/ColorSpaces/Conversion/Implementation/CieLch/CieLabToCieLchConverter.cs
  11. 4
      src/ImageSharp/ColorSpaces/Conversion/Implementation/CieXyy/CieXyzAndCieXyyConverter.cs
  12. 5
      src/ImageSharp/ColorSpaces/Conversion/Implementation/Cmyk/CmykAndRgbConverter.cs
  13. 6
      src/ImageSharp/ColorSpaces/Conversion/Implementation/Hsl/HslAndRgbConverter.cs
  14. 8
      src/ImageSharp/ColorSpaces/Conversion/Implementation/HunterLab/CieXyzAndHunterLabConverterBase.cs
  15. 13
      src/ImageSharp/ColorSpaces/Conversion/Implementation/HunterLab/CieXyzToHunterLabConverter.cs
  16. 7
      src/ImageSharp/ColorSpaces/Conversion/Implementation/HunterLab/HunterLabToCieXyzConverter.cs
  17. 13
      src/ImageSharp/ColorSpaces/Conversion/Implementation/Lms/CieXyzAndLmsConverter.cs
  18. 32
      src/ImageSharp/ColorSpaces/Hsl.cs
  19. 39
      src/ImageSharp/ColorSpaces/Rgb.cs
  20. 1
      src/ImageSharp/PixelFormats/Rgba32.cs

40
src/ImageSharp/ColorSpaces/CieLab.cs

@ -8,6 +8,7 @@ namespace ImageSharp.ColorSpaces
using System;
using System.ComponentModel;
using System.Numerics;
using System.Runtime.CompilerServices;
/// <summary>
/// Represents a CIE L*a*b* 1976 color.
@ -38,6 +39,7 @@ namespace 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)]
public CieLab(float l, float a, float b)
: this(new Vector3(l, a, b), DefaultWhitePoint)
{
@ -50,6 +52,7 @@ namespace 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)]
public CieLab(float l, float a, float b, CieXyz whitePoint)
: this(new Vector3(l, a, b), whitePoint)
{
@ -60,6 +63,7 @@ namespace 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)]
public CieLab(Vector3 vector)
: this(vector, DefaultWhitePoint)
{
@ -70,6 +74,7 @@ namespace 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)]
public CieLab(Vector3 vector, CieXyz whitePoint)
: this()
{
@ -80,25 +85,41 @@ namespace ImageSharp.ColorSpaces
/// <summary>
/// Gets the reference white point of this color
/// </summary>
public CieXyz WhitePoint { get; }
public CieXyz WhitePoint
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
get;
}
/// <summary>
/// Gets the lightness dimension.
/// <remarks>A value ranging between 0 (black), 100 (diffuse white) or higher (specular white).</remarks>
/// </summary>
public float L => this.backingVector.X;
public float L
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
get => this.backingVector.X;
}
/// <summary>
/// Gets the a color component.
/// <remarks>A value ranging from -100 to 100. Negative is green, positive magenta.</remarks>
/// </summary>
public float A => this.backingVector.Y;
public float A
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
get => this.backingVector.Y;
}
/// <summary>
/// Gets the b color component.
/// <remarks>A value ranging from -100 to 100. Negative is blue, positive is yellow</remarks>
/// </summary>
public float B => this.backingVector.Z;
public float B
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
get => this.backingVector.Z;
}
/// <summary>
/// Gets a value indicating whether this <see cref="CieLab"/> is empty.
@ -107,7 +128,11 @@ namespace ImageSharp.ColorSpaces
public bool IsEmpty => this.Equals(Empty);
/// <inheritdoc />
public Vector3 Vector => this.backingVector;
public Vector3 Vector
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
get => this.backingVector;
}
/// <summary>
/// Compares two <see cref="CieLab"/> objects for equality.
@ -121,6 +146,7 @@ namespace ImageSharp.ColorSpaces
/// <returns>
/// True if the current left is equal to the <paramref name="right"/> parameter; otherwise, false.
/// </returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool operator ==(CieLab left, CieLab right)
{
return left.Equals(right);
@ -138,6 +164,7 @@ namespace ImageSharp.ColorSpaces
/// <returns>
/// True if the current left is unequal to the <paramref name="right"/> parameter; otherwise, false.
/// </returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool operator !=(CieLab left, CieLab right)
{
return !left.Equals(right);
@ -161,6 +188,7 @@ namespace ImageSharp.ColorSpaces
}
/// <inheritdoc/>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public override bool Equals(object obj)
{
if (obj is CieLab)
@ -172,12 +200,14 @@ namespace ImageSharp.ColorSpaces
}
/// <inheritdoc/>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public bool Equals(CieLab other)
{
return this.backingVector.Equals(other.backingVector);
}
/// <inheritdoc/>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public bool AlmostEquals(CieLab other, float precision)
{
Vector3 result = Vector3.Abs(this.backingVector - other.backingVector);

41
src/ImageSharp/ColorSpaces/CieLch.cs

@ -8,6 +8,7 @@ namespace ImageSharp.ColorSpaces
using System;
using System.ComponentModel;
using System.Numerics;
using System.Runtime.CompilerServices;
/// <summary>
/// Represents the CIE L*C*h°, cylindrical form of the CIE L*a*b* 1976 color.
@ -38,6 +39,7 @@ namespace 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)]
public CieLch(float l, float c, float h)
: this(new Vector3(l, c, h), DefaultWhitePoint)
{
@ -50,6 +52,7 @@ namespace 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)]
public CieLch(float l, float c, float h, CieXyz whitePoint)
: this(new Vector3(l, c, h), whitePoint)
{
@ -60,6 +63,7 @@ namespace 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)]
public CieLch(Vector3 vector)
: this(vector, DefaultWhitePoint)
{
@ -70,6 +74,7 @@ namespace 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)]
public CieLch(Vector3 vector, CieXyz whitePoint)
: this()
{
@ -80,25 +85,41 @@ namespace ImageSharp.ColorSpaces
/// <summary>
/// Gets the reference white point of this color
/// </summary>
public CieXyz WhitePoint { get; }
public CieXyz WhitePoint
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
get;
}
/// <summary>
/// Gets the lightness dimension.
/// <remarks>A value ranging between 0 (black), 100 (diffuse white) or higher (specular white).</remarks>
/// </summary>
public float L => this.backingVector.X;
public float L
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
get => this.backingVector.X;
}
/// <summary>
/// Gets the a chroma component.
/// <remarks>A value ranging from 0 to 100.</remarks>
/// </summary>
public float C => this.backingVector.Y;
public float C
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
get => this.backingVector.Y;
}
/// <summary>
/// Gets the h° hue component in degrees.
/// <remarks>A value ranging from 0 to 360.</remarks>
/// </summary>
public float H => this.backingVector.Z;
public float H
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
get => this.backingVector.Z;
}
/// <summary>
/// Gets a value indicating whether this <see cref="CieLch"/> is empty.
@ -107,7 +128,11 @@ namespace ImageSharp.ColorSpaces
public bool IsEmpty => this.Equals(Empty);
/// <inheritdoc />
public Vector3 Vector => this.backingVector;
public Vector3 Vector
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
get => this.backingVector;
}
/// <summary>
/// Compares two <see cref="CieLch"/> objects for equality.
@ -121,6 +146,7 @@ namespace ImageSharp.ColorSpaces
/// <returns>
/// True if the current left is equal to the <paramref name="right"/> parameter; otherwise, false.
/// </returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool operator ==(CieLch left, CieLch right)
{
return left.Equals(right);
@ -138,6 +164,7 @@ namespace ImageSharp.ColorSpaces
/// <returns>
/// True if the current left is unequal to the <paramref name="right"/> parameter; otherwise, false.
/// </returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool operator !=(CieLch left, CieLch right)
{
return !left.Equals(right);
@ -161,6 +188,7 @@ namespace ImageSharp.ColorSpaces
}
/// <inheritdoc/>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public override bool Equals(object obj)
{
if (obj is CieLch)
@ -172,12 +200,14 @@ namespace ImageSharp.ColorSpaces
}
/// <inheritdoc/>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public bool Equals(CieLch other)
{
return this.backingVector.Equals(other.backingVector);
}
/// <inheritdoc/>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public bool AlmostEquals(CieLch other, float precision)
{
Vector3 result = Vector3.Abs(this.backingVector - other.backingVector);
@ -194,6 +224,7 @@ namespace ImageSharp.ColorSpaces
/// A value ranging from 0 to 100.
/// </remarks>
/// <returns>The <see cref="float"/></returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public float Saturation()
{
float result = 100 * (this.C / this.L);

20
src/ImageSharp/ColorSpaces/CieXyChromaticityCoordinates.cs

@ -8,6 +8,7 @@ namespace ImageSharp.ColorSpaces
using System;
using System.ComponentModel;
using System.Numerics;
using System.Runtime.CompilerServices;
/// <summary>
/// Represents the coordinates of CIEXY chromaticity space
@ -29,6 +30,7 @@ namespace 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)]
public CieXyChromaticityCoordinates(float x, float y)
: this(new Vector2(x, y))
{
@ -38,6 +40,7 @@ namespace ImageSharp.ColorSpaces
/// Initializes a new instance of the <see cref="CieXyChromaticityCoordinates"/> struct.
/// </summary>
/// <param name="vector">The vector containing the XY Chromaticity coordinates</param>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public CieXyChromaticityCoordinates(Vector2 vector)
{
this.backingVector = vector;
@ -49,7 +52,11 @@ namespace ImageSharp.ColorSpaces
/// <remarks>
/// Ranges usually from 0 to 1.
/// </remarks>
public float X => this.backingVector.X;
public float X
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
get => this.backingVector.X;
}
/// <summary>
/// Gets the chromaticity Y-coordinate
@ -57,7 +64,11 @@ namespace ImageSharp.ColorSpaces
/// <remarks>
/// Ranges usually from 0 to 1.
/// </remarks>
public float Y => this.backingVector.Y;
public float Y
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
get => this.backingVector.Y;
}
/// <summary>
/// Gets a value indicating whether this <see cref="CieXyChromaticityCoordinates"/> is empty.
@ -77,6 +88,7 @@ namespace ImageSharp.ColorSpaces
/// <returns>
/// True if the current left is equal to the <paramref name="right"/> parameter; otherwise, false.
/// </returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool operator ==(CieXyChromaticityCoordinates left, CieXyChromaticityCoordinates right)
{
return left.Equals(right);
@ -94,6 +106,7 @@ namespace ImageSharp.ColorSpaces
/// <returns>
/// True if the current left is unequal to the <paramref name="right"/> parameter; otherwise, false.
/// </returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool operator !=(CieXyChromaticityCoordinates left, CieXyChromaticityCoordinates right)
{
return !left.Equals(right);
@ -117,6 +130,7 @@ namespace ImageSharp.ColorSpaces
}
/// <inheritdoc/>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public override bool Equals(object obj)
{
if (obj is CieXyChromaticityCoordinates)
@ -128,12 +142,14 @@ namespace ImageSharp.ColorSpaces
}
/// <inheritdoc/>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public bool Equals(CieXyChromaticityCoordinates other)
{
return this.backingVector.Equals(other.backingVector);
}
/// <inheritdoc/>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public bool AlmostEquals(CieXyChromaticityCoordinates other, float precision)
{
Vector2 result = Vector2.Abs(this.backingVector - other.backingVector);

32
src/ImageSharp/ColorSpaces/CieXyy.cs

@ -8,6 +8,7 @@ namespace ImageSharp.ColorSpaces
using System;
using System.ComponentModel;
using System.Numerics;
using System.Runtime.CompilerServices;
/// <summary>
/// Represents an CIE xyY 1931 color
@ -31,6 +32,7 @@ namespace 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)]
public CieXyy(float x, float y, float yl)
: this(new Vector3(x, y, yl))
{
@ -40,6 +42,7 @@ namespace 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)]
public CieXyy(Vector3 vector)
: this()
{
@ -51,19 +54,31 @@ namespace ImageSharp.ColorSpaces
/// Gets the X chrominance component.
/// <remarks>A value usually ranging between 0 and 1.</remarks>
/// </summary>
public float X => this.backingVector.X;
public float X
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
get => this.backingVector.X;
}
/// <summary>
/// Gets the Y chrominance component.
/// <remarks>A value usually ranging between 0 and 1.</remarks>
/// </summary>
public float Y => this.backingVector.Y;
public float Y
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
get => this.backingVector.Y;
}
/// <summary>
/// Gets the Y luminance component.
/// <remarks>A value usually ranging between 0 and 1.</remarks>
/// </summary>
public float Yl => this.backingVector.Z;
public float Yl
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
get => this.backingVector.Z;
}
/// <summary>
/// Gets a value indicating whether this <see cref="CieXyy"/> is empty.
@ -72,7 +87,11 @@ namespace ImageSharp.ColorSpaces
public bool IsEmpty => this.Equals(Empty);
/// <inheritdoc />
public Vector3 Vector => this.backingVector;
public Vector3 Vector
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
get => this.backingVector;
}
/// <summary>
/// Compares two <see cref="CieXyy"/> objects for equality.
@ -86,6 +105,7 @@ namespace ImageSharp.ColorSpaces
/// <returns>
/// True if the current left is equal to the <paramref name="right"/> parameter; otherwise, false.
/// </returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool operator ==(CieXyy left, CieXyy right)
{
return left.Equals(right);
@ -103,6 +123,7 @@ namespace ImageSharp.ColorSpaces
/// <returns>
/// True if the current left is unequal to the <paramref name="right"/> parameter; otherwise, false.
/// </returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool operator !=(CieXyy left, CieXyy right)
{
return !left.Equals(right);
@ -126,6 +147,7 @@ namespace ImageSharp.ColorSpaces
}
/// <inheritdoc/>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public override bool Equals(object obj)
{
if (obj is CieXyy)
@ -137,12 +159,14 @@ namespace ImageSharp.ColorSpaces
}
/// <inheritdoc/>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public bool Equals(CieXyy other)
{
return this.backingVector.Equals(other.backingVector);
}
/// <inheritdoc/>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public bool AlmostEquals(CieXyy other, float precision)
{
Vector3 result = Vector3.Abs(this.backingVector - other.backingVector);

32
src/ImageSharp/ColorSpaces/CieXyz.cs

@ -8,6 +8,7 @@ namespace ImageSharp.ColorSpaces
using System;
using System.ComponentModel;
using System.Numerics;
using System.Runtime.CompilerServices;
/// <summary>
/// Represents an CIE XYZ 1931 color
@ -31,6 +32,7 @@ namespace 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)]
public CieXyz(float x, float y, float z)
: this(new Vector3(x, y, z))
{
@ -40,6 +42,7 @@ namespace ImageSharp.ColorSpaces
/// Initializes a new instance of the <see cref="CieXyz"/> struct.
/// </summary>
/// <param name="vector">The vector representing the x, y, z components.</param>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public CieXyz(Vector3 vector)
: this()
{
@ -51,19 +54,31 @@ namespace ImageSharp.ColorSpaces
/// Gets the X component. A mix (a linear combination) of cone response curves chosen to be nonnegative.
/// <remarks>A value usually ranging between 0 and 1.</remarks>
/// </summary>
public float X => this.backingVector.X;
public float X
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
get => this.backingVector.X;
}
/// <summary>
/// Gets the Y luminance component.
/// <remarks>A value usually ranging between 0 and 1.</remarks>
/// </summary>
public float Y => this.backingVector.Y;
public float Y
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
get => this.backingVector.Y;
}
/// <summary>
/// Gets the Z component. Quasi-equal to blue stimulation, or the S cone response
/// <remarks>A value usually ranging between 0 and 1.</remarks>
/// </summary>
public float Z => this.backingVector.Z;
public float Z
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
get => this.backingVector.Z;
}
/// <summary>
/// Gets a value indicating whether this <see cref="CieXyz"/> is empty.
@ -72,7 +87,11 @@ namespace ImageSharp.ColorSpaces
public bool IsEmpty => this.Equals(Empty);
/// <inheritdoc />
public Vector3 Vector => this.backingVector;
public Vector3 Vector
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
get => this.backingVector;
}
/// <summary>
/// Compares two <see cref="CieXyz"/> objects for equality.
@ -86,6 +105,7 @@ namespace ImageSharp.ColorSpaces
/// <returns>
/// True if the current left is equal to the <paramref name="right"/> parameter; otherwise, false.
/// </returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool operator ==(CieXyz left, CieXyz right)
{
return left.Equals(right);
@ -103,6 +123,7 @@ namespace ImageSharp.ColorSpaces
/// <returns>
/// True if the current left is unequal to the <paramref name="right"/> parameter; otherwise, false.
/// </returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool operator !=(CieXyz left, CieXyz right)
{
return !left.Equals(right);
@ -126,6 +147,7 @@ namespace ImageSharp.ColorSpaces
}
/// <inheritdoc/>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public override bool Equals(object obj)
{
if (obj is CieXyz)
@ -137,12 +159,14 @@ namespace ImageSharp.ColorSpaces
}
/// <inheritdoc/>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public bool Equals(CieXyz other)
{
return this.backingVector.Equals(other.backingVector);
}
/// <inheritdoc/>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public bool AlmostEquals(CieXyz other, float precision)
{
Vector3 result = Vector3.Abs(this.backingVector - other.backingVector);

32
src/ImageSharp/ColorSpaces/Cmyk.cs

@ -8,6 +8,7 @@ namespace ImageSharp.ColorSpaces
using System;
using System.ComponentModel;
using System.Numerics;
using System.Runtime.CompilerServices;
/// <summary>
/// Represents an CMYK (cyan, magenta, yellow, keyline) color.
@ -31,6 +32,7 @@ namespace 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)]
public Cmyk(float c, float m, float y, float k)
: this(new Vector4(c, m, y, k))
{
@ -40,6 +42,7 @@ namespace 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)]
public Cmyk(Vector4 vector)
: this()
{
@ -50,25 +53,41 @@ namespace ImageSharp.ColorSpaces
/// Gets the cyan color component.
/// <remarks>A value ranging between 0 and 1.</remarks>
/// </summary>
public float C => this.backingVector.X;
public float C
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
get => this.backingVector.X;
}
/// <summary>
/// Gets the magenta color component.
/// <remarks>A value ranging between 0 and 1.</remarks>
/// </summary>
public float M => this.backingVector.Y;
public float M
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
get => this.backingVector.Y;
}
/// <summary>
/// Gets the yellow color component.
/// <remarks>A value ranging between 0 and 1.</remarks>
/// </summary>
public float Y => this.backingVector.Z;
public float Y
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
get => this.backingVector.Z;
}
/// <summary>
/// Gets the keyline black color component.
/// <remarks>A value ranging between 0 and 1.</remarks>
/// </summary>
public float K => this.backingVector.W;
public float K
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
get => this.backingVector.W;
}
/// <summary>
/// Gets a value indicating whether this <see cref="Cmyk"/> is empty.
@ -88,6 +107,7 @@ namespace ImageSharp.ColorSpaces
/// <returns>
/// True if the current left is equal to the <paramref name="right"/> parameter; otherwise, false.
/// </returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool operator ==(Cmyk left, Cmyk right)
{
return left.Equals(right);
@ -105,6 +125,7 @@ namespace ImageSharp.ColorSpaces
/// <returns>
/// True if the current left is unequal to the <paramref name="right"/> parameter; otherwise, false.
/// </returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool operator !=(Cmyk left, Cmyk right)
{
return !left.Equals(right);
@ -128,6 +149,7 @@ namespace ImageSharp.ColorSpaces
}
/// <inheritdoc/>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public override bool Equals(object obj)
{
if (obj is Cmyk)
@ -139,12 +161,14 @@ namespace ImageSharp.ColorSpaces
}
/// <inheritdoc/>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public bool Equals(Cmyk other)
{
return this.backingVector.Equals(other.backingVector);
}
/// <inheritdoc/>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public bool AlmostEquals(Cmyk other, float precision)
{
Vector4 result = Vector4.Abs(this.backingVector - other.backingVector);

3
src/ImageSharp/ColorSpaces/Conversion/Implementation/CieLab/CieLabToCieXyzConverter.cs

@ -5,6 +5,8 @@
namespace ImageSharp.ColorSpaces.Conversion.Implementation.CieLab
{
using System.Runtime.CompilerServices;
using ImageSharp.ColorSpaces;
/// <summary>
@ -13,6 +15,7 @@ namespace ImageSharp.ColorSpaces.Conversion.Implementation.CieLab
internal class CieLabToCieXyzConverter : IColorConversion<CieLab, CieXyz>
{
/// <inheritdoc/>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public CieXyz Convert(CieLab input)
{
DebugGuard.NotNull(input, nameof(input));

11
src/ImageSharp/ColorSpaces/Conversion/Implementation/CieLab/CieXyzToCieLabConverter.cs

@ -5,6 +5,8 @@
namespace ImageSharp.ColorSpaces.Conversion.Implementation.CieLab
{
using System.Runtime.CompilerServices;
using ImageSharp.ColorSpaces;
/// <summary>
@ -15,6 +17,7 @@ namespace ImageSharp.ColorSpaces.Conversion.Implementation.CieLab
/// <summary>
/// Initializes a new instance of the <see cref="CieXyzToCieLabConverter"/> class.
/// </summary>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public CieXyzToCieLabConverter()
: this(CieLab.DefaultWhitePoint)
{
@ -24,6 +27,7 @@ namespace ImageSharp.ColorSpaces.Conversion.Implementation.CieLab
/// Initializes a new instance of the <see cref="CieXyzToCieLabConverter"/> class.
/// </summary>
/// <param name="labWhitePoint">The target reference lab white point</param>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public CieXyzToCieLabConverter(CieXyz labWhitePoint)
{
this.LabWhitePoint = labWhitePoint;
@ -32,9 +36,14 @@ namespace ImageSharp.ColorSpaces.Conversion.Implementation.CieLab
/// <summary>
/// Gets the target reference whitepoint. When not set, <see cref="CieLab.DefaultWhitePoint"/> is used.
/// </summary>
public CieXyz LabWhitePoint { get; }
public CieXyz LabWhitePoint
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
get;
}
/// <inheritdoc />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public CieLab Convert(CieXyz input)
{
DebugGuard.NotNull(input, nameof(input));

3
src/ImageSharp/ColorSpaces/Conversion/Implementation/CieLch/CIeLchToCieLabConverter.cs

@ -5,6 +5,8 @@
namespace ImageSharp.ColorSpaces.Conversion.Implementation.CieLch
{
using System.Runtime.CompilerServices;
using ImageSharp.ColorSpaces;
/// <summary>
@ -13,6 +15,7 @@ namespace ImageSharp.ColorSpaces.Conversion.Implementation.CieLch
public class CieLchToCieLabConverter : IColorConversion<CieLch, CieLab>
{
/// <inheritdoc/>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public CieLab Convert(CieLch input)
{
DebugGuard.NotNull(input, nameof(input));

3
src/ImageSharp/ColorSpaces/Conversion/Implementation/CieLch/CieLabToCieLchConverter.cs

@ -5,6 +5,8 @@
namespace ImageSharp.ColorSpaces.Conversion.Implementation.CieLch
{
using System.Runtime.CompilerServices;
using ImageSharp.ColorSpaces;
/// <summary>
@ -13,6 +15,7 @@ namespace ImageSharp.ColorSpaces.Conversion.Implementation.CieLch
internal class CieLabToCieLchConverter : IColorConversion<CieLab, CieLch>
{
/// <inheritdoc/>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public CieLch Convert(CieLab input)
{
DebugGuard.NotNull(input, nameof(input));

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

@ -5,6 +5,8 @@
namespace ImageSharp.ColorSpaces.Conversion.Implementation.CieXyy
{
using System.Runtime.CompilerServices;
using ImageSharp.ColorSpaces;
/// <summary>
@ -14,6 +16,7 @@ namespace ImageSharp.ColorSpaces.Conversion.Implementation.CieXyy
internal class CieXyzAndCieXyyConverter : IColorConversion<CieXyz, CieXyy>, IColorConversion<CieXyy, CieXyz>
{
/// <inheritdoc/>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public CieXyy Convert(CieXyz input)
{
DebugGuard.NotNull(input, nameof(input));
@ -30,6 +33,7 @@ namespace ImageSharp.ColorSpaces.Conversion.Implementation.CieXyy
}
/// <inheritdoc/>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public CieXyz Convert(CieXyy input)
{
DebugGuard.NotNull(input, nameof(input));

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

@ -6,6 +6,7 @@
namespace ImageSharp.ColorSpaces.Conversion.Implementation.Cmyk
{
using System;
using System.Runtime.CompilerServices;
using ImageSharp.ColorSpaces;
@ -15,6 +16,7 @@ namespace ImageSharp.ColorSpaces.Conversion.Implementation.Cmyk
internal class CmykAndRgbConverter : IColorConversion<Cmyk, Rgb>, IColorConversion<Rgb, Cmyk>
{
/// <inheritdoc/>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public Rgb Convert(Cmyk input)
{
float r = (1F - input.C) * (1F - input.K);
@ -25,6 +27,7 @@ namespace ImageSharp.ColorSpaces.Conversion.Implementation.Cmyk
}
/// <inheritdoc/>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public Cmyk Convert(Rgb input)
{
// To CMYK
@ -35,7 +38,7 @@ namespace ImageSharp.ColorSpaces.Conversion.Implementation.Cmyk
// To CMYK
float k = MathF.Min(c, MathF.Min(m, y));
if (Math.Abs(k - 1F) < Constants.Epsilon)
if (MathF.Abs(k - 1F) < Constants.Epsilon)
{
return new Cmyk(0, 0, 0, 1F);
}

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

@ -16,8 +16,11 @@ namespace ImageSharp.ColorSpaces.Conversion.Implementation.Hsl
internal class HslAndRgbConverter : IColorConversion<Hsl, Rgb>, IColorConversion<Rgb, Hsl>
{
/// <inheritdoc/>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public Rgb Convert(Hsl input)
{
DebugGuard.NotNull(input, nameof(input));
float rangedH = input.H / 360F;
float r = 0;
float g = 0;
@ -46,8 +49,11 @@ namespace ImageSharp.ColorSpaces.Conversion.Implementation.Hsl
}
/// <inheritdoc/>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public Hsl Convert(Rgb input)
{
DebugGuard.NotNull(input, nameof(input));
float r = input.R;
float g = input.G;
float b = input.B;

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

@ -24,10 +24,10 @@ namespace ImageSharp.ColorSpaces.Conversion.Implementation.HunterLab
if (whitePoint.Equals(Illuminants.C))
{
return 175;
return 175F;
}
return 100 * (175 / 198.04F) * (whitePoint.X + whitePoint.Y);
return 100F * (175F / 198.04F) * (whitePoint.X + whitePoint.Y);
}
/// <summary>
@ -42,10 +42,10 @@ namespace ImageSharp.ColorSpaces.Conversion.Implementation.HunterLab
if (whitePoint == Illuminants.C)
{
return 70;
return 70F;
}
return 100 * (70 / 218.11F) * (whitePoint.Y + whitePoint.Z);
return 100F * (70F / 218.11F) * (whitePoint.Y + whitePoint.Z);
}
}
}

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

@ -5,7 +5,9 @@
namespace ImageSharp.ColorSpaces.Conversion.Implementation.HunterLab
{
using HunterLab = ImageSharp.ColorSpaces.HunterLab;
using System.Runtime.CompilerServices;
using ImageSharp.ColorSpaces;
/// <summary>
/// Color converter between CieXyz and HunterLab
@ -15,6 +17,7 @@ namespace ImageSharp.ColorSpaces.Conversion.Implementation.HunterLab
/// <summary>
/// Initializes a new instance of the <see cref="CieXyzToHunterLabConverter"/> class.
/// </summary>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public CieXyzToHunterLabConverter()
: this(HunterLab.DefaultWhitePoint)
{
@ -24,6 +27,7 @@ namespace ImageSharp.ColorSpaces.Conversion.Implementation.HunterLab
/// Initializes a new instance of the <see cref="CieXyzToHunterLabConverter"/> class.
/// </summary>
/// <param name="labWhitePoint">The hunter Lab white point.</param>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public CieXyzToHunterLabConverter(CieXyz labWhitePoint)
{
this.HunterLabWhitePoint = labWhitePoint;
@ -32,9 +36,14 @@ namespace ImageSharp.ColorSpaces.Conversion.Implementation.HunterLab
/// <summary>
/// Gets the target reference white. When not set, <see cref="HunterLab.DefaultWhitePoint"/> is used.
/// </summary>
public CieXyz HunterLabWhitePoint { get; }
public CieXyz HunterLabWhitePoint
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
get;
}
/// <inheritdoc/>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public HunterLab Convert(CieXyz input)
{
DebugGuard.NotNull(input, nameof(input));

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

@ -5,7 +5,9 @@
namespace ImageSharp.ColorSpaces.Conversion.Implementation.HunterLab
{
using HunterLab = ImageSharp.ColorSpaces.HunterLab;
using System.Runtime.CompilerServices;
using ImageSharp.ColorSpaces;
/// <summary>
/// Color converter between HunterLab and CieXyz
@ -13,6 +15,7 @@ namespace ImageSharp.ColorSpaces.Conversion.Implementation.HunterLab
internal class HunterLabToCieXyzConverter : CieXyzAndHunterLabConverterBase, IColorConversion<HunterLab, CieXyz>
{
/// <inheritdoc/>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public CieXyz Convert(HunterLab input)
{
DebugGuard.NotNull(input, nameof(input));
@ -31,4 +34,4 @@ namespace ImageSharp.ColorSpaces.Conversion.Implementation.HunterLab
return new CieXyz(x, y, z);
}
}
}
}

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

@ -6,6 +6,7 @@
namespace ImageSharp.ColorSpaces.Conversion.Implementation.Lms
{
using System.Numerics;
using System.Runtime.CompilerServices;
using ImageSharp.ColorSpaces;
@ -26,6 +27,7 @@ namespace ImageSharp.ColorSpaces.Conversion.Implementation.Lms
/// <summary>
/// Initializes a new instance of the <see cref="CieXyzAndLmsConverter"/> class.
/// </summary>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public CieXyzAndLmsConverter()
: this(DefaultTransformationMatrix)
{
@ -38,6 +40,7 @@ namespace ImageSharp.ColorSpaces.Conversion.Implementation.Lms
/// Definition of the cone response domain (see <see cref="LmsAdaptationMatrix"/>),
/// if not set <see cref="DefaultTransformationMatrix"/> will be used.
/// </param>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public CieXyzAndLmsConverter(Matrix4x4 transformationMatrix)
{
this.TransformationMatrix = transformationMatrix;
@ -49,10 +52,8 @@ namespace ImageSharp.ColorSpaces.Conversion.Implementation.Lms
/// </summary>
public Matrix4x4 TransformationMatrix
{
get
{
return this.transformationMatrix;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
get => this.transformationMatrix;
set
{
@ -62,6 +63,7 @@ namespace ImageSharp.ColorSpaces.Conversion.Implementation.Lms
}
/// <inheritdoc/>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public Lms Convert(CieXyz input)
{
DebugGuard.NotNull(input, nameof(input));
@ -71,6 +73,7 @@ namespace ImageSharp.ColorSpaces.Conversion.Implementation.Lms
}
/// <inheritdoc/>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public CieXyz Convert(Lms input)
{
DebugGuard.NotNull(input, nameof(input));
@ -79,4 +82,4 @@ namespace ImageSharp.ColorSpaces.Conversion.Implementation.Lms
return new CieXyz(vector);
}
}
}
}

32
src/ImageSharp/ColorSpaces/Hsl.cs

@ -8,6 +8,7 @@ namespace ImageSharp.ColorSpaces
using System;
using System.ComponentModel;
using System.Numerics;
using System.Runtime.CompilerServices;
/// <summary>
/// Represents a Hsl (hue, saturation, lightness) color.
@ -35,6 +36,7 @@ namespace 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)]
public Hsl(float h, float s, float l)
: this(new Vector3(h, s, l))
{
@ -44,6 +46,7 @@ namespace 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)]
public Hsl(Vector3 vector)
{
this.backingVector = Vector3.Clamp(vector, Vector3.Zero, VectorMax);
@ -53,19 +56,31 @@ namespace ImageSharp.ColorSpaces
/// Gets the hue component.
/// <remarks>A value ranging between 0 and 360.</remarks>
/// </summary>
public float H => this.backingVector.X;
public float H
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
get => this.backingVector.X;
}
/// <summary>
/// Gets the saturation component.
/// <remarks>A value ranging between 0 and 1.</remarks>
/// </summary>
public float S => this.backingVector.Y;
public float S
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
get => this.backingVector.Y;
}
/// <summary>
/// Gets the lightness component.
/// <remarks>A value ranging between 0 and 1.</remarks>
/// </summary>
public float L => this.backingVector.Z;
public float L
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
get => this.backingVector.Z;
}
/// <summary>
/// Gets a value indicating whether this <see cref="Hsl"/> is empty.
@ -74,7 +89,11 @@ namespace ImageSharp.ColorSpaces
public bool IsEmpty => this.Equals(Empty);
/// <inheritdoc/>
public Vector3 Vector => this.backingVector;
public Vector3 Vector
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
get => this.backingVector;
}
/// <summary>
/// Compares two <see cref="Hsl"/> objects for equality.
@ -88,6 +107,7 @@ namespace ImageSharp.ColorSpaces
/// <returns>
/// True if the current left is equal to the <paramref name="right"/> parameter; otherwise, false.
/// </returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool operator ==(Hsl left, Hsl right)
{
return left.Equals(right);
@ -105,6 +125,7 @@ namespace ImageSharp.ColorSpaces
/// <returns>
/// True if the current left is unequal to the <paramref name="right"/> parameter; otherwise, false.
/// </returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool operator !=(Hsl left, Hsl right)
{
return !left.Equals(right);
@ -128,6 +149,7 @@ namespace ImageSharp.ColorSpaces
}
/// <inheritdoc/>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public override bool Equals(object obj)
{
if (obj is Hsl)
@ -139,12 +161,14 @@ namespace ImageSharp.ColorSpaces
}
/// <inheritdoc/>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public bool Equals(Hsl other)
{
return this.backingVector.Equals(other.backingVector);
}
/// <inheritdoc/>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public bool AlmostEquals(Hsl other, float precision)
{
Vector3 result = Vector3.Abs(this.backingVector - other.backingVector);

39
src/ImageSharp/ColorSpaces/Rgb.cs

@ -38,6 +38,7 @@ namespace 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)]
public Rgb(float r, float g, float b)
: this(new Vector3(r, g, b))
{
@ -50,6 +51,7 @@ namespace 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)]
public Rgb(float r, float g, float b, IRgbWorkingSpace workingSpace)
: this(new Vector3(r, g, b), workingSpace)
{
@ -59,6 +61,7 @@ namespace 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)]
public Rgb(Vector3 vector)
: this(vector, DefaultWorkingSpace)
{
@ -69,6 +72,7 @@ namespace 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)]
public Rgb(Vector3 vector, IRgbWorkingSpace workingSpace)
: this()
{
@ -81,24 +85,40 @@ namespace ImageSharp.ColorSpaces
/// Gets the red component.
/// <remarks>A value usually ranging between 0 and 1.</remarks>
/// </summary>
public float R => this.backingVector.X;
public float R
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
get => this.backingVector.X;
}
/// <summary>
/// Gets the green component.
/// <remarks>A value usually ranging between 0 and 1.</remarks>
/// </summary>
public float G => this.backingVector.Y;
public float G
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
get => this.backingVector.Y;
}
/// <summary>
/// Gets the blue component.
/// <remarks>A value usually ranging between 0 and 1.</remarks>
/// </summary>
public float B => this.backingVector.Z;
public float B
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
get => this.backingVector.Z;
}
/// <summary>
/// Gets the Rgb color space <seealso cref="RgbWorkingSpaces"/>
/// </summary>
public IRgbWorkingSpace WorkingSpace { get; }
public IRgbWorkingSpace WorkingSpace
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
get;
}
/// <summary>
/// Gets a value indicating whether this <see cref="Rgb"/> is empty.
@ -107,7 +127,11 @@ namespace ImageSharp.ColorSpaces
public bool IsEmpty => this.Equals(Empty);
/// <inheritdoc />
public Vector3 Vector => this.backingVector;
public Vector3 Vector
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
get => this.backingVector;
}
/// <summary>
/// Allows the implicit conversion of an instance of <see cref="Rgba32"/> to a
@ -137,6 +161,7 @@ namespace ImageSharp.ColorSpaces
/// <returns>
/// True if the current left is equal to the <paramref name="right"/> parameter; otherwise, false.
/// </returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool operator ==(Rgb left, Rgb right)
{
return left.Equals(right);
@ -154,6 +179,7 @@ namespace ImageSharp.ColorSpaces
/// <returns>
/// True if the current left is unequal to the <paramref name="right"/> parameter; otherwise, false.
/// </returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool operator !=(Rgb left, Rgb right)
{
return !left.Equals(right);
@ -177,6 +203,7 @@ namespace ImageSharp.ColorSpaces
}
/// <inheritdoc/>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public override bool Equals(object obj)
{
if (obj is Rgb)
@ -188,12 +215,14 @@ namespace ImageSharp.ColorSpaces
}
/// <inheritdoc/>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public bool Equals(Rgb other)
{
return this.backingVector.Equals(other.backingVector);
}
/// <inheritdoc/>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public bool AlmostEquals(Rgb other, float precision)
{
Vector3 result = Vector3.Abs(this.backingVector - other.backingVector);

1
src/ImageSharp/PixelFormats/Rgba32.cs

@ -227,6 +227,7 @@ namespace ImageSharp.PixelFormats
}
/// <inheritdoc />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public BulkPixelOperations<Rgba32> CreateBulkOperations() => new BulkOperations();
/// <inheritdoc/>

Loading…
Cancel
Save