From b458ff2fa024ae478594aa03a8a70f0a6cdb7e4c Mon Sep 17 00:00:00 2001 From: James Jackson-South Date: Tue, 21 May 2024 15:48:23 +1000 Subject: [PATCH] Optimize and cleanup per review --- src/ImageSharp/ColorProfiles/CieLab.cs | 18 ++------ src/ImageSharp/ColorProfiles/CieLch.cs | 10 ++-- src/ImageSharp/ColorProfiles/CieLchuv.cs | 18 ++------ src/ImageSharp/ColorProfiles/CieLuv.cs | 10 ++-- .../CieXyChromaticityCoordinates.cs | 7 +-- src/ImageSharp/ColorProfiles/CieXyy.cs | 10 ++-- src/ImageSharp/ColorProfiles/CieXyz.cs | 5 +- src/ImageSharp/ColorProfiles/Cmyk.cs | 13 ++---- src/ImageSharp/ColorProfiles/Hsl.cs | 10 ++-- src/ImageSharp/ColorProfiles/Hsv.cs | 10 ++-- src/ImageSharp/ColorProfiles/HunterLab.cs | 22 ++++----- .../ColorProfiles/KnownIlluminants.cs | 46 +++++++++---------- src/ImageSharp/ColorProfiles/Lms.cs | 14 +++--- src/ImageSharp/ColorProfiles/Rgb.cs | 10 ++-- .../RgbPrimariesChromaticityCoordinates.cs | 2 +- src/ImageSharp/ColorProfiles/YCbCr.cs | 10 ++-- 16 files changed, 87 insertions(+), 128 deletions(-) diff --git a/src/ImageSharp/ColorProfiles/CieLab.cs b/src/ImageSharp/ColorProfiles/CieLab.cs index 72148af45..82d60f4da 100644 --- a/src/ImageSharp/ColorProfiles/CieLab.cs +++ b/src/ImageSharp/ColorProfiles/CieLab.cs @@ -12,12 +12,6 @@ namespace SixLabors.ImageSharp.ColorProfiles; /// public readonly struct CieLab : IProfileConnectingSpace { - /// - /// D50 standard illuminant. - /// Used when reference white is not specified explicitly. - /// - public static readonly CieXyz DefaultWhitePoint = KnownIlluminants.D50; - /// /// Initializes a new instance of the struct. /// @@ -50,19 +44,19 @@ public readonly struct CieLab : IProfileConnectingSpace /// Gets the lightness dimension. /// A value usually ranging between 0 (black), 100 (diffuse white) or higher (specular white). /// - public readonly float L { get; } + public 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; } + public 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; } + public float B { get; } /// /// Compares two objects for equality. @@ -97,10 +91,8 @@ public readonly struct CieLab : IProfileConnectingSpace /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public bool Equals(CieLab other) => - this.L.Equals(other.L) - && this.A.Equals(other.A) - && this.B.Equals(other.B); + public bool Equals(CieLab other) + => new Vector3(this.L, this.A, this.B) == new Vector3(other.L, other.A, other.B); /// [MethodImpl(MethodImplOptions.AggressiveInlining)] diff --git a/src/ImageSharp/ColorProfiles/CieLch.cs b/src/ImageSharp/ColorProfiles/CieLch.cs index a8d70cfb7..8f6298a2d 100644 --- a/src/ImageSharp/ColorProfiles/CieLch.cs +++ b/src/ImageSharp/ColorProfiles/CieLch.cs @@ -44,19 +44,19 @@ public readonly struct CieLch : IColorProfile /// Gets the lightness dimension. /// A value ranging between 0 (black), 100 (diffuse white) or higher (specular white). /// - public readonly float L { get; } + public float L { get; } /// /// Gets the a chroma component. /// A value ranging from 0 to 200. /// - public readonly float C { get; } + public float C { get; } /// /// Gets the h° hue component in degrees. /// A value ranging from 0 to 360. /// - public readonly float H { get; } + public float H { get; } /// /// Compares two objects for equality. @@ -94,9 +94,7 @@ public readonly struct CieLch : IColorProfile /// [MethodImpl(MethodImplOptions.AggressiveInlining)] public bool Equals(CieLch other) - => this.L.Equals(other.L) - && this.C.Equals(other.C) - && this.H.Equals(other.H); + => new Vector3(this.L, this.C, this.H) == new Vector3(other.L, other.C, other.H); /// public static CieLch FromProfileConnectingSpace(ColorConversionOptions options, in CieLab source) diff --git a/src/ImageSharp/ColorProfiles/CieLchuv.cs b/src/ImageSharp/ColorProfiles/CieLchuv.cs index f8f62d104..e537259e4 100644 --- a/src/ImageSharp/ColorProfiles/CieLchuv.cs +++ b/src/ImageSharp/ColorProfiles/CieLchuv.cs @@ -45,24 +45,19 @@ public readonly struct CieLchuv : IColorProfile /// Gets the lightness dimension. /// A value ranging between 0 (black), 100 (diffuse white) or higher (specular white). /// - public readonly float L { get; } + public float L { get; } /// /// Gets the a chroma component. /// A value ranging from 0 to 200. /// - public readonly float C { get; } + public 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; } + public float H { get; } /// /// Compares two objects for equality. @@ -151,7 +146,7 @@ public readonly struct CieLchuv : IColorProfile /// public override int GetHashCode() - => HashCode.Combine(this.L, this.C, this.H, this.WhitePoint); + => HashCode.Combine(this.L, this.C, this.H); /// public override string ToString() @@ -164,10 +159,7 @@ public readonly struct CieLchuv : IColorProfile /// [MethodImpl(MethodImplOptions.AggressiveInlining)] 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); + => new Vector3(this.L, this.C, this.H) == new Vector3(other.L, other.C, other.H); /// /// Computes the saturation of the color (chroma normalized by lightness) diff --git a/src/ImageSharp/ColorProfiles/CieLuv.cs b/src/ImageSharp/ColorProfiles/CieLuv.cs index 9bf102057..118d32f04 100644 --- a/src/ImageSharp/ColorProfiles/CieLuv.cs +++ b/src/ImageSharp/ColorProfiles/CieLuv.cs @@ -46,19 +46,19 @@ public readonly struct CieLuv : IColorProfile /// Gets the lightness dimension /// A value usually ranging between 0 and 100. /// - public readonly float L { get; } + public float L { get; } /// /// Gets the blue-yellow chromaticity coordinate of the given white point. /// A value usually ranging between -100 and 100. /// - public readonly float U { get; } + public float U { get; } /// /// Gets the red-green chromaticity coordinate of the given white point. /// A value usually ranging between -100 and 100. /// - public readonly float V { get; } + public float V { get; } /// /// Compares two objects for equality. @@ -205,9 +205,7 @@ public readonly struct CieLuv : IColorProfile /// [MethodImpl(MethodImplOptions.AggressiveInlining)] public bool Equals(CieLuv other) - => this.L.Equals(other.L) - && this.U.Equals(other.U) - && this.V.Equals(other.V); + => new Vector3(this.L, this.U, this.V) == new Vector3(other.L, other.U, other.V); [MethodImpl(MethodImplOptions.AggressiveInlining)] private static double ComputeU(in CieXyz source) diff --git a/src/ImageSharp/ColorProfiles/CieXyChromaticityCoordinates.cs b/src/ImageSharp/ColorProfiles/CieXyChromaticityCoordinates.cs index b55abdd05..aad7dbf95 100644 --- a/src/ImageSharp/ColorProfiles/CieXyChromaticityCoordinates.cs +++ b/src/ImageSharp/ColorProfiles/CieXyChromaticityCoordinates.cs @@ -1,6 +1,7 @@ // Copyright (c) Six Labors. // Licensed under the Six Labors Split License. +using System.Numerics; using System.Runtime.CompilerServices; // ReSharper disable CompareOfFloatsByEqualityOperator @@ -29,7 +30,7 @@ public readonly struct CieXyChromaticityCoordinates : IEquatable /// Ranges usually from 0 to 1. /// - public readonly float X { get; } + public float X { get; } /// /// Gets the chromaticity Y-coordinate @@ -37,7 +38,7 @@ public readonly struct CieXyChromaticityCoordinates : IEquatable /// Ranges usually from 0 to 1. /// - public readonly float Y { get; } + public float Y { get; } /// /// Compares two objects for equality. @@ -79,5 +80,5 @@ public readonly struct CieXyChromaticityCoordinates : IEquatable [MethodImpl(InliningOptions.ShortMethod)] public bool Equals(CieXyChromaticityCoordinates other) - => this.X.Equals(other.X) && this.Y.Equals(other.Y); + => new Vector2(this.X, this.Y) == new Vector2(other.X, other.Y); } diff --git a/src/ImageSharp/ColorProfiles/CieXyy.cs b/src/ImageSharp/ColorProfiles/CieXyy.cs index 4dcb582d6..ea19f5740 100644 --- a/src/ImageSharp/ColorProfiles/CieXyy.cs +++ b/src/ImageSharp/ColorProfiles/CieXyy.cs @@ -45,19 +45,19 @@ public readonly struct CieXyy : IColorProfile /// Gets the X chrominance component. /// A value usually ranging between 0 and 1. /// - public readonly float X { get; } + public float X { get; } /// /// Gets the Y chrominance component. /// A value usually ranging between 0 and 1. /// - public readonly float Y { get; } + public float Y { get; } /// /// Gets the Y luminance component. /// A value usually ranging between 0 and 1. /// - public readonly float Yl { get; } + public float Yl { get; } /// /// Compares two objects for equality. @@ -150,7 +150,5 @@ public readonly struct CieXyy : IColorProfile /// [MethodImpl(MethodImplOptions.AggressiveInlining)] public bool Equals(CieXyy other) - => this.X.Equals(other.X) - && this.Y.Equals(other.Y) - && this.Yl.Equals(other.Yl); + => new Vector3(this.X, this.Y, this.Yl) == new Vector3(other.X, other.Y, other.Yl); } diff --git a/src/ImageSharp/ColorProfiles/CieXyz.cs b/src/ImageSharp/ColorProfiles/CieXyz.cs index fbd3e77d7..fe8755454 100644 --- a/src/ImageSharp/ColorProfiles/CieXyz.cs +++ b/src/ImageSharp/ColorProfiles/CieXyz.cs @@ -3,7 +3,6 @@ using System.Numerics; using System.Runtime.CompilerServices; -using System.Runtime.Intrinsics; namespace SixLabors.ImageSharp.ColorProfiles; @@ -99,9 +98,7 @@ public readonly struct CieXyz : IProfileConnectingSpace /// [MethodImpl(MethodImplOptions.AggressiveInlining)] public bool Equals(CieXyz other) - => this.X.Equals(other.X) - && this.Y.Equals(other.Y) - && this.Z.Equals(other.Z); + => new Vector3(this.X, this.Y, this.Z) == new Vector3(other.X, other.Y, other.Z); /// public static CieXyz FromProfileConnectingSpace(ColorConversionOptions options, in CieXyz source) diff --git a/src/ImageSharp/ColorProfiles/Cmyk.cs b/src/ImageSharp/ColorProfiles/Cmyk.cs index d586ab6d4..88d3249b3 100644 --- a/src/ImageSharp/ColorProfiles/Cmyk.cs +++ b/src/ImageSharp/ColorProfiles/Cmyk.cs @@ -45,25 +45,25 @@ public readonly struct Cmyk : IColorProfile /// Gets the cyan color component. /// A value ranging between 0 and 1. /// - public readonly float C { get; } + public float C { get; } /// /// Gets the magenta color component. /// A value ranging between 0 and 1. /// - public readonly float M { get; } + public float M { get; } /// /// Gets the yellow color component. /// A value ranging between 0 and 1. /// - public readonly float Y { get; } + public float Y { get; } /// /// Gets the keyline black color component. /// A value ranging between 0 and 1. /// - public readonly float K { get; } + public float K { get; } /// /// Compares two objects for equality. @@ -157,8 +157,5 @@ public readonly struct Cmyk : IColorProfile /// [MethodImpl(MethodImplOptions.AggressiveInlining)] 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); + => new Vector4(this.C, this.M, this.Y, this.K) == new Vector4(other.C, other.M, other.Y, other.K); } diff --git a/src/ImageSharp/ColorProfiles/Hsl.cs b/src/ImageSharp/ColorProfiles/Hsl.cs index 8dcef23c4..c7ae97c79 100644 --- a/src/ImageSharp/ColorProfiles/Hsl.cs +++ b/src/ImageSharp/ColorProfiles/Hsl.cs @@ -43,19 +43,19 @@ public readonly struct Hsl : IColorProfile /// Gets the hue component. /// A value ranging between 0 and 360. /// - public readonly float H { get; } + public float H { get; } /// /// Gets the saturation component. /// A value ranging between 0 and 1. /// - public readonly float S { get; } + public float S { get; } /// /// Gets the lightness component. /// A value ranging between 0 and 1. /// - public readonly float L { get; } + public float L { get; } /// /// Compares two objects for equality. @@ -200,9 +200,7 @@ public readonly struct Hsl : IColorProfile /// [MethodImpl(MethodImplOptions.AggressiveInlining)] public bool Equals(Hsl other) - => this.H.Equals(other.H) - && this.S.Equals(other.S) - && this.L.Equals(other.L); + => new Vector3(this.H, this.S, this.L) == new Vector3(other.H, other.S, other.L); [MethodImpl(MethodImplOptions.AggressiveInlining)] private static float GetColorComponent(float first, float second, float third) diff --git a/src/ImageSharp/ColorProfiles/Hsv.cs b/src/ImageSharp/ColorProfiles/Hsv.cs index b3922d11f..83445a40f 100644 --- a/src/ImageSharp/ColorProfiles/Hsv.cs +++ b/src/ImageSharp/ColorProfiles/Hsv.cs @@ -43,19 +43,19 @@ public readonly struct Hsv : IColorProfile /// Gets the hue component. /// A value ranging between 0 and 360. /// - public readonly float H { get; } + public float H { get; } /// /// Gets the saturation component. /// A value ranging between 0 and 1. /// - public readonly float S { get; } + public float S { get; } /// /// Gets the value (brightness) component. /// A value ranging between 0 and 1. /// - public readonly float V { get; } + public float V { get; } /// /// Compares two objects for equality. @@ -223,7 +223,5 @@ public readonly struct Hsv : IColorProfile /// [MethodImpl(MethodImplOptions.AggressiveInlining)] public bool Equals(Hsv other) - => this.H.Equals(other.H) - && this.S.Equals(other.S) - && this.V.Equals(other.V); + => new Vector3(this.H, this.S, this.V) == new Vector3(other.H, other.S, other.V); } diff --git a/src/ImageSharp/ColorProfiles/HunterLab.cs b/src/ImageSharp/ColorProfiles/HunterLab.cs index 5d6c01a2b..eb33e6a95 100644 --- a/src/ImageSharp/ColorProfiles/HunterLab.cs +++ b/src/ImageSharp/ColorProfiles/HunterLab.cs @@ -20,8 +20,10 @@ public readonly struct HunterLab : IColorProfile /// The b (blue - yellow) component. [MethodImpl(MethodImplOptions.AggressiveInlining)] public HunterLab(float l, float a, float b) - : this(new Vector3(l, a, b)) { + this.L = l; + this.A = a; + this.B = b; } /// @@ -41,24 +43,19 @@ public readonly struct HunterLab : IColorProfile /// Gets the lightness dimension. /// A value usually ranging between 0 (black), 100 (diffuse white) or higher (specular white). /// - public readonly float L { get; } + public 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; } + public 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; } + public float B { get; } /// /// Compares two objects for equality. @@ -162,7 +159,7 @@ public readonly struct HunterLab : IColorProfile /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public override int GetHashCode() => HashCode.Combine(this.L, this.A, this.B, this.WhitePoint); + public override int GetHashCode() => HashCode.Combine(this.L, this.A, this.B); /// public override string ToString() => FormattableString.Invariant($"HunterLab({this.L:#0.##}, {this.A:#0.##}, {this.B:#0.##})"); @@ -173,10 +170,7 @@ public readonly struct HunterLab : IColorProfile /// [MethodImpl(MethodImplOptions.AggressiveInlining)] public bool Equals(HunterLab other) - => this.L.Equals(other.L) - && this.A.Equals(other.A) - && this.B.Equals(other.B) - && this.WhitePoint.Equals(other.WhitePoint); + => new Vector3(this.L, this.A, this.B) == new Vector3(other.L, other.A, other.B); [MethodImpl(MethodImplOptions.AggressiveInlining)] private static float ComputeKa(in CieXyz whitePoint) diff --git a/src/ImageSharp/ColorProfiles/KnownIlluminants.cs b/src/ImageSharp/ColorProfiles/KnownIlluminants.cs index ac5cbea2c..b9236497f 100644 --- a/src/ImageSharp/ColorProfiles/KnownIlluminants.cs +++ b/src/ImageSharp/ColorProfiles/KnownIlluminants.cs @@ -1,4 +1,4 @@ -// Copyright (c) Six Labors. +// Copyright (c) Six Labors. // Licensed under the Six Labors Split License. namespace SixLabors.ImageSharp.ColorProfiles; @@ -15,57 +15,57 @@ namespace SixLabors.ImageSharp.ColorProfiles; public static class KnownIlluminants { /// - /// Incandescent / Tungsten + /// Gets the Incandescent / Tungsten illuminant. /// - public static readonly CieXyz A = new(1.09850F, 1F, 0.35585F); + public static CieXyz A { get; } = new(1.09850F, 1F, 0.35585F); /// - /// Direct sunlight at noon (obsoleteF) + /// Gets the Direct sunlight at noon (obsoleteF) illuminant. /// - public static readonly CieXyz B = new(0.99072F, 1F, 0.85223F); + public static CieXyz B { get; } = new(0.99072F, 1F, 0.85223F); /// - /// Average / North sky Daylight (obsoleteF) + /// Gets the Average / North sky Daylight (obsoleteF) illuminant. /// - public static readonly CieXyz C = new(0.98074F, 1F, 1.18232F); + public static CieXyz C { get; } = new(0.98074F, 1F, 1.18232F); /// - /// Horizon Light. ICC profile PCS + /// Gets the Horizon Light. ICC profile PCS illuminant. /// - public static readonly CieXyz D50 = new(0.96422F, 1F, 0.82521F); + public static CieXyz D50 { get; } = new(0.96422F, 1F, 0.82521F); /// - /// Mid-morning / Mid-afternoon Daylight + /// Gets the Mid-morning / Mid-afternoon Daylight illuminant. /// - public static readonly CieXyz D55 = new(0.95682F, 1F, 0.92149F); + public static CieXyz D55 { get; } = new(0.95682F, 1F, 0.92149F); /// - /// Noon Daylight: TelevisionF, sRGB color space + /// Gets the Noon Daylight: TelevisionF, sRGB color space illuminant. /// - public static readonly CieXyz D65 = new(0.95047F, 1F, 1.08883F); + public static CieXyz D65 { get; } = new(0.95047F, 1F, 1.08883F); /// - /// North sky Daylight + /// Gets the North sky Daylight illuminant. /// - public static readonly CieXyz D75 = new(0.94972F, 1F, 1.22638F); + public static CieXyz D75 { get; } = new(0.94972F, 1F, 1.22638F); /// - /// Equal energy + /// Gets the Equal energy illuminant. /// - public static readonly CieXyz E = new(1F, 1F, 1F); + public static CieXyz E { get; } = new(1F, 1F, 1F); /// - /// Cool White Fluorescent + /// Gets the Cool White Fluorescent illuminant. /// - public static readonly CieXyz F2 = new(0.99186F, 1F, 0.67393F); + public static CieXyz F2 { get; } = new(0.99186F, 1F, 0.67393F); /// - /// D65 simulatorF, Daylight simulator + /// Gets the D65 simulatorF, Daylight simulator illuminant. /// - public static readonly CieXyz F7 = new(0.95041F, 1F, 1.08747F); + public static CieXyz F7 { get; } = new(0.95041F, 1F, 1.08747F); /// - /// Philips TL84F, Ultralume 40 + /// Gets the Philips TL84F, Ultralume 40 illuminant. /// - public static readonly CieXyz F11 = new(1.00962F, 1F, 0.64350F); + public static CieXyz F11 { get; } = new(1.00962F, 1F, 0.64350F); } diff --git a/src/ImageSharp/ColorProfiles/Lms.cs b/src/ImageSharp/ColorProfiles/Lms.cs index cb060185d..03a1c5d66 100644 --- a/src/ImageSharp/ColorProfiles/Lms.cs +++ b/src/ImageSharp/ColorProfiles/Lms.cs @@ -16,8 +16,10 @@ internal readonly struct Lms : IColorProfile /// S represents the responsivity at short wavelengths. [MethodImpl(MethodImplOptions.AggressiveInlining)] public Lms(float l, float m, float s) - : this(new Vector3(l, m, s)) { + this.L = l; + this.M = m; + this.S = s; } /// @@ -37,19 +39,19 @@ internal readonly struct Lms : IColorProfile /// Gets the L long component. /// A value usually ranging between -1 and 1. /// - public readonly float L { get; } + public float L { get; } /// /// Gets the M medium component. /// A value usually ranging between -1 and 1. /// - public readonly float M { get; } + public float M { get; } /// /// Gets the S short component. /// A value usually ranging between -1 and 1. /// - public readonly float S { get; } + public float S { get; } /// /// Compares two objects for equality. @@ -92,9 +94,7 @@ internal readonly struct Lms : IColorProfile /// [MethodImpl(MethodImplOptions.AggressiveInlining)] public bool Equals(Lms other) - => this.L.Equals(other.L) - && this.M.Equals(other.M) - && this.S.Equals(other.S); + => new Vector3(this.L, this.M, this.S) == new Vector3(other.L, other.M, other.S); /// public static Lms FromProfileConnectingSpace(ColorConversionOptions options, in CieXyz source) diff --git a/src/ImageSharp/ColorProfiles/Rgb.cs b/src/ImageSharp/ColorProfiles/Rgb.cs index 697c0fbd8..8036d83e5 100644 --- a/src/ImageSharp/ColorProfiles/Rgb.cs +++ b/src/ImageSharp/ColorProfiles/Rgb.cs @@ -43,19 +43,19 @@ public readonly struct Rgb : IProfileConnectingSpace /// Gets the red component. /// A value usually ranging between 0 and 1. /// - public readonly float R { get; } + public float R { get; } /// /// Gets the green component. /// A value usually ranging between 0 and 1. /// - public readonly float G { get; } + public float G { get; } /// /// Gets the blue component. /// A value usually ranging between 0 and 1. /// - public readonly float B { get; } + public float B { get; } /// /// Compares two objects for equality. @@ -91,9 +91,7 @@ public readonly struct Rgb : IProfileConnectingSpace /// [MethodImpl(MethodImplOptions.AggressiveInlining)] public bool Equals(Rgb other) - => this.R.Equals(other.R) - && this.G.Equals(other.G) - && this.B.Equals(other.B); + => new Vector3(this.R, this.G, this.B) == new Vector3(other.R, other.G, other.B); /// public static Rgb FromProfileConnectingSpace(ColorConversionOptions options, in CieXyz source) diff --git a/src/ImageSharp/ColorProfiles/RgbPrimariesChromaticityCoordinates.cs b/src/ImageSharp/ColorProfiles/RgbPrimariesChromaticityCoordinates.cs index 90a5a57f9..1040f23ac 100644 --- a/src/ImageSharp/ColorProfiles/RgbPrimariesChromaticityCoordinates.cs +++ b/src/ImageSharp/ColorProfiles/RgbPrimariesChromaticityCoordinates.cs @@ -1,4 +1,4 @@ -// Copyright (c) Six Labors. +// Copyright (c) Six Labors. // Licensed under the Six Labors Split License. using SixLabors.ImageSharp.ColorProfiles.WorkingSpaces; diff --git a/src/ImageSharp/ColorProfiles/YCbCr.cs b/src/ImageSharp/ColorProfiles/YCbCr.cs index 5f0b4118a..b9f5f65ee 100644 --- a/src/ImageSharp/ColorProfiles/YCbCr.cs +++ b/src/ImageSharp/ColorProfiles/YCbCr.cs @@ -45,19 +45,19 @@ public readonly struct YCbCr : IColorProfile /// Gets the Y luminance component. /// A value ranging between 0 and 255. /// - public readonly float Y { get; } + public float Y { get; } /// /// Gets the Cb chroma component. /// A value ranging between 0 and 255. /// - public readonly float Cb { get; } + public float Cb { get; } /// /// Gets the Cr chroma component. /// A value ranging between 0 and 255. /// - public readonly float Cr { get; } + public float Cr { get; } /// /// Compares two objects for equality. @@ -152,7 +152,5 @@ public readonly struct YCbCr : IColorProfile /// [MethodImpl(MethodImplOptions.AggressiveInlining)] public bool Equals(YCbCr other) - => this.Y.Equals(other.Y) - && this.Cb.Equals(other.Cb) - && this.Cr.Equals(other.Cr); + => new Vector3(this.Y, this.Cb, this.Cr) == new Vector3(other.Y, other.Cb, other.Cr); }