diff --git a/.editorconfig b/.editorconfig
index 753a4dbc2a..f84e6de2a0 100644
--- a/.editorconfig
+++ b/.editorconfig
@@ -1,5 +1,5 @@
-# Version: 2.1.0 (Using https://semver.org/)
-# Updated: 2021-03-03
+# Version: 4.1.1 (Using https://semver.org/)
+# Updated: 2022-05-23
# See https://github.com/RehanSaeed/EditorConfig/releases for release notes.
# See https://github.com/RehanSaeed/EditorConfig for updates to this file.
# See http://EditorConfig.org for more information about .editorconfig files.
@@ -49,11 +49,11 @@ indent_size = 2
indent_size = 2
# Markdown Files
-[*.md]
+[*.{md,mdx}]
trim_trailing_whitespace = false
# Web Files
-[*.{htm,html,js,jsm,ts,tsx,css,sass,scss,less,svg,vue}]
+[*.{htm,html,js,jsm,ts,tsx,cjs,cts,ctsx,mjs,mts,mtsx,css,sass,scss,less,pcss,svg,vue}]
indent_size = 2
# Batch Files
@@ -75,7 +75,7 @@ indent_style = tab
[*.{cs,csx,cake,vb,vbx}]
# Default Severity for all .NET Code Style rules below
-dotnet_analyzer_diagnostic.category-style.severity = warning
+dotnet_analyzer_diagnostic.severity = warning
##########################################
# Language Rules
@@ -128,14 +128,15 @@ file_header_template = Copyright (c) Six Labors.\nLicensed under the Six Labors
# dotnet_diagnostic.SA1636.severity = none
# Undocumented
-dotnet_style_operator_placement_when_wrapping = end_of_line
+dotnet_style_operator_placement_when_wrapping = end_of_line:warning
+csharp_style_prefer_null_check_over_type_check = true:warning
# C# Style Rules
# https://docs.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/language-rules#c-style-rules
[*.{cs,csx,cake}]
# 'var' preferences
-csharp_style_var_for_built_in_types = never
-csharp_style_var_when_type_is_apparent = true:warning
+csharp_style_var_for_built_in_types = false:warning
+csharp_style_var_when_type_is_apparent = false:warning
csharp_style_var_elsewhere = false:warning
# Expression-bodied members
csharp_style_expression_bodied_methods = true:warning
@@ -200,12 +201,15 @@ dotnet_diagnostic.IDE0059.severity = suggestion
# Organize using directives
dotnet_sort_system_directives_first = true
dotnet_separate_import_directive_groups = false
+# Dotnet namespace options
+dotnet_style_namespace_match_folder = true:suggestion
+dotnet_diagnostic.IDE0130.severity = suggestion
# C# formatting rules
# https://docs.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/formatting-rules#c-formatting-rules
[*.{cs,csx,cake}]
# Newline options
-# https://docs.microsoft.com/visualstudio/ide/editorconfig-formatting-conventions#new-line-options
+# https://docs.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/formatting-rules#new-line-options
csharp_new_line_before_open_brace = all
csharp_new_line_before_else = true
csharp_new_line_before_catch = true
@@ -214,7 +218,7 @@ csharp_new_line_before_members_in_object_initializers = true
csharp_new_line_before_members_in_anonymous_types = true
csharp_new_line_between_query_expression_clauses = true
# Indentation options
-# https://docs.microsoft.com/visualstudio/ide/editorconfig-formatting-conventions#indentation-options
+# https://docs.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/formatting-rules#indentation-options
csharp_indent_case_contents = true
csharp_indent_switch_labels = true
csharp_indent_labels = no_change
@@ -222,7 +226,7 @@ csharp_indent_block_contents = true
csharp_indent_braces = false
csharp_indent_case_contents_when_block = false
# Spacing options
-# https://docs.microsoft.com/visualstudio/ide/editorconfig-formatting-conventions#spacing-options
+# https://docs.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/formatting-rules#spacing-options
csharp_space_after_cast = false
csharp_space_after_keywords_in_control_flow_statements = true
csharp_space_between_parentheses = false
@@ -246,7 +250,7 @@ csharp_space_before_open_square_brackets = false
csharp_space_between_empty_square_brackets = false
csharp_space_between_square_brackets = false
# Wrap options
-# https://docs.microsoft.com/visualstudio/ide/editorconfig-formatting-conventions#wrap-options
+# https://docs.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/formatting-rules#wrap-options
csharp_preserve_single_line_statements = false
csharp_preserve_single_line_blocks = true
@@ -448,4 +452,4 @@ dotnet_naming_rule.parameters_rule.severity = warning
# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
# OTHER DEALINGS IN THE SOFTWARE.
-##########################################
+##########################################
\ No newline at end of file
diff --git a/shared-infrastructure b/shared-infrastructure
index c0e0353c1e..5eb77e2d9e 160000
--- a/shared-infrastructure
+++ b/shared-infrastructure
@@ -1 +1 @@
-Subproject commit c0e0353c1ee89398def0ccdc3e945380034fbea8
+Subproject commit 5eb77e2d9eb4f0ece012c996941ab78db1af2a41
diff --git a/src/Directory.Build.props b/src/Directory.Build.props
index faa29865f2..cfc3d82225 100644
--- a/src/Directory.Build.props
+++ b/src/Directory.Build.props
@@ -21,6 +21,10 @@
true
+
+ ..\ImageSharp.ruleset
+
+
diff --git a/src/ImageSharp.ruleset b/src/ImageSharp.ruleset
new file mode 100644
index 0000000000..e88c43f838
--- /dev/null
+++ b/src/ImageSharp.ruleset
@@ -0,0 +1,7 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/ImageSharp/Advanced/AdvancedImageExtensions.cs b/src/ImageSharp/Advanced/AdvancedImageExtensions.cs
index 8a7046c9ad..2fbb429957 100644
--- a/src/ImageSharp/Advanced/AdvancedImageExtensions.cs
+++ b/src/ImageSharp/Advanced/AdvancedImageExtensions.cs
@@ -3,6 +3,7 @@
using System;
using System.Collections.Generic;
+using System.Globalization;
using System.IO;
using System.Text;
using System.Threading;
@@ -34,11 +35,11 @@ public static IImageEncoder DetectEncoder(this Image source, string filePath)
IImageFormat format = source.GetConfiguration().ImageFormatsManager.FindFormatByFileExtension(ext);
if (format is null)
{
- var sb = new StringBuilder();
- sb.AppendLine($"No encoder was found for extension '{ext}'. Registered encoders include:");
+ StringBuilder sb = new();
+ sb.AppendLine(CultureInfo.InvariantCulture, $"No encoder was found for extension '{ext}'. Registered encoders include:");
foreach (IImageFormat fmt in source.GetConfiguration().ImageFormats)
{
- sb.AppendFormat(" - {0} : {1}{2}", fmt.Name, string.Join(", ", fmt.FileExtensions), Environment.NewLine);
+ sb.AppendFormat(CultureInfo.InvariantCulture, " - {0} : {1}{2}", fmt.Name, string.Join(", ", fmt.FileExtensions), Environment.NewLine);
}
throw new NotSupportedException(sb.ToString());
@@ -48,11 +49,11 @@ public static IImageEncoder DetectEncoder(this Image source, string filePath)
if (encoder is null)
{
- var sb = new StringBuilder();
- sb.AppendLine($"No encoder was found for extension '{ext}' using image format '{format.Name}'. Registered encoders include:");
+ StringBuilder sb = new();
+ sb.AppendLine(CultureInfo.InvariantCulture, $"No encoder was found for extension '{ext}' using image format '{format.Name}'. Registered encoders include:");
foreach (KeyValuePair enc in source.GetConfiguration().ImageFormatsManager.ImageEncoders)
{
- sb.AppendFormat(" - {0} : {1}{2}", enc.Key, enc.Value.GetType().Name, Environment.NewLine);
+ sb.AppendFormat(CultureInfo.InvariantCulture, " - {0} : {1}{2}", enc.Key, enc.Value.GetType().Name, Environment.NewLine);
}
throw new NotSupportedException(sb.ToString());
@@ -116,6 +117,7 @@ private static Configuration GetConfiguration(IConfigurationProvider source)
/// Certain Image Processors may invalidate the returned and all it's buffers,
/// therefore it's not recommended to mutate the image while holding a reference to it's .
///
+ /// Thrown when the in .
public static IMemoryGroup GetPixelMemoryGroup(this ImageFrame source)
where TPixel : unmanaged, IPixel
=> source?.PixelBuffer.FastMemoryGroup.View ?? throw new ArgumentNullException(nameof(source));
@@ -131,13 +133,14 @@ public static IMemoryGroup GetPixelMemoryGroup(this ImageFrame and all it's buffers,
/// therefore it's not recommended to mutate the image while holding a reference to it's .
///
+ /// Thrown when the in .
public static IMemoryGroup GetPixelMemoryGroup(this Image source)
where TPixel : unmanaged, IPixel
=> source?.Frames.RootFrame.GetPixelMemoryGroup() ?? throw new ArgumentNullException(nameof(source));
///
/// Gets the representation of the pixels as a of contiguous memory
- /// at row beginning from the the first pixel on that row.
+ /// at row beginning from the first pixel on that row.
///
/// The type of the pixel.
/// The source.
@@ -154,8 +157,8 @@ public static Memory DangerousGetPixelRowMemory(this ImageFrame<
}
///
- /// Gets the representation of the pixels as of of contiguous memory
- /// at row beginning from the the first pixel on that row.
+ /// Gets the representation of the pixels as of contiguous memory
+ /// at row beginning from the first pixel on that row.
///
/// The type of the pixel.
/// The source.
diff --git a/src/ImageSharp/Advanced/PreserveAttribute.cs b/src/ImageSharp/Advanced/PreserveAttribute.cs
index d543a043c8..5e3a712707 100644
--- a/src/ImageSharp/Advanced/PreserveAttribute.cs
+++ b/src/ImageSharp/Advanced/PreserveAttribute.cs
@@ -1,6 +1,8 @@
// Copyright (c) Six Labors.
// Licensed under the Six Labors Split License.
+using System;
+
namespace SixLabors.ImageSharp.Advanced
{
///
@@ -8,7 +10,8 @@ namespace SixLabors.ImageSharp.Advanced
/// The only thing that matters is the class name.
/// There is no need to use or inherit from the PreserveAttribute class in each environment.
///
- internal sealed class PreserveAttribute : System.Attribute
+ [AttributeUsage(AttributeTargets.Method)]
+ internal sealed class PreserveAttribute : Attribute
{
}
}
diff --git a/src/ImageSharp/Color/Color.cs b/src/ImageSharp/Color/Color.cs
index d8fb348913..9cff680e46 100644
--- a/src/ImageSharp/Color/Color.cs
+++ b/src/ImageSharp/Color/Color.cs
@@ -151,7 +151,7 @@ public static Color FromPixel(TPixel pixel)
[MethodImpl(InliningOptions.ShortMethod)]
public static Color ParseHex(string hex)
{
- var rgba = Rgba32.ParseHex(hex);
+ Rgba32 rgba = Rgba32.ParseHex(hex);
return new Color(rgba);
}
@@ -193,6 +193,7 @@ public static bool TryParseHex(string hex, out Color result)
///
/// The .
///
+ /// Input string is not in the correct format.
public static Color Parse(string input)
{
Guard.NotNull(input, nameof(input));
@@ -241,7 +242,7 @@ public static bool TryParse(string input, out Color result)
/// The color having it's alpha channel altered.
public Color WithAlpha(float alpha)
{
- var v = (Vector4)this;
+ Vector4 v = (Vector4)this;
v.W = alpha;
return new Color(v);
}
@@ -290,12 +291,12 @@ public TPixel ToPixel()
/// The source color span.
/// The destination pixel span.
[MethodImpl(InliningOptions.ShortMethod)]
- public static void ToPixel(
- Configuration configuration,
- ReadOnlySpan source,
- Span destination)
+#pragma warning disable RCS1163 // Unused parameter.
+ public static void ToPixel(Configuration configuration, ReadOnlySpan source, Span destination)
+#pragma warning restore RCS1163 // Unused parameter.
where TPixel : unmanaged, IPixel
{
+ // TODO: Investigate bulk operations utilizing configuration parameter here.
Guard.DestinationShouldNotBeTooShort(source, destination, nameof(destination));
for (int i = 0; i < source.Length; i++)
{
diff --git a/src/ImageSharp/ColorSpaces/CieLab.cs b/src/ImageSharp/ColorSpaces/CieLab.cs
index b72a2eecd4..bc84342dec 100644
--- a/src/ImageSharp/ColorSpaces/CieLab.cs
+++ b/src/ImageSharp/ColorSpaces/CieLab.cs
@@ -1,4 +1,4 @@
-// Copyright (c) Six Labors.
+// Copyright (c) Six Labors.
// Licensed under the Six Labors Split License.
using System;
@@ -19,29 +19,6 @@ namespace SixLabors.ImageSharp.ColorSpaces
///
public static readonly CieXyz DefaultWhitePoint = Illuminants.D50;
- ///
- /// Gets the lightness dimension.
- /// A value usually ranging between 0 (black), 100 (diffuse white) or higher (specular white).
- ///
- public readonly float L;
-
- ///
- /// Gets the a color component.
- /// A value usually ranging from -100 to 100. Negative is green, positive magenta.
- ///
- public readonly float A;
-
- ///
- /// Gets the b color component.
- /// A value usually ranging from -100 to 100. Negative is blue, positive is yellow
- ///
- public readonly float B;
-
- ///
- /// Gets the reference white point of this color
- ///
- public readonly CieXyz WhitePoint;
-
///
/// Initializes a new instance of the struct.
///
@@ -95,6 +72,29 @@ public CieLab(Vector3 vector, CieXyz whitePoint)
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.
///
@@ -128,12 +128,10 @@ public CieLab(Vector3 vector, CieXyz whitePoint)
///
[MethodImpl(InliningOptions.ShortMethod)]
- public bool Equals(CieLab other)
- {
- return this.L.Equals(other.L)
- && this.A.Equals(other.A)
- && this.B.Equals(other.B)
- && this.WhitePoint.Equals(other.WhitePoint);
- }
+ 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
index 899c7d8dbc..0c46e9b7cc 100644
--- a/src/ImageSharp/ColorSpaces/CieLch.cs
+++ b/src/ImageSharp/ColorSpaces/CieLch.cs
@@ -1,4 +1,4 @@
-// Copyright (c) Six Labors.
+// Copyright (c) Six Labors.
// Licensed under the Six Labors Split License.
using System;
@@ -19,31 +19,8 @@ namespace SixLabors.ImageSharp.ColorSpaces
///
public static readonly CieXyz DefaultWhitePoint = Illuminants.D50;
- private static readonly Vector3 Min = new Vector3(0, -200, 0);
- private static readonly Vector3 Max = new Vector3(100, 200, 360);
-
- ///
- /// Gets the lightness dimension.
- /// A value ranging between 0 (black), 100 (diffuse white) or higher (specular white).
- ///
- public readonly float L;
-
- ///
- /// Gets the a chroma component.
- /// A value ranging from 0 to 200.
- ///
- public readonly float C;
-
- ///
- /// Gets the h° hue component in degrees.
- /// A value ranging from 0 to 360.
- ///
- public readonly float H;
-
- ///
- /// Gets the reference white point of this color
- ///
- public readonly CieXyz WhitePoint;
+ 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.
@@ -97,6 +74,29 @@ public CieLch(Vector3 vector, CieXyz whitePoint)
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.
///
@@ -121,9 +121,7 @@ public CieLch(Vector3 vector, CieXyz whitePoint)
///
public override int GetHashCode()
- {
- return HashCode.Combine(this.L, this.C, this.H, this.WhitePoint);
- }
+ => 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.##})");
@@ -135,12 +133,10 @@ public override int GetHashCode()
///
[MethodImpl(InliningOptions.ShortMethod)]
public bool Equals(CieLch other)
- {
- return this.L.Equals(other.L)
- && this.C.Equals(other.C)
- && this.H.Equals(other.H)
- && this.WhitePoint.Equals(other.WhitePoint);
- }
+ => 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)
diff --git a/src/ImageSharp/ColorSpaces/CieLchuv.cs b/src/ImageSharp/ColorSpaces/CieLchuv.cs
index 2a41fd490c..2227b60225 100644
--- a/src/ImageSharp/ColorSpaces/CieLchuv.cs
+++ b/src/ImageSharp/ColorSpaces/CieLchuv.cs
@@ -1,4 +1,4 @@
-// Copyright (c) Six Labors.
+// Copyright (c) Six Labors.
// Licensed under the Six Labors Split License.
using System;
@@ -13,8 +13,8 @@ namespace SixLabors.ImageSharp.ColorSpaces
///
public readonly struct CieLchuv : IEquatable
{
- private static readonly Vector3 Min = new Vector3(0, -200, 0);
- private static readonly Vector3 Max = new Vector3(100, 200, 360);
+ private static readonly Vector3 Min = new(0, -200, 0);
+ private static readonly Vector3 Max = new(100, 200, 360);
///
/// D50 standard illuminant.
@@ -22,29 +22,6 @@ namespace SixLabors.ImageSharp.ColorSpaces
///
public static readonly CieXyz DefaultWhitePoint = Illuminants.D65;
- ///
- /// Gets the lightness dimension.
- /// A value ranging between 0 (black), 100 (diffuse white) or higher (specular white).
- ///
- public readonly float L;
-
- ///
- /// Gets the a chroma component.
- /// A value ranging from 0 to 200.
- ///
- public readonly float C;
-
- ///
- /// Gets the h° hue component in degrees.
- /// A value ranging from 0 to 360.
- ///
- public readonly float H;
-
- ///
- /// Gets the reference white point of this color
- ///
- public readonly CieXyz WhitePoint;
-
///
/// Initializes a new instance of the struct.
///
@@ -98,6 +75,29 @@ public CieLchuv(Vector3 vector, CieXyz whitePoint)
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.
///
@@ -130,12 +130,10 @@ public CieLchuv(Vector3 vector, CieXyz whitePoint)
///
[MethodImpl(InliningOptions.ShortMethod)]
public bool Equals(CieLchuv other)
- {
- return this.L.Equals(other.L)
- && this.C.Equals(other.C)
- && this.H.Equals(other.H)
- && this.WhitePoint.Equals(other.WhitePoint);
- }
+ => 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)
diff --git a/src/ImageSharp/ColorSpaces/CieLuv.cs b/src/ImageSharp/ColorSpaces/CieLuv.cs
index a45042ba85..32481bcb52 100644
--- a/src/ImageSharp/ColorSpaces/CieLuv.cs
+++ b/src/ImageSharp/ColorSpaces/CieLuv.cs
@@ -1,4 +1,4 @@
-// Copyright (c) Six Labors.
+// Copyright (c) Six Labors.
// Licensed under the Six Labors Split License.
using System;
@@ -21,29 +21,6 @@ namespace SixLabors.ImageSharp.ColorSpaces
///
public static readonly CieXyz DefaultWhitePoint = Illuminants.D65;
- ///
- /// Gets the lightness dimension
- /// A value usually ranging between 0 and 100.
- ///
- public readonly float L;
-
- ///
- /// Gets the blue-yellow chromaticity coordinate of the given whitepoint.
- /// A value usually ranging between -100 and 100.
- ///
- public readonly float U;
-
- ///
- /// Gets the red-green chromaticity coordinate of the given whitepoint.
- /// A value usually ranging between -100 and 100.
- ///
- public readonly float V;
-
- ///
- /// Gets the reference white point of this color
- ///
- public readonly CieXyz WhitePoint;
-
///
/// Initializes a new instance of the struct.
///
@@ -96,6 +73,29 @@ public CieLuv(Vector3 vector, CieXyz whitePoint)
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.
///
@@ -130,11 +130,9 @@ public CieLuv(Vector3 vector, CieXyz whitePoint)
///
[MethodImpl(InliningOptions.ShortMethod)]
public bool Equals(CieLuv other)
- {
- return this.L.Equals(other.L)
- && this.U.Equals(other.U)
- && this.V.Equals(other.V)
- && this.WhitePoint.Equals(other.WhitePoint);
- }
+ => 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
index 9306606db9..6bbcad075c 100644
--- a/src/ImageSharp/ColorSpaces/CieXyy.cs
+++ b/src/ImageSharp/ColorSpaces/CieXyy.cs
@@ -1,4 +1,4 @@
-// Copyright (c) Six Labors.
+// Copyright (c) Six Labors.
// Licensed under the Six Labors Split License.
using System;
@@ -13,24 +13,6 @@ namespace SixLabors.ImageSharp.ColorSpaces
///
public readonly struct CieXyy : IEquatable
{
- ///
- /// Gets the X chrominance component.
- /// A value usually ranging between 0 and 1.
- ///
- public readonly float X;
-
- ///
- /// Gets the Y chrominance component.
- /// A value usually ranging between 0 and 1.
- ///
- public readonly float Y;
-
- ///
- /// Gets the Y luminance component.
- /// A value usually ranging between 0 and 1.
- ///
- public readonly float Yl;
-
///
/// Initializes a new instance of the struct.
///
@@ -60,6 +42,24 @@ public CieXyy(Vector3 vector)
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.
///
@@ -94,10 +94,8 @@ public CieXyy(Vector3 vector)
///
[MethodImpl(InliningOptions.ShortMethod)]
public bool Equals(CieXyy other)
- {
- return this.X.Equals(other.X)
- && this.Y.Equals(other.Y)
- && this.Yl.Equals(other.Yl);
- }
+ => 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
index e52904c558..b767128438 100644
--- a/src/ImageSharp/ColorSpaces/CieXyz.cs
+++ b/src/ImageSharp/ColorSpaces/CieXyz.cs
@@ -1,4 +1,4 @@
-// Copyright (c) Six Labors.
+// Copyright (c) Six Labors.
// Licensed under the Six Labors Split License.
using System;
@@ -13,24 +13,6 @@ namespace SixLabors.ImageSharp.ColorSpaces
///
public readonly struct CieXyz : IEquatable
{
- ///
- /// 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;
-
- ///
- /// Gets the Y luminance component.
- /// A value usually ranging between 0 and 1.
- ///
- public readonly float Y;
-
- ///
- /// 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;
-
///
/// Initializes a new instance of the struct.
///
@@ -56,6 +38,24 @@ public CieXyz(Vector3 vector)
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.
///
@@ -83,7 +83,7 @@ public CieXyz(Vector3 vector)
///
/// The .
[MethodImpl(InliningOptions.ShortMethod)]
- public Vector3 ToVector3() => new Vector3(this.X, this.Y, this.Z);
+ public Vector3 ToVector3() => new(this.X, this.Y, this.Z);
///
public override int GetHashCode() => HashCode.Combine(this.X, this.Y, this.Z);
@@ -97,10 +97,8 @@ public CieXyz(Vector3 vector)
///
[MethodImpl(InliningOptions.ShortMethod)]
public bool Equals(CieXyz other)
- {
- return this.X.Equals(other.X)
- && this.Y.Equals(other.Y)
- && this.Z.Equals(other.Z);
- }
+ => 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
index cd2899ee7d..fad331101c 100644
--- a/src/ImageSharp/ColorSpaces/Cmyk.cs
+++ b/src/ImageSharp/ColorSpaces/Cmyk.cs
@@ -1,4 +1,4 @@
-// Copyright (c) Six Labors.
+// Copyright (c) Six Labors.
// Licensed under the Six Labors Split License.
using System;
@@ -15,30 +15,6 @@ namespace SixLabors.ImageSharp.ColorSpaces
private static readonly Vector4 Min = Vector4.Zero;
private static readonly Vector4 Max = Vector4.One;
- ///
- /// Gets the cyan color component.
- /// A value ranging between 0 and 1.
- ///
- public readonly float C;
-
- ///
- /// Gets the magenta color component.
- /// A value ranging between 0 and 1.
- ///
- public readonly float M;
-
- ///
- /// Gets the yellow color component.
- /// A value ranging between 0 and 1.
- ///
- public readonly float Y;
-
- ///
- /// Gets the keyline black color component.
- /// A value ranging between 0 and 1.
- ///
- public readonly float K;
-
///
/// Initializes a new instance of the struct.
///
@@ -66,6 +42,30 @@ public Cmyk(Vector4 vector)
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.
///
@@ -101,11 +101,9 @@ public Cmyk(Vector4 vector)
///
[MethodImpl(InliningOptions.ShortMethod)]
public bool Equals(Cmyk other)
- {
- return this.C.Equals(other.C)
- && this.M.Equals(other.M)
- && this.Y.Equals(other.Y)
- && this.K.Equals(other.K);
- }
+ => 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/SRgbCompanding.cs b/src/ImageSharp/ColorSpaces/Companding/SRgbCompanding.cs
index 1337af702c..82e9a123be 100644
--- a/src/ImageSharp/ColorSpaces/Companding/SRgbCompanding.cs
+++ b/src/ImageSharp/ColorSpaces/Companding/SRgbCompanding.cs
@@ -5,10 +5,8 @@
using System.Numerics;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
-#if SUPPORTS_RUNTIME_INTRINSICS
using System.Runtime.Intrinsics;
using System.Runtime.Intrinsics.X86;
-#endif
namespace SixLabors.ImageSharp.ColorSpaces.Companding
{
@@ -25,10 +23,10 @@ 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 Lazy(
+ private static readonly Lazy LazyCompressTable = new(
() =>
{
- var result = new float[Length];
+ float[] result = new float[Length];
for (int i = 0; i < result.Length; i++)
{
@@ -49,10 +47,10 @@ public static class SRgbCompanding
},
true);
- private static readonly Lazy LazyExpandTable = new Lazy(
+ private static readonly Lazy LazyExpandTable = new(
() =>
{
- var result = new float[Length];
+ float[] result = new float[Length];
for (int i = 0; i < result.Length; i++)
{
@@ -84,7 +82,6 @@ public static class SRgbCompanding
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void Expand(Span vectors)
{
-#if SUPPORTS_RUNTIME_INTRINSICS
if (Avx2.IsSupported && vectors.Length >= 2)
{
CompandAvx2(vectors, ExpandTable);
@@ -92,11 +89,10 @@ public static void Expand(Span vectors)
if (Numerics.Modulo2(vectors.Length) != 0)
{
// Vector4 fits neatly in pairs. Any overlap has to be equal to 1.
- Expand(ref MemoryMarshal.GetReference(vectors.Slice(vectors.Length - 1)));
+ Expand(ref MemoryMarshal.GetReference(vectors[^1..]));
}
}
else
-#endif
{
CompandScalar(vectors, ExpandTable);
}
@@ -109,7 +105,6 @@ public static void Expand(Span vectors)
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static unsafe void Compress(Span vectors)
{
-#if SUPPORTS_RUNTIME_INTRINSICS
if (Avx2.IsSupported && vectors.Length >= 2)
{
CompandAvx2(vectors, CompressTable);
@@ -117,11 +112,10 @@ public static unsafe void Compress(Span vectors)
if (Numerics.Modulo2(vectors.Length) != 0)
{
// Vector4 fits neatly in pairs. Any overlap has to be equal to 1.
- Compress(ref MemoryMarshal.GetReference(vectors.Slice(vectors.Length - 1)));
+ Compress(ref MemoryMarshal.GetReference(vectors[^1..]));
}
}
else
-#endif
{
CompandScalar(vectors, CompressTable);
}
@@ -171,8 +165,6 @@ public static float Expand(float channel)
public static float Compress(float channel)
=> channel <= 0.0031308F ? 12.92F * channel : (1.055F * MathF.Pow(channel, 0.416666666666667F)) - 0.055F;
-#if SUPPORTS_RUNTIME_INTRINSICS
-
[MethodImpl(MethodImplOptions.AggressiveInlining)]
private static unsafe void CompandAvx2(Span vectors, float[] table)
{
@@ -204,7 +196,6 @@ private static unsafe void CompandAvx2(Span vectors, float[] table)
}
}
}
-#endif
[MethodImpl(MethodImplOptions.AggressiveInlining)]
private static unsafe void CompandScalar(Span vectors, float[] table)
diff --git a/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.Adapt.cs b/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.Adapt.cs
index 60ae18b5c9..d200aa83ec 100644
--- a/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.Adapt.cs
+++ b/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.Adapt.cs
@@ -150,9 +150,9 @@ public Rgb Adapt(in Rgb color)
return color;
}
- var linearInput = this.ToLinearRgb(color);
+ var linearInput = ToLinearRgb(color);
LinearRgb linearOutput = this.Adapt(linearInput);
- return this.ToRgb(linearOutput);
+ return ToRgb(linearOutput);
}
}
}
diff --git a/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.CieLab.cs b/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.CieLab.cs
index 1a7c627db5..c3dd3b473f 100644
--- a/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.CieLab.cs
+++ b/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.CieLab.cs
@@ -12,11 +12,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
///
public partial class ColorSpaceConverter
{
- ///
- /// The converter for converting between CieLch to CieLab.
- ///
- private static readonly CieLchToCieLabConverter CieLchToCieLabConverter = new CieLchToCieLabConverter();
-
///
/// Converts a into a .
///
@@ -58,7 +53,7 @@ public void Convert(ReadOnlySpan source, Span destination)
/// The
public CieLab ToCieLab(in CieLchuv color)
{
- var xyzColor = this.ToCieXyz(color);
+ CieXyz xyzColor = this.ToCieXyz(color);
return this.ToCieLab(xyzColor);
}
@@ -91,7 +86,7 @@ public void Convert(ReadOnlySpan source, Span destination)
/// The
public CieLab ToCieLab(in CieLuv color)
{
- var xyzColor = this.ToCieXyz(color);
+ CieXyz xyzColor = this.ToCieXyz(color);
return this.ToCieLab(xyzColor);
}
@@ -124,7 +119,7 @@ public void Convert(ReadOnlySpan source, Span destination)
/// The
public CieLab ToCieLab(in CieXyy color)
{
- var xyzColor = this.ToCieXyz(color);
+ CieXyz xyzColor = ToCieXyz(color);
return this.ToCieLab(xyzColor);
}
@@ -190,7 +185,7 @@ public void Convert(ReadOnlySpan source, Span destination)
/// The
public CieLab ToCieLab(in Cmyk color)
{
- var xyzColor = this.ToCieXyz(color);
+ CieXyz xyzColor = this.ToCieXyz(color);
return this.ToCieLab(xyzColor);
}
@@ -222,7 +217,7 @@ public void Convert(ReadOnlySpan source, Span destination)
/// The
public CieLab ToCieLab(in Hsl color)
{
- var xyzColor = this.ToCieXyz(color);
+ CieXyz xyzColor = this.ToCieXyz(color);
return this.ToCieLab(xyzColor);
}
@@ -255,7 +250,7 @@ public void Convert(ReadOnlySpan source, Span destination)
/// The
public CieLab ToCieLab(in Hsv color)
{
- var xyzColor = this.ToCieXyz(color);
+ CieXyz xyzColor = this.ToCieXyz(color);
return this.ToCieLab(xyzColor);
}
@@ -287,7 +282,7 @@ public void Convert(ReadOnlySpan source, Span destination)
/// The
public CieLab ToCieLab(in HunterLab color)
{
- var xyzColor = this.ToCieXyz(color);
+ CieXyz xyzColor = this.ToCieXyz(color);
return this.ToCieLab(xyzColor);
}
@@ -320,7 +315,7 @@ public void Convert(ReadOnlySpan source, Span destination)
/// The
public CieLab ToCieLab(in Lms color)
{
- var xyzColor = this.ToCieXyz(color);
+ CieXyz xyzColor = this.ToCieXyz(color);
return this.ToCieLab(xyzColor);
}
@@ -353,7 +348,7 @@ public void Convert(ReadOnlySpan source, Span destination)
/// The
public CieLab ToCieLab(in LinearRgb color)
{
- var xyzColor = this.ToCieXyz(color);
+ CieXyz xyzColor = this.ToCieXyz(color);
return this.ToCieLab(xyzColor);
}
@@ -386,7 +381,7 @@ public void Convert(ReadOnlySpan source, Span destination)
/// The
public CieLab ToCieLab(in Rgb color)
{
- var xyzColor = this.ToCieXyz(color);
+ CieXyz xyzColor = this.ToCieXyz(color);
return this.ToCieLab(xyzColor);
}
@@ -419,7 +414,7 @@ public void Convert(ReadOnlySpan source, Span destination)
/// The
public CieLab ToCieLab(in YCbCr color)
{
- var xyzColor = this.ToCieXyz(color);
+ CieXyz xyzColor = this.ToCieXyz(color);
return this.ToCieLab(xyzColor);
}
diff --git a/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.CieLch.cs b/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.CieLch.cs
index 06ff11b1ec..ec7d48b783 100644
--- a/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.CieLch.cs
+++ b/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.CieLch.cs
@@ -12,11 +12,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
///
public partial class ColorSpaceConverter
{
- ///
- /// The converter for converting between CieLab to CieLch.
- ///
- private static readonly CieLabToCieLchConverter CieLabToCieLchConverter = new CieLabToCieLchConverter();
-
///
/// Converts a into a
///
@@ -123,7 +118,7 @@ public void Convert(ReadOnlySpan source, Span destination)
/// The
public CieLch ToCieLch(in CieXyy color)
{
- var xyzColor = this.ToCieXyz(color);
+ var xyzColor = ToCieXyz(color);
return this.ToCieLch(xyzColor);
}
diff --git a/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.CieLchuv.cs b/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.CieLchuv.cs
index 5752cb9b11..52c092a2e8 100644
--- a/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.CieLchuv.cs
+++ b/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.CieLchuv.cs
@@ -12,11 +12,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
///
public partial class ColorSpaceConverter
{
- ///
- /// The converter for converting between CieLab to CieLchuv.
- ///
- private static readonly CieLuvToCieLchuvConverter CieLuvToCieLchuvConverter = new CieLuvToCieLchuvConverter();
-
///
/// Converts a into a
///
@@ -24,7 +19,7 @@ public partial class ColorSpaceConverter
/// The
public CieLchuv ToCieLchuv(in CieLab color)
{
- var xyzColor = this.ToCieXyz(color);
+ CieXyz xyzColor = this.ToCieXyz(color);
return this.ToCieLchuv(xyzColor);
}
@@ -57,7 +52,7 @@ public void Convert(ReadOnlySpan source, Span destination)
/// The
public CieLchuv ToCieLchuv(in CieLch color)
{
- var xyzColor = this.ToCieXyz(color);
+ CieXyz xyzColor = this.ToCieXyz(color);
return this.ToCieLchuv(xyzColor);
}
@@ -123,7 +118,7 @@ public void Convert(ReadOnlySpan source, Span destination)
/// The
public CieLchuv ToCieLchuv(in CieXyy color)
{
- var xyzColor = this.ToCieXyz(color);
+ CieXyz xyzColor = ToCieXyz(color);
return this.ToCieLchuv(xyzColor);
}
@@ -156,7 +151,7 @@ public void Convert(ReadOnlySpan source, Span destination)
/// The
public CieLchuv ToCieLchuv(in CieXyz color)
{
- var luvColor = this.ToCieLuv(color);
+ CieLuv luvColor = this.ToCieLuv(color);
return this.ToCieLchuv(luvColor);
}
@@ -189,7 +184,7 @@ public void Convert(ReadOnlySpan source, Span destination)
/// The
public CieLchuv ToCieLchuv(in Cmyk color)
{
- var xyzColor = this.ToCieXyz(color);
+ CieXyz xyzColor = this.ToCieXyz(color);
return this.ToCieLchuv(xyzColor);
}
@@ -222,7 +217,7 @@ public void Convert(ReadOnlySpan source, Span destination)
/// The
public CieLchuv ToCieLchuv(in Hsl color)
{
- var xyzColor = this.ToCieXyz(color);
+ CieXyz xyzColor = this.ToCieXyz(color);
return this.ToCieLchuv(xyzColor);
}
@@ -255,7 +250,7 @@ public void Convert(ReadOnlySpan source, Span destination)
/// The
public CieLchuv ToCieLchuv(in Hsv color)
{
- var xyzColor = this.ToCieXyz(color);
+ CieXyz xyzColor = this.ToCieXyz(color);
return this.ToCieLchuv(xyzColor);
}
@@ -288,7 +283,7 @@ public void Convert(ReadOnlySpan source, Span destination)
/// The
public CieLchuv ToCieLchuv(in HunterLab color)
{
- var xyzColor = this.ToCieXyz(color);
+ CieXyz xyzColor = this.ToCieXyz(color);
return this.ToCieLchuv(xyzColor);
}
@@ -321,7 +316,7 @@ public void Convert(ReadOnlySpan source, Span destination)
/// The
public CieLchuv ToCieLchuv(in LinearRgb color)
{
- var xyzColor = this.ToCieXyz(color);
+ CieXyz xyzColor = this.ToCieXyz(color);
return this.ToCieLchuv(xyzColor);
}
@@ -354,7 +349,7 @@ public void Convert(ReadOnlySpan source, Span destination)
/// The
public CieLchuv ToCieLchuv(in Lms color)
{
- var xyzColor = this.ToCieXyz(color);
+ CieXyz xyzColor = this.ToCieXyz(color);
return this.ToCieLchuv(xyzColor);
}
@@ -387,7 +382,7 @@ public void Convert(ReadOnlySpan source, Span destination)
/// The
public CieLchuv ToCieLchuv(in Rgb color)
{
- var xyzColor = this.ToCieXyz(color);
+ CieXyz xyzColor = this.ToCieXyz(color);
return this.ToCieLchuv(xyzColor);
}
@@ -420,7 +415,7 @@ public void Convert(ReadOnlySpan source, Span destination)
/// The
public CieLchuv ToCieLchuv(in YCbCr color)
{
- var xyzColor = this.ToCieXyz(color);
+ CieXyz xyzColor = this.ToCieXyz(color);
return this.ToCieLchuv(xyzColor);
}
diff --git a/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.CieLuv.cs b/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.CieLuv.cs
index 486924b9aa..572d8875db 100644
--- a/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.CieLuv.cs
+++ b/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.CieLuv.cs
@@ -12,8 +12,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
///
public partial class ColorSpaceConverter
{
- private static readonly CieLchuvToCieLuvConverter CieLchuvToCieLuvConverter = new CieLchuvToCieLuvConverter();
-
///
/// Converts a into a .
///
@@ -21,7 +19,7 @@ public partial class ColorSpaceConverter
/// The
public CieLuv ToCieLuv(in CieLab color)
{
- var xyzColor = this.ToCieXyz(color);
+ CieXyz xyzColor = this.ToCieXyz(color);
return this.ToCieLuv(xyzColor);
}
@@ -53,7 +51,7 @@ public void Convert(ReadOnlySpan source, Span destination)
/// The
public CieLuv ToCieLuv(in CieLch color)
{
- var xyzColor = this.ToCieXyz(color);
+ CieXyz xyzColor = this.ToCieXyz(color);
return this.ToCieLuv(xyzColor);
}
@@ -120,7 +118,7 @@ public void Convert(ReadOnlySpan source, Span destination)
/// The
public CieLuv ToCieLuv(in CieXyy color)
{
- var xyzColor = this.ToCieXyz(color);
+ CieXyz xyzColor = ToCieXyz(color);
return this.ToCieLuv(xyzColor);
}
@@ -187,7 +185,7 @@ public void Convert(ReadOnlySpan source, Span destination)
/// The
public CieLuv ToCieLuv(in Cmyk color)
{
- var xyzColor = this.ToCieXyz(color);
+ CieXyz xyzColor = this.ToCieXyz(color);
return this.ToCieLuv(xyzColor);
}
@@ -219,7 +217,7 @@ public void Convert(ReadOnlySpan source, Span destination)
/// The
public CieLuv ToCieLuv(in Hsl color)
{
- var xyzColor = this.ToCieXyz(color);
+ CieXyz xyzColor = this.ToCieXyz(color);
return this.ToCieLuv(xyzColor);
}
@@ -251,7 +249,7 @@ public void Convert(ReadOnlySpan source, Span destination)
/// The
public CieLuv ToCieLuv(in Hsv color)
{
- var xyzColor = this.ToCieXyz(color);
+ CieXyz xyzColor = this.ToCieXyz(color);
return this.ToCieLuv(xyzColor);
}
@@ -283,7 +281,7 @@ public void Convert(ReadOnlySpan source, Span destination)
/// The
public CieLuv ToCieLuv(in HunterLab color)
{
- var xyzColor = this.ToCieXyz(color);
+ CieXyz xyzColor = this.ToCieXyz(color);
return this.ToCieLuv(xyzColor);
}
@@ -315,7 +313,7 @@ public void Convert(ReadOnlySpan source, Span destination)
/// The
public CieLuv ToCieLuv(in Lms color)
{
- var xyzColor = this.ToCieXyz(color);
+ CieXyz xyzColor = this.ToCieXyz(color);
return this.ToCieLuv(xyzColor);
}
@@ -347,7 +345,7 @@ public void Convert(ReadOnlySpan source, Span destination)
/// The
public CieLuv ToCieLuv(in LinearRgb color)
{
- var xyzColor = this.ToCieXyz(color);
+ CieXyz xyzColor = this.ToCieXyz(color);
return this.ToCieLuv(xyzColor);
}
@@ -379,7 +377,7 @@ public void Convert(ReadOnlySpan source, Span destination)
/// The
public CieLuv ToCieLuv(in Rgb color)
{
- var xyzColor = this.ToCieXyz(color);
+ CieXyz xyzColor = this.ToCieXyz(color);
return this.ToCieLuv(xyzColor);
}
@@ -411,7 +409,7 @@ public void Convert(ReadOnlySpan source, Span destination)
/// The
public CieLuv ToCieLuv(in YCbCr color)
{
- var xyzColor = this.ToCieXyz(color);
+ CieXyz xyzColor = this.ToCieXyz(color);
return this.ToCieLuv(xyzColor);
}
diff --git a/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.CieXyy.cs b/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.CieXyy.cs
index 603308751c..b5d655e680 100644
--- a/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.CieXyy.cs
+++ b/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.CieXyy.cs
@@ -12,8 +12,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
///
public partial class ColorSpaceConverter
{
- private static readonly CieXyzAndCieXyyConverter CieXyzAndCieXyyConverter = new CieXyzAndCieXyyConverter();
-
///
/// Converts a into a
///
@@ -21,9 +19,9 @@ public partial class ColorSpaceConverter
/// The
public CieXyy ToCieXyy(in CieLab color)
{
- var xyzColor = this.ToCieXyz(color);
+ CieXyz xyzColor = this.ToCieXyz(color);
- return this.ToCieXyy(xyzColor);
+ return ToCieXyy(xyzColor);
}
///
@@ -54,9 +52,9 @@ public void Convert(ReadOnlySpan source, Span destination)
/// The
public CieXyy ToCieXyy(in CieLch color)
{
- var xyzColor = this.ToCieXyz(color);
+ CieXyz xyzColor = this.ToCieXyz(color);
- return this.ToCieXyy(xyzColor);
+ return ToCieXyy(xyzColor);
}
///
@@ -87,9 +85,9 @@ public void Convert(ReadOnlySpan source, Span destination)
/// The
public CieXyy ToCieXyy(in CieLchuv color)
{
- var xyzColor = this.ToCieXyz(color);
+ CieXyz xyzColor = this.ToCieXyz(color);
- return this.ToCieXyy(xyzColor);
+ return ToCieXyy(xyzColor);
}
///
@@ -120,9 +118,9 @@ public void Convert(ReadOnlySpan source, Span destination)
/// The
public CieXyy ToCieXyy(in CieLuv color)
{
- var xyzColor = this.ToCieXyz(color);
+ CieXyz xyzColor = this.ToCieXyz(color);
- return this.ToCieXyy(xyzColor);
+ return ToCieXyy(xyzColor);
}
///
@@ -151,14 +149,14 @@ public void Convert(ReadOnlySpan source, Span destination)
///
/// The color to convert.
/// The
- public CieXyy ToCieXyy(in CieXyz color) => CieXyzAndCieXyyConverter.Convert(color);
+ 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 void Convert(ReadOnlySpan source, Span destination)
+ public static void Convert(ReadOnlySpan source, Span destination)
{
Guard.DestinationShouldNotBeTooShort(source, destination, nameof(destination));
int count = source.Length;
@@ -170,7 +168,7 @@ public void Convert(ReadOnlySpan source, Span destination)
{
ref CieXyz sp = ref Unsafe.Add(ref sourceRef, i);
ref CieXyy dp = ref Unsafe.Add(ref destRef, i);
- dp = this.ToCieXyy(sp);
+ dp = ToCieXyy(sp);
}
}
@@ -181,9 +179,9 @@ public void Convert(ReadOnlySpan source, Span destination)
/// The
public CieXyy ToCieXyy(in Cmyk color)
{
- var xyzColor = this.ToCieXyz(color);
+ CieXyz xyzColor = this.ToCieXyz(color);
- return this.ToCieXyy(xyzColor);
+ return ToCieXyy(xyzColor);
}
///
@@ -214,9 +212,9 @@ public void Convert(ReadOnlySpan source, Span destination)
/// The
public CieXyy ToCieXyy(Hsl color)
{
- var xyzColor = this.ToCieXyz(color);
+ CieXyz xyzColor = this.ToCieXyz(color);
- return this.ToCieXyy(xyzColor);
+ return ToCieXyy(xyzColor);
}
///
@@ -247,9 +245,9 @@ public void Convert(ReadOnlySpan source, Span destination)
/// The
public CieXyy ToCieXyy(in Hsv color)
{
- var xyzColor = this.ToCieXyz(color);
+ CieXyz xyzColor = this.ToCieXyz(color);
- return this.ToCieXyy(xyzColor);
+ return ToCieXyy(xyzColor);
}
///
@@ -280,9 +278,9 @@ public void Convert(ReadOnlySpan source, Span destination)
/// The
public CieXyy ToCieXyy(in HunterLab color)
{
- var xyzColor = this.ToCieXyz(color);
+ CieXyz xyzColor = this.ToCieXyz(color);
- return this.ToCieXyy(xyzColor);
+ return ToCieXyy(xyzColor);
}
///
@@ -313,9 +311,9 @@ public void Convert(ReadOnlySpan source, Span destination)
/// The
public CieXyy ToCieXyy(in LinearRgb color)
{
- var xyzColor = this.ToCieXyz(color);
+ CieXyz xyzColor = this.ToCieXyz(color);
- return this.ToCieXyy(xyzColor);
+ return ToCieXyy(xyzColor);
}
///
@@ -346,9 +344,9 @@ public void Convert(ReadOnlySpan source, Span destination)
/// The
public CieXyy ToCieXyy(in Lms color)
{
- var xyzColor = this.ToCieXyz(color);
+ CieXyz xyzColor = this.ToCieXyz(color);
- return this.ToCieXyy(xyzColor);
+ return ToCieXyy(xyzColor);
}
///
@@ -379,9 +377,9 @@ public void Convert(ReadOnlySpan source, Span destination)
/// The
public CieXyy ToCieXyy(in Rgb color)
{
- var xyzColor = this.ToCieXyz(color);
+ CieXyz xyzColor = this.ToCieXyz(color);
- return this.ToCieXyy(xyzColor);
+ return ToCieXyy(xyzColor);
}
///
@@ -412,9 +410,9 @@ public void Convert(ReadOnlySpan source, Span destination)
/// The
public CieXyy ToCieXyy(in YCbCr color)
{
- var xyzColor = this.ToCieXyz(color);
+ CieXyz xyzColor = this.ToCieXyz(color);
- return this.ToCieXyy(xyzColor);
+ return ToCieXyy(xyzColor);
}
///
diff --git a/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.CieXyz.cs b/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.CieXyz.cs
index 242392acc0..d1f0ca489d 100644
--- a/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.CieXyz.cs
+++ b/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.CieXyz.cs
@@ -12,12 +12,7 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
///
public partial class ColorSpaceConverter
{
- private static readonly CieLabToCieXyzConverter CieLabToCieXyzConverter = new CieLabToCieXyzConverter();
-
- private static readonly CieLuvToCieXyzConverter CieLuvToCieXyzConverter = new CieLuvToCieXyzConverter();
-
- private static readonly HunterLabToCieXyzConverter
- HunterLabToCieXyzConverter = new HunterLabToCieXyzConverter();
+ private static readonly HunterLabToCieXyzConverter HunterLabToCieXyzConverter = new();
private LinearRgbToCieXyzConverter linearRgbToCieXyzConverter;
@@ -166,18 +161,17 @@ public void Convert(ReadOnlySpan source, Span destination)
///
/// The color to convert.
/// The
- public CieXyz ToCieXyz(in CieXyy color)
- {
+ public static CieXyz ToCieXyz(in CieXyy color)
+
// Conversion
- return CieXyzAndCieXyyConverter.Convert(color);
- }
+ => CieXyzAndCieXyyConverter.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)
+ public static void Convert(ReadOnlySpan source, Span destination)
{
Guard.DestinationShouldNotBeTooShort(source, destination, nameof(destination));
int count = source.Length;
@@ -189,7 +183,7 @@ public void Convert(ReadOnlySpan source, Span destination)
{
ref CieXyy sp = ref Unsafe.Add(ref sourceRef, i);
ref CieXyz dp = ref Unsafe.Add(ref destRef, i);
- dp = this.ToCieXyz(sp);
+ dp = ToCieXyz(sp);
}
}
@@ -200,7 +194,7 @@ public void Convert(ReadOnlySpan source, Span destination)
/// The
public CieXyz ToCieXyz(in Cmyk color)
{
- var rgb = this.ToRgb(color);
+ Rgb rgb = ToRgb(color);
return this.ToCieXyz(rgb);
}
@@ -233,7 +227,7 @@ public void Convert(ReadOnlySpan source, Span destination)
/// The
public CieXyz ToCieXyz(in Hsl color)
{
- var rgb = this.ToRgb(color);
+ Rgb rgb = ToRgb(color);
return this.ToCieXyz(rgb);
}
@@ -267,7 +261,7 @@ public void Convert(ReadOnlySpan source, Span destination)
public CieXyz ToCieXyz(in Hsv color)
{
// Conversion
- var rgb = this.ToRgb(color);
+ Rgb rgb = ToRgb(color);
return this.ToCieXyz(rgb);
}
@@ -367,9 +361,7 @@ public void Convert(ReadOnlySpan source, Span destination)
/// The color to convert.
/// The
public CieXyz ToCieXyz(in Lms color)
- {
- return this.cieXyzAndLmsConverter.Convert(color);
- }
+ => this.cieXyzAndLmsConverter.Convert(color);
///
/// Performs the bulk conversion from into .
@@ -432,7 +424,7 @@ public void Convert(ReadOnlySpan source, Span destination)
/// The
public CieXyz ToCieXyz(in YCbCr color)
{
- var rgb = this.ToRgb(color);
+ Rgb rgb = this.ToRgb(color);
return this.ToCieXyz(rgb);
}
diff --git a/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.Cmyk.cs b/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.Cmyk.cs
index 664511be9a..152a7f7fc6 100644
--- a/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.Cmyk.cs
+++ b/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.Cmyk.cs
@@ -12,8 +12,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
///
public partial class ColorSpaceConverter
{
- private static readonly CmykAndRgbConverter CmykAndRgbConverter = new CmykAndRgbConverter();
-
///
/// Converts a into a .
///
@@ -21,7 +19,7 @@ public partial class ColorSpaceConverter
/// The
public Cmyk ToCmyk(in CieLab color)
{
- var xyzColor = this.ToCieXyz(color);
+ CieXyz xyzColor = this.ToCieXyz(color);
return this.ToCmyk(xyzColor);
}
@@ -54,7 +52,7 @@ public void Convert(ReadOnlySpan source, Span destination)
/// The
public Cmyk ToCmyk(in CieLch color)
{
- var xyzColor = this.ToCieXyz(color);
+ CieXyz xyzColor = this.ToCieXyz(color);
return this.ToCmyk(xyzColor);
}
@@ -87,7 +85,7 @@ public void Convert(ReadOnlySpan source, Span destination)
/// The
public Cmyk ToCmyk(in CieLchuv color)
{
- var xyzColor = this.ToCieXyz(color);
+ CieXyz xyzColor = this.ToCieXyz(color);
return this.ToCmyk(xyzColor);
}
@@ -120,7 +118,7 @@ public void Convert(ReadOnlySpan source, Span destination)
/// The
public Cmyk ToCmyk(in CieLuv color)
{
- var xyzColor = this.ToCieXyz(color);
+ CieXyz xyzColor = this.ToCieXyz(color);
return this.ToCmyk(xyzColor);
}
@@ -153,7 +151,7 @@ public void Convert(ReadOnlySpan source, Span destination)
/// The
public Cmyk ToCmyk(in CieXyy color)
{
- var xyzColor = this.ToCieXyz(color);
+ CieXyz xyzColor = ToCieXyz(color);
return this.ToCmyk(xyzColor);
}
@@ -186,7 +184,7 @@ public void Convert(ReadOnlySpan source, Span destination)
/// The
public Cmyk ToCmyk(in CieXyz color)
{
- var rgb = this.ToRgb(color);
+ Rgb rgb = this.ToRgb(color);
return CmykAndRgbConverter.Convert(rgb);
}
@@ -217,9 +215,9 @@ public void Convert(ReadOnlySpan source, Span destination)
///
/// The color to convert.
/// The
- public Cmyk ToCmyk(in Hsl color)
+ public static Cmyk ToCmyk(in Hsl color)
{
- var rgb = this.ToRgb(color);
+ Rgb rgb = ToRgb(color);
return CmykAndRgbConverter.Convert(rgb);
}
@@ -229,7 +227,7 @@ public Cmyk ToCmyk(in Hsl color)
///
/// The span to the source colors
/// The span to the destination colors
- public void Convert(ReadOnlySpan source, Span destination)
+ public static void Convert(ReadOnlySpan source, Span destination)
{
Guard.DestinationShouldNotBeTooShort(source, destination, nameof(destination));
int count = source.Length;
@@ -241,7 +239,7 @@ public void Convert(ReadOnlySpan source, Span destination)
{
ref Hsl sp = ref Unsafe.Add(ref sourceRef, i);
ref Cmyk dp = ref Unsafe.Add(ref destRef, i);
- dp = this.ToCmyk(sp);
+ dp = ToCmyk(sp);
}
}
@@ -250,9 +248,9 @@ public void Convert(ReadOnlySpan source, Span destination)
///
/// The color to convert.
/// The
- public Cmyk ToCmyk(in Hsv color)
+ public static Cmyk ToCmyk(in Hsv color)
{
- var rgb = this.ToRgb(color);
+ Rgb rgb = ToRgb(color);
return CmykAndRgbConverter.Convert(rgb);
}
@@ -262,7 +260,7 @@ public Cmyk ToCmyk(in Hsv color)
///
/// The span to the source colors
/// The span to the destination colors
- public void Convert(ReadOnlySpan source, Span destination)
+ public static void Convert(ReadOnlySpan source, Span destination)
{
Guard.DestinationShouldNotBeTooShort(source, destination, nameof(destination));
int count = source.Length;
@@ -274,7 +272,7 @@ public void Convert(ReadOnlySpan source, Span destination)
{
ref Hsv sp = ref Unsafe.Add(ref sourceRef, i);
ref Cmyk dp = ref Unsafe.Add(ref destRef, i);
- dp = this.ToCmyk(sp);
+ dp = ToCmyk(sp);
}
}
@@ -285,7 +283,7 @@ public void Convert(ReadOnlySpan source, Span destination)
/// The
public Cmyk ToCmyk(in HunterLab color)
{
- var xyzColor = this.ToCieXyz(color);
+ CieXyz xyzColor = this.ToCieXyz(color);
return this.ToCmyk(xyzColor);
}
@@ -316,9 +314,9 @@ public void Convert(ReadOnlySpan source, Span destination)
///
/// The color to convert.
/// The
- public Cmyk ToCmyk(in LinearRgb color)
+ public static Cmyk ToCmyk(in LinearRgb color)
{
- var rgb = this.ToRgb(color);
+ Rgb rgb = ToRgb(color);
return CmykAndRgbConverter.Convert(rgb);
}
@@ -328,7 +326,7 @@ public Cmyk ToCmyk(in LinearRgb color)
///
/// The span to the source colors
/// The span to the destination colors
- public void Convert(ReadOnlySpan source, Span destination)
+ public static void Convert(ReadOnlySpan source, Span destination)
{
Guard.DestinationShouldNotBeTooShort(source, destination, nameof(destination));
int count = source.Length;
@@ -340,7 +338,7 @@ public void Convert(ReadOnlySpan source, Span destination)
{
ref LinearRgb sp = ref Unsafe.Add(ref sourceRef, i);
ref Cmyk dp = ref Unsafe.Add(ref destRef, i);
- dp = this.ToCmyk(sp);
+ dp = ToCmyk(sp);
}
}
@@ -351,7 +349,7 @@ public void Convert(ReadOnlySpan source, Span destination)
/// The
public Cmyk ToCmyk(in Lms color)
{
- var xyzColor = this.ToCieXyz(color);
+ CieXyz xyzColor = this.ToCieXyz(color);
return this.ToCmyk(xyzColor);
}
@@ -382,14 +380,14 @@ public void Convert(ReadOnlySpan source, Span destination)
///
/// The color to convert.
/// The
- public Cmyk ToCmyk(in Rgb color) => CmykAndRgbConverter.Convert(color);
+ 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 void Convert(ReadOnlySpan source, Span destination)
+ public static void Convert(ReadOnlySpan source, Span destination)
{
Guard.DestinationShouldNotBeTooShort(source, destination, nameof(destination));
int count = source.Length;
@@ -401,7 +399,7 @@ public void Convert(ReadOnlySpan source, Span destination)
{
ref Rgb sp = ref Unsafe.Add(ref sourceRef, i);
ref Cmyk dp = ref Unsafe.Add(ref destRef, i);
- dp = this.ToCmyk(sp);
+ dp = ToCmyk(sp);
}
}
@@ -412,7 +410,7 @@ public void Convert(ReadOnlySpan source, Span destination)
/// The
public Cmyk ToCmyk(in YCbCr color)
{
- var rgb = this.ToRgb(color);
+ Rgb rgb = this.ToRgb(color);
return CmykAndRgbConverter.Convert(rgb);
}
diff --git a/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.Hsl.cs b/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.Hsl.cs
index 666a6b03cf..19e1bef0d0 100644
--- a/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.Hsl.cs
+++ b/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.Hsl.cs
@@ -12,8 +12,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
///
public partial class ColorSpaceConverter
{
- private static readonly HslAndRgbConverter HslAndRgbConverter = new HslAndRgbConverter();
-
///
/// Converts a into a .
///
@@ -21,7 +19,7 @@ public partial class ColorSpaceConverter
/// The
public Hsl ToHsl(in CieLab color)
{
- var xyzColor = this.ToCieXyz(color);
+ CieXyz xyzColor = this.ToCieXyz(color);
return this.ToHsl(xyzColor);
}
@@ -54,7 +52,7 @@ public void Convert(ReadOnlySpan source, Span destination)
/// The
public Hsl ToHsl(in CieLch color)
{
- var xyzColor = this.ToCieXyz(color);
+ CieXyz xyzColor = this.ToCieXyz(color);
return this.ToHsl(xyzColor);
}
@@ -87,7 +85,7 @@ public void Convert(ReadOnlySpan source, Span destination)
/// The
public Hsl ToHsl(in CieLchuv color)
{
- var xyzColor = this.ToCieXyz(color);
+ CieXyz xyzColor = this.ToCieXyz(color);
return this.ToHsl(xyzColor);
}
@@ -120,7 +118,7 @@ public void Convert(ReadOnlySpan source, Span destination)
/// The
public Hsl ToHsl(in CieLuv color)
{
- var xyzColor = this.ToCieXyz(color);
+ CieXyz xyzColor = this.ToCieXyz(color);
return this.ToHsl(xyzColor);
}
@@ -153,7 +151,7 @@ public void Convert(ReadOnlySpan source, Span destination)
/// The
public Hsl ToHsl(in CieXyy color)
{
- var xyzColor = this.ToCieXyz(color);
+ CieXyz xyzColor = ToCieXyz(color);
return this.ToHsl(xyzColor);
}
@@ -186,7 +184,7 @@ public void Convert(ReadOnlySpan source, Span destination)
/// The
public Hsl ToHsl(in CieXyz color)
{
- var rgb = this.ToRgb(color);
+ Rgb rgb = this.ToRgb(color);
return HslAndRgbConverter.Convert(rgb);
}
@@ -217,9 +215,9 @@ public void Convert(ReadOnlySpan source, Span destination)
///
/// The color to convert.
/// The
- public Hsl ToHsl(in Cmyk color)
+ public static Hsl ToHsl(in Cmyk color)
{
- var rgb = this.ToRgb(color);
+ Rgb rgb = ToRgb(color);
return HslAndRgbConverter.Convert(rgb);
}
@@ -229,7 +227,7 @@ public Hsl ToHsl(in Cmyk color)
///
/// The span to the source colors
/// The span to the destination colors
- public void Convert(ReadOnlySpan source, Span destination)
+ public static void Convert(ReadOnlySpan source, Span destination)
{
Guard.DestinationShouldNotBeTooShort(source, destination, nameof(destination));
int count = source.Length;
@@ -241,7 +239,7 @@ public void Convert(ReadOnlySpan source, Span destination)
{
ref Cmyk sp = ref Unsafe.Add(ref sourceRef, i);
ref Hsl dp = ref Unsafe.Add(ref destRef, i);
- dp = this.ToHsl(sp);
+ dp = ToHsl(sp);
}
}
@@ -250,9 +248,9 @@ public void Convert(ReadOnlySpan source, Span destination)
///
/// The color to convert.
/// The
- public Hsl ToHsl(in Hsv color)
+ public static Hsl ToHsl(in Hsv color)
{
- var rgb = this.ToRgb(color);
+ Rgb rgb = ToRgb(color);
return HslAndRgbConverter.Convert(rgb);
}
@@ -262,7 +260,7 @@ public Hsl ToHsl(in Hsv color)
///
/// The span to the source colors
/// The span to the destination colors
- public void Convert(ReadOnlySpan source, Span destination)
+ public static void Convert(ReadOnlySpan source, Span destination)
{
Guard.DestinationShouldNotBeTooShort(source, destination, nameof(destination));
int count = source.Length;
@@ -274,7 +272,7 @@ public void Convert(ReadOnlySpan source, Span destination)
{
ref Hsv sp = ref Unsafe.Add(ref sourceRef, i);
ref Hsl dp = ref Unsafe.Add(ref destRef, i);
- dp = this.ToHsl(sp);
+ dp = ToHsl(sp);
}
}
@@ -285,7 +283,7 @@ public void Convert(ReadOnlySpan source, Span destination)
/// The
public Hsl ToHsl(in HunterLab color)
{
- var xyzColor = this.ToCieXyz(color);
+ CieXyz xyzColor = this.ToCieXyz(color);
return this.ToHsl(xyzColor);
}
@@ -316,9 +314,9 @@ public void Convert(ReadOnlySpan source, Span destination)
///
/// The color to convert.
/// The
- public Hsl ToHsl(in LinearRgb color)
+ public static Hsl ToHsl(in LinearRgb color)
{
- var rgb = this.ToRgb(color);
+ Rgb rgb = ToRgb(color);
return HslAndRgbConverter.Convert(rgb);
}
@@ -328,7 +326,7 @@ public Hsl ToHsl(in LinearRgb color)
///
/// The span to the source colors
/// The span to the destination colors
- public void Convert(ReadOnlySpan source, Span destination)
+ public static void Convert(ReadOnlySpan source, Span destination)
{
Guard.DestinationShouldNotBeTooShort(source, destination, nameof(destination));
int count = source.Length;
@@ -340,7 +338,7 @@ public void Convert(ReadOnlySpan source, Span destination)
{
ref LinearRgb sp = ref Unsafe.Add(ref sourceRef, i);
ref Hsl dp = ref Unsafe.Add(ref destRef, i);
- dp = this.ToHsl(sp);
+ dp = ToHsl(sp);
}
}
@@ -351,7 +349,7 @@ public void Convert(ReadOnlySpan source, Span destination)
/// The
public Hsl ToHsl(Lms color)
{
- var xyzColor = this.ToCieXyz(color);
+ CieXyz xyzColor = this.ToCieXyz(color);
return this.ToHsl(xyzColor);
}
@@ -382,14 +380,14 @@ public void Convert(ReadOnlySpan source, Span destination)
///
/// The color to convert.
/// The
- public Hsl ToHsl(in Rgb color) => HslAndRgbConverter.Convert(color);
+ 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 void Convert(ReadOnlySpan source, Span destination)
+ public static void Convert(ReadOnlySpan source, Span destination)
{
Guard.DestinationShouldNotBeTooShort(source, destination, nameof(destination));
int count = source.Length;
@@ -401,7 +399,7 @@ public void Convert(ReadOnlySpan source, Span destination)
{
ref Rgb sp = ref Unsafe.Add(ref sourceRef, i);
ref Hsl dp = ref Unsafe.Add(ref destRef, i);
- dp = this.ToHsl(sp);
+ dp = ToHsl(sp);
}
}
@@ -412,7 +410,7 @@ public void Convert(ReadOnlySpan source, Span destination)
/// The
public Hsl ToHsl(in YCbCr color)
{
- var rgb = this.ToRgb(color);
+ Rgb rgb = this.ToRgb(color);
return HslAndRgbConverter.Convert(rgb);
}
diff --git a/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.Hsv.cs b/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.Hsv.cs
index 615a26e36c..c6a3a68d78 100644
--- a/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.Hsv.cs
+++ b/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.Hsv.cs
@@ -12,8 +12,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
///
public partial class ColorSpaceConverter
{
- private static readonly HsvAndRgbConverter HsvAndRgbConverter = new HsvAndRgbConverter();
-
///
/// Converts a into a
///
@@ -21,7 +19,7 @@ public partial class ColorSpaceConverter
/// The
public Hsv ToHsv(in CieLab color)
{
- var xyzColor = this.ToCieXyz(color);
+ CieXyz xyzColor = this.ToCieXyz(color);
return this.ToHsv(xyzColor);
}
@@ -54,7 +52,7 @@ public void Convert(ReadOnlySpan source, Span destination)
/// The
public Hsv ToHsv(in CieLch color)
{
- var xyzColor = this.ToCieXyz(color);
+ CieXyz xyzColor = this.ToCieXyz(color);
return this.ToHsv(xyzColor);
}
@@ -87,7 +85,7 @@ public void Convert(ReadOnlySpan source, Span destination)
/// The
public Hsv ToHsv(in CieLchuv color)
{
- var xyzColor = this.ToCieXyz(color);
+ CieXyz xyzColor = this.ToCieXyz(color);
return this.ToHsv(xyzColor);
}
@@ -120,7 +118,7 @@ public void Convert(ReadOnlySpan source, Span destination)
/// The
public Hsv ToHsv(in CieLuv color)
{
- var xyzColor = this.ToCieXyz(color);
+ CieXyz xyzColor = this.ToCieXyz(color);
return this.ToHsv(xyzColor);
}
@@ -153,7 +151,7 @@ public void Convert(ReadOnlySpan source, Span destination)
/// The
public Hsv ToHsv(in CieXyy color)
{
- var xyzColor = this.ToCieXyz(color);
+ CieXyz xyzColor = ToCieXyz(color);
return this.ToHsv(xyzColor);
}
@@ -186,7 +184,7 @@ public void Convert(ReadOnlySpan source, Span destination)
/// The
public Hsv ToHsv(in CieXyz color)
{
- var rgb = this.ToRgb(color);
+ Rgb rgb = this.ToRgb(color);
return HsvAndRgbConverter.Convert(rgb);
}
@@ -217,9 +215,9 @@ public void Convert(ReadOnlySpan source, Span destination)
///
/// The color to convert.
/// The
- public Hsv ToHsv(in Cmyk color)
+ public static Hsv ToHsv(in Cmyk color)
{
- var rgb = this.ToRgb(color);
+ Rgb rgb = ToRgb(color);
return HsvAndRgbConverter.Convert(rgb);
}
@@ -229,7 +227,7 @@ public Hsv ToHsv(in Cmyk color)
///
/// The span to the source colors
/// The span to the destination colors
- public void Convert(ReadOnlySpan source, Span destination)
+ public static void Convert(ReadOnlySpan source, Span destination)
{
Guard.DestinationShouldNotBeTooShort(source, destination, nameof(destination));
int count = source.Length;
@@ -241,7 +239,7 @@ public void Convert(ReadOnlySpan source, Span destination)
{
ref Cmyk sp = ref Unsafe.Add(ref sourceRef, i);
ref Hsv dp = ref Unsafe.Add(ref destRef, i);
- dp = this.ToHsv(sp);
+ dp = ToHsv(sp);
}
}
@@ -250,9 +248,9 @@ public void Convert(ReadOnlySpan source, Span destination)
///
/// The color to convert.
/// The
- public Hsv ToHsv(in Hsl color)
+ public static Hsv ToHsv(in Hsl color)
{
- var rgb = this.ToRgb(color);
+ Rgb rgb = ToRgb(color);
return HsvAndRgbConverter.Convert(rgb);
}
@@ -262,7 +260,7 @@ public Hsv ToHsv(in Hsl color)
///
/// The span to the source colors
/// The span to the destination colors.
- public void Convert(ReadOnlySpan source, Span destination)
+ public static void Convert(ReadOnlySpan source, Span destination)
{
Guard.DestinationShouldNotBeTooShort(source, destination, nameof(destination));
int count = source.Length;
@@ -274,7 +272,7 @@ public void Convert(ReadOnlySpan source, Span destination)
{
ref Hsl sp = ref Unsafe.Add(ref sourceRef, i);
ref Hsv dp = ref Unsafe.Add(ref destRef, i);
- dp = this.ToHsv(sp);
+ dp = ToHsv(sp);
}
}
@@ -285,7 +283,7 @@ public void Convert(ReadOnlySpan source, Span destination)
/// The
public Hsv ToHsv(in HunterLab color)
{
- var xyzColor = this.ToCieXyz(color);
+ CieXyz xyzColor = this.ToCieXyz(color);
return this.ToHsv(xyzColor);
}
@@ -316,9 +314,9 @@ public void Convert(ReadOnlySpan source, Span destination)
///
/// The color to convert.
/// The
- public Hsv ToHsv(in LinearRgb color)
+ public static Hsv ToHsv(in LinearRgb color)
{
- var rgb = this.ToRgb(color);
+ Rgb rgb = ToRgb(color);
return HsvAndRgbConverter.Convert(rgb);
}
@@ -328,7 +326,7 @@ public Hsv ToHsv(in LinearRgb color)
///
/// The span to the source colors
/// The span to the destination colors
- public void Convert(ReadOnlySpan source, Span destination)
+ public static void Convert(ReadOnlySpan source, Span destination)
{
Guard.DestinationShouldNotBeTooShort(source, destination, nameof(destination));
int count = source.Length;
@@ -340,7 +338,7 @@ public void Convert(ReadOnlySpan source, Span destination)
{
ref LinearRgb sp = ref Unsafe.Add(ref sourceRef, i);
ref Hsv dp = ref Unsafe.Add(ref destRef, i);
- dp = this.ToHsv(sp);
+ dp = ToHsv(sp);
}
}
@@ -351,7 +349,7 @@ public void Convert(ReadOnlySpan source, Span destination)
/// The
public Hsv ToHsv(Lms color)
{
- var xyzColor = this.ToCieXyz(color);
+ CieXyz xyzColor = this.ToCieXyz(color);
return this.ToHsv(xyzColor);
}
@@ -382,14 +380,14 @@ public void Convert(ReadOnlySpan source, Span destination)
///
/// The color to convert.
/// The
- public Hsv ToHsv(in Rgb color) => HsvAndRgbConverter.Convert(color);
+ public static Hsv ToHsv(in Rgb color) => HsvAndRgbConverter.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)
+ public static void Convert(ReadOnlySpan source, Span destination)
{
Guard.DestinationShouldNotBeTooShort(source, destination, nameof(destination));
int count = source.Length;
@@ -401,7 +399,7 @@ public void Convert(ReadOnlySpan source, Span destination)
{
ref Rgb sp = ref Unsafe.Add(ref sourceRef, i);
ref Hsv dp = ref Unsafe.Add(ref destRef, i);
- dp = this.ToHsv(sp);
+ dp = ToHsv(sp);
}
}
@@ -412,7 +410,7 @@ public void Convert(ReadOnlySpan source, Span destination)
/// The
public Hsv ToHsv(in YCbCr color)
{
- var rgb = this.ToRgb(color);
+ Rgb rgb = this.ToRgb(color);
return HsvAndRgbConverter.Convert(rgb);
}
diff --git a/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.HunterLab.cs b/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.HunterLab.cs
index ad2fbd626d..0e880ed591 100644
--- a/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.HunterLab.cs
+++ b/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.HunterLab.cs
@@ -336,7 +336,7 @@ public HunterLab ToHunterLab(in CieLuv color)
/// The
public HunterLab ToHunterLab(in CieXyy color)
{
- var xyzColor = this.ToCieXyz(color);
+ var xyzColor = ToCieXyz(color);
return this.ToHunterLab(xyzColor);
}
diff --git a/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.LinearRgb.cs b/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.LinearRgb.cs
index c317c8e8bb..c5801b0b40 100644
--- a/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.LinearRgb.cs
+++ b/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.LinearRgb.cs
@@ -12,8 +12,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
///
public partial class ColorSpaceConverter
{
- private static readonly RgbToLinearRgbConverter RgbToLinearRgbConverter = new RgbToLinearRgbConverter();
-
///
/// Performs the bulk conversion from into .
///
@@ -145,7 +143,7 @@ public void Convert(ReadOnlySpan source, Span destination)
///
/// The span to the source colors.
/// The span to the destination colors.
- public void Convert(ReadOnlySpan source, Span destination)
+ public static void Convert(ReadOnlySpan source, Span destination)
{
Guard.DestinationShouldNotBeTooShort(source, destination, nameof(destination));
int count = source.Length;
@@ -157,7 +155,7 @@ public void Convert(ReadOnlySpan source, Span destination)
{
ref Cmyk sp = ref Unsafe.Add(ref sourceRef, i);
ref LinearRgb dp = ref Unsafe.Add(ref destRef, i);
- dp = this.ToLinearRgb(sp);
+ dp = ToLinearRgb(sp);
}
}
@@ -166,7 +164,7 @@ public void Convert(ReadOnlySpan source, Span destination)
///
/// The span to the source colors.
/// The span to the destination colors.
- public void Convert(ReadOnlySpan source, Span destination)
+ public static void Convert(ReadOnlySpan source, Span destination)
{
Guard.DestinationShouldNotBeTooShort(source, destination, nameof(destination));
int count = source.Length;
@@ -178,7 +176,7 @@ public void Convert(ReadOnlySpan source, Span destination)
{
ref Hsl sp = ref Unsafe.Add(ref sourceRef, i);
ref LinearRgb dp = ref Unsafe.Add(ref destRef, i);
- dp = this.ToLinearRgb(sp);
+ dp = ToLinearRgb(sp);
}
}
@@ -187,7 +185,7 @@ public void Convert(ReadOnlySpan source, Span destination)
///
/// The span to the source colors.
/// The span to the destination colors.
- public void Convert(ReadOnlySpan source, Span destination)
+ public static void Convert(ReadOnlySpan source, Span destination)
{
Guard.DestinationShouldNotBeTooShort(source, destination, nameof(destination));
int count = source.Length;
@@ -199,7 +197,7 @@ public void Convert(ReadOnlySpan source, Span destination)
{
ref Hsv sp = ref Unsafe.Add(ref sourceRef, i);
ref LinearRgb dp = ref Unsafe.Add(ref destRef, i);
- dp = this.ToLinearRgb(sp);
+ dp = ToLinearRgb(sp);
}
}
@@ -250,7 +248,7 @@ public void Convert(ReadOnlySpan source, Span destination)
///
/// The span to the source colors
/// The span to the destination colors
- public void Convert(ReadOnlySpan source, Span destination)
+ public static void Convert(ReadOnlySpan source, Span destination)
{
Guard.DestinationShouldNotBeTooShort(source, destination, nameof(destination));
int count = source.Length;
@@ -262,7 +260,7 @@ public void Convert(ReadOnlySpan source, Span destination)
{
ref Rgb sp = ref Unsafe.Add(ref sourceRef, i);
ref LinearRgb dp = ref Unsafe.Add(ref destRef, i);
- dp = this.ToLinearRgb(sp);
+ dp = ToLinearRgb(sp);
}
}
@@ -294,7 +292,7 @@ public void Convert(ReadOnlySpan source, Span destination)
/// The
public LinearRgb ToLinearRgb(in CieLab color)
{
- var xyzColor = this.ToCieXyz(color);
+ CieXyz xyzColor = this.ToCieXyz(color);
return this.ToLinearRgb(xyzColor);
}
@@ -305,7 +303,7 @@ public LinearRgb ToLinearRgb(in CieLab color)
/// The
public LinearRgb ToLinearRgb(in CieLch color)
{
- var xyzColor = this.ToCieXyz(color);
+ CieXyz xyzColor = this.ToCieXyz(color);
return this.ToLinearRgb(xyzColor);
}
@@ -316,7 +314,7 @@ public LinearRgb ToLinearRgb(in CieLch color)
/// The
public LinearRgb ToLinearRgb(in CieLchuv color)
{
- var xyzColor = this.ToCieXyz(color);
+ CieXyz xyzColor = this.ToCieXyz(color);
return this.ToLinearRgb(xyzColor);
}
@@ -327,7 +325,7 @@ public LinearRgb ToLinearRgb(in CieLchuv color)
/// The
public LinearRgb ToLinearRgb(in CieLuv color)
{
- var xyzColor = this.ToCieXyz(color);
+ CieXyz xyzColor = this.ToCieXyz(color);
return this.ToLinearRgb(xyzColor);
}
@@ -338,7 +336,7 @@ public LinearRgb ToLinearRgb(in CieLuv color)
/// The
public LinearRgb ToLinearRgb(in CieXyy color)
{
- var xyzColor = this.ToCieXyz(color);
+ CieXyz xyzColor = ToCieXyz(color);
return this.ToLinearRgb(xyzColor);
}
@@ -361,10 +359,10 @@ public LinearRgb ToLinearRgb(in CieXyz color)
///
/// The color to convert.
/// The
- public LinearRgb ToLinearRgb(in Cmyk color)
+ public static LinearRgb ToLinearRgb(in Cmyk color)
{
- var rgb = this.ToRgb(color);
- return this.ToLinearRgb(rgb);
+ Rgb rgb = ToRgb(color);
+ return ToLinearRgb(rgb);
}
///
@@ -372,10 +370,10 @@ public LinearRgb ToLinearRgb(in Cmyk color)
///
/// The color to convert.
/// The
- public LinearRgb ToLinearRgb(in Hsl color)
+ public static LinearRgb ToLinearRgb(in Hsl color)
{
- var rgb = this.ToRgb(color);
- return this.ToLinearRgb(rgb);
+ Rgb rgb = ToRgb(color);
+ return ToLinearRgb(rgb);
}
///
@@ -383,10 +381,10 @@ public LinearRgb ToLinearRgb(in Hsl color)
///
/// The color to convert.
/// The
- public LinearRgb ToLinearRgb(in Hsv color)
+ public static LinearRgb ToLinearRgb(in Hsv color)
{
- var rgb = this.ToRgb(color);
- return this.ToLinearRgb(rgb);
+ Rgb rgb = ToRgb(color);
+ return ToLinearRgb(rgb);
}
///
@@ -396,7 +394,7 @@ public LinearRgb ToLinearRgb(in Hsv color)
/// The
public LinearRgb ToLinearRgb(in HunterLab color)
{
- var xyzColor = this.ToCieXyz(color);
+ CieXyz xyzColor = this.ToCieXyz(color);
return this.ToLinearRgb(xyzColor);
}
@@ -407,7 +405,7 @@ public LinearRgb ToLinearRgb(in HunterLab color)
/// The
public LinearRgb ToLinearRgb(in Lms color)
{
- var xyzColor = this.ToCieXyz(color);
+ CieXyz xyzColor = this.ToCieXyz(color);
return this.ToLinearRgb(xyzColor);
}
@@ -416,11 +414,8 @@ public LinearRgb ToLinearRgb(in Lms color)
///
/// The color to convert.
/// The
- public LinearRgb ToLinearRgb(in Rgb color)
- {
- // Conversion
- return RgbToLinearRgbConverter.Convert(color);
- }
+ public static LinearRgb ToLinearRgb(in Rgb color)
+ => RgbToLinearRgbConverter.Convert(color);
///
/// Converts a into a .
@@ -429,8 +424,8 @@ public LinearRgb ToLinearRgb(in Rgb color)
/// The
public LinearRgb ToLinearRgb(in YCbCr color)
{
- var rgb = this.ToRgb(color);
- return this.ToLinearRgb(rgb);
+ Rgb rgb = this.ToRgb(color);
+ return ToLinearRgb(rgb);
}
}
}
diff --git a/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.Lms.cs b/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.Lms.cs
index be36c46dc3..dbaaa4dd0e 100644
--- a/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.Lms.cs
+++ b/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.Lms.cs
@@ -336,7 +336,7 @@ public Lms ToLms(in CieLuv color)
/// The
public Lms ToLms(in CieXyy color)
{
- var xyzColor = this.ToCieXyz(color);
+ var xyzColor = ToCieXyz(color);
return this.ToLms(xyzColor);
}
diff --git a/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.Rgb.cs b/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.Rgb.cs
index cfb6d3b76b..461ce8c21c 100644
--- a/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.Rgb.cs
+++ b/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.Rgb.cs
@@ -12,8 +12,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
///
public partial class ColorSpaceConverter
{
- private static readonly LinearRgbToRgbConverter LinearRgbToRgbConverter = new LinearRgbToRgbConverter();
-
///
/// Performs the bulk conversion from into
///
@@ -145,7 +143,7 @@ public void Convert(ReadOnlySpan source, Span destination)
///
/// The span to the source colors
/// The span to the destination colors
- public void Convert(ReadOnlySpan source, Span destination)
+ public static void Convert(ReadOnlySpan source, Span destination)
{
Guard.DestinationShouldNotBeTooShort(source, destination, nameof(destination));
int count = source.Length;
@@ -157,7 +155,7 @@ public void Convert(ReadOnlySpan source, Span destination)
{
ref Cmyk sp = ref Unsafe.Add(ref sourceRef, i);
ref Rgb dp = ref Unsafe.Add(ref destRef, i);
- dp = this.ToRgb(sp);
+ dp = ToRgb(sp);
}
}
@@ -166,7 +164,7 @@ public void Convert(ReadOnlySpan source, Span destination)
///
/// The span to the source colors
/// The span to the destination colors
- public void Convert(ReadOnlySpan source, Span destination)
+ public static void Convert(ReadOnlySpan source, Span destination)
{
Guard.DestinationShouldNotBeTooShort(source, destination, nameof(destination));
int count = source.Length;
@@ -178,7 +176,7 @@ public void Convert(ReadOnlySpan source, Span destination)
{
ref Hsv sp = ref Unsafe.Add(ref sourceRef, i);
ref Rgb dp = ref Unsafe.Add(ref destRef, i);
- dp = this.ToRgb(sp);
+ dp = ToRgb(sp);
}
}
@@ -187,7 +185,7 @@ public void Convert(ReadOnlySpan source, Span destination)
///
/// The span to the source colors
/// The span to the destination colors
- public void Convert(ReadOnlySpan source, Span destination)
+ public static void Convert(ReadOnlySpan source, Span destination)
{
Guard.DestinationShouldNotBeTooShort(source, destination, nameof(destination));
int count = source.Length;
@@ -199,7 +197,7 @@ public void Convert(ReadOnlySpan source, Span destination)
{
ref Hsl sp = ref Unsafe.Add(ref sourceRef, i);
ref Rgb dp = ref Unsafe.Add(ref destRef, i);
- dp = this.ToRgb(sp);
+ dp = ToRgb(sp);
}
}
@@ -229,7 +227,7 @@ public void Convert(ReadOnlySpan source, Span destination)
///
/// The span to the source colors
/// The span to the destination colors
- public void Convert(ReadOnlySpan source, Span destination)
+ public static void Convert(ReadOnlySpan source, Span destination)
{
Guard.DestinationShouldNotBeTooShort(source, destination, nameof(destination));
int count = source.Length;
@@ -241,7 +239,7 @@ public void Convert(ReadOnlySpan source, Span destination)
{
ref LinearRgb sp = ref Unsafe.Add(ref sourceRef, i);
ref Rgb dp = ref Unsafe.Add(ref destRef, i);
- dp = this.ToRgb(sp);
+ dp = ToRgb(sp);
}
}
@@ -294,7 +292,7 @@ public void Convert(ReadOnlySpan source, Span destination)
/// The
public Rgb ToRgb(in CieLab color)
{
- var xyzColor = this.ToCieXyz(color);
+ CieXyz xyzColor = this.ToCieXyz(color);
return this.ToRgb(xyzColor);
}
@@ -305,7 +303,7 @@ public Rgb ToRgb(in CieLab color)
/// The
public Rgb ToRgb(in CieLch color)
{
- var xyzColor = this.ToCieXyz(color);
+ CieXyz xyzColor = this.ToCieXyz(color);
return this.ToRgb(xyzColor);
}
@@ -316,7 +314,7 @@ public Rgb ToRgb(in CieLch color)
/// The
public Rgb ToRgb(in CieLchuv color)
{
- var xyzColor = this.ToCieXyz(color);
+ CieXyz xyzColor = this.ToCieXyz(color);
return this.ToRgb(xyzColor);
}
@@ -327,7 +325,7 @@ public Rgb ToRgb(in CieLchuv color)
/// The
public Rgb ToRgb(in CieLuv color)
{
- var xyzColor = this.ToCieXyz(color);
+ CieXyz xyzColor = this.ToCieXyz(color);
return this.ToRgb(xyzColor);
}
@@ -338,7 +336,7 @@ public Rgb ToRgb(in CieLuv color)
/// The
public Rgb ToRgb(in CieXyy color)
{
- var xyzColor = this.ToCieXyz(color);
+ CieXyz xyzColor = ToCieXyz(color);
return this.ToRgb(xyzColor);
}
@@ -350,10 +348,10 @@ public Rgb ToRgb(in CieXyy color)
public Rgb ToRgb(in CieXyz color)
{
// Conversion
- var linear = this.ToLinearRgb(color);
+ LinearRgb linear = this.ToLinearRgb(color);
// Compand
- return this.ToRgb(linear);
+ return ToRgb(linear);
}
///
@@ -361,33 +359,21 @@ public Rgb ToRgb(in CieXyz color)
///
/// The color to convert.
/// The
- public Rgb ToRgb(in Cmyk color)
- {
- // Conversion
- return CmykAndRgbConverter.Convert(color);
- }
+ public static Rgb ToRgb(in Cmyk color) => CmykAndRgbConverter.Convert(color);
///
/// Converts a into a
///
/// The color to convert.
/// The
- public Rgb ToRgb(in Hsv color)
- {
- // Conversion
- return HsvAndRgbConverter.Convert(color);
- }
+ public static Rgb ToRgb(in Hsv color) => HsvAndRgbConverter.Convert(color);
///
/// Converts a into a
///
/// The color to convert.
/// The
- public Rgb ToRgb(in Hsl color)
- {
- // Conversion
- return HslAndRgbConverter.Convert(color);
- }
+ public static Rgb ToRgb(in Hsl color) => HslAndRgbConverter.Convert(color);
///
/// Converts a into a
@@ -396,7 +382,7 @@ public Rgb ToRgb(in Hsl color)
/// The
public Rgb ToRgb(in HunterLab color)
{
- var xyzColor = this.ToCieXyz(color);
+ CieXyz xyzColor = this.ToCieXyz(color);
return this.ToRgb(xyzColor);
}
@@ -405,11 +391,7 @@ public Rgb ToRgb(in HunterLab color)
///
/// The color to convert.
/// The
- public Rgb ToRgb(in LinearRgb color)
- {
- // Conversion
- return LinearRgbToRgbConverter.Convert(color);
- }
+ public static Rgb ToRgb(in LinearRgb color) => LinearRgbToRgbConverter.Convert(color);
///
/// Converts a into a
@@ -418,7 +400,7 @@ public Rgb ToRgb(in LinearRgb color)
/// The
public Rgb ToRgb(in Lms color)
{
- var xyzColor = this.ToCieXyz(color);
+ CieXyz xyzColor = this.ToCieXyz(color);
return this.ToRgb(xyzColor);
}
diff --git a/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.YCbCr.cs b/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.YCbCr.cs
index db6dc21338..48bb8ebd61 100644
--- a/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.YCbCr.cs
+++ b/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.YCbCr.cs
@@ -12,8 +12,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
///
public partial class ColorSpaceConverter
{
- private static readonly YCbCrAndRgbConverter YCbCrAndRgbConverter = new YCbCrAndRgbConverter();
-
///
/// Performs the bulk conversion from into .
///
@@ -124,7 +122,7 @@ public void Convert(ReadOnlySpan source, Span destination)
///
/// The span to the source colors
/// The span to the destination colors
- public void Convert(ReadOnlySpan source, Span destination)
+ public static void Convert(ReadOnlySpan source, Span destination)
{
Guard.DestinationShouldNotBeTooShort(source, destination, nameof(destination));
int count = source.Length;
@@ -136,7 +134,7 @@ public void Convert(ReadOnlySpan source, Span destination)
{
ref Cmyk sp = ref Unsafe.Add(ref sourceRef, i);
ref YCbCr dp = ref Unsafe.Add(ref destRef, i);
- dp = this.ToYCbCr(sp);
+ dp = ToYCbCr(sp);
}
}
@@ -145,7 +143,7 @@ public void Convert(ReadOnlySpan source, Span