diff --git a/src/ImageSharp/ColorSpaces/CieLab.cs b/src/ImageSharp/ColorSpaces/CieLab.cs
deleted file mode 100644
index 2346b395c..000000000
--- a/src/ImageSharp/ColorSpaces/CieLab.cs
+++ /dev/null
@@ -1,135 +0,0 @@
-// Copyright (c) Six Labors.
-// Licensed under the Six Labors Split License.
-
-using System.Numerics;
-using System.Runtime.CompilerServices;
-
-namespace SixLabors.ImageSharp.ColorSpaces;
-
-///
-/// Represents a CIE L*a*b* 1976 color.
-///
-///
-public readonly struct CieLab : IEquatable
-{
- ///
- /// D50 standard illuminant.
- /// Used when reference white is not specified explicitly.
- ///
- public static readonly CieXyz DefaultWhitePoint = Illuminants.D50;
-
- ///
- /// Initializes a new instance of the struct.
- ///
- /// The lightness dimension.
- /// The a (green - magenta) component.
- /// The b (blue - yellow) component.
- /// Uses as white point.
- [MethodImpl(InliningOptions.ShortMethod)]
- public CieLab(float l, float a, float b)
- : this(l, a, b, DefaultWhitePoint)
- {
- }
-
- ///
- /// Initializes a new instance of the struct.
- ///
- /// The lightness dimension.
- /// The a (green - magenta) component.
- /// The b (blue - yellow) component.
- /// The reference white point.
- [MethodImpl(InliningOptions.ShortMethod)]
- public CieLab(float l, float a, float b, CieXyz whitePoint)
- : this(new Vector3(l, a, b), whitePoint)
- {
- }
-
- ///
- /// Initializes a new instance of the struct.
- ///
- /// The vector representing the l, a, b components.
- /// Uses as white point.
- [MethodImpl(InliningOptions.ShortMethod)]
- public CieLab(Vector3 vector)
- : this(vector, DefaultWhitePoint)
- {
- }
-
- ///
- /// Initializes a new instance of the struct.
- ///
- /// The vector representing the l, a, b components.
- /// The reference white point.
- [MethodImpl(InliningOptions.ShortMethod)]
- public CieLab(Vector3 vector, CieXyz whitePoint)
- : this()
- {
- // Not clamping as documentation about this space only indicates "usual" ranges
- this.L = vector.X;
- this.A = vector.Y;
- this.B = vector.Z;
- this.WhitePoint = whitePoint;
- }
-
- ///
- /// Gets the lightness dimension.
- /// A value usually ranging between 0 (black), 100 (diffuse white) or higher (specular white).
- ///
- public readonly float L { get; }
-
- ///
- /// Gets the a color component.
- /// A value usually ranging from -100 to 100. Negative is green, positive magenta.
- ///
- public readonly float A { get; }
-
- ///
- /// Gets the b color component.
- /// A value usually ranging from -100 to 100. Negative is blue, positive is yellow
- ///
- public readonly float B { get; }
-
- ///
- /// Gets the reference white point of this color
- ///
- public readonly CieXyz WhitePoint { get; }
-
- ///
- /// Compares two objects for equality.
- ///
- /// The on the left side of the operand.
- /// The on the right side of the operand.
- ///
- /// True if the current left is equal to the parameter; otherwise, false.
- ///
- [MethodImpl(InliningOptions.ShortMethod)]
- public static bool operator ==(CieLab left, CieLab right) => left.Equals(right);
-
- ///
- /// Compares two objects for inequality
- ///
- /// The on the left side of the operand.
- /// The on the right side of the operand.
- ///
- /// True if the current left is unequal to the parameter; otherwise, false.
- ///
- [MethodImpl(InliningOptions.ShortMethod)]
- public static bool operator !=(CieLab left, CieLab right) => !left.Equals(right);
-
- ///
- public override int GetHashCode() => HashCode.Combine(this.L, this.A, this.B, this.WhitePoint);
-
- ///
- public override string ToString() => FormattableString.Invariant($"CieLab({this.L:#0.##}, {this.A:#0.##}, {this.B:#0.##})");
-
- ///
- public override bool Equals(object? obj) => obj is CieLab other && this.Equals(other);
-
- ///
- [MethodImpl(InliningOptions.ShortMethod)]
- public bool Equals(CieLab other) =>
- this.L.Equals(other.L)
- && this.A.Equals(other.A)
- && this.B.Equals(other.B)
- && this.WhitePoint.Equals(other.WhitePoint);
-}
diff --git a/src/ImageSharp/ColorSpaces/CieLch.cs b/src/ImageSharp/ColorSpaces/CieLch.cs
deleted file mode 100644
index 48e8e2c6d..000000000
--- a/src/ImageSharp/ColorSpaces/CieLch.cs
+++ /dev/null
@@ -1,159 +0,0 @@
-// Copyright (c) Six Labors.
-// Licensed under the Six Labors Split License.
-
-using System.Numerics;
-using System.Runtime.CompilerServices;
-
-namespace SixLabors.ImageSharp.ColorSpaces;
-
-///
-/// Represents the CIE L*C*h°, cylindrical form of the CIE L*a*b* 1976 color.
-///
-///
-public readonly struct CieLch : IEquatable
-{
- ///
- /// D50 standard illuminant.
- /// Used when reference white is not specified explicitly.
- ///
- public static readonly CieXyz DefaultWhitePoint = Illuminants.D50;
-
- private static readonly Vector3 Min = new(0, -200, 0);
- private static readonly Vector3 Max = new(100, 200, 360);
-
- ///
- /// Initializes a new instance of the struct.
- ///
- /// The lightness dimension.
- /// The chroma, relative saturation.
- /// The hue in degrees.
- /// Uses as white point.
- [MethodImpl(InliningOptions.ShortMethod)]
- public CieLch(float l, float c, float h)
- : this(l, c, h, DefaultWhitePoint)
- {
- }
-
- ///
- /// Initializes a new instance of the struct.
- ///
- /// The lightness dimension.
- /// The chroma, relative saturation.
- /// The hue in degrees.
- /// The reference white point.
- [MethodImpl(InliningOptions.ShortMethod)]
- public CieLch(float l, float c, float h, CieXyz whitePoint)
- : this(new Vector3(l, c, h), whitePoint)
- {
- }
-
- ///
- /// Initializes a new instance of the struct.
- ///
- /// The vector representing the l, c, h components.
- /// Uses as white point.
- [MethodImpl(InliningOptions.ShortMethod)]
- public CieLch(Vector3 vector)
- : this(vector, DefaultWhitePoint)
- {
- }
-
- ///
- /// Initializes a new instance of the struct.
- ///
- /// The vector representing the l, c, h components.
- /// The reference white point.
- [MethodImpl(InliningOptions.ShortMethod)]
- public CieLch(Vector3 vector, CieXyz whitePoint)
- {
- vector = Vector3.Clamp(vector, Min, Max);
- this.L = vector.X;
- this.C = vector.Y;
- this.H = vector.Z;
- this.WhitePoint = whitePoint;
- }
-
- ///
- /// Gets the lightness dimension.
- /// A value ranging between 0 (black), 100 (diffuse white) or higher (specular white).
- ///
- public readonly float L { get; }
-
- ///
- /// Gets the a chroma component.
- /// A value ranging from 0 to 200.
- ///
- public readonly float C { get; }
-
- ///
- /// Gets the h° hue component in degrees.
- /// A value ranging from 0 to 360.
- ///
- public readonly float H { get; }
-
- ///
- /// Gets the reference white point of this color
- ///
- public readonly CieXyz WhitePoint { get; }
-
- ///
- /// Compares two objects for equality.
- ///
- /// The on the left side of the operand.
- /// The on the right side of the operand.
- ///
- /// True if the current left is equal to the parameter; otherwise, false.
- ///
- [MethodImpl(InliningOptions.ShortMethod)]
- public static bool operator ==(CieLch left, CieLch right) => left.Equals(right);
-
- ///
- /// Compares two objects for inequality
- ///
- /// The on the left side of the operand.
- /// The on the right side of the operand.
- ///
- /// True if the current left is unequal to the parameter; otherwise, false.
- ///
- [MethodImpl(InliningOptions.ShortMethod)]
- public static bool operator !=(CieLch left, CieLch right) => !left.Equals(right);
-
- ///
- public override int GetHashCode()
- => HashCode.Combine(this.L, this.C, this.H, this.WhitePoint);
-
- ///
- public override string ToString() => FormattableString.Invariant($"CieLch({this.L:#0.##}, {this.C:#0.##}, {this.H:#0.##})");
-
- ///
- [MethodImpl(InliningOptions.ShortMethod)]
- public override bool Equals(object? obj) => obj is CieLch other && this.Equals(other);
-
- ///
- [MethodImpl(InliningOptions.ShortMethod)]
- public bool Equals(CieLch other)
- => this.L.Equals(other.L)
- && this.C.Equals(other.C)
- && this.H.Equals(other.H)
- && this.WhitePoint.Equals(other.WhitePoint);
-
- ///
- /// Computes the saturation of the color (chroma normalized by lightness)
- ///
- ///
- /// A value ranging from 0 to 100.
- ///
- /// The
- [MethodImpl(InliningOptions.ShortMethod)]
- public float Saturation()
- {
- float result = 100 * (this.C / this.L);
-
- if (float.IsNaN(result))
- {
- return 0;
- }
-
- return result;
- }
-}
diff --git a/src/ImageSharp/ColorSpaces/CieLchuv.cs b/src/ImageSharp/ColorSpaces/CieLchuv.cs
deleted file mode 100644
index 4d47be5aa..000000000
--- a/src/ImageSharp/ColorSpaces/CieLchuv.cs
+++ /dev/null
@@ -1,156 +0,0 @@
-// Copyright (c) Six Labors.
-// Licensed under the Six Labors Split License.
-
-using System.Numerics;
-using System.Runtime.CompilerServices;
-
-namespace SixLabors.ImageSharp.ColorSpaces;
-
-///
-/// Represents the CIE L*C*h°, cylindrical form of the CIE L*u*v* 1976 color.
-///
-///
-public readonly struct CieLchuv : IEquatable
-{
- private static readonly Vector3 Min = new(0, -200, 0);
- private static readonly Vector3 Max = new(100, 200, 360);
-
- ///
- /// D50 standard illuminant.
- /// Used when reference white is not specified explicitly.
- ///
- public static readonly CieXyz DefaultWhitePoint = Illuminants.D65;
-
- ///
- /// Initializes a new instance of the struct.
- ///
- /// The lightness dimension.
- /// The chroma, relative saturation.
- /// The hue in degrees.
- /// Uses as white point.
- [MethodImpl(InliningOptions.ShortMethod)]
- public CieLchuv(float l, float c, float h)
- : this(l, c, h, DefaultWhitePoint)
- {
- }
-
- ///
- /// Initializes a new instance of the struct.
- ///
- /// The lightness dimension.
- /// The chroma, relative saturation.
- /// The hue in degrees.
- /// The reference white point.
- [MethodImpl(InliningOptions.ShortMethod)]
- public CieLchuv(float l, float c, float h, CieXyz whitePoint)
- : this(new Vector3(l, c, h), whitePoint)
- {
- }
-
- ///
- /// Initializes a new instance of the struct.
- ///
- /// The vector representing the l, c, h components.
- /// Uses as white point.
- [MethodImpl(InliningOptions.ShortMethod)]
- public CieLchuv(Vector3 vector)
- : this(vector, DefaultWhitePoint)
- {
- }
-
- ///
- /// Initializes a new instance of the struct.
- ///
- /// The vector representing the l, c, h components.
- /// The reference white point.
- [MethodImpl(InliningOptions.ShortMethod)]
- public CieLchuv(Vector3 vector, CieXyz whitePoint)
- : this()
- {
- vector = Vector3.Clamp(vector, Min, Max);
- this.L = vector.X;
- this.C = vector.Y;
- this.H = vector.Z;
- this.WhitePoint = whitePoint;
- }
-
- ///
- /// Gets the lightness dimension.
- /// A value ranging between 0 (black), 100 (diffuse white) or higher (specular white).
- ///
- public readonly float L { get; }
-
- ///
- /// Gets the a chroma component.
- /// A value ranging from 0 to 200.
- ///
- public readonly float C { get; }
-
- ///
- /// Gets the h° hue component in degrees.
- /// A value ranging from 0 to 360.
- ///
- public readonly float H { get; }
-
- ///
- /// Gets the reference white point of this color
- ///
- public readonly CieXyz WhitePoint { get; }
-
- ///
- /// Compares two objects for equality.
- ///
- /// The on the left side of the operand.
- /// The on the right side of the operand.
- ///
- /// True if the current left is equal to the parameter; otherwise, false.
- ///
- public static bool operator ==(CieLchuv left, CieLchuv right) => left.Equals(right);
-
- ///
- /// Compares two objects for inequality
- ///
- /// The on the left side of the operand.
- /// The on the right side of the operand.
- ///
- /// True if the current left is unequal to the parameter; otherwise, false.
- ///
- public static bool operator !=(CieLchuv left, CieLchuv right) => !left.Equals(right);
-
- ///
- public override int GetHashCode() => HashCode.Combine(this.L, this.C, this.H, this.WhitePoint);
-
- ///
- public override string ToString() => FormattableString.Invariant($"CieLchuv({this.L:#0.##}, {this.C:#0.##}, {this.H:#0.##})");
-
- ///
- public override bool Equals(object? obj) => obj is CieLchuv other && this.Equals(other);
-
- ///
- [MethodImpl(InliningOptions.ShortMethod)]
- public bool Equals(CieLchuv other)
- => this.L.Equals(other.L)
- && this.C.Equals(other.C)
- && this.H.Equals(other.H)
- && this.WhitePoint.Equals(other.WhitePoint);
-
- ///
- /// Computes the saturation of the color (chroma normalized by lightness)
- ///
- ///
- /// A value ranging from 0 to 100.
- ///
- /// The
- [MethodImpl(InliningOptions.ShortMethod)]
- public float Saturation()
- {
- float result = 100 * (this.C / this.L);
-
- if (float.IsNaN(result))
- {
- return 0;
- }
-
- return result;
- }
-}
diff --git a/src/ImageSharp/ColorSpaces/CieLuv.cs b/src/ImageSharp/ColorSpaces/CieLuv.cs
deleted file mode 100644
index 04bc96cfa..000000000
--- a/src/ImageSharp/ColorSpaces/CieLuv.cs
+++ /dev/null
@@ -1,136 +0,0 @@
-// Copyright (c) Six Labors.
-// Licensed under the Six Labors Split License.
-
-using System.Numerics;
-using System.Runtime.CompilerServices;
-
-namespace SixLabors.ImageSharp.ColorSpaces;
-
-///
-/// The CIE 1976 (L*, u*, v*) color space, commonly known by its abbreviation CIELUV, is a color space adopted by the International
-/// Commission on Illumination (CIE) in 1976, as a simple-to-compute transformation of the 1931 CIE XYZ color space, but which
-/// attempted perceptual uniformity
-///
-///
-public readonly struct CieLuv : IEquatable
-{
- ///
- /// D65 standard illuminant.
- /// Used when reference white is not specified explicitly.
- ///
- public static readonly CieXyz DefaultWhitePoint = Illuminants.D65;
-
- ///
- /// Initializes a new instance of the struct.
- ///
- /// The lightness dimension.
- /// The blue-yellow chromaticity coordinate of the given whitepoint.
- /// The red-green chromaticity coordinate of the given whitepoint.
- /// Uses as white point.
- [MethodImpl(InliningOptions.ShortMethod)]
- public CieLuv(float l, float u, float v)
- : this(l, u, v, DefaultWhitePoint)
- {
- }
-
- ///
- /// Initializes a new instance of the struct.
- ///
- /// The lightness dimension.
- /// The blue-yellow chromaticity coordinate of the given whitepoint.
- /// The red-green chromaticity coordinate of the given whitepoint.
- /// The reference white point.
- [MethodImpl(InliningOptions.ShortMethod)]
- public CieLuv(float l, float u, float v, CieXyz whitePoint)
- : this(new Vector3(l, u, v), whitePoint)
- {
- }
-
- ///
- /// Initializes a new instance of the struct.
- ///
- /// The vector representing the l, u, v components.
- /// Uses as white point.
- [MethodImpl(InliningOptions.ShortMethod)]
- public CieLuv(Vector3 vector)
- : this(vector, DefaultWhitePoint)
- {
- }
-
- ///
- /// Initializes a new instance of the struct.
- ///
- /// The vector representing the l, u, v components.
- /// The reference white point.
- [MethodImpl(InliningOptions.ShortMethod)]
- public CieLuv(Vector3 vector, CieXyz whitePoint)
- {
- // Not clamping as documentation about this space only indicates "usual" ranges
- this.L = vector.X;
- this.U = vector.Y;
- this.V = vector.Z;
- this.WhitePoint = whitePoint;
- }
-
- ///
- /// Gets the lightness dimension
- /// A value usually ranging between 0 and 100.
- ///
- public readonly float L { get; }
-
- ///
- /// Gets the blue-yellow chromaticity coordinate of the given whitepoint.
- /// A value usually ranging between -100 and 100.
- ///
- public readonly float U { get; }
-
- ///
- /// Gets the red-green chromaticity coordinate of the given whitepoint.
- /// A value usually ranging between -100 and 100.
- ///
- public readonly float V { get; }
-
- ///
- /// Gets the reference white point of this color
- ///
- public readonly CieXyz WhitePoint { get; }
-
- ///
- /// Compares two objects for equality.
- ///
- /// The on the left side of the operand.
- /// The on the right side of the operand.
- ///
- /// True if the current left is equal to the parameter; otherwise, false.
- ///
- [MethodImpl(InliningOptions.ShortMethod)]
- public static bool operator ==(CieLuv left, CieLuv right) => left.Equals(right);
-
- ///
- /// Compares two objects for inequality.
- ///
- /// The on the left side of the operand.
- /// The on the right side of the operand.
- ///
- /// True if the current left is unequal to the parameter; otherwise, false.
- ///
- [MethodImpl(InliningOptions.ShortMethod)]
- public static bool operator !=(CieLuv left, CieLuv right) => !left.Equals(right);
-
- ///
- public override int GetHashCode() => HashCode.Combine(this.L, this.U, this.V, this.WhitePoint);
-
- ///
- public override string ToString() => FormattableString.Invariant($"CieLuv({this.L:#0.##}, {this.U:#0.##}, {this.V:#0.##})");
-
- ///
- public override bool Equals(object? obj) => obj is CieLuv other && this.Equals(other);
-
- ///
- [MethodImpl(InliningOptions.ShortMethod)]
- public bool Equals(CieLuv other)
- => this.L.Equals(other.L)
- && this.U.Equals(other.U)
- && this.V.Equals(other.V)
- && this.WhitePoint.Equals(other.WhitePoint);
-}
diff --git a/src/ImageSharp/ColorSpaces/CieXyy.cs b/src/ImageSharp/ColorSpaces/CieXyy.cs
deleted file mode 100644
index 6b7d2e6cb..000000000
--- a/src/ImageSharp/ColorSpaces/CieXyy.cs
+++ /dev/null
@@ -1,99 +0,0 @@
-// Copyright (c) Six Labors.
-// Licensed under the Six Labors Split License.
-
-using System.Numerics;
-using System.Runtime.CompilerServices;
-
-namespace SixLabors.ImageSharp.ColorSpaces;
-
-///
-/// Represents an CIE xyY 1931 color
-///
-///
-public readonly struct CieXyy : IEquatable
-{
- ///
- /// Initializes a new instance of the struct.
- ///
- /// The x chroma component.
- /// The y chroma component.
- /// The y luminance component.
- [MethodImpl(InliningOptions.ShortMethod)]
- public CieXyy(float x, float y, float yl)
- {
- // Not clamping as documentation about this space only indicates "usual" ranges
- this.X = x;
- this.Y = y;
- this.Yl = yl;
- }
-
- ///
- /// Initializes a new instance of the struct.
- ///
- /// The vector representing the x, y, Y components.
- [MethodImpl(InliningOptions.ShortMethod)]
- public CieXyy(Vector3 vector)
- : this()
- {
- // Not clamping as documentation about this space only indicates "usual" ranges
- this.X = vector.X;
- this.Y = vector.Y;
- this.Yl = vector.Z;
- }
-
- ///
- /// Gets the X chrominance component.
- /// A value usually ranging between 0 and 1.
- ///
- public readonly float X { get; }
-
- ///
- /// Gets the Y chrominance component.
- /// A value usually ranging between 0 and 1.
- ///
- public readonly float Y { get; }
-
- ///
- /// Gets the Y luminance component.
- /// A value usually ranging between 0 and 1.
- ///
- public readonly float Yl { get; }
-
- ///
- /// Compares two objects for equality.
- ///
- /// The on the left side of the operand.
- /// The on the right side of the operand.
- ///
- /// True if the current left is equal to the parameter; otherwise, false.
- ///
- [MethodImpl(InliningOptions.ShortMethod)]
- public static bool operator ==(CieXyy left, CieXyy right) => left.Equals(right);
-
- ///
- /// Compares two objects for inequality.
- ///
- /// The on the left side of the operand.
- /// The on the right side of the operand.
- ///
- /// True if the current left is unequal to the parameter; otherwise, false.
- ///
- [MethodImpl(InliningOptions.ShortMethod)]
- public static bool operator !=(CieXyy left, CieXyy right) => !left.Equals(right);
-
- ///
- public override int GetHashCode() => HashCode.Combine(this.X, this.Y, this.Yl);
-
- ///
- public override string ToString() => FormattableString.Invariant($"CieXyy({this.X:#0.##}, {this.Y:#0.##}, {this.Yl:#0.##})");
-
- ///
- public override bool Equals(object? obj) => obj is CieXyy other && this.Equals(other);
-
- ///
- [MethodImpl(InliningOptions.ShortMethod)]
- public bool Equals(CieXyy other)
- => this.X.Equals(other.X)
- && this.Y.Equals(other.Y)
- && this.Yl.Equals(other.Yl);
-}
diff --git a/src/ImageSharp/ColorSpaces/CieXyz.cs b/src/ImageSharp/ColorSpaces/CieXyz.cs
deleted file mode 100644
index 2ac9c9f28..000000000
--- a/src/ImageSharp/ColorSpaces/CieXyz.cs
+++ /dev/null
@@ -1,102 +0,0 @@
-// Copyright (c) Six Labors.
-// Licensed under the Six Labors Split License.
-
-using System.Numerics;
-using System.Runtime.CompilerServices;
-
-namespace SixLabors.ImageSharp.ColorSpaces;
-
-///
-/// Represents an CIE XYZ 1931 color
-///
-///
-public readonly struct CieXyz : IEquatable
-{
- ///
- /// Initializes a new instance of the struct.
- ///
- /// X is a mix (a linear combination) of cone response curves chosen to be nonnegative
- /// The y luminance component.
- /// Z is quasi-equal to blue stimulation, or the S cone of the human eye.
- [MethodImpl(InliningOptions.ShortMethod)]
- public CieXyz(float x, float y, float z)
- : this(new Vector3(x, y, z))
- {
- }
-
- ///
- /// Initializes a new instance of the struct.
- ///
- /// The vector representing the x, y, z components.
- public CieXyz(Vector3 vector)
- : this()
- {
- // Not clamping as documentation about this space only indicates "usual" ranges
- this.X = vector.X;
- this.Y = vector.Y;
- this.Z = vector.Z;
- }
-
- ///
- /// Gets the X component. A mix (a linear combination) of cone response curves chosen to be nonnegative.
- /// A value usually ranging between 0 and 1.
- ///
- public readonly float X { get; }
-
- ///
- /// Gets the Y luminance component.
- /// A value usually ranging between 0 and 1.
- ///
- public readonly float Y { get; }
-
- ///
- /// Gets the Z component. Quasi-equal to blue stimulation, or the S cone response.
- /// A value usually ranging between 0 and 1.
- ///
- public readonly float Z { get; }
-
- ///
- /// Compares two objects for equality.
- ///
- /// The on the left side of the operand.
- /// The on the right side of the operand.
- ///
- /// True if the current left is equal to the parameter; otherwise, false.
- ///
- [MethodImpl(InliningOptions.ShortMethod)]
- public static bool operator ==(CieXyz left, CieXyz right) => left.Equals(right);
-
- ///
- /// Compares two objects for inequality.
- ///
- /// The on the left side of the operand.
- /// The on the right side of the operand.
- ///
- /// True if the current left is unequal to the parameter; otherwise, false.
- ///
- [MethodImpl(InliningOptions.ShortMethod)]
- public static bool operator !=(CieXyz left, CieXyz right) => !left.Equals(right);
-
- ///
- /// Returns a new representing this instance.
- ///
- /// The .
- [MethodImpl(InliningOptions.ShortMethod)]
- public Vector3 ToVector3() => new(this.X, this.Y, this.Z);
-
- ///
- public override int GetHashCode() => HashCode.Combine(this.X, this.Y, this.Z);
-
- ///
- public override string ToString() => FormattableString.Invariant($"CieXyz({this.X:#0.##}, {this.Y:#0.##}, {this.Z:#0.##})");
-
- ///
- public override bool Equals(object? obj) => obj is CieXyz other && this.Equals(other);
-
- ///
- [MethodImpl(InliningOptions.ShortMethod)]
- public bool Equals(CieXyz other)
- => this.X.Equals(other.X)
- && this.Y.Equals(other.Y)
- && this.Z.Equals(other.Z);
-}
diff --git a/src/ImageSharp/ColorSpaces/Cmyk.cs b/src/ImageSharp/ColorSpaces/Cmyk.cs
deleted file mode 100644
index a5aacf38a..000000000
--- a/src/ImageSharp/ColorSpaces/Cmyk.cs
+++ /dev/null
@@ -1,107 +0,0 @@
-// Copyright (c) Six Labors.
-// Licensed under the Six Labors Split License.
-
-using System.Numerics;
-using System.Runtime.CompilerServices;
-
-namespace SixLabors.ImageSharp.ColorSpaces;
-
-///
-/// Represents an CMYK (cyan, magenta, yellow, keyline) color.
-///
-public readonly struct Cmyk : IEquatable
-{
- private static readonly Vector4 Min = Vector4.Zero;
- private static readonly Vector4 Max = Vector4.One;
-
- ///
- /// Initializes a new instance of the struct.
- ///
- /// The cyan component.
- /// The magenta component.
- /// The yellow component.
- /// The keyline black component.
- [MethodImpl(InliningOptions.ShortMethod)]
- public Cmyk(float c, float m, float y, float k)
- : this(new Vector4(c, m, y, k))
- {
- }
-
- ///
- /// Initializes a new instance of the struct.
- ///
- /// The vector representing the c, m, y, k components.
- [MethodImpl(InliningOptions.ShortMethod)]
- public Cmyk(Vector4 vector)
- {
- vector = Numerics.Clamp(vector, Min, Max);
- this.C = vector.X;
- this.M = vector.Y;
- this.Y = vector.Z;
- this.K = vector.W;
- }
-
- ///
- /// Gets the cyan color component.
- /// A value ranging between 0 and 1.
- ///
- public readonly float C { get; }
-
- ///
- /// Gets the magenta color component.
- /// A value ranging between 0 and 1.
- ///
- public readonly float M { get; }
-
- ///
- /// Gets the yellow color component.
- /// A value ranging between 0 and 1.
- ///
- public readonly float Y { get; }
-
- ///
- /// Gets the keyline black color component.
- /// A value ranging between 0 and 1.
- ///
- public readonly float K { get; }
-
- ///
- /// Compares two objects for equality.
- ///
- /// The on the left side of the operand.
- /// The on the right side of the operand.
- ///
- /// True if the current left is equal to the parameter; otherwise, false.
- ///
- [MethodImpl(InliningOptions.ShortMethod)]
- public static bool operator ==(Cmyk left, Cmyk right) => left.Equals(right);
-
- ///
- /// Compares two objects for inequality.
- ///
- /// The on the left side of the operand.
- /// The on the right side of the operand.
- ///
- /// True if the current left is unequal to the parameter; otherwise, false.
- ///
- [MethodImpl(InliningOptions.ShortMethod)]
- public static bool operator !=(Cmyk left, Cmyk right) => !left.Equals(right);
-
- ///
- [MethodImpl(InliningOptions.ShortMethod)]
- public override int GetHashCode() => HashCode.Combine(this.C, this.M, this.Y, this.K);
-
- ///
- public override string ToString() => FormattableString.Invariant($"Cmyk({this.C:#0.##}, {this.M:#0.##}, {this.Y:#0.##}, {this.K:#0.##})");
-
- ///
- public override bool Equals(object? obj) => obj is Cmyk other && this.Equals(other);
-
- ///
- [MethodImpl(InliningOptions.ShortMethod)]
- public bool Equals(Cmyk other)
- => this.C.Equals(other.C)
- && this.M.Equals(other.M)
- && this.Y.Equals(other.Y)
- && this.K.Equals(other.K);
-}
diff --git a/src/ImageSharp/ColorSpaces/Companding/GammaCompanding.cs b/src/ImageSharp/ColorSpaces/Companding/GammaCompanding.cs
deleted file mode 100644
index e5d98430f..000000000
--- a/src/ImageSharp/ColorSpaces/Companding/GammaCompanding.cs
+++ /dev/null
@@ -1,34 +0,0 @@
-// Copyright (c) Six Labors.
-// Licensed under the Six Labors Split License.
-
-using System.Runtime.CompilerServices;
-
-namespace SixLabors.ImageSharp.ColorSpaces.Companding;
-
-///
-/// Implements gamma companding.
-///
-///
-///
-///
-///
-public static class GammaCompanding
-{
- ///
- /// Expands a companded channel to its linear equivalent with respect to the energy.
- ///
- /// The channel value.
- /// The gamma value.
- /// The representing the linear channel value.
- [MethodImpl(InliningOptions.ShortMethod)]
- public static float Expand(float channel, float gamma) => MathF.Pow(channel, gamma);
-
- ///
- /// Compresses an uncompanded channel (linear) to its nonlinear equivalent.
- ///
- /// The channel value.
- /// The gamma value.
- /// The representing the nonlinear channel value.
- [MethodImpl(InliningOptions.ShortMethod)]
- public static float Compress(float channel, float gamma) => MathF.Pow(channel, 1 / gamma);
-}
diff --git a/src/ImageSharp/ColorSpaces/Companding/LCompanding.cs b/src/ImageSharp/ColorSpaces/Companding/LCompanding.cs
deleted file mode 100644
index db44fd069..000000000
--- a/src/ImageSharp/ColorSpaces/Companding/LCompanding.cs
+++ /dev/null
@@ -1,36 +0,0 @@
-// Copyright (c) Six Labors.
-// Licensed under the Six Labors Split License.
-
-using System.Runtime.CompilerServices;
-using SixLabors.ImageSharp.ColorSpaces.Conversion;
-
-namespace SixLabors.ImageSharp.ColorSpaces.Companding;
-
-///
-/// Implements L* companding.
-///
-///
-/// For more info see:
-///
-///
-///
-public static class LCompanding
-{
- ///
- /// Expands a companded channel to its linear equivalent with respect to the energy.
- ///
- /// The channel value.
- /// The representing the linear channel value.
- [MethodImpl(InliningOptions.ShortMethod)]
- public static float Expand(float channel)
- => channel <= 0.08F ? (100F * channel) / CieConstants.Kappa : Numerics.Pow3((channel + 0.16F) / 1.16F);
-
- ///
- /// Compresses an uncompanded channel (linear) to its nonlinear equivalent.
- ///
- /// The channel value
- /// The representing the nonlinear channel value.
- [MethodImpl(InliningOptions.ShortMethod)]
- public static float Compress(float channel)
- => channel <= CieConstants.Epsilon ? (channel * CieConstants.Kappa) / 100F : (1.16F * MathF.Pow(channel, 0.3333333F)) - 0.16F;
-}
diff --git a/src/ImageSharp/ColorSpaces/Companding/Rec2020Companding.cs b/src/ImageSharp/ColorSpaces/Companding/Rec2020Companding.cs
deleted file mode 100644
index 450097618..000000000
--- a/src/ImageSharp/ColorSpaces/Companding/Rec2020Companding.cs
+++ /dev/null
@@ -1,39 +0,0 @@
-// Copyright (c) Six Labors.
-// Licensed under the Six Labors Split License.
-
-using System.Runtime.CompilerServices;
-
-namespace SixLabors.ImageSharp.ColorSpaces.Companding;
-
-///
-/// Implements Rec. 2020 companding function.
-///
-///
-///
-///
-public static class Rec2020Companding
-{
- private const float Alpha = 1.09929682680944F;
- private const float AlphaMinusOne = Alpha - 1F;
- private const float Beta = 0.018053968510807F;
- private const float InverseBeta = Beta * 4.5F;
- private const float Epsilon = 1 / 0.45F;
-
- ///
- /// Expands a companded channel to its linear equivalent with respect to the energy.
- ///
- /// The channel value.
- /// The representing the linear channel value.
- [MethodImpl(InliningOptions.ShortMethod)]
- public static float Expand(float channel)
- => channel < InverseBeta ? channel / 4.5F : MathF.Pow((channel + AlphaMinusOne) / Alpha, Epsilon);
-
- ///
- /// Compresses an uncompanded channel (linear) to its nonlinear equivalent.
- ///
- /// The channel value.
- /// The representing the nonlinear channel value.
- [MethodImpl(InliningOptions.ShortMethod)]
- public static float Compress(float channel)
- => channel < Beta ? 4.5F * channel : (Alpha * MathF.Pow(channel, 0.45F)) - AlphaMinusOne;
-}
diff --git a/src/ImageSharp/ColorSpaces/Companding/Rec709Companding.cs b/src/ImageSharp/ColorSpaces/Companding/Rec709Companding.cs
deleted file mode 100644
index 6e4767bcd..000000000
--- a/src/ImageSharp/ColorSpaces/Companding/Rec709Companding.cs
+++ /dev/null
@@ -1,35 +0,0 @@
-// Copyright (c) Six Labors.
-// Licensed under the Six Labors Split License.
-
-using System.Runtime.CompilerServices;
-
-namespace SixLabors.ImageSharp.ColorSpaces.Companding;
-
-///
-/// Implements the Rec. 709 companding function.
-///
-///
-/// http://en.wikipedia.org/wiki/Rec._709
-///
-public static class Rec709Companding
-{
- private const float Epsilon = 1 / 0.45F;
-
- ///
- /// Expands a companded channel to its linear equivalent with respect to the energy.
- ///
- /// The channel value.
- /// The representing the linear channel value.
- [MethodImpl(InliningOptions.ShortMethod)]
- public static float Expand(float channel)
- => channel < 0.081F ? channel / 4.5F : MathF.Pow((channel + 0.099F) / 1.099F, Epsilon);
-
- ///
- /// Compresses an uncompanded channel (linear) to its nonlinear equivalent.
- ///
- /// The channel value.
- /// The representing the nonlinear channel value.
- [MethodImpl(InliningOptions.ShortMethod)]
- public static float Compress(float channel)
- => channel < 0.018F ? 4.5F * channel : (1.099F * MathF.Pow(channel, 0.45F)) - 0.099F;
-}
diff --git a/src/ImageSharp/ColorSpaces/Companding/SRgbCompanding.cs b/src/ImageSharp/ColorSpaces/Companding/SRgbCompanding.cs
deleted file mode 100644
index 4c3923c88..000000000
--- a/src/ImageSharp/ColorSpaces/Companding/SRgbCompanding.cs
+++ /dev/null
@@ -1,230 +0,0 @@
-// Copyright (c) Six Labors.
-// Licensed under the Six Labors Split License.
-
-using System.Numerics;
-using System.Runtime.CompilerServices;
-using System.Runtime.InteropServices;
-using System.Runtime.Intrinsics;
-using System.Runtime.Intrinsics.X86;
-
-namespace SixLabors.ImageSharp.ColorSpaces.Companding;
-
-///
-/// Implements sRGB companding.
-///
-///
-/// For more info see:
-///
-///
-///
-public static class SRgbCompanding
-{
- private const int Length = Scale + 2; // 256kb @ 16bit precision.
- private const int Scale = (1 << 16) - 1;
-
- private static readonly Lazy LazyCompressTable = new(
- () =>
- {
- float[] result = new float[Length];
-
- for (int i = 0; i < result.Length; i++)
- {
- double d = (double)i / Scale;
- if (d <= (0.04045 / 12.92))
- {
- d *= 12.92;
- }
- else
- {
- d = (1.055 * Math.Pow(d, 1.0 / 2.4)) - 0.055;
- }
-
- result[i] = (float)d;
- }
-
- return result;
- },
- true);
-
- private static readonly Lazy LazyExpandTable = new(
- () =>
- {
- float[] result = new float[Length];
-
- for (int i = 0; i < result.Length; i++)
- {
- double d = (double)i / Scale;
- if (d <= 0.04045)
- {
- d /= 12.92;
- }
- else
- {
- d = Math.Pow((d + 0.055) / 1.055, 2.4);
- }
-
- result[i] = (float)d;
- }
-
- return result;
- },
- true);
-
- private static float[] ExpandTable => LazyExpandTable.Value;
-
- private static float[] CompressTable => LazyCompressTable.Value;
-
- ///
- /// Expands the companded vectors to their linear equivalents with respect to the energy.
- ///
- /// The span of vectors.
- [MethodImpl(MethodImplOptions.AggressiveInlining)]
- public static void Expand(Span vectors)
- {
- if (Avx2.IsSupported && vectors.Length >= 2)
- {
- CompandAvx2(vectors, ExpandTable);
-
- if (Numerics.Modulo2(vectors.Length) != 0)
- {
- // Vector4 fits neatly in pairs. Any overlap has to be equal to 1.
- Expand(ref MemoryMarshal.GetReference(vectors[^1..]));
- }
- }
- else
- {
- CompandScalar(vectors, ExpandTable);
- }
- }
-
- ///
- /// Compresses the uncompanded vectors to their nonlinear equivalents with respect to the energy.
- ///
- /// The span of vectors.
- [MethodImpl(MethodImplOptions.AggressiveInlining)]
- public static unsafe void Compress(Span vectors)
- {
- if (Avx2.IsSupported && vectors.Length >= 2)
- {
- CompandAvx2(vectors, CompressTable);
-
- if (Numerics.Modulo2(vectors.Length) != 0)
- {
- // Vector4 fits neatly in pairs. Any overlap has to be equal to 1.
- Compress(ref MemoryMarshal.GetReference(vectors[^1..]));
- }
- }
- else
- {
- CompandScalar(vectors, CompressTable);
- }
- }
-
- ///
- /// Expands a companded vector to its linear equivalent with respect to the energy.
- ///
- /// The vector.
- [MethodImpl(MethodImplOptions.AggressiveInlining)]
- public static void Expand(ref Vector4 vector)
- {
- // Alpha is already a linear representation of opacity so we do not want to convert it.
- vector.X = Expand(vector.X);
- vector.Y = Expand(vector.Y);
- vector.Z = Expand(vector.Z);
- }
-
- ///
- /// Compresses an uncompanded vector (linear) to its nonlinear equivalent.
- ///
- /// The vector.
- [MethodImpl(MethodImplOptions.AggressiveInlining)]
- public static void Compress(ref Vector4 vector)
- {
- // Alpha is already a linear representation of opacity so we do not want to convert it.
- vector.X = Compress(vector.X);
- vector.Y = Compress(vector.Y);
- vector.Z = Compress(vector.Z);
- }
-
- ///
- /// Expands a companded channel to its linear equivalent with respect to the energy.
- ///
- /// The channel value.
- /// The representing the linear channel value.
- [MethodImpl(MethodImplOptions.AggressiveInlining)]
- public static float Expand(float channel)
- => channel <= 0.04045F ? channel / 12.92F : MathF.Pow((channel + 0.055F) / 1.055F, 2.4F);
-
- ///
- /// Compresses an uncompanded channel (linear) to its nonlinear equivalent.
- ///
- /// The channel value.
- /// The representing the nonlinear channel value.
- [MethodImpl(MethodImplOptions.AggressiveInlining)]
- public static float Compress(float channel)
- => channel <= 0.0031308F ? 12.92F * channel : (1.055F * MathF.Pow(channel, 0.416666666666667F)) - 0.055F;
-
- [MethodImpl(MethodImplOptions.AggressiveInlining)]
- private static unsafe void CompandAvx2(Span vectors, float[] table)
- {
- fixed (float* tablePointer = &MemoryMarshal.GetArrayDataReference(table))
- {
- var scale = Vector256.Create((float)Scale);
- Vector256 zero = Vector256.Zero;
- var offset = Vector256.Create(1);
-
- // Divide by 2 as 4 elements per Vector4 and 8 per Vector256
- ref Vector256 vectorsBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(vectors));
- ref Vector256 vectorsLast = ref Unsafe.Add(ref vectorsBase, (uint)vectors.Length / 2u);
-
- while (Unsafe.IsAddressLessThan(ref vectorsBase, ref vectorsLast))
- {
- Vector256 multiplied = Avx.Multiply(scale, vectorsBase);
- multiplied = Avx.Min(Avx.Max(zero, multiplied), scale);
-
- Vector256 truncated = Avx.ConvertToVector256Int32WithTruncation(multiplied);
- Vector256 truncatedF = Avx.ConvertToVector256Single(truncated);
-
- Vector256 low = Avx2.GatherVector256(tablePointer, truncated, sizeof(float));
- Vector256 high = Avx2.GatherVector256(tablePointer, Avx2.Add(truncated, offset), sizeof(float));
-
- // Alpha is already a linear representation of opacity so we do not want to convert it.
- Vector256 companded = Numerics.Lerp(low, high, Avx.Subtract(multiplied, truncatedF));
- vectorsBase = Avx.Blend(companded, vectorsBase, Numerics.BlendAlphaControl);
- vectorsBase = ref Unsafe.Add(ref vectorsBase, 1);
- }
- }
- }
-
- [MethodImpl(MethodImplOptions.AggressiveInlining)]
- private static unsafe void CompandScalar(Span vectors, float[] table)
- {
- fixed (float* tablePointer = &MemoryMarshal.GetArrayDataReference(table))
- {
- Vector4 zero = Vector4.Zero;
- var scale = new Vector4(Scale);
- ref Vector4 vectorsBase = ref MemoryMarshal.GetReference(vectors);
- ref Vector4 vectorsLast = ref Unsafe.Add(ref vectorsBase, (uint)vectors.Length);
-
- while (Unsafe.IsAddressLessThan(ref vectorsBase, ref vectorsLast))
- {
- Vector4 multiplied = Numerics.Clamp(vectorsBase * Scale, zero, scale);
-
- float f0 = multiplied.X;
- float f1 = multiplied.Y;
- float f2 = multiplied.Z;
-
- uint i0 = (uint)f0;
- uint i1 = (uint)f1;
- uint i2 = (uint)f2;
-
- // Alpha is already a linear representation of opacity so we do not want to convert it.
- vectorsBase.X = Numerics.Lerp(tablePointer[i0], tablePointer[i0 + 1], f0 - (int)i0);
- vectorsBase.Y = Numerics.Lerp(tablePointer[i1], tablePointer[i1 + 1], f1 - (int)i1);
- vectorsBase.Z = Numerics.Lerp(tablePointer[i2], tablePointer[i2 + 1], f2 - (int)i2);
-
- vectorsBase = ref Unsafe.Add(ref vectorsBase, 1);
- }
- }
- }
-}
diff --git a/src/ImageSharp/ColorSpaces/Conversion/CieConstants.cs b/src/ImageSharp/ColorSpaces/Conversion/CieConstants.cs
deleted file mode 100644
index 7c8794404..000000000
--- a/src/ImageSharp/ColorSpaces/Conversion/CieConstants.cs
+++ /dev/null
@@ -1,21 +0,0 @@
-// Copyright (c) Six Labors.
-// Licensed under the Six Labors Split License.
-
-namespace SixLabors.ImageSharp.ColorSpaces.Conversion;
-
-///
-/// Constants use for Cie conversion calculations
-///
-///
-internal static class CieConstants
-{
- ///
- /// 216F / 24389F
- ///
- public const float Epsilon = 0.008856452F;
-
- ///
- /// 24389F / 27F
- ///
- public const float Kappa = 903.2963F;
-}
diff --git a/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.Adapt.cs b/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.Adapt.cs
deleted file mode 100644
index b4934e44a..000000000
--- a/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.Adapt.cs
+++ /dev/null
@@ -1,159 +0,0 @@
-// Copyright (c) Six Labors.
-// Licensed under the Six Labors Split License.
-
-namespace SixLabors.ImageSharp.ColorSpaces.Conversion;
-
-///
-/// Performs chromatic adaptation on the various color spaces.
-///
-public partial class ColorSpaceConverter
-{
- ///
- /// Performs chromatic adaptation of given color.
- /// Target white point is .
- ///
- /// The color to adapt
- /// The source white point.
- /// The adapted color
- public CieXyz Adapt(in CieXyz color, in CieXyz sourceWhitePoint) => this.Adapt(color, sourceWhitePoint, this.whitePoint);
-
- ///
- /// Performs chromatic adaptation of given color.
- /// Target white point is .
- ///
- /// The color to adapt
- /// The source white point.
- /// The target white point.
- /// The adapted color
- public CieXyz Adapt(in CieXyz color, in CieXyz sourceWhitePoint, in CieXyz targetWhitePoint)
- {
- if (!this.performChromaticAdaptation || sourceWhitePoint.Equals(targetWhitePoint))
- {
- return color;
- }
-
- // We know that chromaticAdaption is not null because performChromaticAdaption is checked
- return this.chromaticAdaptation!.Transform(color, sourceWhitePoint, targetWhitePoint);
- }
-
- ///
- /// Adapts color from the source white point to white point set in .
- ///
- /// The color to adapt
- /// The adapted color
- public CieLab Adapt(in CieLab color)
- {
- if (!this.performChromaticAdaptation || color.WhitePoint.Equals(this.targetLabWhitePoint))
- {
- return color;
- }
-
- var xyzColor = this.ToCieXyz(color);
- return this.ToCieLab(xyzColor);
- }
-
- ///
- /// Adapts color from the source white point to white point set in .
- ///
- /// The color to adapt
- /// The adapted color
- public CieLch Adapt(in CieLch color)
- {
- if (!this.performChromaticAdaptation || color.WhitePoint.Equals(this.targetLabWhitePoint))
- {
- return color;
- }
-
- var labColor = this.ToCieLab(color);
- return this.ToCieLch(labColor);
- }
-
- ///
- /// Adapts color from the source white point to white point set in .
- ///
- /// The color to adapt
- /// The adapted color
- public CieLchuv Adapt(in CieLchuv color)
- {
- if (!this.performChromaticAdaptation || color.WhitePoint.Equals(this.targetLabWhitePoint))
- {
- return color;
- }
-
- var luvColor = this.ToCieLuv(color);
- return this.ToCieLchuv(luvColor);
- }
-
- ///
- /// Adapts color from the source white point to white point set in .
- ///
- /// The color to adapt
- /// The adapted color
- public CieLuv Adapt(in CieLuv color)
- {
- if (!this.performChromaticAdaptation || color.WhitePoint.Equals(this.targetLuvWhitePoint))
- {
- return color;
- }
-
- var xyzColor = this.ToCieXyz(color);
- return this.ToCieLuv(xyzColor);
- }
-
- ///
- /// Adapts color from the source white point to white point set in .
- ///
- /// The color to adapt
- /// The adapted color
- public HunterLab Adapt(in HunterLab color)
- {
- if (!this.performChromaticAdaptation || color.WhitePoint.Equals(this.targetHunterLabWhitePoint))
- {
- return color;
- }
-
- var xyzColor = this.ToCieXyz(color);
- return this.ToHunterLab(xyzColor);
- }
-
- ///
- /// Adapts a color from the source working space to working space set in .
- ///
- /// The color to adapt
- /// The adapted color
- public LinearRgb Adapt(in LinearRgb color)
- {
- if (!this.performChromaticAdaptation || color.WorkingSpace.Equals(this.targetRgbWorkingSpace))
- {
- return color;
- }
-
- // Conversion to XYZ
- LinearRgbToCieXyzConverter converterToXYZ = GetLinearRgbToCieXyzConverter(color.WorkingSpace);
- CieXyz unadapted = converterToXYZ.Convert(color);
-
- // Adaptation
- // We know that chromaticAdaption is not null because performChromaticAdaption is checked
- CieXyz adapted = this.chromaticAdaptation!.Transform(unadapted, color.WorkingSpace.WhitePoint, this.targetRgbWorkingSpace.WhitePoint);
-
- // Conversion back to RGB
- return this.cieXyzToLinearRgbConverter.Convert(adapted);
- }
-
- ///
- /// Adapts an color from the source working space to working space set in .
- ///
- /// The color to adapt
- /// The adapted color
- public Rgb Adapt(in Rgb color)
- {
- if (!this.performChromaticAdaptation)
- {
- return color;
- }
-
- var linearInput = ToLinearRgb(color);
- LinearRgb linearOutput = this.Adapt(linearInput);
- return ToRgb(linearOutput);
- }
-}
diff --git a/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.CieLab.cs b/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.CieLab.cs
deleted file mode 100644
index 54667ca2a..000000000
--- a/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.CieLab.cs
+++ /dev/null
@@ -1,441 +0,0 @@
-// Copyright (c) Six Labors.
-// Licensed under the Six Labors Split License.
-
-using System.Runtime.CompilerServices;
-using System.Runtime.InteropServices;
-
-namespace SixLabors.ImageSharp.ColorSpaces.Conversion;
-
-///
-/// Allows conversion to .
-///
-public partial class ColorSpaceConverter
-{
- ///
- /// Converts a into a .
- ///
- /// The color to convert.
- /// The
- public CieLab ToCieLab(in CieLch color)
- {
- // Conversion (preserving white point)
- CieLab unadapted = CieLchToCieLabConverter.Convert(color);
-
- return this.Adapt(unadapted);
- }
-
- ///
- /// Performs the bulk conversion from into .
- ///
- /// The span to the source colors
- /// The span to the destination colors
- public void Convert(ReadOnlySpan source, Span destination)
- {
- Guard.DestinationShouldNotBeTooShort(source, destination, nameof(destination));
- int count = source.Length;
-
- ref CieLch sourceRef = ref MemoryMarshal.GetReference(source);
- ref CieLab destRef = ref MemoryMarshal.GetReference(destination);
-
- for (nuint i = 0; i < (uint)count; i++)
- {
- ref CieLch sp = ref Unsafe.Add(ref sourceRef, i);
- ref CieLab dp = ref Unsafe.Add(ref destRef, i);
- dp = this.ToCieLab(sp);
- }
- }
-
- ///
- /// Converts a into a .
- ///
- /// The color to convert.
- /// The
- public CieLab ToCieLab(in CieLchuv color)
- {
- CieXyz xyzColor = this.ToCieXyz(color);
-
- return this.ToCieLab(xyzColor);
- }
-
- ///
- /// Performs the bulk conversion from into .
- ///
- /// The span to the source colors
- /// The span to the destination colors
- public void Convert(ReadOnlySpan source, Span destination)
- {
- Guard.DestinationShouldNotBeTooShort(source, destination, nameof(destination));
- int count = source.Length;
-
- ref CieLchuv sourceRef = ref MemoryMarshal.GetReference(source);
- ref CieLab destRef = ref MemoryMarshal.GetReference(destination);
-
- for (nuint i = 0; i < (uint)count; i++)
- {
- ref CieLchuv sp = ref Unsafe.Add(ref sourceRef, i);
- ref CieLab dp = ref Unsafe.Add(ref destRef, i);
- dp = this.ToCieLab(sp);
- }
- }
-
- ///
- /// Converts a into a .
- ///
- /// The color to convert.
- /// The
- public CieLab ToCieLab(in CieLuv color)
- {
- CieXyz xyzColor = this.ToCieXyz(color);
-
- return this.ToCieLab(xyzColor);
- }
-
- ///
- /// Performs the bulk conversion from into .
- ///
- /// The span to the source colors
- /// The span to the destination colors
- public void Convert(ReadOnlySpan source, Span destination)
- {
- Guard.DestinationShouldNotBeTooShort(source, destination, nameof(destination));
- int count = source.Length;
-
- ref CieLuv sourceRef = ref MemoryMarshal.GetReference(source);
- ref CieLab destRef = ref MemoryMarshal.GetReference(destination);
-
- for (nuint i = 0; i < (uint)count; i++)
- {
- ref CieLuv sp = ref Unsafe.Add(ref sourceRef, i);
- ref CieLab dp = ref Unsafe.Add(ref destRef, i);
- dp = this.ToCieLab(sp);
- }
- }
-
- ///
- /// Converts a into a .
- ///
- /// The color to convert.
- /// The
- public CieLab ToCieLab(in CieXyy color)
- {
- CieXyz xyzColor = ToCieXyz(color);
-
- return this.ToCieLab(xyzColor);
- }
-
- ///
- /// Performs the bulk conversion from into .
- ///
- /// The span to the source colors
- /// The span to the destination colors
- public void Convert(ReadOnlySpan source, Span destination)
- {
- Guard.DestinationShouldNotBeTooShort(source, destination, nameof(destination));
- int count = source.Length;
-
- ref CieXyy sourceRef = ref MemoryMarshal.GetReference(source);
- ref CieLab destRef = ref MemoryMarshal.GetReference(destination);
-
- for (nuint i = 0; i < (uint)count; i++)
- {
- ref CieXyy sp = ref Unsafe.Add(ref sourceRef, i);
- ref CieLab dp = ref Unsafe.Add(ref destRef, i);
- dp = this.ToCieLab(sp);
- }
- }
-
- ///
- /// Converts a into a
- ///
- /// The color to convert.
- /// The
- public CieLab ToCieLab(in CieXyz color)
- {
- CieXyz adapted = this.Adapt(color, this.whitePoint, this.targetLabWhitePoint);
-
- return this.cieXyzToCieLabConverter.Convert(adapted);
- }
-
- ///
- /// Performs the bulk conversion from into
- ///
- /// The span to the source colors
- /// The span to the destination colors
- public void Convert(ReadOnlySpan source, Span destination)
- {
- Guard.DestinationShouldNotBeTooShort(source, destination, nameof(destination));
- int count = source.Length;
-
- ref CieXyz sourceRef = ref MemoryMarshal.GetReference(source);
- ref CieLab destRef = ref MemoryMarshal.GetReference(destination);
-
- for (nuint i = 0; i < (uint)count; i++)
- {
- ref CieXyz sp = ref Unsafe.Add(ref sourceRef, i);
- ref CieLab dp = ref Unsafe.Add(ref destRef, i);
- dp = this.ToCieLab(sp);
- }
- }
-
- ///
- /// Converts a into a
- ///
- /// The color to convert.
- /// The
- public CieLab ToCieLab(in Cmyk color)
- {
- CieXyz xyzColor = this.ToCieXyz(color);
- return this.ToCieLab(xyzColor);
- }
-
- ///
- /// Performs the bulk conversion from into .
- ///
- /// The span to the source colors
- /// The span to the destination colors
- public void Convert(ReadOnlySpan source, Span destination)
- {
- Guard.DestinationShouldNotBeTooShort(source, destination, nameof(destination));
- int count = source.Length;
-
- ref Cmyk sourceRef = ref MemoryMarshal.GetReference(source);
- ref CieLab destRef = ref MemoryMarshal.GetReference(destination);
-
- for (nuint i = 0; i < (uint)count; i++)
- {
- ref Cmyk sp = ref Unsafe.Add(ref sourceRef, i);
- ref CieLab dp = ref Unsafe.Add(ref destRef, i);
- dp = this.ToCieLab(sp);
- }
- }
-
- ///
- /// Converts a into a .
- ///
- /// The color to convert.
- /// The
- public CieLab ToCieLab(in Hsl color)
- {
- CieXyz xyzColor = this.ToCieXyz(color);
-
- return this.ToCieLab(xyzColor);
- }
-
- ///
- /// Performs the bulk conversion from into .
- ///
- /// The span to the source colors
- /// The span to the destination colors
- public void Convert(ReadOnlySpan source, Span destination)
- {
- Guard.DestinationShouldNotBeTooShort(source, destination, nameof(destination));
- int count = source.Length;
-
- ref Hsl sourceRef = ref MemoryMarshal.GetReference(source);
- ref CieLab destRef = ref MemoryMarshal.GetReference(destination);
-
- for (nuint i = 0; i < (uint)count; i++)
- {
- ref Hsl sp = ref Unsafe.Add(ref sourceRef, i);
- ref CieLab dp = ref Unsafe.Add(ref destRef, i);
- dp = this.ToCieLab(sp);
- }
- }
-
- ///
- /// Converts a into a .
- ///
- /// The color to convert.
- /// The
- public CieLab ToCieLab(in Hsv color)
- {
- CieXyz xyzColor = this.ToCieXyz(color);
- return this.ToCieLab(xyzColor);
- }
-
- ///
- /// Performs the bulk conversion from into .
- ///
- /// The span to the source colors
- /// The span to the destination colors
- public void Convert(ReadOnlySpan source, Span destination)
- {
- Guard.DestinationShouldNotBeTooShort(source, destination, nameof(destination));
- int count = source.Length;
-
- ref Hsv sourceRef = ref MemoryMarshal.GetReference(source);
- ref CieLab destRef = ref MemoryMarshal.GetReference(destination);
-
- for (nuint i = 0; i < (uint)count; i++)
- {
- ref Hsv sp = ref Unsafe.Add(ref sourceRef, i);
- ref CieLab dp = ref Unsafe.Add(ref destRef, i);
- dp = this.ToCieLab(sp);
- }
- }
-
- ///
- /// Converts a into a .
- ///
- /// The color to convert.
- /// The
- public CieLab ToCieLab(in HunterLab color)
- {
- CieXyz xyzColor = this.ToCieXyz(color);
-
- return this.ToCieLab(xyzColor);
- }
-
- ///
- /// Performs the bulk conversion from into .
- ///
- /// The span to the source colors
- /// The span to the destination colors
- public void Convert(ReadOnlySpan source, Span destination)
- {
- Guard.DestinationShouldNotBeTooShort(source, destination, nameof(destination));
- int count = source.Length;
-
- ref HunterLab sourceRef = ref MemoryMarshal.GetReference(source);
- ref CieLab destRef = ref MemoryMarshal.GetReference(destination);
-
- for (nuint i = 0; i < (uint)count; i++)
- {
- ref HunterLab sp = ref Unsafe.Add(ref sourceRef, i);
- ref CieLab dp = ref Unsafe.Add(ref destRef, i);
- dp = this.ToCieLab(sp);
- }
- }
-
- ///
- /// Converts a into a .
- ///
- /// The color to convert.
- /// The
- public CieLab ToCieLab(in Lms color)
- {
- CieXyz xyzColor = this.ToCieXyz(color);
-
- return this.ToCieLab(xyzColor);
- }
-
- ///
- /// Performs the bulk conversion from into .
- ///
- /// The span to the source colors
- /// The span to the destination colors
- public void Convert(ReadOnlySpan source, Span destination)
- {
- Guard.DestinationShouldNotBeTooShort(source, destination, nameof(destination));
- int count = source.Length;
-
- ref Lms sourceRef = ref MemoryMarshal.GetReference(source);
- ref CieLab destRef = ref MemoryMarshal.GetReference(destination);
-
- for (nuint i = 0; i < (uint)count; i++)
- {
- ref Lms sp = ref Unsafe.Add(ref sourceRef, i);
- ref CieLab dp = ref Unsafe.Add(ref destRef, i);
- dp = this.ToCieLab(sp);
- }
- }
-
- ///
- /// Converts a into a .
- ///
- /// The color to convert.
- /// The
- public CieLab ToCieLab(in LinearRgb color)
- {
- CieXyz xyzColor = this.ToCieXyz(color);
-
- return this.ToCieLab(xyzColor);
- }
-
- ///
- /// Performs the bulk conversion from into .
- ///
- /// The span to the source colors
- /// The span to the destination colors
- public void Convert(ReadOnlySpan source, Span destination)
- {
- Guard.DestinationShouldNotBeTooShort(source, destination, nameof(destination));
- int count = source.Length;
-
- ref LinearRgb sourceRef = ref MemoryMarshal.GetReference(source);
- ref CieLab destRef = ref MemoryMarshal.GetReference(destination);
-
- for (nuint i = 0; i < (uint)count; i++)
- {
- ref LinearRgb sp = ref Unsafe.Add(ref sourceRef, i);
- ref CieLab dp = ref Unsafe.Add(ref destRef, i);
- dp = this.ToCieLab(sp);
- }
- }
-
- ///
- /// Converts a into a .
- ///
- /// The color to convert.
- /// The
- public CieLab ToCieLab(in Rgb color)
- {
- CieXyz xyzColor = this.ToCieXyz(color);
-
- return this.ToCieLab(xyzColor);
- }
-
- ///
- /// Performs the bulk conversion from into .
- ///
- /// The span to the source colors
- /// The span to the destination colors
- public void Convert(ReadOnlySpan source, Span destination)
- {
- Guard.DestinationShouldNotBeTooShort(source, destination, nameof(destination));
- int count = source.Length;
-
- ref Rgb sourceRef = ref MemoryMarshal.GetReference(source);
- ref CieLab destRef = ref MemoryMarshal.GetReference(destination);
-
- for (nuint i = 0; i < (uint)count; i++)
- {
- ref Rgb sp = ref Unsafe.Add(ref sourceRef, i);
- ref CieLab dp = ref Unsafe.Add(ref destRef, i);
- dp = this.ToCieLab(sp);
- }
- }
-
- ///
- /// Converts a into a
- ///
- /// The color to convert.
- /// The
- public CieLab ToCieLab(in YCbCr color)
- {
- CieXyz xyzColor = this.ToCieXyz(color);
-
- return this.ToCieLab(xyzColor);
- }
-
- ///
- /// Performs the bulk conversion from into .
- ///
- /// The span to the source colors
- /// The span to the destination colors
- public void Convert(ReadOnlySpan source, Span destination)
- {
- Guard.DestinationShouldNotBeTooShort(source, destination, nameof(destination));
- int count = source.Length;
-
- ref YCbCr sourceRef = ref MemoryMarshal.GetReference(source);
- ref CieLab destRef = ref MemoryMarshal.GetReference(destination);
-
- for (nuint i = 0; i < (uint)count; i++)
- {
- ref YCbCr sp = ref Unsafe.Add(ref sourceRef, i);
- ref CieLab dp = ref Unsafe.Add(ref destRef, i);
- dp = this.ToCieLab(sp);
- }
- }
-}
diff --git a/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.CieLch.cs b/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.CieLch.cs
deleted file mode 100644
index 9949b5d91..000000000
--- a/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.CieLch.cs
+++ /dev/null
@@ -1,441 +0,0 @@
-// Copyright (c) Six Labors.
-// Licensed under the Six Labors Split License.
-
-using System.Runtime.CompilerServices;
-using System.Runtime.InteropServices;
-
-namespace SixLabors.ImageSharp.ColorSpaces.Conversion;
-
-///
-/// Allows conversion to .
-///
-public partial class ColorSpaceConverter
-{
- ///
- /// Converts a into a
- ///
- /// The color to convert.
- /// The
- public CieLch ToCieLch(in CieLab color)
- {
- CieLab adapted = this.Adapt(color);
-
- return CieLabToCieLchConverter.Convert(adapted);
- }
-
- ///
- /// Performs the bulk conversion from into .
- ///
- /// The span to the source colors
- /// The span to the destination colors
- public void Convert(ReadOnlySpan source, Span destination)
- {
- Guard.DestinationShouldNotBeTooShort(source, destination, nameof(destination));
- int count = source.Length;
-
- ref CieLab sourceRef = ref MemoryMarshal.GetReference(source);
- ref CieLch destRef = ref MemoryMarshal.GetReference(destination);
-
- for (nuint i = 0; i < (uint)count; i++)
- {
- ref CieLab sp = ref Unsafe.Add(ref sourceRef, i);
- ref CieLch dp = ref Unsafe.Add(ref destRef, i);
- dp = this.ToCieLch(sp);
- }
- }
-
- ///
- /// Converts a into a .
- ///
- /// The color to convert.
- /// The
- public CieLch ToCieLch(in CieLchuv color)
- {
- var xyzColor = this.ToCieXyz(color);
-
- return this.ToCieLch(xyzColor);
- }
-
- ///
- /// Performs the bulk conversion from into .
- ///
- /// The span to the source colors
- /// The span to the destination colors
- public void Convert(ReadOnlySpan source, Span destination)
- {
- Guard.DestinationShouldNotBeTooShort(source, destination, nameof(destination));
- int count = source.Length;
-
- ref CieLchuv sourceRef = ref MemoryMarshal.GetReference(source);
- ref CieLch destRef = ref MemoryMarshal.GetReference(destination);
-
- for (nuint i = 0; i < (uint)count; i++)
- {
- ref CieLchuv sp = ref Unsafe.Add(ref sourceRef, i);
- ref CieLch dp = ref Unsafe.Add(ref destRef, i);
- dp = this.ToCieLch(sp);
- }
- }
-
- ///
- /// Converts a into a .
- ///
- /// The color to convert.
- /// The
- public CieLch ToCieLch(in CieLuv color)
- {
- var xyzColor = this.ToCieXyz(color);
-
- return this.ToCieLch(xyzColor);
- }
-
- ///
- /// Performs the bulk conversion from into .
- ///
- /// The span to the source colors
- /// The span to the destination colors
- public void Convert(ReadOnlySpan source, Span destination)
- {
- Guard.DestinationShouldNotBeTooShort(source, destination, nameof(destination));
- int count = source.Length;
-
- ref CieLuv sourceRef = ref MemoryMarshal.GetReference(source);
- ref CieLch destRef = ref MemoryMarshal.GetReference(destination);
-
- for (nuint i = 0; i < (uint)count; i++)
- {
- ref CieLuv sp = ref Unsafe.Add(ref sourceRef, i);
- ref CieLch dp = ref Unsafe.Add(ref destRef, i);
- dp = this.ToCieLch(sp);
- }
- }
-
- ///
- /// Converts a into a .
- ///
- /// The color to convert.
- /// The
- public CieLch ToCieLch(in CieXyy color)
- {
- var xyzColor = ToCieXyz(color);
-
- return this.ToCieLch(xyzColor);
- }
-
- ///
- /// Performs the bulk conversion from into .
- ///
- /// The span to the source colors
- /// The span to the destination colors
- public void Convert(ReadOnlySpan source, Span destination)
- {
- Guard.DestinationShouldNotBeTooShort(source, destination, nameof(destination));
- int count = source.Length;
-
- ref CieXyy sourceRef = ref MemoryMarshal.GetReference(source);
- ref CieLch destRef = ref MemoryMarshal.GetReference(destination);
-
- for (nuint i = 0; i < (uint)count; i++)
- {
- ref CieXyy sp = ref Unsafe.Add(ref sourceRef, i);
- ref CieLch dp = ref Unsafe.Add(ref destRef, i);
- dp = this.ToCieLch(sp);
- }
- }
-
- ///
- /// Converts a into a
- ///
- /// The color to convert.
- /// The
- public CieLch ToCieLch(in CieXyz color)
- {
- var labColor = this.ToCieLab(color);
-
- return this.ToCieLch(labColor);
- }
-
- ///
- /// Performs the bulk conversion from into .
- ///
- /// The span to the source colors
- /// The span to the destination colors
- public void Convert(ReadOnlySpan source, Span destination)
- {
- Guard.DestinationShouldNotBeTooShort(source, destination, nameof(destination));
- int count = source.Length;
-
- ref CieXyz sourceRef = ref MemoryMarshal.GetReference(source);
- ref CieLch destRef = ref MemoryMarshal.GetReference(destination);
-
- for (nuint i = 0; i < (uint)count; i++)
- {
- ref CieXyz sp = ref Unsafe.Add(ref sourceRef, i);
- ref CieLch dp = ref Unsafe.Add(ref destRef, i);
- dp = this.ToCieLch(sp);
- }
- }
-
- ///
- /// Converts a into a .
- ///
- /// The color to convert.
- /// The
- public CieLch ToCieLch(in Cmyk color)
- {
- var xyzColor = this.ToCieXyz(color);
- return this.ToCieLch(xyzColor);
- }
-
- ///
- /// Performs the bulk conversion from into .
- ///
- /// The span to the source colors
- /// The span to the destination colors
- public void Convert(ReadOnlySpan source, Span destination)
- {
- Guard.DestinationShouldNotBeTooShort(source, destination, nameof(destination));
- int count = source.Length;
-
- ref Cmyk sourceRef = ref MemoryMarshal.GetReference(source);
- ref CieLch destRef = ref MemoryMarshal.GetReference(destination);
-
- for (nuint i = 0; i < (uint)count; i++)
- {
- ref Cmyk sp = ref Unsafe.Add(ref sourceRef, i);
- ref CieLch dp = ref Unsafe.Add(ref destRef, i);
- dp = this.ToCieLch(sp);
- }
- }
-
- ///
- /// Converts a into a .
- ///
- /// The color to convert.
- /// The
- public CieLch ToCieLch(in Hsl color)
- {
- var xyzColor = this.ToCieXyz(color);
-
- return this.ToCieLch(xyzColor);
- }
-
- ///
- /// Performs the bulk conversion from into .
- ///
- /// The span to the source colors
- /// The span to the destination colors
- public void Convert(ReadOnlySpan source, Span destination)
- {
- Guard.DestinationShouldNotBeTooShort(source, destination, nameof(destination));
- int count = source.Length;
-
- ref Hsl sourceRef = ref MemoryMarshal.GetReference(source);
- ref CieLch destRef = ref MemoryMarshal.GetReference(destination);
-
- for (nuint i = 0; i < (uint)count; i++)
- {
- ref Hsl sp = ref Unsafe.Add(ref sourceRef, i);
- ref CieLch dp = ref Unsafe.Add(ref destRef, i);
- dp = this.ToCieLch(sp);
- }
- }
-
- ///
- /// Converts a into a .
- ///
- /// The color to convert.
- /// The
- public CieLch ToCieLch(in Hsv color)
- {
- var xyzColor = this.ToCieXyz(color);
-
- return this.ToCieLch(xyzColor);
- }
-
- ///
- /// Performs the bulk conversion from into .
- ///
- /// The span to the source colors
- /// The span to the destination colors
- public void Convert(ReadOnlySpan source, Span destination)
- {
- Guard.DestinationShouldNotBeTooShort(source, destination, nameof(destination));
- int count = source.Length;
-
- ref Hsv sourceRef = ref MemoryMarshal.GetReference(source);
- ref CieLch destRef = ref MemoryMarshal.GetReference(destination);
-
- for (nuint i = 0; i < (uint)count; i++)
- {
- ref Hsv sp = ref Unsafe.Add(ref sourceRef, i);
- ref CieLch dp = ref Unsafe.Add(ref destRef, i);
- dp = this.ToCieLch(sp);
- }
- }
-
- ///
- /// Converts a into a .
- ///
- /// The color to convert.
- /// The
- public CieLch ToCieLch(in HunterLab color)
- {
- var xyzColor = this.ToCieXyz(color);
-
- return this.ToCieLch(xyzColor);
- }
-
- ///
- /// Performs the bulk conversion from into .
- ///
- /// The span to the source colors
- /// The span to the destination colors
- public void Convert(ReadOnlySpan source, Span destination)
- {
- Guard.DestinationShouldNotBeTooShort(source, destination, nameof(destination));
- int count = source.Length;
-
- ref HunterLab sourceRef = ref MemoryMarshal.GetReference(source);
- ref CieLch destRef = ref MemoryMarshal.GetReference(destination);
-
- for (nuint i = 0; i < (uint)count; i++)
- {
- ref HunterLab sp = ref Unsafe.Add(ref sourceRef, i);
- ref CieLch dp = ref Unsafe.Add(ref destRef, i);
- dp = this.ToCieLch(sp);
- }
- }
-
- ///
- /// Converts a into a .
- ///
- /// The color to convert.
- /// The
- public CieLch ToCieLch(in LinearRgb color)
- {
- var xyzColor = this.ToCieXyz(color);
-
- return this.ToCieLch(xyzColor);
- }
-
- ///
- /// Performs the bulk conversion from into .
- ///
- /// The span to the source colors
- /// The span to the destination colors
- public void Convert(ReadOnlySpan source, Span destination)
- {
- Guard.DestinationShouldNotBeTooShort(source, destination, nameof(destination));
- int count = source.Length;
-
- ref LinearRgb sourceRef = ref MemoryMarshal.GetReference(source);
- ref CieLch destRef = ref MemoryMarshal.GetReference(destination);
-
- for (nuint i = 0; i < (uint)count; i++)
- {
- ref LinearRgb sp = ref Unsafe.Add(ref sourceRef, i);
- ref CieLch dp = ref Unsafe.Add(ref destRef, i);
- dp = this.ToCieLch(sp);
- }
- }
-
- ///
- /// Converts a into a .
- ///
- /// The color to convert.
- /// The
- public CieLch ToCieLch(in Lms color)
- {
- var xyzColor = this.ToCieXyz(color);
-
- return this.ToCieLch(xyzColor);
- }
-
- ///
- /// Performs the bulk conversion from into .
- ///
- /// The span to the source colors
- /// The span to the destination colors
- public void Convert(ReadOnlySpan source, Span destination)
- {
- Guard.DestinationShouldNotBeTooShort(source, destination, nameof(destination));
- int count = source.Length;
-
- ref Lms sourceRef = ref MemoryMarshal.GetReference(source);
- ref CieLch destRef = ref MemoryMarshal.GetReference(destination);
-
- for (nuint i = 0; i < (uint)count; i++)
- {
- ref Lms sp = ref Unsafe.Add(ref sourceRef, i);
- ref CieLch dp = ref Unsafe.Add(ref destRef, i);
- dp = this.ToCieLch(sp);
- }
- }
-
- ///
- /// Converts a into a .
- ///
- /// The color to convert.
- /// The
- public CieLch ToCieLch(in Rgb color)
- {
- var xyzColor = this.ToCieXyz(color);
-
- return this.ToCieLch(xyzColor);
- }
-
- ///
- /// Performs the bulk conversion from into .
- ///
- /// The span to the source colors
- /// The span to the destination colors
- public void Convert(ReadOnlySpan source, Span destination)
- {
- Guard.DestinationShouldNotBeTooShort(source, destination, nameof(destination));
- int count = source.Length;
-
- ref Rgb sourceRef = ref MemoryMarshal.GetReference(source);
- ref CieLch destRef = ref MemoryMarshal.GetReference(destination);
-
- for (nuint i = 0; i < (uint)count; i++)
- {
- ref Rgb sp = ref Unsafe.Add(ref sourceRef, i);
- ref CieLch dp = ref Unsafe.Add(ref destRef, i);
- dp = this.ToCieLch(sp);
- }
- }
-
- ///
- /// Converts a into a .
- ///
- /// The color to convert.
- /// The
- public CieLch ToCieLch(in YCbCr color)
- {
- var xyzColor = this.ToCieXyz(color);
-
- return this.ToCieLch(xyzColor);
- }
-
- ///
- /// Performs the bulk conversion from into .
- ///
- /// The span to the source colors
- /// The span to the destination colors
- public void Convert(ReadOnlySpan source, Span destination)
- {
- Guard.DestinationShouldNotBeTooShort(source, destination, nameof(destination));
- int count = source.Length;
-
- ref YCbCr sourceRef = ref MemoryMarshal.GetReference(source);
- ref CieLch destRef = ref MemoryMarshal.GetReference(destination);
-
- for (nuint i = 0; i < (uint)count; i++)
- {
- ref YCbCr sp = ref Unsafe.Add(ref sourceRef, i);
- ref CieLch dp = ref Unsafe.Add(ref destRef, i);
- dp = this.ToCieLch(sp);
- }
- }
-}
diff --git a/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.CieLchuv.cs b/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.CieLchuv.cs
deleted file mode 100644
index 4b856d118..000000000
--- a/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.CieLchuv.cs
+++ /dev/null
@@ -1,441 +0,0 @@
-// Copyright (c) Six Labors.
-// Licensed under the Six Labors Split License.
-
-using System.Runtime.CompilerServices;
-using System.Runtime.InteropServices;
-
-namespace SixLabors.ImageSharp.ColorSpaces.Conversion;
-
-///
-/// Allows conversion to .
-///
-public partial class ColorSpaceConverter
-{
- ///
- /// Converts a into a
- ///
- /// The color to convert.
- /// The
- public CieLchuv ToCieLchuv(in CieLab color)
- {
- CieXyz xyzColor = this.ToCieXyz(color);
-
- return this.ToCieLchuv(xyzColor);
- }
-
- ///
- /// Performs the bulk conversion from into .
- ///
- /// The span to the source colors
- /// The span to the destination colors
- public void Convert(ReadOnlySpan source, Span destination)
- {
- Guard.DestinationShouldNotBeTooShort(source, destination, nameof(destination));
- int count = source.Length;
-
- ref CieLab sourceRef = ref MemoryMarshal.GetReference(source);
- ref CieLchuv destRef = ref MemoryMarshal.GetReference(destination);
-
- for (nuint i = 0; i < (uint)count; i++)
- {
- ref CieLab sp = ref Unsafe.Add(ref sourceRef, i);
- ref CieLchuv dp = ref Unsafe.Add(ref destRef, i);
- dp = this.ToCieLchuv(sp);
- }
- }
-
- ///
- /// Converts a into a .
- ///
- /// The color to convert.
- /// The
- public CieLchuv ToCieLchuv(in CieLch color)
- {
- CieXyz xyzColor = this.ToCieXyz(color);
-
- return this.ToCieLchuv(xyzColor);
- }
-
- ///
- /// Performs the bulk conversion from into .
- ///
- /// The span to the source colors
- /// The span to the destination colors
- public void Convert(ReadOnlySpan source, Span destination)
- {
- Guard.DestinationShouldNotBeTooShort(source, destination, nameof(destination));
- int count = source.Length;
-
- ref CieLch sourceRef = ref MemoryMarshal.GetReference(source);
- ref CieLchuv destRef = ref MemoryMarshal.GetReference(destination);
-
- for (nuint i = 0; i < (uint)count; i++)
- {
- ref CieLch sp = ref Unsafe.Add(ref sourceRef, i);
- ref CieLchuv dp = ref Unsafe.Add(ref destRef, i);
- dp = this.ToCieLchuv(sp);
- }
- }
-
- ///
- /// Converts a into a .
- ///
- /// The color to convert.
- /// The
- public CieLchuv ToCieLchuv(in CieLuv color)
- {
- CieLuv adapted = this.Adapt(color);
-
- return CieLuvToCieLchuvConverter.Convert(adapted);
- }
-
- ///
- /// Performs the bulk conversion from into .
- ///
- /// The span to the source colors
- /// The span to the destination colors
- public void Convert(ReadOnlySpan source, Span destination)
- {
- Guard.DestinationShouldNotBeTooShort(source, destination, nameof(destination));
- int count = source.Length;
-
- ref CieLuv sourceRef = ref MemoryMarshal.GetReference(source);
- ref CieLchuv destRef = ref MemoryMarshal.GetReference(destination);
-
- for (nuint i = 0; i < (uint)count; i++)
- {
- ref CieLuv sp = ref Unsafe.Add(ref sourceRef, i);
- ref CieLchuv dp = ref Unsafe.Add(ref destRef, i);
- dp = this.ToCieLchuv(sp);
- }
- }
-
- ///
- /// Converts a into a .
- ///
- /// The color to convert.
- /// The
- public CieLchuv ToCieLchuv(in CieXyy color)
- {
- CieXyz xyzColor = ToCieXyz(color);
-
- return this.ToCieLchuv(xyzColor);
- }
-
- ///
- /// Performs the bulk conversion from into .
- ///
- /// The span to the source colors
- /// The span to the destination colors
- public void Convert(ReadOnlySpan source, Span destination)
- {
- Guard.DestinationShouldNotBeTooShort(source, destination, nameof(destination));
- int count = source.Length;
-
- ref CieXyy sourceRef = ref MemoryMarshal.GetReference(source);
- ref CieLchuv destRef = ref MemoryMarshal.GetReference(destination);
-
- for (nuint i = 0; i < (uint)count; i++)
- {
- ref CieXyy sp = ref Unsafe.Add(ref sourceRef, i);
- ref CieLchuv dp = ref Unsafe.Add(ref destRef, i);
- dp = this.ToCieLchuv(sp);
- }
- }
-
- ///
- /// Converts a into a .
- ///
- /// The color to convert.
- /// The
- public CieLchuv ToCieLchuv(in CieXyz color)
- {
- CieLuv luvColor = this.ToCieLuv(color);
-
- return this.ToCieLchuv(luvColor);
- }
-
- ///
- /// Performs the bulk conversion from into .
- ///
- /// The span to the source colors
- /// The span to the destination colors
- public void Convert(ReadOnlySpan source, Span destination)
- {
- Guard.DestinationShouldNotBeTooShort(source, destination, nameof(destination));
- int count = source.Length;
-
- ref CieXyz sourceRef = ref MemoryMarshal.GetReference(source);
- ref CieLchuv destRef = ref MemoryMarshal.GetReference(destination);
-
- for (nuint i = 0; i < (uint)count; i++)
- {
- ref CieXyz sp = ref Unsafe.Add(ref sourceRef, i);
- ref CieLchuv dp = ref Unsafe.Add(ref destRef, i);
- dp = this.ToCieLchuv(sp);
- }
- }
-
- ///
- /// Converts a into a .
- ///
- /// The color to convert.
- /// The
- public CieLchuv ToCieLchuv(in Cmyk color)
- {
- CieXyz xyzColor = this.ToCieXyz(color);
-
- return this.ToCieLchuv(xyzColor);
- }
-
- ///
- /// Performs the bulk conversion from into .
- ///
- /// The span to the source colors
- /// The span to the destination colors
- public void Convert(ReadOnlySpan source, Span destination)
- {
- Guard.DestinationShouldNotBeTooShort(source, destination, nameof(destination));
- int count = source.Length;
-
- ref Cmyk sourceRef = ref MemoryMarshal.GetReference(source);
- ref CieLchuv destRef = ref MemoryMarshal.GetReference(destination);
-
- for (nuint i = 0; i < (uint)count; i++)
- {
- ref Cmyk sp = ref Unsafe.Add(ref sourceRef, i);
- ref CieLchuv dp = ref Unsafe.Add(ref destRef, i);
- dp = this.ToCieLchuv(sp);
- }
- }
-
- ///
- /// Converts a into a .
- ///
- /// The color to convert.
- /// The
- public CieLchuv ToCieLchuv(in Hsl color)
- {
- CieXyz xyzColor = this.ToCieXyz(color);
-
- return this.ToCieLchuv(xyzColor);
- }
-
- ///
- /// Performs the bulk conversion from into
- ///
- /// The span to the source colors
- /// The span to the destination colors
- public void Convert(ReadOnlySpan source, Span destination)
- {
- Guard.DestinationShouldNotBeTooShort(source, destination, nameof(destination));
- int count = source.Length;
-
- ref Hsl sourceRef = ref MemoryMarshal.GetReference(source);
- ref CieLchuv destRef = ref MemoryMarshal.GetReference(destination);
-
- for (nuint i = 0; i < (uint)count; i++)
- {
- ref Hsl sp = ref Unsafe.Add(ref sourceRef, i);
- ref CieLchuv dp = ref Unsafe.Add(ref destRef, i);
- dp = this.ToCieLchuv(sp);
- }
- }
-
- ///
- /// Converts a into a .
- ///
- /// The color to convert.
- /// The
- public CieLchuv ToCieLchuv(in Hsv color)
- {
- CieXyz xyzColor = this.ToCieXyz(color);
-
- return this.ToCieLchuv(xyzColor);
- }
-
- ///
- /// Performs the bulk conversion from into .
- ///
- /// The span to the source colors
- /// The span to the destination colors
- public void Convert(ReadOnlySpan source, Span destination)
- {
- Guard.DestinationShouldNotBeTooShort(source, destination, nameof(destination));
- int count = source.Length;
-
- ref Hsv sourceRef = ref MemoryMarshal.GetReference(source);
- ref CieLchuv destRef = ref MemoryMarshal.GetReference(destination);
-
- for (nuint i = 0; i < (uint)count; i++)
- {
- ref Hsv sp = ref Unsafe.Add(ref sourceRef, i);
- ref CieLchuv dp = ref Unsafe.Add(ref destRef, i);
- dp = this.ToCieLchuv(sp);
- }
- }
-
- ///
- /// Converts a into a .
- ///
- /// The color to convert.
- /// The
- public CieLchuv ToCieLchuv(in HunterLab color)
- {
- CieXyz xyzColor = this.ToCieXyz(color);
-
- return this.ToCieLchuv(xyzColor);
- }
-
- ///
- /// Performs the bulk conversion from into .
- ///
- /// The span to the source colors
- /// The span to the destination colors
- public void Convert(ReadOnlySpan source, Span destination)
- {
- Guard.DestinationShouldNotBeTooShort(source, destination, nameof(destination));
- int count = source.Length;
-
- ref HunterLab sourceRef = ref MemoryMarshal.GetReference(source);
- ref CieLchuv destRef = ref MemoryMarshal.GetReference(destination);
-
- for (nuint i = 0; i < (uint)count; i++)
- {
- ref HunterLab sp = ref Unsafe.Add(ref sourceRef, i);
- ref CieLchuv dp = ref Unsafe.Add(ref destRef, i);
- dp = this.ToCieLchuv(sp);
- }
- }
-
- ///
- /// Converts a into a .
- ///
- /// The color to convert.
- /// The
- public CieLchuv ToCieLchuv(in LinearRgb color)
- {
- CieXyz xyzColor = this.ToCieXyz(color);
-
- return this.ToCieLchuv(xyzColor);
- }
-
- ///
- /// Performs the bulk conversion from into .
- ///
- /// The span to the source colors
- /// The span to the destination colors
- public void Convert(ReadOnlySpan source, Span destination)
- {
- Guard.DestinationShouldNotBeTooShort(source, destination, nameof(destination));
- int count = source.Length;
-
- ref LinearRgb sourceRef = ref MemoryMarshal.GetReference(source);
- ref CieLchuv destRef = ref MemoryMarshal.GetReference(destination);
-
- for (nuint i = 0; i < (uint)count; i++)
- {
- ref LinearRgb sp = ref Unsafe.Add(ref sourceRef, i);
- ref CieLchuv dp = ref Unsafe.Add(ref destRef, i);
- dp = this.ToCieLchuv(sp);
- }
- }
-
- ///
- /// Converts a into a .
- ///
- /// The color to convert.
- /// The
- public CieLchuv ToCieLchuv(in Lms color)
- {
- CieXyz xyzColor = this.ToCieXyz(color);
-
- return this.ToCieLchuv(xyzColor);
- }
-
- ///
- /// Performs the bulk conversion from into .
- ///
- /// The span to the source colors
- /// The span to the destination colors
- public void Convert(ReadOnlySpan source, Span destination)
- {
- Guard.DestinationShouldNotBeTooShort(source, destination, nameof(destination));
- int count = source.Length;
-
- ref Lms sourceRef = ref MemoryMarshal.GetReference(source);
- ref CieLchuv destRef = ref MemoryMarshal.GetReference(destination);
-
- for (nuint i = 0; i < (uint)count; i++)
- {
- ref Lms sp = ref Unsafe.Add(ref sourceRef, i);
- ref CieLchuv dp = ref Unsafe.Add(ref destRef, i);
- dp = this.ToCieLchuv(sp);
- }
- }
-
- ///
- /// Converts a into a .
- ///
- /// The color to convert.
- /// The
- public CieLchuv ToCieLchuv(in Rgb color)
- {
- CieXyz xyzColor = this.ToCieXyz(color);
-
- return this.ToCieLchuv(xyzColor);
- }
-
- ///
- /// Performs the bulk conversion from into .
- ///
- /// The span to the source colors
- /// The span to the destination colors
- public void Convert(ReadOnlySpan source, Span destination)
- {
- Guard.DestinationShouldNotBeTooShort(source, destination, nameof(destination));
- int count = source.Length;
-
- ref Rgb sourceRef = ref MemoryMarshal.GetReference(source);
- ref CieLchuv destRef = ref MemoryMarshal.GetReference(destination);
-
- for (nuint i = 0; i < (uint)count; i++)
- {
- ref Rgb sp = ref Unsafe.Add(ref sourceRef, i);
- ref CieLchuv dp = ref Unsafe.Add(ref destRef, i);
- dp = this.ToCieLchuv(sp);
- }
- }
-
- ///
- /// Converts a into a .
- ///
- /// The color to convert.
- /// The
- public CieLchuv ToCieLchuv(in YCbCr color)
- {
- CieXyz xyzColor = this.ToCieXyz(color);
- return this.ToCieLchuv(xyzColor);
- }
-
- ///
- /// Performs the bulk conversion from into .
- ///
- /// The span to the source colors
- /// The span to the destination colors
- public void Convert(ReadOnlySpan source, Span destination)
- {
- Guard.DestinationShouldNotBeTooShort(source, destination, nameof(destination));
- int count = source.Length;
-
- ref YCbCr sourceRef = ref MemoryMarshal.GetReference(source);
- ref CieLchuv destRef = ref MemoryMarshal.GetReference(destination);
-
- for (nuint i = 0; i < (uint)count; i++)
- {
- ref YCbCr sp = ref Unsafe.Add(ref sourceRef, i);
- ref CieLchuv dp = ref Unsafe.Add(ref destRef, i);
- dp = this.ToCieLchuv(sp);
- }
- }
-}
diff --git a/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.CieLuv.cs b/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.CieLuv.cs
deleted file mode 100644
index 2e8029f64..000000000
--- a/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.CieLuv.cs
+++ /dev/null
@@ -1,435 +0,0 @@
-// Copyright (c) Six Labors.
-// Licensed under the Six Labors Split License.
-
-using System.Runtime.CompilerServices;
-using System.Runtime.InteropServices;
-
-namespace SixLabors.ImageSharp.ColorSpaces.Conversion;
-
-///
-/// Allows conversion to .
-///
-public partial class ColorSpaceConverter
-{
- ///
- /// Converts a into a .
- ///
- /// The color to convert.
- /// The
- public CieLuv ToCieLuv(in CieLab color)
- {
- CieXyz xyzColor = this.ToCieXyz(color);
- return this.ToCieLuv(xyzColor);
- }
-
- ///
- /// Performs the bulk conversion from into .
- ///
- /// The span to the source colors
- /// The span to the destination colors
- public void Convert(ReadOnlySpan source, Span destination)
- {
- Guard.DestinationShouldNotBeTooShort(source, destination, nameof(destination));
- int count = source.Length;
-
- ref CieLab sourceRef = ref MemoryMarshal.GetReference(source);
- ref CieLuv destRef = ref MemoryMarshal.GetReference(destination);
-
- for (nuint i = 0; i < (uint)count; i++)
- {
- ref CieLab sp = ref Unsafe.Add(ref sourceRef, i);
- ref CieLuv dp = ref Unsafe.Add(ref destRef, i);
- dp = this.ToCieLuv(sp);
- }
- }
-
- ///
- /// Converts a into a .
- ///
- /// The color to convert.
- /// The
- public CieLuv ToCieLuv(in CieLch color)
- {
- CieXyz xyzColor = this.ToCieXyz(color);
- return this.ToCieLuv(xyzColor);
- }
-
- ///
- /// Performs the bulk conversion from into .
- ///
- /// The span to the source colors
- /// The span to the destination colors
- public void Convert(ReadOnlySpan source, Span destination)
- {
- Guard.DestinationShouldNotBeTooShort(source, destination, nameof(destination));
- int count = source.Length;
-
- ref CieLch sourceRef = ref MemoryMarshal.GetReference(source);
- ref CieLuv destRef = ref MemoryMarshal.GetReference(destination);
-
- for (nuint i = 0; i < (uint)count; i++)
- {
- ref CieLch sp = ref Unsafe.Add(ref sourceRef, i);
- ref CieLuv dp = ref Unsafe.Add(ref destRef, i);
- dp = this.ToCieLuv(sp);
- }
- }
-
- ///
- /// Converts a into a .
- ///
- /// The color to convert.
- /// The
- public CieLuv ToCieLuv(in CieLchuv color)
- {
- // Conversion (preserving white point)
- CieLuv unadapted = CieLchuvToCieLuvConverter.Convert(color);
-
- // Adaptation
- return this.Adapt(unadapted);
- }
-
- ///
- /// Performs the bulk conversion from into .
- ///
- /// The span to the source colors
- /// The span to the destination colors
- public void Convert(ReadOnlySpan source, Span destination)
- {
- Guard.DestinationShouldNotBeTooShort(source, destination, nameof(destination));
- int count = source.Length;
-
- ref CieLchuv sourceRef = ref MemoryMarshal.GetReference(source);
- ref CieLuv destRef = ref MemoryMarshal.GetReference(destination);
-
- for (nuint i = 0; i < (uint)count; i++)
- {
- ref CieLchuv sp = ref Unsafe.Add(ref sourceRef, i);
- ref CieLuv dp = ref Unsafe.Add(ref destRef, i);
- dp = this.ToCieLuv(sp);
- }
- }
-
- ///
- /// Converts a into a .
- ///
- /// The color to convert.
- /// The
- public CieLuv ToCieLuv(in CieXyy color)
- {
- CieXyz xyzColor = ToCieXyz(color);
- return this.ToCieLuv(xyzColor);
- }
-
- ///
- /// Performs the bulk conversion from into .
- ///
- /// The span to the source colors
- /// The span to the destination colors
- public void Convert(ReadOnlySpan source, Span destination)
- {
- Guard.DestinationShouldNotBeTooShort(source, destination, nameof(destination));
- int count = source.Length;
-
- ref CieXyy sourceRef = ref MemoryMarshal.GetReference(source);
- ref CieLuv destRef = ref MemoryMarshal.GetReference(destination);
-
- for (nuint i = 0; i < (uint)count; i++)
- {
- ref CieXyy sp = ref Unsafe.Add(ref sourceRef, i);
- ref CieLuv dp = ref Unsafe.Add(ref destRef, i);
- dp = this.ToCieLuv(sp);
- }
- }
-
- ///
- /// Converts a into a .
- ///
- /// The color to convert.
- /// The
- public CieLuv ToCieLuv(in CieXyz color)
- {
- // Adaptation
- CieXyz adapted = this.Adapt(color, this.whitePoint, this.targetLuvWhitePoint);
-
- // Conversion
- return this.cieXyzToCieLuvConverter.Convert(adapted);
- }
-
- ///
- /// Performs the bulk conversion from into .
- ///
- /// The span to the source colors
- /// The span to the destination colors
- public void Convert(ReadOnlySpan source, Span destination)
- {
- Guard.DestinationShouldNotBeTooShort(source, destination, nameof(destination));
- int count = source.Length;
-
- ref CieXyz sourceRef = ref MemoryMarshal.GetReference(source);
- ref CieLuv destRef = ref MemoryMarshal.GetReference(destination);
-
- for (nuint i = 0; i < (uint)count; i++)
- {
- ref CieXyz sp = ref Unsafe.Add(ref sourceRef, i);
- ref CieLuv dp = ref Unsafe.Add(ref destRef, i);
- dp = this.ToCieLuv(sp);
- }
- }
-
- ///
- /// Converts a into a .
- ///
- /// The color to convert.
- /// The
- public CieLuv ToCieLuv(in Cmyk color)
- {
- CieXyz xyzColor = this.ToCieXyz(color);
- return this.ToCieLuv(xyzColor);
- }
-
- ///
- /// Performs the bulk conversion from into .
- ///
- /// The span to the source colors
- /// The span to the destination colors
- public void Convert(ReadOnlySpan source, Span destination)
- {
- Guard.DestinationShouldNotBeTooShort(source, destination, nameof(destination));
- int count = source.Length;
-
- ref Cmyk sourceRef = ref MemoryMarshal.GetReference(source);
- ref CieLuv destRef = ref MemoryMarshal.GetReference(destination);
-
- for (nuint i = 0; i < (uint)count; i++)
- {
- ref Cmyk sp = ref Unsafe.Add(ref sourceRef, i);
- ref CieLuv dp = ref Unsafe.Add(ref destRef, i);
- dp = this.ToCieLuv(sp);
- }
- }
-
- ///
- /// Converts a into a
- ///
- /// The color to convert.
- /// The
- public CieLuv ToCieLuv(in Hsl color)
- {
- CieXyz xyzColor = this.ToCieXyz(color);
- return this.ToCieLuv(xyzColor);
- }
-
- ///
- /// Performs the bulk conversion from into .
- ///
- /// The span to the source colors
- /// The span to the destination colors
- public void Convert(ReadOnlySpan source, Span destination)
- {
- Guard.DestinationShouldNotBeTooShort(source, destination, nameof(destination));
- int count = source.Length;
-
- ref Hsl sourceRef = ref MemoryMarshal.GetReference(source);
- ref CieLuv destRef = ref MemoryMarshal.GetReference(destination);
-
- for (nuint i = 0; i < (uint)count; i++)
- {
- ref Hsl sp = ref Unsafe.Add(ref sourceRef, i);
- ref CieLuv dp = ref Unsafe.Add(ref destRef, i);
- dp = this.ToCieLuv(sp);
- }
- }
-
- ///
- /// Converts a into a .
- ///
- /// The color to convert.
- /// The
- public CieLuv ToCieLuv(in Hsv color)
- {
- CieXyz xyzColor = this.ToCieXyz(color);
- return this.ToCieLuv(xyzColor);
- }
-
- ///
- /// Performs the bulk conversion from into .
- ///
- /// The span to the source colors
- /// The span to the destination colors
- public void Convert(ReadOnlySpan source, Span destination)
- {
- Guard.DestinationShouldNotBeTooShort(source, destination, nameof(destination));
- int count = source.Length;
-
- ref Hsv sourceRef = ref MemoryMarshal.GetReference(source);
- ref CieLuv destRef = ref MemoryMarshal.GetReference(destination);
-
- for (nuint i = 0; i < (uint)count; i++)
- {
- ref Hsv sp = ref Unsafe.Add(ref sourceRef, i);
- ref CieLuv dp = ref Unsafe.Add(ref destRef, i);
- dp = this.ToCieLuv(sp);
- }
- }
-
- ///
- /// Converts a into a .
- ///
- /// The color to convert.
- /// The
- public CieLuv ToCieLuv(in HunterLab color)
- {
- CieXyz xyzColor = this.ToCieXyz(color);
- return this.ToCieLuv(xyzColor);
- }
-
- ///
- /// Performs the bulk conversion from into .
- ///
- /// The span to the source colors
- /// The span to the destination colors
- public void Convert(ReadOnlySpan source, Span destination)
- {
- Guard.DestinationShouldNotBeTooShort(source, destination, nameof(destination));
- int count = source.Length;
-
- ref HunterLab sourceRef = ref MemoryMarshal.GetReference(source);
- ref CieLuv destRef = ref MemoryMarshal.GetReference(destination);
-
- for (nuint i = 0; i < (uint)count; i++)
- {
- ref HunterLab sp = ref Unsafe.Add(ref sourceRef, i);
- ref CieLuv dp = ref Unsafe.Add(ref destRef, i);
- dp = this.ToCieLuv(sp);
- }
- }
-
- ///
- /// Converts a into a .
- ///
- /// The color to convert.
- /// The
- public CieLuv ToCieLuv(in Lms color)
- {
- CieXyz xyzColor = this.ToCieXyz(color);
- return this.ToCieLuv(xyzColor);
- }
-
- ///
- /// Performs the bulk conversion from into .
- ///
- /// The span to the source colors
- /// The span to the destination colors
- public void Convert(ReadOnlySpan source, Span destination)
- {
- Guard.DestinationShouldNotBeTooShort(source, destination, nameof(destination));
- int count = source.Length;
-
- ref Lms sourceRef = ref MemoryMarshal.GetReference(source);
- ref CieLuv destRef = ref MemoryMarshal.GetReference(destination);
-
- for (nuint i = 0; i < (uint)count; i++)
- {
- ref Lms sp = ref Unsafe.Add(ref sourceRef, i);
- ref CieLuv dp = ref Unsafe.Add(ref destRef, i);
- dp = this.ToCieLuv(sp);
- }
- }
-
- ///
- /// Converts a into a .
- ///
- /// The color to convert.
- /// The
- public CieLuv ToCieLuv(in LinearRgb color)
- {
- CieXyz xyzColor = this.ToCieXyz(color);
- return this.ToCieLuv(xyzColor);
- }
-
- ///
- /// Performs the bulk conversion from into .
- ///
- /// The span to the source colors
- /// The span to the destination colors
- public void Convert(ReadOnlySpan source, Span destination)
- {
- Guard.DestinationShouldNotBeTooShort(source, destination, nameof(destination));
- int count = source.Length;
-
- ref LinearRgb sourceRef = ref MemoryMarshal.GetReference(source);
- ref CieLuv destRef = ref MemoryMarshal.GetReference(destination);
-
- for (nuint i = 0; i < (uint)count; i++)
- {
- ref LinearRgb sp = ref Unsafe.Add(ref sourceRef, i);
- ref CieLuv dp = ref Unsafe.Add(ref destRef, i);
- dp = this.ToCieLuv(sp);
- }
- }
-
- ///
- /// Converts a into a .
- ///
- /// The color to convert.
- /// The
- public CieLuv ToCieLuv(in Rgb color)
- {
- CieXyz xyzColor = this.ToCieXyz(color);
- return this.ToCieLuv(xyzColor);
- }
-
- ///
- /// Performs the bulk conversion from into .
- ///
- /// The span to the source colors
- /// The span to the destination colors
- public void Convert(ReadOnlySpan source, Span destination)
- {
- Guard.DestinationShouldNotBeTooShort(source, destination, nameof(destination));
- int count = source.Length;
-
- ref Rgb sourceRef = ref MemoryMarshal.GetReference(source);
- ref CieLuv destRef = ref MemoryMarshal.GetReference(destination);
-
- for (nuint i = 0; i < (uint)count; i++)
- {
- ref Rgb sp = ref Unsafe.Add(ref sourceRef, i);
- ref CieLuv dp = ref Unsafe.Add(ref destRef, i);
- dp = this.ToCieLuv(sp);
- }
- }
-
- ///
- /// Converts a into a .
- ///
- /// The color to convert.
- /// The
- public CieLuv ToCieLuv(in YCbCr color)
- {
- CieXyz xyzColor = this.ToCieXyz(color);
- return this.ToCieLuv(xyzColor);
- }
-
- ///
- /// Performs the bulk conversion from into .
- ///
- /// The span to the source colors.
- /// The span to the destination colors.
- public void Convert(ReadOnlySpan source, Span destination)
- {
- Guard.DestinationShouldNotBeTooShort(source, destination, nameof(destination));
- int count = source.Length;
-
- ref YCbCr sourceRef = ref MemoryMarshal.GetReference(source);
- ref CieLuv destRef = ref MemoryMarshal.GetReference(destination);
-
- for (nuint i = 0; i < (uint)count; i++)
- {
- ref YCbCr sp = ref Unsafe.Add(ref sourceRef, i);
- ref CieLuv dp = ref Unsafe.Add(ref destRef, i);
- dp = this.ToCieLuv(sp);
- }
- }
-}
diff --git a/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.CieXyy.cs b/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.CieXyy.cs
deleted file mode 100644
index 13b2a225c..000000000
--- a/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.CieXyy.cs
+++ /dev/null
@@ -1,437 +0,0 @@
-// Copyright (c) Six Labors.
-// Licensed under the Six Labors Split License.
-
-using System.Runtime.CompilerServices;
-using System.Runtime.InteropServices;
-
-namespace SixLabors.ImageSharp.ColorSpaces.Conversion;
-
-///
-/// Allows conversion to .
-///
-public partial class ColorSpaceConverter
-{
- ///
- /// Converts a into a
- ///
- /// The color to convert.
- /// The
- public CieXyy ToCieXyy(in CieLab color)
- {
- CieXyz xyzColor = this.ToCieXyz(color);
-
- return ToCieXyy(xyzColor);
- }
-
- ///
- /// Performs the bulk conversion from into
- ///
- /// The span to the source colors
- /// The span to the destination colors
- public void Convert(ReadOnlySpan source, Span destination)
- {
- Guard.DestinationShouldNotBeTooShort(source, destination, nameof(destination));
- int count = source.Length;
-
- ref CieLab sourceRef = ref MemoryMarshal.GetReference(source);
- ref CieXyy destRef = ref MemoryMarshal.GetReference(destination);
-
- for (nuint i = 0; i < (uint)count; i++)
- {
- ref CieLab sp = ref Unsafe.Add(ref sourceRef, i);
- ref CieXyy dp = ref Unsafe.Add(ref destRef, i);
- dp = this.ToCieXyy(sp);
- }
- }
-
- ///
- /// Converts a into a
- ///
- /// The color to convert.
- /// The
- public CieXyy ToCieXyy(in CieLch color)
- {
- CieXyz xyzColor = this.ToCieXyz(color);
-
- return ToCieXyy(xyzColor);
- }
-
- ///
- /// Performs the bulk conversion from into
- ///
- /// The span to the source colors
- /// The span to the destination colors
- public void Convert(ReadOnlySpan source, Span destination)
- {
- Guard.DestinationShouldNotBeTooShort(source, destination, nameof(destination));
- int count = source.Length;
-
- ref CieLch sourceRef = ref MemoryMarshal.GetReference(source);
- ref CieXyy destRef = ref MemoryMarshal.GetReference(destination);
-
- for (nuint i = 0; i < (uint)count; i++)
- {
- ref CieLch sp = ref Unsafe.Add(ref sourceRef, i);
- ref CieXyy dp = ref Unsafe.Add(ref destRef, i);
- dp = this.ToCieXyy(sp);
- }
- }
-
- ///
- /// Converts a into a
- ///
- /// The color to convert.
- /// The
- public CieXyy ToCieXyy(in CieLchuv color)
- {
- CieXyz xyzColor = this.ToCieXyz(color);
-
- return ToCieXyy(xyzColor);
- }
-
- ///
- /// Performs the bulk conversion from into
- ///
- /// The span to the source colors
- /// The span to the destination colors
- public void Convert(ReadOnlySpan source, Span destination)
- {
- Guard.DestinationShouldNotBeTooShort(source, destination, nameof(destination));
- int count = source.Length;
-
- ref CieLchuv sourceRef = ref MemoryMarshal.GetReference(source);
- ref CieXyy destRef = ref MemoryMarshal.GetReference(destination);
-
- for (nuint i = 0; i < (uint)count; i++)
- {
- ref CieLchuv sp = ref Unsafe.Add(ref sourceRef, i);
- ref CieXyy dp = ref Unsafe.Add(ref destRef, i);
- dp = this.ToCieXyy(sp);
- }
- }
-
- ///
- /// Converts a into a
- ///
- /// The color to convert.
- /// The
- public CieXyy ToCieXyy(in CieLuv color)
- {
- CieXyz xyzColor = this.ToCieXyz(color);
-
- return ToCieXyy(xyzColor);
- }
-
- ///
- /// Performs the bulk conversion from into
- ///
- /// The span to the source colors
- /// The span to the destination colors
- public void Convert(ReadOnlySpan source, Span destination)
- {
- Guard.DestinationShouldNotBeTooShort(source, destination, nameof(destination));
- int count = source.Length;
-
- ref CieLuv sourceRef = ref MemoryMarshal.GetReference(source);
- ref CieXyy destRef = ref MemoryMarshal.GetReference(destination);
-
- for (nuint i = 0; i < (uint)count; i++)
- {
- ref CieLuv sp = ref Unsafe.Add(ref sourceRef, i);
- ref CieXyy dp = ref Unsafe.Add(ref destRef, i);
- dp = this.ToCieXyy(sp);
- }
- }
-
- ///
- /// Converts a into a
- ///
- /// The color to convert.
- /// The
- public static CieXyy ToCieXyy(in CieXyz color) => CieXyzAndCieXyyConverter.Convert(color);
-
- ///
- /// Performs the bulk conversion from into
- ///
- /// The span to the source colors
- /// The span to the destination colors
- public static void Convert(ReadOnlySpan source, Span destination)
- {
- Guard.DestinationShouldNotBeTooShort(source, destination, nameof(destination));
- int count = source.Length;
-
- ref CieXyz sourceRef = ref MemoryMarshal.GetReference(source);
- ref CieXyy destRef = ref MemoryMarshal.GetReference(destination);
-
- for (nuint i = 0; i < (uint)count; i++)
- {
- ref CieXyz sp = ref Unsafe.Add(ref sourceRef, i);
- ref CieXyy dp = ref Unsafe.Add(ref destRef, i);
- dp = ToCieXyy(sp);
- }
- }
-
- ///
- /// Converts a into a
- ///
- /// The color to convert.
- /// The
- public CieXyy ToCieXyy(in Cmyk color)
- {
- CieXyz xyzColor = this.ToCieXyz(color);
-
- return ToCieXyy(xyzColor);
- }
-
- ///
- /// Performs the bulk conversion from into
- ///
- /// The span to the source colors
- /// The span to the destination colors
- public void Convert(ReadOnlySpan source, Span destination)
- {
- Guard.DestinationShouldNotBeTooShort(source, destination, nameof(destination));
- int count = source.Length;
-
- ref Cmyk sourceRef = ref MemoryMarshal.GetReference(source);
- ref CieXyy destRef = ref MemoryMarshal.GetReference(destination);
-
- for (nuint i = 0; i < (uint)count; i++)
- {
- ref Cmyk sp = ref Unsafe.Add(ref sourceRef, i);
- ref CieXyy dp = ref Unsafe.Add(ref destRef, i);
- dp = this.ToCieXyy(sp);
- }
- }
-
- ///
- /// Converts a into a
- ///
- /// The color to convert.
- /// The
- public CieXyy ToCieXyy(Hsl color)
- {
- CieXyz xyzColor = this.ToCieXyz(color);
-
- return ToCieXyy(xyzColor);
- }
-
- ///
- /// Performs the bulk conversion from into
- ///
- /// The span to the source colors
- /// The span to the destination colors
- public void Convert(ReadOnlySpan source, Span destination)
- {
- Guard.DestinationShouldNotBeTooShort(source, destination, nameof(destination));
- int count = source.Length;
-
- ref Hsl sourceRef = ref MemoryMarshal.GetReference(source);
- ref CieXyy destRef = ref MemoryMarshal.GetReference(destination);
-
- for (nuint i = 0; i < (uint)count; i++)
- {
- ref Hsl sp = ref Unsafe.Add(ref sourceRef, i);
- ref CieXyy dp = ref Unsafe.Add(ref destRef, i);
- dp = this.ToCieXyy(sp);
- }
- }
-
- ///
- /// Converts a into a
- ///
- /// The color to convert.
- /// The
- public CieXyy ToCieXyy(in Hsv color)
- {
- CieXyz xyzColor = this.ToCieXyz(color);
-
- return ToCieXyy(xyzColor);
- }
-
- ///
- /// Performs the bulk conversion from into
- ///
- /// The span to the source colors
- /// The span to the destination colors
- public void Convert(ReadOnlySpan source, Span destination)
- {
- Guard.DestinationShouldNotBeTooShort(source, destination, nameof(destination));
- int count = source.Length;
-
- ref Hsv sourceRef = ref MemoryMarshal.GetReference(source);
- ref CieXyy destRef = ref MemoryMarshal.GetReference(destination);
-
- for (nuint i = 0; i < (uint)count; i++)
- {
- ref Hsv sp = ref Unsafe.Add(ref sourceRef, i);
- ref CieXyy dp = ref Unsafe.Add(ref destRef, i);
- dp = this.ToCieXyy(sp);
- }
- }
-
- ///
- /// Converts a into a
- ///
- /// The color to convert.
- /// The
- public CieXyy ToCieXyy(in HunterLab color)
- {
- CieXyz xyzColor = this.ToCieXyz(color);
-
- return ToCieXyy(xyzColor);
- }
-
- ///
- /// Performs the bulk conversion from into
- ///
- /// The span to the source colors
- /// The span to the destination colors
- public void Convert(ReadOnlySpan source, Span destination)
- {
- Guard.DestinationShouldNotBeTooShort(source, destination, nameof(destination));
- int count = source.Length;
-
- ref HunterLab sourceRef = ref MemoryMarshal.GetReference(source);
- ref CieXyy destRef = ref MemoryMarshal.GetReference(destination);
-
- for (nuint i = 0; i < (uint)count; i++)
- {
- ref HunterLab sp = ref Unsafe.Add(ref sourceRef, i);
- ref CieXyy dp = ref Unsafe.Add(ref destRef, i);
- dp = this.ToCieXyy(sp);
- }
- }
-
- ///
- /// Converts a into a
- ///
- /// The color to convert.
- /// The
- public CieXyy ToCieXyy(in LinearRgb color)
- {
- CieXyz xyzColor = this.ToCieXyz(color);
-
- return ToCieXyy(xyzColor);
- }
-
- ///
- /// Performs the bulk conversion from into
- ///
- /// The span to the source colors
- /// The span to the destination colors
- public void Convert(ReadOnlySpan source, Span destination)
- {
- Guard.DestinationShouldNotBeTooShort(source, destination, nameof(destination));
- int count = source.Length;
-
- ref LinearRgb sourceRef = ref MemoryMarshal.GetReference(source);
- ref CieXyy destRef = ref MemoryMarshal.GetReference(destination);
-
- for (nuint i = 0; i < (uint)count; i++)
- {
- ref LinearRgb sp = ref Unsafe.Add(ref sourceRef, i);
- ref CieXyy dp = ref Unsafe.Add(ref destRef, i);
- dp = this.ToCieXyy(sp);
- }
- }
-
- ///
- /// Converts a into a
- ///
- /// The color to convert.
- /// The
- public CieXyy ToCieXyy(in Lms color)
- {
- CieXyz xyzColor = this.ToCieXyz(color);
-
- return ToCieXyy(xyzColor);
- }
-
- ///
- /// Performs the bulk conversion from into
- ///
- /// The span to the source colors
- /// The span to the destination colors
- public void Convert(ReadOnlySpan source, Span destination)
- {
- Guard.DestinationShouldNotBeTooShort(source, destination, nameof(destination));
- int count = source.Length;
-
- ref Lms sourceRef = ref MemoryMarshal.GetReference(source);
- ref CieXyy destRef = ref MemoryMarshal.GetReference(destination);
-
- for (nuint i = 0; i < (uint)count; i++)
- {
- ref Lms sp = ref Unsafe.Add(ref sourceRef, i);
- ref CieXyy dp = ref Unsafe.Add(ref destRef, i);
- dp = this.ToCieXyy(sp);
- }
- }
-
- ///
- /// Converts a into a
- ///
- /// The color to convert.
- /// The
- public CieXyy ToCieXyy(in Rgb color)
- {
- CieXyz xyzColor = this.ToCieXyz(color);
-
- return ToCieXyy(xyzColor);
- }
-
- ///
- /// Performs the bulk conversion from into
- ///
- /// The span to the source colors
- /// The span to the destination colors
- public void Convert(ReadOnlySpan source, Span destination)
- {
- Guard.DestinationShouldNotBeTooShort(source, destination, nameof(destination));
- int count = source.Length;
-
- ref Rgb sourceRef = ref MemoryMarshal.GetReference(source);
- ref CieXyy destRef = ref MemoryMarshal.GetReference(destination);
-
- for (nuint i = 0; i < (uint)count; i++)
- {
- ref Rgb sp = ref Unsafe.Add(ref sourceRef, i);
- ref CieXyy dp = ref Unsafe.Add(ref destRef, i);
- dp = this.ToCieXyy(sp);
- }
- }
-
- ///
- /// Converts a into a
- ///
- /// The color to convert.
- /// The
- public CieXyy ToCieXyy(in YCbCr color)
- {
- CieXyz xyzColor = this.ToCieXyz(color);
-
- return ToCieXyy(xyzColor);
- }
-
- ///
- /// Performs the bulk conversion from into
- ///
- /// The span to the source colors
- /// The span to the destination colors
- public void Convert(ReadOnlySpan source, Span destination)
- {
- Guard.DestinationShouldNotBeTooShort(source, destination, nameof(destination));
- int count = source.Length;
-
- ref YCbCr sourceRef = ref MemoryMarshal.GetReference(source);
- ref CieXyy destRef = ref MemoryMarshal.GetReference(destination);
-
- for (nuint i = 0; i < (uint)count; i++)
- {
- ref YCbCr sp = ref Unsafe.Add(ref sourceRef, i);
- ref CieXyy dp = ref Unsafe.Add(ref destRef, i);
- dp = this.ToCieXyy(sp);
- }
- }
-}
diff --git a/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.CieXyz.cs b/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.CieXyz.cs
deleted file mode 100644
index 2212ca2e5..000000000
--- a/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.CieXyz.cs
+++ /dev/null
@@ -1,458 +0,0 @@
-// Copyright (c) Six Labors.
-// Licensed under the Six Labors Split License.
-
-using System.Collections.Concurrent;
-using System.Runtime.CompilerServices;
-using System.Runtime.InteropServices;
-
-namespace SixLabors.ImageSharp.ColorSpaces.Conversion;
-
-///
-/// Allows conversion to .
-///
-public partial class ColorSpaceConverter
-{
- private static readonly ConcurrentDictionary ConverterCache = new();
-
- ///
- /// Converts a into a .
- ///
- /// The color to convert.
- /// The
- public CieXyz ToCieXyz(in CieLab color)
- {
- // Conversion
- CieXyz unadapted = CieLabToCieXyzConverter.Convert(color);
-
- // Adaptation
- return this.Adapt(unadapted, color.WhitePoint);
- }
-
- ///
- /// Performs the bulk conversion from into .
- ///
- /// The span to the source colors
- /// The span to the destination colors
- public void Convert(ReadOnlySpan source, Span destination)
- {
- Guard.DestinationShouldNotBeTooShort(source, destination, nameof(destination));
- int count = source.Length;
-
- ref CieLab sourceRef = ref MemoryMarshal.GetReference(source);
- ref CieXyz destRef = ref MemoryMarshal.GetReference(destination);
-
- for (nuint i = 0; i < (uint)count; i++)
- {
- ref CieLab sp = ref Unsafe.Add(ref sourceRef, i);
- ref CieXyz dp = ref Unsafe.Add(ref destRef, i);
- dp = this.ToCieXyz(sp);
- }
- }
-
- ///
- /// Converts a into a .
- ///
- /// The color to convert.
- /// The
- public CieXyz ToCieXyz(in CieLch color)
- {
- // Conversion to Lab
- CieLab labColor = CieLchToCieLabConverter.Convert(color);
-
- // Conversion to XYZ (incl. adaptation)
- return this.ToCieXyz(labColor);
- }
-
- ///
- /// Performs the bulk conversion from into .
- ///
- /// The span to the source colors
- /// The span to the destination colors
- public void Convert(ReadOnlySpan source, Span destination)
- {
- Guard.DestinationShouldNotBeTooShort(source, destination, nameof(destination));
- int count = source.Length;
-
- ref CieLch sourceRef = ref MemoryMarshal.GetReference(source);
- ref CieXyz destRef = ref MemoryMarshal.GetReference(destination);
-
- for (nuint i = 0; i < (uint)count; i++)
- {
- ref CieLch sp = ref Unsafe.Add(ref sourceRef, i);
- ref CieXyz dp = ref Unsafe.Add(ref destRef, i);
- dp = this.ToCieXyz(sp);
- }
- }
-
- ///
- /// Converts a into a .
- ///
- /// The color to convert.
- /// The
- public CieXyz ToCieXyz(in CieLchuv color)
- {
- // Conversion to Luv
- CieLuv luvColor = CieLchuvToCieLuvConverter.Convert(color);
-
- // Conversion to XYZ (incl. adaptation)
- return this.ToCieXyz(luvColor);
- }
-
- ///
- /// Performs the bulk conversion from into .
- ///
- /// The span to the source colors
- /// The span to the destination colors
- public void Convert(ReadOnlySpan source, Span destination)
- {
- Guard.DestinationShouldNotBeTooShort(source, destination, nameof(destination));
- int count = source.Length;
-
- ref CieLchuv sourceRef = ref MemoryMarshal.GetReference(source);
- ref CieXyz destRef = ref MemoryMarshal.GetReference(destination);
-
- for (nuint i = 0; i < (uint)count; i++)
- {
- ref CieLchuv sp = ref Unsafe.Add(ref sourceRef, i);
- ref CieXyz dp = ref Unsafe.Add(ref destRef, i);
- dp = this.ToCieXyz(sp);
- }
- }
-
- ///
- /// Converts a into a
- ///
- /// The color to convert.
- /// The
- public CieXyz ToCieXyz(in CieLuv color)
- {
- // Conversion
- CieXyz unadapted = CieLuvToCieXyzConverter.Convert(color);
-
- // Adaptation
- return this.Adapt(unadapted, color.WhitePoint);
- }
-
- ///
- /// Performs the bulk conversion from into .
- ///
- /// The span to the source colors
- /// The span to the destination colors
- public void Convert(ReadOnlySpan source, Span destination)
- {
- Guard.DestinationShouldNotBeTooShort(source, destination, nameof(destination));
- int count = source.Length;
-
- ref CieLuv sourceRef = ref MemoryMarshal.GetReference(source);
- ref CieXyz destRef = ref MemoryMarshal.GetReference(destination);
-
- for (nuint i = 0; i < (uint)count; i++)
- {
- ref CieLuv sp = ref Unsafe.Add(ref sourceRef, i);
- ref CieXyz dp = ref Unsafe.Add(ref destRef, i);
- dp = this.ToCieXyz(sp);
- }
- }
-
- ///
- /// Converts a into a .
- ///
- /// The color to convert.
- /// The
- public static CieXyz ToCieXyz(in CieXyy color)
-
- // Conversion
- => CieXyzAndCieXyyConverter.Convert(color);
-
- ///
- /// Performs the bulk conversion from into .
- ///
- /// The span to the source colors
- /// The span to the destination colors
- public static void Convert(ReadOnlySpan source, Span destination)
- {
- Guard.DestinationShouldNotBeTooShort(source, destination, nameof(destination));
- int count = source.Length;
-
- ref CieXyy sourceRef = ref MemoryMarshal.GetReference(source);
- ref CieXyz destRef = ref MemoryMarshal.GetReference(destination);
-
- for (nuint i = 0; i < (uint)count; i++)
- {
- ref CieXyy sp = ref Unsafe.Add(ref sourceRef, i);
- ref CieXyz dp = ref Unsafe.Add(ref destRef, i);
- dp = ToCieXyz(sp);
- }
- }
-
- ///
- /// Converts a into a .
- ///
- /// The color to convert.
- /// The
- public CieXyz ToCieXyz(in Cmyk color)
- {
- Rgb rgb = ToRgb(color);
-
- return this.ToCieXyz(rgb);
- }
-
- ///
- /// Performs the bulk conversion from into .
- ///
- /// The span to the source colors
- /// The span to the destination colors
- public void Convert(ReadOnlySpan source, Span destination)
- {
- Guard.DestinationShouldNotBeTooShort(source, destination, nameof(destination));
- int count = source.Length;
-
- ref Cmyk sourceRef = ref MemoryMarshal.GetReference(source);
- ref CieXyz destRef = ref MemoryMarshal.GetReference(destination);
-
- for (nuint i = 0; i < (uint)count; i++)
- {
- ref Cmyk sp = ref Unsafe.Add(ref sourceRef, i);
- ref CieXyz dp = ref Unsafe.Add(ref destRef, i);
- dp = this.ToCieXyz(sp);
- }
- }
-
- ///
- /// Converts a into a .
- ///
- /// The color to convert.
- /// The
- public CieXyz ToCieXyz(in Hsl color)
- {
- Rgb rgb = ToRgb(color);
-
- return this.ToCieXyz(rgb);
- }
-
- ///
- /// Performs the bulk conversion from into .
- ///
- /// The span to the source colors.
- /// The span to the destination colors.
- public void Convert(ReadOnlySpan source, Span destination)
- {
- Guard.DestinationShouldNotBeTooShort(source, destination, nameof(destination));
- int count = source.Length;
-
- ref Hsl sourceRef = ref MemoryMarshal.GetReference(source);
- ref CieXyz destRef = ref MemoryMarshal.GetReference(destination);
-
- for (nuint i = 0; i < (uint)count; i++)
- {
- ref Hsl sp = ref Unsafe.Add(ref sourceRef, i);
- ref CieXyz dp = ref Unsafe.Add(ref destRef, i);
- dp = this.ToCieXyz(sp);
- }
- }
-
- ///
- /// Converts a into a .
- ///
- /// The color to convert.
- /// The
- public CieXyz ToCieXyz(in Hsv color)
- {
- // Conversion
- Rgb rgb = ToRgb(color);
-
- return this.ToCieXyz(rgb);
- }
-
- ///
- /// Performs the bulk conversion from into .
- ///
- /// The span to the source colors
- /// The span to the destination colors
- public void Convert(ReadOnlySpan source, Span destination)
- {
- Guard.DestinationShouldNotBeTooShort(source, destination, nameof(destination));
- int count = source.Length;
-
- ref Hsv sourceRef = ref MemoryMarshal.GetReference(source);
- ref CieXyz destRef = ref MemoryMarshal.GetReference(destination);
-
- for (nuint i = 0; i < (uint)count; i++)
- {
- ref Hsv sp = ref Unsafe.Add(ref sourceRef, i);
- ref CieXyz dp = ref Unsafe.Add(ref destRef, i);
- dp = this.ToCieXyz(sp);
- }
- }
-
- ///
- /// Converts a into a .
- ///
- /// The color to convert.
- /// The
- public CieXyz ToCieXyz(in HunterLab color)
- {
- CieXyz unadapted = HunterLabToCieXyzConverter.Convert(color);
-
- return this.Adapt(unadapted, color.WhitePoint);
- }
-
- ///
- /// Performs the bulk conversion from into .
- ///
- /// The span to the source colors
- /// The span to the destination colors
- public void Convert(ReadOnlySpan source, Span destination)
- {
- Guard.DestinationShouldNotBeTooShort(source, destination, nameof(destination));
- int count = source.Length;
-
- ref HunterLab sourceRef = ref MemoryMarshal.GetReference(source);
- ref CieXyz destRef = ref MemoryMarshal.GetReference(destination);
-
- for (nuint i = 0; i < (uint)count; i++)
- {
- ref HunterLab sp = ref Unsafe.Add(ref sourceRef, i);
- ref CieXyz dp = ref Unsafe.Add(ref destRef, i);
- dp = this.ToCieXyz(sp);
- }
- }
-
- ///
- /// Converts a into a .
- ///
- /// The color to convert.
- /// The
- public CieXyz ToCieXyz(in LinearRgb color)
- {
- // Conversion
- LinearRgbToCieXyzConverter converter = GetLinearRgbToCieXyzConverter(color.WorkingSpace);
- CieXyz unadapted = converter.Convert(color);
-
- return this.Adapt(unadapted, color.WorkingSpace.WhitePoint);
- }
-
- ///
- /// Performs the bulk conversion from into .
- ///
- /// The span to the source colors.
- /// The span to the destination colors.
- public void Convert(ReadOnlySpan source, Span destination)
- {
- Guard.DestinationShouldNotBeTooShort(source, destination, nameof(destination));
- int count = source.Length;
-
- ref LinearRgb sourceRef = ref MemoryMarshal.GetReference(source);
- ref CieXyz destRef = ref MemoryMarshal.GetReference(destination);
-
- for (nuint i = 0; i < (uint)count; i++)
- {
- ref LinearRgb sp = ref Unsafe.Add(ref sourceRef, i);
- ref CieXyz dp = ref Unsafe.Add(ref destRef, i);
- dp = this.ToCieXyz(sp);
- }
- }
-
- ///
- /// Converts a into a .
- ///
- /// The color to convert.
- /// The
- public CieXyz ToCieXyz(in Lms color)
- => this.cieXyzAndLmsConverter.Convert(color);
-
- ///
- /// Performs the bulk conversion from into .
- ///
- /// The span to the source colors
- /// The span to the destination colors
- public void Convert(ReadOnlySpan source, Span destination)
- {
- Guard.DestinationShouldNotBeTooShort(source, destination, nameof(destination));
- int count = source.Length;
-
- ref Lms sourceRef = ref MemoryMarshal.GetReference(source);
- ref CieXyz destRef = ref MemoryMarshal.GetReference(destination);
-
- for (nuint i = 0; i < (uint)count; i++)
- {
- ref Lms sp = ref Unsafe.Add(ref sourceRef, i);
- ref CieXyz dp = ref Unsafe.Add(ref destRef, i);
- dp = this.ToCieXyz(sp);
- }
- }
-
- ///
- /// Converts a into a
- ///
- /// The color to convert.
- /// The
- public CieXyz ToCieXyz(in Rgb color)
- {
- // Conversion
- LinearRgb linear = RgbToLinearRgbConverter.Convert(color);
- return this.ToCieXyz(linear);
- }
-
- ///
- /// Performs the bulk conversion from into
- ///
- /// The span to the source colors
- /// The span to the destination colors
- public void Convert(ReadOnlySpan source, Span destination)
- {
- Guard.DestinationShouldNotBeTooShort(source, destination, nameof(destination));
- int count = source.Length;
-
- ref Rgb sourceRef = ref MemoryMarshal.GetReference(source);
- ref CieXyz destRef = ref MemoryMarshal.GetReference(destination);
-
- for (nuint i = 0; i < (uint)count; i++)
- {
- ref Rgb sp = ref Unsafe.Add(ref sourceRef, i);
- ref CieXyz dp = ref Unsafe.Add(ref destRef, i);
- dp = this.ToCieXyz(sp);
- }
- }
-
- ///
- /// Converts a into a
- ///
- /// The color to convert.
- /// The
- public CieXyz ToCieXyz(in YCbCr color)
- {
- Rgb rgb = this.ToRgb(color);
-
- return this.ToCieXyz(rgb);
- }
-
- ///
- /// Performs the bulk conversion from into
- ///
- /// The span to the source colors
- /// The span to the destination colors
- public void Convert(ReadOnlySpan source, Span destination)
- {
- Guard.DestinationShouldNotBeTooShort(source, destination, nameof(destination));
- int count = source.Length;
-
- ref YCbCr sourceRef = ref MemoryMarshal.GetReference(source);
- ref CieXyz destRef = ref MemoryMarshal.GetReference(destination);
-
- for (nuint i = 0; i < (uint)count; i++)
- {
- ref YCbCr sp = ref Unsafe.Add(ref sourceRef, i);
- ref CieXyz dp = ref Unsafe.Add(ref destRef, i);
- dp = this.ToCieXyz(sp);
- }
- }
-
- ///
- /// Gets the correct converter for the given rgb working space.
- ///
- /// The source working space
- /// The
- private static LinearRgbToCieXyzConverter GetLinearRgbToCieXyzConverter(RgbWorkingSpace workingSpace)
- => ConverterCache.GetOrAdd(workingSpace, (key) => new LinearRgbToCieXyzConverter(key));
-}
diff --git a/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.Cmyk.cs b/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.Cmyk.cs
deleted file mode 100644
index ea9a5d734..000000000
--- a/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.Cmyk.cs
+++ /dev/null
@@ -1,437 +0,0 @@
-// Copyright (c) Six Labors.
-// Licensed under the Six Labors Split License.
-
-using System.Runtime.CompilerServices;
-using System.Runtime.InteropServices;
-
-namespace SixLabors.ImageSharp.ColorSpaces.Conversion;
-
-///
-/// Allows conversion to .
-///
-public partial class ColorSpaceConverter
-{
- ///
- /// Converts a into a .
- ///
- /// The color to convert.
- /// The
- public Cmyk ToCmyk(in CieLab color)
- {
- CieXyz xyzColor = this.ToCieXyz(color);
-
- return this.ToCmyk(xyzColor);
- }
-
- ///
- /// Performs the bulk conversion from into .
- ///
- /// The span to the source colors
- /// The span to the destination colors
- public void Convert(ReadOnlySpan source, Span destination)
- {
- Guard.DestinationShouldNotBeTooShort(source, destination, nameof(destination));
- int count = source.Length;
-
- ref CieLab sourceRef = ref MemoryMarshal.GetReference(source);
- ref Cmyk destRef = ref MemoryMarshal.GetReference(destination);
-
- for (nuint i = 0; i < (uint)count; i++)
- {
- ref CieLab sp = ref Unsafe.Add(ref sourceRef, i);
- ref Cmyk dp = ref Unsafe.Add(ref destRef, i);
- dp = this.ToCmyk(sp);
- }
- }
-
- ///
- /// Converts a into a .
- ///
- /// The color to convert.
- /// The
- public Cmyk ToCmyk(in CieLch color)
- {
- CieXyz xyzColor = this.ToCieXyz(color);
-
- return this.ToCmyk(xyzColor);
- }
-
- ///
- /// Performs the bulk conversion from into .
- ///
- /// The span to the source colors
- /// The span to the destination colors
- public void Convert(ReadOnlySpan source, Span destination)
- {
- Guard.DestinationShouldNotBeTooShort(source, destination, nameof(destination));
- int count = source.Length;
-
- ref CieLch sourceRef = ref MemoryMarshal.GetReference(source);
- ref Cmyk destRef = ref MemoryMarshal.GetReference(destination);
-
- for (nuint i = 0; i < (uint)count; i++)
- {
- ref CieLch sp = ref Unsafe.Add(ref sourceRef, i);
- ref Cmyk dp = ref Unsafe.Add(ref destRef, i);
- dp = this.ToCmyk(sp);
- }
- }
-
- ///
- /// Converts a into a
- ///
- /// The color to convert.
- /// The
- public Cmyk ToCmyk(in CieLchuv color)
- {
- CieXyz xyzColor = this.ToCieXyz(color);
-
- return this.ToCmyk(xyzColor);
- }
-
- ///
- /// Performs the bulk conversion from into
- ///
- /// The span to the source colors
- /// The span to the destination colors
- public void Convert(ReadOnlySpan source, Span destination)
- {
- Guard.DestinationShouldNotBeTooShort(source, destination, nameof(destination));
- int count = source.Length;
-
- ref CieLchuv sourceRef = ref MemoryMarshal.GetReference(source);
- ref Cmyk destRef = ref MemoryMarshal.GetReference(destination);
-
- for (nuint i = 0; i < (uint)count; i++)
- {
- ref CieLchuv sp = ref Unsafe.Add(ref sourceRef, i);
- ref Cmyk dp = ref Unsafe.Add(ref destRef, i);
- dp = this.ToCmyk(sp);
- }
- }
-
- ///
- /// Converts a into a
- ///
- /// The color to convert.
- /// The
- public Cmyk ToCmyk(in CieLuv color)
- {
- CieXyz xyzColor = this.ToCieXyz(color);
-
- return this.ToCmyk(xyzColor);
- }
-
- ///
- /// Performs the bulk conversion from into
- ///
- /// The span to the source colors
- /// The span to the destination colors
- public void Convert(ReadOnlySpan source, Span destination)
- {
- Guard.DestinationShouldNotBeTooShort(source, destination, nameof(destination));
- int count = source.Length;
-
- ref CieLuv sourceRef = ref MemoryMarshal.GetReference(source);
- ref Cmyk destRef = ref MemoryMarshal.GetReference(destination);
-
- for (nuint i = 0; i < (uint)count; i++)
- {
- ref CieLuv sp = ref Unsafe.Add(ref sourceRef, i);
- ref Cmyk dp = ref Unsafe.Add(ref destRef, i);
- dp = this.ToCmyk(sp);
- }
- }
-
- ///
- /// Converts a into a .
- ///
- /// The color to convert.
- /// The
- public Cmyk ToCmyk(in CieXyy color)
- {
- CieXyz xyzColor = ToCieXyz(color);
-
- return this.ToCmyk(xyzColor);
- }
-
- ///
- /// Performs the bulk conversion from into .
- ///
- /// The span to the source colors
- /// The span to the destination colors
- public void Convert(ReadOnlySpan source, Span destination)
- {
- Guard.DestinationShouldNotBeTooShort(source, destination, nameof(destination));
- int count = source.Length;
-
- ref CieXyy sourceRef = ref MemoryMarshal.GetReference(source);
- ref Cmyk destRef = ref MemoryMarshal.GetReference(destination);
-
- for (nuint i = 0; i < (uint)count; i++)
- {
- ref CieXyy sp = ref Unsafe.Add(ref sourceRef, i);
- ref Cmyk dp = ref Unsafe.Add(ref destRef, i);
- dp = this.ToCmyk(sp);
- }
- }
-
- ///
- /// Converts a into a .
- ///
- /// The color to convert.
- /// The
- public Cmyk ToCmyk(in CieXyz color)
- {
- Rgb rgb = this.ToRgb(color);
-
- return CmykAndRgbConverter.Convert(rgb);
- }
-
- ///
- /// Performs the bulk conversion from into
- ///
- /// The span to the source colors
- /// The span to the destination colors
- public void Convert(ReadOnlySpan source, Span destination)
- {
- Guard.DestinationShouldNotBeTooShort(source, destination, nameof(destination));
- int count = source.Length;
-
- ref CieXyz sourceRef = ref MemoryMarshal.GetReference(source);
- ref Cmyk destRef = ref MemoryMarshal.GetReference(destination);
-
- for (nuint i = 0; i < (uint)count; i++)
- {
- ref CieXyz sp = ref Unsafe.Add(ref sourceRef, i);
- ref Cmyk dp = ref Unsafe.Add(ref destRef, i);
- dp = this.ToCmyk(sp);
- }
- }
-
- ///
- /// Converts a into a .
- ///
- /// The color to convert.
- /// The
- public static Cmyk ToCmyk(in Hsl color)
- {
- Rgb rgb = ToRgb(color);
-
- return CmykAndRgbConverter.Convert(rgb);
- }
-
- ///
- /// Performs the bulk conversion from into .
- ///
- /// The span to the source colors
- /// The span to the destination colors
- public static void Convert(ReadOnlySpan source, Span destination)
- {
- Guard.DestinationShouldNotBeTooShort(source, destination, nameof(destination));
- int count = source.Length;
-
- ref Hsl sourceRef = ref MemoryMarshal.GetReference(source);
- ref Cmyk destRef = ref MemoryMarshal.GetReference(destination);
-
- for (nuint i = 0; i < (uint)count; i++)
- {
- ref Hsl sp = ref Unsafe.Add(ref sourceRef, i);
- ref Cmyk dp = ref Unsafe.Add(ref destRef, i);
- dp = ToCmyk(sp);
- }
- }
-
- ///
- /// Converts a into a .
- ///
- /// The color to convert.
- /// The
- public static Cmyk ToCmyk(in Hsv color)
- {
- Rgb rgb = ToRgb(color);
-
- return CmykAndRgbConverter.Convert(rgb);
- }
-
- ///
- /// Performs the bulk conversion from into .
- ///
- /// The span to the source colors
- /// The span to the destination colors
- public static void Convert(ReadOnlySpan source, Span destination)
- {
- Guard.DestinationShouldNotBeTooShort(source, destination, nameof(destination));
- int count = source.Length;
-
- ref Hsv sourceRef = ref MemoryMarshal.GetReference(source);
- ref Cmyk destRef = ref MemoryMarshal.GetReference(destination);
-
- for (nuint i = 0; i < (uint)count; i++)
- {
- ref Hsv sp = ref Unsafe.Add(ref sourceRef, i);
- ref Cmyk dp = ref Unsafe.Add(ref destRef, i);
- dp = ToCmyk(sp);
- }
- }
-
- ///
- /// Converts a into a .
- ///
- /// The color to convert.
- /// The
- public Cmyk ToCmyk(in HunterLab color)
- {
- CieXyz xyzColor = this.ToCieXyz(color);
-
- return this.ToCmyk(xyzColor);
- }
-
- ///
- /// Performs the bulk conversion from into .
- ///
- /// The span to the source colors
- /// The span to the destination colors
- public void Convert(ReadOnlySpan source, Span destination)
- {
- Guard.DestinationShouldNotBeTooShort(source, destination, nameof(destination));
- int count = source.Length;
-
- ref HunterLab sourceRef = ref MemoryMarshal.GetReference(source);
- ref Cmyk destRef = ref MemoryMarshal.GetReference(destination);
-
- for (nuint i = 0; i < (uint)count; i++)
- {
- ref HunterLab sp = ref Unsafe.Add(ref sourceRef, i);
- ref Cmyk dp = ref Unsafe.Add(ref destRef, i);
- dp = this.ToCmyk(sp);
- }
- }
-
- ///
- /// Converts a into a .
- ///
- /// The color to convert.
- /// The
- public static Cmyk ToCmyk(in LinearRgb color)
- {
- Rgb rgb = ToRgb(color);
-
- return CmykAndRgbConverter.Convert(rgb);
- }
-
- ///
- /// Performs the bulk conversion from into .
- ///
- /// The span to the source colors
- /// The span to the destination colors
- public static void Convert(ReadOnlySpan source, Span destination)
- {
- Guard.DestinationShouldNotBeTooShort(source, destination, nameof(destination));
- int count = source.Length;
-
- ref LinearRgb sourceRef = ref MemoryMarshal.GetReference(source);
- ref Cmyk destRef = ref MemoryMarshal.GetReference(destination);
-
- for (nuint i = 0; i < (uint)count; i++)
- {
- ref LinearRgb sp = ref Unsafe.Add(ref sourceRef, i);
- ref Cmyk dp = ref Unsafe.Add(ref destRef, i);
- dp = ToCmyk(sp);
- }
- }
-
- ///
- /// Converts a into a .
- ///
- /// The color to convert.
- /// The
- public Cmyk ToCmyk(in Lms color)
- {
- CieXyz xyzColor = this.ToCieXyz(color);
-
- return this.ToCmyk(xyzColor);
- }
-
- ///
- /// Performs the bulk conversion from into .
- ///
- /// The span to the source colors,
- /// The span to the destination colors
- public void Convert(ReadOnlySpan source, Span destination)
- {
- Guard.DestinationShouldNotBeTooShort(source, destination, nameof(destination));
- int count = source.Length;
-
- ref Lms sourceRef = ref MemoryMarshal.GetReference(source);
- ref Cmyk destRef = ref MemoryMarshal.GetReference(destination);
-
- for (nuint i = 0; i < (uint)count; i++)
- {
- ref Lms sp = ref Unsafe.Add(ref sourceRef, i);
- ref Cmyk dp = ref Unsafe.Add(ref destRef, i);
- dp = this.ToCmyk(sp);
- }
- }
-
- ///
- /// Converts a into a .
- ///
- /// The color to convert.
- /// The
- public static Cmyk ToCmyk(in Rgb color) => CmykAndRgbConverter.Convert(color);
-
- ///
- /// Performs the bulk conversion from into
- ///
- /// The span to the source colors
- /// The span to the destination colors
- public static void Convert(ReadOnlySpan source, Span destination)
- {
- Guard.DestinationShouldNotBeTooShort(source, destination, nameof(destination));
- int count = source.Length;
-
- ref Rgb sourceRef = ref MemoryMarshal.GetReference(source);
- ref Cmyk destRef = ref MemoryMarshal.GetReference(destination);
-
- for (nuint i = 0; i < (uint)count; i++)
- {
- ref Rgb sp = ref Unsafe.Add(ref sourceRef, i);
- ref Cmyk dp = ref Unsafe.Add(ref destRef, i);
- dp = ToCmyk(sp);
- }
- }
-
- ///
- /// Converts a into a .
- ///
- /// The color to convert.
- /// The
- public Cmyk ToCmyk(in YCbCr color)
- {
- Rgb rgb = this.ToRgb(color);
-
- return CmykAndRgbConverter.Convert(rgb);
- }
-
- ///
- /// Performs the bulk conversion from into .
- ///
- /// The span to the source colors
- /// The span to the destination colors
- public void Convert(ReadOnlySpan source, Span destination)
- {
- Guard.DestinationShouldNotBeTooShort(source, destination, nameof(destination));
- int count = source.Length;
-
- ref YCbCr sourceRef = ref MemoryMarshal.GetReference(source);
- ref Cmyk destRef = ref MemoryMarshal.GetReference(destination);
-
- for (nuint i = 0; i < (uint)count; i++)
- {
- ref YCbCr sp = ref Unsafe.Add(ref sourceRef, i);
- ref Cmyk dp = ref Unsafe.Add(ref destRef, i);
- dp = this.ToCmyk(sp);
- }
- }
-}
diff --git a/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.Hsl.cs b/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.Hsl.cs
deleted file mode 100644
index 67ec16291..000000000
--- a/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.Hsl.cs
+++ /dev/null
@@ -1,437 +0,0 @@
-// Copyright (c) Six Labors.
-// Licensed under the Six Labors Split License.
-
-using System.Runtime.CompilerServices;
-using System.Runtime.InteropServices;
-
-namespace SixLabors.ImageSharp.ColorSpaces.Conversion;
-
-///
-/// Allows conversion to .
-///
-public partial class ColorSpaceConverter
-{
- ///
- /// Converts a into a .
- ///
- /// The color to convert.
- /// The
- public Hsl ToHsl(in CieLab color)
- {
- CieXyz xyzColor = this.ToCieXyz(color);
-
- return this.ToHsl(xyzColor);
- }
-
- ///
- /// Performs the bulk conversion from into .
- ///
- /// The span to the source colors
- /// The span to the destination colors
- public void Convert(ReadOnlySpan source, Span destination)
- {
- Guard.DestinationShouldNotBeTooShort(source, destination, nameof(destination));
- int count = source.Length;
-
- ref CieLab sourceRef = ref MemoryMarshal.GetReference(source);
- ref Hsl destRef = ref MemoryMarshal.GetReference(destination);
-
- for (nuint i = 0; i < (uint)count; i++)
- {
- ref CieLab sp = ref Unsafe.Add(ref sourceRef, i);
- ref Hsl dp = ref Unsafe.Add(ref destRef, i);
- dp = this.ToHsl(sp);
- }
- }
-
- ///
- /// Converts a into a .
- ///
- /// The color to convert.
- /// The
- public Hsl ToHsl(in CieLch color)
- {
- CieXyz xyzColor = this.ToCieXyz(color);
-
- return this.ToHsl(xyzColor);
- }
-
- ///
- /// Performs the bulk conversion from into .
- ///
- /// The span to the source colors
- /// The span to the destination colors
- public void Convert(ReadOnlySpan source, Span destination)
- {
- Guard.DestinationShouldNotBeTooShort(source, destination, nameof(destination));
- int count = source.Length;
-
- ref CieLch sourceRef = ref MemoryMarshal.GetReference(source);
- ref Hsl destRef = ref MemoryMarshal.GetReference(destination);
-
- for (nuint i = 0; i < (uint)count; i++)
- {
- ref CieLch sp = ref Unsafe.Add(ref sourceRef, i);
- ref Hsl dp = ref Unsafe.Add(ref destRef, i);
- dp = this.ToHsl(sp);
- }
- }
-
- ///
- /// Converts a into a .
- ///
- /// The color to convert.
- /// The
- public Hsl ToHsl(in CieLchuv color)
- {
- CieXyz xyzColor = this.ToCieXyz(color);
-
- return this.ToHsl(xyzColor);
- }
-
- ///
- /// Performs the bulk conversion from into .
- ///
- /// The span to the source colors
- /// The span to the destination colors
- public void Convert(ReadOnlySpan source, Span destination)
- {
- Guard.DestinationShouldNotBeTooShort(source, destination, nameof(destination));
- int count = source.Length;
-
- ref CieLchuv sourceRef = ref MemoryMarshal.GetReference(source);
- ref Hsl destRef = ref MemoryMarshal.GetReference(destination);
-
- for (nuint i = 0; i < (uint)count; i++)
- {
- ref CieLchuv sp = ref Unsafe.Add(ref sourceRef, i);
- ref Hsl dp = ref Unsafe.Add(ref destRef, i);
- dp = this.ToHsl(sp);
- }
- }
-
- ///
- /// Converts a into a .
- ///
- /// The color to convert.
- /// The
- public Hsl ToHsl(in CieLuv color)
- {
- CieXyz xyzColor = this.ToCieXyz(color);
-
- return this.ToHsl(xyzColor);
- }
-
- ///
- /// Performs the bulk conversion from into .
- ///
- /// The span to the source colors
- /// The span to the destination colors
- public void Convert(ReadOnlySpan source, Span destination)
- {
- Guard.DestinationShouldNotBeTooShort(source, destination, nameof(destination));
- int count = source.Length;
-
- ref CieLuv sourceRef = ref MemoryMarshal.GetReference(source);
- ref Hsl destRef = ref MemoryMarshal.GetReference(destination);
-
- for (nuint i = 0; i < (uint)count; i++)
- {
- ref CieLuv sp = ref Unsafe.Add(ref sourceRef, i);
- ref Hsl dp = ref Unsafe.Add(ref destRef, i);
- dp = this.ToHsl(sp);
- }
- }
-
- ///
- /// Converts a into a .
- ///
- /// The color to convert.
- /// The
- public Hsl ToHsl(in CieXyy color)
- {
- CieXyz xyzColor = ToCieXyz(color);
-
- return this.ToHsl(xyzColor);
- }
-
- ///
- /// Performs the bulk conversion from into
- ///
- /// The span to the source colors
- /// The span to the destination colors
- public void Convert(ReadOnlySpan source, Span destination)
- {
- Guard.DestinationShouldNotBeTooShort(source, destination, nameof(destination));
- int count = source.Length;
-
- ref CieXyy sourceRef = ref MemoryMarshal.GetReference(source);
- ref Hsl destRef = ref MemoryMarshal.GetReference(destination);
-
- for (nuint i = 0; i < (uint)count; i++)
- {
- ref CieXyy sp = ref Unsafe.Add(ref sourceRef, i);
- ref Hsl dp = ref Unsafe.Add(ref destRef, i);
- dp = this.ToHsl(sp);
- }
- }
-
- ///
- /// Converts a into a
- ///
- /// The color to convert.
- /// The
- public Hsl ToHsl(in CieXyz color)
- {
- Rgb rgb = this.ToRgb(color);
-
- return HslAndRgbConverter.Convert(rgb);
- }
-
- ///
- /// Performs the bulk conversion from into
- ///
- /// The span to the source colors
- /// The span to the destination colors
- public void Convert(ReadOnlySpan source, Span destination)
- {
- Guard.DestinationShouldNotBeTooShort(source, destination, nameof(destination));
- int count = source.Length;
-
- ref CieXyz sourceRef = ref MemoryMarshal.GetReference(source);
- ref Hsl destRef = ref MemoryMarshal.GetReference(destination);
-
- for (nuint i = 0; i < (uint)count; i++)
- {
- ref CieXyz sp = ref Unsafe.Add(ref sourceRef, i);
- ref Hsl dp = ref Unsafe.Add(ref destRef, i);
- dp = this.ToHsl(sp);
- }
- }
-
- ///
- /// Converts a into a
- ///
- /// The color to convert.
- /// The
- public static Hsl ToHsl(in Cmyk color)
- {
- Rgb rgb = ToRgb(color);
-
- return HslAndRgbConverter.Convert(rgb);
- }
-
- ///
- /// Performs the bulk conversion from into
- ///
- /// The span to the source colors
- /// The span to the destination colors
- public static void Convert(ReadOnlySpan source, Span destination)
- {
- Guard.DestinationShouldNotBeTooShort(source, destination, nameof(destination));
- int count = source.Length;
-
- ref Cmyk sourceRef = ref MemoryMarshal.GetReference(source);
- ref Hsl destRef = ref MemoryMarshal.GetReference(destination);
-
- for (nuint i = 0; i < (uint)count; i++)
- {
- ref Cmyk sp = ref Unsafe.Add(ref sourceRef, i);
- ref Hsl dp = ref Unsafe.Add(ref destRef, i);
- dp = ToHsl(sp);
- }
- }
-
- ///
- /// Converts a into a
- ///
- /// The color to convert.
- /// The
- public static Hsl ToHsl(in Hsv color)
- {
- Rgb rgb = ToRgb(color);
-
- return HslAndRgbConverter.Convert(rgb);
- }
-
- ///
- /// Performs the bulk conversion from into
- ///
- /// The span to the source colors
- /// The span to the destination colors
- public static void Convert(ReadOnlySpan source, Span destination)
- {
- Guard.DestinationShouldNotBeTooShort(source, destination, nameof(destination));
- int count = source.Length;
-
- ref Hsv sourceRef = ref MemoryMarshal.GetReference(source);
- ref Hsl destRef = ref MemoryMarshal.GetReference(destination);
-
- for (nuint i = 0; i < (uint)count; i++)
- {
- ref Hsv sp = ref Unsafe.Add(ref sourceRef, i);
- ref Hsl dp = ref Unsafe.Add(ref destRef, i);
- dp = ToHsl(sp);
- }
- }
-
- ///
- /// Converts a into a .
- ///
- /// The color to convert.
- /// The
- public Hsl ToHsl(in HunterLab color)
- {
- CieXyz xyzColor = this.ToCieXyz(color);
-
- return this.ToHsl(xyzColor);
- }
-
- ///
- /// Performs the bulk conversion from into .
- ///
- /// The span to the source colors
- /// The span to the destination colors
- public void Convert(ReadOnlySpan source, Span destination)
- {
- Guard.DestinationShouldNotBeTooShort(source, destination, nameof(destination));
- int count = source.Length;
-
- ref HunterLab sourceRef = ref MemoryMarshal.GetReference(source);
- ref Hsl destRef = ref MemoryMarshal.GetReference(destination);
-
- for (nuint i = 0; i < (uint)count; i++)
- {
- ref HunterLab sp = ref Unsafe.Add(ref sourceRef, i);
- ref Hsl dp = ref Unsafe.Add(ref destRef, i);
- dp = this.ToHsl(sp);
- }
- }
-
- ///
- /// Converts a into a .
- ///
- /// The color to convert.
- /// The
- public static Hsl ToHsl(in LinearRgb color)
- {
- Rgb rgb = ToRgb(color);
-
- return HslAndRgbConverter.Convert(rgb);
- }
-
- ///
- /// Performs the bulk conversion from into .
- ///
- /// The span to the source colors
- /// The span to the destination colors
- public static void Convert(ReadOnlySpan source, Span destination)
- {
- Guard.DestinationShouldNotBeTooShort(source, destination, nameof(destination));
- int count = source.Length;
-
- ref LinearRgb sourceRef = ref MemoryMarshal.GetReference(source);
- ref Hsl destRef = ref MemoryMarshal.GetReference(destination);
-
- for (nuint i = 0; i < (uint)count; i++)
- {
- ref LinearRgb sp = ref Unsafe.Add(ref sourceRef, i);
- ref Hsl dp = ref Unsafe.Add(ref destRef, i);
- dp = ToHsl(sp);
- }
- }
-
- ///
- /// Converts a into a .
- ///
- /// The color to convert.
- /// The
- public Hsl ToHsl(Lms color)
- {
- CieXyz xyzColor = this.ToCieXyz(color);
-
- return this.ToHsl(xyzColor);
- }
-
- ///
- /// Performs the bulk conversion from into .
- ///
- /// The span to the source colors
- /// The span to the destination colors
- public void Convert(ReadOnlySpan source, Span destination)
- {
- Guard.DestinationShouldNotBeTooShort(source, destination, nameof(destination));
- int count = source.Length;
-
- ref Lms sourceRef = ref MemoryMarshal.GetReference(source);
- ref Hsl destRef = ref MemoryMarshal.GetReference(destination);
-
- for (nuint i = 0; i < (uint)count; i++)
- {
- ref Lms sp = ref Unsafe.Add(ref sourceRef, i);
- ref Hsl dp = ref Unsafe.Add(ref destRef, i);
- dp = this.ToHsl(sp);
- }
- }
-
- ///
- /// Converts a into a
- ///
- /// The color to convert.
- /// The
- public static Hsl ToHsl(in Rgb color) => HslAndRgbConverter.Convert(color);
-
- ///
- /// Performs the bulk conversion from into .
- ///
- /// The span to the source colors
- /// The span to the destination colors
- public static void Convert(ReadOnlySpan source, Span destination)
- {
- Guard.DestinationShouldNotBeTooShort(source, destination, nameof(destination));
- int count = source.Length;
-
- ref Rgb sourceRef = ref MemoryMarshal.GetReference(source);
- ref Hsl destRef = ref MemoryMarshal.GetReference(destination);
-
- for (nuint i = 0; i < (uint)count; i++)
- {
- ref Rgb sp = ref Unsafe.Add(ref sourceRef, i);
- ref Hsl dp = ref Unsafe.Add(ref destRef, i);
- dp = ToHsl(sp);
- }
- }
-
- ///
- /// Converts a into a .
- ///
- /// The color to convert.
- /// The
- public Hsl ToHsl(in YCbCr color)
- {
- Rgb rgb = this.ToRgb(color);
-
- return HslAndRgbConverter.Convert(rgb);
- }
-
- ///
- /// Performs the bulk conversion from into .
- ///
- /// The span to the source colors
- /// The span to the destination colors
- public void Convert(ReadOnlySpan source, Span destination)
- {
- Guard.DestinationShouldNotBeTooShort(source, destination, nameof(destination));
- int count = source.Length;
-
- ref YCbCr sourceRef = ref MemoryMarshal.GetReference(source);
- ref Hsl destRef = ref MemoryMarshal.GetReference(destination);
-
- for (nuint i = 0; i < (uint)count; i++)
- {
- ref YCbCr sp = ref Unsafe.Add(ref sourceRef, i);
- ref Hsl dp = ref Unsafe.Add(ref destRef, i);
- dp = this.ToHsl(sp);
- }
- }
-}
diff --git a/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.Hsv.cs b/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.Hsv.cs
deleted file mode 100644
index 47ee42dc5..000000000
--- a/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.Hsv.cs
+++ /dev/null
@@ -1,437 +0,0 @@
-// Copyright (c) Six Labors.
-// Licensed under the Six Labors Split License.
-
-using System.Runtime.CompilerServices;
-using System.Runtime.InteropServices;
-
-namespace SixLabors.ImageSharp.ColorSpaces.Conversion;
-
-///
-/// Allows conversion to .
-///
-public partial class ColorSpaceConverter
-{
- ///
- /// Converts a into a
- ///
- /// The color to convert.
- /// The
- public Hsv ToHsv(in CieLab color)
- {
- CieXyz xyzColor = this.ToCieXyz(color);
-
- return this.ToHsv(xyzColor);
- }
-
- ///
- /// Performs the bulk conversion from into
- ///
- /// The span to the source colors
- /// The span to the destination colors
- public void Convert(ReadOnlySpan source, Span destination)
- {
- Guard.DestinationShouldNotBeTooShort(source, destination, nameof(destination));
- int count = source.Length;
-
- ref CieLab sourceRef = ref MemoryMarshal.GetReference(source);
- ref Hsv destRef = ref MemoryMarshal.GetReference(destination);
-
- for (nuint i = 0; i < (uint)count; i++)
- {
- ref CieLab sp = ref Unsafe.Add(ref sourceRef, i);
- ref Hsv dp = ref Unsafe.Add(ref destRef, i);
- dp = this.ToHsv(sp);
- }
- }
-
- ///
- /// Converts a into a
- ///
- /// The color to convert.
- /// The
- public Hsv ToHsv(in CieLch color)
- {
- CieXyz xyzColor = this.ToCieXyz(color);
-
- return this.ToHsv(xyzColor);
- }
-
- ///
- /// Performs the bulk conversion from into
- ///
- /// The span to the source colors
- /// The span to the destination colors
- public void Convert(ReadOnlySpan source, Span destination)
- {
- Guard.DestinationShouldNotBeTooShort(source, destination, nameof(destination));
- int count = source.Length;
-
- ref CieLch sourceRef = ref MemoryMarshal.GetReference(source);
- ref Hsv destRef = ref MemoryMarshal.GetReference(destination);
-
- for (nuint i = 0; i < (uint)count; i++)
- {
- ref CieLch sp = ref Unsafe.Add(ref sourceRef, i);
- ref Hsv dp = ref Unsafe.Add(ref destRef, i);
- dp = this.ToHsv(sp);
- }
- }
-
- ///
- /// Converts a into a
- ///
- /// The color to convert.
- /// The
- public Hsv ToHsv(in CieLchuv color)
- {
- CieXyz xyzColor = this.ToCieXyz(color);
-
- return this.ToHsv(xyzColor);
- }
-
- ///
- /// Performs the bulk conversion from into
- ///
- /// The span to the source colors
- /// The span to the destination colors
- public void Convert(ReadOnlySpan source, Span destination)
- {
- Guard.DestinationShouldNotBeTooShort(source, destination, nameof(destination));
- int count = source.Length;
-
- ref CieLchuv sourceRef = ref MemoryMarshal.GetReference(source);
- ref Hsv destRef = ref MemoryMarshal.GetReference(destination);
-
- for (nuint i = 0; i < (uint)count; i++)
- {
- ref CieLchuv sp = ref Unsafe.Add(ref sourceRef, i);
- ref Hsv dp = ref Unsafe.Add(ref destRef, i);
- dp = this.ToHsv(sp);
- }
- }
-
- ///
- /// Converts a into a
- ///
- /// The color to convert.
- /// The
- public Hsv ToHsv(in CieLuv color)
- {
- CieXyz xyzColor = this.ToCieXyz(color);
-
- return this.ToHsv(xyzColor);
- }
-
- ///
- /// Performs the bulk conversion from into
- ///
- /// The span to the source colors
- /// The span to the destination colors
- public void Convert(ReadOnlySpan source, Span destination)
- {
- Guard.DestinationShouldNotBeTooShort(source, destination, nameof(destination));
- int count = source.Length;
-
- ref CieLuv sourceRef = ref MemoryMarshal.GetReference(source);
- ref Hsv destRef = ref MemoryMarshal.GetReference(destination);
-
- for (nuint i = 0; i < (uint)count; i++)
- {
- ref CieLuv sp = ref Unsafe.Add(ref sourceRef, i);
- ref Hsv dp = ref Unsafe.Add(ref destRef, i);
- dp = this.ToHsv(sp);
- }
- }
-
- ///
- /// Converts a into a
- ///
- /// The color to convert.
- /// The
- public Hsv ToHsv(in CieXyy color)
- {
- CieXyz xyzColor = ToCieXyz(color);
-
- return this.ToHsv(xyzColor);
- }
-
- ///
- /// Performs the bulk conversion from into
- ///
- /// The span to the source colors
- /// The span to the destination colors
- public void Convert(ReadOnlySpan source, Span destination)
- {
- Guard.DestinationShouldNotBeTooShort(source, destination, nameof(destination));
- int count = source.Length;
-
- ref CieXyy sourceRef = ref MemoryMarshal.GetReference(source);
- ref Hsv destRef = ref MemoryMarshal.GetReference(destination);
-
- for (nuint i = 0; i < (uint)count; i++)
- {
- ref CieXyy sp = ref Unsafe.Add(ref sourceRef, i);
- ref Hsv dp = ref Unsafe.Add(ref destRef, i);
- dp = this.ToHsv(sp);
- }
- }
-
- ///
- /// Converts a into a
- ///
- /// The color to convert.
- /// The
- public Hsv ToHsv(in CieXyz color)
- {
- Rgb rgb = this.ToRgb(color);
-
- return HsvAndRgbConverter.Convert(rgb);
- }
-
- ///
- /// Performs the bulk conversion from into
- ///
- /// The span to the source colors
- /// The span to the destination colors
- public void Convert(ReadOnlySpan source, Span destination)
- {
- Guard.DestinationShouldNotBeTooShort(source, destination, nameof(destination));
- int count = source.Length;
-
- ref CieXyz sourceRef = ref MemoryMarshal.GetReference(source);
- ref Hsv destRef = ref MemoryMarshal.GetReference(destination);
-
- for (nuint i = 0; i < (uint)count; i++)
- {
- ref CieXyz sp = ref Unsafe.Add(ref sourceRef, i);
- ref Hsv dp = ref Unsafe.Add(ref destRef, i);
- dp = this.ToHsv(sp);
- }
- }
-
- ///
- /// Converts a into a
- ///
- /// The color to convert.
- /// The
- public static Hsv ToHsv(in Cmyk color)
- {
- Rgb rgb = ToRgb(color);
-
- return HsvAndRgbConverter.Convert(rgb);
- }
-
- ///
- /// Performs the bulk conversion from into
- ///
- /// The span to the source colors
- /// The span to the destination colors
- public static void Convert(ReadOnlySpan source, Span destination)
- {
- Guard.DestinationShouldNotBeTooShort(source, destination, nameof(destination));
- int count = source.Length;
-
- ref Cmyk sourceRef = ref MemoryMarshal.GetReference(source);
- ref Hsv destRef = ref MemoryMarshal.GetReference(destination);
-
- for (nuint i = 0; i < (uint)count; i++)
- {
- ref Cmyk sp = ref Unsafe.Add(ref sourceRef, i);
- ref Hsv dp = ref Unsafe.Add(ref destRef, i);
- dp = ToHsv(sp);
- }
- }
-
- ///
- /// Converts a into a
- ///
- /// The color to convert.
- /// The
- public static Hsv ToHsv(in Hsl color)
- {
- Rgb rgb = ToRgb(color);
-
- return HsvAndRgbConverter.Convert(rgb);
- }
-
- ///
- /// Performs the bulk conversion from into
- ///
- /// The span to the source colors
- /// The span to the destination colors.
- public static void Convert(ReadOnlySpan source, Span destination)
- {
- Guard.DestinationShouldNotBeTooShort(source, destination, nameof(destination));
- int count = source.Length;
-
- ref Hsl sourceRef = ref MemoryMarshal.GetReference(source);
- ref Hsv destRef = ref MemoryMarshal.GetReference(destination);
-
- for (nuint i = 0; i < (uint)count; i++)
- {
- ref Hsl sp = ref Unsafe.Add(ref sourceRef, i);
- ref Hsv dp = ref Unsafe.Add(ref destRef, i);
- dp = ToHsv(sp);
- }
- }
-
- ///
- /// Converts a into a
- ///
- /// The color to convert.
- /// The
- public Hsv ToHsv(in HunterLab color)
- {
- CieXyz xyzColor = this.ToCieXyz(color);
-
- return this.ToHsv(xyzColor);
- }
-
- ///
- /// Performs the bulk conversion from into
- ///
- /// The span to the source colors
- /// The span to the destination colors
- public void Convert(ReadOnlySpan source, Span destination)
- {
- Guard.DestinationShouldNotBeTooShort(source, destination, nameof(destination));
- int count = source.Length;
-
- ref HunterLab sourceRef = ref MemoryMarshal.GetReference(source);
- ref Hsv destRef = ref MemoryMarshal.GetReference(destination);
-
- for (nuint i = 0; i < (uint)count; i++)
- {
- ref HunterLab sp = ref Unsafe.Add(ref sourceRef, i);
- ref Hsv dp = ref Unsafe.Add(ref destRef, i);
- dp = this.ToHsv(sp);
- }
- }
-
- ///
- /// Converts a into a
- ///
- /// The color to convert.
- /// The
- public static Hsv ToHsv(in LinearRgb color)
- {
- Rgb rgb = ToRgb(color);
-
- return HsvAndRgbConverter.Convert(rgb);
- }
-
- ///
- /// Performs the bulk conversion from into
- ///
- /// The span to the source colors
- /// The span to the destination colors
- public static void Convert(ReadOnlySpan source, Span destination)
- {
- Guard.DestinationShouldNotBeTooShort(source, destination, nameof(destination));
- int count = source.Length;
-
- ref LinearRgb sourceRef = ref MemoryMarshal.GetReference(source);
- ref Hsv destRef = ref MemoryMarshal.GetReference(destination);
-
- for (nuint i = 0; i < (uint)count; i++)
- {
- ref LinearRgb sp = ref Unsafe.Add(ref sourceRef, i);
- ref Hsv dp = ref Unsafe.Add(ref destRef, i);
- dp = ToHsv(sp);
- }
- }
-
- ///