diff --git a/.editorconfig b/.editorconfig
index c28089d720..af1e5b44c1 100644
--- a/.editorconfig
+++ b/.editorconfig
@@ -104,8 +104,8 @@ dotnet_style_parentheses_in_relational_binary_operators = always_for_clarity:war
dotnet_style_parentheses_in_other_binary_operators = always_for_clarity:warning
dotnet_style_parentheses_in_other_operators = always_for_clarity:suggestion
# Expression-level preferences
-dotnet_style_object_initializer = true:warning
-dotnet_style_collection_initializer = true:warning
+dotnet_style_object_initializer = true:error
+dotnet_style_collection_initializer = true:error
dotnet_style_explicit_tuple_names = true:warning
dotnet_style_prefer_inferred_tuple_names = true:warning
dotnet_style_prefer_inferred_anonymous_type_member_names = true:warning
@@ -135,9 +135,9 @@ csharp_style_prefer_null_check_over_type_check = true:warning
# 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 = false:warning
-csharp_style_var_when_type_is_apparent = false:warning
-csharp_style_var_elsewhere = false:warning
+csharp_style_var_for_built_in_types = false:error
+csharp_style_var_when_type_is_apparent = false:error
+csharp_style_var_elsewhere = false:error
# Expression-bodied members
csharp_style_expression_bodied_methods = true:warning
csharp_style_expression_bodied_constructors = true:warning
@@ -160,7 +160,7 @@ csharp_style_pattern_local_over_anonymous_function = true:warning
csharp_style_deconstructed_variable_declaration = true:warning
csharp_style_prefer_index_operator = true:warning
csharp_style_prefer_range_operator = true:warning
-csharp_style_implicit_object_creation_when_type_is_apparent = true:warning
+csharp_style_implicit_object_creation_when_type_is_apparent = true:error
# "Null" checking preferences
csharp_style_throw_expression = true:warning
csharp_style_conditional_delegate_call = true:warning
diff --git a/ImageSharp.sln.DotSettings b/ImageSharp.sln.DotSettings
new file mode 100644
index 0000000000..2e9974fe80
--- /dev/null
+++ b/ImageSharp.sln.DotSettings
@@ -0,0 +1,9 @@
+
+ ERROR
+ ERROR
+ ERROR
+ ERROR
+ ERROR
+ UseExplicitType
+ UseExplicitType
+ UseExplicitType
\ No newline at end of file
diff --git a/shared-infrastructure b/shared-infrastructure
index 1dbfb576c8..ec3e588f79 160000
--- a/shared-infrastructure
+++ b/shared-infrastructure
@@ -1 +1 @@
-Subproject commit 1dbfb576c83507645265c79e03369b66cdc0379f
+Subproject commit ec3e588f79d98957d23e40aafc5128e4b8140ed9
diff --git a/src/ImageSharp/Advanced/ParallelExecutionSettings.cs b/src/ImageSharp/Advanced/ParallelExecutionSettings.cs
index fd9692f9ae..f295ddb1b0 100644
--- a/src/ImageSharp/Advanced/ParallelExecutionSettings.cs
+++ b/src/ImageSharp/Advanced/ParallelExecutionSettings.cs
@@ -79,7 +79,7 @@ public ParallelExecutionSettings MultiplyMinimumPixelsPerTask(int multiplier)
{
Guard.MustBeGreaterThan(multiplier, 0, nameof(multiplier));
- return new ParallelExecutionSettings(
+ return new(
this.MaxDegreeOfParallelism,
this.MinimumPixelsProcessedPerTask * multiplier,
this.MemoryAllocator);
@@ -92,6 +92,6 @@ public ParallelExecutionSettings MultiplyMinimumPixelsPerTask(int multiplier)
/// The .
public static ParallelExecutionSettings FromConfiguration(Configuration configuration)
{
- return new ParallelExecutionSettings(configuration.MaxDegreeOfParallelism, configuration.MemoryAllocator);
+ return new(configuration.MaxDegreeOfParallelism, configuration.MemoryAllocator);
}
}
diff --git a/src/ImageSharp/Advanced/ParallelRowIterator.Wrappers.cs b/src/ImageSharp/Advanced/ParallelRowIterator.Wrappers.cs
index a959faa3b6..cbcd12aec2 100644
--- a/src/ImageSharp/Advanced/ParallelRowIterator.Wrappers.cs
+++ b/src/ImageSharp/Advanced/ParallelRowIterator.Wrappers.cs
@@ -139,7 +139,7 @@ public void Invoke(int i)
}
int yMax = Math.Min(yMin + this.stepY, this.maxY);
- var rows = new RowInterval(yMin, yMax);
+ RowInterval rows = new(yMin, yMax);
// Skip the safety copy when invoking a potentially impure method on a readonly field
Unsafe.AsRef(in this.operation).Invoke(in rows);
@@ -185,7 +185,7 @@ public void Invoke(int i)
}
int yMax = Math.Min(yMin + this.stepY, this.maxY);
- var rows = new RowInterval(yMin, yMax);
+ RowInterval rows = new(yMin, yMax);
using IMemoryOwner buffer = this.allocator.Allocate(this.bufferLength);
diff --git a/src/ImageSharp/Advanced/ParallelRowIterator.cs b/src/ImageSharp/Advanced/ParallelRowIterator.cs
index 1284a3a898..b878f9ec0a 100644
--- a/src/ImageSharp/Advanced/ParallelRowIterator.cs
+++ b/src/ImageSharp/Advanced/ParallelRowIterator.cs
@@ -26,7 +26,7 @@ public static partial class ParallelRowIterator
public static void IterateRows(Configuration configuration, Rectangle rectangle, in T operation)
where T : struct, IRowOperation
{
- var parallelSettings = ParallelExecutionSettings.FromConfiguration(configuration);
+ ParallelExecutionSettings parallelSettings = ParallelExecutionSettings.FromConfiguration(configuration);
IterateRows(rectangle, in parallelSettings, in operation);
}
@@ -65,8 +65,8 @@ public static void IterateRows(
}
int verticalStep = DivideCeil(rectangle.Height, numOfSteps);
- var parallelOptions = new ParallelOptions { MaxDegreeOfParallelism = numOfSteps };
- var wrappingOperation = new RowOperationWrapper(top, bottom, verticalStep, in operation);
+ ParallelOptions parallelOptions = new() { MaxDegreeOfParallelism = numOfSteps };
+ RowOperationWrapper wrappingOperation = new(top, bottom, verticalStep, in operation);
Parallel.For(
0,
@@ -88,7 +88,7 @@ public static void IterateRows(Configuration configuration, Rectangl
where T : struct, IRowOperation
where TBuffer : unmanaged
{
- var parallelSettings = ParallelExecutionSettings.FromConfiguration(configuration);
+ ParallelExecutionSettings parallelSettings = ParallelExecutionSettings.FromConfiguration(configuration);
IterateRows(rectangle, in parallelSettings, in operation);
}
@@ -135,8 +135,8 @@ public static void IterateRows(
}
int verticalStep = DivideCeil(height, numOfSteps);
- var parallelOptions = new ParallelOptions { MaxDegreeOfParallelism = numOfSteps };
- var wrappingOperation = new RowOperationWrapper(top, bottom, verticalStep, bufferLength, allocator, in operation);
+ ParallelOptions parallelOptions = new() { MaxDegreeOfParallelism = numOfSteps };
+ RowOperationWrapper wrappingOperation = new(top, bottom, verticalStep, bufferLength, allocator, in operation);
Parallel.For(
0,
@@ -156,7 +156,7 @@ public static void IterateRows(
public static void IterateRowIntervals(Configuration configuration, Rectangle rectangle, in T operation)
where T : struct, IRowIntervalOperation
{
- var parallelSettings = ParallelExecutionSettings.FromConfiguration(configuration);
+ ParallelExecutionSettings parallelSettings = ParallelExecutionSettings.FromConfiguration(configuration);
IterateRowIntervals(rectangle, in parallelSettings, in operation);
}
@@ -186,14 +186,14 @@ public static void IterateRowIntervals(
// Avoid TPL overhead in this trivial case:
if (numOfSteps == 1)
{
- var rows = new RowInterval(top, bottom);
+ RowInterval rows = new(top, bottom);
Unsafe.AsRef(in operation).Invoke(in rows);
return;
}
int verticalStep = DivideCeil(rectangle.Height, numOfSteps);
- var parallelOptions = new ParallelOptions { MaxDegreeOfParallelism = numOfSteps };
- var wrappingOperation = new RowIntervalOperationWrapper(top, bottom, verticalStep, in operation);
+ ParallelOptions parallelOptions = new() { MaxDegreeOfParallelism = numOfSteps };
+ RowIntervalOperationWrapper wrappingOperation = new(top, bottom, verticalStep, in operation);
Parallel.For(
0,
@@ -215,7 +215,7 @@ public static void IterateRowIntervals(Configuration configuration,
where T : struct, IRowIntervalOperation
where TBuffer : unmanaged
{
- var parallelSettings = ParallelExecutionSettings.FromConfiguration(configuration);
+ ParallelExecutionSettings parallelSettings = ParallelExecutionSettings.FromConfiguration(configuration);
IterateRowIntervals(rectangle, in parallelSettings, in operation);
}
@@ -250,7 +250,7 @@ public static void IterateRowIntervals(
// Avoid TPL overhead in this trivial case:
if (numOfSteps == 1)
{
- var rows = new RowInterval(top, bottom);
+ RowInterval rows = new(top, bottom);
using IMemoryOwner buffer = allocator.Allocate(bufferLength);
Unsafe.AsRef(in operation).Invoke(in rows, buffer.Memory.Span);
@@ -259,8 +259,8 @@ public static void IterateRowIntervals(
}
int verticalStep = DivideCeil(height, numOfSteps);
- var parallelOptions = new ParallelOptions { MaxDegreeOfParallelism = numOfSteps };
- var wrappingOperation = new RowIntervalOperationWrapper(top, bottom, verticalStep, bufferLength, allocator, in operation);
+ ParallelOptions parallelOptions = new() { MaxDegreeOfParallelism = numOfSteps };
+ RowIntervalOperationWrapper wrappingOperation = new(top, bottom, verticalStep, bufferLength, allocator, in operation);
Parallel.For(
0,
diff --git a/src/ImageSharp/Color/Color.WebSafePalette.cs b/src/ImageSharp/Color/Color.WebSafePalette.cs
index feb4a8659d..bd17d9a76c 100644
--- a/src/ImageSharp/Color/Color.WebSafePalette.cs
+++ b/src/ImageSharp/Color/Color.WebSafePalette.cs
@@ -8,15 +8,15 @@ namespace SixLabors.ImageSharp;
///
public partial struct Color
{
- private static readonly Lazy WebSafePaletteLazy = new Lazy(CreateWebSafePalette, true);
+ private static readonly Lazy WebSafePaletteLazy = new(CreateWebSafePalette, true);
///
/// Gets a collection of named, web safe colors as defined in the CSS Color Module Level 4.
///
public static ReadOnlyMemory WebSafePalette => WebSafePaletteLazy.Value;
- private static Color[] CreateWebSafePalette() => new[]
- {
+ private static Color[] CreateWebSafePalette() =>
+ [
AliceBlue,
AntiqueWhite,
Aqua,
@@ -159,5 +159,5 @@ private static Color[] CreateWebSafePalette() => new[]
WhiteSmoke,
Yellow,
YellowGreen
- };
+ ];
}
diff --git a/src/ImageSharp/Color/Color.WernerPalette.cs b/src/ImageSharp/Color/Color.WernerPalette.cs
index 1058da6547..583c71379f 100644
--- a/src/ImageSharp/Color/Color.WernerPalette.cs
+++ b/src/ImageSharp/Color/Color.WernerPalette.cs
@@ -8,7 +8,7 @@ namespace SixLabors.ImageSharp;
///
public partial struct Color
{
- private static readonly Lazy WernerPaletteLazy = new Lazy(CreateWernerPalette, true);
+ private static readonly Lazy WernerPaletteLazy = new(CreateWernerPalette, true);
///
/// Gets a collection of colors as defined in the original second edition of Werner’s Nomenclature of Colours 1821.
@@ -16,8 +16,8 @@ public partial struct Color
///
public static ReadOnlyMemory WernerPalette => WernerPaletteLazy.Value;
- private static Color[] CreateWernerPalette() => new[]
- {
+ private static Color[] CreateWernerPalette() =>
+ [
ParseHex("#f1e9cd"),
ParseHex("#f2e7cf"),
ParseHex("#ece6d0"),
@@ -128,5 +128,5 @@ private static Color[] CreateWernerPalette() => new[]
ParseHex("#9b856b"),
ParseHex("#766051"),
ParseHex("#453b32")
- };
+ ];
}
diff --git a/src/ImageSharp/ColorProfiles/CieLab.cs b/src/ImageSharp/ColorProfiles/CieLab.cs
index 377cc20a99..fdcceee66c 100644
--- a/src/ImageSharp/ColorProfiles/CieLab.cs
+++ b/src/ImageSharp/ColorProfiles/CieLab.cs
@@ -103,7 +103,7 @@ public static CieLab FromProfileConnectingSpace(ColorConversionOptions options,
float a = 500F * (fx - fy);
float b = 200F * (fy - fz);
- return new CieLab(l, a, b);
+ return new(l, a, b);
}
///
diff --git a/src/ImageSharp/ColorProfiles/CieLch.cs b/src/ImageSharp/ColorProfiles/CieLch.cs
index 1319783406..976d77c1e2 100644
--- a/src/ImageSharp/ColorProfiles/CieLch.cs
+++ b/src/ImageSharp/ColorProfiles/CieLch.cs
@@ -25,7 +25,7 @@ namespace SixLabors.ImageSharp.ColorProfiles;
/// The hue in degrees.
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public CieLch(float l, float c, float h)
- : this(new Vector3(l, c, h))
+ : this(new(l, c, h))
{
}
@@ -101,7 +101,7 @@ public static CieLch FromProfileConnectingSpace(ColorConversionOptions options,
hDegrees += 360;
}
- return new CieLch(l, c, hDegrees);
+ return new(l, c, hDegrees);
}
///
@@ -127,7 +127,7 @@ public CieLab ToProfileConnectingSpace(ColorConversionOptions options)
float a = c * MathF.Cos(hRadians);
float b = c * MathF.Sin(hRadians);
- return new CieLab(l, a, b);
+ return new(l, a, b);
}
///
diff --git a/src/ImageSharp/ColorProfiles/CieLchuv.cs b/src/ImageSharp/ColorProfiles/CieLchuv.cs
index 7fd95feb19..29307dc807 100644
--- a/src/ImageSharp/ColorProfiles/CieLchuv.cs
+++ b/src/ImageSharp/ColorProfiles/CieLchuv.cs
@@ -25,7 +25,7 @@ namespace SixLabors.ImageSharp.ColorProfiles;
/// The hue in degrees.
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public CieLchuv(float l, float c, float h)
- : this(new Vector3(l, c, h))
+ : this(new(l, c, h))
{
}
@@ -102,7 +102,7 @@ public static CieLchuv FromProfileConnectingSpace(ColorConversionOptions options
hDegrees += 360;
}
- return new CieLchuv(l, c, hDegrees);
+ return new(l, c, hDegrees);
}
///
diff --git a/src/ImageSharp/ColorProfiles/CieLuv.cs b/src/ImageSharp/ColorProfiles/CieLuv.cs
index 97e2826f74..846ccfa841 100644
--- a/src/ImageSharp/ColorProfiles/CieLuv.cs
+++ b/src/ImageSharp/ColorProfiles/CieLuv.cs
@@ -123,7 +123,7 @@ public static CieLuv FromProfileConnectingSpace(ColorConversionOptions options,
v = 0;
}
- return new CieLuv((float)l, (float)u, (float)v);
+ return new((float)l, (float)u, (float)v);
}
///
@@ -177,7 +177,7 @@ public CieXyz ToProfileConnectingSpace(ColorConversionOptions options)
z = 0;
}
- return new CieXyz((float)x, (float)y, (float)z);
+ return new((float)x, (float)y, (float)z);
}
///
diff --git a/src/ImageSharp/ColorProfiles/CieXyy.cs b/src/ImageSharp/ColorProfiles/CieXyy.cs
index 62873df147..7ab2bcd9b0 100644
--- a/src/ImageSharp/ColorProfiles/CieXyy.cs
+++ b/src/ImageSharp/ColorProfiles/CieXyy.cs
@@ -91,10 +91,10 @@ public static CieXyy FromProfileConnectingSpace(ColorConversionOptions options,
if (float.IsNaN(x) || float.IsNaN(y))
{
- return new CieXyy(0, 0, source.Y);
+ return new(0, 0, source.Y);
}
- return new CieXyy(x, y, source.Y);
+ return new(x, y, source.Y);
}
///
@@ -113,14 +113,14 @@ public CieXyz ToProfileConnectingSpace(ColorConversionOptions options)
{
if (MathF.Abs(this.Y) < Constants.Epsilon)
{
- return new CieXyz(0, 0, this.Yl);
+ return new(0, 0, this.Yl);
}
float x = (this.X * this.Yl) / this.Y;
float y = this.Yl;
float z = ((1 - this.X - this.Y) * y) / this.Y;
- return new CieXyz(x, y, z);
+ return new(x, y, z);
}
///
diff --git a/src/ImageSharp/ColorProfiles/Cmyk.cs b/src/ImageSharp/ColorProfiles/Cmyk.cs
index e924904497..3313ab54cb 100644
--- a/src/ImageSharp/ColorProfiles/Cmyk.cs
+++ b/src/ImageSharp/ColorProfiles/Cmyk.cs
@@ -25,7 +25,7 @@ namespace SixLabors.ImageSharp.ColorProfiles;
/// The keyline black component.
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public Cmyk(float c, float m, float y, float k)
- : this(new Vector4(c, m, y, k))
+ : this(new(c, m, y, k))
{
}
@@ -100,12 +100,12 @@ public static Cmyk FromProfileConnectingSpace(ColorConversionOptions options, in
if (MathF.Abs(k.X - 1F) < Constants.Epsilon)
{
- return new Cmyk(0, 0, 0, 1F);
+ return new(0, 0, 0, 1F);
}
cmy = (cmy - k) / (Vector3.One - k);
- return new Cmyk(cmy.X, cmy.Y, cmy.Z, k.X);
+ return new(cmy.X, cmy.Y, cmy.Z, k.X);
}
///
diff --git a/src/ImageSharp/ColorProfiles/Hsl.cs b/src/ImageSharp/ColorProfiles/Hsl.cs
index 2c98c7df99..189d3b9347 100644
--- a/src/ImageSharp/ColorProfiles/Hsl.cs
+++ b/src/ImageSharp/ColorProfiles/Hsl.cs
@@ -24,7 +24,7 @@ namespace SixLabors.ImageSharp.ColorProfiles;
/// The l value (lightness) component.
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public Hsl(float h, float s, float l)
- : this(new Vector3(h, s, l))
+ : this(new(h, s, l))
{
}
@@ -99,7 +99,7 @@ public static Hsl FromProfileConnectingSpace(ColorConversionOptions options, in
if (MathF.Abs(chroma) < Constants.Epsilon)
{
- return new Hsl(0F, s, l);
+ return new(0F, s, l);
}
if (MathF.Abs(r - max) < Constants.Epsilon)
@@ -130,7 +130,7 @@ public static Hsl FromProfileConnectingSpace(ColorConversionOptions options, in
s = chroma / (2F - max - min);
}
- return new Hsl(h, s, l);
+ return new(h, s, l);
}
///
@@ -171,7 +171,7 @@ public Rgb ToProfileConnectingSpace(ColorConversionOptions options)
}
}
- return new Rgb(r, g, b);
+ return new(r, g, b);
}
///
diff --git a/src/ImageSharp/ColorProfiles/Hsv.cs b/src/ImageSharp/ColorProfiles/Hsv.cs
index 7535f2463d..4e4b0efca5 100644
--- a/src/ImageSharp/ColorProfiles/Hsv.cs
+++ b/src/ImageSharp/ColorProfiles/Hsv.cs
@@ -24,7 +24,7 @@ namespace SixLabors.ImageSharp.ColorProfiles;
/// The v value (brightness) component.
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public Hsv(float h, float s, float v)
- : this(new Vector3(h, s, v))
+ : this(new(h, s, v))
{
}
@@ -97,7 +97,7 @@ public static Hsv FromProfileConnectingSpace(ColorConversionOptions options, in
if (MathF.Abs(chroma) < Constants.Epsilon)
{
- return new Hsv(0, s, v);
+ return new(0, s, v);
}
if (MathF.Abs(r - max) < Constants.Epsilon)
@@ -121,7 +121,7 @@ public static Hsv FromProfileConnectingSpace(ColorConversionOptions options, in
s = chroma / v;
- return new Hsv(h, s, v);
+ return new(h, s, v);
}
///
@@ -143,7 +143,7 @@ public Rgb ToProfileConnectingSpace(ColorConversionOptions options)
if (MathF.Abs(s) < Constants.Epsilon)
{
- return new Rgb(v, v, v);
+ return new(v, v, v);
}
float h = (MathF.Abs(this.H - 360) < Constants.Epsilon) ? 0 : this.H / 60;
@@ -194,7 +194,7 @@ public Rgb ToProfileConnectingSpace(ColorConversionOptions options)
break;
}
- return new Rgb(r, g, b);
+ return new(r, g, b);
}
///
diff --git a/src/ImageSharp/ColorProfiles/HunterLab.cs b/src/ImageSharp/ColorProfiles/HunterLab.cs
index 43ad2ac5c0..e1c5330c0a 100644
--- a/src/ImageSharp/ColorProfiles/HunterLab.cs
+++ b/src/ImageSharp/ColorProfiles/HunterLab.cs
@@ -108,7 +108,7 @@ public static HunterLab FromProfileConnectingSpace(ColorConversionOptions option
b = 0;
}
- return new HunterLab(l, a, b);
+ return new(l, a, b);
}
///
@@ -141,7 +141,7 @@ public CieXyz ToProfileConnectingSpace(ColorConversionOptions options)
float x = (((a / ka) * sqrtPow) + pow) * xn;
float z = (((b / kb) * sqrtPow) - pow) * (-zn);
- return new CieXyz(x, y, z);
+ return new(x, y, z);
}
///
diff --git a/src/ImageSharp/ColorProfiles/KnownChromaticAdaptationMatrices.cs b/src/ImageSharp/ColorProfiles/KnownChromaticAdaptationMatrices.cs
index 71d565f87f..a5486580fd 100644
--- a/src/ImageSharp/ColorProfiles/KnownChromaticAdaptationMatrices.cs
+++ b/src/ImageSharp/ColorProfiles/KnownChromaticAdaptationMatrices.cs
@@ -24,7 +24,7 @@ public static class KnownChromaticAdaptationMatrices
/// von Kries chromatic adaptation transform matrix (Hunt-Pointer-Estevez adjusted for D65)
///
public static readonly Matrix4x4 VonKriesHPEAdjusted
- = Matrix4x4.Transpose(new Matrix4x4
+ = Matrix4x4.Transpose(new()
{
M11 = 0.40024F,
M12 = 0.7076F,
@@ -42,7 +42,7 @@ public static readonly Matrix4x4 VonKriesHPEAdjusted
/// von Kries chromatic adaptation transform matrix (Hunt-Pointer-Estevez for equal energy)
///
public static readonly Matrix4x4 VonKriesHPE
- = Matrix4x4.Transpose(new Matrix4x4
+ = Matrix4x4.Transpose(new()
{
M11 = 0.3897F,
M12 = 0.6890F,
@@ -65,7 +65,7 @@ public static readonly Matrix4x4 VonKriesHPE
/// Bradford chromatic adaptation transform matrix (used in CMCCAT97)
///
public static readonly Matrix4x4 Bradford
- = Matrix4x4.Transpose(new Matrix4x4
+ = Matrix4x4.Transpose(new()
{
M11 = 0.8951F,
M12 = 0.2664F,
@@ -83,7 +83,7 @@ public static readonly Matrix4x4 Bradford
/// Spectral sharpening and the Bradford transform
///
public static readonly Matrix4x4 BradfordSharp
- = Matrix4x4.Transpose(new Matrix4x4
+ = Matrix4x4.Transpose(new()
{
M11 = 1.2694F,
M12 = -0.0988F,
@@ -101,7 +101,7 @@ public static readonly Matrix4x4 BradfordSharp
/// CMCCAT2000 (fitted from all available color data sets)
///
public static readonly Matrix4x4 CMCCAT2000
- = Matrix4x4.Transpose(new Matrix4x4
+ = Matrix4x4.Transpose(new()
{
M11 = 0.7982F,
M12 = 0.3389F,
@@ -119,7 +119,7 @@ public static readonly Matrix4x4 CMCCAT2000
/// CAT02 (optimized for minimizing CIELAB differences)
///
public static readonly Matrix4x4 CAT02
- = Matrix4x4.Transpose(new Matrix4x4
+ = Matrix4x4.Transpose(new()
{
M11 = 0.7328F,
M12 = 0.4296F,
diff --git a/src/ImageSharp/ColorProfiles/KnownRgbWorkingSpaces.cs b/src/ImageSharp/ColorProfiles/KnownRgbWorkingSpaces.cs
index 9163839363..1c5f1664c9 100644
--- a/src/ImageSharp/ColorProfiles/KnownRgbWorkingSpaces.cs
+++ b/src/ImageSharp/ColorProfiles/KnownRgbWorkingSpaces.cs
@@ -18,96 +18,96 @@ public static class KnownRgbWorkingSpaces
/// Uses proper companding function, according to:
///
///
- public static readonly RgbWorkingSpace SRgb = new SRgbWorkingSpace(KnownIlluminants.D65, new RgbPrimariesChromaticityCoordinates(new CieXyChromaticityCoordinates(0.6400F, 0.3300F), new CieXyChromaticityCoordinates(0.3000F, 0.6000F), new CieXyChromaticityCoordinates(0.1500F, 0.0600F)));
+ public static readonly RgbWorkingSpace SRgb = new SRgbWorkingSpace(KnownIlluminants.D65, new(new(0.6400F, 0.3300F), new(0.3000F, 0.6000F), new(0.1500F, 0.0600F)));
///
/// Simplified sRgb working space (uses gamma companding instead of ).
/// See also .
///
- public static readonly RgbWorkingSpace SRgbSimplified = new GammaWorkingSpace(2.2F, KnownIlluminants.D65, new RgbPrimariesChromaticityCoordinates(new CieXyChromaticityCoordinates(0.6400F, 0.3300F), new CieXyChromaticityCoordinates(0.3000F, 0.6000F), new CieXyChromaticityCoordinates(0.1500F, 0.0600F)));
+ public static readonly RgbWorkingSpace SRgbSimplified = new GammaWorkingSpace(2.2F, KnownIlluminants.D65, new(new(0.6400F, 0.3300F), new(0.3000F, 0.6000F), new(0.1500F, 0.0600F)));
///
/// Rec. 709 (ITU-R Recommendation BT.709) working space.
///
- public static readonly RgbWorkingSpace Rec709 = new Rec709WorkingSpace(KnownIlluminants.D65, new RgbPrimariesChromaticityCoordinates(new CieXyChromaticityCoordinates(0.64F, 0.33F), new CieXyChromaticityCoordinates(0.30F, 0.60F), new CieXyChromaticityCoordinates(0.15F, 0.06F)));
+ public static readonly RgbWorkingSpace Rec709 = new Rec709WorkingSpace(KnownIlluminants.D65, new(new(0.64F, 0.33F), new(0.30F, 0.60F), new(0.15F, 0.06F)));
///
/// Rec. 2020 (ITU-R Recommendation BT.2020F) working space.
///
- public static readonly RgbWorkingSpace Rec2020 = new Rec2020WorkingSpace(KnownIlluminants.D65, new RgbPrimariesChromaticityCoordinates(new CieXyChromaticityCoordinates(0.708F, 0.292F), new CieXyChromaticityCoordinates(0.170F, 0.797F), new CieXyChromaticityCoordinates(0.131F, 0.046F)));
+ public static readonly RgbWorkingSpace Rec2020 = new Rec2020WorkingSpace(KnownIlluminants.D65, new(new(0.708F, 0.292F), new(0.170F, 0.797F), new(0.131F, 0.046F)));
///
/// ECI Rgb v2 working space.
///
- public static readonly RgbWorkingSpace ECIRgbv2 = new LWorkingSpace(KnownIlluminants.D50, new RgbPrimariesChromaticityCoordinates(new CieXyChromaticityCoordinates(0.6700F, 0.3300F), new CieXyChromaticityCoordinates(0.2100F, 0.7100F), new CieXyChromaticityCoordinates(0.1400F, 0.0800F)));
+ public static readonly RgbWorkingSpace ECIRgbv2 = new LWorkingSpace(KnownIlluminants.D50, new(new(0.6700F, 0.3300F), new(0.2100F, 0.7100F), new(0.1400F, 0.0800F)));
///
/// Adobe Rgb (1998) working space.
///
- public static readonly RgbWorkingSpace AdobeRgb1998 = new GammaWorkingSpace(2.2F, KnownIlluminants.D65, new RgbPrimariesChromaticityCoordinates(new CieXyChromaticityCoordinates(0.6400F, 0.3300F), new CieXyChromaticityCoordinates(0.2100F, 0.7100F), new CieXyChromaticityCoordinates(0.1500F, 0.0600F)));
+ public static readonly RgbWorkingSpace AdobeRgb1998 = new GammaWorkingSpace(2.2F, KnownIlluminants.D65, new(new(0.6400F, 0.3300F), new(0.2100F, 0.7100F), new(0.1500F, 0.0600F)));
///
/// Apple sRgb working space.
///
- public static readonly RgbWorkingSpace ApplesRgb = new GammaWorkingSpace(1.8F, KnownIlluminants.D65, new RgbPrimariesChromaticityCoordinates(new CieXyChromaticityCoordinates(0.6250F, 0.3400F), new CieXyChromaticityCoordinates(0.2800F, 0.5950F), new CieXyChromaticityCoordinates(0.1550F, 0.0700F)));
+ public static readonly RgbWorkingSpace ApplesRgb = new GammaWorkingSpace(1.8F, KnownIlluminants.D65, new(new(0.6250F, 0.3400F), new(0.2800F, 0.5950F), new(0.1550F, 0.0700F)));
///
/// Best Rgb working space.
///
- public static readonly RgbWorkingSpace BestRgb = new GammaWorkingSpace(2.2F, KnownIlluminants.D50, new RgbPrimariesChromaticityCoordinates(new CieXyChromaticityCoordinates(0.7347F, 0.2653F), new CieXyChromaticityCoordinates(0.2150F, 0.7750F), new CieXyChromaticityCoordinates(0.1300F, 0.0350F)));
+ public static readonly RgbWorkingSpace BestRgb = new GammaWorkingSpace(2.2F, KnownIlluminants.D50, new(new(0.7347F, 0.2653F), new(0.2150F, 0.7750F), new(0.1300F, 0.0350F)));
///
/// Beta Rgb working space.
///
- public static readonly RgbWorkingSpace BetaRgb = new GammaWorkingSpace(2.2F, KnownIlluminants.D50, new RgbPrimariesChromaticityCoordinates(new CieXyChromaticityCoordinates(0.6888F, 0.3112F), new CieXyChromaticityCoordinates(0.1986F, 0.7551F), new CieXyChromaticityCoordinates(0.1265F, 0.0352F)));
+ public static readonly RgbWorkingSpace BetaRgb = new GammaWorkingSpace(2.2F, KnownIlluminants.D50, new(new(0.6888F, 0.3112F), new(0.1986F, 0.7551F), new(0.1265F, 0.0352F)));
///
/// Bruce Rgb working space.
///
- public static readonly RgbWorkingSpace BruceRgb = new GammaWorkingSpace(2.2F, KnownIlluminants.D65, new RgbPrimariesChromaticityCoordinates(new CieXyChromaticityCoordinates(0.6400F, 0.3300F), new CieXyChromaticityCoordinates(0.2800F, 0.6500F), new CieXyChromaticityCoordinates(0.1500F, 0.0600F)));
+ public static readonly RgbWorkingSpace BruceRgb = new GammaWorkingSpace(2.2F, KnownIlluminants.D65, new(new(0.6400F, 0.3300F), new(0.2800F, 0.6500F), new(0.1500F, 0.0600F)));
///
/// CIE Rgb working space.
///
- public static readonly RgbWorkingSpace CIERgb = new GammaWorkingSpace(2.2F, KnownIlluminants.E, new RgbPrimariesChromaticityCoordinates(new CieXyChromaticityCoordinates(0.7350F, 0.2650F), new CieXyChromaticityCoordinates(0.2740F, 0.7170F), new CieXyChromaticityCoordinates(0.1670F, 0.0090F)));
+ public static readonly RgbWorkingSpace CIERgb = new GammaWorkingSpace(2.2F, KnownIlluminants.E, new(new(0.7350F, 0.2650F), new(0.2740F, 0.7170F), new(0.1670F, 0.0090F)));
///
/// ColorMatch Rgb working space.
///
- public static readonly RgbWorkingSpace ColorMatchRgb = new GammaWorkingSpace(1.8F, KnownIlluminants.D50, new RgbPrimariesChromaticityCoordinates(new CieXyChromaticityCoordinates(0.6300F, 0.3400F), new CieXyChromaticityCoordinates(0.2950F, 0.6050F), new CieXyChromaticityCoordinates(0.1500F, 0.0750F)));
+ public static readonly RgbWorkingSpace ColorMatchRgb = new GammaWorkingSpace(1.8F, KnownIlluminants.D50, new(new(0.6300F, 0.3400F), new(0.2950F, 0.6050F), new(0.1500F, 0.0750F)));
///
/// Don Rgb 4 working space.
///
- public static readonly RgbWorkingSpace DonRgb4 = new GammaWorkingSpace(2.2F, KnownIlluminants.D50, new RgbPrimariesChromaticityCoordinates(new CieXyChromaticityCoordinates(0.6960F, 0.3000F), new CieXyChromaticityCoordinates(0.2150F, 0.7650F), new CieXyChromaticityCoordinates(0.1300F, 0.0350F)));
+ public static readonly RgbWorkingSpace DonRgb4 = new GammaWorkingSpace(2.2F, KnownIlluminants.D50, new(new(0.6960F, 0.3000F), new(0.2150F, 0.7650F), new(0.1300F, 0.0350F)));
///
/// Ekta Space PS5 working space.
///
- public static readonly RgbWorkingSpace EktaSpacePS5 = new GammaWorkingSpace(2.2F, KnownIlluminants.D50, new RgbPrimariesChromaticityCoordinates(new CieXyChromaticityCoordinates(0.6950F, 0.3050F), new CieXyChromaticityCoordinates(0.2600F, 0.7000F), new CieXyChromaticityCoordinates(0.1100F, 0.0050F)));
+ public static readonly RgbWorkingSpace EktaSpacePS5 = new GammaWorkingSpace(2.2F, KnownIlluminants.D50, new(new(0.6950F, 0.3050F), new(0.2600F, 0.7000F), new(0.1100F, 0.0050F)));
///
/// NTSC Rgb working space.
///
- public static readonly RgbWorkingSpace NTSCRgb = new GammaWorkingSpace(2.2F, KnownIlluminants.C, new RgbPrimariesChromaticityCoordinates(new CieXyChromaticityCoordinates(0.6700F, 0.3300F), new CieXyChromaticityCoordinates(0.2100F, 0.7100F), new CieXyChromaticityCoordinates(0.1400F, 0.0800F)));
+ public static readonly RgbWorkingSpace NTSCRgb = new GammaWorkingSpace(2.2F, KnownIlluminants.C, new(new(0.6700F, 0.3300F), new(0.2100F, 0.7100F), new(0.1400F, 0.0800F)));
///
/// PAL/SECAM Rgb working space.
///
- public static readonly RgbWorkingSpace PALSECAMRgb = new GammaWorkingSpace(2.2F, KnownIlluminants.D65, new RgbPrimariesChromaticityCoordinates(new CieXyChromaticityCoordinates(0.6400F, 0.3300F), new CieXyChromaticityCoordinates(0.2900F, 0.6000F), new CieXyChromaticityCoordinates(0.1500F, 0.0600F)));
+ public static readonly RgbWorkingSpace PALSECAMRgb = new GammaWorkingSpace(2.2F, KnownIlluminants.D65, new(new(0.6400F, 0.3300F), new(0.2900F, 0.6000F), new(0.1500F, 0.0600F)));
///
/// ProPhoto Rgb working space.
///
- public static readonly RgbWorkingSpace ProPhotoRgb = new GammaWorkingSpace(1.8F, KnownIlluminants.D50, new RgbPrimariesChromaticityCoordinates(new CieXyChromaticityCoordinates(0.7347F, 0.2653F), new CieXyChromaticityCoordinates(0.1596F, 0.8404F), new CieXyChromaticityCoordinates(0.0366F, 0.0001F)));
+ public static readonly RgbWorkingSpace ProPhotoRgb = new GammaWorkingSpace(1.8F, KnownIlluminants.D50, new(new(0.7347F, 0.2653F), new(0.1596F, 0.8404F), new(0.0366F, 0.0001F)));
///
/// SMPTE-C Rgb working space.
///
- public static readonly RgbWorkingSpace SMPTECRgb = new GammaWorkingSpace(2.2F, KnownIlluminants.D65, new RgbPrimariesChromaticityCoordinates(new CieXyChromaticityCoordinates(0.6300F, 0.3400F), new CieXyChromaticityCoordinates(0.3100F, 0.5950F), new CieXyChromaticityCoordinates(0.1550F, 0.0700F)));
+ public static readonly RgbWorkingSpace SMPTECRgb = new GammaWorkingSpace(2.2F, KnownIlluminants.D65, new(new(0.6300F, 0.3400F), new(0.3100F, 0.5950F), new(0.1550F, 0.0700F)));
///
/// Wide Gamut Rgb working space.
///
- public static readonly RgbWorkingSpace WideGamutRgb = new GammaWorkingSpace(2.2F, KnownIlluminants.D50, new RgbPrimariesChromaticityCoordinates(new CieXyChromaticityCoordinates(0.7350F, 0.2650F), new CieXyChromaticityCoordinates(0.1150F, 0.8260F), new CieXyChromaticityCoordinates(0.1570F, 0.0180F)));
+ public static readonly RgbWorkingSpace WideGamutRgb = new GammaWorkingSpace(2.2F, KnownIlluminants.D50, new(new(0.7350F, 0.2650F), new(0.1150F, 0.8260F), new(0.1570F, 0.0180F)));
}
diff --git a/src/ImageSharp/ColorProfiles/Lms.cs b/src/ImageSharp/ColorProfiles/Lms.cs
index 5a6791b2d7..707b5f9f1f 100644
--- a/src/ImageSharp/ColorProfiles/Lms.cs
+++ b/src/ImageSharp/ColorProfiles/Lms.cs
@@ -93,7 +93,7 @@ public Lms(Vector3 vector)
public static Lms FromProfileConnectingSpace(ColorConversionOptions options, in CieXyz source)
{
Vector3 vector = Vector3.Transform(source.ToVector3(), options.AdaptationMatrix);
- return new Lms(vector);
+ return new(vector);
}
///
@@ -112,7 +112,7 @@ public static void FromProfileConnectionSpace(ColorConversionOptions options, Re
public CieXyz ToProfileConnectingSpace(ColorConversionOptions options)
{
Vector3 vector = Vector3.Transform(this.ToVector3(), options.InverseAdaptationMatrix);
- return new CieXyz(vector);
+ return new(vector);
}
///
diff --git a/src/ImageSharp/ColorProfiles/Rgb.cs b/src/ImageSharp/ColorProfiles/Rgb.cs
index 6698e12cb8..3d75b85ba4 100644
--- a/src/ImageSharp/ColorProfiles/Rgb.cs
+++ b/src/ImageSharp/ColorProfiles/Rgb.cs
@@ -111,7 +111,7 @@ public CieXyz ToProfileConnectingSpace(ColorConversionOptions options)
Rgb linear = FromScaledVector4(options.RgbWorkingSpace.Expand(this.ToScaledVector4()));
// Then convert to xyz
- return new CieXyz(Vector3.Transform(linear.ToScaledVector3(), GetRgbToCieXyzMatrix(options.RgbWorkingSpace)));
+ return new(Vector3.Transform(linear.ToScaledVector3(), GetRgbToCieXyzMatrix(options.RgbWorkingSpace)));
}
///
@@ -128,7 +128,7 @@ public static void ToProfileConnectionSpace(ColorConversionOptions options, Read
Rgb linear = FromScaledVector4(options.RgbWorkingSpace.Expand(rgb.ToScaledVector4()));
// Then convert to xyz
- destination[i] = new CieXyz(Vector3.Transform(linear.ToScaledVector3(), matrix));
+ destination[i] = new(Vector3.Transform(linear.ToScaledVector3(), matrix));
}
}
@@ -252,7 +252,7 @@ private static Matrix4x4 GetRgbToCieXyzMatrix(RgbWorkingSpace workingSpace)
Vector3 vector = Vector3.Transform(workingSpace.WhitePoint.ToVector3(), inverseXyzMatrix);
// Use transposed Rows/Columns
- return new Matrix4x4
+ return new()
{
M11 = vector.X * mXr,
M21 = vector.Y * mXg,
diff --git a/src/ImageSharp/ColorProfiles/VonKriesChromaticAdaptation.cs b/src/ImageSharp/ColorProfiles/VonKriesChromaticAdaptation.cs
index 2f9a52912e..665c08904a 100644
--- a/src/ImageSharp/ColorProfiles/VonKriesChromaticAdaptation.cs
+++ b/src/ImageSharp/ColorProfiles/VonKriesChromaticAdaptation.cs
@@ -42,7 +42,7 @@ public static CieXyz Transform(in CieXyz source, (CieXyz From, CieXyz To) whiteP
Vector3 targetColorLms = Vector3.Multiply(vector, sourceColorLms);
Matrix4x4.Invert(matrix, out Matrix4x4 inverseMatrix);
- return new CieXyz(Vector3.Transform(targetColorLms, inverseMatrix));
+ return new(Vector3.Transform(targetColorLms, inverseMatrix));
}
///
@@ -89,7 +89,7 @@ public static void Transform(
Vector3 sourceColorLms = Vector3.Transform(sp.ToVector3(), matrix);
Vector3 targetColorLms = Vector3.Multiply(vector, sourceColorLms);
- dp = new CieXyz(Vector3.Transform(targetColorLms, inverseMatrix));
+ dp = new(Vector3.Transform(targetColorLms, inverseMatrix));
}
}
}
diff --git a/src/ImageSharp/ColorProfiles/YCbCr.cs b/src/ImageSharp/ColorProfiles/YCbCr.cs
index 03bd1d3120..a9cfa5a73c 100644
--- a/src/ImageSharp/ColorProfiles/YCbCr.cs
+++ b/src/ImageSharp/ColorProfiles/YCbCr.cs
@@ -26,7 +26,7 @@ namespace SixLabors.ImageSharp.ColorProfiles;
/// The cr chroma component.
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public YCbCr(float y, float cb, float cr)
- : this(new Vector3(y, cb, cr))
+ : this(new(y, cb, cr))
{
}
@@ -94,7 +94,7 @@ public static YCbCr FromProfileConnectingSpace(ColorConversionOptions options, i
float cb = 128F + ((-0.168736F * r) - (0.331264F * g) + (0.5F * b));
float cr = 128F + ((0.5F * r) - (0.418688F * g) - (0.081312F * b));
- return new YCbCr(y, cb, cr);
+ return new(y, cb, cr);
}
///
diff --git a/src/ImageSharp/Common/Extensions/ConfigurationExtensions.cs b/src/ImageSharp/Common/Extensions/ConfigurationExtensions.cs
index 6ed83a0d8a..c20c6e9c93 100644
--- a/src/ImageSharp/Common/Extensions/ConfigurationExtensions.cs
+++ b/src/ImageSharp/Common/Extensions/ConfigurationExtensions.cs
@@ -14,6 +14,6 @@ internal static class ConfigurationExtensions
///
public static ParallelOptions GetParallelOptions(this Configuration configuration)
{
- return new ParallelOptions { MaxDegreeOfParallelism = configuration.MaxDegreeOfParallelism };
+ return new() { MaxDegreeOfParallelism = configuration.MaxDegreeOfParallelism };
}
}
diff --git a/src/ImageSharp/Common/Helpers/HexConverter.cs b/src/ImageSharp/Common/Helpers/HexConverter.cs
index 8c473688f3..a6face960e 100644
--- a/src/ImageSharp/Common/Helpers/HexConverter.cs
+++ b/src/ImageSharp/Common/Helpers/HexConverter.cs
@@ -35,8 +35,8 @@ static int FromChar(int c)
{
// Map from an ASCII char to its hex value, e.g. arr['b'] == 11. 0xFF means it's not a hex digit.
// This doesn't actually allocate.
- ReadOnlySpan charToHexLookup = new byte[]
- {
+ ReadOnlySpan charToHexLookup =
+ [
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // 15
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // 31
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // 47
@@ -52,8 +52,8 @@ static int FromChar(int c)
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // 207
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // 223
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // 239
- 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // 255
- };
+ 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF // 255
+ ];
return (uint)c >= (uint)charToHexLookup.Length ? 0xFF : charToHexLookup[c];
}
diff --git a/src/ImageSharp/Common/Helpers/Numerics.cs b/src/ImageSharp/Common/Helpers/Numerics.cs
index ca14ae4c38..c7762c9292 100644
--- a/src/ImageSharp/Common/Helpers/Numerics.cs
+++ b/src/ImageSharp/Common/Helpers/Numerics.cs
@@ -470,8 +470,8 @@ private static void ClampImpl(Span span, T min, T max)
where T : unmanaged
{
ref T sRef = ref MemoryMarshal.GetReference(span);
- var vmin = new Vector(min);
- var vmax = new Vector(max);
+ Vector vmin = new(min);
+ Vector vmax = new(max);
nint n = (nint)(uint)span.Length / Vector.Count;
nint m = Modulo4(n);
@@ -726,12 +726,12 @@ public static unsafe void CubeRootOnXYZ(Span vectors)
ref Vector128 vectors128Ref = ref Unsafe.As>(ref MemoryMarshal.GetReference(vectors));
ref Vector128 vectors128End = ref Unsafe.Add(ref vectors128Ref, (uint)vectors.Length);
- var v128_341 = Vector128.Create(341);
+ Vector128 v128_341 = Vector128.Create(341);
Vector128 v128_negativeZero = Vector128.Create(-0.0f).AsInt32();
Vector128 v128_one = Vector128.Create(1.0f).AsInt32();
- var v128_13rd = Vector128.Create(1 / 3f);
- var v128_23rds = Vector128.Create(2 / 3f);
+ Vector128 v128_13rd = Vector128.Create(1 / 3f);
+ Vector128 v128_23rds = Vector128.Create(2 / 3f);
while (Unsafe.IsAddressLessThan(ref vectors128Ref, ref vectors128End))
{
diff --git a/src/ImageSharp/Common/Helpers/SimdUtils.Pack.cs b/src/ImageSharp/Common/Helpers/SimdUtils.Pack.cs
index f471d0231b..80bfa29ca2 100644
--- a/src/ImageSharp/Common/Helpers/SimdUtils.Pack.cs
+++ b/src/ImageSharp/Common/Helpers/SimdUtils.Pack.cs
@@ -134,7 +134,7 @@ private static void PackFromRgbPlanesScalarBatchedReduce(
ref Rgba32 rgb = ref MemoryMarshal.GetReference(destination);
nuint count = (uint)redChannel.Length / 4;
- destination.Fill(new Rgba32(0, 0, 0, 255));
+ destination.Fill(new(0, 0, 0, 255));
for (nuint i = 0; i < count; i++)
{
ref Rgba32 d0 = ref Unsafe.Add(ref rgb, i * 4);
diff --git a/src/ImageSharp/Common/Helpers/SimdUtils.cs b/src/ImageSharp/Common/Helpers/SimdUtils.cs
index 0279e57cc6..168a941ebb 100644
--- a/src/ImageSharp/Common/Helpers/SimdUtils.cs
+++ b/src/ImageSharp/Common/Helpers/SimdUtils.cs
@@ -29,7 +29,7 @@ internal static partial class SimdUtils
[MethodImpl(MethodImplOptions.AggressiveInlining)]
internal static Vector4 PseudoRound(this Vector4 v)
{
- Vector4 sign = Numerics.Clamp(v, new Vector4(-1), new Vector4(1));
+ Vector4 sign = Numerics.Clamp(v, new(-1), new(1));
return v + (sign * 0.5f);
}
@@ -53,11 +53,11 @@ internal static Vector FastRound(this Vector v)
}
else
{
- var magic0 = new Vector(int.MinValue); // 0x80000000
- var sgn0 = Vector.AsVectorSingle(magic0);
- var and0 = Vector.BitwiseAnd(sgn0, v);
- var or0 = Vector.BitwiseOr(and0, new Vector(8388608.0f));
- var add0 = Vector.Add(v, or0);
+ Vector magic0 = new(int.MinValue); // 0x80000000
+ Vector sgn0 = Vector.AsVectorSingle(magic0);
+ Vector and0 = Vector.BitwiseAnd(sgn0, v);
+ Vector or0 = Vector.BitwiseOr(and0, new(8388608.0f));
+ Vector add0 = Vector.Add(v, or0);
return Vector.Subtract(add0, or0);
}
}
diff --git a/src/ImageSharp/Common/Helpers/TolerantMath.cs b/src/ImageSharp/Common/Helpers/TolerantMath.cs
index b4ed9ee2f2..2c622d1679 100644
--- a/src/ImageSharp/Common/Helpers/TolerantMath.cs
+++ b/src/ImageSharp/Common/Helpers/TolerantMath.cs
@@ -20,7 +20,7 @@ internal readonly struct TolerantMath
/// It is a field so it can be passed as an 'in' parameter.
/// Does not necessarily fit all use cases!
///
- public static readonly TolerantMath Default = new TolerantMath(1e-8);
+ public static readonly TolerantMath Default = new(1e-8);
public TolerantMath(double epsilon)
{
diff --git a/src/ImageSharp/Common/Helpers/UnitConverter.cs b/src/ImageSharp/Common/Helpers/UnitConverter.cs
index 45dbe41cb9..c50766ec20 100644
--- a/src/ImageSharp/Common/Helpers/UnitConverter.cs
+++ b/src/ImageSharp/Common/Helpers/UnitConverter.cs
@@ -131,9 +131,9 @@ public static ExifResolutionValues GetExifResolutionValues(PixelResolutionUnit u
ushort exifUnit = (ushort)(unit + 1);
if (unit == PixelResolutionUnit.AspectRatio)
{
- return new ExifResolutionValues(exifUnit, null, null);
+ return new(exifUnit, null, null);
}
- return new ExifResolutionValues(exifUnit, horizontal, vertical);
+ return new(exifUnit, horizontal, vertical);
}
}
diff --git a/src/ImageSharp/Compression/Zlib/Adler32.cs b/src/ImageSharp/Compression/Zlib/Adler32.cs
index dd8217541a..6f21850818 100644
--- a/src/ImageSharp/Compression/Zlib/Adler32.cs
+++ b/src/ImageSharp/Compression/Zlib/Adler32.cs
@@ -32,11 +32,11 @@ internal static class Adler32
private const int BlockSize = 1 << 5;
// The C# compiler emits this as a compile-time constant embedded in the PE file.
- private static ReadOnlySpan Tap1Tap2 => new byte[]
- {
+ private static ReadOnlySpan Tap1Tap2 =>
+ [
32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, // tap1
16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1 // tap2
- };
+ ];
///
/// Calculates the Adler32 checksum with the bytes taken from the span.
diff --git a/src/ImageSharp/Compression/Zlib/Deflater.cs b/src/ImageSharp/Compression/Zlib/Deflater.cs
index f642ec85a7..2e39d435d6 100644
--- a/src/ImageSharp/Compression/Zlib/Deflater.cs
+++ b/src/ImageSharp/Compression/Zlib/Deflater.cs
@@ -79,7 +79,7 @@ public Deflater(MemoryAllocator memoryAllocator, int level)
}
// TODO: Possibly provide DeflateStrategy as an option.
- this.engine = new DeflaterEngine(memoryAllocator, DeflateStrategy.Default);
+ this.engine = new(memoryAllocator, DeflateStrategy.Default);
this.SetLevel(level);
this.Reset();
diff --git a/src/ImageSharp/Compression/Zlib/DeflaterConstants.cs b/src/ImageSharp/Compression/Zlib/DeflaterConstants.cs
index b623149470..fbc2083b39 100644
--- a/src/ImageSharp/Compression/Zlib/DeflaterConstants.cs
+++ b/src/ImageSharp/Compression/Zlib/DeflaterConstants.cs
@@ -124,25 +124,25 @@ internal static class DeflaterConstants
///
/// Internal compression engine constant
///
- public static int[] GOOD_LENGTH = { 0, 4, 4, 4, 4, 8, 8, 8, 32, 32 };
+ public static int[] GOOD_LENGTH = [0, 4, 4, 4, 4, 8, 8, 8, 32, 32];
///
/// Internal compression engine constant
///
- public static int[] MAX_LAZY = { 0, 4, 5, 6, 4, 16, 16, 32, 128, 258 };
+ public static int[] MAX_LAZY = [0, 4, 5, 6, 4, 16, 16, 32, 128, 258];
///
/// Internal compression engine constant
///
- public static int[] NICE_LENGTH = { 0, 8, 16, 32, 16, 32, 128, 128, 258, 258 };
+ public static int[] NICE_LENGTH = [0, 8, 16, 32, 16, 32, 128, 128, 258, 258];
///
/// Internal compression engine constant
///
- public static int[] MAX_CHAIN = { 0, 4, 8, 32, 16, 32, 128, 256, 1024, 4096 };
+ public static int[] MAX_CHAIN = [0, 4, 8, 32, 16, 32, 128, 256, 1024, 4096];
///
/// Internal compression engine constant
///
- public static int[] COMPR_FUNC = { 0, 1, 1, 1, 1, 2, 2, 2, 2, 2 };
+ public static int[] COMPR_FUNC = [0, 1, 1, 1, 1, 2, 2, 2, 2, 2];
}
diff --git a/src/ImageSharp/Compression/Zlib/DeflaterEngine.cs b/src/ImageSharp/Compression/Zlib/DeflaterEngine.cs
index 6009fdfbc0..c9613610d8 100644
--- a/src/ImageSharp/Compression/Zlib/DeflaterEngine.cs
+++ b/src/ImageSharp/Compression/Zlib/DeflaterEngine.cs
@@ -147,7 +147,7 @@ internal sealed unsafe class DeflaterEngine : IDisposable
/// The deflate strategy to use.
public DeflaterEngine(MemoryAllocator memoryAllocator, DeflateStrategy strategy)
{
- this.huffman = new DeflaterHuffman(memoryAllocator);
+ this.huffman = new(memoryAllocator);
this.Pending = this.huffman.Pending;
this.strategy = strategy;
diff --git a/src/ImageSharp/Compression/Zlib/DeflaterHuffman.cs b/src/ImageSharp/Compression/Zlib/DeflaterHuffman.cs
index e4dc1945a8..cd333c724d 100644
--- a/src/ImageSharp/Compression/Zlib/DeflaterHuffman.cs
+++ b/src/ImageSharp/Compression/Zlib/DeflaterHuffman.cs
@@ -58,11 +58,11 @@ internal sealed unsafe class DeflaterHuffman : IDisposable
/// The memory allocator to use for buffer allocations.
public DeflaterHuffman(MemoryAllocator memoryAllocator)
{
- this.Pending = new DeflaterPendingBuffer(memoryAllocator);
+ this.Pending = new(memoryAllocator);
- this.literalTree = new Tree(memoryAllocator, LiteralNumber, 257, 15);
- this.distTree = new Tree(memoryAllocator, DistanceNumber, 1, 15);
- this.blTree = new Tree(memoryAllocator, BitLengthNumber, 4, 7);
+ this.literalTree = new(memoryAllocator, LiteralNumber, 257, 15);
+ this.distTree = new(memoryAllocator, DistanceNumber, 1, 15);
+ this.blTree = new(memoryAllocator, BitLengthNumber, 4, 7);
this.distanceMemoryOwner = memoryAllocator.Allocate(BufferSize);
this.distanceBufferHandle = this.distanceMemoryOwner.Memory.Pin();
@@ -77,8 +77,8 @@ public DeflaterHuffman(MemoryAllocator memoryAllocator)
// See RFC 1951 3.2.6
// Literal codes
- private static readonly short[] StaticLCodes = new short[]
- {
+ private static readonly short[] StaticLCodes =
+ [
12, 140, 76, 204, 44, 172, 108, 236, 28, 156, 92, 220, 60, 188, 124, 252,
2, 130, 66, 194, 34, 162, 98, 226, 18, 146, 82, 210, 50, 178, 114, 242,
10, 138, 74, 202, 42, 170, 106, 234, 26, 154, 90, 218, 58, 186, 122, 250,
@@ -97,10 +97,10 @@ public DeflaterHuffman(MemoryAllocator memoryAllocator)
31, 287, 159, 415, 95, 351, 223, 479, 63, 319, 191, 447, 127, 383, 255, 511,
0, 64, 32, 96, 16, 80, 48, 112, 8, 72, 40, 104, 24, 88, 56, 120, 4, 68, 36,
100, 20, 84, 52, 116, 3, 131, 67, 195, 35, 163
- };
+ ];
- private static ReadOnlySpan StaticLLength => new byte[]
- {
+ private static ReadOnlySpan StaticLLength =>
+ [
8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
@@ -119,34 +119,34 @@ public DeflaterHuffman(MemoryAllocator memoryAllocator)
9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9,
7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
7, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8
- };
+ ];
// Distance codes and lengths.
- private static readonly short[] StaticDCodes = new short[]
- {
+ private static readonly short[] StaticDCodes =
+ [
0, 16, 8, 24, 4, 20, 12, 28, 2, 18, 10, 26, 6, 22, 14,
30, 1, 17, 9, 25, 5, 21, 13, 29, 3, 19, 11, 27, 7, 23
- };
+ ];
- private static ReadOnlySpan StaticDLength => new byte[]
- {
+ private static ReadOnlySpan StaticDLength =>
+ [
5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5
- };
+ ];
#pragma warning restore SA1201 // Elements should appear in the correct order
///
/// Gets the lengths of the bit length codes are sent in order of decreasing probability, to avoid transmitting the lengths for unused bit length codes.
///
- private static ReadOnlySpan BitLengthOrder => new byte[]
- {
+ private static ReadOnlySpan BitLengthOrder =>
+ [
16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15
- };
+ ];
- private static ReadOnlySpan Bit4Reverse => new byte[]
- {
+ private static ReadOnlySpan Bit4Reverse =>
+ [
0, 8, 4, 12, 2, 10, 6, 14, 1, 9, 5, 13, 3, 11, 7, 15
- };
+ ];
///
/// Gets the pending buffer to use.
diff --git a/src/ImageSharp/Compression/Zlib/DeflaterOutputStream.cs b/src/ImageSharp/Compression/Zlib/DeflaterOutputStream.cs
index de818fd8f5..76a5a045ee 100644
--- a/src/ImageSharp/Compression/Zlib/DeflaterOutputStream.cs
+++ b/src/ImageSharp/Compression/Zlib/DeflaterOutputStream.cs
@@ -30,7 +30,7 @@ public DeflaterOutputStream(MemoryAllocator memoryAllocator, Stream rawStream, i
this.rawStream = rawStream;
this.memoryOwner = memoryAllocator.Allocate(BufferLength);
this.buffer = this.memoryOwner.Memory;
- this.deflater = new Deflater(memoryAllocator, compressionLevel);
+ this.deflater = new(memoryAllocator, compressionLevel);
}
///
diff --git a/src/ImageSharp/Compression/Zlib/ZlibDeflateStream.cs b/src/ImageSharp/Compression/Zlib/ZlibDeflateStream.cs
index 2e52f84d7b..9364444065 100644
--- a/src/ImageSharp/Compression/Zlib/ZlibDeflateStream.cs
+++ b/src/ImageSharp/Compression/Zlib/ZlibDeflateStream.cs
@@ -101,7 +101,7 @@ public ZlibDeflateStream(MemoryAllocator memoryAllocator, Stream stream, PngComp
this.rawStream.WriteByte(Cmf);
this.rawStream.WriteByte((byte)flg);
- this.deflateStream = new DeflaterOutputStream(memoryAllocator, this.rawStream, compressionLevel);
+ this.deflateStream = new(memoryAllocator, this.rawStream, compressionLevel);
}
///
diff --git a/src/ImageSharp/Compression/Zlib/ZlibInflateStream.cs b/src/ImageSharp/Compression/Zlib/ZlibInflateStream.cs
index 1d743bf3a5..aa4beba18c 100644
--- a/src/ImageSharp/Compression/Zlib/ZlibInflateStream.cs
+++ b/src/ImageSharp/Compression/Zlib/ZlibInflateStream.cs
@@ -270,7 +270,7 @@ private bool InitializeInflateStream(bool isCriticalChunk)
}
// Initialize the deflate BufferedReadStream.
- this.CompressedStream = new DeflateStream(this, CompressionMode.Decompress, true);
+ this.CompressedStream = new(this, CompressionMode.Decompress, true);
return true;
}
diff --git a/src/ImageSharp/Configuration.cs b/src/ImageSharp/Configuration.cs
index 1d9f3bb85d..c2b02dedd9 100644
--- a/src/ImageSharp/Configuration.cs
+++ b/src/ImageSharp/Configuration.cs
@@ -122,7 +122,7 @@ public int StreamProcessingBufferSize
///
/// Gets or the that is currently in use.
///
- public ImageFormatManager ImageFormatsManager { get; private set; } = new ImageFormatManager();
+ public ImageFormatManager ImageFormatsManager { get; private set; } = new();
///
/// Gets or sets the that is currently in use.
diff --git a/src/ImageSharp/Formats/Bmp/BmpConstants.cs b/src/ImageSharp/Formats/Bmp/BmpConstants.cs
index 62edfdfdfa..1ac79a9e26 100644
--- a/src/ImageSharp/Formats/Bmp/BmpConstants.cs
+++ b/src/ImageSharp/Formats/Bmp/BmpConstants.cs
@@ -11,17 +11,17 @@ internal static class BmpConstants
///
/// The list of mimetypes that equate to a bmp.
///
- public static readonly IEnumerable MimeTypes = new[]
- {
+ public static readonly IEnumerable MimeTypes =
+ [
"image/bmp",
"image/x-windows-bmp",
"image/x-win-bitmap"
- };
+ ];
///
/// The list of file extensions that equate to a bmp.
///
- public static readonly IEnumerable FileExtensions = new[] { "bm", "bmp", "dip" };
+ public static readonly IEnumerable FileExtensions = ["bm", "bmp", "dip"];
///
/// Valid magic bytes markers identifying a Bitmap file.
diff --git a/src/ImageSharp/Formats/Bmp/BmpDecoderCore.cs b/src/ImageSharp/Formats/Bmp/BmpDecoderCore.cs
index 94257517d2..43fe3af85b 100644
--- a/src/ImageSharp/Formats/Bmp/BmpDecoderCore.cs
+++ b/src/ImageSharp/Formats/Bmp/BmpDecoderCore.cs
@@ -132,7 +132,7 @@ protected override Image Decode(BufferedReadStream stream, Cance
{
int bytesPerColorMapEntry = this.ReadImageHeaders(stream, out bool inverted, out byte[] palette);
- image = new Image(this.configuration, this.infoHeader.Width, this.infoHeader.Height, this.metadata);
+ image = new(this.configuration, this.infoHeader.Width, this.infoHeader.Height, this.metadata);
Buffer2D pixels = image.GetRootFramePixelBuffer();
@@ -220,7 +220,7 @@ protected override Image Decode(BufferedReadStream stream, Cance
protected override ImageInfo Identify(BufferedReadStream stream, CancellationToken cancellationToken)
{
this.ReadImageHeaders(stream, out _, out _);
- return new ImageInfo(new(this.infoHeader.Width, this.infoHeader.Height), this.metadata);
+ return new(new(this.infoHeader.Width, this.infoHeader.Height), this.metadata);
}
///
@@ -343,7 +343,7 @@ private void ReadRle(BufferedReadStream stream, BmpCompression compressi
RleSkippedPixelHandling.Transparent => TPixel.FromScaledVector4(Vector4.Zero),
// Default handling for skipped pixels is black (which is what System.Drawing is also doing).
- _ => TPixel.FromScaledVector4(new Vector4(0.0f, 0.0f, 0.0f, 1.0f)),
+ _ => TPixel.FromScaledVector4(new(0.0f, 0.0f, 0.0f, 1.0f)),
};
}
else
@@ -404,7 +404,7 @@ private void ReadRle24(BufferedReadStream stream, Buffer2D pixel
RleSkippedPixelHandling.Transparent => TPixel.FromScaledVector4(Vector4.Zero),
// Default handling for skipped pixels is black (which is what System.Drawing is also doing).
- _ => TPixel.FromScaledVector4(new Vector4(0.0f, 0.0f, 0.0f, 1.0f)),
+ _ => TPixel.FromScaledVector4(new(0.0f, 0.0f, 0.0f, 1.0f)),
};
}
else
@@ -1332,7 +1332,7 @@ private void ReadInfoHeader(BufferedReadStream stream)
long infoHeaderStart = stream.Position;
// Resolution is stored in PPM.
- this.metadata = new ImageMetadata
+ this.metadata = new()
{
ResolutionUnits = PixelResolutionUnit.PixelsPerMeter
};
@@ -1426,7 +1426,7 @@ private void ReadInfoHeader(BufferedReadStream stream)
byte[] iccProfileData = new byte[this.infoHeader.ProfileSize];
stream.Position = infoHeaderStart + this.infoHeader.ProfileData;
stream.Read(iccProfileData);
- this.metadata.IccProfile = new IccProfile(iccProfileData);
+ this.metadata.IccProfile = new(iccProfileData);
stream.Position = streamPosition;
}
}
diff --git a/src/ImageSharp/Formats/Bmp/BmpEncoderCore.cs b/src/ImageSharp/Formats/Bmp/BmpEncoderCore.cs
index 85786949d8..73a5b322ad 100644
--- a/src/ImageSharp/Formats/Bmp/BmpEncoderCore.cs
+++ b/src/ImageSharp/Formats/Bmp/BmpEncoderCore.cs
@@ -573,7 +573,7 @@ private void Write8BitPixelData(Stream stream, Image image, Span
private void Write4BitPixelData(Configuration configuration, Stream stream, Image image)
where TPixel : unmanaged, IPixel
{
- using IQuantizer frameQuantizer = this.quantizer.CreatePixelSpecificQuantizer(configuration, new QuantizerOptions()
+ using IQuantizer frameQuantizer = this.quantizer.CreatePixelSpecificQuantizer(configuration, new()
{
MaxColors = 16
});
@@ -621,7 +621,7 @@ private void Write4BitPixelData(Configuration configuration, Stream stre
private void Write2BitPixelData(Configuration configuration, Stream stream, Image image)
where TPixel : unmanaged, IPixel
{
- using IQuantizer frameQuantizer = this.quantizer.CreatePixelSpecificQuantizer(configuration, new QuantizerOptions()
+ using IQuantizer frameQuantizer = this.quantizer.CreatePixelSpecificQuantizer(configuration, new()
{
MaxColors = 4
});
@@ -678,7 +678,7 @@ private void Write2BitPixelData(Configuration configuration, Stream stre
private void Write1BitPixelData(Configuration configuration, Stream stream, Image image)
where TPixel : unmanaged, IPixel
{
- using IQuantizer frameQuantizer = this.quantizer.CreatePixelSpecificQuantizer(configuration, new QuantizerOptions()
+ using IQuantizer frameQuantizer = this.quantizer.CreatePixelSpecificQuantizer(configuration, new()
{
MaxColors = 2
});
diff --git a/src/ImageSharp/Formats/Bmp/BmpFormat.cs b/src/ImageSharp/Formats/Bmp/BmpFormat.cs
index a67b06cb88..5dec4a6748 100644
--- a/src/ImageSharp/Formats/Bmp/BmpFormat.cs
+++ b/src/ImageSharp/Formats/Bmp/BmpFormat.cs
@@ -15,7 +15,7 @@ private BmpFormat()
///
/// Gets the shared instance.
///
- public static BmpFormat Instance { get; } = new BmpFormat();
+ public static BmpFormat Instance { get; } = new();
///
public string Name => "BMP";
diff --git a/src/ImageSharp/Formats/Bmp/BmpMetadata.cs b/src/ImageSharp/Formats/Bmp/BmpMetadata.cs
index d0c60421c4..25a4515644 100644
--- a/src/ImageSharp/Formats/Bmp/BmpMetadata.cs
+++ b/src/ImageSharp/Formats/Bmp/BmpMetadata.cs
@@ -54,21 +54,21 @@ public static BmpMetadata FromFormatConnectingMetadata(FormatConnectingMetadata
int bpp = metadata.PixelTypeInfo.BitsPerPixel;
return bpp switch
{
- 1 => new BmpMetadata { BitsPerPixel = BmpBitsPerPixel.Bit1 },
- 2 => new BmpMetadata { BitsPerPixel = BmpBitsPerPixel.Bit2 },
- <= 4 => new BmpMetadata { BitsPerPixel = BmpBitsPerPixel.Bit4 },
- <= 8 => new BmpMetadata { BitsPerPixel = BmpBitsPerPixel.Bit8 },
- <= 16 => new BmpMetadata
+ 1 => new() { BitsPerPixel = BmpBitsPerPixel.Bit1 },
+ 2 => new() { BitsPerPixel = BmpBitsPerPixel.Bit2 },
+ <= 4 => new() { BitsPerPixel = BmpBitsPerPixel.Bit4 },
+ <= 8 => new() { BitsPerPixel = BmpBitsPerPixel.Bit8 },
+ <= 16 => new()
{
BitsPerPixel = BmpBitsPerPixel.Bit16,
InfoHeaderType = BmpInfoHeaderType.WinVersion3
},
- <= 24 => new BmpMetadata
+ <= 24 => new()
{
BitsPerPixel = BmpBitsPerPixel.Bit24,
InfoHeaderType = BmpInfoHeaderType.WinVersion4
},
- _ => new BmpMetadata
+ _ => new()
{
BitsPerPixel = BmpBitsPerPixel.Bit32,
InfoHeaderType = BmpInfoHeaderType.WinVersion5
@@ -131,7 +131,7 @@ BmpInfoHeaderType.WinVersion5 or
break;
}
- return new PixelTypeInfo(bpp)
+ return new(bpp)
{
AlphaRepresentation = alpha,
ComponentInfo = info,
diff --git a/src/ImageSharp/Formats/Cur/CurFrameMetadata.cs b/src/ImageSharp/Formats/Cur/CurFrameMetadata.cs
index 4e9a432b16..326e3d5471 100644
--- a/src/ImageSharp/Formats/Cur/CurFrameMetadata.cs
+++ b/src/ImageSharp/Formats/Cur/CurFrameMetadata.cs
@@ -73,7 +73,7 @@ public static CurFrameMetadata FromFormatConnectingFrameMetadata(FormatConnectin
{
if (!metadata.PixelTypeInfo.HasValue)
{
- return new CurFrameMetadata
+ return new()
{
BmpBitsPerPixel = BmpBitsPerPixel.Bit32,
Compression = IconFrameCompression.Png
@@ -112,7 +112,7 @@ public static CurFrameMetadata FromFormatConnectingFrameMetadata(FormatConnectin
compression = IconFrameCompression.Png;
}
- return new CurFrameMetadata
+ return new()
{
BmpBitsPerPixel = bbpp,
Compression = compression,
@@ -225,7 +225,7 @@ private PixelTypeInfo GetPixelTypeInfo()
}
}
- return new PixelTypeInfo(bpp)
+ return new(bpp)
{
AlphaRepresentation = alpha,
ComponentInfo = info,
diff --git a/src/ImageSharp/Formats/Cur/CurMetadata.cs b/src/ImageSharp/Formats/Cur/CurMetadata.cs
index 19de7f434d..a0550f87f0 100644
--- a/src/ImageSharp/Formats/Cur/CurMetadata.cs
+++ b/src/ImageSharp/Formats/Cur/CurMetadata.cs
@@ -68,7 +68,7 @@ public static CurMetadata FromFormatConnectingMetadata(FormatConnectingMetadata
compression = IconFrameCompression.Png;
}
- return new CurMetadata
+ return new()
{
BmpBitsPerPixel = bbpp,
Compression = compression,
@@ -130,7 +130,7 @@ public PixelTypeInfo GetPixelTypeInfo()
}
}
- return new PixelTypeInfo(bpp)
+ return new(bpp)
{
AlphaRepresentation = alpha,
ComponentInfo = info,
diff --git a/src/ImageSharp/Formats/Gif/GifConstants.cs b/src/ImageSharp/Formats/Gif/GifConstants.cs
index 796b5506c7..d2121adce2 100644
--- a/src/ImageSharp/Formats/Gif/GifConstants.cs
+++ b/src/ImageSharp/Formats/Gif/GifConstants.cs
@@ -93,41 +93,41 @@ internal static class GifConstants
///
/// The collection of mimetypes that equate to a Gif.
///
- public static readonly IEnumerable MimeTypes = new[] { "image/gif" };
+ public static readonly IEnumerable MimeTypes = ["image/gif"];
///
/// The collection of file extensions that equate to a Gif.
///
- public static readonly IEnumerable FileExtensions = new[] { "gif" };
+ public static readonly IEnumerable FileExtensions = ["gif"];
///
/// Gets the ASCII encoded bytes used to identify the GIF file (combining and ).
///
- internal static ReadOnlySpan MagicNumber => new[]
- {
+ internal static ReadOnlySpan MagicNumber =>
+ [
(byte)'G', (byte)'I', (byte)'F',
(byte)'8', (byte)'9', (byte)'a'
- };
+ ];
///
/// Gets the ASCII encoded application identification bytes (representing ).
///
- internal static ReadOnlySpan NetscapeApplicationIdentificationBytes => new[]
- {
+ internal static ReadOnlySpan NetscapeApplicationIdentificationBytes =>
+ [
(byte)'N', (byte)'E', (byte)'T',
(byte)'S', (byte)'C', (byte)'A',
(byte)'P', (byte)'E',
(byte)'2', (byte)'.', (byte)'0'
- };
+ ];
///
/// Gets the ASCII encoded application identification bytes.
///
- internal static ReadOnlySpan XmpApplicationIdentificationBytes => new[]
- {
+ internal static ReadOnlySpan XmpApplicationIdentificationBytes =>
+ [
(byte)'X', (byte)'M', (byte)'P',
(byte)' ', (byte)'D', (byte)'a',
(byte)'t', (byte)'a',
(byte)'X', (byte)'M', (byte)'P'
- };
+ ];
}
diff --git a/src/ImageSharp/Formats/Gif/GifDecoderCore.cs b/src/ImageSharp/Formats/Gif/GifDecoderCore.cs
index a99b5862dd..060fd756d2 100644
--- a/src/ImageSharp/Formats/Gif/GifDecoderCore.cs
+++ b/src/ImageSharp/Formats/Gif/GifDecoderCore.cs
@@ -241,7 +241,7 @@ protected override ImageInfo Identify(BufferedReadStream stream, CancellationTok
GifThrowHelper.ThrowNoHeader();
}
- return new ImageInfo(
+ return new(
new(this.logicalScreenDescriptor.Width, this.logicalScreenDescriptor.Height),
this.metadata,
framesMetadata);
@@ -319,7 +319,7 @@ private void ReadApplicationExtension(BufferedReadStream stream)
GifXmpApplicationExtension extension = GifXmpApplicationExtension.Read(stream, this.memoryAllocator);
if (extension.Data.Length > 0)
{
- this.metadata!.XmpProfile = new XmpProfile(extension.Data);
+ this.metadata!.XmpProfile = new(extension.Data);
}
else
{
@@ -478,12 +478,12 @@ private void ReadFrameColors(
{
if (!transFlag)
{
- image = new Image(this.configuration, imageWidth, imageHeight, Color.Black.ToPixel(), this.metadata);
+ image = new(this.configuration, imageWidth, imageHeight, Color.Black.ToPixel(), this.metadata);
}
else
{
// This initializes the image to become fully transparent because the alpha channel is zero.
- image = new Image(this.configuration, imageWidth, imageHeight, this.metadata);
+ image = new(this.configuration, imageWidth, imageHeight, this.metadata);
}
this.SetFrameMetadata(image.Frames.RootFrame.Metadata);
diff --git a/src/ImageSharp/Formats/Gif/GifMetadata.cs b/src/ImageSharp/Formats/Gif/GifMetadata.cs
index 517609af45..c8ed7e06be 100644
--- a/src/ImageSharp/Formats/Gif/GifMetadata.cs
+++ b/src/ImageSharp/Formats/Gif/GifMetadata.cs
@@ -105,7 +105,7 @@ public PixelTypeInfo GetPixelTypeInfo()
? Numerics.Clamp(ColorNumerics.GetBitsNeededForColorDepth(this.GlobalColorTable.Value.Length), 1, 8)
: 8;
- return new PixelTypeInfo(bpp)
+ return new(bpp)
{
ColorType = PixelColorType.Indexed,
ComponentInfo = PixelComponentInfo.Create(1, bpp, bpp),
diff --git a/src/ImageSharp/Formats/Gif/LzwEncoder.cs b/src/ImageSharp/Formats/Gif/LzwEncoder.cs
index d4050810df..08daf38990 100644
--- a/src/ImageSharp/Formats/Gif/LzwEncoder.cs
+++ b/src/ImageSharp/Formats/Gif/LzwEncoder.cs
@@ -47,7 +47,7 @@ internal sealed class LzwEncoder : IDisposable
/// Mask used when shifting pixel values
///
private static readonly int[] Masks =
- {
+ [
0b0,
0b1,
0b11,
@@ -65,7 +65,7 @@ internal sealed class LzwEncoder : IDisposable
0b11111111111111,
0b111111111111111,
0b1111111111111111
- };
+ ];
///
/// The maximum number of bits/code.
diff --git a/src/ImageSharp/Formats/Gif/Sections/GifNetscapeLoopingApplicationExtension.cs b/src/ImageSharp/Formats/Gif/Sections/GifNetscapeLoopingApplicationExtension.cs
index e413896751..4c2ffbe4d1 100644
--- a/src/ImageSharp/Formats/Gif/Sections/GifNetscapeLoopingApplicationExtension.cs
+++ b/src/ImageSharp/Formats/Gif/Sections/GifNetscapeLoopingApplicationExtension.cs
@@ -22,7 +22,7 @@ namespace SixLabors.ImageSharp.Formats.Gif;
public static GifNetscapeLoopingApplicationExtension Parse(ReadOnlySpan buffer)
{
ushort repeatCount = BinaryPrimitives.ReadUInt16LittleEndian(buffer[..2]);
- return new GifNetscapeLoopingApplicationExtension(repeatCount);
+ return new(repeatCount);
}
public int WriteTo(Span buffer)
diff --git a/src/ImageSharp/Formats/Gif/Sections/GifXmpApplicationExtension.cs b/src/ImageSharp/Formats/Gif/Sections/GifXmpApplicationExtension.cs
index 1c1127c3be..410972f9cc 100644
--- a/src/ImageSharp/Formats/Gif/Sections/GifXmpApplicationExtension.cs
+++ b/src/ImageSharp/Formats/Gif/Sections/GifXmpApplicationExtension.cs
@@ -34,7 +34,7 @@ public static GifXmpApplicationExtension Read(Stream stream, MemoryAllocator all
// Exclude the "magic trailer", see XMP Specification Part 3, 1.1.2 GIF
int xmpLength = xmpBytes.Length - 256; // 257 - unread 0x0
- byte[] buffer = Array.Empty();
+ byte[] buffer = [];
if (xmpLength > 0)
{
buffer = new byte[xmpLength];
@@ -42,7 +42,7 @@ public static GifXmpApplicationExtension Read(Stream stream, MemoryAllocator all
stream.Skip(1); // Skip the terminator.
}
- return new GifXmpApplicationExtension(buffer);
+ return new(buffer);
}
public int WriteTo(Span buffer)
diff --git a/src/ImageSharp/Formats/Ico/IcoFrameMetadata.cs b/src/ImageSharp/Formats/Ico/IcoFrameMetadata.cs
index a2d1c01391..6dbc87a56f 100644
--- a/src/ImageSharp/Formats/Ico/IcoFrameMetadata.cs
+++ b/src/ImageSharp/Formats/Ico/IcoFrameMetadata.cs
@@ -66,7 +66,7 @@ public static IcoFrameMetadata FromFormatConnectingFrameMetadata(FormatConnectin
{
if (!metadata.PixelTypeInfo.HasValue)
{
- return new IcoFrameMetadata
+ return new()
{
BmpBitsPerPixel = BmpBitsPerPixel.Bit32,
Compression = IconFrameCompression.Png
@@ -105,7 +105,7 @@ public static IcoFrameMetadata FromFormatConnectingFrameMetadata(FormatConnectin
compression = IconFrameCompression.Png;
}
- return new IcoFrameMetadata
+ return new()
{
BmpBitsPerPixel = bbpp,
Compression = compression,
@@ -220,7 +220,7 @@ private PixelTypeInfo GetPixelTypeInfo()
}
}
- return new PixelTypeInfo(bpp)
+ return new(bpp)
{
AlphaRepresentation = alpha,
ComponentInfo = info,
diff --git a/src/ImageSharp/Formats/Ico/IcoMetadata.cs b/src/ImageSharp/Formats/Ico/IcoMetadata.cs
index a6c2704b31..9f930893d5 100644
--- a/src/ImageSharp/Formats/Ico/IcoMetadata.cs
+++ b/src/ImageSharp/Formats/Ico/IcoMetadata.cs
@@ -68,7 +68,7 @@ public static IcoMetadata FromFormatConnectingMetadata(FormatConnectingMetadata
compression = IconFrameCompression.Png;
}
- return new IcoMetadata
+ return new()
{
BmpBitsPerPixel = bbpp,
Compression = compression,
@@ -130,7 +130,7 @@ public PixelTypeInfo GetPixelTypeInfo()
}
}
- return new PixelTypeInfo(bpp)
+ return new(bpp)
{
AlphaRepresentation = alpha,
ComponentInfo = info,
diff --git a/src/ImageSharp/Formats/Jpeg/Components/Block8x8.cs b/src/ImageSharp/Formats/Jpeg/Components/Block8x8.cs
index 01d112bd6f..177803ea55 100644
--- a/src/ImageSharp/Formats/Jpeg/Components/Block8x8.cs
+++ b/src/ImageSharp/Formats/Jpeg/Components/Block8x8.cs
@@ -140,7 +140,7 @@ public void LoadFrom(Span source)
///
public override string ToString()
{
- var sb = new StringBuilder();
+ StringBuilder sb = new();
sb.Append('[');
for (int i = 0; i < Size; i++)
{
diff --git a/src/ImageSharp/Formats/Jpeg/Components/Block8x8F.ScaledCopy.cs b/src/ImageSharp/Formats/Jpeg/Components/Block8x8F.ScaledCopy.cs
index efc1dbd729..179f9aa287 100644
--- a/src/ImageSharp/Formats/Jpeg/Components/Block8x8F.ScaledCopy.cs
+++ b/src/ImageSharp/Formats/Jpeg/Components/Block8x8F.ScaledCopy.cs
@@ -57,19 +57,19 @@ static void WidenCopyRowImpl2x2(ref Vector4 selfBase, ref Vector2 destBase, nuin
ref Vector4 dTopLeft = ref Unsafe.As(ref Unsafe.Add(ref destBase, offset));
ref Vector4 dBottomLeft = ref Unsafe.As(ref Unsafe.Add(ref destBase, offset + destStride));
- var xyLeft = new Vector4(sLeft.X);
+ Vector4 xyLeft = new(sLeft.X);
xyLeft.Z = sLeft.Y;
xyLeft.W = sLeft.Y;
- var zwLeft = new Vector4(sLeft.Z);
+ Vector4 zwLeft = new(sLeft.Z);
zwLeft.Z = sLeft.W;
zwLeft.W = sLeft.W;
- var xyRight = new Vector4(sRight.X);
+ Vector4 xyRight = new(sRight.X);
xyRight.Z = sRight.Y;
xyRight.W = sRight.Y;
- var zwRight = new Vector4(sRight.Z);
+ Vector4 zwRight = new(sRight.Z);
zwRight.Z = sRight.W;
zwRight.W = sRight.W;
diff --git a/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.CmykArm64.cs b/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.CmykArm64.cs
index 11122d3b89..f073f61890 100644
--- a/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.CmykArm64.cs
+++ b/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.CmykArm64.cs
@@ -30,7 +30,7 @@ public override void ConvertToRgbInplace(in ComponentValues values)
ref Unsafe.As>(ref MemoryMarshal.GetReference(values.Component3));
// Used for the color conversion
- var scale = Vector128.Create(1 / (this.MaximumValue * this.MaximumValue));
+ Vector128 scale = Vector128.Create(1 / (this.MaximumValue * this.MaximumValue));
nint n = (nint)(uint)values.Component0.Length / Vector128.Count;
for (nint i = 0; i < n; i++)
@@ -69,7 +69,7 @@ public static void ConvertFromRgb(in ComponentValues values, float maxValue, Spa
ref Vector128 srcB =
ref Unsafe.As>(ref MemoryMarshal.GetReference(bLane));
- var scale = Vector128.Create(maxValue);
+ Vector128 scale = Vector128.Create(maxValue);
nint n = (nint)(uint)values.Component0.Length / Vector128.Count;
for (nint i = 0; i < n; i++)
diff --git a/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.CmykAvx.cs b/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.CmykAvx.cs
index 76d188f457..61f64c3b79 100644
--- a/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.CmykAvx.cs
+++ b/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.CmykAvx.cs
@@ -30,7 +30,7 @@ public override void ConvertToRgbInplace(in ComponentValues values)
ref Unsafe.As>(ref MemoryMarshal.GetReference(values.Component3));
// Used for the color conversion
- var scale = Vector256.Create(1 / (this.MaximumValue * this.MaximumValue));
+ Vector256 scale = Vector256.Create(1 / (this.MaximumValue * this.MaximumValue));
nuint n = values.Component0.Vector256Count();
for (nuint i = 0; i < n; i++)
@@ -69,7 +69,7 @@ public static void ConvertFromRgb(in ComponentValues values, float maxValue, Spa
ref Vector256 srcB =
ref Unsafe.As>(ref MemoryMarshal.GetReference(bLane));
- var scale = Vector256.Create(maxValue);
+ Vector256 scale = Vector256.Create(maxValue);
nuint n = values.Component0.Vector256Count();
for (nuint i = 0; i < n; i++)
diff --git a/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.CmykVector.cs b/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.CmykVector.cs
index a59be009b7..e425d6e3ff 100644
--- a/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.CmykVector.cs
+++ b/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.CmykVector.cs
@@ -28,7 +28,7 @@ protected override void ConvertToRgbInplaceVectorized(in ComponentValues values)
ref Vector kBase =
ref Unsafe.As>(ref MemoryMarshal.GetReference(values.Component3));
- var scale = new Vector(1 / (this.MaximumValue * this.MaximumValue));
+ Vector scale = new(1 / (this.MaximumValue * this.MaximumValue));
nuint n = values.Component0.VectorCount();
for (nuint i = 0; i < n; i++)
@@ -76,7 +76,7 @@ public static void ConvertFromRgbInplaceVectorized(in ComponentValues values, fl
ref Unsafe.As>(ref MemoryMarshal.GetReference(b));
// Used for the color conversion
- var scale = new Vector(maxValue);
+ Vector scale = new(maxValue);
nuint n = values.Component0.VectorCount();
for (nuint i = 0; i < n; i++)
@@ -86,7 +86,7 @@ public static void ConvertFromRgbInplaceVectorized(in ComponentValues values, fl
Vector ytmp = scale - Unsafe.Add(ref srcB, i);
Vector ktmp = Vector.Min(ctmp, Vector.Min(mtmp, ytmp));
- var kMask = Vector.Equals(ktmp, scale);
+ Vector kMask = Vector.Equals(ktmp, scale);
ctmp = Vector.AndNot((ctmp - ktmp) / (scale - ktmp), kMask.As());
mtmp = Vector.AndNot((mtmp - ktmp) / (scale - ktmp), kMask.As());
ytmp = Vector.AndNot((ytmp - ktmp) / (scale - ktmp), kMask.As());
diff --git a/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.GrayScaleArm.cs b/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.GrayScaleArm.cs
index 6bb8fd7aa3..7d3e3f563a 100644
--- a/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.GrayScaleArm.cs
+++ b/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.GrayScaleArm.cs
@@ -25,7 +25,7 @@ public override void ConvertToRgbInplace(in ComponentValues values)
ref Unsafe.As>(ref MemoryMarshal.GetReference(values.Component0));
// Used for the color conversion
- var scale = Vector128.Create(1 / this.MaximumValue);
+ Vector128 scale = Vector128.Create(1 / this.MaximumValue);
nuint n = values.Component0.Vector128Count();
for (nuint i = 0; i < n; i++)
@@ -49,9 +49,9 @@ public override void ConvertFromRgb(in ComponentValues values, Span rLane
ref Unsafe.As>(ref MemoryMarshal.GetReference(bLane));
// Used for the color conversion
- var f0299 = Vector128.Create(0.299f);
- var f0587 = Vector128.Create(0.587f);
- var f0114 = Vector128.Create(0.114f);
+ Vector128 f0299 = Vector128.Create(0.299f);
+ Vector128 f0587 = Vector128.Create(0.587f);
+ Vector128 f0114 = Vector128.Create(0.114f);
nuint n = values.Component0.Vector128Count();
for (nuint i = 0; i < n; i++)
diff --git a/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.GrayScaleAvx.cs b/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.GrayScaleAvx.cs
index a9e1c5d130..39658fcffd 100644
--- a/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.GrayScaleAvx.cs
+++ b/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.GrayScaleAvx.cs
@@ -25,7 +25,7 @@ public override void ConvertToRgbInplace(in ComponentValues values)
ref Unsafe.As>(ref MemoryMarshal.GetReference(values.Component0));
// Used for the color conversion
- var scale = Vector256.Create(1 / this.MaximumValue);
+ Vector256 scale = Vector256.Create(1 / this.MaximumValue);
nuint n = values.Component0.Vector256Count();
for (nuint i = 0; i < n; i++)
@@ -49,9 +49,9 @@ public override void ConvertFromRgb(in ComponentValues values, Span rLane
ref Unsafe.As>(ref MemoryMarshal.GetReference(bLane));
// Used for the color conversion
- var f0299 = Vector256.Create(0.299f);
- var f0587 = Vector256.Create(0.587f);
- var f0114 = Vector256.Create(0.114f);
+ Vector256 f0299 = Vector256.Create(0.299f);
+ Vector256 f0587 = Vector256.Create(0.587f);
+ Vector256 f0114 = Vector256.Create(0.114f);
nuint n = values.Component0.Vector256Count();
for (nuint i = 0; i < n; i++)
diff --git a/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.GrayScaleVector.cs b/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.GrayScaleVector.cs
index cac10636f5..92fc88fad6 100644
--- a/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.GrayScaleVector.cs
+++ b/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.GrayScaleVector.cs
@@ -22,7 +22,7 @@ protected override void ConvertToRgbInplaceVectorized(in ComponentValues values)
ref Vector cBase =
ref Unsafe.As>(ref MemoryMarshal.GetReference(values.Component0));
- var scale = new Vector(1 / this.MaximumValue);
+ Vector scale = new(1 / this.MaximumValue);
nuint n = values.Component0.VectorCount();
for (nuint i = 0; i < n; i++)
@@ -49,9 +49,9 @@ protected override void ConvertFromRgbVectorized(in ComponentValues values, Span
ref Vector srcB =
ref Unsafe.As>(ref MemoryMarshal.GetReference(bLane));
- var rMult = new Vector(0.299f);
- var gMult = new Vector(0.587f);
- var bMult = new Vector(0.114f);
+ Vector rMult = new(0.299f);
+ Vector gMult = new(0.587f);
+ Vector bMult = new(0.114f);
nuint n = values.Component0.VectorCount();
for (nuint i = 0; i < n; i++)
diff --git a/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.RgbArm.cs b/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.RgbArm.cs
index 75eeb17dd3..d47e4cae33 100644
--- a/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.RgbArm.cs
+++ b/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.RgbArm.cs
@@ -29,7 +29,7 @@ public override void ConvertToRgbInplace(in ComponentValues values)
ref Unsafe.As>(ref MemoryMarshal.GetReference(values.Component2));
// Used for the color conversion
- var scale = Vector128.Create(1 / this.MaximumValue);
+ Vector128 scale = Vector128.Create(1 / this.MaximumValue);
nuint n = values.Component0.Vector128Count();
for (nuint i = 0; i < n; i++)
{
diff --git a/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.RgbAvx.cs b/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.RgbAvx.cs
index b56728fa71..e99ab09988 100644
--- a/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.RgbAvx.cs
+++ b/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.RgbAvx.cs
@@ -28,7 +28,7 @@ public override void ConvertToRgbInplace(in ComponentValues values)
ref Unsafe.As>(ref MemoryMarshal.GetReference(values.Component2));
// Used for the color conversion
- var scale = Vector256.Create(1 / this.MaximumValue);
+ Vector256 scale = Vector256.Create(1 / this.MaximumValue);
nuint n = values.Component0.Vector256Count();
for (nuint i = 0; i < n; i++)
{
diff --git a/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.RgbVector.cs b/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.RgbVector.cs
index bd3142fa13..1152bcc3b9 100644
--- a/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.RgbVector.cs
+++ b/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.RgbVector.cs
@@ -26,7 +26,7 @@ protected override void ConvertToRgbInplaceVectorized(in ComponentValues values)
ref Vector bBase =
ref Unsafe.As>(ref MemoryMarshal.GetReference(values.Component2));
- var scale = new Vector(1 / this.MaximumValue);
+ Vector scale = new(1 / this.MaximumValue);
nuint n = values.Component0.VectorCount();
for (nuint i = 0; i < n; i++)
diff --git a/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.YCbCrArm.cs b/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.YCbCrArm.cs
index 4f7cf1ed65..71cc5ef20f 100644
--- a/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.YCbCrArm.cs
+++ b/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.YCbCrArm.cs
@@ -31,12 +31,12 @@ public override void ConvertToRgbInplace(in ComponentValues values)
ref Unsafe.As>(ref MemoryMarshal.GetReference(values.Component2));
// Used for the color conversion
- var chromaOffset = Vector128.Create(-this.HalfValue);
- var scale = Vector128.Create(1 / this.MaximumValue);
- var rCrMult = Vector128.Create(YCbCrScalar.RCrMult);
- var gCbMult = Vector128.Create(-YCbCrScalar.GCbMult);
- var gCrMult = Vector128.Create(-YCbCrScalar.GCrMult);
- var bCbMult = Vector128.Create(YCbCrScalar.BCbMult);
+ Vector128 chromaOffset = Vector128.Create(-this.HalfValue);
+ Vector128 scale = Vector128.Create(1 / this.MaximumValue);
+ Vector128 rCrMult = Vector128.Create(YCbCrScalar.RCrMult);
+ Vector128 gCbMult = Vector128.Create(-YCbCrScalar.GCbMult);
+ Vector128 gCrMult = Vector128.Create(-YCbCrScalar.GCrMult);
+ Vector128 bCbMult = Vector128.Create(YCbCrScalar.BCbMult);
// Walking 8 elements at one step:
nuint n = (uint)values.Component0.Length / (uint)Vector128.Count;
@@ -88,16 +88,16 @@ public override void ConvertFromRgb(in ComponentValues values, Span rLane
ref Unsafe.As>(ref MemoryMarshal.GetReference(bLane));
// Used for the color conversion
- var chromaOffset = Vector128.Create(this.HalfValue);
-
- var f0299 = Vector128.Create(0.299f);
- var f0587 = Vector128.Create(0.587f);
- var f0114 = Vector128.Create(0.114f);
- var fn0168736 = Vector128.Create(-0.168736f);
- var fn0331264 = Vector128.Create(-0.331264f);
- var fn0418688 = Vector128.Create(-0.418688f);
- var fn0081312F = Vector128.Create(-0.081312F);
- var f05 = Vector128.Create(0.5f);
+ Vector128 chromaOffset = Vector128.Create(this.HalfValue);
+
+ Vector128 f0299 = Vector128.Create(0.299f);
+ Vector128 f0587 = Vector128.Create(0.587f);
+ Vector128 f0114 = Vector128.Create(0.114f);
+ Vector128 fn0168736 = Vector128.Create(-0.168736f);
+ Vector128 fn0331264 = Vector128.Create(-0.331264f);
+ Vector128 fn0418688 = Vector128.Create(-0.418688f);
+ Vector128 fn0081312F = Vector128.Create(-0.081312F);
+ Vector128 f05 = Vector128.Create(0.5f);
nuint n = (uint)values.Component0.Length / (uint)Vector128.Count;
for (nuint i = 0; i < n; i++)
diff --git a/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.YCbCrAvx.cs b/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.YCbCrAvx.cs
index c5fa786e2c..80f5e6884c 100644
--- a/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.YCbCrAvx.cs
+++ b/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.YCbCrAvx.cs
@@ -30,12 +30,12 @@ public override void ConvertToRgbInplace(in ComponentValues values)
ref Unsafe.As>(ref MemoryMarshal.GetReference(values.Component2));
// Used for the color conversion
- var chromaOffset = Vector256.Create(-this.HalfValue);
- var scale = Vector256.Create(1 / this.MaximumValue);
- var rCrMult = Vector256.Create(YCbCrScalar.RCrMult);
- var gCbMult = Vector256.Create(-YCbCrScalar.GCbMult);
- var gCrMult = Vector256.Create(-YCbCrScalar.GCrMult);
- var bCbMult = Vector256.Create(YCbCrScalar.BCbMult);
+ Vector256 chromaOffset = Vector256.Create(-this.HalfValue);
+ Vector256 scale = Vector256.Create(1 / this.MaximumValue);
+ Vector256 rCrMult = Vector256.Create(YCbCrScalar.RCrMult);
+ Vector256 gCbMult = Vector256.Create(-YCbCrScalar.GCbMult);
+ Vector256 gCrMult = Vector256.Create(-YCbCrScalar.GCrMult);
+ Vector256 bCbMult = Vector256.Create(YCbCrScalar.BCbMult);
// Walking 8 elements at one step:
nuint n = values.Component0.Vector256Count();
@@ -87,16 +87,16 @@ public override void ConvertFromRgb(in ComponentValues values, Span rLane
ref Unsafe.As>(ref MemoryMarshal.GetReference(bLane));
// Used for the color conversion
- var chromaOffset = Vector256.Create(this.HalfValue);
-
- var f0299 = Vector256.Create(0.299f);
- var f0587 = Vector256.Create(0.587f);
- var f0114 = Vector256.Create(0.114f);
- var fn0168736 = Vector256.Create(-0.168736f);
- var fn0331264 = Vector256.Create(-0.331264f);
- var fn0418688 = Vector256.Create(-0.418688f);
- var fn0081312F = Vector256.Create(-0.081312F);
- var f05 = Vector256.Create(0.5f);
+ Vector256 chromaOffset = Vector256.Create(this.HalfValue);
+
+ Vector256 f0299 = Vector256.Create(0.299f);
+ Vector256 f0587 = Vector256.Create(0.587f);
+ Vector256 f0114 = Vector256.Create(0.114f);
+ Vector256 fn0168736 = Vector256.Create(-0.168736f);
+ Vector256 fn0331264 = Vector256.Create(-0.331264f);
+ Vector256 fn0418688 = Vector256.Create(-0.418688f);
+ Vector256 fn0081312F = Vector256.Create(-0.081312F);
+ Vector256 f05 = Vector256.Create(0.5f);
nuint n = values.Component0.Vector256Count();
for (nuint i = 0; i < n; i++)
diff --git a/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.YCbCrVector.cs b/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.YCbCrVector.cs
index a5d0c889e3..fe05a8e976 100644
--- a/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.YCbCrVector.cs
+++ b/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.YCbCrVector.cs
@@ -27,13 +27,13 @@ protected override void ConvertToRgbInplaceVectorized(in ComponentValues values)
ref Vector c2Base =
ref Unsafe.As>(ref MemoryMarshal.GetReference(values.Component2));
- var chromaOffset = new Vector(-this.HalfValue);
+ Vector chromaOffset = new(-this.HalfValue);
- var scale = new Vector(1 / this.MaximumValue);
- var rCrMult = new Vector(YCbCrScalar.RCrMult);
- var gCbMult = new Vector(-YCbCrScalar.GCbMult);
- var gCrMult = new Vector(-YCbCrScalar.GCrMult);
- var bCbMult = new Vector(YCbCrScalar.BCbMult);
+ Vector scale = new(1 / this.MaximumValue);
+ Vector rCrMult = new(YCbCrScalar.RCrMult);
+ Vector gCbMult = new(-YCbCrScalar.GCbMult);
+ Vector gCrMult = new(-YCbCrScalar.GCrMult);
+ Vector bCbMult = new(YCbCrScalar.BCbMult);
nuint n = values.Component0.VectorCount();
for (nuint i = 0; i < n; i++)
@@ -89,19 +89,19 @@ protected override void ConvertFromRgbVectorized(in ComponentValues values, Span
ref Vector srcB =
ref Unsafe.As>(ref MemoryMarshal.GetReference(bLane));
- var chromaOffset = new Vector(this.HalfValue);
+ Vector chromaOffset = new(this.HalfValue);
- var rYMult = new Vector(0.299f);
- var gYMult = new Vector(0.587f);
- var bYMult = new Vector(0.114f);
+ Vector rYMult = new(0.299f);
+ Vector gYMult = new(0.587f);
+ Vector bYMult = new(0.114f);
- var rCbMult = new Vector(0.168736f);
- var gCbMult = new Vector(0.331264f);
- var bCbMult = new Vector(0.5f);
+ Vector rCbMult = new(0.168736f);
+ Vector gCbMult = new(0.331264f);
+ Vector bCbMult = new(0.5f);
- var rCrMult = new Vector(0.5f);
- var gCrMult = new Vector(0.418688f);
- var bCrMult = new Vector(0.081312f);
+ Vector rCrMult = new(0.5f);
+ Vector gCrMult = new(0.418688f);
+ Vector bCrMult = new(0.081312f);
nuint n = values.Component0.VectorCount();
for (nuint i = 0; i < n; i++)
diff --git a/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.YccKArm64.cs b/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.YccKArm64.cs
index 285ba62cfd..d3e6d60c41 100644
--- a/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.YccKArm64.cs
+++ b/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.YccKArm64.cs
@@ -32,13 +32,13 @@ public override void ConvertToRgbInplace(in ComponentValues values)
ref Unsafe.As>(ref MemoryMarshal.GetReference(values.Component3));
// Used for the color conversion
- var chromaOffset = Vector128.Create(-this.HalfValue);
- var scale = Vector128.Create(1 / (this.MaximumValue * this.MaximumValue));
- var max = Vector128.Create(this.MaximumValue);
- var rCrMult = Vector128.Create(YCbCrScalar.RCrMult);
- var gCbMult = Vector128.Create(-YCbCrScalar.GCbMult);
- var gCrMult = Vector128.Create(-YCbCrScalar.GCrMult);
- var bCbMult = Vector128.Create(YCbCrScalar.BCbMult);
+ Vector128 chromaOffset = Vector128.Create(-this.HalfValue);
+ Vector128 scale = Vector128.Create(1 / (this.MaximumValue * this.MaximumValue));
+ Vector128 max = Vector128.Create(this.MaximumValue);
+ Vector128 rCrMult = Vector128.Create(YCbCrScalar.RCrMult);
+ Vector128 gCbMult = Vector128.Create(-YCbCrScalar.GCbMult);
+ Vector128 gCrMult = Vector128.Create(-YCbCrScalar.GCrMult);
+ Vector128 bCbMult = Vector128.Create(YCbCrScalar.BCbMult);
// Walking 8 elements at one step:
nuint n = (uint)values.Component0.Length / (uint)Vector128.Count;
@@ -97,18 +97,18 @@ public override void ConvertFromRgb(in ComponentValues values, Span