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 rLane ref Vector128 srcB = ref destCr; // Used for the color conversion - var maxSampleValue = Vector128.Create(this.MaximumValue); - - 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 maxSampleValue = Vector128.Create(this.MaximumValue); + + 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.YccKAvx.cs b/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.YccKAvx.cs index efe40ba085..62b5d67651 100644 --- a/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.YccKAvx.cs +++ b/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.YccKAvx.cs @@ -31,13 +31,13 @@ public override void ConvertToRgbInplace(in ComponentValues values) ref Unsafe.As>(ref MemoryMarshal.GetReference(values.Component3)); // Used for the color conversion - var chromaOffset = Vector256.Create(-this.HalfValue); - var scale = Vector256.Create(1 / (this.MaximumValue * this.MaximumValue)); - var max = Vector256.Create(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 * this.MaximumValue)); + Vector256 max = Vector256.Create(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(); @@ -96,18 +96,18 @@ public override void ConvertFromRgb(in ComponentValues values, Span rLane ref Vector256 srcB = ref destCr; // Used for the color conversion - var maxSampleValue = Vector256.Create(this.MaximumValue); - - 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 maxSampleValue = Vector256.Create(this.MaximumValue); + + 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.YccKVector.cs b/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.YccKVector.cs index 570a401adf..7ea1dfed22 100644 --- a/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.YccKVector.cs +++ b/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.YccKVector.cs @@ -28,13 +28,13 @@ protected override void ConvertToRgbInplaceVectorized(in ComponentValues values) ref Vector kBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(values.Component3)); - var chromaOffset = new Vector(-this.HalfValue); - var scale = new Vector(1 / (this.MaximumValue * this.MaximumValue)); - var max = new Vector(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 chromaOffset = new(-this.HalfValue); + Vector scale = new(1 / (this.MaximumValue * this.MaximumValue)); + Vector max = new(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++) @@ -91,21 +91,21 @@ protected override void ConvertFromRgbVectorized(in ComponentValues values, Span ref Vector srcG = ref destCb; ref Vector srcB = ref destCr; - var maxSampleValue = new Vector(this.MaximumValue); + Vector maxSampleValue = new(this.MaximumValue); - 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/JpegColorConverterBase.cs b/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverterBase.cs index 041f6b0578..8abc5edc78 100644 --- a/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverterBase.cs +++ b/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverterBase.cs @@ -357,7 +357,7 @@ public ComponentValues Slice(int start, int length) Span c2 = this.Component2.Length > 0 ? this.Component2.Slice(start, length) : Span.Empty; Span c3 = this.Component3.Length > 0 ? this.Component3.Slice(start, length) : Span.Empty; - return new ComponentValues(this.ComponentCount, c0, c1, c2, c3); + return new(this.ComponentCount, c0, c1, c2, c3); } } } diff --git a/src/ImageSharp/Formats/Jpeg/Components/Decoder/AdobeMarker.cs b/src/ImageSharp/Formats/Jpeg/Components/Decoder/AdobeMarker.cs index cf2369b2cb..5109b1862b 100644 --- a/src/ImageSharp/Formats/Jpeg/Components/Decoder/AdobeMarker.cs +++ b/src/ImageSharp/Formats/Jpeg/Components/Decoder/AdobeMarker.cs @@ -71,7 +71,7 @@ public static bool TryParse(ReadOnlySpan bytes, out AdobeMarker marker) short app14Flags1 = (short)((bytes[9] << 8) | bytes[10]); byte colorTransform = bytes[11]; - marker = new AdobeMarker(dctEncodeVersion, app14Flags0, app14Flags1, colorTransform); + marker = new(dctEncodeVersion, app14Flags0, app14Flags1, colorTransform); return true; } diff --git a/src/ImageSharp/Formats/Jpeg/Components/Decoder/ArithmeticScanDecoder.cs b/src/ImageSharp/Formats/Jpeg/Components/Decoder/ArithmeticScanDecoder.cs index 02a346ff07..1a3bb18fa1 100644 --- a/src/ImageSharp/Formats/Jpeg/Components/Decoder/ArithmeticScanDecoder.cs +++ b/src/ImageSharp/Formats/Jpeg/Components/Decoder/ArithmeticScanDecoder.cs @@ -54,12 +54,12 @@ internal class ArithmeticScanDecoder : IJpegScanDecoder private ArithmeticDecodingTable[] acDecodingTables; // Don't make this a ReadOnlySpan, as the values need to get updated. - private readonly byte[] fixedBin = { 113, 0, 0, 0 }; + private readonly byte[] fixedBin = [113, 0, 0, 0]; private readonly CancellationToken cancellationToken; private static readonly int[] ArithmeticTable = - { + [ Pack(0x5a1d, 1, 1, 1), Pack(0x2586, 14, 2, 0), Pack(0x1114, 16, 3, 0), @@ -177,9 +177,9 @@ internal class ArithmeticScanDecoder : IJpegScanDecoder // This last entry is used for fixed probability estimate of 0.5 // as suggested in Section 10.3 Table 5 of ITU-T Rec. T.851. Pack(0x5a1d, 113, 113, 0) - }; + ]; - private readonly List statistics = new(); + private readonly List statistics = []; /// /// Initializes a new instance of the class. @@ -244,7 +244,7 @@ public void ParseEntropyCodedData(int scanComponentCount) this.scanComponentCount = scanComponentCount; - this.scanBuffer = new JpegBitReader(this.stream); + this.scanBuffer = new(this.stream); this.frame.AllocateComponents(); diff --git a/src/ImageSharp/Formats/Jpeg/Components/Decoder/HuffmanScanDecoder.cs b/src/ImageSharp/Formats/Jpeg/Components/Decoder/HuffmanScanDecoder.cs index bbd2bff53b..3224a05de3 100644 --- a/src/ImageSharp/Formats/Jpeg/Components/Decoder/HuffmanScanDecoder.cs +++ b/src/ImageSharp/Formats/Jpeg/Components/Decoder/HuffmanScanDecoder.cs @@ -115,7 +115,7 @@ public void ParseEntropyCodedData(int scanComponentCount) this.scanComponentCount = scanComponentCount; - this.scanBuffer = new JpegBitReader(this.stream); + this.scanBuffer = new(this.stream); this.frame.AllocateComponents(); @@ -182,7 +182,7 @@ private void ParseBaselineDataInterleaved() for (int k = 0; k < this.scanComponentCount; k++) { int order = this.frame.ComponentOrder[k]; - var component = this.components[order] as JpegComponent; + JpegComponent component = this.components[order] as JpegComponent; ref HuffmanTable dcHuffmanTable = ref this.dcHuffmanTables[component.DcTableId]; ref HuffmanTable acHuffmanTable = ref this.acHuffmanTables[component.AcTableId]; @@ -231,7 +231,7 @@ ref Unsafe.Add(ref blockRef, (uint)blockCol), private void ParseBaselineDataNonInterleaved() { - var component = this.components[this.frame.ComponentOrder[0]] as JpegComponent; + JpegComponent component = this.components[this.frame.ComponentOrder[0]] as JpegComponent; ref JpegBitReader buffer = ref this.scanBuffer; int w = component.WidthInBlocks; @@ -392,7 +392,7 @@ private void ParseProgressiveDataInterleaved() for (int k = 0; k < this.scanComponentCount; k++) { int order = this.frame.ComponentOrder[k]; - var component = this.components[order] as JpegComponent; + JpegComponent component = this.components[order] as JpegComponent; ref HuffmanTable dcHuffmanTable = ref this.dcHuffmanTables[component.DcTableId]; int h = component.HorizontalSamplingFactor; @@ -433,7 +433,7 @@ ref Unsafe.Add(ref blockRef, (uint)blockCol), private void ParseProgressiveDataNonInterleaved() { - var component = this.components[this.frame.ComponentOrder[0]] as JpegComponent; + JpegComponent component = this.components[this.frame.ComponentOrder[0]] as JpegComponent; ref JpegBitReader buffer = ref this.scanBuffer; int w = component.WidthInBlocks; @@ -781,6 +781,6 @@ private bool HandleRestart() public void BuildHuffmanTable(int type, int index, ReadOnlySpan codeLengths, ReadOnlySpan values, Span workspace) { HuffmanTable[] tables = type == 0 ? this.dcHuffmanTables : this.acHuffmanTables; - tables[index] = new HuffmanTable(codeLengths, values, workspace); + tables[index] = new(codeLengths, values, workspace); } } diff --git a/src/ImageSharp/Formats/Jpeg/Components/Decoder/JFifMarker.cs b/src/ImageSharp/Formats/Jpeg/Components/Decoder/JFifMarker.cs index 7e25e945a5..b31376992f 100644 --- a/src/ImageSharp/Formats/Jpeg/Components/Decoder/JFifMarker.cs +++ b/src/ImageSharp/Formats/Jpeg/Components/Decoder/JFifMarker.cs @@ -80,7 +80,7 @@ public static bool TryParse(ReadOnlySpan bytes, out JFifMarker marker) byte densityUnits = bytes[7]; short xDensity = (short)((bytes[8] << 8) | bytes[9]); short yDensity = (short)((bytes[10] << 8) | bytes[11]); - marker = new JFifMarker(majorVersion, minorVersion, densityUnits, xDensity, yDensity); + marker = new(majorVersion, minorVersion, densityUnits, xDensity, yDensity); return true; } diff --git a/src/ImageSharp/Formats/Jpeg/Components/Decoder/JpegComponent.cs b/src/ImageSharp/Formats/Jpeg/Components/Decoder/JpegComponent.cs index b2debf3938..7e4a06d41a 100644 --- a/src/ImageSharp/Formats/Jpeg/Components/Decoder/JpegComponent.cs +++ b/src/ImageSharp/Formats/Jpeg/Components/Decoder/JpegComponent.cs @@ -21,7 +21,7 @@ public JpegComponent(MemoryAllocator memoryAllocator, JpegFrame frame, byte id, this.HorizontalSamplingFactor = horizontalFactor; this.VerticalSamplingFactor = verticalFactor; - this.SamplingFactors = new Size(this.HorizontalSamplingFactor, this.VerticalSamplingFactor); + this.SamplingFactors = new(this.HorizontalSamplingFactor, this.VerticalSamplingFactor); this.QuantizationTableIndex = quantizationTableIndex; this.Index = index; @@ -109,7 +109,7 @@ public void Init(int maxSubFactorH, int maxSubFactorV) int blocksPerLineForMcu = this.Frame.McusPerLine * this.HorizontalSamplingFactor; int blocksPerColumnForMcu = this.Frame.McusPerColumn * this.VerticalSamplingFactor; - this.SizeInBlocks = new Size(blocksPerLineForMcu, blocksPerColumnForMcu); + this.SizeInBlocks = new(blocksPerLineForMcu, blocksPerColumnForMcu); this.SubSamplingDivisors = new Size(maxSubFactorH, maxSubFactorV).DivideBy(this.SamplingFactors); diff --git a/src/ImageSharp/Formats/Jpeg/Components/Decoder/ProfileResolver.cs b/src/ImageSharp/Formats/Jpeg/Components/Decoder/ProfileResolver.cs index c11679feb1..b83c01064a 100644 --- a/src/ImageSharp/Formats/Jpeg/Components/Decoder/ProfileResolver.cs +++ b/src/ImageSharp/Formats/Jpeg/Components/Decoder/ProfileResolver.cs @@ -11,80 +11,80 @@ internal static class ProfileResolver /// /// Gets the JFIF specific markers. /// - public static ReadOnlySpan JFifMarker => new[] - { + public static ReadOnlySpan JFifMarker => + [ (byte)'J', (byte)'F', (byte)'I', (byte)'F', (byte)'\0' - }; + ]; /// /// Gets the JFXX specific markers. /// - public static ReadOnlySpan JFxxMarker => new[] - { + public static ReadOnlySpan JFxxMarker => + [ (byte)'J', (byte)'F', (byte)'X', (byte)'X', (byte)'\0' - }; + ]; /// /// Gets the ICC specific markers. /// - public static ReadOnlySpan IccMarker => new[] - { + public static ReadOnlySpan IccMarker => + [ (byte)'I', (byte)'C', (byte)'C', (byte)'_', (byte)'P', (byte)'R', (byte)'O', (byte)'F', (byte)'I', (byte)'L', (byte)'E', (byte)'\0' - }; + ]; /// /// Gets the adobe photoshop APP13 marker which can contain IPTC meta data. /// - public static ReadOnlySpan AdobePhotoshopApp13Marker => new[] - { + public static ReadOnlySpan AdobePhotoshopApp13Marker => + [ (byte)'P', (byte)'h', (byte)'o', (byte)'t', (byte)'o', (byte)'s', (byte)'h', (byte)'o', (byte)'p', (byte)' ', (byte)'3', (byte)'.', (byte)'0', (byte)'\0' - }; + ]; /// /// Gets the 8BIM marker, which signals the start of a adobe specific image resource block. /// - public static ReadOnlySpan AdobeImageResourceBlockMarker => new[] - { + public static ReadOnlySpan AdobeImageResourceBlockMarker => + [ (byte)'8', (byte)'B', (byte)'I', (byte)'M' - }; + ]; /// /// Gets a IPTC Image resource ID. /// - public static ReadOnlySpan AdobeIptcMarker => new[] - { + public static ReadOnlySpan AdobeIptcMarker => + [ (byte)4, (byte)4 - }; + ]; /// /// Gets the EXIF specific markers. /// - public static ReadOnlySpan ExifMarker => new[] - { + public static ReadOnlySpan ExifMarker => + [ (byte)'E', (byte)'x', (byte)'i', (byte)'f', (byte)'\0', (byte)'\0' - }; + ]; /// /// Gets the XMP specific markers. /// - public static ReadOnlySpan XmpMarker => new[] - { + public static ReadOnlySpan XmpMarker => + [ (byte)'h', (byte)'t', (byte)'t', (byte)'p', (byte)':', (byte)'/', (byte)'/', (byte)'n', (byte)'s', (byte)'.', (byte)'a', (byte)'d', (byte)'o', (byte)'b', (byte)'e', (byte)'.', (byte)'c', (byte)'o', (byte)'m', (byte)'/', (byte)'x', (byte)'a', (byte)'p', (byte)'/', (byte)'1', (byte)'.', (byte)'0', (byte)'/', (byte)0 - }; + ]; /// /// Gets the Adobe specific markers . /// - public static ReadOnlySpan AdobeMarker => new[] - { + public static ReadOnlySpan AdobeMarker => + [ (byte)'A', (byte)'d', (byte)'o', (byte)'b', (byte)'e' - }; + ]; /// /// Returns a value indicating whether the passed bytes are a match to the profile identifier. diff --git a/src/ImageSharp/Formats/Jpeg/Components/Decoder/SpectralConverter.cs b/src/ImageSharp/Formats/Jpeg/Components/Decoder/SpectralConverter.cs index 51d9bfbced..7e6e8755a7 100644 --- a/src/ImageSharp/Formats/Jpeg/Components/Decoder/SpectralConverter.cs +++ b/src/ImageSharp/Formats/Jpeg/Components/Decoder/SpectralConverter.cs @@ -11,8 +11,8 @@ internal abstract class SpectralConverter /// /// Supported scaled spectral block sizes for scaled IDCT decoding. /// - private static readonly int[] ScaledBlockSizes = new int[] - { + private static readonly int[] ScaledBlockSizes = + [ // 8 => 1, 1/8 of the original size 1, @@ -20,8 +20,8 @@ internal abstract class SpectralConverter 2, // 8 => 4, 1/2 of the original size - 4, - }; + 4 + ]; /// /// Gets a value indicating whether this converter has converted spectral @@ -114,7 +114,7 @@ public static Size CalculateResultingImageSize(Size size, Size? targetSize, out if (scaledWidth >= tSize.Width && scaledHeight >= tSize.Height) { blockPixelSize = blockSize; - return new Size(scaledWidth, scaledHeight); + return new(scaledWidth, scaledHeight); } } } diff --git a/src/ImageSharp/Formats/Jpeg/Components/Encoder/Component.cs b/src/ImageSharp/Formats/Jpeg/Components/Encoder/Component.cs index cc565c4d84..7398e97a01 100644 --- a/src/ImageSharp/Formats/Jpeg/Components/Encoder/Component.cs +++ b/src/ImageSharp/Formats/Jpeg/Components/Encoder/Component.cs @@ -19,7 +19,7 @@ public Component(MemoryAllocator memoryAllocator, int horizontalFactor, int vert this.HorizontalSamplingFactor = horizontalFactor; this.VerticalSamplingFactor = verticalFactor; - this.SamplingFactors = new Size(horizontalFactor, verticalFactor); + this.SamplingFactors = new(horizontalFactor, verticalFactor); this.QuantizationTableIndex = quantizationTableIndex; } @@ -95,7 +95,7 @@ public void Init(JpegFrame frame, int maxSubFactorH, int maxSubFactorV) int blocksPerLineForMcu = frame.McusPerLine * this.HorizontalSamplingFactor; int blocksPerColumnForMcu = frame.McusPerColumn * this.VerticalSamplingFactor; - this.SizeInBlocks = new Size(blocksPerLineForMcu, blocksPerColumnForMcu); + this.SizeInBlocks = new(blocksPerLineForMcu, blocksPerColumnForMcu); this.SubSamplingDivisors = new Size(maxSubFactorH, maxSubFactorV).DivideBy(this.SamplingFactors); diff --git a/src/ImageSharp/Formats/Jpeg/Components/Encoder/ComponentProcessor.cs b/src/ImageSharp/Formats/Jpeg/Components/Encoder/ComponentProcessor.cs index c33a8a1968..1b0a177049 100644 --- a/src/ImageSharp/Formats/Jpeg/Components/Encoder/ComponentProcessor.cs +++ b/src/ImageSharp/Formats/Jpeg/Components/Encoder/ComponentProcessor.cs @@ -241,7 +241,7 @@ static void MultiplyToAverage(Span target, float multiplier) ref Vector targetVectorRef = ref Unsafe.As>(ref MemoryMarshal.GetReference(target)); nuint count = target.VectorCount(); - var multiplierVector = new Vector(multiplier); + Vector multiplierVector = new(multiplier); for (nuint i = 0; i < count; i++) { Unsafe.Add(ref targetVectorRef, i) *= multiplierVector; diff --git a/src/ImageSharp/Formats/Jpeg/Components/Encoder/HuffmanScanEncoder.cs b/src/ImageSharp/Formats/Jpeg/Components/Encoder/HuffmanScanEncoder.cs index ac527ff312..b68be78b71 100644 --- a/src/ImageSharp/Formats/Jpeg/Components/Encoder/HuffmanScanEncoder.cs +++ b/src/ImageSharp/Formats/Jpeg/Components/Encoder/HuffmanScanEncoder.cs @@ -129,7 +129,7 @@ private bool IsStreamFlushNeeded public void BuildHuffmanTable(JpegHuffmanTableConfig tableConfig) { HuffmanLut[] tables = tableConfig.Class == 0 ? this.dcHuffmanTables : this.acHuffmanTables; - tables[tableConfig.DestinationIndex] = new HuffmanLut(tableConfig.Table); + tables[tableConfig.DestinationIndex] = new(tableConfig.Table); } /// diff --git a/src/ImageSharp/Formats/Jpeg/Components/Encoder/HuffmanSpec.cs b/src/ImageSharp/Formats/Jpeg/Components/Encoder/HuffmanSpec.cs index f5666f7799..502b919177 100644 --- a/src/ImageSharp/Formats/Jpeg/Components/Encoder/HuffmanSpec.cs +++ b/src/ImageSharp/Formats/Jpeg/Components/Encoder/HuffmanSpec.cs @@ -15,15 +15,13 @@ internal readonly struct HuffmanSpec /// This is an example specification taken from the jpeg specification paper. /// public static readonly HuffmanSpec LuminanceDC = new( - new byte[] - { + [ 0, 1, 5, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0 - }, - new byte[] - { + ], + [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 - }); + ]); /// /// Huffman talbe specification for luminance AC. @@ -32,13 +30,11 @@ internal readonly struct HuffmanSpec /// This is an example specification taken from the jpeg specification paper. /// public static readonly HuffmanSpec LuminanceAC = new( - new byte[] - { + [ 0, 2, 1, 3, 3, 2, 4, 3, 5, 5, 4, 4, 0, 0, 1, 125 - }, - new byte[] - { + ], + [ 0x01, 0x02, 0x03, 0x00, 0x04, 0x11, 0x05, 0x12, 0x21, 0x31, 0x41, 0x06, 0x13, 0x51, 0x61, 0x07, 0x22, 0x71, 0x14, 0x32, @@ -63,7 +59,7 @@ internal readonly struct HuffmanSpec 0xe5, 0xe6, 0xe7, 0xe8, 0xe9, 0xea, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8, 0xf9, 0xfa - }); + ]); /// /// Huffman talbe specification for chrominance DC. @@ -72,15 +68,13 @@ internal readonly struct HuffmanSpec /// This is an example specification taken from the jpeg specification paper. /// public static readonly HuffmanSpec ChrominanceDC = new( - new byte[] - { + [ 0, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0 - }, - new byte[] - { + ], + [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 - }); + ]); /// /// Huffman talbe specification for chrominance DC. @@ -89,13 +83,11 @@ internal readonly struct HuffmanSpec /// This is an example specification taken from the jpeg specification paper. /// public static readonly HuffmanSpec ChrominanceAC = new( - new byte[] - { + [ 0, 2, 1, 2, 4, 4, 3, 4, 7, 5, 4, 4, 0, 1, 2, 119 - }, - new byte[] - { + ], + [ 0x00, 0x01, 0x02, 0x03, 0x11, 0x04, 0x05, 0x21, 0x31, 0x06, 0x12, 0x41, 0x51, 0x07, 0x61, 0x71, 0x13, 0x22, 0x32, 0x81, @@ -120,7 +112,7 @@ internal readonly struct HuffmanSpec 0xe4, 0xe5, 0xe6, 0xe7, 0xe8, 0xe9, 0xea, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8, 0xf9, 0xfa - }); + ]); /// /// Initializes a new instance of the struct. diff --git a/src/ImageSharp/Formats/Jpeg/Components/Encoder/JpegFrame.cs b/src/ImageSharp/Formats/Jpeg/Components/Encoder/JpegFrame.cs index 6ba0b82723..f8a3d6dd2d 100644 --- a/src/ImageSharp/Formats/Jpeg/Components/Encoder/JpegFrame.cs +++ b/src/ImageSharp/Formats/Jpeg/Components/Encoder/JpegFrame.cs @@ -27,7 +27,7 @@ public JpegFrame(Image image, JpegFrameConfig frameConfig, bool interleaved) for (int i = 0; i < this.Components.Length; i++) { JpegComponentConfig componentConfig = componentConfigs[i]; - this.Components[i] = new Component(allocator, componentConfig.HorizontalSampleFactor, componentConfig.VerticalSampleFactor, componentConfig.QuantizatioTableIndex) + this.Components[i] = new(allocator, componentConfig.HorizontalSampleFactor, componentConfig.VerticalSampleFactor, componentConfig.QuantizatioTableIndex) { DcTableId = componentConfig.DcTableSelector, AcTableId = componentConfig.AcTableSelector, diff --git a/src/ImageSharp/Formats/Jpeg/Components/Encoder/SpectralConverter{TPixel}.cs b/src/ImageSharp/Formats/Jpeg/Components/Encoder/SpectralConverter{TPixel}.cs index fc93db9bb0..37ff2a143c 100644 --- a/src/ImageSharp/Formats/Jpeg/Components/Encoder/SpectralConverter{TPixel}.cs +++ b/src/ImageSharp/Formats/Jpeg/Components/Encoder/SpectralConverter{TPixel}.cs @@ -47,12 +47,12 @@ public SpectralConverter(JpegFrame frame, Image image, Block8x8F[] dequa // component processors from spectral to Rgb24 const int blockPixelWidth = 8; this.alignedPixelWidth = majorBlockWidth * blockPixelWidth; - var postProcessorBufferSize = new Size(this.alignedPixelWidth, this.pixelRowsPerStep); + Size postProcessorBufferSize = new(this.alignedPixelWidth, this.pixelRowsPerStep); this.componentProcessors = new ComponentProcessor[frame.Components.Length]; for (int i = 0; i < this.componentProcessors.Length; i++) { Component component = frame.Components[i]; - this.componentProcessors[i] = new ComponentProcessor( + this.componentProcessors[i] = new( allocator, component, postProcessorBufferSize, @@ -118,7 +118,7 @@ private void ConvertStride(int spectralStep) bLane.Slice(paddingStartIndex).Fill(bLane[paddingStartIndex - 1]); // Convert from rgb24 to target pixel type - var values = new JpegColorConverterBase.ComponentValues(this.componentProcessors, y); + JpegColorConverterBase.ComponentValues values = new(this.componentProcessors, y); this.colorConverter.ConvertFromRgb(values, rLane, gLane, bLane); } diff --git a/src/ImageSharp/Formats/Jpeg/Components/FloatingPointDCT.Intrinsic.cs b/src/ImageSharp/Formats/Jpeg/Components/FloatingPointDCT.Intrinsic.cs index 7e102f696d..27744752b6 100644 --- a/src/ImageSharp/Formats/Jpeg/Components/FloatingPointDCT.Intrinsic.cs +++ b/src/ImageSharp/Formats/Jpeg/Components/FloatingPointDCT.Intrinsic.cs @@ -44,7 +44,7 @@ static void FDCT8x8_1D_Avx(ref Block8x8F block) block.V0 = Avx.Add(tmp10, tmp11); block.V4 = Avx.Subtract(tmp10, tmp11); - var mm256_F_0_7071 = Vector256.Create(0.707106781f); + Vector256 mm256_F_0_7071 = Vector256.Create(0.707106781f); Vector256 z1 = Avx.Multiply(Avx.Add(tmp12, tmp13), mm256_F_0_7071); block.V2 = Avx.Add(tmp13, z1); block.V6 = Avx.Subtract(tmp13, z1); @@ -97,7 +97,7 @@ static void IDCT8x8_1D_Avx(ref Block8x8F block) Vector256 tmp10 = Avx.Add(z5, tmp2); Vector256 tmp11 = Avx.Subtract(z5, tmp2); - var mm256_F_1_4142 = Vector256.Create(1.414213562f); + Vector256 mm256_F_1_4142 = Vector256.Create(1.414213562f); Vector256 tmp13 = Avx.Add(tmp1, tmp3); Vector256 tmp12 = SimdUtils.HwIntrinsics.MultiplySubtract(tmp13, Avx.Subtract(tmp1, tmp3), mm256_F_1_4142); diff --git a/src/ImageSharp/Formats/Jpeg/Components/FloatingPointDCT.cs b/src/ImageSharp/Formats/Jpeg/Components/FloatingPointDCT.cs index 0aca33b4c9..0bac928564 100644 --- a/src/ImageSharp/Formats/Jpeg/Components/FloatingPointDCT.cs +++ b/src/ImageSharp/Formats/Jpeg/Components/FloatingPointDCT.cs @@ -49,8 +49,8 @@ internal static partial class FloatingPointDCT /// /// /// - private static readonly float[] AdjustmentCoefficients = new float[] - { + private static readonly float[] AdjustmentCoefficients = + [ 1f, 1.3870399f, 1.306563f, 1.1758755f, 1f, 0.78569496f, 0.5411961f, 0.27589938f, 1.3870399f, 1.9238797f, 1.812255f, 1.6309863f, 1.3870399f, 1.0897902f, 0.7506606f, 0.38268346f, 1.306563f, 1.812255f, 1.707107f, 1.5363555f, 1.306563f, 1.02656f, 0.7071068f, 0.36047992f, @@ -58,8 +58,8 @@ internal static partial class FloatingPointDCT 1f, 1.3870399f, 1.306563f, 1.1758755f, 1f, 0.78569496f, 0.5411961f, 0.27589938f, 0.78569496f, 1.0897902f, 1.02656f, 0.9238795f, 0.78569496f, 0.61731654f, 0.42521507f, 0.21677275f, 0.5411961f, 0.7506606f, 0.7071068f, 0.63637924f, 0.5411961f, 0.42521507f, 0.29289323f, 0.14931567f, - 0.27589938f, 0.38268346f, 0.36047992f, 0.32442334f, 0.27589938f, 0.21677275f, 0.14931567f, 0.076120466f, - }; + 0.27589938f, 0.38268346f, 0.36047992f, 0.32442334f, 0.27589938f, 0.21677275f, 0.14931567f, 0.076120466f + ]; /// /// Adjusts given quantization table for usage with . diff --git a/src/ImageSharp/Formats/Jpeg/Components/Quantization.cs b/src/ImageSharp/Formats/Jpeg/Components/Quantization.cs index 7dca1cf5ea..644cf2df57 100644 --- a/src/ImageSharp/Formats/Jpeg/Components/Quantization.cs +++ b/src/ImageSharp/Formats/Jpeg/Components/Quantization.cs @@ -46,8 +46,8 @@ internal static class Quantization // The C# compiler emits this as a compile-time constant embedded in the PE file. // This is effectively compiled down to: return new ReadOnlySpan(&data, length) // More details can be found: https://github.com/dotnet/roslyn/pull/24621 - public static ReadOnlySpan LuminanceTable => new byte[] - { + public static ReadOnlySpan LuminanceTable => + [ 16, 11, 10, 16, 24, 40, 51, 61, 12, 12, 14, 19, 26, 58, 60, 55, 14, 13, 16, 24, 40, 57, 69, 56, @@ -55,8 +55,8 @@ internal static class Quantization 18, 22, 37, 56, 68, 109, 103, 77, 24, 35, 55, 64, 81, 104, 113, 92, 49, 64, 78, 87, 103, 121, 120, 101, - 72, 92, 95, 98, 112, 100, 103, 99, - }; + 72, 92, 95, 98, 112, 100, 103, 99 + ]; /// /// Gets unscaled chrominance quantization table. @@ -67,8 +67,8 @@ internal static class Quantization // The C# compiler emits this as a compile-time constant embedded in the PE file. // This is effectively compiled down to: return new ReadOnlySpan(&data, length) // More details can be found: https://github.com/dotnet/roslyn/pull/24621 - public static ReadOnlySpan ChrominanceTable => new byte[] - { + public static ReadOnlySpan ChrominanceTable => + [ 17, 18, 24, 47, 99, 99, 99, 99, 18, 21, 26, 66, 99, 99, 99, 99, 24, 26, 56, 99, 99, 99, 99, 99, @@ -76,8 +76,8 @@ internal static class Quantization 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, - 99, 99, 99, 99, 99, 99, 99, 99, - }; + 99, 99, 99, 99, 99, 99, 99, 99 + ]; /// Ported from JPEGsnoop: /// https://github.com/ImpulseAdventure/JPEGsnoop/blob/9732ee0961f100eb69bbff4a0c47438d5997abee/source/JfifDecode.cpp#L4570-L4694 diff --git a/src/ImageSharp/Formats/Jpeg/Components/SizeExtensions.cs b/src/ImageSharp/Formats/Jpeg/Components/SizeExtensions.cs index c7212fc2df..c92c2e7bd9 100644 --- a/src/ImageSharp/Formats/Jpeg/Components/SizeExtensions.cs +++ b/src/ImageSharp/Formats/Jpeg/Components/SizeExtensions.cs @@ -14,25 +14,25 @@ internal static class SizeExtensions /// Multiplies 'a.Width' with 'b.Width' and 'a.Height' with 'b.Height'. /// TODO: Shouldn't we expose this as operator in SixLabors.Core? /// - public static Size MultiplyBy(this Size a, Size b) => new Size(a.Width * b.Width, a.Height * b.Height); + public static Size MultiplyBy(this Size a, Size b) => new(a.Width * b.Width, a.Height * b.Height); /// /// Divides 'a.Width' with 'b.Width' and 'a.Height' with 'b.Height'. /// TODO: Shouldn't we expose this as operator in SixLabors.Core? /// - public static Size DivideBy(this Size a, Size b) => new Size(a.Width / b.Width, a.Height / b.Height); + public static Size DivideBy(this Size a, Size b) => new(a.Width / b.Width, a.Height / b.Height); /// /// Divide Width and Height as real numbers and return the Ceiling. /// public static Size DivideRoundUp(this Size originalSize, int divX, int divY) { - var sizeVect = (Vector2)(SizeF)originalSize; + Vector2 sizeVect = (Vector2)(SizeF)originalSize; sizeVect /= new Vector2(divX, divY); sizeVect.X = MathF.Ceiling(sizeVect.X); sizeVect.Y = MathF.Ceiling(sizeVect.Y); - return new Size((int)sizeVect.X, (int)sizeVect.Y); + return new((int)sizeVect.X, (int)sizeVect.Y); } /// diff --git a/src/ImageSharp/Formats/Jpeg/Components/ZigZag.cs b/src/ImageSharp/Formats/Jpeg/Components/ZigZag.cs index 7b0e096e2a..630017082d 100644 --- a/src/ImageSharp/Formats/Jpeg/Components/ZigZag.cs +++ b/src/ImageSharp/Formats/Jpeg/Components/ZigZag.cs @@ -18,8 +18,8 @@ internal static partial class ZigZag /// The worst case would be a run-length of 15, which means we need 16 /// fake entries. /// - public static ReadOnlySpan ZigZagOrder => new byte[] - { + public static ReadOnlySpan ZigZagOrder => + [ 0, 1, 8, 16, 9, 2, 3, 10, 17, 24, 32, 25, 18, 11, 4, 5, 12, 19, 26, 33, 40, 48, 41, 34, @@ -32,7 +32,7 @@ internal static partial class ZigZag // Extra entries for safety in decoder 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63 - }; + ]; /// /// Gets span of zig-zag with fused transpose step ordering indices. @@ -47,8 +47,8 @@ internal static partial class ZigZag /// The worst case would be a run-length of 15, which means we need 16 /// fake entries. /// - public static ReadOnlySpan TransposingOrder => new byte[] - { + public static ReadOnlySpan TransposingOrder => + [ 0, 8, 1, 2, 9, 16, 24, 17, 10, 3, 4, 11, 18, 25, 32, 40, 33, 26, 19, 12, 5, 6, 13, 20, @@ -61,5 +61,5 @@ internal static partial class ZigZag // Extra entries for safety in decoder 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63 - }; + ]; } diff --git a/src/ImageSharp/Formats/Jpeg/JpegConstants.cs b/src/ImageSharp/Formats/Jpeg/JpegConstants.cs index 7a627b7b84..50b7de68e4 100644 --- a/src/ImageSharp/Formats/Jpeg/JpegConstants.cs +++ b/src/ImageSharp/Formats/Jpeg/JpegConstants.cs @@ -18,12 +18,12 @@ internal static class JpegConstants /// /// The list of mimetypes that equate to a jpeg. /// - public static readonly IEnumerable MimeTypes = new[] { "image/jpeg", "image/pjpeg" }; + public static readonly IEnumerable MimeTypes = ["image/jpeg", "image/pjpeg"]; /// /// The list of file extensions that equate to a jpeg. /// - public static readonly IEnumerable FileExtensions = new[] { "jpg", "jpeg", "jfif" }; + public static readonly IEnumerable FileExtensions = ["jpg", "jpeg", "jfif"]; /// /// Contains marker specific constants. diff --git a/src/ImageSharp/Formats/Jpeg/JpegDecoderCore.cs b/src/ImageSharp/Formats/Jpeg/JpegDecoderCore.cs index 2320fe1791..dd367bb4c6 100644 --- a/src/ImageSharp/Formats/Jpeg/JpegDecoderCore.cs +++ b/src/ImageSharp/Formats/Jpeg/JpegDecoderCore.cs @@ -128,7 +128,7 @@ public JpegDecoderCore(JpegDecoderOptions options) /// Gets the only supported precisions /// // Refers to assembly's static data segment, no allocation occurs. - private static ReadOnlySpan SupportedPrecisions => new byte[] { 8, 12 }; + private static ReadOnlySpan SupportedPrecisions => [8, 12]; /// /// Gets the frame @@ -166,7 +166,7 @@ public static JpegFileMarker FindNextFileMarker(BufferedReadStream stream) int b = stream.ReadByte(); if (b == -1) { - return new JpegFileMarker(JpegConstants.Markers.EOI, stream.Length - 2); + return new(JpegConstants.Markers.EOI, stream.Length - 2); } // Found a marker. @@ -178,14 +178,14 @@ public static JpegFileMarker FindNextFileMarker(BufferedReadStream stream) b = stream.ReadByte(); if (b == -1) { - return new JpegFileMarker(JpegConstants.Markers.EOI, stream.Length - 2); + return new(JpegConstants.Markers.EOI, stream.Length - 2); } } // Found a valid marker. Exit loop if (b is not 0 and (< JpegConstants.Markers.RST0 or > JpegConstants.Markers.RST7)) { - return new JpegFileMarker((byte)(uint)b, stream.Position - 2); + return new((byte)(uint)b, stream.Position - 2); } } } @@ -202,7 +202,7 @@ protected override Image Decode(BufferedReadStream stream, Cance this.InitXmpProfile(); this.InitDerivedMetadataProperties(); - return new Image( + return new( this.configuration, spectralConverter.GetPixelBuffer(cancellationToken), this.Metadata); @@ -219,7 +219,7 @@ protected override ImageInfo Identify(BufferedReadStream stream, CancellationTok this.InitDerivedMetadataProperties(); Size pixelSize = this.Frame.PixelSize; - return new ImageInfo(new(pixelSize.Width, pixelSize.Height), this.Metadata); + return new(new(pixelSize.Width, pixelSize.Height), this.Metadata); } /// @@ -230,7 +230,7 @@ protected override ImageInfo Identify(BufferedReadStream stream, CancellationTok /// The scan decoder. public void LoadTables(byte[] tableBytes, IJpegScanDecoder scanDecoder) { - this.Metadata = new ImageMetadata(); + this.Metadata = new(); this.QuantizationTables = new Block8x8F[4]; this.scanDecoder = scanDecoder; if (tableBytes.Length < 4) @@ -253,7 +253,7 @@ public void LoadTables(byte[] tableBytes, IJpegScanDecoder scanDecoder) // Read next marker. bytesRead = stream.Read(markerBuffer); - fileMarker = new JpegFileMarker(markerBuffer[1], (int)stream.Position - 2); + fileMarker = new(markerBuffer[1], (int)stream.Position - 2); while (fileMarker.Marker != JpegConstants.Markers.EOI || (fileMarker.Marker == JpegConstants.Markers.EOI && fileMarker.Invalid)) { @@ -297,7 +297,7 @@ public void LoadTables(byte[] tableBytes, IJpegScanDecoder scanDecoder) JpegThrowHelper.ThrowInvalidImageContentException("Not enough data to read marker"); } - fileMarker = new JpegFileMarker(markerBuffer[1], 0); + fileMarker = new(markerBuffer[1], 0); } } @@ -313,7 +313,7 @@ internal void ParseStream(BufferedReadStream stream, SpectralConverter spectralC this.scanDecoder ??= new HuffmanScanDecoder(stream, spectralConverter, cancellationToken); - this.Metadata = new ImageMetadata(); + this.Metadata = new(); Span markerBuffer = stackalloc byte[2]; @@ -526,7 +526,7 @@ private void ProcessComMarker(BufferedReadStream stream, int markerContentByteSi chars[i] = (char)read; } - metadata.Comments.Add(new JpegComData(chars)); + metadata.Comments.Add(new(chars)); } /// @@ -658,7 +658,7 @@ private void InitExifProfile() { if (this.hasExif) { - this.Metadata.ExifProfile = new ExifProfile(this.exifData); + this.Metadata.ExifProfile = new(this.exifData); } } @@ -684,7 +684,7 @@ private void InitIptcProfile() { if (this.hasIptc) { - this.Metadata.IptcProfile = new IptcProfile(this.iptcData); + this.Metadata.IptcProfile = new(this.iptcData); } } @@ -695,7 +695,7 @@ private void InitXmpProfile() { if (this.hasXmp) { - this.Metadata.XmpProfile = new XmpProfile(this.xmpData); + this.Metadata.XmpProfile = new(this.xmpData); } } @@ -979,7 +979,7 @@ private void ProcessApp13Marker(BufferedReadStream stream, int remaining) /// The remaining bytes in the segment block. private void ProcessArithmeticTable(BufferedReadStream stream, int remaining) { - this.arithmeticDecodingTables ??= new List(4); + this.arithmeticDecodingTables ??= new(4); while (remaining > 0) { @@ -1229,7 +1229,7 @@ private void ProcessStartOfFrameMarker(BufferedReadStream stream, int remaining, JpegThrowHelper.ThrowNotSupportedComponentCount(componentCount); } - this.Frame = new JpegFrame(frameMarker, precision, frameWidth, frameHeight, componentCount); + this.Frame = new(frameMarker, precision, frameWidth, frameHeight, componentCount); this.Dimensions = new(frameWidth, frameHeight); this.Metadata.GetJpegMetadata().Progressive = this.Frame.Progressive; diff --git a/src/ImageSharp/Formats/Jpeg/JpegEncoderCore.FrameConfig.cs b/src/ImageSharp/Formats/Jpeg/JpegEncoderCore.FrameConfig.cs index 71f852a092..012635a0e8 100644 --- a/src/ImageSharp/Formats/Jpeg/JpegEncoderCore.FrameConfig.cs +++ b/src/ImageSharp/Formats/Jpeg/JpegEncoderCore.FrameConfig.cs @@ -13,183 +13,166 @@ internal sealed unsafe partial class JpegEncoderCore { private static JpegFrameConfig[] CreateFrameConfigs() { - var defaultLuminanceHuffmanDC = new JpegHuffmanTableConfig(@class: 0, destIndex: 0, HuffmanSpec.LuminanceDC); - var defaultLuminanceHuffmanAC = new JpegHuffmanTableConfig(@class: 1, destIndex: 0, HuffmanSpec.LuminanceAC); - var defaultChrominanceHuffmanDC = new JpegHuffmanTableConfig(@class: 0, destIndex: 1, HuffmanSpec.ChrominanceDC); - var defaultChrominanceHuffmanAC = new JpegHuffmanTableConfig(@class: 1, destIndex: 1, HuffmanSpec.ChrominanceAC); + JpegHuffmanTableConfig defaultLuminanceHuffmanDC = new(@class: 0, destIndex: 0, HuffmanSpec.LuminanceDC); + JpegHuffmanTableConfig defaultLuminanceHuffmanAC = new(@class: 1, destIndex: 0, HuffmanSpec.LuminanceAC); + JpegHuffmanTableConfig defaultChrominanceHuffmanDC = new(@class: 0, destIndex: 1, HuffmanSpec.ChrominanceDC); + JpegHuffmanTableConfig defaultChrominanceHuffmanAC = new(@class: 1, destIndex: 1, HuffmanSpec.ChrominanceAC); - var defaultLuminanceQuantTable = new JpegQuantizationTableConfig(0, Quantization.LuminanceTable); - var defaultChrominanceQuantTable = new JpegQuantizationTableConfig(1, Quantization.ChrominanceTable); + JpegQuantizationTableConfig defaultLuminanceQuantTable = new(0, Quantization.LuminanceTable); + JpegQuantizationTableConfig defaultChrominanceQuantTable = new(1, Quantization.ChrominanceTable); - var yCbCrHuffmanConfigs = new JpegHuffmanTableConfig[] - { + JpegHuffmanTableConfig[] yCbCrHuffmanConfigs = + [ defaultLuminanceHuffmanDC, defaultLuminanceHuffmanAC, defaultChrominanceHuffmanDC, - defaultChrominanceHuffmanAC, - }; + defaultChrominanceHuffmanAC + ]; - var yCbCrQuantTableConfigs = new JpegQuantizationTableConfig[] - { + JpegQuantizationTableConfig[] yCbCrQuantTableConfigs = + [ defaultLuminanceQuantTable, - defaultChrominanceQuantTable, - }; + defaultChrominanceQuantTable + ]; - return new JpegFrameConfig[] - { + return + [ // YCbCr 4:4:4 - new JpegFrameConfig( + new( JpegColorSpace.YCbCr, JpegColorType.YCbCrRatio444, - new JpegComponentConfig[] - { - new JpegComponentConfig(id: 1, hsf: 1, vsf: 1, quantIndex: 0, dcIndex: 0, acIndex: 0), - new JpegComponentConfig(id: 2, hsf: 1, vsf: 1, quantIndex: 1, dcIndex: 1, acIndex: 1), - new JpegComponentConfig(id: 3, hsf: 1, vsf: 1, quantIndex: 1, dcIndex: 1, acIndex: 1), - }, + [ + new(id: 1, hsf: 1, vsf: 1, quantIndex: 0, dcIndex: 0, acIndex: 0), + new(id: 2, hsf: 1, vsf: 1, quantIndex: 1, dcIndex: 1, acIndex: 1), + new(id: 3, hsf: 1, vsf: 1, quantIndex: 1, dcIndex: 1, acIndex: 1) + ], yCbCrHuffmanConfigs, yCbCrQuantTableConfigs), // YCbCr 4:2:2 - new JpegFrameConfig( + new( JpegColorSpace.YCbCr, JpegColorType.YCbCrRatio422, - new JpegComponentConfig[] - { - new JpegComponentConfig(id: 1, hsf: 2, vsf: 1, quantIndex: 0, dcIndex: 0, acIndex: 0), - new JpegComponentConfig(id: 2, hsf: 1, vsf: 1, quantIndex: 1, dcIndex: 1, acIndex: 1), - new JpegComponentConfig(id: 3, hsf: 1, vsf: 1, quantIndex: 1, dcIndex: 1, acIndex: 1), - }, + [ + new(id: 1, hsf: 2, vsf: 1, quantIndex: 0, dcIndex: 0, acIndex: 0), + new(id: 2, hsf: 1, vsf: 1, quantIndex: 1, dcIndex: 1, acIndex: 1), + new(id: 3, hsf: 1, vsf: 1, quantIndex: 1, dcIndex: 1, acIndex: 1) + ], yCbCrHuffmanConfigs, yCbCrQuantTableConfigs), // YCbCr 4:2:0 - new JpegFrameConfig( + new( JpegColorSpace.YCbCr, JpegColorType.YCbCrRatio420, - new JpegComponentConfig[] - { - new JpegComponentConfig(id: 1, hsf: 2, vsf: 2, quantIndex: 0, dcIndex: 0, acIndex: 0), - new JpegComponentConfig(id: 2, hsf: 1, vsf: 1, quantIndex: 1, dcIndex: 1, acIndex: 1), - new JpegComponentConfig(id: 3, hsf: 1, vsf: 1, quantIndex: 1, dcIndex: 1, acIndex: 1), - }, + [ + new(id: 1, hsf: 2, vsf: 2, quantIndex: 0, dcIndex: 0, acIndex: 0), + new(id: 2, hsf: 1, vsf: 1, quantIndex: 1, dcIndex: 1, acIndex: 1), + new(id: 3, hsf: 1, vsf: 1, quantIndex: 1, dcIndex: 1, acIndex: 1) + ], yCbCrHuffmanConfigs, yCbCrQuantTableConfigs), // YCbCr 4:1:1 - new JpegFrameConfig( + new( JpegColorSpace.YCbCr, JpegColorType.YCbCrRatio411, - new JpegComponentConfig[] - { - new JpegComponentConfig(id: 1, hsf: 4, vsf: 1, quantIndex: 0, dcIndex: 0, acIndex: 0), - new JpegComponentConfig(id: 2, hsf: 1, vsf: 1, quantIndex: 1, dcIndex: 1, acIndex: 1), - new JpegComponentConfig(id: 3, hsf: 1, vsf: 1, quantIndex: 1, dcIndex: 1, acIndex: 1), - }, + [ + new(id: 1, hsf: 4, vsf: 1, quantIndex: 0, dcIndex: 0, acIndex: 0), + new(id: 2, hsf: 1, vsf: 1, quantIndex: 1, dcIndex: 1, acIndex: 1), + new(id: 3, hsf: 1, vsf: 1, quantIndex: 1, dcIndex: 1, acIndex: 1) + ], yCbCrHuffmanConfigs, yCbCrQuantTableConfigs), // YCbCr 4:1:0 - new JpegFrameConfig( + new( JpegColorSpace.YCbCr, JpegColorType.YCbCrRatio410, - new JpegComponentConfig[] - { - new JpegComponentConfig(id: 1, hsf: 4, vsf: 2, quantIndex: 0, dcIndex: 0, acIndex: 0), - new JpegComponentConfig(id: 2, hsf: 1, vsf: 1, quantIndex: 1, dcIndex: 1, acIndex: 1), - new JpegComponentConfig(id: 3, hsf: 1, vsf: 1, quantIndex: 1, dcIndex: 1, acIndex: 1), - }, + [ + new(id: 1, hsf: 4, vsf: 2, quantIndex: 0, dcIndex: 0, acIndex: 0), + new(id: 2, hsf: 1, vsf: 1, quantIndex: 1, dcIndex: 1, acIndex: 1), + new(id: 3, hsf: 1, vsf: 1, quantIndex: 1, dcIndex: 1, acIndex: 1) + ], yCbCrHuffmanConfigs, yCbCrQuantTableConfigs), // Luminance - new JpegFrameConfig( + new( JpegColorSpace.Grayscale, JpegColorType.Luminance, - new JpegComponentConfig[] - { - new JpegComponentConfig(id: 0, hsf: 1, vsf: 1, quantIndex: 0, dcIndex: 0, acIndex: 0), - }, - new JpegHuffmanTableConfig[] - { + [ + new(id: 0, hsf: 1, vsf: 1, quantIndex: 0, dcIndex: 0, acIndex: 0) + ], + [ defaultLuminanceHuffmanDC, defaultLuminanceHuffmanAC - }, - new JpegQuantizationTableConfig[] - { + ], + [ defaultLuminanceQuantTable - }), + ]), // Rgb - new JpegFrameConfig( + new( JpegColorSpace.RGB, JpegColorType.Rgb, - new JpegComponentConfig[] - { - new JpegComponentConfig(id: 82, hsf: 1, vsf: 1, quantIndex: 0, dcIndex: 0, acIndex: 0), - new JpegComponentConfig(id: 71, hsf: 1, vsf: 1, quantIndex: 0, dcIndex: 0, acIndex: 0), - new JpegComponentConfig(id: 66, hsf: 1, vsf: 1, quantIndex: 0, dcIndex: 0, acIndex: 0), - }, - new JpegHuffmanTableConfig[] - { + [ + new(id: 82, hsf: 1, vsf: 1, quantIndex: 0, dcIndex: 0, acIndex: 0), + new(id: 71, hsf: 1, vsf: 1, quantIndex: 0, dcIndex: 0, acIndex: 0), + new(id: 66, hsf: 1, vsf: 1, quantIndex: 0, dcIndex: 0, acIndex: 0) + ], + [ defaultLuminanceHuffmanDC, defaultLuminanceHuffmanAC - }, - new JpegQuantizationTableConfig[] - { + ], + [ defaultLuminanceQuantTable - }) + ]) { AdobeColorTransformMarkerFlag = JpegConstants.Adobe.ColorTransformUnknown }, // Cmyk - new JpegFrameConfig( + new( JpegColorSpace.Cmyk, JpegColorType.Cmyk, - new JpegComponentConfig[] - { - new JpegComponentConfig(id: 1, hsf: 1, vsf: 1, quantIndex: 0, dcIndex: 0, acIndex: 0), - new JpegComponentConfig(id: 2, hsf: 1, vsf: 1, quantIndex: 0, dcIndex: 0, acIndex: 0), - new JpegComponentConfig(id: 3, hsf: 1, vsf: 1, quantIndex: 0, dcIndex: 0, acIndex: 0), - new JpegComponentConfig(id: 4, hsf: 1, vsf: 1, quantIndex: 0, dcIndex: 0, acIndex: 0), - }, - new JpegHuffmanTableConfig[] - { + [ + new(id: 1, hsf: 1, vsf: 1, quantIndex: 0, dcIndex: 0, acIndex: 0), + new(id: 2, hsf: 1, vsf: 1, quantIndex: 0, dcIndex: 0, acIndex: 0), + new(id: 3, hsf: 1, vsf: 1, quantIndex: 0, dcIndex: 0, acIndex: 0), + new(id: 4, hsf: 1, vsf: 1, quantIndex: 0, dcIndex: 0, acIndex: 0) + ], + [ defaultLuminanceHuffmanDC, defaultLuminanceHuffmanAC - }, - new JpegQuantizationTableConfig[] - { + ], + [ defaultLuminanceQuantTable - }) + ]) { AdobeColorTransformMarkerFlag = JpegConstants.Adobe.ColorTransformUnknown, }, // YccK - new JpegFrameConfig( + new( JpegColorSpace.Ycck, JpegColorType.Ycck, - new JpegComponentConfig[] - { - new JpegComponentConfig(id: 1, hsf: 1, vsf: 1, quantIndex: 0, dcIndex: 0, acIndex: 0), - new JpegComponentConfig(id: 2, hsf: 1, vsf: 1, quantIndex: 0, dcIndex: 0, acIndex: 0), - new JpegComponentConfig(id: 3, hsf: 1, vsf: 1, quantIndex: 0, dcIndex: 0, acIndex: 0), - new JpegComponentConfig(id: 4, hsf: 1, vsf: 1, quantIndex: 0, dcIndex: 0, acIndex: 0), - }, - new JpegHuffmanTableConfig[] - { + [ + new(id: 1, hsf: 1, vsf: 1, quantIndex: 0, dcIndex: 0, acIndex: 0), + new(id: 2, hsf: 1, vsf: 1, quantIndex: 0, dcIndex: 0, acIndex: 0), + new(id: 3, hsf: 1, vsf: 1, quantIndex: 0, dcIndex: 0, acIndex: 0), + new(id: 4, hsf: 1, vsf: 1, quantIndex: 0, dcIndex: 0, acIndex: 0) + ], + [ defaultLuminanceHuffmanDC, defaultLuminanceHuffmanAC - }, - new JpegQuantizationTableConfig[] - { + ], + [ defaultLuminanceQuantTable - }) + ]) { AdobeColorTransformMarkerFlag = JpegConstants.Adobe.ColorTransformYcck, - }, - }; + } + ]; } } diff --git a/src/ImageSharp/Formats/Jpeg/JpegFormat.cs b/src/ImageSharp/Formats/Jpeg/JpegFormat.cs index a07be33fc4..9d5a299817 100644 --- a/src/ImageSharp/Formats/Jpeg/JpegFormat.cs +++ b/src/ImageSharp/Formats/Jpeg/JpegFormat.cs @@ -15,7 +15,7 @@ private JpegFormat() /// /// Gets the shared instance. /// - public static JpegFormat Instance { get; } = new JpegFormat(); + public static JpegFormat Instance { get; } = new(); /// public string Name => "JPEG"; diff --git a/src/ImageSharp/Formats/Jpeg/JpegMetadata.cs b/src/ImageSharp/Formats/Jpeg/JpegMetadata.cs index fe4855dc77..88bea3dc9f 100644 --- a/src/ImageSharp/Formats/Jpeg/JpegMetadata.cs +++ b/src/ImageSharp/Formats/Jpeg/JpegMetadata.cs @@ -139,7 +139,7 @@ public static JpegMetadata FromFormatConnectingMetadata(FormatConnectingMetadata break; } - return new JpegMetadata + return new() { ColorType = color, ChrominanceQuality = metadata.Quality, @@ -182,7 +182,7 @@ public PixelTypeInfo GetPixelTypeInfo() break; } - return new PixelTypeInfo(bpp) + return new(bpp) { AlphaRepresentation = PixelAlphaRepresentation.None, ColorType = colorType, diff --git a/src/ImageSharp/Formats/Pbm/PbmConstants.cs b/src/ImageSharp/Formats/Pbm/PbmConstants.cs index fe0088c3ce..4a3a444978 100644 --- a/src/ImageSharp/Formats/Pbm/PbmConstants.cs +++ b/src/ImageSharp/Formats/Pbm/PbmConstants.cs @@ -16,10 +16,10 @@ internal static class PbmConstants /// /// The list of mimetypes that equate to a ppm. /// - public static readonly IEnumerable MimeTypes = new[] { "image/x-portable-pixmap", "image/x-portable-anymap" }; + public static readonly IEnumerable MimeTypes = ["image/x-portable-pixmap", "image/x-portable-anymap"]; /// /// The list of file extensions that equate to a ppm. /// - public static readonly IEnumerable FileExtensions = new[] { "ppm", "pbm", "pgm" }; + public static readonly IEnumerable FileExtensions = ["ppm", "pbm", "pgm"]; } diff --git a/src/ImageSharp/Formats/Pbm/PbmDecoderCore.cs b/src/ImageSharp/Formats/Pbm/PbmDecoderCore.cs index 9d3dd3ea4c..d2a2f661f3 100644 --- a/src/ImageSharp/Formats/Pbm/PbmDecoderCore.cs +++ b/src/ImageSharp/Formats/Pbm/PbmDecoderCore.cs @@ -79,7 +79,7 @@ protected override Image Decode(BufferedReadStream stream, Cance protected override ImageInfo Identify(BufferedReadStream stream, CancellationToken cancellationToken) { this.ProcessHeader(stream); - return new ImageInfo( + return new( new(this.pixelSize.Width, this.pixelSize.Height), this.metadata); } @@ -171,9 +171,9 @@ private void ProcessHeader(BufferedReadStream stream) this.componentType = PbmComponentType.Bit; } - this.pixelSize = new Size(width, height); + this.pixelSize = new(width, height); this.Dimensions = this.pixelSize; - this.metadata = new ImageMetadata(); + this.metadata = new(); PbmMetadata meta = this.metadata.GetPbmMetadata(); meta.Encoding = this.encoding; meta.ColorType = this.colorType; diff --git a/src/ImageSharp/Formats/Pbm/PbmMetadata.cs b/src/ImageSharp/Formats/Pbm/PbmMetadata.cs index d852f3c8eb..9045671fb0 100644 --- a/src/ImageSharp/Formats/Pbm/PbmMetadata.cs +++ b/src/ImageSharp/Formats/Pbm/PbmMetadata.cs @@ -77,7 +77,7 @@ public static PbmMetadata FromFormatConnectingMetadata(FormatConnectingMetadata _ => PbmComponentType.Short }; - return new PbmMetadata + return new() { ColorType = color, ComponentType = componentType @@ -114,7 +114,7 @@ public PixelTypeInfo GetPixelTypeInfo() break; } - return new PixelTypeInfo(bpp) + return new(bpp) { AlphaRepresentation = PixelAlphaRepresentation.None, ColorType = colorType, diff --git a/src/ImageSharp/Formats/Pbm/PlainDecoder.cs b/src/ImageSharp/Formats/Pbm/PlainDecoder.cs index 8748d90fa8..4ffd824c5f 100644 --- a/src/ImageSharp/Formats/Pbm/PlainDecoder.cs +++ b/src/ImageSharp/Formats/Pbm/PlainDecoder.cs @@ -71,7 +71,7 @@ private static void ProcessGrayscale(Configuration configuration, Buffer for (int x = 0; x < width; x++) { stream.ReadDecimal(out int value); - rowSpan[x] = new L8((byte)value); + rowSpan[x] = new((byte)value); eofReached = !stream.SkipWhitespaceAndComments(); if (eofReached) { @@ -107,7 +107,7 @@ private static void ProcessWideGrayscale(Configuration configuration, Bu for (int x = 0; x < width; x++) { stream.ReadDecimal(out int value); - rowSpan[x] = new L16((ushort)value); + rowSpan[x] = new((ushort)value); eofReached = !stream.SkipWhitespaceAndComments(); if (eofReached) { @@ -154,7 +154,7 @@ private static void ProcessRgb(Configuration configuration, Buffer2D(Configuration configuration, Buffer2D stream.ReadDecimal(out int blue); - rowSpan[x] = new Rgb48((ushort)red, (ushort)green, (ushort)blue); + rowSpan[x] = new((ushort)red, (ushort)green, (ushort)blue); eofReached = !stream.SkipWhitespaceAndComments(); if (eofReached) { diff --git a/src/ImageSharp/Formats/Png/Adam7.cs b/src/ImageSharp/Formats/Png/Adam7.cs index 8310ca64c8..5da2fdd2e7 100644 --- a/src/ImageSharp/Formats/Png/Adam7.cs +++ b/src/ImageSharp/Formats/Png/Adam7.cs @@ -13,22 +13,22 @@ internal static class Adam7 /// /// The amount to increment when processing each column per scanline for each interlaced pass. /// - public static readonly int[] ColumnIncrement = { 8, 8, 4, 4, 2, 2, 1 }; + public static readonly int[] ColumnIncrement = [8, 8, 4, 4, 2, 2, 1]; /// /// The index to start at when processing each column per scanline for each interlaced pass. /// - public static readonly int[] FirstColumn = { 0, 4, 0, 2, 0, 1, 0 }; + public static readonly int[] FirstColumn = [0, 4, 0, 2, 0, 1, 0]; /// /// The index to start at when processing each row per scanline for each interlaced pass. /// - public static readonly int[] FirstRow = { 0, 0, 4, 0, 2, 0, 1 }; + public static readonly int[] FirstRow = [0, 0, 4, 0, 2, 0, 1]; /// /// The amount to increment when processing each row per scanline for each interlaced pass. /// - public static readonly int[] RowIncrement = { 8, 8, 8, 4, 4, 2, 2 }; + public static readonly int[] RowIncrement = [8, 8, 8, 4, 4, 2, 2]; /// /// Gets the width of the block. diff --git a/src/ImageSharp/Formats/Png/Chunks/PngPhysical.cs b/src/ImageSharp/Formats/Png/Chunks/PngPhysical.cs index 8af0ac8ca7..a68b1cab45 100644 --- a/src/ImageSharp/Formats/Png/Chunks/PngPhysical.cs +++ b/src/ImageSharp/Formats/Png/Chunks/PngPhysical.cs @@ -50,7 +50,7 @@ public static PngPhysical Parse(ReadOnlySpan data) uint vResolution = BinaryPrimitives.ReadUInt32BigEndian(data.Slice(4, 4)); byte unit = data[8]; - return new PngPhysical(hResolution, vResolution, unit); + return new(hResolution, vResolution, unit); } /// @@ -92,7 +92,7 @@ public static PngPhysical FromMetadata(ImageMetadata meta) break; } - return new PngPhysical(x, y, unitSpecifier); + return new(x, y, unitSpecifier); } /// diff --git a/src/ImageSharp/Formats/Png/PngConstants.cs b/src/ImageSharp/Formats/Png/PngConstants.cs index 43f2b0fb25..17d13e86df 100644 --- a/src/ImageSharp/Formats/Png/PngConstants.cs +++ b/src/ImageSharp/Formats/Png/PngConstants.cs @@ -28,12 +28,12 @@ internal static class PngConstants /// /// The list of mimetypes that equate to a Png. /// - public static readonly IEnumerable MimeTypes = new[] { "image/png", "image/apng" }; + public static readonly IEnumerable MimeTypes = ["image/png", "image/apng"]; /// /// The list of file extensions that equate to a Png. /// - public static readonly IEnumerable FileExtensions = new[] { "png", "apng" }; + public static readonly IEnumerable FileExtensions = ["png", "apng"]; /// /// The header bytes as a big-endian coded ulong. @@ -45,11 +45,11 @@ internal static class PngConstants /// public static readonly Dictionary ColorTypes = new() { - [PngColorType.Grayscale] = new byte[] { 1, 2, 4, 8, 16 }, - [PngColorType.Rgb] = new byte[] { 8, 16 }, - [PngColorType.Palette] = new byte[] { 1, 2, 4, 8 }, - [PngColorType.GrayscaleWithAlpha] = new byte[] { 8, 16 }, - [PngColorType.RgbWithAlpha] = new byte[] { 8, 16 } + [PngColorType.Grayscale] = [1, 2, 4, 8, 16], + [PngColorType.Rgb] = [8, 16], + [PngColorType.Palette] = [1, 2, 4, 8], + [PngColorType.GrayscaleWithAlpha] = [8, 16], + [PngColorType.RgbWithAlpha] = [8, 16] }; /// @@ -65,8 +65,8 @@ internal static class PngConstants /// /// Gets the header bytes identifying a Png. /// - public static ReadOnlySpan HeaderBytes => new byte[] - { + public static ReadOnlySpan HeaderBytes => + [ 0x89, // Set the high bit. 0x50, // P 0x4E, // N @@ -75,13 +75,13 @@ internal static class PngConstants 0x0A, // Line ending CRLF 0x1A, // EOF 0x0A // LF - }; + ]; /// /// Gets the keyword of the XMP metadata, encoded in an iTXT chunk. /// - public static ReadOnlySpan XmpKeyword => new[] - { + public static ReadOnlySpan XmpKeyword => + [ (byte)'X', (byte)'M', (byte)'L', @@ -99,5 +99,5 @@ internal static class PngConstants (byte)'x', (byte)'m', (byte)'p' - }; + ]; } diff --git a/src/ImageSharp/Formats/Png/PngDecoder.cs b/src/ImageSharp/Formats/Png/PngDecoder.cs index cfea0e6020..b0adbe6c55 100644 --- a/src/ImageSharp/Formats/Png/PngDecoder.cs +++ b/src/ImageSharp/Formats/Png/PngDecoder.cs @@ -25,7 +25,7 @@ protected override ImageInfo Identify(DecoderOptions options, Stream stream, Can Guard.NotNull(options, nameof(options)); Guard.NotNull(stream, nameof(stream)); - return new PngDecoderCore(new PngDecoderOptions() { GeneralOptions = options }).Identify(options.Configuration, stream, cancellationToken); + return new PngDecoderCore(new() { GeneralOptions = options }).Identify(options.Configuration, stream, cancellationToken); } /// diff --git a/src/ImageSharp/Formats/Png/PngDecoderCore.cs b/src/ImageSharp/Formats/Png/PngDecoderCore.cs index 484241d52f..8fbfd00e76 100644 --- a/src/ImageSharp/Formats/Png/PngDecoderCore.cs +++ b/src/ImageSharp/Formats/Png/PngDecoderCore.cs @@ -292,7 +292,7 @@ protected override Image Decode(BufferedReadStream stream, Cance { byte[] exifData = new byte[chunk.Length]; chunk.Data.GetSpan().CopyTo(exifData); - MergeOrSetExifProfile(metadata, new ExifProfile(exifData), replaceExistingKeys: true); + MergeOrSetExifProfile(metadata, new(exifData), replaceExistingKeys: true); } break; @@ -492,7 +492,7 @@ protected override ImageInfo Identify(BufferedReadStream stream, CancellationTok { byte[] exifData = new byte[chunk.Length]; chunk.Data.GetSpan().CopyTo(exifData); - MergeOrSetExifProfile(metadata, new ExifProfile(exifData), replaceExistingKeys: true); + MergeOrSetExifProfile(metadata, new(exifData), replaceExistingKeys: true); } break; @@ -520,7 +520,7 @@ protected override ImageInfo Identify(BufferedReadStream stream, CancellationTok PngThrowHelper.ThrowInvalidHeader(); } - return new ImageInfo(new(this.header.Width, this.header.Height), metadata, framesMetadata); + return new(new(this.header.Width, this.header.Height), metadata, framesMetadata); } finally { @@ -621,7 +621,7 @@ private static void ReadGammaChunk(PngMetadata pngMetadata, ReadOnlySpan d private void InitializeImage(ImageMetadata metadata, FrameControl frameControl, out Image image) where TPixel : unmanaged, IPixel { - image = new Image(this.configuration, this.header.Width, this.header.Height, metadata); + image = new(this.configuration, this.header.Width, this.header.Height, metadata); PngFrameMetadata frameMetadata = image.Frames.RootFrame.Metadata.GetPngMetadata(); frameMetadata.FromChunk(in frameControl); @@ -1366,7 +1366,7 @@ private void ReadTextChunk(ImageMetadata baseMetadata, PngMetadata metadata, Rea if (!TryReadTextChunkMetadata(baseMetadata, name, value)) { - metadata.TextData.Add(new PngTextData(name, value, string.Empty, string.Empty)); + metadata.TextData.Add(new(name, value, string.Empty, string.Empty)); } } @@ -1407,7 +1407,7 @@ private void ReadCompressedTextChunk(ImageMetadata baseMetadata, PngMetadata met if (this.TryDecompressTextData(compressedData, PngConstants.Encoding, out string? uncompressed) && !TryReadTextChunkMetadata(baseMetadata, name, uncompressed)) { - metadata.TextData.Add(new PngTextData(name, uncompressed, string.Empty, string.Empty)); + metadata.TextData.Add(new(name, uncompressed, string.Empty, string.Empty)); } } @@ -1465,7 +1465,7 @@ private static void ReadCicpChunk(ImageMetadata metadata, ReadOnlySpan dat fullRange = null; } - metadata.CicpProfile = new CicpProfile(colorPrimaries, transferFunction, matrixCoefficients, fullRange); + metadata.CicpProfile = new(colorPrimaries, transferFunction, matrixCoefficients, fullRange); } /// @@ -1549,7 +1549,7 @@ private static bool TryReadLegacyExifTextChunk(ImageMetadata metadata, string da return false; } - MergeOrSetExifProfile(metadata, new ExifProfile(exifBlob), replaceExistingKeys: false); + MergeOrSetExifProfile(metadata, new(exifBlob), replaceExistingKeys: false); return true; } @@ -1583,7 +1583,7 @@ private void ReadColorProfileChunk(ImageMetadata metadata, ReadOnlySpan da if (this.TryDecompressZlibData(compressedData, this.maxUncompressedLength, out byte[] iccpProfileBytes)) { - metadata.IccProfile = new IccProfile(iccpProfileBytes); + metadata.IccProfile = new(iccpProfileBytes); } } @@ -1739,17 +1739,17 @@ private void ReadInternationalTextChunk(ImageMetadata metadata, ReadOnlySpan buffer, out PngChunk chunk) type != PngChunkType.AnimationControl && type != PngChunkType.FrameControl) { - chunk = new PngChunk(length, type); + chunk = new(length, type); return true; } // A chunk might report a length that exceeds the length of the stream. // Take the minimum of the two values to ensure we don't read past the end of the stream. long position = this.currentStream.Position; - chunk = new PngChunk( + chunk = new( length: (int)Math.Min(length, this.currentStream.Length - position), type: type, data: this.ReadChunkData(length)); diff --git a/src/ImageSharp/Formats/Png/PngDecoderOptions.cs b/src/ImageSharp/Formats/Png/PngDecoderOptions.cs index a73db87774..e4aeded157 100644 --- a/src/ImageSharp/Formats/Png/PngDecoderOptions.cs +++ b/src/ImageSharp/Formats/Png/PngDecoderOptions.cs @@ -9,7 +9,7 @@ namespace SixLabors.ImageSharp.Formats.Png; public sealed class PngDecoderOptions : ISpecializedDecoderOptions { /// - public DecoderOptions GeneralOptions { get; init; } = new DecoderOptions(); + public DecoderOptions GeneralOptions { get; init; } = new(); /// /// Gets the maximum memory in bytes that a zTXt, sPLT, iTXt, iCCP, or unknown chunk can occupy when decompressed. diff --git a/src/ImageSharp/Formats/Png/PngEncoderCore.cs b/src/ImageSharp/Formats/Png/PngEncoderCore.cs index 978b9184e9..ed02f94d77 100644 --- a/src/ImageSharp/Formats/Png/PngEncoderCore.cs +++ b/src/ImageSharp/Formats/Png/PngEncoderCore.cs @@ -1531,7 +1531,7 @@ private void SanitizeAndSetEncoderOptions( } else { - this.quantizer = new WuQuantizer(new QuantizerOptions { MaxColors = ColorNumerics.GetColorCountForBitDepth(bitDepth) }); + this.quantizer = new WuQuantizer(new() { MaxColors = ColorNumerics.GetColorCountForBitDepth(bitDepth) }); } } diff --git a/src/ImageSharp/Formats/Png/PngFormat.cs b/src/ImageSharp/Formats/Png/PngFormat.cs index e5852affa9..e49b89631f 100644 --- a/src/ImageSharp/Formats/Png/PngFormat.cs +++ b/src/ImageSharp/Formats/Png/PngFormat.cs @@ -15,7 +15,7 @@ private PngFormat() /// /// Gets the shared instance. /// - public static PngFormat Instance { get; } = new PngFormat(); + public static PngFormat Instance { get; } = new(); /// public string Name => "PNG"; diff --git a/src/ImageSharp/Formats/Png/PngFrameMetadata.cs b/src/ImageSharp/Formats/Png/PngFrameMetadata.cs index b8086cd6d1..dd642cf6de 100644 --- a/src/ImageSharp/Formats/Png/PngFrameMetadata.cs +++ b/src/ImageSharp/Formats/Png/PngFrameMetadata.cs @@ -53,7 +53,7 @@ private PngFrameMetadata(PngFrameMetadata other) /// The chunk to create an instance from. internal void FromChunk(in FrameControl frameControl) { - this.FrameDelay = new Rational(frameControl.DelayNumerator, frameControl.DelayDenominator); + this.FrameDelay = new(frameControl.DelayNumerator, frameControl.DelayDenominator); this.DisposalMode = frameControl.DisposalMode; this.BlendMode = frameControl.BlendMode; } diff --git a/src/ImageSharp/Formats/Png/PngMetadata.cs b/src/ImageSharp/Formats/Png/PngMetadata.cs index 00cba088cb..a3918f26d6 100644 --- a/src/ImageSharp/Formats/Png/PngMetadata.cs +++ b/src/ImageSharp/Formats/Png/PngMetadata.cs @@ -229,7 +229,7 @@ public PixelTypeInfo GetPixelTypeInfo() break; } - return new PixelTypeInfo(bpp) + return new(bpp) { AlphaRepresentation = alpha, ColorType = colorType, diff --git a/src/ImageSharp/Formats/Qoi/QoiConstants.cs b/src/ImageSharp/Formats/Qoi/QoiConstants.cs index 9643ccef03..3c64128ee1 100644 --- a/src/ImageSharp/Formats/Qoi/QoiConstants.cs +++ b/src/ImageSharp/Formats/Qoi/QoiConstants.cs @@ -18,10 +18,10 @@ internal static class QoiConstants /// Gets the list of mimetypes that equate to a QOI. /// See https://github.com/phoboslab/qoi/issues/167 /// - public static string[] MimeTypes { get; } = { "image/qoi", "image/x-qoi", "image/vnd.qoi" }; + public static string[] MimeTypes { get; } = ["image/qoi", "image/x-qoi", "image/vnd.qoi"]; /// /// Gets the list of file extensions that equate to a QOI. /// - public static string[] FileExtensions { get; } = { "qoi" }; + public static string[] FileExtensions { get; } = ["qoi"]; } diff --git a/src/ImageSharp/Formats/Qoi/QoiDecoderCore.cs b/src/ImageSharp/Formats/Qoi/QoiDecoderCore.cs index 85fac7ea26..45f79c040f 100644 --- a/src/ImageSharp/Formats/Qoi/QoiDecoderCore.cs +++ b/src/ImageSharp/Formats/Qoi/QoiDecoderCore.cs @@ -68,7 +68,7 @@ protected override ImageInfo Identify(BufferedReadStream stream, CancellationTok qoiMetadata.Channels = this.header.Channels; qoiMetadata.ColorSpace = this.header.ColorSpace; - return new ImageInfo(size, metadata); + return new(size, metadata); } /// @@ -124,7 +124,7 @@ private void ProcessHeader(BufferedReadStream stream) ThrowInvalidImageContentException(); } - this.header = new QoiHeader(width, height, (QoiChannels)channels, (QoiColorSpace)colorSpace); + this.header = new(width, height, (QoiChannels)channels, (QoiColorSpace)colorSpace); } [DoesNotReturn] diff --git a/src/ImageSharp/Formats/Qoi/QoiFormat.cs b/src/ImageSharp/Formats/Qoi/QoiFormat.cs index ca2d7ae452..fbee2bc3f4 100644 --- a/src/ImageSharp/Formats/Qoi/QoiFormat.cs +++ b/src/ImageSharp/Formats/Qoi/QoiFormat.cs @@ -15,7 +15,7 @@ private QoiFormat() /// /// Gets the shared instance. /// - public static QoiFormat Instance { get; } = new QoiFormat(); + public static QoiFormat Instance { get; } = new(); /// public string DefaultMimeType => "image/qoi"; diff --git a/src/ImageSharp/Formats/Qoi/QoiMetadata.cs b/src/ImageSharp/Formats/Qoi/QoiMetadata.cs index e463d511d2..8f71ebeee8 100644 --- a/src/ImageSharp/Formats/Qoi/QoiMetadata.cs +++ b/src/ImageSharp/Formats/Qoi/QoiMetadata.cs @@ -44,10 +44,10 @@ public static QoiMetadata FromFormatConnectingMetadata(FormatConnectingMetadata if (color.HasFlag(PixelColorType.Alpha)) { - return new QoiMetadata { Channels = QoiChannels.Rgba }; + return new() { Channels = QoiChannels.Rgba }; } - return new QoiMetadata { Channels = QoiChannels.Rgb }; + return new() { Channels = QoiChannels.Rgb }; } /// @@ -73,7 +73,7 @@ public PixelTypeInfo GetPixelTypeInfo() break; } - return new PixelTypeInfo(bpp) + return new(bpp) { AlphaRepresentation = alpha, ColorType = colorType, diff --git a/src/ImageSharp/Formats/Tga/TgaConstants.cs b/src/ImageSharp/Formats/Tga/TgaConstants.cs index ac7d837985..c4663ac091 100644 --- a/src/ImageSharp/Formats/Tga/TgaConstants.cs +++ b/src/ImageSharp/Formats/Tga/TgaConstants.cs @@ -8,12 +8,12 @@ internal static class TgaConstants /// /// The list of mimetypes that equate to a targa file. /// - public static readonly IEnumerable MimeTypes = new[] { "image/x-tga", "image/x-targa" }; + public static readonly IEnumerable MimeTypes = ["image/x-tga", "image/x-targa"]; /// /// The list of file extensions that equate to a targa file. /// - public static readonly IEnumerable FileExtensions = new[] { "tga", "vda", "icb", "vst" }; + public static readonly IEnumerable FileExtensions = ["tga", "vda", "icb", "vst"]; /// /// The file header length of a tga image in bytes. diff --git a/src/ImageSharp/Formats/Tga/TgaDecoderCore.cs b/src/ImageSharp/Formats/Tga/TgaDecoderCore.cs index dc6b33422f..59977ecbcb 100644 --- a/src/ImageSharp/Formats/Tga/TgaDecoderCore.cs +++ b/src/ImageSharp/Formats/Tga/TgaDecoderCore.cs @@ -622,7 +622,7 @@ private void ReadRle(BufferedReadStream stream, int width, int height, B else { byte alpha = alphaBits == 0 ? byte.MaxValue : bufferSpan[idx + 3]; - color = TPixel.FromBgra32(new Bgra32(bufferSpan[idx + 2], bufferSpan[idx + 1], bufferSpan[idx], alpha)); + color = TPixel.FromBgra32(new(bufferSpan[idx + 2], bufferSpan[idx + 1], bufferSpan[idx], alpha)); } break; @@ -638,7 +638,7 @@ private void ReadRle(BufferedReadStream stream, int width, int height, B protected override ImageInfo Identify(BufferedReadStream stream, CancellationToken cancellationToken) { this.ReadFileHeader(stream); - return new ImageInfo( + return new( new(this.fileHeader.Width, this.fileHeader.Height), this.metadata); } @@ -705,7 +705,7 @@ private void ReadBgra32Pixel(BufferedReadStream stream, int x, Span /// /// Gets the shared instance. /// - public static TgaFormat Instance { get; } = new TgaFormat(); + public static TgaFormat Instance { get; } = new(); /// public string Name => "TGA"; diff --git a/src/ImageSharp/Formats/Tga/TgaImageFormatDetector.cs b/src/ImageSharp/Formats/Tga/TgaImageFormatDetector.cs index ad76bc3fbd..50d9920302 100644 --- a/src/ImageSharp/Formats/Tga/TgaImageFormatDetector.cs +++ b/src/ImageSharp/Formats/Tga/TgaImageFormatDetector.cs @@ -34,7 +34,7 @@ private bool IsSupportedFileFormat(ReadOnlySpan header) } // The third byte is the image type. - var imageType = (TgaImageType)header[2]; + TgaImageType imageType = (TgaImageType)header[2]; if (!imageType.IsValid()) { return false; diff --git a/src/ImageSharp/Formats/Tga/TgaMetadata.cs b/src/ImageSharp/Formats/Tga/TgaMetadata.cs index 8d40f86464..a7be538ec8 100644 --- a/src/ImageSharp/Formats/Tga/TgaMetadata.cs +++ b/src/ImageSharp/Formats/Tga/TgaMetadata.cs @@ -41,10 +41,10 @@ public static TgaMetadata FromFormatConnectingMetadata(FormatConnectingMetadata int bpp = metadata.PixelTypeInfo.BitsPerPixel; return bpp switch { - <= 8 => new TgaMetadata { BitsPerPixel = TgaBitsPerPixel.Bit8 }, - <= 16 => new TgaMetadata { BitsPerPixel = TgaBitsPerPixel.Bit16 }, - <= 24 => new TgaMetadata { BitsPerPixel = TgaBitsPerPixel.Bit24 }, - _ => new TgaMetadata { BitsPerPixel = TgaBitsPerPixel.Bit32 } + <= 8 => new() { BitsPerPixel = TgaBitsPerPixel.Bit8 }, + <= 16 => new() { BitsPerPixel = TgaBitsPerPixel.Bit16 }, + <= 24 => new() { BitsPerPixel = TgaBitsPerPixel.Bit24 }, + _ => new() { BitsPerPixel = TgaBitsPerPixel.Bit32 } }; } @@ -79,7 +79,7 @@ public PixelTypeInfo GetPixelTypeInfo() break; } - return new PixelTypeInfo(bpp) + return new(bpp) { AlphaRepresentation = alpha, ComponentInfo = info, diff --git a/src/ImageSharp/Formats/Tiff/Compression/Compressors/DeflateCompressor.cs b/src/ImageSharp/Formats/Tiff/Compression/Compressors/DeflateCompressor.cs index 6881e3a7b3..3debd373c4 100644 --- a/src/ImageSharp/Formats/Tiff/Compression/Compressors/DeflateCompressor.cs +++ b/src/ImageSharp/Formats/Tiff/Compression/Compressors/DeflateCompressor.cs @@ -11,7 +11,7 @@ internal sealed class DeflateCompressor : TiffBaseCompressor { private readonly DeflateCompressionLevel compressionLevel; - private readonly MemoryStream memoryStream = new MemoryStream(); + private readonly MemoryStream memoryStream = new(); public DeflateCompressor(Stream output, MemoryAllocator allocator, int width, int bitsPerPixel, TiffPredictor predictor, DeflateCompressionLevel compressionLevel) : base(output, allocator, width, bitsPerPixel, predictor) @@ -29,7 +29,7 @@ public override void Initialize(int rowsPerStrip) public override void CompressStrip(Span rows, int height) { this.memoryStream.Seek(0, SeekOrigin.Begin); - using (var stream = new ZlibDeflateStream(this.Allocator, this.memoryStream, this.compressionLevel)) + using (ZlibDeflateStream stream = new(this.Allocator, this.memoryStream, this.compressionLevel)) { if (this.Predictor == TiffPredictor.Horizontal) { diff --git a/src/ImageSharp/Formats/Tiff/Compression/Compressors/LzwCompressor.cs b/src/ImageSharp/Formats/Tiff/Compression/Compressors/LzwCompressor.cs index a6242114ef..7dfb60bad8 100644 --- a/src/ImageSharp/Formats/Tiff/Compression/Compressors/LzwCompressor.cs +++ b/src/ImageSharp/Formats/Tiff/Compression/Compressors/LzwCompressor.cs @@ -20,7 +20,7 @@ public LzwCompressor(Stream output, MemoryAllocator allocator, int width, int bi public override TiffCompression Method => TiffCompression.Lzw; /// - public override void Initialize(int rowsPerStrip) => this.lzwEncoder = new TiffLzwEncoder(this.Allocator); + public override void Initialize(int rowsPerStrip) => this.lzwEncoder = new(this.Allocator); /// public override void CompressStrip(Span rows, int height) diff --git a/src/ImageSharp/Formats/Tiff/Compression/Compressors/PackBitsWriter.cs b/src/ImageSharp/Formats/Tiff/Compression/Compressors/PackBitsWriter.cs index 1c0a473659..4229cfada5 100644 --- a/src/ImageSharp/Formats/Tiff/Compression/Compressors/PackBitsWriter.cs +++ b/src/ImageSharp/Formats/Tiff/Compression/Compressors/PackBitsWriter.cs @@ -101,7 +101,7 @@ private static bool IsReplicateRun(ReadOnlySpan rowSpan, int startPos) private static int FindRunLength(ReadOnlySpan rowSpan, int startPos, int maxRunLength) { - var startByte = rowSpan[startPos]; + byte startByte = rowSpan[startPos]; int count = 1; for (int i = startPos + 1; i < rowSpan.Length; i++) { diff --git a/src/ImageSharp/Formats/Tiff/Compression/Compressors/T6BitCompressor.cs b/src/ImageSharp/Formats/Tiff/Compression/Compressors/T6BitCompressor.cs index 692e088d1c..cffc96fcdf 100644 --- a/src/ImageSharp/Formats/Tiff/Compression/Compressors/T6BitCompressor.cs +++ b/src/ImageSharp/Formats/Tiff/Compression/Compressors/T6BitCompressor.cs @@ -17,7 +17,7 @@ internal sealed class T6BitCompressor : TiffCcittCompressor /// Vertical codes from -3 to +3. /// private static readonly (uint Length, uint Code)[] VerticalCodes = - { + [ (7u, 3u), (6u, 3u), (3u, 3u), @@ -25,7 +25,7 @@ private static readonly (uint Length, uint Code)[] VerticalCodes = (3u, 2u), (6u, 2u), (7u, 2u) - }; + ]; private IMemoryOwner referenceLineBuffer; diff --git a/src/ImageSharp/Formats/Tiff/Compression/Compressors/TiffCcittCompressor.cs b/src/ImageSharp/Formats/Tiff/Compression/Compressors/TiffCcittCompressor.cs index 4e04f9cf17..8e2227cba5 100644 --- a/src/ImageSharp/Formats/Tiff/Compression/Compressors/TiffCcittCompressor.cs +++ b/src/ImageSharp/Formats/Tiff/Compression/Compressors/TiffCcittCompressor.cs @@ -17,9 +17,9 @@ internal abstract class TiffCcittCompressor : TiffBaseCompressor protected const uint BlackZeroRunTermCode = 0x37; private static readonly uint[] MakeupRunLength = - { + [ 64, 128, 192, 256, 320, 384, 448, 512, 576, 640, 704, 768, 832, 896, 960, 1024, 1088, 1152, 1216, 1280, 1344, 1408, 1472, 1536, 1600, 1664, 1728, 1792, 1856, 1920, 1984, 2048, 2112, 2176, 2240, 2304, 2368, 2432, 2496, 2560 - }; + ]; private static readonly Dictionary WhiteLen4TermCodes = new() { diff --git a/src/ImageSharp/Formats/Tiff/Compression/Compressors/TiffJpegCompressor.cs b/src/ImageSharp/Formats/Tiff/Compression/Compressors/TiffJpegCompressor.cs index 08faa539a8..1ad69b2c8f 100644 --- a/src/ImageSharp/Formats/Tiff/Compression/Compressors/TiffJpegCompressor.cs +++ b/src/ImageSharp/Formats/Tiff/Compression/Compressors/TiffJpegCompressor.cs @@ -29,8 +29,8 @@ public override void CompressStrip(Span rows, int height) int pixelCount = rows.Length / 3; int width = pixelCount / height; - using var memoryStream = new MemoryStream(); - var image = Image.LoadPixelData(rows, width, height); + using MemoryStream memoryStream = new(); + Image image = Image.LoadPixelData(rows, width, height); image.Save(memoryStream, new JpegEncoder() { ColorType = JpegColorType.Rgb diff --git a/src/ImageSharp/Formats/Tiff/Compression/Decompressors/DeflateTiffCompression.cs b/src/ImageSharp/Formats/Tiff/Compression/Decompressors/DeflateTiffCompression.cs index 27c311009c..97591573fc 100644 --- a/src/ImageSharp/Formats/Tiff/Compression/Decompressors/DeflateTiffCompression.cs +++ b/src/ImageSharp/Formats/Tiff/Compression/Decompressors/DeflateTiffCompression.cs @@ -42,7 +42,7 @@ public DeflateTiffCompression(MemoryAllocator memoryAllocator, int width, int bi protected override void Decompress(BufferedReadStream stream, int byteCount, int stripHeight, Span buffer, CancellationToken cancellationToken) { long pos = stream.Position; - using (var deframeStream = new ZlibInflateStream( + using (ZlibInflateStream deframeStream = new( stream, () => { diff --git a/src/ImageSharp/Formats/Tiff/Compression/Decompressors/LzwString.cs b/src/ImageSharp/Formats/Tiff/Compression/Decompressors/LzwString.cs index 5f18fc2d73..cad46e987b 100644 --- a/src/ImageSharp/Formats/Tiff/Compression/Decompressors/LzwString.cs +++ b/src/ImageSharp/Formats/Tiff/Compression/Decompressors/LzwString.cs @@ -9,7 +9,7 @@ namespace SixLabors.ImageSharp.Formats.Tiff.Compression.Decompressors; /// public class LzwString { - private static readonly LzwString Empty = new LzwString(0, 0, 0, null); + private static readonly LzwString Empty = new(0, 0, 0, null); private readonly LzwString previous; private readonly byte value; @@ -50,10 +50,10 @@ public LzwString Concatenate(byte other) { if (this == Empty) { - return new LzwString(other); + return new(other); } - return new LzwString(other, this.FirstChar, this.Length + 1, this); + return new(other, this.FirstChar, this.Length + 1, this); } /// diff --git a/src/ImageSharp/Formats/Tiff/Compression/Decompressors/LzwTiffCompression.cs b/src/ImageSharp/Formats/Tiff/Compression/Decompressors/LzwTiffCompression.cs index 01591e138b..4ad751e636 100644 --- a/src/ImageSharp/Formats/Tiff/Compression/Decompressors/LzwTiffCompression.cs +++ b/src/ImageSharp/Formats/Tiff/Compression/Decompressors/LzwTiffCompression.cs @@ -36,7 +36,7 @@ public LzwTiffCompression(MemoryAllocator memoryAllocator, int width, int bitsPe /// protected override void Decompress(BufferedReadStream stream, int byteCount, int stripHeight, Span buffer, CancellationToken cancellationToken) { - var decoder = new TiffLzwDecoder(stream); + TiffLzwDecoder decoder = new(stream); decoder.DecodePixels(buffer); if (this.Predictor == TiffPredictor.Horizontal) diff --git a/src/ImageSharp/Formats/Tiff/Compression/Decompressors/ModifiedHuffmanTiffCompression.cs b/src/ImageSharp/Formats/Tiff/Compression/Decompressors/ModifiedHuffmanTiffCompression.cs index d2dbedc9cb..ccdf9b0b7d 100644 --- a/src/ImageSharp/Formats/Tiff/Compression/Decompressors/ModifiedHuffmanTiffCompression.cs +++ b/src/ImageSharp/Formats/Tiff/Compression/Decompressors/ModifiedHuffmanTiffCompression.cs @@ -41,7 +41,7 @@ public ModifiedHuffmanTiffCompression(MemoryAllocator allocator, TiffFillOrder f /// protected override void Decompress(BufferedReadStream stream, int byteCount, int stripHeight, Span buffer, CancellationToken cancellationToken) { - var bitReader = new ModifiedHuffmanBitReader(stream, this.FillOrder, byteCount); + ModifiedHuffmanBitReader bitReader = new(stream, this.FillOrder, byteCount); buffer.Clear(); nint bitsWritten = 0; diff --git a/src/ImageSharp/Formats/Tiff/Compression/Decompressors/T4TiffCompression.cs b/src/ImageSharp/Formats/Tiff/Compression/Decompressors/T4TiffCompression.cs index 6bdcad2b81..d9e49aa754 100644 --- a/src/ImageSharp/Formats/Tiff/Compression/Decompressors/T4TiffCompression.cs +++ b/src/ImageSharp/Formats/Tiff/Compression/Decompressors/T4TiffCompression.cs @@ -60,7 +60,7 @@ protected override void Decompress(BufferedReadStream stream, int byteCount, int } bool eolPadding = this.faxCompressionOptions.HasFlag(FaxCompressionOptions.EolPadding); - var bitReader = new T4BitReader(stream, this.FillOrder, byteCount, eolPadding); + T4BitReader bitReader = new(stream, this.FillOrder, byteCount, eolPadding); buffer.Clear(); nint bitsWritten = 0; diff --git a/src/ImageSharp/Formats/Tiff/Compression/Decompressors/T6TiffCompression.cs b/src/ImageSharp/Formats/Tiff/Compression/Decompressors/T6TiffCompression.cs index c868fec626..c0ec49d8e7 100644 --- a/src/ImageSharp/Formats/Tiff/Compression/Decompressors/T6TiffCompression.cs +++ b/src/ImageSharp/Formats/Tiff/Compression/Decompressors/T6TiffCompression.cs @@ -57,9 +57,9 @@ protected override void Decompress(BufferedReadStream stream, int byteCount, int Span scanLine = scanLineBuffer.GetSpan()[..this.width]; Span referenceScanLineSpan = scanLineBuffer.GetSpan().Slice(this.width, this.width); - var bitReader = new T6BitReader(stream, this.FillOrder, byteCount); + T6BitReader bitReader = new(stream, this.FillOrder, byteCount); - var referenceScanLine = new CcittReferenceScanline(this.isWhiteZero, this.width); + CcittReferenceScanline referenceScanLine = new(this.isWhiteZero, this.width); nint bitsWritten = 0; for (int y = 0; y < height; y++) { @@ -69,7 +69,7 @@ protected override void Decompress(BufferedReadStream stream, int byteCount, int bitsWritten = this.WriteScanLine(buffer, scanLine, bitsWritten); scanLine.CopyTo(referenceScanLineSpan); - referenceScanLine = new CcittReferenceScanline(this.isWhiteZero, referenceScanLineSpan); + referenceScanLine = new(this.isWhiteZero, referenceScanLineSpan); } } diff --git a/src/ImageSharp/Formats/Tiff/Compression/Decompressors/TiffLzwDecoder.cs b/src/ImageSharp/Formats/Tiff/Compression/Decompressors/TiffLzwDecoder.cs index a53e1bc74c..40278dca20 100644 --- a/src/ImageSharp/Formats/Tiff/Compression/Decompressors/TiffLzwDecoder.cs +++ b/src/ImageSharp/Formats/Tiff/Compression/Decompressors/TiffLzwDecoder.cs @@ -103,7 +103,7 @@ public TiffLzwDecoder(Stream stream) this.table = new LzwString[TableSize]; for (int i = 0; i < 256; i++) { - this.table[i] = new LzwString((byte)i); + this.table[i] = new((byte)i); } this.Init(); diff --git a/src/ImageSharp/Formats/Tiff/Compression/Decompressors/WebpTiffCompression.cs b/src/ImageSharp/Formats/Tiff/Compression/Decompressors/WebpTiffCompression.cs index 76d0bb6418..5f4ca12bda 100644 --- a/src/ImageSharp/Formats/Tiff/Compression/Decompressors/WebpTiffCompression.cs +++ b/src/ImageSharp/Formats/Tiff/Compression/Decompressors/WebpTiffCompression.cs @@ -32,7 +32,7 @@ public WebpTiffCompression(DecoderOptions options, MemoryAllocator memoryAllocat /// protected override void Decompress(BufferedReadStream stream, int byteCount, int stripHeight, Span buffer, CancellationToken cancellationToken) { - using WebpDecoderCore decoder = new(new WebpDecoderOptions() { GeneralOptions = this.options }); + using WebpDecoderCore decoder = new(new() { GeneralOptions = this.options }); using Image image = decoder.Decode(this.options.Configuration, stream, cancellationToken); CopyImageBytesToBuffer(buffer, image.Frames.RootFrame.PixelBuffer); } diff --git a/src/ImageSharp/Formats/Tiff/Compression/HorizontalPredictor.cs b/src/ImageSharp/Formats/Tiff/Compression/HorizontalPredictor.cs index 30a9335286..18d771ab56 100644 --- a/src/ImageSharp/Formats/Tiff/Compression/HorizontalPredictor.cs +++ b/src/ImageSharp/Formats/Tiff/Compression/HorizontalPredictor.cs @@ -102,7 +102,7 @@ private static void ApplyHorizontalPrediction24Bit(Span rows, int width) byte r = (byte)(rowRgb[x].R - rowRgb[x - 1].R); byte g = (byte)(rowRgb[x].G - rowRgb[x - 1].G); byte b = (byte)(rowRgb[x].B - rowRgb[x - 1].B); - rowRgb[x] = new Rgb24(r, g, b); + rowRgb[x] = new(r, g, b); } } } @@ -276,7 +276,7 @@ private static void UndoRgb24Bit(Span pixelBytes, int width) r += pixel.R; g += pixel.G; b += pixel.B; - pixel = new Rgb24(r, g, b); + pixel = new(r, g, b); } } } @@ -302,7 +302,7 @@ private static void UndoRgba32Bit(Span pixelBytes, int width) g += pixel.G; b += pixel.B; a += pixel.A; - pixel = new Rgba32(r, g, b, a); + pixel = new(r, g, b, a); } } } diff --git a/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/BlackIsZero32FloatTiffColor{TPixel}.cs b/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/BlackIsZero32FloatTiffColor{TPixel}.cs index ac316459d8..b30700adb3 100644 --- a/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/BlackIsZero32FloatTiffColor{TPixel}.cs +++ b/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/BlackIsZero32FloatTiffColor{TPixel}.cs @@ -40,7 +40,7 @@ public override void Decode(ReadOnlySpan data, Buffer2D pixels, in float intensity = BitConverter.ToSingle(buffer); offset += 4; - pixelRow[x] = TPixel.FromScaledVector4(new Vector4(intensity, intensity, intensity, 1f)); + pixelRow[x] = TPixel.FromScaledVector4(new(intensity, intensity, intensity, 1f)); } } else @@ -50,7 +50,7 @@ public override void Decode(ReadOnlySpan data, Buffer2D pixels, in float intensity = BitConverter.ToSingle(data.Slice(offset, 4)); offset += 4; - pixelRow[x] = TPixel.FromScaledVector4(new Vector4(intensity, intensity, intensity, 1f)); + pixelRow[x] = TPixel.FromScaledVector4(new(intensity, intensity, intensity, 1f)); } } } diff --git a/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/RgbTiffColor{TPixel}.cs b/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/RgbTiffColor{TPixel}.cs index 3c205d1476..2b85c2fd6f 100644 --- a/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/RgbTiffColor{TPixel}.cs +++ b/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/RgbTiffColor{TPixel}.cs @@ -52,7 +52,7 @@ public override void Decode(ReadOnlySpan data, Buffer2D pixels, in float g = bitReader.ReadBits(this.bitsPerSampleG) / this.gFactor; float b = bitReader.ReadBits(this.bitsPerSampleB) / this.bFactor; - pixelRow[x] = TPixel.FromScaledVector4(new Vector4(r, g, b, 1f)); + pixelRow[x] = TPixel.FromScaledVector4(new(r, g, b, 1f)); } bitReader.NextRow(); diff --git a/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/WhiteIsZero32FloatTiffColor{TPixel}.cs b/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/WhiteIsZero32FloatTiffColor{TPixel}.cs index 7d31f23abd..0db555cbbd 100644 --- a/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/WhiteIsZero32FloatTiffColor{TPixel}.cs +++ b/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/WhiteIsZero32FloatTiffColor{TPixel}.cs @@ -50,7 +50,7 @@ public override void Decode(ReadOnlySpan data, Buffer2D pixels, in float intensity = 1.0f - BitConverter.ToSingle(data.Slice(offset, 4)); offset += 4; - pixelRow[x] = TPixel.FromScaledVector4(new Vector4(intensity, intensity, intensity, 1.0f)); + pixelRow[x] = TPixel.FromScaledVector4(new(intensity, intensity, intensity, 1.0f)); } } } diff --git a/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/WhiteIsZeroTiffColor{TPixel}.cs b/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/WhiteIsZeroTiffColor{TPixel}.cs index 0cd01a6199..06212eff3f 100644 --- a/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/WhiteIsZeroTiffColor{TPixel}.cs +++ b/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/WhiteIsZeroTiffColor{TPixel}.cs @@ -36,7 +36,7 @@ public override void Decode(ReadOnlySpan data, Buffer2D pixels, in { int value = bitReader.ReadBits(this.bitsPerSample0); float intensity = 1f - (value / this.factor); - pixelRow[x] = TPixel.FromScaledVector4(new Vector4(intensity, intensity, intensity, 1f)); + pixelRow[x] = TPixel.FromScaledVector4(new(intensity, intensity, intensity, 1f)); } bitReader.NextRow(); diff --git a/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/YCbCrConverter.cs b/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/YCbCrConverter.cs index 0a1cf6ab98..ab5294d1ff 100644 --- a/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/YCbCrConverter.cs +++ b/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/YCbCrConverter.cs @@ -17,18 +17,18 @@ internal class YCbCrConverter private readonly YCbCrToRgbConverter converter; private static readonly Rational[] DefaultLuma = - { + [ new(299, 1000), new(587, 1000), new(114, 1000) - }; + ]; private static readonly Rational[] DefaultReferenceBlackWhite = - { + [ new(0, 1), new(255, 1), new(128, 1), new(255, 1), new(128, 1), new(255, 1) - }; + ]; public YCbCrConverter(Rational[] referenceBlackAndWhite, Rational[] coefficients) { @@ -45,10 +45,10 @@ public YCbCrConverter(Rational[] referenceBlackAndWhite, Rational[] coefficients TiffThrowHelper.ThrowImageFormatException("luma coefficients array should have 6 entry's"); } - this.yExpander = new CodingRangeExpander(referenceBlackAndWhite[0], referenceBlackAndWhite[1], 255); - this.cbExpander = new CodingRangeExpander(referenceBlackAndWhite[2], referenceBlackAndWhite[3], 127); - this.crExpander = new CodingRangeExpander(referenceBlackAndWhite[4], referenceBlackAndWhite[5], 127); - this.converter = new YCbCrToRgbConverter(coefficients[0], coefficients[1], coefficients[2]); + this.yExpander = new(referenceBlackAndWhite[0], referenceBlackAndWhite[1], 255); + this.cbExpander = new(referenceBlackAndWhite[2], referenceBlackAndWhite[3], 127); + this.crExpander = new(referenceBlackAndWhite[4], referenceBlackAndWhite[5], 127); + this.converter = new(coefficients[0], coefficients[1], coefficients[2]); } [MethodImpl(MethodImplOptions.AggressiveInlining)] @@ -107,7 +107,7 @@ public YCbCrToRgbConverter(Rational lumaRed, Rational lumaGreen, Rational lumaBl [MethodImpl(MethodImplOptions.AggressiveInlining)] public Rgba32 Convert(float y, float cb, float cr) { - var pixel = default(Rgba32); + Rgba32 pixel = default(Rgba32); pixel.R = RoundAndClampTo8Bit((cr * this.cr2R) + y); pixel.G = RoundAndClampTo8Bit((this.y2G * y) + (this.cr2G * cr) + (this.cb2G * cb)); pixel.B = RoundAndClampTo8Bit((cb * this.cb2B) + y); diff --git a/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/YCbCrPlanarTiffColor{TPixel}.cs b/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/YCbCrPlanarTiffColor{TPixel}.cs index 768177bfc0..ebae824303 100644 --- a/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/YCbCrPlanarTiffColor{TPixel}.cs +++ b/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/YCbCrPlanarTiffColor{TPixel}.cs @@ -20,7 +20,7 @@ internal class YCbCrPlanarTiffColor : TiffBasePlanarColorDecoder public YCbCrPlanarTiffColor(Rational[] referenceBlackAndWhite, Rational[] coefficients, ushort[] ycbcrSubSampling) { - this.converter = new YCbCrConverter(referenceBlackAndWhite, coefficients); + this.converter = new(referenceBlackAndWhite, coefficients); this.ycbcrSubSampling = ycbcrSubSampling; } diff --git a/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/YCbCrTiffColor{TPixel}.cs b/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/YCbCrTiffColor{TPixel}.cs index 5a13890356..3bf550fe55 100644 --- a/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/YCbCrTiffColor{TPixel}.cs +++ b/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/YCbCrTiffColor{TPixel}.cs @@ -24,7 +24,7 @@ internal class YCbCrTiffColor : TiffBaseColorDecoder public YCbCrTiffColor(MemoryAllocator memoryAllocator, Rational[] referenceBlackAndWhite, Rational[] coefficients, ushort[] ycbcrSubSampling) { this.memoryAllocator = memoryAllocator; - this.converter = new YCbCrConverter(referenceBlackAndWhite, coefficients); + this.converter = new(referenceBlackAndWhite, coefficients); this.ycbcrSubSampling = ycbcrSubSampling; } diff --git a/src/ImageSharp/Formats/Tiff/TiffBitsPerSample.cs b/src/ImageSharp/Formats/Tiff/TiffBitsPerSample.cs index 2bfd9a626f..e9b620ea29 100644 --- a/src/ImageSharp/Formats/Tiff/TiffBitsPerSample.cs +++ b/src/ImageSharp/Formats/Tiff/TiffBitsPerSample.cs @@ -120,7 +120,7 @@ public static bool TryParse(ushort[]? value, out TiffBitsPerSample sample) break; } - sample = new TiffBitsPerSample(c0, c1, c2, c3); + sample = new(c0, c1, c2, c3); return true; } diff --git a/src/ImageSharp/Formats/Tiff/TiffDecoderCore.cs b/src/ImageSharp/Formats/Tiff/TiffDecoderCore.cs index d699a7b631..0586f44f80 100644 --- a/src/ImageSharp/Formats/Tiff/TiffDecoderCore.cs +++ b/src/ImageSharp/Formats/Tiff/TiffDecoderCore.cs @@ -190,7 +190,7 @@ protected override Image Decode(BufferedReadStream stream, Cance this.Dimensions = frames[0].Size; ImageMetadata metadata = TiffDecoderMetadataCreator.Create(framesMetadata, this.skipMetadata, reader.ByteOrder, reader.IsBigTiff); - return new Image(this.configuration, metadata, frames); + return new(this.configuration, metadata, frames); } catch { @@ -227,7 +227,7 @@ protected override ImageInfo Identify(BufferedReadStream stream, CancellationTok ImageMetadata metadata = TiffDecoderMetadataCreator.Create(framesMetadata, this.skipMetadata, reader.ByteOrder, reader.IsBigTiff); - return new ImageInfo(new(width, height), metadata, framesMetadata); + return new(new(width, height), metadata, framesMetadata); } /// diff --git a/src/ImageSharp/Formats/Tiff/TiffDecoderMetadataCreator.cs b/src/ImageSharp/Formats/Tiff/TiffDecoderMetadataCreator.cs index 28565cac47..fbb1b28de3 100644 --- a/src/ImageSharp/Formats/Tiff/TiffDecoderMetadataCreator.cs +++ b/src/ImageSharp/Formats/Tiff/TiffDecoderMetadataCreator.cs @@ -32,17 +32,17 @@ public static ImageMetadata Create(List frames, bool ignoreM ImageFrameMetadata frameMetaData = frames[i]; if (TryGetIptc(frameMetaData.ExifProfile.Values, out byte[] iptcBytes)) { - frameMetaData.IptcProfile = new IptcProfile(iptcBytes); + frameMetaData.IptcProfile = new(iptcBytes); } if (frameMetaData.ExifProfile.TryGetValue(ExifTag.XMP, out IExifValue xmpProfileBytes)) { - frameMetaData.XmpProfile = new XmpProfile(xmpProfileBytes.Value); + frameMetaData.XmpProfile = new(xmpProfileBytes.Value); } if (frameMetaData.ExifProfile.TryGetValue(ExifTag.IccProfile, out IExifValue iccProfileBytes)) { - frameMetaData.IccProfile = new IccProfile(iccProfileBytes.Value); + frameMetaData.IccProfile = new(iccProfileBytes.Value); } } } diff --git a/src/ImageSharp/Formats/Tiff/TiffDecoderOptionsParser.cs b/src/ImageSharp/Formats/Tiff/TiffDecoderOptionsParser.cs index ed91755468..10d9b231e3 100644 --- a/src/ImageSharp/Formats/Tiff/TiffDecoderOptionsParser.cs +++ b/src/ImageSharp/Formats/Tiff/TiffDecoderOptionsParser.cs @@ -529,7 +529,7 @@ private static void ParseCompression(this TiffDecoderCore options, TiffCompressi // Some encoders do not set the BitsPerSample correctly, so we set those values here to the required values: // https://github.com/SixLabors/ImageSharp/issues/2587 - options.BitsPerSample = new TiffBitsPerSample(1, 0, 0); + options.BitsPerSample = new(1, 0, 0); options.BitsPerPixel = 1; break; @@ -547,7 +547,7 @@ private static void ParseCompression(this TiffDecoderCore options, TiffCompressi options.FaxCompressionOptions = FaxCompressionOptions.None; } - options.BitsPerSample = new TiffBitsPerSample(1, 0, 0); + options.BitsPerSample = new(1, 0, 0); options.BitsPerPixel = 1; break; @@ -555,7 +555,7 @@ private static void ParseCompression(this TiffDecoderCore options, TiffCompressi case TiffCompression.Ccitt1D: options.CompressionType = TiffDecoderCompressionType.HuffmanRle; - options.BitsPerSample = new TiffBitsPerSample(1, 0, 0); + options.BitsPerSample = new(1, 0, 0); options.BitsPerPixel = 1; break; diff --git a/src/ImageSharp/Formats/Tiff/TiffEncoderEntriesCollector.cs b/src/ImageSharp/Formats/Tiff/TiffEncoderEntriesCollector.cs index 803b77fb0a..8890c61a59 100644 --- a/src/ImageSharp/Formats/Tiff/TiffEncoderEntriesCollector.cs +++ b/src/ImageSharp/Formats/Tiff/TiffEncoderEntriesCollector.cs @@ -16,7 +16,7 @@ internal class TiffEncoderEntriesCollector { private const string SoftwareValue = "ImageSharp"; - public List Entries { get; } = new List(); + public List Entries { get; } = new(); public void ProcessMetadata(Image image, bool skipMetadata) => new MetadataProcessor(this).Process(image, skipMetadata); @@ -298,12 +298,12 @@ private void ProcessResolution(ImageMetadata imageMetadata) { this.Collector.AddOrReplace(new ExifRational(ExifTagValue.XResolution) { - Value = new Rational(resolution.HorizontalResolution.Value) + Value = new(resolution.HorizontalResolution.Value) }); this.Collector.AddOrReplace(new ExifRational(ExifTagValue.YResolution) { - Value = new Rational(resolution.VerticalResolution.Value) + Value = new(resolution.VerticalResolution.Value) }); } } diff --git a/src/ImageSharp/Formats/Tiff/TiffFormat.cs b/src/ImageSharp/Formats/Tiff/TiffFormat.cs index 76a06d013d..eb052d1bf2 100644 --- a/src/ImageSharp/Formats/Tiff/TiffFormat.cs +++ b/src/ImageSharp/Formats/Tiff/TiffFormat.cs @@ -17,7 +17,7 @@ private TiffFormat() /// /// Gets the shared instance. /// - public static TiffFormat Instance { get; } = new TiffFormat(); + public static TiffFormat Instance { get; } = new(); /// public string Name => "TIFF"; @@ -32,8 +32,8 @@ private TiffFormat() public IEnumerable FileExtensions => TiffConstants.FileExtensions; /// - public TiffMetadata CreateDefaultFormatMetadata() => new TiffMetadata(); + public TiffMetadata CreateDefaultFormatMetadata() => new(); /// - public TiffFrameMetadata CreateDefaultFormatFrameMetadata() => new TiffFrameMetadata(); + public TiffFrameMetadata CreateDefaultFormatFrameMetadata() => new(); } diff --git a/src/ImageSharp/Formats/Tiff/TiffMetadata.cs b/src/ImageSharp/Formats/Tiff/TiffMetadata.cs index e965fcb4f6..7d20564694 100644 --- a/src/ImageSharp/Formats/Tiff/TiffMetadata.cs +++ b/src/ImageSharp/Formats/Tiff/TiffMetadata.cs @@ -75,7 +75,7 @@ public static TiffMetadata FromFormatConnectingMetadata(FormatConnectingMetadata int bpp = metadata.PixelTypeInfo.BitsPerPixel; return bpp switch { - 1 => new TiffMetadata + 1 => new() { BitsPerPixel = TiffBitsPerPixel.Bit1, BitsPerSample = TiffConstants.BitsPerSample1Bit, @@ -83,7 +83,7 @@ public static TiffMetadata FromFormatConnectingMetadata(FormatConnectingMetadata Compression = TiffCompression.CcittGroup4Fax, Predictor = TiffPredictor.None }, - <= 4 => new TiffMetadata + <= 4 => new() { BitsPerPixel = TiffBitsPerPixel.Bit4, BitsPerSample = TiffConstants.BitsPerSample4Bit, @@ -91,7 +91,7 @@ public static TiffMetadata FromFormatConnectingMetadata(FormatConnectingMetadata Compression = TiffCompression.Deflate, Predictor = TiffPredictor.None // Best match for low bit depth }, - 8 => new TiffMetadata + 8 => new() { BitsPerPixel = TiffBitsPerPixel.Bit8, BitsPerSample = TiffConstants.BitsPerSample8Bit, @@ -99,7 +99,7 @@ public static TiffMetadata FromFormatConnectingMetadata(FormatConnectingMetadata Compression = TiffCompression.Deflate, Predictor = TiffPredictor.Horizontal }, - 16 => new TiffMetadata + 16 => new() { BitsPerPixel = TiffBitsPerPixel.Bit16, BitsPerSample = TiffConstants.BitsPerSample16Bit, @@ -107,7 +107,7 @@ public static TiffMetadata FromFormatConnectingMetadata(FormatConnectingMetadata Compression = TiffCompression.Deflate, Predictor = TiffPredictor.Horizontal }, - 32 or 64 => new TiffMetadata + 32 or 64 => new() { BitsPerPixel = TiffBitsPerPixel.Bit32, BitsPerSample = TiffConstants.BitsPerSampleRgb8Bit, @@ -115,7 +115,7 @@ public static TiffMetadata FromFormatConnectingMetadata(FormatConnectingMetadata Compression = TiffCompression.Deflate, Predictor = TiffPredictor.Horizontal }, - _ => new TiffMetadata + _ => new() { BitsPerPixel = TiffBitsPerPixel.Bit24, BitsPerSample = TiffConstants.BitsPerSampleRgb8Bit, @@ -165,7 +165,7 @@ public PixelTypeInfo GetPixelTypeInfo() break; } - return new PixelTypeInfo(bpp) + return new(bpp) { ColorType = colorType, ComponentInfo = info, diff --git a/src/ImageSharp/Formats/Tiff/Writers/TiffBiColorWriter{TPixel}.cs b/src/ImageSharp/Formats/Tiff/Writers/TiffBiColorWriter{TPixel}.cs index 647ff8a1a3..8ede732793 100644 --- a/src/ImageSharp/Formats/Tiff/Writers/TiffBiColorWriter{TPixel}.cs +++ b/src/ImageSharp/Formats/Tiff/Writers/TiffBiColorWriter{TPixel}.cs @@ -30,7 +30,7 @@ public TiffBiColorWriter( : base(image, encodingSize, memoryAllocator, configuration, entriesCollector) { // Convert image to black and white. - this.imageBlackWhite = new Image(configuration, new ImageMetadata(), [image.Clone()]); + this.imageBlackWhite = new(configuration, new(), [image.Clone()]); this.imageBlackWhite.Mutate(img => img.BinaryDither(KnownDitherings.FloydSteinberg)); } diff --git a/src/ImageSharp/Formats/Tiff/Writers/TiffPaletteWriter{TPixel}.cs b/src/ImageSharp/Formats/Tiff/Writers/TiffPaletteWriter{TPixel}.cs index da66373631..a6106ae855 100644 --- a/src/ImageSharp/Formats/Tiff/Writers/TiffPaletteWriter{TPixel}.cs +++ b/src/ImageSharp/Formats/Tiff/Writers/TiffPaletteWriter{TPixel}.cs @@ -44,13 +44,13 @@ public TiffPaletteWriter( this.colorPaletteBytes = this.colorPaletteSize * 2; using IQuantizer frameQuantizer = quantizer.CreatePixelSpecificQuantizer( this.Configuration, - new QuantizerOptions() + new() { MaxColors = this.maxColors }); frameQuantizer.BuildPalette(pixelSamplingStrategy, frame); - this.quantizedFrame = frameQuantizer.QuantizeFrame(frame, new Rectangle(Point.Empty, encodingSize)); + this.quantizedFrame = frameQuantizer.QuantizeFrame(frame, new(Point.Empty, encodingSize)); this.AddColorMapTag(); } diff --git a/src/ImageSharp/Formats/Tiff/Writers/TiffStreamWriter.cs b/src/ImageSharp/Formats/Tiff/Writers/TiffStreamWriter.cs index 3c2ad60846..f880834119 100644 --- a/src/ImageSharp/Formats/Tiff/Writers/TiffStreamWriter.cs +++ b/src/ImageSharp/Formats/Tiff/Writers/TiffStreamWriter.cs @@ -110,7 +110,7 @@ public void WritePadded(Span value) if (value.Length % 4 != 0) { // No allocation occurs, refers directly to assembly's data segment. - ReadOnlySpan paddingBytes = new byte[4] { 0x00, 0x00, 0x00, 0x00 }; + ReadOnlySpan paddingBytes = [0x00, 0x00, 0x00, 0x00]; paddingBytes = paddingBytes[..(4 - (value.Length % 4))]; this.BaseStream.Write(paddingBytes); } diff --git a/src/ImageSharp/Formats/Webp/AlphaDecoder.cs b/src/ImageSharp/Formats/Webp/AlphaDecoder.cs index eccd9ede8e..7f959da69a 100644 --- a/src/ImageSharp/Formats/Webp/AlphaDecoder.cs +++ b/src/ImageSharp/Formats/Webp/AlphaDecoder.cs @@ -57,12 +57,12 @@ public AlphaDecoder(int width, int height, IMemoryOwner data, byte alphaCh this.Alpha = memoryAllocator.Allocate(totalPixels); this.AlphaFilterType = (WebpAlphaFilterType)filter; - this.Vp8LDec = new Vp8LDecoder(width, height, memoryAllocator); + this.Vp8LDec = new(width, height, memoryAllocator); if (this.Compressed) { - Vp8LBitReader bitReader = new Vp8LBitReader(data); - this.LosslessDecoder = new WebpLosslessDecoder(bitReader, memoryAllocator, configuration); + Vp8LBitReader bitReader = new(data); + this.LosslessDecoder = new(bitReader, memoryAllocator, configuration); this.LosslessDecoder.DecodeImageStream(this.Vp8LDec, width, height, true); // Special case: if alpha data uses only the color indexing transform and diff --git a/src/ImageSharp/Formats/Webp/AlphaEncoder.cs b/src/ImageSharp/Formats/Webp/AlphaEncoder.cs index 46030dde32..8bb0764f7b 100644 --- a/src/ImageSharp/Formats/Webp/AlphaEncoder.cs +++ b/src/ImageSharp/Formats/Webp/AlphaEncoder.cs @@ -92,7 +92,7 @@ private static ImageFrame DispatchAlphaToGreen(Configuration con for (int x = 0; x < width; x++) { // Leave A/R/B channels zero'd. - pixelRow[x] = new Bgra32(0, alphaRow[x], 0, 0); + pixelRow[x] = new(0, alphaRow[x], 0, 0); } } diff --git a/src/ImageSharp/Formats/Webp/BitReader/Vp8LBitReader.cs b/src/ImageSharp/Formats/Webp/BitReader/Vp8LBitReader.cs index 6d3cab1514..c7e1455911 100644 --- a/src/ImageSharp/Formats/Webp/BitReader/Vp8LBitReader.cs +++ b/src/ImageSharp/Formats/Webp/BitReader/Vp8LBitReader.cs @@ -28,7 +28,7 @@ internal class Vp8LBitReader : BitReaderBase private const int Wbits = 32; private static readonly uint[] BitMask = - { + [ 0, 0x000001, 0x000003, 0x000007, 0x00000f, 0x00001f, 0x00003f, 0x00007f, 0x0000ff, @@ -36,7 +36,7 @@ internal class Vp8LBitReader : BitReaderBase 0x001fff, 0x003fff, 0x007fff, 0x00ffff, 0x01ffff, 0x03ffff, 0x07ffff, 0x0fffff, 0x1fffff, 0x3fffff, 0x7fffff, 0xffffff - }; + ]; /// /// Pre-fetched bits. diff --git a/src/ImageSharp/Formats/Webp/BitWriter/Vp8BitWriter.cs b/src/ImageSharp/Formats/Webp/BitWriter/Vp8BitWriter.cs index 81530706d6..923d2a69c4 100644 --- a/src/ImageSharp/Formats/Webp/BitWriter/Vp8BitWriter.cs +++ b/src/ImageSharp/Formats/Webp/BitWriter/Vp8BitWriter.cs @@ -399,7 +399,7 @@ public override void WriteEncodedImageToStream(Stream stream) int mbSize = this.enc.Mbw * this.enc.Mbh; int expectedSize = (int)((uint)mbSize * 7 / 8); - Vp8BitWriter bitWriterPartZero = new Vp8BitWriter(expectedSize, this.enc); + Vp8BitWriter bitWriterPartZero = new(expectedSize, this.enc); // Partition #0 with header and partition sizes. uint size0 = bitWriterPartZero.GeneratePartition0(); @@ -545,7 +545,7 @@ private void WriteProbas() // Writes the partition #0 modes (that is: all intra modes) private void CodeIntraModes() { - Vp8EncIterator it = new Vp8EncIterator(this.enc); + Vp8EncIterator it = new(this.enc); int predsWidth = this.enc.PredsWidth; do diff --git a/src/ImageSharp/Formats/Webp/BitWriter/Vp8LBitWriter.cs b/src/ImageSharp/Formats/Webp/BitWriter/Vp8LBitWriter.cs index dc867fa85e..0b71a3ed0c 100644 --- a/src/ImageSharp/Formats/Webp/BitWriter/Vp8LBitWriter.cs +++ b/src/ImageSharp/Formats/Webp/BitWriter/Vp8LBitWriter.cs @@ -102,7 +102,7 @@ public Vp8LBitWriter Clone() { byte[] clonedBuffer = new byte[this.Buffer.Length]; System.Buffer.BlockCopy(this.Buffer, 0, clonedBuffer, 0, this.cur); - return new Vp8LBitWriter(clonedBuffer, this.bits, this.used, this.cur); + return new(clonedBuffer, this.bits, this.used, this.cur); } /// diff --git a/src/ImageSharp/Formats/Webp/Lossless/BackwardReferenceEncoder.cs b/src/ImageSharp/Formats/Webp/Lossless/BackwardReferenceEncoder.cs index 2e7dd722fc..41603e8501 100644 --- a/src/ImageSharp/Formats/Webp/Lossless/BackwardReferenceEncoder.cs +++ b/src/ImageSharp/Formats/Webp/Lossless/BackwardReferenceEncoder.cs @@ -72,7 +72,7 @@ public static Vp8LBackwardRefs GetBackwardReferences( BackwardReferencesLz77(width, height, bgra, 0, hashChain, worst); break; case Vp8LLz77Type.Lz77Box: - hashChainBox = new Vp8LHashChain(memoryAllocator, width * height); + hashChainBox = new(memoryAllocator, width * height); BackwardReferencesLz77Box(width, height, bgra, 0, hashChain, hashChainBox, worst); break; } @@ -145,7 +145,7 @@ private static int CalculateBestCacheSize( for (int i = 0; i < colorCache.Length; i++) { histos[i].PaletteCodeBits = i; - colorCache[i] = new ColorCache(i); + colorCache[i] = new(i); } // Find the cacheBits giving the lowest entropy. @@ -282,7 +282,7 @@ private static void BackwardReferencesHashChainDistanceOnly( if (useColorCache) { - colorCache = new ColorCache(cacheBits); + colorCache = new(cacheBits); } costModel.Build(xSize, cacheBits, refs); @@ -384,7 +384,7 @@ private static void BackwardReferencesHashChainFollowChosenPath(ReadOnlySpan bgra, int cacheBits, Vp8LBackwardRefs refs) { int pixelIndex = 0; - ColorCache colorCache = new ColorCache(cacheBits); + ColorCache colorCache = new(cacheBits); for (int idx = 0; idx < refs.Refs.Count; idx++) { PixOrCopy v = refs.Refs[idx]; diff --git a/src/ImageSharp/Formats/Webp/Lossless/ColorSpaceTransformUtils.cs b/src/ImageSharp/Formats/Webp/Lossless/ColorSpaceTransformUtils.cs index 9a6dfb66e8..f437b5cabc 100644 --- a/src/ImageSharp/Formats/Webp/Lossless/ColorSpaceTransformUtils.cs +++ b/src/ImageSharp/Formats/Webp/Lossless/ColorSpaceTransformUtils.cs @@ -16,13 +16,13 @@ public static void CollectColorBlueTransforms(Span bgra, int stride, int t { const int span = 16; Span values = stackalloc ushort[span]; - var collectColorBlueTransformsShuffleLowMask256 = Vector256.Create(255, 2, 255, 6, 255, 10, 255, 14, 255, 255, 255, 255, 255, 255, 255, 255, 255, 18, 255, 22, 255, 26, 255, 30, 255, 255, 255, 255, 255, 255, 255, 255); - var collectColorBlueTransformsShuffleHighMask256 = Vector256.Create(255, 255, 255, 255, 255, 255, 255, 255, 255, 2, 255, 6, 255, 10, 255, 14, 255, 255, 255, 255, 255, 255, 255, 255, 255, 18, 255, 22, 255, 26, 255, 30); - var collectColorBlueTransformsGreenBlueMask256 = Vector256.Create(255, 255, 0, 0, 255, 255, 0, 0, 255, 255, 0, 0, 255, 255, 0, 0, 255, 255, 0, 0, 255, 255, 0, 0, 255, 255, 0, 0, 255, 255, 0, 0); - var collectColorBlueTransformsGreenMask256 = Vector256.Create(0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255); - var collectColorBlueTransformsBlueMask256 = Vector256.Create(255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0); - var multsr = Vector256.Create(LosslessUtils.Cst5b(redToBlue)); - var multsg = Vector256.Create(LosslessUtils.Cst5b(greenToBlue)); + Vector256 collectColorBlueTransformsShuffleLowMask256 = Vector256.Create(255, 2, 255, 6, 255, 10, 255, 14, 255, 255, 255, 255, 255, 255, 255, 255, 255, 18, 255, 22, 255, 26, 255, 30, 255, 255, 255, 255, 255, 255, 255, 255); + Vector256 collectColorBlueTransformsShuffleHighMask256 = Vector256.Create(255, 255, 255, 255, 255, 255, 255, 255, 255, 2, 255, 6, 255, 10, 255, 14, 255, 255, 255, 255, 255, 255, 255, 255, 255, 18, 255, 22, 255, 26, 255, 30); + Vector256 collectColorBlueTransformsGreenBlueMask256 = Vector256.Create(255, 255, 0, 0, 255, 255, 0, 0, 255, 255, 0, 0, 255, 255, 0, 0, 255, 255, 0, 0, 255, 255, 0, 0, 255, 255, 0, 0, 255, 255, 0, 0); + Vector256 collectColorBlueTransformsGreenMask256 = Vector256.Create(0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255); + Vector256 collectColorBlueTransformsBlueMask256 = Vector256.Create(255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0); + Vector256 multsr = Vector256.Create(LosslessUtils.Cst5b(redToBlue)); + Vector256 multsg = Vector256.Create(LosslessUtils.Cst5b(greenToBlue)); for (int y = 0; y < tileHeight; y++) { Span srcSpan = bgra[(y * stride)..]; @@ -66,13 +66,13 @@ public static void CollectColorBlueTransforms(Span bgra, int stride, int t { const int span = 8; Span values = stackalloc ushort[span]; - var collectColorBlueTransformsShuffleLowMask = Vector128.Create(255, 2, 255, 6, 255, 10, 255, 14, 255, 255, 255, 255, 255, 255, 255, 255); - var collectColorBlueTransformsShuffleHighMask = Vector128.Create(255, 255, 255, 255, 255, 255, 255, 255, 255, 2, 255, 6, 255, 10, 255, 14); - var collectColorBlueTransformsGreenBlueMask = Vector128.Create(255, 255, 0, 0, 255, 255, 0, 0, 255, 255, 0, 0, 255, 255, 0, 0); - var collectColorBlueTransformsGreenMask = Vector128.Create(0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255); - var collectColorBlueTransformsBlueMask = Vector128.Create(255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0); - var multsr = Vector128.Create(LosslessUtils.Cst5b(redToBlue)); - var multsg = Vector128.Create(LosslessUtils.Cst5b(greenToBlue)); + Vector128 collectColorBlueTransformsShuffleLowMask = Vector128.Create(255, 2, 255, 6, 255, 10, 255, 14, 255, 255, 255, 255, 255, 255, 255, 255); + Vector128 collectColorBlueTransformsShuffleHighMask = Vector128.Create(255, 255, 255, 255, 255, 255, 255, 255, 255, 2, 255, 6, 255, 10, 255, 14); + Vector128 collectColorBlueTransformsGreenBlueMask = Vector128.Create(255, 255, 0, 0, 255, 255, 0, 0, 255, 255, 0, 0, 255, 255, 0, 0); + Vector128 collectColorBlueTransformsGreenMask = Vector128.Create(0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255); + Vector128 collectColorBlueTransformsBlueMask = Vector128.Create(255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0); + Vector128 multsr = Vector128.Create(LosslessUtils.Cst5b(redToBlue)); + Vector128 multsg = Vector128.Create(LosslessUtils.Cst5b(greenToBlue)); for (int y = 0; y < tileHeight; y++) { Span srcSpan = bgra[(y * stride)..]; @@ -139,7 +139,7 @@ public static void CollectColorRedTransforms(Span bgra, int stride, int ti { Vector256 collectColorRedTransformsGreenMask256 = Vector256.Create(0x00ff00).AsByte(); Vector256 collectColorRedTransformsAndMask256 = Vector256.Create((short)0xff).AsByte(); - var multsg = Vector256.Create(LosslessUtils.Cst5b(greenToRed)); + Vector256 multsg = Vector256.Create(LosslessUtils.Cst5b(greenToRed)); const int span = 16; Span values = stackalloc ushort[span]; for (int y = 0; y < tileHeight; y++) @@ -182,7 +182,7 @@ public static void CollectColorRedTransforms(Span bgra, int stride, int ti { Vector128 collectColorRedTransformsGreenMask = Vector128.Create(0x00ff00).AsByte(); Vector128 collectColorRedTransformsAndMask = Vector128.Create((short)0xff).AsByte(); - var multsg = Vector128.Create(LosslessUtils.Cst5b(greenToRed)); + Vector128 multsg = Vector128.Create(LosslessUtils.Cst5b(greenToRed)); const int span = 8; Span values = stackalloc ushort[span]; for (int y = 0; y < tileHeight; y++) diff --git a/src/ImageSharp/Formats/Webp/Lossless/CostManager.cs b/src/ImageSharp/Formats/Webp/Lossless/CostManager.cs index 63ce9dbec6..2b2286e044 100644 --- a/src/ImageSharp/Formats/Webp/Lossless/CostManager.cs +++ b/src/ImageSharp/Formats/Webp/Lossless/CostManager.cs @@ -17,21 +17,21 @@ internal sealed class CostManager : IDisposable private const int FreeIntervalsStartCount = 25; - private readonly Stack freeIntervals = new Stack(FreeIntervalsStartCount); + private readonly Stack freeIntervals = new(FreeIntervalsStartCount); public CostManager(MemoryAllocator memoryAllocator, IMemoryOwner distArray, int pixCount, CostModel costModel) { int costCacheSize = pixCount > BackwardReferenceEncoder.MaxLength ? BackwardReferenceEncoder.MaxLength : pixCount; - this.CacheIntervals = new List(); - this.CostCache = new List(); + this.CacheIntervals = new(); + this.CostCache = new(); this.Costs = memoryAllocator.Allocate(pixCount); this.DistArray = distArray; this.Count = 0; for (int i = 0; i < FreeIntervalsStartCount; i++) { - this.freeIntervals.Push(new CostInterval()); + this.freeIntervals.Push(new()); } // Fill in the cost cache. @@ -49,7 +49,7 @@ public CostManager(MemoryAllocator memoryAllocator, IMemoryOwner distArr } // Fill in the cache intervals. - var cur = new CostCacheInterval() + CostCacheInterval cur = new() { Start = 0, End = 1, @@ -62,7 +62,7 @@ public CostManager(MemoryAllocator memoryAllocator, IMemoryOwner distArr double costVal = this.CostCache[i]; if (costVal != cur.Cost) { - cur = new CostCacheInterval() + cur = new() { Start = i, Cost = costVal @@ -258,7 +258,7 @@ private void InsertInterval(CostInterval? intervalIn, float cost, int position, } else { - intervalNew = new CostInterval() { Cost = cost, Start = start, End = end, Index = position }; + intervalNew = new() { Cost = cost, Start = start, End = end, Index = position }; } this.PositionOrphanInterval(intervalNew, intervalIn); diff --git a/src/ImageSharp/Formats/Webp/Lossless/CrunchConfig.cs b/src/ImageSharp/Formats/Webp/Lossless/CrunchConfig.cs index 7488f03ca4..58394c212f 100644 --- a/src/ImageSharp/Formats/Webp/Lossless/CrunchConfig.cs +++ b/src/ImageSharp/Formats/Webp/Lossless/CrunchConfig.cs @@ -7,5 +7,5 @@ internal class CrunchConfig { public EntropyIx EntropyIdx { get; set; } - public List SubConfigs { get; } = new List(); + public List SubConfigs { get; } = new(); } diff --git a/src/ImageSharp/Formats/Webp/Lossless/HTreeGroup.cs b/src/ImageSharp/Formats/Webp/Lossless/HTreeGroup.cs index 5806ee5b5c..1375218da9 100644 --- a/src/ImageSharp/Formats/Webp/Lossless/HTreeGroup.cs +++ b/src/ImageSharp/Formats/Webp/Lossless/HTreeGroup.cs @@ -15,7 +15,7 @@ internal struct HTreeGroup { public HTreeGroup(uint packedTableSize) { - this.HTrees = new List(WebpConstants.HuffmanCodesPerMetaCode); + this.HTrees = new(WebpConstants.HuffmanCodesPerMetaCode); this.PackedTable = new HuffmanCode[packedTableSize]; this.IsTrivialCode = false; this.IsTrivialLiteral = false; diff --git a/src/ImageSharp/Formats/Webp/Lossless/HuffmanUtils.cs b/src/ImageSharp/Formats/Webp/Lossless/HuffmanUtils.cs index 027d4f7ee9..f8c515dc0f 100644 --- a/src/ImageSharp/Formats/Webp/Lossless/HuffmanUtils.cs +++ b/src/ImageSharp/Formats/Webp/Lossless/HuffmanUtils.cs @@ -20,10 +20,10 @@ internal static class HuffmanUtils // Pre-reversed 4-bit values. private static readonly byte[] ReversedBits = - { + [ 0x0, 0x8, 0x4, 0xc, 0x2, 0xa, 0x6, 0xe, 0x1, 0x9, 0x5, 0xd, 0x3, 0xb, 0x7, 0xf - }; + ]; public static void CreateHuffmanTree(Span histogram, int treeDepthLimit, bool[] bufRle, Span huffTree, HuffmanTreeCode huffCode) { @@ -425,7 +425,7 @@ public static int BuildHuffmanTable(Span table, int rootBits, int[] tableSize = 1 << tableBits; totalSize += tableSize; low = key & mask; - table[low] = new HuffmanCode + table[low] = new() { BitsUsed = tableBits + rootBits, Value = (uint)(tablePos - low) diff --git a/src/ImageSharp/Formats/Webp/Lossless/PixOrCopy.cs b/src/ImageSharp/Formats/Webp/Lossless/PixOrCopy.cs index d6b10ada55..cecd2fd1f2 100644 --- a/src/ImageSharp/Formats/Webp/Lossless/PixOrCopy.cs +++ b/src/ImageSharp/Formats/Webp/Lossless/PixOrCopy.cs @@ -15,7 +15,7 @@ internal sealed class PixOrCopy public uint BgraOrDistance { get; set; } public static PixOrCopy CreateCacheIdx(int idx) => - new PixOrCopy + new() { Mode = PixOrCopyMode.CacheIdx, BgraOrDistance = (uint)idx, @@ -23,7 +23,7 @@ public static PixOrCopy CreateCacheIdx(int idx) => }; public static PixOrCopy CreateLiteral(uint bgra) => - new PixOrCopy + new() { Mode = PixOrCopyMode.Literal, BgraOrDistance = bgra, @@ -31,8 +31,8 @@ public static PixOrCopy CreateLiteral(uint bgra) => }; public static PixOrCopy CreateCopy(uint distance, ushort len) => - new PixOrCopy - { + new() + { Mode = PixOrCopyMode.Copy, BgraOrDistance = distance, Len = len diff --git a/src/ImageSharp/Formats/Webp/Lossless/PredictorEncoder.cs b/src/ImageSharp/Formats/Webp/Lossless/PredictorEncoder.cs index 2170eb1985..133947095d 100644 --- a/src/ImageSharp/Formats/Webp/Lossless/PredictorEncoder.cs +++ b/src/ImageSharp/Formats/Webp/Lossless/PredictorEncoder.cs @@ -12,9 +12,9 @@ namespace SixLabors.ImageSharp.Formats.Webp.Lossless; internal static unsafe class PredictorEncoder { private static readonly sbyte[][] Offset = - { - new sbyte[] { 0, -1 }, new sbyte[] { 0, 1 }, new sbyte[] { -1, 0 }, new sbyte[] { 1, 0 }, new sbyte[] { -1, -1 }, new sbyte[] { -1, 1 }, new sbyte[] { 1, -1 }, new sbyte[] { 1, 1 } - }; + [ + [0, -1], [0, 1], [-1, 0], [1, 0], [-1, -1], [-1, 1], [1, -1], [1, 1] + ]; private const int GreenRedToBlueNumAxis = 8; @@ -29,7 +29,7 @@ internal static unsafe class PredictorEncoder private const int PredLowEffort = 11; // This uses C#'s compiler optimization to refer to assembly's static data directly. - private static ReadOnlySpan DeltaLut => new sbyte[] { 16, 16, 8, 4, 2, 2, 2 }; + private static ReadOnlySpan DeltaLut => [16, 16, 8, 4, 2, 2, 2]; /// /// Finds the best predictor for each tile, and converts the image to residuals @@ -58,12 +58,12 @@ public static void ResidualImage( // TODO: Can we optimize this? int[][] histo = - { + [ new int[256], new int[256], new int[256], new int[256] - }; + ]; if (lowEffort) { @@ -122,8 +122,8 @@ public static void ColorSpaceTransform(int width, int height, int bits, uint qua int tileYSize = LosslessUtils.SubSampleSize(height, bits); int[] accumulatedRedHisto = new int[256]; int[] accumulatedBlueHisto = new int[256]; - var prevX = default(Vp8LMultipliers); - var prevY = default(Vp8LMultipliers); + Vp8LMultipliers prevX = default(Vp8LMultipliers); + Vp8LMultipliers prevY = default(Vp8LMultipliers); for (int tileY = 0; tileY < tileYSize; tileY++) { for (int tileX = 0; tileX < tileXSize; tileX++) @@ -854,7 +854,7 @@ private static Vp8LMultipliers GetBestColorTransformForTile( int tileHeight = allYMax - tileYOffset; Span tileArgb = argb[((tileYOffset * xSize) + tileXOffset)..]; - var bestTx = default(Vp8LMultipliers); + Vp8LMultipliers bestTx = default(Vp8LMultipliers); GetBestGreenToRed(tileArgb, xSize, scratch, tileWidth, tileHeight, prevX, prevY, quality, accumulatedRedHisto, ref bestTx); diff --git a/src/ImageSharp/Formats/Webp/Lossless/Vp8LBackwardRefs.cs b/src/ImageSharp/Formats/Webp/Lossless/Vp8LBackwardRefs.cs index ace9d62271..1a1a4df380 100644 --- a/src/ImageSharp/Formats/Webp/Lossless/Vp8LBackwardRefs.cs +++ b/src/ImageSharp/Formats/Webp/Lossless/Vp8LBackwardRefs.cs @@ -5,7 +5,7 @@ namespace SixLabors.ImageSharp.Formats.Webp.Lossless; internal class Vp8LBackwardRefs { - public Vp8LBackwardRefs(int pixels) => this.Refs = new List(pixels); + public Vp8LBackwardRefs(int pixels) => this.Refs = new(pixels); /// /// Gets or sets the common block-size. diff --git a/src/ImageSharp/Formats/Webp/Lossless/Vp8LDecoder.cs b/src/ImageSharp/Formats/Webp/Lossless/Vp8LDecoder.cs index 374465cf79..c22abd83e2 100644 --- a/src/ImageSharp/Formats/Webp/Lossless/Vp8LDecoder.cs +++ b/src/ImageSharp/Formats/Webp/Lossless/Vp8LDecoder.cs @@ -22,7 +22,7 @@ public Vp8LDecoder(int width, int height, MemoryAllocator memoryAllocator) { this.Width = width; this.Height = height; - this.Metadata = new Vp8LMetadata(); + this.Metadata = new(); this.Pixels = memoryAllocator.Allocate(width * height, AllocationOptions.Clean); } diff --git a/src/ImageSharp/Formats/Webp/Lossless/Vp8LEncoder.cs b/src/ImageSharp/Formats/Webp/Lossless/Vp8LEncoder.cs index 244691e77e..f65fde08a3 100644 --- a/src/ImageSharp/Formats/Webp/Lossless/Vp8LEncoder.cs +++ b/src/ImageSharp/Formats/Webp/Lossless/Vp8LEncoder.cs @@ -26,9 +26,9 @@ internal class Vp8LEncoder : IDisposable /// private ScratchBuffer scratch; // mutable struct, don't make readonly - private readonly int[][] histoArgb = { new int[256], new int[256], new int[256], new int[256] }; + private readonly int[][] histoArgb = [new int[256], new int[256], new int[256], new int[256]]; - private readonly int[][] bestHisto = { new int[256], new int[256], new int[256], new int[256] }; + private readonly int[][] bestHisto = [new int[256], new int[256], new int[256], new int[256]]; /// /// The to use for buffer allocations. @@ -129,18 +129,18 @@ public Vp8LEncoder( this.transparentColorMode = transparentColorMode; this.nearLossless = nearLossless; this.nearLosslessQuality = Numerics.Clamp(nearLosslessQuality, 0, 100); - this.bitWriter = new Vp8LBitWriter(initialSize); + this.bitWriter = new(initialSize); this.Bgra = memoryAllocator.Allocate(pixelCount); this.EncodedData = memoryAllocator.Allocate(pixelCount); this.Palette = memoryAllocator.Allocate(WebpConstants.MaxPaletteSize); this.Refs = new Vp8LBackwardRefs[3]; - this.HashChain = new Vp8LHashChain(memoryAllocator, pixelCount); + this.HashChain = new(memoryAllocator, pixelCount); // We round the block size up, so we're guaranteed to have at most MaxRefsBlockPerImage blocks used: int refsBlockSize = ((pixelCount - 1) / MaxRefsBlockPerImage) + 1; for (int i = 0; i < this.Refs.Length; i++) { - this.Refs[i] = new Vp8LBackwardRefs(pixelCount) + this.Refs[i] = new(pixelCount) { BlockSize = refsBlockSize < MinBlockSize ? MinBlockSize : refsBlockSize }; @@ -151,10 +151,11 @@ public Vp8LEncoder( // This sequence is tuned from that, but more weighted for lower symbol count, // and more spiking histograms. // This uses C#'s compiler optimization to refer to assembly's static data directly. - private static ReadOnlySpan StorageOrder => new byte[] { 17, 18, 0, 1, 2, 3, 4, 5, 16, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 }; + private static ReadOnlySpan StorageOrder => [17, 18, 0, 1, 2, 3, 4, 5, 16, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 + ]; // This uses C#'s compiler optimization to refer to assembly's static data directly. - private static ReadOnlySpan Order => new byte[] { 1, 2, 0, 3 }; + private static ReadOnlySpan Order => [1, 2, 0, 3]; /// /// Gets the memory for the image data as packed bgra values. @@ -550,7 +551,7 @@ private CrunchConfig[] EncoderAnalyze(ReadOnlySpan bgra, int width, int he EntropyIx entropyIdx = this.AnalyzeEntropy(bgra, width, height, usePalette, this.PaletteSize, this.TransformBits, out redAndBlueAlwaysZero); bool doNotCache = false; - List crunchConfigs = new(); + List crunchConfigs = []; if (this.method == WebpEncodingMethod.BestQuality && this.quality == 100) { @@ -562,14 +563,14 @@ private CrunchConfig[] EncoderAnalyze(ReadOnlySpan bgra, int width, int he // We can only apply kPalette or kPaletteAndSpatial if we can indeed use a palette. if ((entropyIx != EntropyIx.Palette && entropyIx != EntropyIx.PaletteAndSpatial) || usePalette) { - crunchConfigs.Add(new CrunchConfig { EntropyIdx = entropyIx }); + crunchConfigs.Add(new() { EntropyIdx = entropyIx }); } } } else { // Only choose the guessed best transform. - crunchConfigs.Add(new CrunchConfig { EntropyIdx = entropyIdx }); + crunchConfigs.Add(new() { EntropyIdx = entropyIdx }); if (this.quality >= 75 && this.method == WebpEncodingMethod.Level5) { // Test with and without color cache. @@ -578,7 +579,7 @@ private CrunchConfig[] EncoderAnalyze(ReadOnlySpan bgra, int width, int he // If we have a palette, also check in combination with spatial. if (entropyIdx == EntropyIx.Palette) { - crunchConfigs.Add(new CrunchConfig { EntropyIdx = EntropyIx.PaletteAndSpatial }); + crunchConfigs.Add(new() { EntropyIdx = EntropyIx.PaletteAndSpatial }); } } } @@ -588,7 +589,7 @@ private CrunchConfig[] EncoderAnalyze(ReadOnlySpan bgra, int width, int he { for (int j = 0; j < nlz77s; j++) { - crunchConfig.SubConfigs.Add(new CrunchSubConfig + crunchConfig.SubConfigs.Add(new() { Lz77 = j == 0 ? (int)Vp8LLz77Type.Lz77Standard | (int)Vp8LLz77Type.Lz77Rle : (int)Vp8LLz77Type.Lz77Box, DoNotCache = doNotCache @@ -725,7 +726,7 @@ private void EncodeImage(int width, int height, bool useCache, CrunchConfig conf HuffmanTreeToken[] tokens = new HuffmanTreeToken[maxTokens]; for (int i = 0; i < tokens.Length; i++) { - tokens[i] = new HuffmanTreeToken(); + tokens[i] = new(); } for (int i = 0; i < 5 * histogramImageSize; i++) @@ -871,7 +872,7 @@ private void EncodeImageNoHuffman(Span bgra, Vp8LHashChain hashChain, Vp8L HuffmanTreeToken[] tokens = new HuffmanTreeToken[maxTokens]; for (int i = 0; i < tokens.Length; i++) { - tokens[i] = new HuffmanTreeToken(); + tokens[i] = new(); } // Store Huffman codes. @@ -1268,13 +1269,13 @@ private EntropyIx AnalyzeEntropy(ReadOnlySpan bgra, int width, int height, // non-zero red and blue values. If all are zero, we can later skip // the cross color optimization. byte[][] histoPairs = - { - new[] { (byte)HistoIx.HistoRed, (byte)HistoIx.HistoBlue }, - new[] { (byte)HistoIx.HistoRedPred, (byte)HistoIx.HistoBluePred }, - new[] { (byte)HistoIx.HistoRedSubGreen, (byte)HistoIx.HistoBlueSubGreen }, - new[] { (byte)HistoIx.HistoRedPredSubGreen, (byte)HistoIx.HistoBluePredSubGreen }, - new[] { (byte)HistoIx.HistoRed, (byte)HistoIx.HistoBlue } - }; + [ + [(byte)HistoIx.HistoRed, (byte)HistoIx.HistoBlue], + [(byte)HistoIx.HistoRedPred, (byte)HistoIx.HistoBluePred], + [(byte)HistoIx.HistoRedSubGreen, (byte)HistoIx.HistoBlueSubGreen], + [(byte)HistoIx.HistoRedPredSubGreen, (byte)HistoIx.HistoBluePredSubGreen], + [(byte)HistoIx.HistoRed, (byte)HistoIx.HistoBlue] + ]; Span redHisto = histo[(256 * histoPairs[(int)minEntropyIx][0])..]; Span blueHisto = histo[(256 * histoPairs[(int)minEntropyIx][1])..]; for (int i = 1; i < 256; i++) @@ -1328,7 +1329,7 @@ private bool AnalyzeAndCreatePalette(ReadOnlySpan bgra, int width, int hei /// The number of palette entries. private static int GetColorPalette(ReadOnlySpan bgra, int width, int height, Span palette) { - HashSet colors = new(); + HashSet colors = []; for (int y = 0; y < height; y++) { ReadOnlySpan bgraRow = bgra.Slice(y * width, width); diff --git a/src/ImageSharp/Formats/Webp/Lossless/Vp8LHistogram.cs b/src/ImageSharp/Formats/Webp/Lossless/Vp8LHistogram.cs index f473977908..758eb3b1cb 100644 --- a/src/ImageSharp/Formats/Webp/Lossless/Vp8LHistogram.cs +++ b/src/ImageSharp/Formats/Webp/Lossless/Vp8LHistogram.cs @@ -613,7 +613,7 @@ public static OwnedVp8LHistogram Create(MemoryAllocator memoryAllocator, int pal { IMemoryOwner bufferOwner = memoryAllocator.Allocate(BufferSize, AllocationOptions.Clean); MemoryHandle bufferHandle = bufferOwner.Memory.Pin(); - return new OwnedVp8LHistogram(bufferOwner, ref bufferHandle, (uint*)bufferHandle.Pointer, paletteCodeBits); + return new(bufferOwner, ref bufferHandle, (uint*)bufferHandle.Pointer, paletteCodeBits); } /// diff --git a/src/ImageSharp/Formats/Webp/Lossless/Vp8LHistogramSet.cs b/src/ImageSharp/Formats/Webp/Lossless/Vp8LHistogramSet.cs index a46838ee67..68b52f22bf 100644 --- a/src/ImageSharp/Formats/Webp/Lossless/Vp8LHistogramSet.cs +++ b/src/ImageSharp/Formats/Webp/Lossless/Vp8LHistogramSet.cs @@ -25,7 +25,7 @@ public Vp8LHistogramSet(MemoryAllocator memoryAllocator, int capacity, int cache unsafe { uint* basePointer = (uint*)this.bufferHandle.Pointer; - this.items = new List(capacity); + this.items = new(capacity); for (int i = 0; i < capacity; i++) { this.items.Add(new MemberVp8LHistogram(basePointer + (Vp8LHistogram.BufferSize * i), cacheBits)); @@ -41,7 +41,7 @@ public Vp8LHistogramSet(MemoryAllocator memoryAllocator, Vp8LBackwardRefs refs, unsafe { uint* basePointer = (uint*)this.bufferHandle.Pointer; - this.items = new List(capacity); + this.items = new(capacity); for (int i = 0; i < capacity; i++) { this.items.Add(new MemberVp8LHistogram(basePointer + (Vp8LHistogram.BufferSize * i), refs, cacheBits)); diff --git a/src/ImageSharp/Formats/Webp/Lossless/WebpLosslessDecoder.cs b/src/ImageSharp/Formats/Webp/Lossless/WebpLosslessDecoder.cs index e4c2a7ddf6..16284d4b71 100644 --- a/src/ImageSharp/Formats/Webp/Lossless/WebpLosslessDecoder.cs +++ b/src/ImageSharp/Formats/Webp/Lossless/WebpLosslessDecoder.cs @@ -49,7 +49,7 @@ internal sealed class WebpLosslessDecoder private const int FixedTableSize = (630 * 3) + 410; private static readonly int[] TableSize = - { + [ FixedTableSize + 654, FixedTableSize + 656, FixedTableSize + 658, @@ -62,7 +62,7 @@ internal sealed class WebpLosslessDecoder FixedTableSize + 1168, FixedTableSize + 1680, FixedTableSize + 2704 - }; + ]; private static readonly int NumCodeLengthCodes = CodeLengthCodeOrder.Length; @@ -80,10 +80,11 @@ public WebpLosslessDecoder(Vp8LBitReader bitReader, MemoryAllocator memoryAlloca } // This uses C#'s compiler optimization to refer to assembly's static data directly. - private static ReadOnlySpan CodeLengthCodeOrder => new byte[] { 17, 18, 0, 1, 2, 3, 4, 5, 16, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 }; + private static ReadOnlySpan CodeLengthCodeOrder => [17, 18, 0, 1, 2, 3, 4, 5, 16, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 + ]; // This uses C#'s compiler optimization to refer to assembly's static data directly. - private static ReadOnlySpan LiteralMap => new byte[] { 0, 1, 1, 1, 0 }; + private static ReadOnlySpan LiteralMap => [0, 1, 1, 1, 0]; /// /// Decodes the lossless webp image from the stream. @@ -108,7 +109,7 @@ public IMemoryOwner DecodeImageStream(Vp8LDecoder decoder, int xSize, int int numberOfTransformsPresent = 0; if (isLevel0) { - decoder.Transforms = new List(WebpConstants.MaxNumberOfTransforms); + decoder.Transforms = new(WebpConstants.MaxNumberOfTransforms); // Next bit indicates, if a transformation is present. while (this.bitReader.ReadBit()) @@ -129,7 +130,7 @@ public IMemoryOwner DecodeImageStream(Vp8LDecoder decoder, int xSize, int } else { - decoder.Metadata = new Vp8LMetadata(); + decoder.Metadata = new(); } // Color cache. @@ -156,7 +157,7 @@ public IMemoryOwner DecodeImageStream(Vp8LDecoder decoder, int xSize, int // Finish setting up the color-cache. if (isColorCachePresent) { - decoder.Metadata.ColorCache = new ColorCache(colorCacheBits); + decoder.Metadata.ColorCache = new(colorCacheBits); colorCacheSize = 1 << colorCacheBits; decoder.Metadata.ColorCacheSize = colorCacheSize; } @@ -416,7 +417,7 @@ private void ReadHuffmanCodes(Vp8LDecoder decoder, int xSize, int ySize, int col int[] codeLengths = new int[maxAlphabetSize]; for (int i = 0; i < numHTreeGroupsMax; i++) { - hTreeGroups[i] = new HTreeGroup(HuffmanUtils.HuffmanPackedTableSize); + hTreeGroups[i] = new(HuffmanUtils.HuffmanPackedTableSize); HTreeGroup hTreeGroup = hTreeGroups[i]; int totalSize = 0; bool isTrivialLiteral = true; diff --git a/src/ImageSharp/Formats/Webp/Lossy/LossyUtils.cs b/src/ImageSharp/Formats/Webp/Lossy/LossyUtils.cs index aae4181ce0..67a921a37c 100644 --- a/src/ImageSharp/Formats/Webp/Lossy/LossyUtils.cs +++ b/src/ImageSharp/Formats/Webp/Lossy/LossyUtils.cs @@ -66,16 +66,16 @@ public static int Vp8_Sse4x4(Span a, Span b) // Load values. ref byte aRef = ref MemoryMarshal.GetReference(a); ref byte bRef = ref MemoryMarshal.GetReference(b); - var a0 = Vector256.Create( + Vector256 a0 = Vector256.Create( Unsafe.As>(ref aRef), Unsafe.As>(ref Unsafe.Add(ref aRef, WebpConstants.Bps))); - var a1 = Vector256.Create( + Vector256 a1 = Vector256.Create( Unsafe.As>(ref Unsafe.Add(ref aRef, WebpConstants.Bps * 2)), Unsafe.As>(ref Unsafe.Add(ref aRef, WebpConstants.Bps * 3))); - var b0 = Vector256.Create( + Vector256 b0 = Vector256.Create( Unsafe.As>(ref bRef), Unsafe.As>(ref Unsafe.Add(ref bRef, WebpConstants.Bps))); - var b1 = Vector256.Create( + Vector256 b1 = Vector256.Create( Unsafe.As>(ref Unsafe.Add(ref bRef, WebpConstants.Bps * 2)), Unsafe.As>(ref Unsafe.Add(ref bRef, WebpConstants.Bps * 3))); @@ -192,16 +192,16 @@ private static int Vp8_Sse16xN_Avx2(Span a, Span b, int numPairs) for (int i = 0; i < numPairs; i++) { // Load values. - var a0 = Vector256.Create( + Vector256 a0 = Vector256.Create( Unsafe.As>(ref Unsafe.Add(ref aRef, offset)), Unsafe.As>(ref Unsafe.Add(ref aRef, offset + WebpConstants.Bps))); - var b0 = Vector256.Create( + Vector256 b0 = Vector256.Create( Unsafe.As>(ref Unsafe.Add(ref bRef, offset)), Unsafe.As>(ref Unsafe.Add(ref bRef, offset + WebpConstants.Bps))); - var a1 = Vector256.Create( + Vector256 a1 = Vector256.Create( Unsafe.As>(ref Unsafe.Add(ref aRef, offset + (2 * WebpConstants.Bps))), Unsafe.As>(ref Unsafe.Add(ref aRef, offset + (3 * WebpConstants.Bps)))); - var b1 = Vector256.Create( + Vector256 b1 = Vector256.Create( Unsafe.As>(ref Unsafe.Add(ref bRef, offset + (2 * WebpConstants.Bps))), Unsafe.As>(ref Unsafe.Add(ref bRef, offset + (3 * WebpConstants.Bps)))); @@ -1057,19 +1057,19 @@ public static void TransformTwo(Span src, Span dst, Span scrat // Load and concatenate the transform coefficients (we'll do two transforms // in parallel). ref short srcRef = ref MemoryMarshal.GetReference(src); - var in0 = Vector128.Create(Unsafe.As(ref srcRef), 0); - var in1 = Vector128.Create(Unsafe.As(ref Unsafe.Add(ref srcRef, 4)), 0); - var in2 = Vector128.Create(Unsafe.As(ref Unsafe.Add(ref srcRef, 8)), 0); - var in3 = Vector128.Create(Unsafe.As(ref Unsafe.Add(ref srcRef, 12)), 0); + Vector128 in0 = Vector128.Create(Unsafe.As(ref srcRef), 0); + Vector128 in1 = Vector128.Create(Unsafe.As(ref Unsafe.Add(ref srcRef, 4)), 0); + Vector128 in2 = Vector128.Create(Unsafe.As(ref Unsafe.Add(ref srcRef, 8)), 0); + Vector128 in3 = Vector128.Create(Unsafe.As(ref Unsafe.Add(ref srcRef, 12)), 0); // a00 a10 a20 a30 x x x x // a01 a11 a21 a31 x x x x // a02 a12 a22 a32 x x x x // a03 a13 a23 a33 x x x x - var inb0 = Vector128.Create(Unsafe.As(ref Unsafe.Add(ref srcRef, 16)), 0); - var inb1 = Vector128.Create(Unsafe.As(ref Unsafe.Add(ref srcRef, 20)), 0); - var inb2 = Vector128.Create(Unsafe.As(ref Unsafe.Add(ref srcRef, 24)), 0); - var inb3 = Vector128.Create(Unsafe.As(ref Unsafe.Add(ref srcRef, 28)), 0); + Vector128 inb0 = Vector128.Create(Unsafe.As(ref Unsafe.Add(ref srcRef, 16)), 0); + Vector128 inb1 = Vector128.Create(Unsafe.As(ref Unsafe.Add(ref srcRef, 20)), 0); + Vector128 inb2 = Vector128.Create(Unsafe.As(ref Unsafe.Add(ref srcRef, 24)), 0); + Vector128 inb3 = Vector128.Create(Unsafe.As(ref Unsafe.Add(ref srcRef, 28)), 0); in0 = Sse2.UnpackLow(in0, inb0); in1 = Sse2.UnpackLow(in1, inb1); @@ -1086,8 +1086,8 @@ public static void TransformTwo(Span src, Span dst, Span scrat Vector128 a = Sse2.Add(in0.AsInt16(), in2.AsInt16()); Vector128 b = Sse2.Subtract(in0.AsInt16(), in2.AsInt16()); - var k1 = Vector128.Create((short)20091); - var k2 = Vector128.Create((short)-30068); + Vector128 k1 = Vector128.Create((short)20091); + Vector128 k2 = Vector128.Create((short)-30068); // c = MUL(in1, K2) - MUL(in3, K1) = MUL(in1, k2) - MUL(in3, k1) + in1 - in3 Vector128 c1 = Sse2.MultiplyHigh(in1.AsInt16(), k2); @@ -1193,10 +1193,10 @@ public static void TransformOne(Span src, Span dst, Span scrat { // Load and concatenate the transform coefficients. ref short srcRef = ref MemoryMarshal.GetReference(src); - var in0 = Vector128.Create(Unsafe.As(ref srcRef), 0); - var in1 = Vector128.Create(Unsafe.As(ref Unsafe.Add(ref srcRef, 4)), 0); - var in2 = Vector128.Create(Unsafe.As(ref Unsafe.Add(ref srcRef, 8)), 0); - var in3 = Vector128.Create(Unsafe.As(ref Unsafe.Add(ref srcRef, 12)), 0); + Vector128 in0 = Vector128.Create(Unsafe.As(ref srcRef), 0); + Vector128 in1 = Vector128.Create(Unsafe.As(ref Unsafe.Add(ref srcRef, 4)), 0); + Vector128 in2 = Vector128.Create(Unsafe.As(ref Unsafe.Add(ref srcRef, 8)), 0); + Vector128 in3 = Vector128.Create(Unsafe.As(ref Unsafe.Add(ref srcRef, 12)), 0); // a00 a10 a20 a30 x x x x // a01 a11 a21 a31 x x x x @@ -1208,8 +1208,8 @@ public static void TransformOne(Span src, Span dst, Span scrat Vector128 a = Sse2.Add(in0.AsInt16(), in2.AsInt16()); Vector128 b = Sse2.Subtract(in0.AsInt16(), in2.AsInt16()); - var k1 = Vector128.Create((short)20091); - var k2 = Vector128.Create((short)-30068); + Vector128 k1 = Vector128.Create((short)20091); + Vector128 k2 = Vector128.Create((short)-30068); // c = MUL(in1, K2) - MUL(in3, K1) = MUL(in1, k2) - MUL(in3, k1) + in1 - in3 Vector128 c1 = Sse2.MultiplyHigh(in1.AsInt16(), k2); @@ -2017,7 +2017,7 @@ private static void DoFilter2(Span p, int offset, int step) // Applies filter on 2 pixels (p0 and q0) private static void DoFilter2Sse2(ref Vector128 p1, ref Vector128 p0, ref Vector128 q0, ref Vector128 q1, int thresh) { - var signBit = Vector128.Create((byte)0x80); + Vector128 signBit = Vector128.Create((byte)0x80); // Convert p1/q1 to byte (for GetBaseDelta). Vector128 p1s = Sse2.Xor(p1, signBit); @@ -2046,7 +2046,7 @@ private static void DoFilter4Sse2(ref Vector128 p1, ref Vector128 p0 // Compute hev mask. Vector128 notHev = GetNotHev(ref p1, ref p0, ref q0, ref q1, tresh); - var signBit = Vector128.Create((byte)0x80); + Vector128 signBit = Vector128.Create((byte)0x80); // Convert to signed values. p1 = Sse2.Xor(p1, signBit); @@ -2090,7 +2090,7 @@ private static void DoFilter6Sse2(ref Vector128 p2, ref Vector128 p1 Vector128 notHev = GetNotHev(ref p1, ref p0, ref q0, ref q1, tresh); // Convert to signed values. - var signBit = Vector128.Create((byte)0x80); + Vector128 signBit = Vector128.Create((byte)0x80); p1 = Sse2.Xor(p1, signBit); p0 = Sse2.Xor(p0, signBit); q0 = Sse2.Xor(q0, signBit); @@ -2111,11 +2111,11 @@ private static void DoFilter6Sse2(ref Vector128 p2, ref Vector128 p1 Vector128 flow = Sse2.UnpackLow(Vector128.Zero, f); Vector128 fhigh = Sse2.UnpackHigh(Vector128.Zero, f); - var nine = Vector128.Create((short)0x0900); + Vector128 nine = Vector128.Create((short)0x0900); Vector128 f9Low = Sse2.MultiplyHigh(flow.AsInt16(), nine); // Filter (lo) * 9 Vector128 f9High = Sse2.MultiplyHigh(fhigh.AsInt16(), nine); // Filter (hi) * 9 - var sixtyThree = Vector128.Create((short)63); + Vector128 sixtyThree = Vector128.Create((short)63); Vector128 a2Low = Sse2.Add(f9Low, sixtyThree); // Filter * 9 + 63 Vector128 a2High = Sse2.Add(f9High, sixtyThree); // Filter * 9 + 63 @@ -2146,7 +2146,7 @@ private static Vector128 GetNotHev(ref Vector128 p1, ref Vector128 t1 = Abs(p1, p0); Vector128 t2 = Abs(q1, q0); - var h = Vector128.Create((byte)hevThresh); + Vector128 h = Vector128.Create((byte)hevThresh); Vector128 tMax = Sse2.Max(t1, t2); Vector128 tMaxH = Sse2.SubtractSaturate(tMax, h); @@ -2235,9 +2235,9 @@ private static bool NeedsFilter2(Span p, int offset, int step, int t, int private static Vector128 NeedsFilter(Vector128 p1, Vector128 p0, Vector128 q0, Vector128 q1, int thresh) { - var mthresh = Vector128.Create((byte)thresh); + Vector128 mthresh = Vector128.Create((byte)thresh); Vector128 t1 = Abs(p1, q1); // abs(p1 - q1) - var fe = Vector128.Create((byte)0xFE); + Vector128 fe = Vector128.Create((byte)0xFE); Vector128 t2 = Sse2.And(t1, fe); // set lsb of each byte to zero. Vector128 t3 = Sse2.ShiftRightLogical(t2.AsInt16(), 1); // abs(p1 - q1) / 2 @@ -2383,7 +2383,7 @@ private static Vector128 SignedShift8b(Vector128 x) [MethodImpl(InliningOptions.ShortMethod)] private static void ComplexMask(Vector128 p1, Vector128 p0, Vector128 q0, Vector128 q1, int thresh, int ithresh, ref Vector128 mask) { - var it = Vector128.Create((byte)ithresh); + Vector128 it = Vector128.Create((byte)ithresh); Vector128 diff = Sse2.SubtractSaturate(mask, it); Vector128 threshMask = Sse2.CompareEqual(diff, Vector128.Zero); Vector128 filterMask = NeedsFilter(p1, p0, q0, q1, thresh); @@ -2397,7 +2397,7 @@ private static void ComplexMask(Vector128 p1, Vector128 p0, Vector12 // Pixels 'pi' and 'qi' are int8_t on input, uint8_t on output (sign flip). private static void Update2Pixels(ref Vector128 pi, ref Vector128 qi, Vector128 a0Low, Vector128 a0High) { - var signBit = Vector128.Create((byte)0x80); + Vector128 signBit = Vector128.Create((byte)0x80); Vector128 a1Low = Sse2.ShiftRightArithmetic(a0Low, 7); Vector128 a1High = Sse2.ShiftRightArithmetic(a0High, 7); Vector128 delta = Sse2.PackSignedSaturate(a1Low, a1High); @@ -2410,8 +2410,8 @@ private static void Update2Pixels(ref Vector128 pi, ref Vector128 qi [MethodImpl(InliningOptions.ShortMethod)] private static Vector128 LoadUvEdge(ref byte uRef, ref byte vRef, int offset) { - var uVec = Vector128.Create(Unsafe.As(ref Unsafe.Add(ref uRef, (uint)offset)), 0); - var vVec = Vector128.Create(Unsafe.As(ref Unsafe.Add(ref vRef, (uint)offset)), 0); + Vector128 uVec = Vector128.Create(Unsafe.As(ref Unsafe.Add(ref uRef, (uint)offset)), 0); + Vector128 vVec = Vector128.Create(Unsafe.As(ref Unsafe.Add(ref vRef, (uint)offset)), 0); return Sse2.UnpackLow(uVec, vVec).AsByte(); } diff --git a/src/ImageSharp/Formats/Webp/Lossy/QuantEnc.cs b/src/ImageSharp/Formats/Webp/Lossy/QuantEnc.cs index e9eb1110b0..ab83e1641c 100644 --- a/src/ImageSharp/Formats/Webp/Lossy/QuantEnc.cs +++ b/src/ImageSharp/Formats/Webp/Lossy/QuantEnc.cs @@ -14,7 +14,7 @@ namespace SixLabors.ImageSharp.Formats.Webp.Lossy; /// internal static unsafe class QuantEnc { - private static readonly ushort[] WeightY = { 38, 32, 20, 9, 32, 28, 17, 7, 20, 17, 10, 4, 9, 7, 4, 2 }; + private static readonly ushort[] WeightY = [38, 32, 20, 9, 32, 28, 17, 7, 20, 17, 10, 4, 9, 7, 4, 2]; private const int MaxLevel = 2047; @@ -26,7 +26,7 @@ internal static unsafe class QuantEnc private const int DSCALE = 1; // storage descaling, needed to make the error fit byte // This uses C#'s optimization to refer to the static data segment of the assembly, no allocation occurs. - private static ReadOnlySpan Zigzag => new byte[] { 0, 1, 4, 8, 5, 2, 3, 6, 9, 12, 13, 10, 7, 11, 14, 15 }; + private static ReadOnlySpan Zigzag => [0, 1, 4, 8, 5, 2, 3, 6, 9, 12, 13, 10, 7, 11, 14, 15]; public static void PickBestIntra16(Vp8EncIterator it, ref Vp8ModeScore rd, Vp8SegmentInfo[] segmentInfos, Vp8EncProba proba) { @@ -36,8 +36,8 @@ public static void PickBestIntra16(Vp8EncIterator it, ref Vp8ModeScore rd, Vp8Se int tlambda = dqm.TLambda; Span src = it.YuvIn.AsSpan(Vp8EncIterator.YOffEnc); Span scratch = it.Scratch3; - var rdTmp = new Vp8ModeScore(); - var res = new Vp8Residual(); + Vp8ModeScore rdTmp = new(); + Vp8Residual res = new(); Vp8ModeScore rdCur = rdTmp; Vp8ModeScore rdBest = rd; int mode; @@ -107,7 +107,7 @@ public static bool PickBestIntra4(Vp8EncIterator it, ref Vp8ModeScore rd, Vp8Seg Span bestBlocks = it.YuvOut2.AsSpan(Vp8EncIterator.YOffEnc); Span scratch = it.Scratch3; int totalHeaderBits = 0; - var rdBest = new Vp8ModeScore(); + Vp8ModeScore rdBest = new(); if (maxI4HeaderBits == 0) { @@ -118,9 +118,9 @@ public static bool PickBestIntra4(Vp8EncIterator it, ref Vp8ModeScore rd, Vp8Seg rdBest.H = 211; // '211' is the value of VP8BitCost(0, 145) rdBest.SetRdScore(dqm.LambdaMode); it.StartI4(); - var rdi4 = new Vp8ModeScore(); - var rdTmp = new Vp8ModeScore(); - var res = new Vp8Residual(); + Vp8ModeScore rdi4 = new(); + Vp8ModeScore rdTmp = new(); + Vp8Residual res = new(); Span tmpLevels = stackalloc short[16]; do { @@ -220,9 +220,9 @@ public static void PickBestUv(Vp8EncIterator it, ref Vp8ModeScore rd, Vp8Segment Span tmpDst = it.YuvOut2.AsSpan(Vp8EncIterator.UOffEnc); Span dst0 = it.YuvOut.AsSpan(Vp8EncIterator.UOffEnc); Span dst = dst0; - var rdBest = new Vp8ModeScore(); - var rdUv = new Vp8ModeScore(); - var res = new Vp8Residual(); + Vp8ModeScore rdBest = new(); + Vp8ModeScore rdUv = new(); + Vp8Residual res = new(); int mode; rd.ModeUv = -1; @@ -628,7 +628,7 @@ public static int QuantizeBlock(Span input, Span output, ref Vp8Ma Vector128 out8 = Sse2.PackSignedSaturate(out08.AsInt32(), out12.AsInt32()); // if (coeff > 2047) coeff = 2047 - var maxCoeff2047 = Vector128.Create((short)MaxLevel); + Vector128 maxCoeff2047 = Vector128.Create((short)MaxLevel); out0 = Sse2.Min(out0, maxCoeff2047); out8 = Sse2.Min(out8, maxCoeff2047); diff --git a/src/ImageSharp/Formats/Webp/Lossy/Vp8BandProbas.cs b/src/ImageSharp/Formats/Webp/Lossy/Vp8BandProbas.cs index 90506efb81..0c25fb4e47 100644 --- a/src/ImageSharp/Formats/Webp/Lossy/Vp8BandProbas.cs +++ b/src/ImageSharp/Formats/Webp/Lossy/Vp8BandProbas.cs @@ -16,7 +16,7 @@ public Vp8BandProbas() this.Probabilities = new Vp8ProbaArray[WebpConstants.NumCtx]; for (int i = 0; i < WebpConstants.NumCtx; i++) { - this.Probabilities[i] = new Vp8ProbaArray(); + this.Probabilities[i] = new(); } } diff --git a/src/ImageSharp/Formats/Webp/Lossy/Vp8Costs.cs b/src/ImageSharp/Formats/Webp/Lossy/Vp8Costs.cs index eee22159e1..a0fe034864 100644 --- a/src/ImageSharp/Formats/Webp/Lossy/Vp8Costs.cs +++ b/src/ImageSharp/Formats/Webp/Lossy/Vp8Costs.cs @@ -13,7 +13,7 @@ public Vp8Costs() this.Costs = new Vp8CostArray[WebpConstants.NumCtx]; for (int i = 0; i < WebpConstants.NumCtx; i++) { - this.Costs[i] = new Vp8CostArray(); + this.Costs[i] = new(); } } diff --git a/src/ImageSharp/Formats/Webp/Lossy/Vp8Decoder.cs b/src/ImageSharp/Formats/Webp/Lossy/Vp8Decoder.cs index b3c5bfaf41..f45b1034eb 100644 --- a/src/ImageSharp/Formats/Webp/Lossy/Vp8Decoder.cs +++ b/src/ImageSharp/Formats/Webp/Lossy/Vp8Decoder.cs @@ -25,7 +25,7 @@ internal class Vp8Decoder : IDisposable /// Used for allocating memory for the pixel data output and the temporary buffers. public Vp8Decoder(Vp8FrameHeader frameHeader, Vp8PictureHeader pictureHeader, Vp8SegmentHeader segmentHeader, Vp8Proba probabilities, MemoryAllocator memoryAllocator) { - this.FilterHeader = new Vp8FilterHeader(); + this.FilterHeader = new(); this.FrameHeader = frameHeader; this.PictureHeader = pictureHeader; this.SegmentHeader = segmentHeader; @@ -41,22 +41,22 @@ public Vp8Decoder(Vp8FrameHeader frameHeader, Vp8PictureHeader pictureHeader, Vp this.FilterInfo = new Vp8FilterInfo[this.MbWidth]; for (int i = 0; i < this.MbWidth; i++) { - this.MacroBlockInfo[i] = new Vp8MacroBlock(); - this.MacroBlockData[i] = new Vp8MacroBlockData(); - this.YuvTopSamples[i] = new Vp8TopSamples(); - this.FilterInfo[i] = new Vp8FilterInfo(); + this.MacroBlockInfo[i] = new(); + this.MacroBlockData[i] = new(); + this.YuvTopSamples[i] = new(); + this.FilterInfo[i] = new(); } - this.MacroBlockInfo[this.MbWidth] = new Vp8MacroBlock(); + this.MacroBlockInfo[this.MbWidth] = new(); this.DeQuantMatrices = new Vp8QuantMatrix[WebpConstants.NumMbSegments]; this.FilterStrength = new Vp8FilterInfo[WebpConstants.NumMbSegments, 2]; for (int i = 0; i < WebpConstants.NumMbSegments; i++) { - this.DeQuantMatrices[i] = new Vp8QuantMatrix(); + this.DeQuantMatrices[i] = new(); for (int j = 0; j < 2; j++) { - this.FilterStrength[i, j] = new Vp8FilterInfo(); + this.FilterStrength[i, j] = new(); } } @@ -245,7 +245,7 @@ public Vp8Decoder(Vp8FrameHeader frameHeader, Vp8PictureHeader pictureHeader, Vp public Vp8MacroBlock CurrentMacroBlock => this.MacroBlockInfo[this.MbX]; - public Vp8MacroBlock LeftMacroBlock => this.leftMacroBlock ??= new Vp8MacroBlock(); + public Vp8MacroBlock LeftMacroBlock => this.leftMacroBlock ??= new(); public Vp8MacroBlockData CurrentBlockData => this.MacroBlockData[this.MbX]; diff --git a/src/ImageSharp/Formats/Webp/Lossy/Vp8EncIterator.cs b/src/ImageSharp/Formats/Webp/Lossy/Vp8EncIterator.cs index 52c7e9703b..3f49b3c0d9 100644 --- a/src/ImageSharp/Formats/Webp/Lossy/Vp8EncIterator.cs +++ b/src/ImageSharp/Formats/Webp/Lossy/Vp8EncIterator.cs @@ -36,12 +36,12 @@ internal class Vp8EncIterator /// Array to record the position of the top sample to pass to the prediction functions. /// private readonly byte[] vp8TopLeftI4 = - { + [ 17, 21, 25, 29, 13, 17, 21, 25, 9, 13, 17, 21, 5, 9, 13, 17 - }; + ]; private int currentMbIdx; @@ -396,7 +396,7 @@ public int MbAnalyzeBestIntra16Mode() this.MakeLuma16Preds(); for (mode = 0; mode < maxMode; mode++) { - Vp8Histogram histo = new Vp8Histogram(); + Vp8Histogram histo = new(); histo.CollectHistogram(this.YuvIn.AsSpan(YOffEnc), this.YuvP.AsSpan(Vp8Encoding.Vp8I16ModeOffsets[mode]), 0, 16); int alpha = histo.GetAlpha(); if (alpha > bestAlpha) @@ -414,7 +414,7 @@ public int MbAnalyzeBestIntra4Mode(int bestAlpha) { Span modes = stackalloc byte[16]; const int maxMode = MaxIntra4Mode; - Vp8Histogram totalHisto = new Vp8Histogram(); + Vp8Histogram totalHisto = new(); int curHisto = 0; this.StartI4(); do @@ -427,7 +427,7 @@ public int MbAnalyzeBestIntra4Mode(int bestAlpha) this.MakeIntra4Preds(); for (mode = 0; mode < maxMode; ++mode) { - histos[curHisto] = new Vp8Histogram(); + histos[curHisto] = new(); histos[curHisto].CollectHistogram(src, this.YuvP.AsSpan(Vp8Encoding.Vp8I4ModeOffsets[mode]), 0, 1); int alpha = histos[curHisto].GetAlpha(); @@ -467,7 +467,7 @@ public int MbAnalyzeBestUvMode() this.MakeChroma8Preds(); for (mode = 0; mode < maxMode; ++mode) { - Vp8Histogram histo = new Vp8Histogram(); + Vp8Histogram histo = new(); histo.CollectHistogram(this.YuvIn.AsSpan(UOffEnc), this.YuvP.AsSpan(Vp8Encoding.Vp8UvModeOffsets[mode]), 16, 16 + 4 + 4); int alpha = histo.GetAlpha(); if (alpha > bestAlpha) diff --git a/src/ImageSharp/Formats/Webp/Lossy/Vp8EncProba.cs b/src/ImageSharp/Formats/Webp/Lossy/Vp8EncProba.cs index 070e705747..a6faddc04d 100644 --- a/src/ImageSharp/Formats/Webp/Lossy/Vp8EncProba.cs +++ b/src/ImageSharp/Formats/Webp/Lossy/Vp8EncProba.cs @@ -29,7 +29,7 @@ public Vp8EncProba() this.Coeffs[i] = new Vp8BandProbas[WebpConstants.NumBands]; for (int j = 0; j < this.Coeffs[i].Length; j++) { - this.Coeffs[i][j] = new Vp8BandProbas(); + this.Coeffs[i][j] = new(); } } @@ -39,7 +39,7 @@ public Vp8EncProba() this.Stats[i] = new Vp8Stats[WebpConstants.NumBands]; for (int j = 0; j < this.Stats[i].Length; j++) { - this.Stats[i][j] = new Vp8Stats(); + this.Stats[i][j] = new(); } } @@ -49,7 +49,7 @@ public Vp8EncProba() this.LevelCost[i] = new Vp8Costs[WebpConstants.NumBands]; for (int j = 0; j < this.LevelCost[i].Length; j++) { - this.LevelCost[i][j] = new Vp8Costs(); + this.LevelCost[i][j] = new(); } } @@ -59,7 +59,7 @@ public Vp8EncProba() this.RemappedCosts[i] = new Vp8Costs[16]; for (int j = 0; j < this.RemappedCosts[i].Length; j++) { - this.RemappedCosts[i][j] = new Vp8Costs(); + this.RemappedCosts[i][j] = new(); } } diff --git a/src/ImageSharp/Formats/Webp/Lossy/Vp8Encoder.cs b/src/ImageSharp/Formats/Webp/Lossy/Vp8Encoder.cs index 3ad72f7d00..e6c27489fc 100644 --- a/src/ImageSharp/Formats/Webp/Lossy/Vp8Encoder.cs +++ b/src/ImageSharp/Formats/Webp/Lossy/Vp8Encoder.cs @@ -172,19 +172,19 @@ public Vp8Encoder( this.MbInfo = new Vp8MacroBlockInfo[this.Mbw * this.Mbh]; for (int i = 0; i < this.MbInfo.Length; i++) { - this.MbInfo[i] = new Vp8MacroBlockInfo(); + this.MbInfo[i] = new(); } this.SegmentInfos = new Vp8SegmentInfo[4]; for (int i = 0; i < 4; i++) { - this.SegmentInfos[i] = new Vp8SegmentInfo(); + this.SegmentInfos[i] = new(); } - this.FilterHeader = new Vp8FilterHeader(); + this.FilterHeader = new(); int predSize = (((4 * this.Mbw) + 1) * ((4 * this.Mbh) + 1)) + this.PredsWidth + 1; this.PredsWidth = (4 * this.Mbw) + 1; - this.Proba = new Vp8EncProba(); + this.Proba = new(); this.Preds = new byte[predSize + this.PredsWidth + this.Mbw]; // Initialize with default values, which the reference c implementation uses, @@ -196,7 +196,7 @@ public Vp8Encoder( } // This uses C#'s optimization to refer to the static data segment of the assembly, no allocation occurs. - private static ReadOnlySpan AverageBytesPerMb => new byte[] { 50, 24, 16, 9, 7, 5, 3, 2 }; + private static ReadOnlySpan AverageBytesPerMb => [50, 24, 16, 9, 7, 5, 3, 2]; public int BaseQuant { get; set; } @@ -418,14 +418,14 @@ private bool Encode(Stream stream, ImageFrame frame, Rectangle b this.uvAlpha /= totalMb; // Analysis is done, proceed to actual encoding. - this.SegmentHeader = new Vp8EncSegmentHeader(4); + this.SegmentHeader = new(4); this.AssignSegments(alphas); this.SetLoopParams(this.quality); // Initialize the bitwriter. int averageBytesPerMacroBlock = AverageBytesPerMb[this.BaseQuant >> 4]; int expectedSize = this.Mbw * this.Mbh * averageBytesPerMacroBlock; - this.bitWriter = new Vp8BitWriter(expectedSize, this); + this.bitWriter = new(expectedSize, this); // Stats-collection loop. this.StatLoop(width, height, yStride, uvStride); diff --git a/src/ImageSharp/Formats/Webp/Lossy/Vp8Encoding.cs b/src/ImageSharp/Formats/Webp/Lossy/Vp8Encoding.cs index 82f00e8760..d3713b4ce1 100644 --- a/src/ImageSharp/Formats/Webp/Lossy/Vp8Encoding.cs +++ b/src/ImageSharp/Formats/Webp/Lossy/Vp8Encoding.cs @@ -36,9 +36,9 @@ internal static unsafe class Vp8Encoding private const int C8HE8 = C8VE8 + (1 * 16); - public static readonly int[] Vp8I16ModeOffsets = { I16DC16, I16TM16, I16VE16, I16HE16 }; + public static readonly int[] Vp8I16ModeOffsets = [I16DC16, I16TM16, I16VE16, I16HE16]; - public static readonly int[] Vp8UvModeOffsets = { C8DC8, C8TM8, C8VE8, C8HE8 }; + public static readonly int[] Vp8UvModeOffsets = [C8DC8, C8TM8, C8VE8, C8HE8]; private const int I4DC4 = (3 * 16 * WebpConstants.Bps) + 0; @@ -60,7 +60,8 @@ internal static unsafe class Vp8Encoding private const int I4HU4 = I4HD4 + 4; - public static readonly int[] Vp8I4ModeOffsets = { I4DC4, I4TM4, I4VE4, I4HE4, I4RD4, I4VR4, I4LD4, I4VL4, I4HD4, I4HU4 }; + public static readonly int[] Vp8I4ModeOffsets = [I4DC4, I4TM4, I4VE4, I4HE4, I4RD4, I4VR4, I4LD4, I4VL4, I4HD4, I4HU4 + ]; private static byte[] GetClip1() { diff --git a/src/ImageSharp/Formats/Webp/Lossy/Vp8Matrix.cs b/src/ImageSharp/Formats/Webp/Lossy/Vp8Matrix.cs index 7ba15a6d61..22104f1ac8 100644 --- a/src/ImageSharp/Formats/Webp/Lossy/Vp8Matrix.cs +++ b/src/ImageSharp/Formats/Webp/Lossy/Vp8Matrix.cs @@ -6,12 +6,12 @@ namespace SixLabors.ImageSharp.Formats.Webp.Lossy; internal unsafe struct Vp8Matrix { private static readonly int[][] BiasMatrices = - { + [ // [luma-ac,luma-dc,chroma][dc,ac] - new[] { 96, 110 }, - new[] { 96, 108 }, - new[] { 110, 115 } - }; + [96, 110], + [96, 108], + [110, 115] + ]; /// /// Number of descaling bits for sharpening bias. @@ -46,7 +46,7 @@ internal unsafe struct Vp8Matrix // Sharpening by (slightly) raising the hi-frequency coeffs. // Hack-ish but helpful for mid-bitrate range. Use with care. // This uses C#'s optimization to refer to the static data segment of the assembly, no allocation occurs. - private static ReadOnlySpan FreqSharpening => new byte[] { 0, 30, 60, 90, 30, 60, 90, 90, 60, 90, 90, 90, 90, 90, 90, 90 }; + private static ReadOnlySpan FreqSharpening => [0, 30, 60, 90, 30, 60, 90, 90, 60, 90, 90, 90, 90, 90, 90, 90]; /// /// Returns the average quantizer. diff --git a/src/ImageSharp/Formats/Webp/Lossy/Vp8Proba.cs b/src/ImageSharp/Formats/Webp/Lossy/Vp8Proba.cs index 0da6dfcad4..de03f3c93c 100644 --- a/src/ImageSharp/Formats/Webp/Lossy/Vp8Proba.cs +++ b/src/ImageSharp/Formats/Webp/Lossy/Vp8Proba.cs @@ -23,7 +23,7 @@ public Vp8Proba() { for (int j = 0; j < WebpConstants.NumBands; j++) { - this.Bands[i, j] = new Vp8BandProbas(); + this.Bands[i, j] = new(); } } diff --git a/src/ImageSharp/Formats/Webp/Lossy/Vp8Stats.cs b/src/ImageSharp/Formats/Webp/Lossy/Vp8Stats.cs index dda921a7c7..bd335f2985 100644 --- a/src/ImageSharp/Formats/Webp/Lossy/Vp8Stats.cs +++ b/src/ImageSharp/Formats/Webp/Lossy/Vp8Stats.cs @@ -13,7 +13,7 @@ public Vp8Stats() this.Stats = new Vp8StatsArray[WebpConstants.NumCtx]; for (int i = 0; i < WebpConstants.NumCtx; i++) { - this.Stats[i] = new Vp8StatsArray(); + this.Stats[i] = new(); } } diff --git a/src/ImageSharp/Formats/Webp/Lossy/WebpLossyDecoder.cs b/src/ImageSharp/Formats/Webp/Lossy/WebpLossyDecoder.cs index 65d5b65e88..bd87b385c6 100644 --- a/src/ImageSharp/Formats/Webp/Lossy/WebpLossyDecoder.cs +++ b/src/ImageSharp/Formats/Webp/Lossy/WebpLossyDecoder.cs @@ -1173,13 +1173,13 @@ private void ParsePartitions(Vp8Decoder dec) pSize = sizeLeft; } - dec.Vp8BitReaders[p] = new Vp8BitReader(this.bitReader.Data, (uint)pSize, partStart); + dec.Vp8BitReaders[p] = new(this.bitReader.Data, (uint)pSize, partStart); partStart += pSize; sizeLeft -= pSize; sz = sz[3..]; } - dec.Vp8BitReaders[lastPart] = new Vp8BitReader(this.bitReader.Data, (uint)sizeLeft, partStart); + dec.Vp8BitReaders[lastPart] = new(this.bitReader.Data, (uint)sizeLeft, partStart); } private void ParseDequantizationIndices(Vp8Decoder decoder) diff --git a/src/ImageSharp/Formats/Webp/Lossy/YuvConversion.cs b/src/ImageSharp/Formats/Webp/Lossy/YuvConversion.cs index f8e664ed03..8d9d9fa200 100644 --- a/src/ImageSharp/Formats/Webp/Lossy/YuvConversion.cs +++ b/src/ImageSharp/Formats/Webp/Lossy/YuvConversion.cs @@ -708,9 +708,9 @@ private static void ConvertYuv444ToBgrSse41(ref byte y, ref byte u, ref byte v, // R = (19077 * y + 26149 * v - 14234) >> 6 // G = (19077 * y - 6419 * u - 13320 * v + 8708) >> 6 // B = (19077 * y + 33050 * u - 17685) >> 6 - var k19077 = Vector128.Create((ushort)19077); - var k26149 = Vector128.Create((ushort)26149); - var k14234 = Vector128.Create((ushort)14234); + Vector128 k19077 = Vector128.Create((ushort)19077); + Vector128 k26149 = Vector128.Create((ushort)26149); + Vector128 k14234 = Vector128.Create((ushort)14234); Vector128 y1 = Sse2.MultiplyHigh(y0.AsUInt16(), k19077); Vector128 r0 = Sse2.MultiplyHigh(v0.AsUInt16(), k26149); diff --git a/src/ImageSharp/Formats/Webp/WebpAnimationDecoder.cs b/src/ImageSharp/Formats/Webp/WebpAnimationDecoder.cs index 72405e480e..562d28808a 100644 --- a/src/ImageSharp/Formats/Webp/WebpAnimationDecoder.cs +++ b/src/ImageSharp/Formats/Webp/WebpAnimationDecoder.cs @@ -87,7 +87,7 @@ public Image Decode(BufferedReadStream stream, WebpFeatures feat Image? image = null; ImageFrame? previousFrame = null; - this.metadata = new ImageMetadata(); + this.metadata = new(); this.webpMetadata = this.metadata.GetWebpMetadata(); this.webpMetadata.RepeatCount = features.AnimationLoopCount; @@ -178,7 +178,7 @@ private uint ReadFrame(BufferedReadStream stream, ref Image? ima ImageFrame imageFrame; if (previousFrame is null) { - image = new Image(this.configuration, (int)width, (int)height, backgroundColor.ToPixel(), this.metadata); + image = new(this.configuration, (int)width, (int)height, backgroundColor.ToPixel(), this.metadata); SetFrameMetadata(image.Frames.RootFrame.Metadata, frameData); diff --git a/src/ImageSharp/Formats/Webp/WebpChunkParsingUtils.cs b/src/ImageSharp/Formats/Webp/WebpChunkParsingUtils.cs index 4ccaf65031..a4e88e2271 100644 --- a/src/ImageSharp/Formats/Webp/WebpChunkParsingUtils.cs +++ b/src/ImageSharp/Formats/Webp/WebpChunkParsingUtils.cs @@ -358,7 +358,7 @@ public static void ParseOptionalChunks(BufferedReadStream stream, WebpChunkType if (metadata.ExifProfile != null) { - metadata.ExifProfile = new ExifProfile(exifData); + metadata.ExifProfile = new(exifData); } break; @@ -372,7 +372,7 @@ public static void ParseOptionalChunks(BufferedReadStream stream, WebpChunkType if (metadata.XmpProfile != null) { - metadata.XmpProfile = new XmpProfile(xmpData); + metadata.XmpProfile = new(xmpData); } break; diff --git a/src/ImageSharp/Formats/Webp/WebpConstants.cs b/src/ImageSharp/Formats/Webp/WebpConstants.cs index 818c843ea9..f489899c68 100644 --- a/src/ImageSharp/Formats/Webp/WebpConstants.cs +++ b/src/ImageSharp/Formats/Webp/WebpConstants.cs @@ -11,22 +11,22 @@ internal static class WebpConstants /// /// The list of file extensions that equate to Webp. /// - public static readonly IEnumerable FileExtensions = new[] { "webp" }; + public static readonly IEnumerable FileExtensions = ["webp"]; /// /// The list of mimetypes that equate to a jpeg. /// - public static readonly IEnumerable MimeTypes = new[] { "image/webp", }; + public static readonly IEnumerable MimeTypes = ["image/webp"]; /// /// Signature which identifies a VP8 header. /// public static readonly byte[] Vp8HeaderMagicBytes = - { + [ 0x9D, 0x01, 0x2A - }; + ]; /// /// Signature byte which identifies a VP8L header. @@ -37,23 +37,23 @@ internal static class WebpConstants /// The header bytes identifying RIFF file. /// public static readonly byte[] RiffFourCc = - { + [ 0x52, // R 0x49, // I 0x46, // F 0x46 // F - }; + ]; /// /// The header bytes identifying a Webp. /// public static readonly byte[] WebpHeader = - { + [ 0x57, // W 0x45, // E 0x42, // B 0x50 // P - }; + ]; /// /// The header bytes identifying a Webp. @@ -164,16 +164,16 @@ internal static class WebpConstants public const int CodeLengthRepeatCode = 16; - public static readonly int[] CodeLengthExtraBits = { 2, 3, 7 }; + public static readonly int[] CodeLengthExtraBits = [2, 3, 7]; - public static readonly int[] CodeLengthRepeatOffsets = { 3, 3, 11 }; + public static readonly int[] CodeLengthRepeatOffsets = [3, 3, 11]; public static readonly int[] AlphabetSize = - { + [ NumLiteralCodes + NumLengthCodes, NumLiteralCodes, NumLiteralCodes, NumLiteralCodes, NumDistanceCodes - }; + ]; public const int NumMbSegments = 4; @@ -270,9 +270,9 @@ internal static class WebpConstants /// public const int Vp8MaxPartition0Size = 1 << 19; - public static readonly short[] Vp8FixedCostsUv = { 302, 984, 439, 642 }; + public static readonly short[] Vp8FixedCostsUv = [302, 984, 439, 642]; - public static readonly short[] Vp8FixedCostsI16 = { 663, 919, 872, 919 }; + public static readonly short[] Vp8FixedCostsI16 = [663, 919, 872, 919]; /// /// Distortion multiplier (equivalent of lambda). @@ -284,31 +284,31 @@ internal static class WebpConstants /// Simple filter(1): up to 2 luma samples are read and 1 is written. /// Complex filter(2): up to 4 luma samples are read and 3 are written. Same for U/V, so it's 8 samples total (because of the 2x upsampling). /// - public static readonly byte[] FilterExtraRows = { 0, 2, 8 }; + public static readonly byte[] FilterExtraRows = [0, 2, 8]; // Paragraph 9.9 public static readonly int[] Vp8EncBands = - { + [ 0, 1, 2, 3, 6, 4, 5, 6, 6, 6, 6, 6, 6, 6, 6, 7, 0 - }; + ]; public static readonly short[] Scan = - { + [ 0 + (0 * Bps), 4 + (0 * Bps), 8 + (0 * Bps), 12 + (0 * Bps), 0 + (4 * Bps), 4 + (4 * Bps), 8 + (4 * Bps), 12 + (4 * Bps), 0 + (8 * Bps), 4 + (8 * Bps), 8 + (8 * Bps), 12 + (8 * Bps), 0 + (12 * Bps), 4 + (12 * Bps), 8 + (12 * Bps), 12 + (12 * Bps) - }; + ]; // Residual decoding (Paragraph 13.2 / 13.3) - public static readonly byte[] Cat3 = { 173, 148, 140 }; - public static readonly byte[] Cat4 = { 176, 155, 140, 135 }; - public static readonly byte[] Cat5 = { 180, 157, 141, 134, 130 }; - public static readonly byte[] Cat6 = { 254, 254, 243, 230, 196, 177, 153, 140, 133, 130, 129 }; - public static readonly byte[] Zigzag = { 0, 1, 4, 8, 5, 2, 3, 6, 9, 12, 13, 10, 7, 11, 14, 15 }; + public static readonly byte[] Cat3 = [173, 148, 140]; + public static readonly byte[] Cat4 = [176, 155, 140, 135]; + public static readonly byte[] Cat5 = [180, 157, 141, 134, 130]; + public static readonly byte[] Cat6 = [254, 254, 243, 230, 196, 177, 153, 140, 133, 130, 129]; + public static readonly byte[] Zigzag = [0, 1, 4, 8, 5, 2, 3, 6, 9, 12, 13, 10, 7, 11, 14, 15]; public static readonly sbyte[] YModesIntra4 = - { + [ -0, 1, -1, 2, -2, 3, @@ -318,5 +318,5 @@ internal static class WebpConstants -6, 7, -7, 8, -8, -9 - }; + ]; } diff --git a/src/ImageSharp/Formats/Webp/WebpDecoder.cs b/src/ImageSharp/Formats/Webp/WebpDecoder.cs index dfbf4ef0e6..41c5d60f73 100644 --- a/src/ImageSharp/Formats/Webp/WebpDecoder.cs +++ b/src/ImageSharp/Formats/Webp/WebpDecoder.cs @@ -17,7 +17,7 @@ private WebpDecoder() /// /// Gets the shared instance. /// - public static WebpDecoder Instance { get; } = new WebpDecoder(); + public static WebpDecoder Instance { get; } = new(); /// protected override ImageInfo Identify(DecoderOptions options, Stream stream, CancellationToken cancellationToken) @@ -25,7 +25,7 @@ protected override ImageInfo Identify(DecoderOptions options, Stream stream, Can Guard.NotNull(options, nameof(options)); Guard.NotNull(stream, nameof(stream)); - using WebpDecoderCore decoder = new WebpDecoderCore(new WebpDecoderOptions() { GeneralOptions = options }); + using WebpDecoderCore decoder = new(new() { GeneralOptions = options }); return decoder.Identify(options.Configuration, stream, cancellationToken); } @@ -35,7 +35,7 @@ protected override Image Decode(WebpDecoderOptions options, Stre Guard.NotNull(options, nameof(options)); Guard.NotNull(stream, nameof(stream)); - using WebpDecoderCore decoder = new WebpDecoderCore(options); + using WebpDecoderCore decoder = new(options); Image image = decoder.Decode(options.GeneralOptions.Configuration, stream, cancellationToken); ScaleToTargetSize(options.GeneralOptions, image); @@ -52,5 +52,5 @@ protected override Image Decode(DecoderOptions options, Stream stream, Cancellat => this.Decode(options, stream, cancellationToken); /// - protected override WebpDecoderOptions CreateDefaultSpecializedOptions(DecoderOptions options) => new WebpDecoderOptions { GeneralOptions = options }; + protected override WebpDecoderOptions CreateDefaultSpecializedOptions(DecoderOptions options) => new() { GeneralOptions = options }; } diff --git a/src/ImageSharp/Formats/Webp/WebpDecoderCore.cs b/src/ImageSharp/Formats/Webp/WebpDecoderCore.cs index 9ca6e2bee3..5f6f5beca6 100644 --- a/src/ImageSharp/Formats/Webp/WebpDecoderCore.cs +++ b/src/ImageSharp/Formats/Webp/WebpDecoderCore.cs @@ -93,7 +93,7 @@ protected override Image Decode(BufferedReadStream stream, Cance return animationDecoder.Decode(stream, this.webImageInfo.Features, this.webImageInfo.Width, this.webImageInfo.Height, fileSize); } - image = new Image(this.configuration, (int)this.webImageInfo.Width, (int)this.webImageInfo.Height, metadata); + image = new(this.configuration, (int)this.webImageInfo.Width, (int)this.webImageInfo.Height, metadata); Buffer2D pixels = image.GetRootFramePixelBuffer(); if (this.webImageInfo.IsLossless) { @@ -136,8 +136,8 @@ protected override ImageInfo Identify(BufferedReadStream stream, CancellationTok ImageMetadata metadata = new(); using (this.webImageInfo = this.ReadVp8Info(stream, metadata, true)) { - return new ImageInfo( - new Size((int)this.webImageInfo.Width, (int)this.webImageInfo.Height), + return new( + new((int)this.webImageInfo.Width, (int)this.webImageInfo.Height), metadata); } } @@ -229,7 +229,7 @@ private WebpImageInfo ReadVp8Info(BufferedReadStream stream, ImageMetadata metad default: WebpThrowHelper.ThrowImageFormatException("Unrecognized VP8 header"); return - new WebpImageInfo(); // this return will never be reached, because throw helper will throw an exception. + new(); // this return will never be reached, because throw helper will throw an exception. } } @@ -389,7 +389,7 @@ private void ReadXmpProfile(BufferedReadStream stream, ImageMetadata metadata, S return; } - metadata.XmpProfile = new XmpProfile(xmpData); + metadata.XmpProfile = new(xmpData); } } diff --git a/src/ImageSharp/Formats/Webp/WebpDecoderOptions.cs b/src/ImageSharp/Formats/Webp/WebpDecoderOptions.cs index 8840805b1f..6fb15acbb4 100644 --- a/src/ImageSharp/Formats/Webp/WebpDecoderOptions.cs +++ b/src/ImageSharp/Formats/Webp/WebpDecoderOptions.cs @@ -9,7 +9,7 @@ namespace SixLabors.ImageSharp.Formats.Webp; public sealed class WebpDecoderOptions : ISpecializedDecoderOptions { /// - public DecoderOptions GeneralOptions { get; init; } = new DecoderOptions(); + public DecoderOptions GeneralOptions { get; init; } = new(); /// /// Gets the flag to decide how to handle the background color Animation Chunk. diff --git a/src/ImageSharp/Formats/Webp/WebpFormat.cs b/src/ImageSharp/Formats/Webp/WebpFormat.cs index 1764182c51..9853ce7d79 100644 --- a/src/ImageSharp/Formats/Webp/WebpFormat.cs +++ b/src/ImageSharp/Formats/Webp/WebpFormat.cs @@ -15,7 +15,7 @@ private WebpFormat() /// /// Gets the shared instance. /// - public static WebpFormat Instance { get; } = new WebpFormat(); + public static WebpFormat Instance { get; } = new(); /// public string Name => "WEBP"; @@ -30,8 +30,8 @@ private WebpFormat() public IEnumerable FileExtensions => WebpConstants.FileExtensions; /// - public WebpMetadata CreateDefaultFormatMetadata() => new WebpMetadata(); + public WebpMetadata CreateDefaultFormatMetadata() => new(); /// - public WebpFrameMetadata CreateDefaultFormatFrameMetadata() => new WebpFrameMetadata(); + public WebpFrameMetadata CreateDefaultFormatFrameMetadata() => new(); } diff --git a/src/ImageSharp/Formats/Webp/WebpLookupTables.cs b/src/ImageSharp/Formats/Webp/WebpLookupTables.cs index a69bcfd006..11bda24c4f 100644 --- a/src/ImageSharp/Formats/Webp/WebpLookupTables.cs +++ b/src/ImageSharp/Formats/Webp/WebpLookupTables.cs @@ -19,7 +19,7 @@ internal static class WebpLookupTables // Compute susceptibility based on DCT-coeff histograms: // the higher, the "easier" the macroblock is to compress. public static readonly int[] Vp8DspScan = - { + [ // Luma 0 + (0 * WebpConstants.Bps), 4 + (0 * WebpConstants.Bps), 8 + (0 * WebpConstants.Bps), 12 + (0 * WebpConstants.Bps), 0 + (4 * WebpConstants.Bps), 4 + (4 * WebpConstants.Bps), 8 + (4 * WebpConstants.Bps), 12 + (4 * WebpConstants.Bps), @@ -28,22 +28,22 @@ internal static class WebpLookupTables 0 + (0 * WebpConstants.Bps), 4 + (0 * WebpConstants.Bps), 0 + (4 * WebpConstants.Bps), 4 + (4 * WebpConstants.Bps), // U 8 + (0 * WebpConstants.Bps), 12 + (0 * WebpConstants.Bps), 8 + (4 * WebpConstants.Bps), 12 + (4 * WebpConstants.Bps) // V - }; + ]; public static readonly short[] Vp8Scan = - { + [ // Luma 0 + (0 * WebpConstants.Bps), 4 + (0 * WebpConstants.Bps), 8 + (0 * WebpConstants.Bps), 12 + (0 * WebpConstants.Bps), 0 + (4 * WebpConstants.Bps), 4 + (4 * WebpConstants.Bps), 8 + (4 * WebpConstants.Bps), 12 + (4 * WebpConstants.Bps), 0 + (8 * WebpConstants.Bps), 4 + (8 * WebpConstants.Bps), 8 + (8 * WebpConstants.Bps), 12 + (8 * WebpConstants.Bps), - 0 + (12 * WebpConstants.Bps), 4 + (12 * WebpConstants.Bps), 8 + (12 * WebpConstants.Bps), 12 + (12 * WebpConstants.Bps), - }; + 0 + (12 * WebpConstants.Bps), 4 + (12 * WebpConstants.Bps), 8 + (12 * WebpConstants.Bps), 12 + (12 * WebpConstants.Bps) + ]; public static readonly short[] Vp8ScanUv = - { + [ 0 + (0 * WebpConstants.Bps), 4 + (0 * WebpConstants.Bps), 0 + (4 * WebpConstants.Bps), 4 + (4 * WebpConstants.Bps), // U 8 + (0 * WebpConstants.Bps), 12 + (0 * WebpConstants.Bps), 8 + (4 * WebpConstants.Bps), 12 + (4 * WebpConstants.Bps) // V - }; + ]; [MethodImpl(InliningOptions.ShortMethod)] public static byte Abs0(int x) => Abs0Table[x + 255]; @@ -60,7 +60,7 @@ internal static class WebpLookupTables // fixed costs for coding levels, deduce from the coding tree. // This is only the part that doesn't depend on the probability state. public static readonly short[] Vp8LevelFixedCosts = - { + [ 0, 256, 256, 256, 256, 432, 618, 630, 731, 640, 640, 828, 901, 948, 1021, 1101, 1174, 1221, 1294, 1042, 1085, 1115, 1158, 1202, 1245, 1275, 1318, 1337, 1380, 1410, 1453, 1497, 1540, 1570, 1613, 1280, 1295, 1317, 1332, 1358, 1373, 1395, 1410, 1454, 1469, 1491, 1506, 1532, 1547, 1569, 1584, 1601, 1616, 1638, @@ -182,7 +182,7 @@ internal static class WebpLookupTables 7403, 7409, 7429, 7435, 7444, 7450, 7461, 7467, 7476, 7482, 7505, 7511, 7520, 7526, 7537, 7543, 7552, 7558, 7578, 7584, 7593, 7599, 7610, 7616, 7625, 7631, 7656, 7662, 7671, 7677, 7688, 7694, 7703, 7709, 7729, 7735, 7744, 7750, 7761 - }; + ]; // This table gives, for a given sharpness, the filtering strength to be // used (at least) in order to filter a given edge step delta. @@ -239,8 +239,8 @@ internal static class WebpLookupTables }; // This uses C#'s compiler optimization to refer to assembly's static data directly. - public static ReadOnlySpan Norm => new byte[] - { + public static ReadOnlySpan Norm => + [ // renorm_sizes[i] = 8 - log2(i) 7, 6, 6, 5, 5, 5, 5, 4, 4, 4, 4, 4, 4, 4, 4, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, @@ -251,11 +251,11 @@ internal static class WebpLookupTables 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0 - }; + ]; // This uses C#'s compiler optimization to refer to assembly's static data directly. - public static ReadOnlySpan NewRange => new byte[] - { + public static ReadOnlySpan NewRange => + [ // range = ((range + 1) << kVP8Log2Range[range]) - 1 127, 127, 191, 127, 159, 191, 223, 127, 143, 159, 175, 191, 207, 223, 239, 127, 135, 143, 151, 159, 167, 175, 183, 191, 199, 207, 215, 223, 231, 239, @@ -266,10 +266,10 @@ internal static class WebpLookupTables 181, 183, 185, 187, 189, 191, 193, 195, 197, 199, 201, 203, 205, 207, 209, 211, 213, 215, 217, 219, 221, 223, 225, 227, 229, 231, 233, 235, 237, 239, 241, 243, 245, 247, 249, 251, 253, 127 - }; + ]; public static readonly ushort[] Vp8EntropyCost = - { + [ 1792, 1792, 1792, 1536, 1536, 1408, 1366, 1280, 1280, 1216, 1178, 1152, 1110, 1076, 1061, 1024, 1024, 992, 968, 951, 939, 911, 896, 878, 871, 854, 838, 820, 811, 794, @@ -296,35 +296,35 @@ internal static class WebpLookupTables 41, 40, 38, 36, 35, 33, 32, 30, 29, 27, 25, 24, 22, 21, 19, 18, 16, 15, 13, 12, 10, 9, 7, 6, 4, 3 - }; + ]; public static readonly ushort[][] Vp8LevelCodes = - { - new ushort[] { 0x001, 0x000 }, new ushort[] { 0x007, 0x001 }, new ushort[] { 0x00f, 0x005 }, - new ushort[] { 0x00f, 0x00d }, new ushort[] { 0x033, 0x003 }, new ushort[] { 0x033, 0x003 }, new ushort[] { 0x033, 0x023 }, - new ushort[] { 0x033, 0x023 }, new ushort[] { 0x033, 0x023 }, new ushort[] { 0x033, 0x023 }, new ushort[] { 0x0d3, 0x013 }, - new ushort[] { 0x0d3, 0x013 }, new ushort[] { 0x0d3, 0x013 }, new ushort[] { 0x0d3, 0x013 }, new ushort[] { 0x0d3, 0x013 }, - new ushort[] { 0x0d3, 0x013 }, new ushort[] { 0x0d3, 0x013 }, new ushort[] { 0x0d3, 0x013 }, new ushort[] { 0x0d3, 0x093 }, - new ushort[] { 0x0d3, 0x093 }, new ushort[] { 0x0d3, 0x093 }, new ushort[] { 0x0d3, 0x093 }, new ushort[] { 0x0d3, 0x093 }, - new ushort[] { 0x0d3, 0x093 }, new ushort[] { 0x0d3, 0x093 }, new ushort[] { 0x0d3, 0x093 }, new ushort[] { 0x0d3, 0x093 }, - new ushort[] { 0x0d3, 0x093 }, new ushort[] { 0x0d3, 0x093 }, new ushort[] { 0x0d3, 0x093 }, new ushort[] { 0x0d3, 0x093 }, - new ushort[] { 0x0d3, 0x093 }, new ushort[] { 0x0d3, 0x093 }, new ushort[] { 0x0d3, 0x093 }, new ushort[] { 0x153, 0x053 }, - new ushort[] { 0x153, 0x053 }, new ushort[] { 0x153, 0x053 }, new ushort[] { 0x153, 0x053 }, new ushort[] { 0x153, 0x053 }, - new ushort[] { 0x153, 0x053 }, new ushort[] { 0x153, 0x053 }, new ushort[] { 0x153, 0x053 }, new ushort[] { 0x153, 0x053 }, - new ushort[] { 0x153, 0x053 }, new ushort[] { 0x153, 0x053 }, new ushort[] { 0x153, 0x053 }, new ushort[] { 0x153, 0x053 }, - new ushort[] { 0x153, 0x053 }, new ushort[] { 0x153, 0x053 }, new ushort[] { 0x153, 0x053 }, new ushort[] { 0x153, 0x053 }, - new ushort[] { 0x153, 0x053 }, new ushort[] { 0x153, 0x053 }, new ushort[] { 0x153, 0x053 }, new ushort[] { 0x153, 0x053 }, - new ushort[] { 0x153, 0x053 }, new ushort[] { 0x153, 0x053 }, new ushort[] { 0x153, 0x053 }, new ushort[] { 0x153, 0x053 }, - new ushort[] { 0x153, 0x053 }, new ushort[] { 0x153, 0x053 }, new ushort[] { 0x153, 0x053 }, new ushort[] { 0x153, 0x053 }, - new ushort[] { 0x153, 0x053 }, new ushort[] { 0x153, 0x053 }, new ushort[] { 0x153, 0x053 }, new ushort[] { 0x153, 0x153 }, - }; + [ + [0x001, 0x000], [0x007, 0x001], [0x00f, 0x005], + [0x00f, 0x00d], [0x033, 0x003], [0x033, 0x003], [0x033, 0x023], + [0x033, 0x023], [0x033, 0x023], [0x033, 0x023], [0x0d3, 0x013], + [0x0d3, 0x013], [0x0d3, 0x013], [0x0d3, 0x013], [0x0d3, 0x013], + [0x0d3, 0x013], [0x0d3, 0x013], [0x0d3, 0x013], [0x0d3, 0x093], + [0x0d3, 0x093], [0x0d3, 0x093], [0x0d3, 0x093], [0x0d3, 0x093], + [0x0d3, 0x093], [0x0d3, 0x093], [0x0d3, 0x093], [0x0d3, 0x093], + [0x0d3, 0x093], [0x0d3, 0x093], [0x0d3, 0x093], [0x0d3, 0x093], + [0x0d3, 0x093], [0x0d3, 0x093], [0x0d3, 0x093], [0x153, 0x053], + [0x153, 0x053], [0x153, 0x053], [0x153, 0x053], [0x153, 0x053], + [0x153, 0x053], [0x153, 0x053], [0x153, 0x053], [0x153, 0x053], + [0x153, 0x053], [0x153, 0x053], [0x153, 0x053], [0x153, 0x053], + [0x153, 0x053], [0x153, 0x053], [0x153, 0x053], [0x153, 0x053], + [0x153, 0x053], [0x153, 0x053], [0x153, 0x053], [0x153, 0x053], + [0x153, 0x053], [0x153, 0x053], [0x153, 0x053], [0x153, 0x053], + [0x153, 0x053], [0x153, 0x053], [0x153, 0x053], [0x153, 0x053], + [0x153, 0x053], [0x153, 0x053], [0x153, 0x053], [0x153, 0x153] + ]; /// /// Lookup table for small values of log2(int). /// public static readonly float[] Log2Table = - { - 0.0000000000000000f, 0.0000000000000000f, + [ + 0.0000000000000000f, 0.0000000000000000f, 1.0000000000000000f, 1.5849625007211560f, 2.0000000000000000f, 2.3219280948873621f, 2.5849625007211560f, 2.8073549220576041f, @@ -452,11 +452,11 @@ internal static class WebpLookupTables 7.9657842846620869f, 7.9715435539507719f, 7.9772799234999167f, 7.9829935746943103f, 7.9886846867721654f, 7.9943534368588577f - }; + ]; public static readonly float[] SLog2Table = - { - 0.00000000f, 0.00000000f, 2.00000000f, 4.75488750f, + [ + 0.00000000f, 0.00000000f, 2.00000000f, 4.75488750f, 8.00000000f, 11.60964047f, 15.50977500f, 19.65148445f, 24.00000000f, 28.52932501f, 33.21928095f, 38.05374781f, 43.01955001f, 48.10571634f, 53.30296891f, 58.60335893f, @@ -520,10 +520,10 @@ internal static class WebpLookupTables 1935.09991037f, 1944.47629506f, 1953.85856831f, 1963.24670620f, 1972.64068498f, 1982.04048108f, 1991.44607117f, 2000.85743204f, 2010.27454072f, 2019.69737440f, 2029.12591044f, 2038.56012640f - }; + ]; public static readonly int[] CodeToPlane = - { + [ 0x18, 0x07, 0x17, 0x19, 0x28, 0x06, 0x27, 0x29, 0x16, 0x1a, 0x26, 0x2a, 0x38, 0x05, 0x37, 0x39, 0x15, 0x1b, 0x36, 0x3a, 0x25, 0x2b, 0x48, 0x04, 0x47, 0x49, 0x14, 0x1c, 0x35, 0x3b, @@ -536,10 +536,10 @@ internal static class WebpLookupTables 0x31, 0x3f, 0x63, 0x6d, 0x52, 0x5e, 0x00, 0x74, 0x7c, 0x41, 0x4f, 0x10, 0x20, 0x62, 0x6e, 0x30, 0x73, 0x7d, 0x51, 0x5f, 0x40, 0x72, 0x7e, 0x61, 0x6f, 0x50, 0x71, 0x7f, 0x60, 0x70 - }; + ]; public static readonly uint[] PlaneToCodeLut = - { + [ 96, 73, 55, 39, 23, 13, 5, 1, 255, 255, 255, 255, 255, 255, 255, 255, 101, 78, 58, 42, 26, 16, 8, 2, 0, 3, 9, 17, 27, 43, 59, 79, 102, 86, 62, 46, 32, 20, 10, 6, 4, 7, 11, 21, 33, 47, 63, 87, @@ -548,11 +548,11 @@ internal static class WebpLookupTables 115, 108, 94, 76, 64, 50, 44, 40, 34, 41, 45, 51, 65, 77, 95, 109, 118, 113, 103, 92, 80, 68, 60, 56, 54, 57, 61, 69, 81, 93, 104, 114, 119, 116, 111, 106, 97, 88, 84, 74, 72, 75, 85, 89, 98, 107, 112, 117 - }; + ]; // 31 ^ clz(i) - public static ReadOnlySpan LogTable8Bit => new byte[] - { + public static ReadOnlySpan LogTable8Bit => + [ 0, 0, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, @@ -569,12 +569,12 @@ internal static class WebpLookupTables 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7 - }; + ]; // Paragraph 14.1 // This uses C#'s compiler optimization to refer to assembly's static data directly. - public static ReadOnlySpan DcTable => new byte[] - { + public static ReadOnlySpan DcTable => + [ 4, 5, 6, 7, 8, 9, 10, 10, 11, 12, 13, 14, 15, 16, 17, 17, 18, 19, 20, 20, 21, 21, 22, 22, @@ -591,11 +591,11 @@ internal static class WebpLookupTables 104, 106, 108, 110, 112, 114, 116, 118, 122, 124, 126, 128, 130, 132, 134, 136, 138, 140, 143, 145, 148, 151, 154, 157 - }; + ]; // Paragraph 14.1 public static readonly ushort[] AcTable = - { + [ 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, @@ -612,10 +612,10 @@ internal static class WebpLookupTables 181, 185, 189, 193, 197, 201, 205, 209, 213, 217, 221, 225, 229, 234, 239, 245, 249, 254, 259, 264, 269, 274, 279, 284 - }; + ]; public static readonly ushort[] AcTable2 = - { + [ 8, 8, 9, 10, 12, 13, 15, 17, 18, 20, 21, 23, 24, 26, 27, 29, 31, 32, 34, 35, 37, 38, 40, 41, @@ -632,7 +632,7 @@ internal static class WebpLookupTables 280, 286, 292, 299, 305, 311, 317, 323, 330, 336, 342, 348, 354, 362, 370, 379, 385, 393, 401, 409, 416, 424, 432, 440 - }; + ]; // Paragraph 13 public static readonly byte[,,,] CoeffsUpdateProba = @@ -981,7 +981,7 @@ internal static class WebpLookupTables }; public static readonly (int Code, int ExtraBits)[] PrefixEncodeCode = - { + [ (0, 0), (0, 0), (1, 0), (2, 0), (3, 0), (4, 1), (4, 1), (5, 1), (5, 1), (6, 2), (6, 2), (6, 2), (6, 2), (7, 2), (7, 2), (7, 2), (7, 2), (8, 3), (8, 3), (8, 3), (8, 3), (8, 3), (8, 3), (8, 3), @@ -1045,13 +1045,13 @@ public static readonly (int Code, int ExtraBits)[] PrefixEncodeCode = (17, 7), (17, 7), (17, 7), (17, 7), (17, 7), (17, 7), (17, 7), (17, 7), (17, 7), (17, 7), (17, 7), (17, 7), (17, 7), (17, 7), (17, 7), (17, 7), (17, 7), (17, 7), (17, 7), (17, 7), (17, 7), (17, 7), (17, 7), (17, 7), - (17, 7), (17, 7), (17, 7), (17, 7), (17, 7), (17, 7), (17, 7), (17, 7), - }; + (17, 7), (17, 7), (17, 7), (17, 7), (17, 7), (17, 7), (17, 7), (17, 7) + ]; // This uses C#'s compiler optimization to refer to assembly's static data directly. - public static ReadOnlySpan PrefixEncodeExtraBitsValue => new byte[] - { - 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 2, 3, 0, 1, 2, 3, + public static ReadOnlySpan PrefixEncodeExtraBitsValue => + [ + 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 4, 5, 6, 7, 0, 1, 2, 3, 4, 5, 6, 7, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, @@ -1084,7 +1084,7 @@ public static readonly (int Code, int ExtraBits)[] PrefixEncodeCode = 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126 - }; + ]; // Following table is (1 << AlphaFix) / a. The (v * InvAlpha[a]) >> AlphaFix // formula is then equal to v / a in most (99.6%) cases. Note that this table @@ -1094,7 +1094,7 @@ public static readonly (int Code, int ExtraBits)[] PrefixEncodeCode = // with ai in [0..255] and pi in [0..1< Abs0Table => new byte[] - { + private static ReadOnlySpan Abs0Table => + [ 0xff, 0xfe, 0xfd, 0xfc, 0xfb, 0xfa, 0xf9, 0xf8, 0xf7, 0xf6, 0xf5, 0xf4, 0xf3, 0xf2, 0xf1, 0xf0, 0xef, 0xee, 0xed, 0xec, 0xeb, 0xea, 0xe9, 0xe8, 0xe7, 0xe6, 0xe5, 0xe4, 0xe3, 0xe2, 0xe1, 0xe0, 0xdf, 0xde, 0xdd, 0xdc, 0xdb, 0xda, 0xd9, 0xd8, 0xd7, 0xd6, 0xd5, 0xd4, 0xd3, 0xd2, 0xd1, 0xd0, 0xcf, 0xce, 0xcd, @@ -1278,11 +1278,11 @@ static WebpLookupTables() 0xdd, 0xde, 0xdf, 0xe0, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, 0xe8, 0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef, 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff - }; + ]; // This uses C#'s compiler optimization to refer to assembly's static data directly. - private static ReadOnlySpan Clip1Table => new byte[] - { + private static ReadOnlySpan Clip1Table => + [ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, @@ -1329,11 +1329,11 @@ static WebpLookupTables() 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff - }; + ]; // This uses C#'s compiler optimization to refer to assembly's static data directly. - private static ReadOnlySpan Sclip1Table => new sbyte[] - { + private static ReadOnlySpan Sclip1Table => + [ -128, -128, -128, -128, -128, -128, -128, -128, -128, -128, -128, -128, -128, -128, -128, -128, -128, -128, -128, -128, -128, -128, -128, -128, -128, -128, -128, -128, -128, -128, -128, -128, -128, -128, -128, -128, -128, -128, -128, -128, -128, -128, -128, -128, -128, -128, -128, -128, -128, -128, -128, @@ -1441,11 +1441,11 @@ static WebpLookupTables() 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127 - }; + ]; // This uses C#'s compiler optimization to refer to assembly's static data directly. - private static ReadOnlySpan Sclip2Table => new sbyte[] - { + private static ReadOnlySpan Sclip2Table => + [ -16, -16, -16, -16, -16, -16, -16, -16, -16, -16, -16, -16, -16, -16, -16, -16, -16, -16, -16, -16, -16, -16, -16, -16, -16, -16, -16, -16, -16, -16, -16, -16, -16, -16, -16, -16, -16, -16, -16, -16, -16, -16, -16, -16, -16, -16, -16, -16, -16, -16, -16, -16, -16, -16, -16, -16, -16, -16, -16, -16, -16, -16, -16, @@ -1456,214 +1456,214 @@ static WebpLookupTables() 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15 - }; + ]; private static void InitializeModesProbabilities() { // Paragraph 11.5 - ModesProba[0, 0] = new byte[] { 231, 120, 48, 89, 115, 113, 120, 152, 112 }; - ModesProba[0, 1] = new byte[] { 152, 179, 64, 126, 170, 118, 46, 70, 95 }; - ModesProba[0, 2] = new byte[] { 175, 69, 143, 80, 85, 82, 72, 155, 103 }; - ModesProba[0, 3] = new byte[] { 56, 58, 10, 171, 218, 189, 17, 13, 152 }; - ModesProba[0, 4] = new byte[] { 114, 26, 17, 163, 44, 195, 21, 10, 173 }; - ModesProba[0, 5] = new byte[] { 121, 24, 80, 195, 26, 62, 44, 64, 85 }; - ModesProba[0, 6] = new byte[] { 144, 71, 10, 38, 171, 213, 144, 34, 26 }; - ModesProba[0, 7] = new byte[] { 170, 46, 55, 19, 136, 160, 33, 206, 71 }; - ModesProba[0, 8] = new byte[] { 63, 20, 8, 114, 114, 208, 12, 9, 226 }; - ModesProba[0, 9] = new byte[] { 81, 40, 11, 96, 182, 84, 29, 16, 36 }; - ModesProba[1, 0] = new byte[] { 134, 183, 89, 137, 98, 101, 106, 165, 148 }; - ModesProba[1, 1] = new byte[] { 72, 187, 100, 130, 157, 111, 32, 75, 80 }; - ModesProba[1, 2] = new byte[] { 66, 102, 167, 99, 74, 62, 40, 234, 128 }; - ModesProba[1, 3] = new byte[] { 41, 53, 9, 178, 241, 141, 26, 8, 107 }; - ModesProba[1, 4] = new byte[] { 74, 43, 26, 146, 73, 166, 49, 23, 157 }; - ModesProba[1, 5] = new byte[] { 65, 38, 105, 160, 51, 52, 31, 115, 128 }; - ModesProba[1, 6] = new byte[] { 104, 79, 12, 27, 217, 255, 87, 17, 7 }; - ModesProba[1, 7] = new byte[] { 87, 68, 71, 44, 114, 51, 15, 186, 23 }; - ModesProba[1, 8] = new byte[] { 47, 41, 14, 110, 182, 183, 21, 17, 194 }; - ModesProba[1, 9] = new byte[] { 66, 45, 25, 102, 197, 189, 23, 18, 22 }; - ModesProba[2, 0] = new byte[] { 88, 88, 147, 150, 42, 46, 45, 196, 205 }; - ModesProba[2, 1] = new byte[] { 43, 97, 183, 117, 85, 38, 35, 179, 61 }; - ModesProba[2, 2] = new byte[] { 39, 53, 200, 87, 26, 21, 43, 232, 171 }; - ModesProba[2, 3] = new byte[] { 56, 34, 51, 104, 114, 102, 29, 93, 77 }; - ModesProba[2, 4] = new byte[] { 39, 28, 85, 171, 58, 165, 90, 98, 64 }; - ModesProba[2, 5] = new byte[] { 34, 22, 116, 206, 23, 34, 43, 166, 73 }; - ModesProba[2, 6] = new byte[] { 107, 54, 32, 26, 51, 1, 81, 43, 31 }; - ModesProba[2, 7] = new byte[] { 68, 25, 106, 22, 64, 171, 36, 225, 114 }; - ModesProba[2, 8] = new byte[] { 34, 19, 21, 102, 132, 188, 16, 76, 124 }; - ModesProba[2, 9] = new byte[] { 62, 18, 78, 95, 85, 57, 50, 48, 51 }; - ModesProba[3, 0] = new byte[] { 193, 101, 35, 159, 215, 111, 89, 46, 111 }; - ModesProba[3, 1] = new byte[] { 60, 148, 31, 172, 219, 228, 21, 18, 111 }; - ModesProba[3, 2] = new byte[] { 112, 113, 77, 85, 179, 255, 38, 120, 114 }; - ModesProba[3, 3] = new byte[] { 40, 42, 1, 196, 245, 209, 10, 25, 109 }; - ModesProba[3, 4] = new byte[] { 88, 43, 29, 140, 166, 213, 37, 43, 154 }; - ModesProba[3, 5] = new byte[] { 61, 63, 30, 155, 67, 45, 68, 1, 209 }; - ModesProba[3, 6] = new byte[] { 100, 80, 8, 43, 154, 1, 51, 26, 71 }; - ModesProba[3, 7] = new byte[] { 142, 78, 78, 16, 255, 128, 34, 197, 171 }; - ModesProba[3, 8] = new byte[] { 41, 40, 5, 102, 211, 183, 4, 1, 221 }; - ModesProba[3, 9] = new byte[] { 51, 50, 17, 168, 209, 192, 23, 25, 82 }; - ModesProba[4, 0] = new byte[] { 138, 31, 36, 171, 27, 166, 38, 44, 229 }; - ModesProba[4, 1] = new byte[] { 67, 87, 58, 169, 82, 115, 26, 59, 179 }; - ModesProba[4, 2] = new byte[] { 63, 59, 90, 180, 59, 166, 93, 73, 154 }; - ModesProba[4, 3] = new byte[] { 40, 40, 21, 116, 143, 209, 34, 39, 175 }; - ModesProba[4, 4] = new byte[] { 47, 15, 16, 183, 34, 223, 49, 45, 183 }; - ModesProba[4, 5] = new byte[] { 46, 17, 33, 183, 6, 98, 15, 32, 183 }; - ModesProba[4, 6] = new byte[] { 57, 46, 22, 24, 128, 1, 54, 17, 37 }; - ModesProba[4, 7] = new byte[] { 65, 32, 73, 115, 28, 128, 23, 128, 205 }; - ModesProba[4, 8] = new byte[] { 40, 3, 9, 115, 51, 192, 18, 6, 223 }; - ModesProba[4, 9] = new byte[] { 87, 37, 9, 115, 59, 77, 64, 21, 47 }; - ModesProba[5, 0] = new byte[] { 104, 55, 44, 218, 9, 54, 53, 130, 226 }; - ModesProba[5, 1] = new byte[] { 64, 90, 70, 205, 40, 41, 23, 26, 57 }; - ModesProba[5, 2] = new byte[] { 54, 57, 112, 184, 5, 41, 38, 166, 213 }; - ModesProba[5, 3] = new byte[] { 30, 34, 26, 133, 152, 116, 10, 32, 134 }; - ModesProba[5, 4] = new byte[] { 39, 19, 53, 221, 26, 114, 32, 73, 255 }; - ModesProba[5, 5] = new byte[] { 31, 9, 65, 234, 2, 15, 1, 118, 73 }; - ModesProba[5, 6] = new byte[] { 75, 32, 12, 51, 192, 255, 160, 43, 51 }; - ModesProba[5, 7] = new byte[] { 88, 31, 35, 67, 102, 85, 55, 186, 85 }; - ModesProba[5, 8] = new byte[] { 56, 21, 23, 111, 59, 205, 45, 37, 192 }; - ModesProba[5, 9] = new byte[] { 55, 38, 70, 124, 73, 102, 1, 34, 98 }; - ModesProba[6, 0] = new byte[] { 125, 98, 42, 88, 104, 85, 117, 175, 82 }; - ModesProba[6, 1] = new byte[] { 95, 84, 53, 89, 128, 100, 113, 101, 45 }; - ModesProba[6, 2] = new byte[] { 75, 79, 123, 47, 51, 128, 81, 171, 1 }; - ModesProba[6, 3] = new byte[] { 57, 17, 5, 71, 102, 57, 53, 41, 49 }; - ModesProba[6, 4] = new byte[] { 38, 33, 13, 121, 57, 73, 26, 1, 85 }; - ModesProba[6, 5] = new byte[] { 41, 10, 67, 138, 77, 110, 90, 47, 114 }; - ModesProba[6, 6] = new byte[] { 115, 21, 2, 10, 102, 255, 166, 23, 6 }; - ModesProba[6, 7] = new byte[] { 101, 29, 16, 10, 85, 128, 101, 196, 26 }; - ModesProba[6, 8] = new byte[] { 57, 18, 10, 102, 102, 213, 34, 20, 43 }; - ModesProba[6, 9] = new byte[] { 117, 20, 15, 36, 163, 128, 68, 1, 26 }; - ModesProba[7, 0] = new byte[] { 102, 61, 71, 37, 34, 53, 31, 243, 192 }; - ModesProba[7, 1] = new byte[] { 69, 60, 71, 38, 73, 119, 28, 222, 37 }; - ModesProba[7, 2] = new byte[] { 68, 45, 128, 34, 1, 47, 11, 245, 171 }; - ModesProba[7, 3] = new byte[] { 62, 17, 19, 70, 146, 85, 55, 62, 70 }; - ModesProba[7, 4] = new byte[] { 37, 43, 37, 154, 100, 163, 85, 160, 1 }; - ModesProba[7, 5] = new byte[] { 63, 9, 92, 136, 28, 64, 32, 201, 85 }; - ModesProba[7, 6] = new byte[] { 75, 15, 9, 9, 64, 255, 184, 119, 16 }; - ModesProba[7, 7] = new byte[] { 86, 6, 28, 5, 64, 255, 25, 248, 1 }; - ModesProba[7, 8] = new byte[] { 56, 8, 17, 132, 137, 255, 55, 116, 128 }; - ModesProba[7, 9] = new byte[] { 58, 15, 20, 82, 135, 57, 26, 121, 40 }; - ModesProba[8, 0] = new byte[] { 164, 50, 31, 137, 154, 133, 25, 35, 218 }; - ModesProba[8, 1] = new byte[] { 51, 103, 44, 131, 131, 123, 31, 6, 158 }; - ModesProba[8, 2] = new byte[] { 86, 40, 64, 135, 148, 224, 45, 183, 128 }; - ModesProba[8, 3] = new byte[] { 22, 26, 17, 131, 240, 154, 14, 1, 209 }; - ModesProba[8, 4] = new byte[] { 45, 16, 21, 91, 64, 222, 7, 1, 197 }; - ModesProba[8, 5] = new byte[] { 56, 21, 39, 155, 60, 138, 23, 102, 213 }; - ModesProba[8, 6] = new byte[] { 83, 12, 13, 54, 192, 255, 68, 47, 28 }; - ModesProba[8, 7] = new byte[] { 85, 26, 85, 85, 128, 128, 32, 146, 171 }; - ModesProba[8, 8] = new byte[] { 18, 11, 7, 63, 144, 171, 4, 4, 246 }; - ModesProba[8, 9] = new byte[] { 35, 27, 10, 146, 174, 171, 12, 26, 128 }; - ModesProba[9, 0] = new byte[] { 190, 80, 35, 99, 180, 80, 126, 54, 45 }; - ModesProba[9, 1] = new byte[] { 85, 126, 47, 87, 176, 51, 41, 20, 32 }; - ModesProba[9, 2] = new byte[] { 101, 75, 128, 139, 118, 146, 116, 128, 85 }; - ModesProba[9, 3] = new byte[] { 56, 41, 15, 176, 236, 85, 37, 9, 62 }; - ModesProba[9, 4] = new byte[] { 71, 30, 17, 119, 118, 255, 17, 18, 138 }; - ModesProba[9, 5] = new byte[] { 101, 38, 60, 138, 55, 70, 43, 26, 142 }; - ModesProba[9, 6] = new byte[] { 146, 36, 19, 30, 171, 255, 97, 27, 20 }; - ModesProba[9, 7] = new byte[] { 138, 45, 61, 62, 219, 1, 81, 188, 64 }; - ModesProba[9, 8] = new byte[] { 32, 41, 20, 117, 151, 142, 20, 21, 163 }; - ModesProba[9, 9] = new byte[] { 112, 19, 12, 61, 195, 128, 48, 4, 24 }; + ModesProba[0, 0] = [231, 120, 48, 89, 115, 113, 120, 152, 112]; + ModesProba[0, 1] = [152, 179, 64, 126, 170, 118, 46, 70, 95]; + ModesProba[0, 2] = [175, 69, 143, 80, 85, 82, 72, 155, 103]; + ModesProba[0, 3] = [56, 58, 10, 171, 218, 189, 17, 13, 152]; + ModesProba[0, 4] = [114, 26, 17, 163, 44, 195, 21, 10, 173]; + ModesProba[0, 5] = [121, 24, 80, 195, 26, 62, 44, 64, 85]; + ModesProba[0, 6] = [144, 71, 10, 38, 171, 213, 144, 34, 26]; + ModesProba[0, 7] = [170, 46, 55, 19, 136, 160, 33, 206, 71]; + ModesProba[0, 8] = [63, 20, 8, 114, 114, 208, 12, 9, 226]; + ModesProba[0, 9] = [81, 40, 11, 96, 182, 84, 29, 16, 36]; + ModesProba[1, 0] = [134, 183, 89, 137, 98, 101, 106, 165, 148]; + ModesProba[1, 1] = [72, 187, 100, 130, 157, 111, 32, 75, 80]; + ModesProba[1, 2] = [66, 102, 167, 99, 74, 62, 40, 234, 128]; + ModesProba[1, 3] = [41, 53, 9, 178, 241, 141, 26, 8, 107]; + ModesProba[1, 4] = [74, 43, 26, 146, 73, 166, 49, 23, 157]; + ModesProba[1, 5] = [65, 38, 105, 160, 51, 52, 31, 115, 128]; + ModesProba[1, 6] = [104, 79, 12, 27, 217, 255, 87, 17, 7]; + ModesProba[1, 7] = [87, 68, 71, 44, 114, 51, 15, 186, 23]; + ModesProba[1, 8] = [47, 41, 14, 110, 182, 183, 21, 17, 194]; + ModesProba[1, 9] = [66, 45, 25, 102, 197, 189, 23, 18, 22]; + ModesProba[2, 0] = [88, 88, 147, 150, 42, 46, 45, 196, 205]; + ModesProba[2, 1] = [43, 97, 183, 117, 85, 38, 35, 179, 61]; + ModesProba[2, 2] = [39, 53, 200, 87, 26, 21, 43, 232, 171]; + ModesProba[2, 3] = [56, 34, 51, 104, 114, 102, 29, 93, 77]; + ModesProba[2, 4] = [39, 28, 85, 171, 58, 165, 90, 98, 64]; + ModesProba[2, 5] = [34, 22, 116, 206, 23, 34, 43, 166, 73]; + ModesProba[2, 6] = [107, 54, 32, 26, 51, 1, 81, 43, 31]; + ModesProba[2, 7] = [68, 25, 106, 22, 64, 171, 36, 225, 114]; + ModesProba[2, 8] = [34, 19, 21, 102, 132, 188, 16, 76, 124]; + ModesProba[2, 9] = [62, 18, 78, 95, 85, 57, 50, 48, 51]; + ModesProba[3, 0] = [193, 101, 35, 159, 215, 111, 89, 46, 111]; + ModesProba[3, 1] = [60, 148, 31, 172, 219, 228, 21, 18, 111]; + ModesProba[3, 2] = [112, 113, 77, 85, 179, 255, 38, 120, 114]; + ModesProba[3, 3] = [40, 42, 1, 196, 245, 209, 10, 25, 109]; + ModesProba[3, 4] = [88, 43, 29, 140, 166, 213, 37, 43, 154]; + ModesProba[3, 5] = [61, 63, 30, 155, 67, 45, 68, 1, 209]; + ModesProba[3, 6] = [100, 80, 8, 43, 154, 1, 51, 26, 71]; + ModesProba[3, 7] = [142, 78, 78, 16, 255, 128, 34, 197, 171]; + ModesProba[3, 8] = [41, 40, 5, 102, 211, 183, 4, 1, 221]; + ModesProba[3, 9] = [51, 50, 17, 168, 209, 192, 23, 25, 82]; + ModesProba[4, 0] = [138, 31, 36, 171, 27, 166, 38, 44, 229]; + ModesProba[4, 1] = [67, 87, 58, 169, 82, 115, 26, 59, 179]; + ModesProba[4, 2] = [63, 59, 90, 180, 59, 166, 93, 73, 154]; + ModesProba[4, 3] = [40, 40, 21, 116, 143, 209, 34, 39, 175]; + ModesProba[4, 4] = [47, 15, 16, 183, 34, 223, 49, 45, 183]; + ModesProba[4, 5] = [46, 17, 33, 183, 6, 98, 15, 32, 183]; + ModesProba[4, 6] = [57, 46, 22, 24, 128, 1, 54, 17, 37]; + ModesProba[4, 7] = [65, 32, 73, 115, 28, 128, 23, 128, 205]; + ModesProba[4, 8] = [40, 3, 9, 115, 51, 192, 18, 6, 223]; + ModesProba[4, 9] = [87, 37, 9, 115, 59, 77, 64, 21, 47]; + ModesProba[5, 0] = [104, 55, 44, 218, 9, 54, 53, 130, 226]; + ModesProba[5, 1] = [64, 90, 70, 205, 40, 41, 23, 26, 57]; + ModesProba[5, 2] = [54, 57, 112, 184, 5, 41, 38, 166, 213]; + ModesProba[5, 3] = [30, 34, 26, 133, 152, 116, 10, 32, 134]; + ModesProba[5, 4] = [39, 19, 53, 221, 26, 114, 32, 73, 255]; + ModesProba[5, 5] = [31, 9, 65, 234, 2, 15, 1, 118, 73]; + ModesProba[5, 6] = [75, 32, 12, 51, 192, 255, 160, 43, 51]; + ModesProba[5, 7] = [88, 31, 35, 67, 102, 85, 55, 186, 85]; + ModesProba[5, 8] = [56, 21, 23, 111, 59, 205, 45, 37, 192]; + ModesProba[5, 9] = [55, 38, 70, 124, 73, 102, 1, 34, 98]; + ModesProba[6, 0] = [125, 98, 42, 88, 104, 85, 117, 175, 82]; + ModesProba[6, 1] = [95, 84, 53, 89, 128, 100, 113, 101, 45]; + ModesProba[6, 2] = [75, 79, 123, 47, 51, 128, 81, 171, 1]; + ModesProba[6, 3] = [57, 17, 5, 71, 102, 57, 53, 41, 49]; + ModesProba[6, 4] = [38, 33, 13, 121, 57, 73, 26, 1, 85]; + ModesProba[6, 5] = [41, 10, 67, 138, 77, 110, 90, 47, 114]; + ModesProba[6, 6] = [115, 21, 2, 10, 102, 255, 166, 23, 6]; + ModesProba[6, 7] = [101, 29, 16, 10, 85, 128, 101, 196, 26]; + ModesProba[6, 8] = [57, 18, 10, 102, 102, 213, 34, 20, 43]; + ModesProba[6, 9] = [117, 20, 15, 36, 163, 128, 68, 1, 26]; + ModesProba[7, 0] = [102, 61, 71, 37, 34, 53, 31, 243, 192]; + ModesProba[7, 1] = [69, 60, 71, 38, 73, 119, 28, 222, 37]; + ModesProba[7, 2] = [68, 45, 128, 34, 1, 47, 11, 245, 171]; + ModesProba[7, 3] = [62, 17, 19, 70, 146, 85, 55, 62, 70]; + ModesProba[7, 4] = [37, 43, 37, 154, 100, 163, 85, 160, 1]; + ModesProba[7, 5] = [63, 9, 92, 136, 28, 64, 32, 201, 85]; + ModesProba[7, 6] = [75, 15, 9, 9, 64, 255, 184, 119, 16]; + ModesProba[7, 7] = [86, 6, 28, 5, 64, 255, 25, 248, 1]; + ModesProba[7, 8] = [56, 8, 17, 132, 137, 255, 55, 116, 128]; + ModesProba[7, 9] = [58, 15, 20, 82, 135, 57, 26, 121, 40]; + ModesProba[8, 0] = [164, 50, 31, 137, 154, 133, 25, 35, 218]; + ModesProba[8, 1] = [51, 103, 44, 131, 131, 123, 31, 6, 158]; + ModesProba[8, 2] = [86, 40, 64, 135, 148, 224, 45, 183, 128]; + ModesProba[8, 3] = [22, 26, 17, 131, 240, 154, 14, 1, 209]; + ModesProba[8, 4] = [45, 16, 21, 91, 64, 222, 7, 1, 197]; + ModesProba[8, 5] = [56, 21, 39, 155, 60, 138, 23, 102, 213]; + ModesProba[8, 6] = [83, 12, 13, 54, 192, 255, 68, 47, 28]; + ModesProba[8, 7] = [85, 26, 85, 85, 128, 128, 32, 146, 171]; + ModesProba[8, 8] = [18, 11, 7, 63, 144, 171, 4, 4, 246]; + ModesProba[8, 9] = [35, 27, 10, 146, 174, 171, 12, 26, 128]; + ModesProba[9, 0] = [190, 80, 35, 99, 180, 80, 126, 54, 45]; + ModesProba[9, 1] = [85, 126, 47, 87, 176, 51, 41, 20, 32]; + ModesProba[9, 2] = [101, 75, 128, 139, 118, 146, 116, 128, 85]; + ModesProba[9, 3] = [56, 41, 15, 176, 236, 85, 37, 9, 62]; + ModesProba[9, 4] = [71, 30, 17, 119, 118, 255, 17, 18, 138]; + ModesProba[9, 5] = [101, 38, 60, 138, 55, 70, 43, 26, 142]; + ModesProba[9, 6] = [146, 36, 19, 30, 171, 255, 97, 27, 20]; + ModesProba[9, 7] = [138, 45, 61, 62, 219, 1, 81, 188, 64]; + ModesProba[9, 8] = [32, 41, 20, 117, 151, 142, 20, 21, 163]; + ModesProba[9, 9] = [112, 19, 12, 61, 195, 128, 48, 4, 24]; } private static void InitializeFixedCostsI4() { - Vp8FixedCostsI4[0, 0] = new short[] { 40, 1151, 1723, 1874, 2103, 2019, 1628, 1777, 2226, 2137 }; - Vp8FixedCostsI4[0, 1] = new short[] { 192, 469, 1296, 1308, 1849, 1794, 1781, 1703, 1713, 1522 }; - Vp8FixedCostsI4[0, 2] = new short[] { 142, 910, 762, 1684, 1849, 1576, 1460, 1305, 1801, 1657 }; - Vp8FixedCostsI4[0, 3] = new short[] { 559, 641, 1370, 421, 1182, 1569, 1612, 1725, 863, 1007 }; - Vp8FixedCostsI4[0, 4] = new short[] { 299, 1059, 1256, 1108, 636, 1068, 1581, 1883, 869, 1142 }; - Vp8FixedCostsI4[0, 5] = new short[] { 277, 1111, 707, 1362, 1089, 672, 1603, 1541, 1545, 1291 }; - Vp8FixedCostsI4[0, 6] = new short[] { 214, 781, 1609, 1303, 1632, 2229, 726, 1560, 1713, 918 }; - Vp8FixedCostsI4[0, 7] = new short[] { 152, 1037, 1046, 1759, 1983, 2174, 1358, 742, 1740, 1390 }; - Vp8FixedCostsI4[0, 8] = new short[] { 512, 1046, 1420, 753, 752, 1297, 1486, 1613, 460, 1207 }; - Vp8FixedCostsI4[0, 9] = new short[] { 424, 827, 1362, 719, 1462, 1202, 1199, 1476, 1199, 538 }; - Vp8FixedCostsI4[1, 0] = new short[] { 240, 402, 1134, 1491, 1659, 1505, 1517, 1555, 1979, 2099 }; - Vp8FixedCostsI4[1, 1] = new short[] { 467, 242, 960, 1232, 1714, 1620, 1834, 1570, 1676, 1391 }; - Vp8FixedCostsI4[1, 2] = new short[] { 500, 455, 463, 1507, 1699, 1282, 1564, 982, 2114, 2114 }; - Vp8FixedCostsI4[1, 3] = new short[] { 672, 643, 1372, 331, 1589, 1667, 1453, 1938, 996, 876 }; - Vp8FixedCostsI4[1, 4] = new short[] { 458, 783, 1037, 911, 738, 968, 1165, 1518, 859, 1033 }; - Vp8FixedCostsI4[1, 5] = new short[] { 504, 815, 504, 1139, 1219, 719, 1506, 1085, 1268, 1268 }; - Vp8FixedCostsI4[1, 6] = new short[] { 333, 630, 1445, 1239, 1883, 3672, 799, 1548, 1865, 598 }; - Vp8FixedCostsI4[1, 7] = new short[] { 399, 644, 746, 1342, 1856, 1350, 1493, 613, 1855, 1015 }; - Vp8FixedCostsI4[1, 8] = new short[] { 622, 749, 1205, 608, 1066, 1408, 1290, 1406, 546, 971 }; - Vp8FixedCostsI4[1, 9] = new short[] { 500, 753, 1041, 668, 1230, 1617, 1297, 1425, 1383, 523 }; - Vp8FixedCostsI4[2, 0] = new short[] { 394, 553, 523, 1502, 1536, 981, 1608, 1142, 1666, 2181 }; - Vp8FixedCostsI4[2, 1] = new short[] { 655, 430, 375, 1411, 1861, 1220, 1677, 1135, 1978, 1553 }; - Vp8FixedCostsI4[2, 2] = new short[] { 690, 640, 245, 1954, 2070, 1194, 1528, 982, 1972, 2232 }; - Vp8FixedCostsI4[2, 3] = new short[] { 559, 834, 741, 867, 1131, 980, 1225, 852, 1092, 784 }; - Vp8FixedCostsI4[2, 4] = new short[] { 690, 875, 516, 959, 673, 894, 1056, 1190, 1528, 1126 }; - Vp8FixedCostsI4[2, 5] = new short[] { 740, 951, 384, 1277, 1177, 492, 1579, 1155, 1846, 1513 }; - Vp8FixedCostsI4[2, 6] = new short[] { 323, 775, 1062, 1776, 3062, 1274, 813, 1188, 1372, 655 }; - Vp8FixedCostsI4[2, 7] = new short[] { 488, 971, 484, 1767, 1515, 1775, 1115, 503, 1539, 1461 }; - Vp8FixedCostsI4[2, 8] = new short[] { 740, 1006, 998, 709, 851, 1230, 1337, 788, 741, 721 }; - Vp8FixedCostsI4[2, 9] = new short[] { 522, 1073, 573, 1045, 1346, 887, 1046, 1146, 1203, 697 }; - Vp8FixedCostsI4[3, 0] = new short[] { 105, 864, 1442, 1009, 1934, 1840, 1519, 1920, 1673, 1579 }; - Vp8FixedCostsI4[3, 1] = new short[] { 534, 305, 1193, 683, 1388, 2164, 1802, 1894, 1264, 1170 }; - Vp8FixedCostsI4[3, 2] = new short[] { 305, 518, 877, 1108, 1426, 3215, 1425, 1064, 1320, 1242 }; - Vp8FixedCostsI4[3, 3] = new short[] { 683, 732, 1927, 257, 1493, 2048, 1858, 1552, 1055, 947 }; - Vp8FixedCostsI4[3, 4] = new short[] { 394, 814, 1024, 660, 959, 1556, 1282, 1289, 893, 1047 }; - Vp8FixedCostsI4[3, 5] = new short[] { 528, 615, 996, 940, 1201, 635, 1094, 2515, 803, 1358 }; - Vp8FixedCostsI4[3, 6] = new short[] { 347, 614, 1609, 1187, 3133, 1345, 1007, 1339, 1017, 667 }; - Vp8FixedCostsI4[3, 7] = new short[] { 218, 740, 878, 1605, 3650, 3650, 1345, 758, 1357, 1617 }; - Vp8FixedCostsI4[3, 8] = new short[] { 672, 750, 1541, 558, 1257, 1599, 1870, 2135, 402, 1087 }; - Vp8FixedCostsI4[3, 9] = new short[] { 592, 684, 1161, 430, 1092, 1497, 1475, 1489, 1095, 822 }; - Vp8FixedCostsI4[4, 0] = new short[] { 228, 1056, 1059, 1368, 752, 982, 1512, 1518, 987, 1782 }; - Vp8FixedCostsI4[4, 1] = new short[] { 494, 514, 818, 942, 965, 892, 1610, 1356, 1048, 1363 }; - Vp8FixedCostsI4[4, 2] = new short[] { 512, 648, 591, 1042, 761, 991, 1196, 1454, 1309, 1463 }; - Vp8FixedCostsI4[4, 3] = new short[] { 683, 749, 1043, 676, 841, 1396, 1133, 1138, 654, 939 }; - Vp8FixedCostsI4[4, 4] = new short[] { 622, 1101, 1126, 994, 361, 1077, 1203, 1318, 877, 1219 }; - Vp8FixedCostsI4[4, 5] = new short[] { 631, 1068, 857, 1650, 651, 477, 1650, 1419, 828, 1170 }; - Vp8FixedCostsI4[4, 6] = new short[] { 555, 727, 1068, 1335, 3127, 1339, 820, 1331, 1077, 429 }; - Vp8FixedCostsI4[4, 7] = new short[] { 504, 879, 624, 1398, 889, 889, 1392, 808, 891, 1406 }; - Vp8FixedCostsI4[4, 8] = new short[] { 683, 1602, 1289, 977, 578, 983, 1280, 1708, 406, 1122 }; - Vp8FixedCostsI4[4, 9] = new short[] { 399, 865, 1433, 1070, 1072, 764, 968, 1477, 1223, 678 }; - Vp8FixedCostsI4[5, 0] = new short[] { 333, 760, 935, 1638, 1010, 529, 1646, 1410, 1472, 2219 }; - Vp8FixedCostsI4[5, 1] = new short[] { 512, 494, 750, 1160, 1215, 610, 1870, 1868, 1628, 1169 }; - Vp8FixedCostsI4[5, 2] = new short[] { 572, 646, 492, 1934, 1208, 603, 1580, 1099, 1398, 1995 }; - Vp8FixedCostsI4[5, 3] = new short[] { 786, 789, 942, 581, 1018, 951, 1599, 1207, 731, 768 }; - Vp8FixedCostsI4[5, 4] = new short[] { 690, 1015, 672, 1078, 582, 504, 1693, 1438, 1108, 2897 }; - Vp8FixedCostsI4[5, 5] = new short[] { 768, 1267, 571, 2005, 1243, 244, 2881, 1380, 1786, 1453 }; - Vp8FixedCostsI4[5, 6] = new short[] { 452, 899, 1293, 903, 1311, 3100, 465, 1311, 1319, 813 }; - Vp8FixedCostsI4[5, 7] = new short[] { 394, 927, 942, 1103, 1358, 1104, 946, 593, 1363, 1109 }; - Vp8FixedCostsI4[5, 8] = new short[] { 559, 1005, 1007, 1016, 658, 1173, 1021, 1164, 623, 1028 }; - Vp8FixedCostsI4[5, 9] = new short[] { 564, 796, 632, 1005, 1014, 863, 2316, 1268, 938, 764 }; - Vp8FixedCostsI4[6, 0] = new short[] { 266, 606, 1098, 1228, 1497, 1243, 948, 1030, 1734, 1461 }; - Vp8FixedCostsI4[6, 1] = new short[] { 366, 585, 901, 1060, 1407, 1247, 876, 1134, 1620, 1054 }; - Vp8FixedCostsI4[6, 2] = new short[] { 452, 565, 542, 1729, 1479, 1479, 1016, 886, 2938, 1150 }; - Vp8FixedCostsI4[6, 3] = new short[] { 555, 1088, 1533, 950, 1354, 895, 834, 1019, 1021, 496 }; - Vp8FixedCostsI4[6, 4] = new short[] { 704, 815, 1193, 971, 973, 640, 1217, 2214, 832, 578 }; - Vp8FixedCostsI4[6, 5] = new short[] { 672, 1245, 579, 871, 875, 774, 872, 1273, 1027, 949 }; - Vp8FixedCostsI4[6, 6] = new short[] { 296, 1134, 2050, 1784, 1636, 3425, 442, 1550, 2076, 722 }; - Vp8FixedCostsI4[6, 7] = new short[] { 342, 982, 1259, 1846, 1848, 1848, 622, 568, 1847, 1052 }; - Vp8FixedCostsI4[6, 8] = new short[] { 555, 1064, 1304, 828, 746, 1343, 1075, 1329, 1078, 494 }; - Vp8FixedCostsI4[6, 9] = new short[] { 288, 1167, 1285, 1174, 1639, 1639, 833, 2254, 1304, 509 }; - Vp8FixedCostsI4[7, 0] = new short[] { 342, 719, 767, 1866, 1757, 1270, 1246, 550, 1746, 2151 }; - Vp8FixedCostsI4[7, 1] = new short[] { 483, 653, 694, 1509, 1459, 1410, 1218, 507, 1914, 1266 }; - Vp8FixedCostsI4[7, 2] = new short[] { 488, 757, 447, 2979, 1813, 1268, 1654, 539, 1849, 2109 }; - Vp8FixedCostsI4[7, 3] = new short[] { 522, 1097, 1085, 851, 1365, 1111, 851, 901, 961, 605 }; - Vp8FixedCostsI4[7, 4] = new short[] { 709, 716, 841, 728, 736, 945, 941, 862, 2845, 1057 }; - Vp8FixedCostsI4[7, 5] = new short[] { 512, 1323, 500, 1336, 1083, 681, 1342, 717, 1604, 1350 }; - Vp8FixedCostsI4[7, 6] = new short[] { 452, 1155, 1372, 1900, 1501, 3290, 311, 944, 1919, 922 }; - Vp8FixedCostsI4[7, 7] = new short[] { 403, 1520, 977, 2132, 1733, 3522, 1076, 276, 3335, 1547 }; - Vp8FixedCostsI4[7, 8] = new short[] { 559, 1374, 1101, 615, 673, 2462, 974, 795, 984, 984 }; - Vp8FixedCostsI4[7, 9] = new short[] { 547, 1122, 1062, 812, 1410, 951, 1140, 622, 1268, 651 }; - Vp8FixedCostsI4[8, 0] = new short[] { 165, 982, 1235, 938, 1334, 1366, 1659, 1578, 964, 1612 }; - Vp8FixedCostsI4[8, 1] = new short[] { 592, 422, 925, 847, 1139, 1112, 1387, 2036, 861, 1041 }; - Vp8FixedCostsI4[8, 2] = new short[] { 403, 837, 732, 770, 941, 1658, 1250, 809, 1407, 1407 }; - Vp8FixedCostsI4[8, 3] = new short[] { 896, 874, 1071, 381, 1568, 1722, 1437, 2192, 480, 1035 }; - Vp8FixedCostsI4[8, 4] = new short[] { 640, 1098, 1012, 1032, 684, 1382, 1581, 2106, 416, 865 }; - Vp8FixedCostsI4[8, 5] = new short[] { 559, 1005, 819, 914, 710, 770, 1418, 920, 838, 1435 }; - Vp8FixedCostsI4[8, 6] = new short[] { 415, 1258, 1245, 870, 1278, 3067, 770, 1021, 1287, 522 }; - Vp8FixedCostsI4[8, 7] = new short[] { 406, 990, 601, 1009, 1265, 1265, 1267, 759, 1017, 1277 }; - Vp8FixedCostsI4[8, 8] = new short[] { 968, 1182, 1329, 788, 1032, 1292, 1705, 1714, 203, 1403 }; - Vp8FixedCostsI4[8, 9] = new short[] { 732, 877, 1279, 471, 901, 1161, 1545, 1294, 755, 755 }; - Vp8FixedCostsI4[9, 0] = new short[] { 111, 931, 1378, 1185, 1933, 1648, 1148, 1714, 1873, 1307 }; - Vp8FixedCostsI4[9, 1] = new short[] { 406, 414, 1030, 1023, 1910, 1404, 1313, 1647, 1509, 793 }; - Vp8FixedCostsI4[9, 2] = new short[] { 342, 640, 575, 1088, 1241, 1349, 1161, 1350, 1756, 1502 }; - Vp8FixedCostsI4[9, 3] = new short[] { 559, 766, 1185, 357, 1682, 1428, 1329, 1897, 1219, 802 }; - Vp8FixedCostsI4[9, 4] = new short[] { 473, 909, 1164, 771, 719, 2508, 1427, 1432, 722, 782 }; - Vp8FixedCostsI4[9, 5] = new short[] { 342, 892, 785, 1145, 1150, 794, 1296, 1550, 973, 1057 }; - Vp8FixedCostsI4[9, 6] = new short[] { 208, 1036, 1326, 1343, 1606, 3395, 815, 1455, 1618, 712 }; - Vp8FixedCostsI4[9, 7] = new short[] { 228, 928, 890, 1046, 3499, 1711, 994, 829, 1720, 1318 }; - Vp8FixedCostsI4[9, 8] = new short[] { 768, 724, 1058, 636, 991, 1075, 1319, 1324, 616, 825 }; - Vp8FixedCostsI4[9, 9] = new short[] { 305, 1167, 1358, 899, 1587, 1587, 987, 1988, 1332, 501 }; + Vp8FixedCostsI4[0, 0] = [40, 1151, 1723, 1874, 2103, 2019, 1628, 1777, 2226, 2137]; + Vp8FixedCostsI4[0, 1] = [192, 469, 1296, 1308, 1849, 1794, 1781, 1703, 1713, 1522]; + Vp8FixedCostsI4[0, 2] = [142, 910, 762, 1684, 1849, 1576, 1460, 1305, 1801, 1657]; + Vp8FixedCostsI4[0, 3] = [559, 641, 1370, 421, 1182, 1569, 1612, 1725, 863, 1007]; + Vp8FixedCostsI4[0, 4] = [299, 1059, 1256, 1108, 636, 1068, 1581, 1883, 869, 1142]; + Vp8FixedCostsI4[0, 5] = [277, 1111, 707, 1362, 1089, 672, 1603, 1541, 1545, 1291]; + Vp8FixedCostsI4[0, 6] = [214, 781, 1609, 1303, 1632, 2229, 726, 1560, 1713, 918]; + Vp8FixedCostsI4[0, 7] = [152, 1037, 1046, 1759, 1983, 2174, 1358, 742, 1740, 1390]; + Vp8FixedCostsI4[0, 8] = [512, 1046, 1420, 753, 752, 1297, 1486, 1613, 460, 1207]; + Vp8FixedCostsI4[0, 9] = [424, 827, 1362, 719, 1462, 1202, 1199, 1476, 1199, 538]; + Vp8FixedCostsI4[1, 0] = [240, 402, 1134, 1491, 1659, 1505, 1517, 1555, 1979, 2099]; + Vp8FixedCostsI4[1, 1] = [467, 242, 960, 1232, 1714, 1620, 1834, 1570, 1676, 1391]; + Vp8FixedCostsI4[1, 2] = [500, 455, 463, 1507, 1699, 1282, 1564, 982, 2114, 2114]; + Vp8FixedCostsI4[1, 3] = [672, 643, 1372, 331, 1589, 1667, 1453, 1938, 996, 876]; + Vp8FixedCostsI4[1, 4] = [458, 783, 1037, 911, 738, 968, 1165, 1518, 859, 1033]; + Vp8FixedCostsI4[1, 5] = [504, 815, 504, 1139, 1219, 719, 1506, 1085, 1268, 1268]; + Vp8FixedCostsI4[1, 6] = [333, 630, 1445, 1239, 1883, 3672, 799, 1548, 1865, 598]; + Vp8FixedCostsI4[1, 7] = [399, 644, 746, 1342, 1856, 1350, 1493, 613, 1855, 1015]; + Vp8FixedCostsI4[1, 8] = [622, 749, 1205, 608, 1066, 1408, 1290, 1406, 546, 971]; + Vp8FixedCostsI4[1, 9] = [500, 753, 1041, 668, 1230, 1617, 1297, 1425, 1383, 523]; + Vp8FixedCostsI4[2, 0] = [394, 553, 523, 1502, 1536, 981, 1608, 1142, 1666, 2181]; + Vp8FixedCostsI4[2, 1] = [655, 430, 375, 1411, 1861, 1220, 1677, 1135, 1978, 1553]; + Vp8FixedCostsI4[2, 2] = [690, 640, 245, 1954, 2070, 1194, 1528, 982, 1972, 2232]; + Vp8FixedCostsI4[2, 3] = [559, 834, 741, 867, 1131, 980, 1225, 852, 1092, 784]; + Vp8FixedCostsI4[2, 4] = [690, 875, 516, 959, 673, 894, 1056, 1190, 1528, 1126]; + Vp8FixedCostsI4[2, 5] = [740, 951, 384, 1277, 1177, 492, 1579, 1155, 1846, 1513]; + Vp8FixedCostsI4[2, 6] = [323, 775, 1062, 1776, 3062, 1274, 813, 1188, 1372, 655]; + Vp8FixedCostsI4[2, 7] = [488, 971, 484, 1767, 1515, 1775, 1115, 503, 1539, 1461]; + Vp8FixedCostsI4[2, 8] = [740, 1006, 998, 709, 851, 1230, 1337, 788, 741, 721]; + Vp8FixedCostsI4[2, 9] = [522, 1073, 573, 1045, 1346, 887, 1046, 1146, 1203, 697]; + Vp8FixedCostsI4[3, 0] = [105, 864, 1442, 1009, 1934, 1840, 1519, 1920, 1673, 1579]; + Vp8FixedCostsI4[3, 1] = [534, 305, 1193, 683, 1388, 2164, 1802, 1894, 1264, 1170]; + Vp8FixedCostsI4[3, 2] = [305, 518, 877, 1108, 1426, 3215, 1425, 1064, 1320, 1242]; + Vp8FixedCostsI4[3, 3] = [683, 732, 1927, 257, 1493, 2048, 1858, 1552, 1055, 947]; + Vp8FixedCostsI4[3, 4] = [394, 814, 1024, 660, 959, 1556, 1282, 1289, 893, 1047]; + Vp8FixedCostsI4[3, 5] = [528, 615, 996, 940, 1201, 635, 1094, 2515, 803, 1358]; + Vp8FixedCostsI4[3, 6] = [347, 614, 1609, 1187, 3133, 1345, 1007, 1339, 1017, 667]; + Vp8FixedCostsI4[3, 7] = [218, 740, 878, 1605, 3650, 3650, 1345, 758, 1357, 1617]; + Vp8FixedCostsI4[3, 8] = [672, 750, 1541, 558, 1257, 1599, 1870, 2135, 402, 1087]; + Vp8FixedCostsI4[3, 9] = [592, 684, 1161, 430, 1092, 1497, 1475, 1489, 1095, 822]; + Vp8FixedCostsI4[4, 0] = [228, 1056, 1059, 1368, 752, 982, 1512, 1518, 987, 1782]; + Vp8FixedCostsI4[4, 1] = [494, 514, 818, 942, 965, 892, 1610, 1356, 1048, 1363]; + Vp8FixedCostsI4[4, 2] = [512, 648, 591, 1042, 761, 991, 1196, 1454, 1309, 1463]; + Vp8FixedCostsI4[4, 3] = [683, 749, 1043, 676, 841, 1396, 1133, 1138, 654, 939]; + Vp8FixedCostsI4[4, 4] = [622, 1101, 1126, 994, 361, 1077, 1203, 1318, 877, 1219]; + Vp8FixedCostsI4[4, 5] = [631, 1068, 857, 1650, 651, 477, 1650, 1419, 828, 1170]; + Vp8FixedCostsI4[4, 6] = [555, 727, 1068, 1335, 3127, 1339, 820, 1331, 1077, 429]; + Vp8FixedCostsI4[4, 7] = [504, 879, 624, 1398, 889, 889, 1392, 808, 891, 1406]; + Vp8FixedCostsI4[4, 8] = [683, 1602, 1289, 977, 578, 983, 1280, 1708, 406, 1122]; + Vp8FixedCostsI4[4, 9] = [399, 865, 1433, 1070, 1072, 764, 968, 1477, 1223, 678]; + Vp8FixedCostsI4[5, 0] = [333, 760, 935, 1638, 1010, 529, 1646, 1410, 1472, 2219]; + Vp8FixedCostsI4[5, 1] = [512, 494, 750, 1160, 1215, 610, 1870, 1868, 1628, 1169]; + Vp8FixedCostsI4[5, 2] = [572, 646, 492, 1934, 1208, 603, 1580, 1099, 1398, 1995]; + Vp8FixedCostsI4[5, 3] = [786, 789, 942, 581, 1018, 951, 1599, 1207, 731, 768]; + Vp8FixedCostsI4[5, 4] = [690, 1015, 672, 1078, 582, 504, 1693, 1438, 1108, 2897]; + Vp8FixedCostsI4[5, 5] = [768, 1267, 571, 2005, 1243, 244, 2881, 1380, 1786, 1453]; + Vp8FixedCostsI4[5, 6] = [452, 899, 1293, 903, 1311, 3100, 465, 1311, 1319, 813]; + Vp8FixedCostsI4[5, 7] = [394, 927, 942, 1103, 1358, 1104, 946, 593, 1363, 1109]; + Vp8FixedCostsI4[5, 8] = [559, 1005, 1007, 1016, 658, 1173, 1021, 1164, 623, 1028]; + Vp8FixedCostsI4[5, 9] = [564, 796, 632, 1005, 1014, 863, 2316, 1268, 938, 764]; + Vp8FixedCostsI4[6, 0] = [266, 606, 1098, 1228, 1497, 1243, 948, 1030, 1734, 1461]; + Vp8FixedCostsI4[6, 1] = [366, 585, 901, 1060, 1407, 1247, 876, 1134, 1620, 1054]; + Vp8FixedCostsI4[6, 2] = [452, 565, 542, 1729, 1479, 1479, 1016, 886, 2938, 1150]; + Vp8FixedCostsI4[6, 3] = [555, 1088, 1533, 950, 1354, 895, 834, 1019, 1021, 496]; + Vp8FixedCostsI4[6, 4] = [704, 815, 1193, 971, 973, 640, 1217, 2214, 832, 578]; + Vp8FixedCostsI4[6, 5] = [672, 1245, 579, 871, 875, 774, 872, 1273, 1027, 949]; + Vp8FixedCostsI4[6, 6] = [296, 1134, 2050, 1784, 1636, 3425, 442, 1550, 2076, 722]; + Vp8FixedCostsI4[6, 7] = [342, 982, 1259, 1846, 1848, 1848, 622, 568, 1847, 1052]; + Vp8FixedCostsI4[6, 8] = [555, 1064, 1304, 828, 746, 1343, 1075, 1329, 1078, 494]; + Vp8FixedCostsI4[6, 9] = [288, 1167, 1285, 1174, 1639, 1639, 833, 2254, 1304, 509]; + Vp8FixedCostsI4[7, 0] = [342, 719, 767, 1866, 1757, 1270, 1246, 550, 1746, 2151]; + Vp8FixedCostsI4[7, 1] = [483, 653, 694, 1509, 1459, 1410, 1218, 507, 1914, 1266]; + Vp8FixedCostsI4[7, 2] = [488, 757, 447, 2979, 1813, 1268, 1654, 539, 1849, 2109]; + Vp8FixedCostsI4[7, 3] = [522, 1097, 1085, 851, 1365, 1111, 851, 901, 961, 605]; + Vp8FixedCostsI4[7, 4] = [709, 716, 841, 728, 736, 945, 941, 862, 2845, 1057]; + Vp8FixedCostsI4[7, 5] = [512, 1323, 500, 1336, 1083, 681, 1342, 717, 1604, 1350]; + Vp8FixedCostsI4[7, 6] = [452, 1155, 1372, 1900, 1501, 3290, 311, 944, 1919, 922]; + Vp8FixedCostsI4[7, 7] = [403, 1520, 977, 2132, 1733, 3522, 1076, 276, 3335, 1547]; + Vp8FixedCostsI4[7, 8] = [559, 1374, 1101, 615, 673, 2462, 974, 795, 984, 984]; + Vp8FixedCostsI4[7, 9] = [547, 1122, 1062, 812, 1410, 951, 1140, 622, 1268, 651]; + Vp8FixedCostsI4[8, 0] = [165, 982, 1235, 938, 1334, 1366, 1659, 1578, 964, 1612]; + Vp8FixedCostsI4[8, 1] = [592, 422, 925, 847, 1139, 1112, 1387, 2036, 861, 1041]; + Vp8FixedCostsI4[8, 2] = [403, 837, 732, 770, 941, 1658, 1250, 809, 1407, 1407]; + Vp8FixedCostsI4[8, 3] = [896, 874, 1071, 381, 1568, 1722, 1437, 2192, 480, 1035]; + Vp8FixedCostsI4[8, 4] = [640, 1098, 1012, 1032, 684, 1382, 1581, 2106, 416, 865]; + Vp8FixedCostsI4[8, 5] = [559, 1005, 819, 914, 710, 770, 1418, 920, 838, 1435]; + Vp8FixedCostsI4[8, 6] = [415, 1258, 1245, 870, 1278, 3067, 770, 1021, 1287, 522]; + Vp8FixedCostsI4[8, 7] = [406, 990, 601, 1009, 1265, 1265, 1267, 759, 1017, 1277]; + Vp8FixedCostsI4[8, 8] = [968, 1182, 1329, 788, 1032, 1292, 1705, 1714, 203, 1403]; + Vp8FixedCostsI4[8, 9] = [732, 877, 1279, 471, 901, 1161, 1545, 1294, 755, 755]; + Vp8FixedCostsI4[9, 0] = [111, 931, 1378, 1185, 1933, 1648, 1148, 1714, 1873, 1307]; + Vp8FixedCostsI4[9, 1] = [406, 414, 1030, 1023, 1910, 1404, 1313, 1647, 1509, 793]; + Vp8FixedCostsI4[9, 2] = [342, 640, 575, 1088, 1241, 1349, 1161, 1350, 1756, 1502]; + Vp8FixedCostsI4[9, 3] = [559, 766, 1185, 357, 1682, 1428, 1329, 1897, 1219, 802]; + Vp8FixedCostsI4[9, 4] = [473, 909, 1164, 771, 719, 2508, 1427, 1432, 722, 782]; + Vp8FixedCostsI4[9, 5] = [342, 892, 785, 1145, 1150, 794, 1296, 1550, 973, 1057]; + Vp8FixedCostsI4[9, 6] = [208, 1036, 1326, 1343, 1606, 3395, 815, 1455, 1618, 712]; + Vp8FixedCostsI4[9, 7] = [228, 928, 890, 1046, 3499, 1711, 994, 829, 1720, 1318]; + Vp8FixedCostsI4[9, 8] = [768, 724, 1058, 636, 991, 1075, 1319, 1324, 616, 825]; + Vp8FixedCostsI4[9, 9] = [305, 1167, 1358, 899, 1587, 1587, 987, 1988, 1332, 501]; } } diff --git a/src/ImageSharp/Formats/Webp/WebpMetadata.cs b/src/ImageSharp/Formats/Webp/WebpMetadata.cs index db57bd8f27..817addac5b 100644 --- a/src/ImageSharp/Formats/Webp/WebpMetadata.cs +++ b/src/ImageSharp/Formats/Webp/WebpMetadata.cs @@ -126,7 +126,7 @@ public PixelTypeInfo GetPixelTypeInfo() break; } - return new PixelTypeInfo(bpp) + return new(bpp) { AlphaRepresentation = alpha, ColorType = colorType, diff --git a/src/ImageSharp/GraphicOptionsDefaultsExtensions.cs b/src/ImageSharp/GraphicOptionsDefaultsExtensions.cs index 4220b3df77..9412062ccc 100644 --- a/src/ImageSharp/GraphicOptionsDefaultsExtensions.cs +++ b/src/ImageSharp/GraphicOptionsDefaultsExtensions.cs @@ -18,7 +18,7 @@ public static class GraphicOptionsDefaultsExtensions /// The passed in to allow chaining. public static IImageProcessingContext SetGraphicsOptions(this IImageProcessingContext context, Action optionsBuilder) { - var cloned = context.GetGraphicsOptions().DeepClone(); + GraphicsOptions cloned = context.GetGraphicsOptions().DeepClone(); optionsBuilder(cloned); context.Properties[typeof(GraphicsOptions)] = cloned; return context; @@ -31,7 +31,7 @@ public static IImageProcessingContext SetGraphicsOptions(this IImageProcessingCo /// The default options to use. public static void SetGraphicsOptions(this Configuration configuration, Action optionsBuilder) { - var cloned = configuration.GetGraphicsOptions().DeepClone(); + GraphicsOptions cloned = configuration.GetGraphicsOptions().DeepClone(); optionsBuilder(cloned); configuration.Properties[typeof(GraphicsOptions)] = cloned; } @@ -65,7 +65,7 @@ public static void SetGraphicsOptions(this Configuration configuration, Graphics /// The globaly configued default options. public static GraphicsOptions GetGraphicsOptions(this IImageProcessingContext context) { - if (context.Properties.TryGetValue(typeof(GraphicsOptions), out var options) && options is GraphicsOptions go) + if (context.Properties.TryGetValue(typeof(GraphicsOptions), out object? options) && options is GraphicsOptions go) { return go; } @@ -82,12 +82,12 @@ public static GraphicsOptions GetGraphicsOptions(this IImageProcessingContext co /// The globaly configued default options. public static GraphicsOptions GetGraphicsOptions(this Configuration configuration) { - if (configuration.Properties.TryGetValue(typeof(GraphicsOptions), out var options) && options is GraphicsOptions go) + if (configuration.Properties.TryGetValue(typeof(GraphicsOptions), out object? options) && options is GraphicsOptions go) { return go; } - var configOptions = new GraphicsOptions(); + GraphicsOptions configOptions = new(); // capture the fallback so the same instance will always be returned in case its mutated configuration.Properties[typeof(GraphicsOptions)] = configOptions; diff --git a/src/ImageSharp/GraphicsOptions.cs b/src/ImageSharp/GraphicsOptions.cs index 4ac8585c3c..dc3d179027 100644 --- a/src/ImageSharp/GraphicsOptions.cs +++ b/src/ImageSharp/GraphicsOptions.cs @@ -84,5 +84,5 @@ public float BlendPercentage public PixelAlphaCompositionMode AlphaCompositionMode { get; set; } = PixelAlphaCompositionMode.SrcOver; /// - public GraphicsOptions DeepClone() => new GraphicsOptions(this); + public GraphicsOptions DeepClone() => new(this); } diff --git a/src/ImageSharp/IO/ChunkedMemoryStream.cs b/src/ImageSharp/IO/ChunkedMemoryStream.cs index 2534548141..70acc3ffb6 100644 --- a/src/ImageSharp/IO/ChunkedMemoryStream.cs +++ b/src/ImageSharp/IO/ChunkedMemoryStream.cs @@ -523,7 +523,7 @@ private MemoryChunk AllocateMemoryChunk() // available contiguous buffer size. IMemoryOwner buffer = this.allocator.Allocate(Math.Min(this.allocatorCapacity, GetChunkSize(this.chunkCount++))); - return new MemoryChunk(buffer) + return new(buffer) { Next = null, Length = buffer.Length() diff --git a/src/ImageSharp/Image.Decode.cs b/src/ImageSharp/Image.Decode.cs index 7f58c6ecd8..d23a1e33bc 100644 --- a/src/ImageSharp/Image.Decode.cs +++ b/src/ImageSharp/Image.Decode.cs @@ -36,7 +36,7 @@ internal static Image CreateUninitialized( width, height, configuration.PreferContiguousImageBuffers); - return new Image(configuration, uninitializedMemoryBuffer.FastMemoryGroup, width, height, metadata); + return new(configuration, uninitializedMemoryBuffer.FastMemoryGroup, width, height, metadata); } /// diff --git a/src/ImageSharp/Image.WrapMemory.cs b/src/ImageSharp/Image.WrapMemory.cs index 03bec8bc6a..ab2718f6c5 100644 --- a/src/ImageSharp/Image.WrapMemory.cs +++ b/src/ImageSharp/Image.WrapMemory.cs @@ -53,7 +53,7 @@ public static Image WrapMemory( Guard.IsTrue(pixelMemory.Length >= (long)width * height, nameof(pixelMemory), "The length of the input memory is less than the specified image size"); MemoryGroup memorySource = MemoryGroup.Wrap(pixelMemory); - return new Image(configuration, memorySource, width, height, metadata); + return new(configuration, memorySource, width, height, metadata); } /// @@ -87,7 +87,7 @@ public static Image WrapMemory( int width, int height) where TPixel : unmanaged, IPixel - => WrapMemory(configuration, pixelMemory, width, height, new ImageMetadata()); + => WrapMemory(configuration, pixelMemory, width, height, new()); /// /// @@ -148,7 +148,7 @@ public static Image WrapMemory( Guard.IsTrue(pixelMemoryOwner.Memory.Length >= (long)width * height, nameof(pixelMemoryOwner), "The length of the input memory is less than the specified image size"); MemoryGroup memorySource = MemoryGroup.Wrap(pixelMemoryOwner); - return new Image(configuration, memorySource, width, height, metadata); + return new(configuration, memorySource, width, height, metadata); } /// @@ -171,7 +171,7 @@ public static Image WrapMemory( int width, int height) where TPixel : unmanaged, IPixel - => WrapMemory(configuration, pixelMemoryOwner, width, height, new ImageMetadata()); + => WrapMemory(configuration, pixelMemoryOwner, width, height, new()); /// /// Wraps an existing contiguous memory area of at least 'width' x 'height' pixels, @@ -235,7 +235,7 @@ public static Image WrapMemory( Guard.IsTrue(memoryManager.Memory.Length >= (long)width * height, nameof(byteMemory), "The length of the input memory is less than the specified image size"); MemoryGroup memorySource = MemoryGroup.Wrap(memoryManager.Memory); - return new Image(configuration, memorySource, width, height, metadata); + return new(configuration, memorySource, width, height, metadata); } /// @@ -269,7 +269,7 @@ public static Image WrapMemory( int width, int height) where TPixel : unmanaged, IPixel - => WrapMemory(configuration, byteMemory, width, height, new ImageMetadata()); + => WrapMemory(configuration, byteMemory, width, height, new()); /// /// @@ -333,7 +333,7 @@ public static Image WrapMemory( Guard.IsTrue(pixelMemoryOwner.Memory.Length >= (long)width * height, nameof(pixelMemoryOwner), "The length of the input memory is less than the specified image size"); MemoryGroup memorySource = MemoryGroup.Wrap(pixelMemoryOwner); - return new Image(configuration, memorySource, width, height, metadata); + return new(configuration, memorySource, width, height, metadata); } /// @@ -356,7 +356,7 @@ public static Image WrapMemory( int width, int height) where TPixel : unmanaged, IPixel - => WrapMemory(configuration, byteMemoryOwner, width, height, new ImageMetadata()); + => WrapMemory(configuration, byteMemoryOwner, width, height, new()); /// /// Wraps an existing contiguous memory area of at least 'width' x 'height' pixels, @@ -429,7 +429,7 @@ public static unsafe Image WrapMemory( Guard.MustBeGreaterThanOrEqualTo(bufferSizeInBytes / sizeof(TPixel), memoryManager.Memory.Span.Length, nameof(bufferSizeInBytes)); MemoryGroup memorySource = MemoryGroup.Wrap(memoryManager.Memory); - return new Image(configuration, memorySource, width, height, metadata); + return new(configuration, memorySource, width, height, metadata); } /// @@ -470,7 +470,7 @@ public static unsafe Image WrapMemory( int width, int height) where TPixel : unmanaged, IPixel - => WrapMemory(configuration, pointer, bufferSizeInBytes, width, height, new ImageMetadata()); + => WrapMemory(configuration, pointer, bufferSizeInBytes, width, height, new()); /// /// diff --git a/src/ImageSharp/Image.cs b/src/ImageSharp/Image.cs index 07b40a41a1..693b58db64 100644 --- a/src/ImageSharp/Image.cs +++ b/src/ImageSharp/Image.cs @@ -47,7 +47,7 @@ internal Image( ImageMetadata metadata, int width, int height) - : this(configuration, pixelType, metadata, new Size(width, height)) + : this(configuration, pixelType, metadata, new(width, height)) { } diff --git a/src/ImageSharp/ImageExtensions.cs b/src/ImageSharp/ImageExtensions.cs index 6c769a9d17..c6853b40ca 100644 --- a/src/ImageSharp/ImageExtensions.cs +++ b/src/ImageSharp/ImageExtensions.cs @@ -179,6 +179,6 @@ public static string ToBase64String(this Image source, IImageFormat format) // Always available. stream.TryGetBuffer(out ArraySegment buffer); - return $"data:{format.DefaultMimeType};base64,{Convert.ToBase64String(buffer.Array ?? Array.Empty(), 0, (int)stream.Length)}"; + return $"data:{format.DefaultMimeType};base64,{Convert.ToBase64String(buffer.Array ?? [], 0, (int)stream.Length)}"; } } diff --git a/src/ImageSharp/ImageFrame.LoadPixelData.cs b/src/ImageSharp/ImageFrame.LoadPixelData.cs index 61f4c0ea9d..003a0349ae 100644 --- a/src/ImageSharp/ImageFrame.LoadPixelData.cs +++ b/src/ImageSharp/ImageFrame.LoadPixelData.cs @@ -40,7 +40,7 @@ internal static ImageFrame LoadPixelData(Configuration configura int count = width * height; Guard.MustBeGreaterThanOrEqualTo(data.Length, count, nameof(data)); - var image = new ImageFrame(configuration, width, height); + ImageFrame image = new(configuration, width, height); data = data[..count]; data.CopyTo(image.PixelBuffer.FastMemoryGroup); diff --git a/src/ImageSharp/ImageFrameCollection{TPixel}.cs b/src/ImageSharp/ImageFrameCollection{TPixel}.cs index ad7d719744..82be567733 100644 --- a/src/ImageSharp/ImageFrameCollection{TPixel}.cs +++ b/src/ImageSharp/ImageFrameCollection{TPixel}.cs @@ -23,7 +23,7 @@ internal ImageFrameCollection(Image parent, int width, int height, TPixe this.parent = parent ?? throw new ArgumentNullException(nameof(parent)); // Frames are already cloned within the caller - this.frames.Add(new ImageFrame(parent.Configuration, width, height, backgroundColor)); + this.frames.Add(new(parent.Configuration, width, height, backgroundColor)); } internal ImageFrameCollection(Image parent, int width, int height, MemoryGroup memorySource) @@ -31,7 +31,7 @@ internal ImageFrameCollection(Image parent, int width, int height, Memor this.parent = parent ?? throw new ArgumentNullException(nameof(parent)); // Frames are already cloned within the caller - this.frames.Add(new ImageFrame(parent.Configuration, width, height, memorySource)); + this.frames.Add(new(parent.Configuration, width, height, memorySource)); } internal ImageFrameCollection(Image parent, IEnumerable> frames) @@ -269,7 +269,7 @@ public override void MoveFrame(int sourceIndex, int destinationIndex) this.frames.Remove(frame); - return new Image(this.parent.Configuration, this.parent.Metadata.DeepClone(), new[] { frame }); + return new(this.parent.Configuration, this.parent.Metadata.DeepClone(), [frame]); } /// @@ -284,7 +284,7 @@ public override void MoveFrame(int sourceIndex, int destinationIndex) ImageFrame frame = this[index]; ImageFrame clonedFrame = frame.Clone(); - return new Image(this.parent.Configuration, this.parent.Metadata.DeepClone(), new[] { clonedFrame }); + return new(this.parent.Configuration, this.parent.Metadata.DeepClone(), [clonedFrame]); } /// diff --git a/src/ImageSharp/ImageFrame{TPixel}.cs b/src/ImageSharp/ImageFrame{TPixel}.cs index 2287f65cd8..0a64f0b418 100644 --- a/src/ImageSharp/ImageFrame{TPixel}.cs +++ b/src/ImageSharp/ImageFrame{TPixel}.cs @@ -81,7 +81,7 @@ internal ImageFrame(Configuration configuration, int width, int height, ImageFra /// The height of the image in pixels. /// The color to clear the image with. internal ImageFrame(Configuration configuration, int width, int height, TPixel backgroundColor) - : this(configuration, width, height, backgroundColor, new ImageFrameMetadata()) + : this(configuration, width, height, backgroundColor, new()) { } @@ -114,7 +114,7 @@ internal ImageFrame(Configuration configuration, int width, int height, TPixel b /// The height of the image in pixels. /// The memory source. internal ImageFrame(Configuration configuration, int width, int height, MemoryGroup memorySource) - : this(configuration, width, height, memorySource, new ImageFrameMetadata()) + : this(configuration, width, height, memorySource, new()) { } @@ -132,7 +132,7 @@ internal ImageFrame(Configuration configuration, int width, int height, MemoryGr Guard.MustBeGreaterThan(width, 0, nameof(width)); Guard.MustBeGreaterThan(height, 0, nameof(height)); - this.PixelBuffer = new Buffer2D(memorySource, width, height); + this.PixelBuffer = new(memorySource, width, height); } /// diff --git a/src/ImageSharp/Image{TPixel}.cs b/src/ImageSharp/Image{TPixel}.cs index 02403923d2..98de406b9b 100644 --- a/src/ImageSharp/Image{TPixel}.cs +++ b/src/ImageSharp/Image{TPixel}.cs @@ -41,7 +41,7 @@ public Image(Configuration configuration, int width, int height) /// The height of the image in pixels. /// The color to initialize the pixels with. public Image(Configuration configuration, int width, int height, TPixel backgroundColor) - : this(configuration, width, height, backgroundColor, new ImageMetadata()) + : this(configuration, width, height, backgroundColor, new()) { } @@ -53,7 +53,7 @@ public Image(Configuration configuration, int width, int height, TPixel backgrou /// The height of the image in pixels. /// The color to initialize the pixels with. public Image(int width, int height, TPixel backgroundColor) - : this(Configuration.Default, width, height, backgroundColor, new ImageMetadata()) + : this(Configuration.Default, width, height, backgroundColor, new()) { } @@ -78,7 +78,7 @@ public Image(int width, int height) /// The images metadata. internal Image(Configuration configuration, int width, int height, ImageMetadata? metadata) : base(configuration, TPixel.GetPixelTypeInfo(), metadata ?? new(), width, height) - => this.frames = new ImageFrameCollection(this, width, height, default(TPixel)); + => this.frames = new(this, width, height, default(TPixel)); /// /// Initializes a new instance of the class @@ -111,7 +111,7 @@ internal Image( int height, ImageMetadata metadata) : base(configuration, TPixel.GetPixelTypeInfo(), metadata, width, height) - => this.frames = new ImageFrameCollection(this, width, height, memoryGroup); + => this.frames = new(this, width, height, memoryGroup); /// /// Initializes a new instance of the class @@ -129,7 +129,7 @@ internal Image( TPixel backgroundColor, ImageMetadata? metadata) : base(configuration, TPixel.GetPixelTypeInfo(), metadata ?? new(), width, height) - => this.frames = new ImageFrameCollection(this, width, height, backgroundColor); + => this.frames = new(this, width, height, backgroundColor); /// /// Initializes a new instance of the class @@ -140,7 +140,7 @@ internal Image( /// The frames that will be owned by this image instance. internal Image(Configuration configuration, ImageMetadata metadata, IEnumerable> frames) : base(configuration, TPixel.GetPixelTypeInfo(), metadata, ValidateFramesAndGetSize(frames)) - => this.frames = new ImageFrameCollection(this, frames); + => this.frames = new(this, frames); /// protected override ImageFrameCollection NonGenericFrameCollection => this.Frames; @@ -344,7 +344,7 @@ public Image Clone(Configuration configuration) clonedFrames[i] = this.frames[i].Clone(configuration); } - return new Image(configuration, this.Metadata.DeepClone(), clonedFrames); + return new(configuration, this.Metadata.DeepClone(), clonedFrames); } /// @@ -363,7 +363,7 @@ public override Image CloneAs(Configuration configuration) clonedFrames[i] = this.frames[i].CloneAs(configuration); } - return new Image(configuration, this.Metadata.DeepClone(), clonedFrames); + return new(configuration, this.Metadata.DeepClone(), clonedFrames); } /// @@ -437,7 +437,7 @@ private static Size ValidateFramesAndGetSize(IEnumerable> fra { Guard.NotNull(frames, nameof(frames)); - ImageFrame? rootFrame = frames.FirstOrDefault() ?? throw new ArgumentException("Must not be empty.", nameof(frames)); + ImageFrame rootFrame = frames.FirstOrDefault() ?? throw new ArgumentException("Must not be empty.", nameof(frames)); Size rootSize = rootFrame.Size; diff --git a/src/ImageSharp/Memory/Allocators/Internals/ManagedBufferBase.cs b/src/ImageSharp/Memory/Allocators/Internals/ManagedBufferBase.cs index a6ed797d6d..cbf64e6a16 100644 --- a/src/ImageSharp/Memory/Allocators/Internals/ManagedBufferBase.cs +++ b/src/ImageSharp/Memory/Allocators/Internals/ManagedBufferBase.cs @@ -27,7 +27,7 @@ public override unsafe MemoryHandle Pin(int elementIndex = 0) void* ptr = Unsafe.Add((void*)this.pinHandle.AddrOfPinnedObject(), elementIndex); // We should only pass pinnable:this, when GCHandle lifetime is managed by the MemoryManager instance. - return new MemoryHandle(ptr, pinnable: this); + return new(ptr, pinnable: this); } /// diff --git a/src/ImageSharp/Memory/Allocators/Internals/SharedArrayPoolBuffer{T}.cs b/src/ImageSharp/Memory/Allocators/Internals/SharedArrayPoolBuffer{T}.cs index 02bdf0f48d..364aa05afc 100644 --- a/src/ImageSharp/Memory/Allocators/Internals/SharedArrayPoolBuffer{T}.cs +++ b/src/ImageSharp/Memory/Allocators/Internals/SharedArrayPoolBuffer{T}.cs @@ -19,7 +19,7 @@ public SharedArrayPoolBuffer(int lengthInElements) { this.lengthInBytes = lengthInElements * Unsafe.SizeOf(); this.Array = ArrayPool.Shared.Rent(this.lengthInBytes); - this.lifetimeGuard = new LifetimeGuard(this.Array); + this.lifetimeGuard = new(this.Array); } public byte[]? Array { get; private set; } diff --git a/src/ImageSharp/Memory/Allocators/Internals/UniformUnmanagedMemoryPool.LifetimeGuards.cs b/src/ImageSharp/Memory/Allocators/Internals/UniformUnmanagedMemoryPool.LifetimeGuards.cs index 24bf52b1f9..e3b73204de 100644 --- a/src/ImageSharp/Memory/Allocators/Internals/UniformUnmanagedMemoryPool.LifetimeGuards.cs +++ b/src/ImageSharp/Memory/Allocators/Internals/UniformUnmanagedMemoryPool.LifetimeGuards.cs @@ -11,7 +11,7 @@ public UnmanagedBuffer CreateGuardedBuffer( bool clear) where T : struct { - var buffer = new UnmanagedBuffer(lengthInElements, new ReturnToPoolBufferLifetimeGuard(this, handle)); + UnmanagedBuffer buffer = new(lengthInElements, new ReturnToPoolBufferLifetimeGuard(this, handle)); if (clear) { buffer.Clear(); diff --git a/src/ImageSharp/Memory/Allocators/Internals/UniformUnmanagedMemoryPool.cs b/src/ImageSharp/Memory/Allocators/Internals/UniformUnmanagedMemoryPool.cs index aa8bcd3859..4dfb7850ea 100644 --- a/src/ImageSharp/Memory/Allocators/Internals/UniformUnmanagedMemoryPool.cs +++ b/src/ImageSharp/Memory/Allocators/Internals/UniformUnmanagedMemoryPool.cs @@ -11,7 +11,7 @@ namespace SixLabors.ImageSharp.Memory.Internals; internal partial class UniformUnmanagedMemoryPool : System.Runtime.ConstrainedExecution.CriticalFinalizerObject { private static int minTrimPeriodMilliseconds = int.MaxValue; - private static readonly List> AllPools = new(); + private static readonly List> AllPools = []; private static Timer? trimTimer; private static readonly Stopwatch Stopwatch = Stopwatch.StartNew(); @@ -214,14 +214,14 @@ private static void UpdateTimer(TrimSettings settings, UniformUnmanagedMemoryPoo { lock (AllPools) { - AllPools.Add(new WeakReference(pool)); + AllPools.Add(new(pool)); // Invoke the timer callback more frequently, than trimSettings.TrimPeriodMilliseconds. // We are checking in the callback if enough time passed since the last trimming. If not, we do nothing. int period = settings.TrimPeriodMilliseconds / 4; if (trimTimer == null) { - trimTimer = new Timer(_ => TimerCallback(), null, period, period); + trimTimer = new(_ => TimerCallback(), null, period, period); } else if (settings.TrimPeriodMilliseconds < minTrimPeriodMilliseconds) { @@ -337,6 +337,6 @@ public class TrimSettings public bool Enabled => this.Rate > 0; - public static TrimSettings Default => new TrimSettings(); + public static TrimSettings Default => new(); } } diff --git a/src/ImageSharp/Memory/Allocators/Internals/UnmanagedBuffer{T}.cs b/src/ImageSharp/Memory/Allocators/Internals/UnmanagedBuffer{T}.cs index de09647261..5e7f386fd7 100644 --- a/src/ImageSharp/Memory/Allocators/Internals/UnmanagedBuffer{T}.cs +++ b/src/ImageSharp/Memory/Allocators/Internals/UnmanagedBuffer{T}.cs @@ -48,7 +48,7 @@ public override MemoryHandle Pin(int elementIndex = 0) this.lifetimeGuard.AddRef(); void* pbData = Unsafe.Add(this.Pointer, elementIndex); - return new MemoryHandle(pbData, pinnable: this); + return new(pbData, pinnable: this); } /// diff --git a/src/ImageSharp/Memory/Allocators/Internals/UnmanagedMemoryHandle.cs b/src/ImageSharp/Memory/Allocators/Internals/UnmanagedMemoryHandle.cs index 6b31cadf4f..0fc5d2dea4 100644 --- a/src/ImageSharp/Memory/Allocators/Internals/UnmanagedMemoryHandle.cs +++ b/src/ImageSharp/Memory/Allocators/Internals/UnmanagedMemoryHandle.cs @@ -64,7 +64,7 @@ private UnmanagedMemoryHandle(IntPtr handle, int lengthInBytes) public static UnmanagedMemoryHandle Allocate(int lengthInBytes) { IntPtr handle = AllocateHandle(lengthInBytes); - return new UnmanagedMemoryHandle(handle, lengthInBytes); + return new(handle, lengthInBytes); } private static IntPtr AllocateHandle(int lengthInBytes) @@ -84,7 +84,7 @@ private static IntPtr AllocateHandle(int lengthInBytes) counter++; Interlocked.Increment(ref totalOomRetries); - Interlocked.CompareExchange(ref lowMemoryMonitor, new object(), null); + Interlocked.CompareExchange(ref lowMemoryMonitor, new(), null); Monitor.Enter(lowMemoryMonitor); Monitor.Wait(lowMemoryMonitor, millisecondsTimeout: 1); Monitor.Exit(lowMemoryMonitor); diff --git a/src/ImageSharp/Memory/Allocators/UniformUnmanagedMemoryPoolMemoryAllocator.cs b/src/ImageSharp/Memory/Allocators/UniformUnmanagedMemoryPoolMemoryAllocator.cs index 621073a3db..203a5df695 100644 --- a/src/ImageSharp/Memory/Allocators/UniformUnmanagedMemoryPoolMemoryAllocator.cs +++ b/src/ImageSharp/Memory/Allocators/UniformUnmanagedMemoryPoolMemoryAllocator.cs @@ -67,8 +67,8 @@ internal UniformUnmanagedMemoryPoolMemoryAllocator( this.poolBufferSizeInBytes = poolBufferSizeInBytes; this.poolCapacity = (int)(maxPoolSizeInBytes / poolBufferSizeInBytes); this.trimSettings = trimSettings; - this.pool = new UniformUnmanagedMemoryPool(this.poolBufferSizeInBytes, this.poolCapacity, this.trimSettings); - this.nonPoolAllocator = new UnmanagedMemoryAllocator(unmanagedBufferSizeInBytes); + this.pool = new(this.poolBufferSizeInBytes, this.poolCapacity, this.trimSettings); + this.nonPoolAllocator = new(unmanagedBufferSizeInBytes); } // This delegate allows overriding the method returning the available system memory, @@ -96,7 +96,7 @@ public override IMemoryOwner Allocate( if (lengthInBytes <= (ulong)this.sharedArrayPoolThresholdInBytes) { - var buffer = new SharedArrayPoolBuffer(length); + SharedArrayPoolBuffer buffer = new(length); if (options.Has(AllocationOptions.Clean)) { buffer.GetSpan().Clear(); @@ -127,7 +127,7 @@ internal override MemoryGroup AllocateGroupCore( { if (totalLengthInBytes <= this.sharedArrayPoolThresholdInBytes) { - var buffer = new SharedArrayPoolBuffer((int)totalLengthInElements); + SharedArrayPoolBuffer buffer = new((int)totalLengthInElements); return MemoryGroup.CreateContiguous(buffer, options.Has(AllocationOptions.Clean)); } diff --git a/src/ImageSharp/Memory/Allocators/UnmanagedMemoryAllocator.cs b/src/ImageSharp/Memory/Allocators/UnmanagedMemoryAllocator.cs index da202aa596..daf1a79925 100644 --- a/src/ImageSharp/Memory/Allocators/UnmanagedMemoryAllocator.cs +++ b/src/ImageSharp/Memory/Allocators/UnmanagedMemoryAllocator.cs @@ -20,7 +20,7 @@ internal class UnmanagedMemoryAllocator : MemoryAllocator public override IMemoryOwner Allocate(int length, AllocationOptions options = AllocationOptions.None) { - var buffer = UnmanagedBuffer.Allocate(length); + UnmanagedBuffer buffer = UnmanagedBuffer.Allocate(length); if (options.Has(AllocationOptions.Clean)) { buffer.GetSpan().Clear(); diff --git a/src/ImageSharp/Memory/Buffer2DExtensions.cs b/src/ImageSharp/Memory/Buffer2DExtensions.cs index 2eb05ea935..2a0474c5f3 100644 --- a/src/ImageSharp/Memory/Buffer2DExtensions.cs +++ b/src/ImageSharp/Memory/Buffer2DExtensions.cs @@ -74,7 +74,7 @@ internal static unsafe void DangerousCopyColumns( internal static Rectangle FullRectangle(this Buffer2D buffer) where T : struct { - return new Rectangle(0, 0, buffer.Width, buffer.Height); + return new(0, 0, buffer.Width, buffer.Height); } /// @@ -86,11 +86,11 @@ internal static Rectangle FullRectangle(this Buffer2D buffer) /// The internal static Buffer2DRegion GetRegion(this Buffer2D buffer, Rectangle rectangle) where T : unmanaged => - new Buffer2DRegion(buffer, rectangle); + new(buffer, rectangle); internal static Buffer2DRegion GetRegion(this Buffer2D buffer, int x, int y, int width, int height) where T : unmanaged => - new Buffer2DRegion(buffer, new Rectangle(x, y, width, height)); + new(buffer, new(x, y, width, height)); /// /// Return a to the whole area of 'buffer' @@ -100,7 +100,7 @@ internal static Buffer2DRegion GetRegion(this Buffer2D buffer, int x, i /// The internal static Buffer2DRegion GetRegion(this Buffer2D buffer) where T : unmanaged => - new Buffer2DRegion(buffer); + new(buffer); /// /// Returns the size of the buffer. diff --git a/src/ImageSharp/Memory/Buffer2DRegion{T}.cs b/src/ImageSharp/Memory/Buffer2DRegion{T}.cs index 033b0a25a6..c628bfd856 100644 --- a/src/ImageSharp/Memory/Buffer2DRegion{T}.cs +++ b/src/ImageSharp/Memory/Buffer2DRegion{T}.cs @@ -107,7 +107,7 @@ public Span DangerousGetRowSpan(int y) [MethodImpl(MethodImplOptions.AggressiveInlining)] public Buffer2DRegion GetSubRegion(int x, int y, int width, int height) { - var rectangle = new Rectangle(x, y, width, height); + Rectangle rectangle = new(x, y, width, height); return this.GetSubRegion(rectangle); } @@ -124,8 +124,8 @@ public Buffer2DRegion GetSubRegion(Rectangle rectangle) int x = this.Rectangle.X + rectangle.X; int y = this.Rectangle.Y + rectangle.Y; - rectangle = new Rectangle(x, y, rectangle.Width, rectangle.Height); - return new Buffer2DRegion(this.Buffer, rectangle); + rectangle = new(x, y, rectangle.Width, rectangle.Height); + return new(this.Buffer, rectangle); } /// diff --git a/src/ImageSharp/Memory/ByteMemoryOwner{T}.cs b/src/ImageSharp/Memory/ByteMemoryOwner{T}.cs index bc71751412..91525e5ade 100644 --- a/src/ImageSharp/Memory/ByteMemoryOwner{T}.cs +++ b/src/ImageSharp/Memory/ByteMemoryOwner{T}.cs @@ -24,7 +24,7 @@ internal sealed class ByteMemoryOwner : IMemoryOwner public ByteMemoryOwner(IMemoryOwner memoryOwner) { this.memoryOwner = memoryOwner; - this.memoryManager = new ByteMemoryManager(memoryOwner.Memory); + this.memoryManager = new(memoryOwner.Memory); } /// diff --git a/src/ImageSharp/Memory/DiscontiguousBuffers/MemoryGroupExtensions.cs b/src/ImageSharp/Memory/DiscontiguousBuffers/MemoryGroupExtensions.cs index b4b1ffc6f4..c52b722bed 100644 --- a/src/ImageSharp/Memory/DiscontiguousBuffers/MemoryGroupExtensions.cs +++ b/src/ImageSharp/Memory/DiscontiguousBuffers/MemoryGroupExtensions.cs @@ -72,7 +72,7 @@ internal static void CopyTo(this IMemoryGroup source, Span target) Guard.NotNull(source, nameof(source)); Guard.MustBeGreaterThanOrEqualTo(target.Length, source.TotalLength, nameof(target)); - var cur = new MemoryGroupCursor(source); + MemoryGroupCursor cur = new(source); long position = 0; while (position < source.TotalLength) { @@ -95,7 +95,7 @@ internal static void CopyTo(this ReadOnlySpan source, IMemoryGroup targ Guard.NotNull(target, nameof(target)); Guard.MustBeGreaterThanOrEqualTo(target.TotalLength, source.Length, nameof(target)); - var cur = new MemoryGroupCursor(target); + MemoryGroupCursor cur = new(target); while (!source.IsEmpty) { @@ -121,8 +121,8 @@ internal static void CopyTo(this IMemoryGroup? source, IMemoryGroup? ta } long position = 0; - var srcCur = new MemoryGroupCursor(source); - var trgCur = new MemoryGroupCursor(target); + MemoryGroupCursor srcCur = new(source); + MemoryGroupCursor trgCur = new(target); while (position < source.TotalLength) { @@ -157,8 +157,8 @@ internal static void TransformTo( } long position = 0; - var srcCur = new MemoryGroupCursor(source); - var trgCur = new MemoryGroupCursor(target); + MemoryGroupCursor srcCur = new(source); + MemoryGroupCursor trgCur = new(target); while (position < source.TotalLength) { diff --git a/src/ImageSharp/Memory/DiscontiguousBuffers/MemoryGroupView{T}.cs b/src/ImageSharp/Memory/DiscontiguousBuffers/MemoryGroupView{T}.cs index 76371e6744..a3f45c8cfd 100644 --- a/src/ImageSharp/Memory/DiscontiguousBuffers/MemoryGroupView{T}.cs +++ b/src/ImageSharp/Memory/DiscontiguousBuffers/MemoryGroupView{T}.cs @@ -31,7 +31,7 @@ public MemoryGroupView(MemoryGroup owner) for (int i = 0; i < owner.Count; i++) { - this.memoryWrappers[i] = new MemoryOwnerWrapper(this, i); + this.memoryWrappers[i] = new(this, i); } } @@ -79,7 +79,7 @@ public Memory this[int index] [MethodImpl(InliningOptions.ShortMethod)] public MemoryGroupEnumerator GetEnumerator() { - return new MemoryGroupEnumerator(this); + return new(this); } /// diff --git a/src/ImageSharp/Memory/DiscontiguousBuffers/MemoryGroup{T}.Consumed.cs b/src/ImageSharp/Memory/DiscontiguousBuffers/MemoryGroup{T}.Consumed.cs index 950e2a019e..783ab53a54 100644 --- a/src/ImageSharp/Memory/DiscontiguousBuffers/MemoryGroup{T}.Consumed.cs +++ b/src/ImageSharp/Memory/DiscontiguousBuffers/MemoryGroup{T}.Consumed.cs @@ -18,7 +18,7 @@ public Consumed(Memory[] source, int bufferLength, long totalLength) : base(bufferLength, totalLength) { this.source = source; - this.View = new MemoryGroupView(this); + this.View = new(this); } public override int Count @@ -33,7 +33,7 @@ public override int Count [MethodImpl(InliningOptions.ShortMethod)] public override MemoryGroupEnumerator GetEnumerator() { - return new MemoryGroupEnumerator(this); + return new(this); } /// diff --git a/src/ImageSharp/Memory/DiscontiguousBuffers/MemoryGroup{T}.Owned.cs b/src/ImageSharp/Memory/DiscontiguousBuffers/MemoryGroup{T}.Owned.cs index 9da0139e6e..937a1a32b9 100644 --- a/src/ImageSharp/Memory/DiscontiguousBuffers/MemoryGroup{T}.Owned.cs +++ b/src/ImageSharp/Memory/DiscontiguousBuffers/MemoryGroup{T}.Owned.cs @@ -23,7 +23,7 @@ public Owned(IMemoryOwner[] memoryOwners, int bufferLength, long totalLength, { this.memoryOwners = memoryOwners; this.Swappable = swappable; - this.View = new MemoryGroupView(this); + this.View = new(this); this.memoryGroupSpanCache = MemoryGroupSpanCache.Create(memoryOwners); } @@ -66,14 +66,14 @@ private static IMemoryOwner[] CreateBuffers( int sizeOfLastBuffer, AllocationOptions options) { - var result = new IMemoryOwner[pooledBuffers.Length]; + IMemoryOwner[] result = new IMemoryOwner[pooledBuffers.Length]; for (int i = 0; i < pooledBuffers.Length - 1; i++) { - var currentBuffer = ObservedBuffer.Create(pooledBuffers[i], bufferLength, options); + ObservedBuffer currentBuffer = ObservedBuffer.Create(pooledBuffers[i], bufferLength, options); result[i] = currentBuffer; } - var lastBuffer = ObservedBuffer.Create(pooledBuffers[pooledBuffers.Length - 1], sizeOfLastBuffer, options); + ObservedBuffer lastBuffer = ObservedBuffer.Create(pooledBuffers[pooledBuffers.Length - 1], sizeOfLastBuffer, options); result[result.Length - 1] = lastBuffer; return result; } @@ -124,7 +124,7 @@ public override void DecreaseRefCounts() public override void RecreateViewAfterSwap() { this.View.Invalidate(); - this.View = new MemoryGroupView(this); + this.View = new(this); } /// @@ -193,7 +193,7 @@ public static ObservedBuffer Create( int lengthInElements, AllocationOptions options) { - var buffer = new ObservedBuffer(handle, lengthInElements); + ObservedBuffer buffer = new(handle, lengthInElements); if (options.Has(AllocationOptions.Clean)) { buffer.GetSpan().Clear(); @@ -212,7 +212,7 @@ protected override void Dispose(bool disposing) public override unsafe MemoryHandle Pin(int elementIndex = 0) { void* pbData = Unsafe.Add(this.handle.Pointer, elementIndex); - return new MemoryHandle(pbData); + return new(pbData); } public override void Unpin() diff --git a/src/ImageSharp/Memory/DiscontiguousBuffers/MemoryGroup{T}.cs b/src/ImageSharp/Memory/DiscontiguousBuffers/MemoryGroup{T}.cs index 03c29a7231..e80e05aa17 100644 --- a/src/ImageSharp/Memory/DiscontiguousBuffers/MemoryGroup{T}.cs +++ b/src/ImageSharp/Memory/DiscontiguousBuffers/MemoryGroup{T}.cs @@ -97,7 +97,7 @@ public static MemoryGroup Allocate( if (totalLengthInElements == 0) { - var buffers0 = new IMemoryOwner[1] { allocator.Allocate(0, options) }; + IMemoryOwner[] buffers0 = [allocator.Allocate(0, options)]; return new Owned(buffers0, 0, 0, true); } @@ -120,7 +120,7 @@ public static MemoryGroup Allocate( bufferCount++; } - var buffers = new IMemoryOwner[bufferCount]; + IMemoryOwner[] buffers = new IMemoryOwner[bufferCount]; for (int i = 0; i < buffers.Length - 1; i++) { buffers[i] = allocator.Allocate(bufferLength, options); @@ -142,7 +142,7 @@ public static MemoryGroup CreateContiguous(IMemoryOwner buffer, bool clear } int length = buffer.Memory.Length; - var buffers = new IMemoryOwner[1] { buffer }; + IMemoryOwner[] buffers = [buffer]; return new Owned(buffers, length, length, true); } @@ -260,14 +260,14 @@ public unsafe Span GetRowSpanCoreUnsafe(int y, int width) case SpanCacheMode.SinglePointer: { void* start = Unsafe.Add(this.memoryGroupSpanCache.SinglePointer, y * width); - return new Span(start, width); + return new(start, width); } case SpanCacheMode.MultiPointer: { this.GetMultiBufferPosition(y, width, out int bufferIdx, out int bufferStart); void* start = Unsafe.Add(this.memoryGroupSpanCache.MultiPointer[bufferIdx], bufferStart); - return new Span(start, width); + return new(start, width); } default: diff --git a/src/ImageSharp/Memory/MemoryAllocatorExtensions.cs b/src/ImageSharp/Memory/MemoryAllocatorExtensions.cs index ff306e1e45..8178ca818d 100644 --- a/src/ImageSharp/Memory/MemoryAllocatorExtensions.cs +++ b/src/ImageSharp/Memory/MemoryAllocatorExtensions.cs @@ -41,7 +41,7 @@ public static Buffer2D Allocate2D( memoryGroup = memoryAllocator.AllocateGroup(groupLength, width, options); } - return new Buffer2D(memoryGroup, width, height); + return new(memoryGroup, width, height); } /// @@ -109,7 +109,7 @@ internal static Buffer2D Allocate2DOveraligned( groupLength, width * alignmentMultiplier, options); - return new Buffer2D(memoryGroup, width, height); + return new(memoryGroup, width, height); } /// diff --git a/src/ImageSharp/Memory/RowInterval.cs b/src/ImageSharp/Memory/RowInterval.cs index 90a88d735a..f27dc74411 100644 --- a/src/ImageSharp/Memory/RowInterval.cs +++ b/src/ImageSharp/Memory/RowInterval.cs @@ -79,7 +79,7 @@ public override bool Equals(object? obj) /// public override string ToString() => $"RowInterval [{this.Min}->{this.Max}]"; - internal RowInterval Slice(int start) => new RowInterval(this.Min + start, this.Max); + internal RowInterval Slice(int start) => new(this.Min + start, this.Max); - internal RowInterval Slice(int start, int length) => new RowInterval(this.Min + start, this.Min + start + length); + internal RowInterval Slice(int start, int length) => new(this.Min + start, this.Min + start + length); } diff --git a/src/ImageSharp/Memory/UnmanagedMemoryManager{T}.cs b/src/ImageSharp/Memory/UnmanagedMemoryManager{T}.cs index 7f3163af3d..df845dd7a8 100644 --- a/src/ImageSharp/Memory/UnmanagedMemoryManager{T}.cs +++ b/src/ImageSharp/Memory/UnmanagedMemoryManager{T}.cs @@ -42,13 +42,13 @@ protected override void Dispose(bool disposing) /// public override Span GetSpan() { - return new Span(this.pointer, this.length); + return new(this.pointer, this.length); } /// public override MemoryHandle Pin(int elementIndex = 0) { - return new MemoryHandle(((T*)this.pointer) + elementIndex, pinnable: this); + return new(((T*)this.pointer) + elementIndex, pinnable: this); } /// diff --git a/src/ImageSharp/Metadata/Profiles/Exif/ExifConstants.cs b/src/ImageSharp/Metadata/Profiles/Exif/ExifConstants.cs index 725533ea5f..df6f7bdf83 100644 --- a/src/ImageSharp/Metadata/Profiles/Exif/ExifConstants.cs +++ b/src/ImageSharp/Metadata/Profiles/Exif/ExifConstants.cs @@ -7,21 +7,21 @@ namespace SixLabors.ImageSharp.Metadata.Profiles.Exif; internal static class ExifConstants { - public static ReadOnlySpan LittleEndianByteOrderMarker => new byte[] - { + public static ReadOnlySpan LittleEndianByteOrderMarker => + [ (byte)'I', (byte)'I', 0x2A, - 0x00, - }; + 0x00 + ]; - public static ReadOnlySpan BigEndianByteOrderMarker => new byte[] - { + public static ReadOnlySpan BigEndianByteOrderMarker => + [ (byte)'M', (byte)'M', 0x00, 0x2A - }; + ]; // UTF-8 is better than ASCII, UTF-8 encodes the ASCII codes the same way public static Encoding DefaultEncoding => Encoding.UTF8; diff --git a/src/ImageSharp/Metadata/Profiles/Exif/ExifEncodedStringHelpers.cs b/src/ImageSharp/Metadata/Profiles/Exif/ExifEncodedStringHelpers.cs index e9f46731c8..3ed9e5d7f8 100644 --- a/src/ImageSharp/Metadata/Profiles/Exif/ExifEncodedStringHelpers.cs +++ b/src/ImageSharp/Metadata/Profiles/Exif/ExifEncodedStringHelpers.cs @@ -16,13 +16,13 @@ internal static class ExifEncodedStringHelpers private const ulong UnicodeCode = 0x_45_44_4F_43_49_4E_55; private const ulong UndefinedCode = 0x_00_00_00_00_00_00_00_00; - private static ReadOnlySpan AsciiCodeBytes => new byte[] { 0x41, 0x53, 0x43, 0x49, 0x49, 0, 0, 0 }; + private static ReadOnlySpan AsciiCodeBytes => [0x41, 0x53, 0x43, 0x49, 0x49, 0, 0, 0]; - private static ReadOnlySpan JISCodeBytes => new byte[] { 0x4A, 0x49, 0x53, 0, 0, 0, 0, 0 }; + private static ReadOnlySpan JISCodeBytes => [0x4A, 0x49, 0x53, 0, 0, 0, 0, 0]; - private static ReadOnlySpan UnicodeCodeBytes => new byte[] { 0x55, 0x4E, 0x49, 0x43, 0x4F, 0x44, 0x45, 0 }; + private static ReadOnlySpan UnicodeCodeBytes => [0x55, 0x4E, 0x49, 0x43, 0x4F, 0x44, 0x45, 0]; - private static ReadOnlySpan UndefinedCodeBytes => new byte[] { 0, 0, 0, 0, 0, 0, 0, 0 }; + private static ReadOnlySpan UndefinedCodeBytes => [0, 0, 0, 0, 0, 0, 0, 0]; // 20932 EUC-JP Japanese (JIS 0208-1990 and 0212-1990) // https://docs.microsoft.com/en-us/dotnet/api/system.text.encoding?view=net-6.0 @@ -64,7 +64,7 @@ public static bool TryParse(ReadOnlySpan buffer, out EncodedString encoded if (TryDetect(buffer, out CharacterCode code)) { string text = GetEncoding(code).GetString(buffer[CharacterCodeBytesLength..]); - encodedString = new EncodedString(code, text); + encodedString = new(code, text); return true; } diff --git a/src/ImageSharp/Metadata/Profiles/Exif/ExifProfile.cs b/src/ImageSharp/Metadata/Profiles/Exif/ExifProfile.cs index e91a69444d..52f409b3d3 100644 --- a/src/ImageSharp/Metadata/Profiles/Exif/ExifProfile.cs +++ b/src/ImageSharp/Metadata/Profiles/Exif/ExifProfile.cs @@ -83,7 +83,7 @@ private ExifProfile(ExifProfile other) if (other.values != null) { - this.values = new List(other.Values.Count); + this.values = new(other.Values.Count); foreach (IExifValue value in other.Values) { @@ -234,7 +234,7 @@ public void SetValue(ExifTag tag, TValueType value) if (this.values.Count == 0) { - return Array.Empty(); + return []; } ExifWriter writer = new(this.values, this.Parts); @@ -349,7 +349,7 @@ private void InitializeValues() if (this.data is null) { - this.values = new List(); + this.values = []; return; } diff --git a/src/ImageSharp/Metadata/Profiles/Exif/ExifReader.cs b/src/ImageSharp/Metadata/Profiles/Exif/ExifReader.cs index a4fcd9275b..9f93d67c12 100644 --- a/src/ImageSharp/Metadata/Profiles/Exif/ExifReader.cs +++ b/src/ImageSharp/Metadata/Profiles/Exif/ExifReader.cs @@ -33,7 +33,7 @@ public ExifReader(byte[] exifData, MemoryAllocator? allocator) /// public List ReadValues() { - List values = new(); + List values = []; // II == 0x4949 this.IsBigEndian = this.ReadUInt16() != 0x4949; @@ -63,7 +63,7 @@ private void GetThumbnail(uint offset) return; } - List values = new(); + List values = []; this.ReadValues(values, offset); for (int i = 0; i < values.Count; i++) @@ -117,7 +117,8 @@ protected BaseExifReader(Stream stream, MemoryAllocator? allocator) public bool IsBigEndian { get; protected set; } - public List<(ulong Offset, ExifDataType DataType, ulong NumberOfComponents, ExifValue Exif)> BigValues { get; } = new(); + public List<(ulong Offset, ExifDataType DataType, ulong NumberOfComponents, ExifValue Exif)> BigValues { get; } = + []; protected void ReadBigValues(List values) { @@ -504,10 +505,10 @@ private void Add(IList values, ExifValue exif, object? value) } private void AddInvalidTag(ExifTag tag) - => (this.invalidTags ??= new List()).Add(tag); + => (this.invalidTags ??= []).Add(tag); private void AddSubIfd(object? val) - => (this.subIfds ??= new List()).Add(Convert.ToUInt64(val, CultureInfo.InvariantCulture)); + => (this.subIfds ??= []).Add(Convert.ToUInt64(val, CultureInfo.InvariantCulture)); private void Seek(ulong pos) => this.data.Seek((long)pos, SeekOrigin.Begin); @@ -639,7 +640,7 @@ private Rational ToRational(ReadOnlySpan buffer) uint numerator = this.ConvertToUInt32(buffer[..4]); uint denominator = this.ConvertToUInt32(buffer.Slice(4, 4)); - return new Rational(numerator, denominator, false); + return new(numerator, denominator, false); } private sbyte ConvertToSignedByte(ReadOnlySpan buffer) => unchecked((sbyte)buffer[0]); @@ -666,7 +667,7 @@ private SignedRational ToSignedRational(ReadOnlySpan buffer) int numerator = this.ConvertToInt32(buffer[..4]); int denominator = this.ConvertToInt32(buffer.Slice(4, 4)); - return new SignedRational(numerator, denominator, false); + return new(numerator, denominator, false); } private short ConvertToSignedShort(ReadOnlySpan buffer) diff --git a/src/ImageSharp/Metadata/Profiles/Exif/ExifWriter.cs b/src/ImageSharp/Metadata/Profiles/Exif/ExifWriter.cs index 1d2dca8700..d81c24ed7e 100644 --- a/src/ImageSharp/Metadata/Profiles/Exif/ExifWriter.cs +++ b/src/ImageSharp/Metadata/Profiles/Exif/ExifWriter.cs @@ -55,7 +55,7 @@ public byte[] GetData() if (length == 0) { - return Array.Empty(); + return []; } // two bytes for the byte Order marker 'II' or 'MM', followed by the number 42 (0x2A) and a 0, making 4 bytes total @@ -197,7 +197,7 @@ private static int WriteInt32(int value, Span destination, int offset) private List GetPartValues(ExifParts part) { - List result = new(); + List result = []; if (!EnumUtils.HasFlag(this.allowedParts, part)) { @@ -332,7 +332,7 @@ private int WriteData(uint startIndex, List values, Span desti private int WriteHeaders(List values, Span destination, int offset) { - this.dataOffsets = new List(); + this.dataOffsets = []; int newOffset = WriteUInt16((ushort)values.Count, destination, offset); diff --git a/src/ImageSharp/Metadata/Profiles/Exif/Tags/ExifTag.Byte.cs b/src/ImageSharp/Metadata/Profiles/Exif/Tags/ExifTag.Byte.cs index 9ee2cf2f45..ff74ecd19d 100644 --- a/src/ImageSharp/Metadata/Profiles/Exif/Tags/ExifTag.Byte.cs +++ b/src/ImageSharp/Metadata/Profiles/Exif/Tags/ExifTag.Byte.cs @@ -9,15 +9,15 @@ public abstract partial class ExifTag /// /// Gets the FaxProfile exif tag. /// - public static ExifTag FaxProfile { get; } = new ExifTag(ExifTagValue.FaxProfile); + public static ExifTag FaxProfile { get; } = new(ExifTagValue.FaxProfile); /// /// Gets the ModeNumber exif tag. /// - public static ExifTag ModeNumber { get; } = new ExifTag(ExifTagValue.ModeNumber); + public static ExifTag ModeNumber { get; } = new(ExifTagValue.ModeNumber); /// /// Gets the GPSAltitudeRef exif tag. /// - public static ExifTag GPSAltitudeRef { get; } = new ExifTag(ExifTagValue.GPSAltitudeRef); + public static ExifTag GPSAltitudeRef { get; } = new(ExifTagValue.GPSAltitudeRef); } diff --git a/src/ImageSharp/Metadata/Profiles/Exif/Tags/ExifTag.ByteArray.cs b/src/ImageSharp/Metadata/Profiles/Exif/Tags/ExifTag.ByteArray.cs index 00a9056d34..64d8e14371 100644 --- a/src/ImageSharp/Metadata/Profiles/Exif/Tags/ExifTag.ByteArray.cs +++ b/src/ImageSharp/Metadata/Profiles/Exif/Tags/ExifTag.ByteArray.cs @@ -9,40 +9,40 @@ public abstract partial class ExifTag /// /// Gets the ClipPath exif tag. /// - public static ExifTag ClipPath => new ExifTag(ExifTagValue.ClipPath); + public static ExifTag ClipPath => new(ExifTagValue.ClipPath); /// /// Gets the VersionYear exif tag. /// - public static ExifTag VersionYear => new ExifTag(ExifTagValue.VersionYear); + public static ExifTag VersionYear => new(ExifTagValue.VersionYear); /// /// Gets the XMP exif tag. /// - public static ExifTag XMP => new ExifTag(ExifTagValue.XMP); + public static ExifTag XMP => new(ExifTagValue.XMP); /// /// Gets the IPTC exif tag. /// - public static ExifTag IPTC => new ExifTag(ExifTagValue.IPTC); + public static ExifTag IPTC => new(ExifTagValue.IPTC); /// /// Gets the IccProfile exif tag. /// - public static ExifTag IccProfile => new ExifTag(ExifTagValue.IccProfile); + public static ExifTag IccProfile => new(ExifTagValue.IccProfile); /// /// Gets the CFAPattern2 exif tag. /// - public static ExifTag CFAPattern2 => new ExifTag(ExifTagValue.CFAPattern2); + public static ExifTag CFAPattern2 => new(ExifTagValue.CFAPattern2); /// /// Gets the TIFFEPStandardID exif tag. /// - public static ExifTag TIFFEPStandardID => new ExifTag(ExifTagValue.TIFFEPStandardID); + public static ExifTag TIFFEPStandardID => new(ExifTagValue.TIFFEPStandardID); /// /// Gets the GPSVersionID exif tag. /// - public static ExifTag GPSVersionID => new ExifTag(ExifTagValue.GPSVersionID); + public static ExifTag GPSVersionID => new(ExifTagValue.GPSVersionID); } diff --git a/src/ImageSharp/Metadata/Profiles/Exif/Tags/ExifTag.DoubleArray.cs b/src/ImageSharp/Metadata/Profiles/Exif/Tags/ExifTag.DoubleArray.cs index 91d0c97b38..fded122613 100644 --- a/src/ImageSharp/Metadata/Profiles/Exif/Tags/ExifTag.DoubleArray.cs +++ b/src/ImageSharp/Metadata/Profiles/Exif/Tags/ExifTag.DoubleArray.cs @@ -9,20 +9,20 @@ public abstract partial class ExifTag /// /// Gets the PixelScale exif tag. /// - public static ExifTag PixelScale { get; } = new ExifTag(ExifTagValue.PixelScale); + public static ExifTag PixelScale { get; } = new(ExifTagValue.PixelScale); /// /// Gets the IntergraphMatrix exif tag. /// - public static ExifTag IntergraphMatrix { get; } = new ExifTag(ExifTagValue.IntergraphMatrix); + public static ExifTag IntergraphMatrix { get; } = new(ExifTagValue.IntergraphMatrix); /// /// Gets the ModelTiePoint exif tag. /// - public static ExifTag ModelTiePoint { get; } = new ExifTag(ExifTagValue.ModelTiePoint); + public static ExifTag ModelTiePoint { get; } = new(ExifTagValue.ModelTiePoint); /// /// Gets the ModelTransform exif tag. /// - public static ExifTag ModelTransform { get; } = new ExifTag(ExifTagValue.ModelTransform); + public static ExifTag ModelTransform { get; } = new(ExifTagValue.ModelTransform); } diff --git a/src/ImageSharp/Metadata/Profiles/Exif/Tags/ExifTag.EncodedString.cs b/src/ImageSharp/Metadata/Profiles/Exif/Tags/ExifTag.EncodedString.cs index 4b53ba6360..4cac0d0cab 100644 --- a/src/ImageSharp/Metadata/Profiles/Exif/Tags/ExifTag.EncodedString.cs +++ b/src/ImageSharp/Metadata/Profiles/Exif/Tags/ExifTag.EncodedString.cs @@ -9,15 +9,15 @@ public abstract partial class ExifTag /// /// Gets the UserComment exif tag. /// - public static ExifTag UserComment { get; } = new ExifTag(ExifTagValue.UserComment); + public static ExifTag UserComment { get; } = new(ExifTagValue.UserComment); /// /// Gets the GPSProcessingMethod exif tag. /// - public static ExifTag GPSProcessingMethod { get; } = new ExifTag(ExifTagValue.GPSProcessingMethod); + public static ExifTag GPSProcessingMethod { get; } = new(ExifTagValue.GPSProcessingMethod); /// /// Gets the GPSAreaInformation exif tag. /// - public static ExifTag GPSAreaInformation { get; } = new ExifTag(ExifTagValue.GPSAreaInformation); + public static ExifTag GPSAreaInformation { get; } = new(ExifTagValue.GPSAreaInformation); } diff --git a/src/ImageSharp/Metadata/Profiles/Exif/Tags/ExifTag.Long.cs b/src/ImageSharp/Metadata/Profiles/Exif/Tags/ExifTag.Long.cs index f6c7c8ea73..5f9dfb4cde 100644 --- a/src/ImageSharp/Metadata/Profiles/Exif/Tags/ExifTag.Long.cs +++ b/src/ImageSharp/Metadata/Profiles/Exif/Tags/ExifTag.Long.cs @@ -9,105 +9,105 @@ public abstract partial class ExifTag /// /// Gets the SubfileType exif tag. /// - public static ExifTag SubfileType { get; } = new ExifTag(ExifTagValue.SubfileType); + public static ExifTag SubfileType { get; } = new(ExifTagValue.SubfileType); /// /// Gets the SubIFDOffset exif tag. /// - public static ExifTag SubIFDOffset { get; } = new ExifTag(ExifTagValue.SubIFDOffset); + public static ExifTag SubIFDOffset { get; } = new(ExifTagValue.SubIFDOffset); /// /// Gets the GPSIFDOffset exif tag. /// - public static ExifTag GPSIFDOffset { get; } = new ExifTag(ExifTagValue.GPSIFDOffset); + public static ExifTag GPSIFDOffset { get; } = new(ExifTagValue.GPSIFDOffset); /// /// Gets the T4Options exif tag. /// - public static ExifTag T4Options { get; } = new ExifTag(ExifTagValue.T4Options); + public static ExifTag T4Options { get; } = new(ExifTagValue.T4Options); /// /// Gets the T6Options exif tag. /// - public static ExifTag T6Options { get; } = new ExifTag(ExifTagValue.T6Options); + public static ExifTag T6Options { get; } = new(ExifTagValue.T6Options); /// /// Gets the XClipPathUnits exif tag. /// - public static ExifTag XClipPathUnits { get; } = new ExifTag(ExifTagValue.XClipPathUnits); + public static ExifTag XClipPathUnits { get; } = new(ExifTagValue.XClipPathUnits); /// /// Gets the YClipPathUnits exif tag. /// - public static ExifTag YClipPathUnits { get; } = new ExifTag(ExifTagValue.YClipPathUnits); + public static ExifTag YClipPathUnits { get; } = new(ExifTagValue.YClipPathUnits); /// /// Gets the ProfileType exif tag. /// - public static ExifTag ProfileType { get; } = new ExifTag(ExifTagValue.ProfileType); + public static ExifTag ProfileType { get; } = new(ExifTagValue.ProfileType); /// /// Gets the CodingMethods exif tag. /// - public static ExifTag CodingMethods { get; } = new ExifTag(ExifTagValue.CodingMethods); + public static ExifTag CodingMethods { get; } = new(ExifTagValue.CodingMethods); /// /// Gets the T82ptions exif tag. /// - public static ExifTag T82ptions { get; } = new ExifTag(ExifTagValue.T82ptions); + public static ExifTag T82ptions { get; } = new(ExifTagValue.T82ptions); /// /// Gets the JPEGInterchangeFormat exif tag. /// - public static ExifTag JPEGInterchangeFormat { get; } = new ExifTag(ExifTagValue.JPEGInterchangeFormat); + public static ExifTag JPEGInterchangeFormat { get; } = new(ExifTagValue.JPEGInterchangeFormat); /// /// Gets the JPEGInterchangeFormatLength exif tag. /// - public static ExifTag JPEGInterchangeFormatLength { get; } = new ExifTag(ExifTagValue.JPEGInterchangeFormatLength); + public static ExifTag JPEGInterchangeFormatLength { get; } = new(ExifTagValue.JPEGInterchangeFormatLength); /// /// Gets the MDFileTag exif tag. /// - public static ExifTag MDFileTag { get; } = new ExifTag(ExifTagValue.MDFileTag); + public static ExifTag MDFileTag { get; } = new(ExifTagValue.MDFileTag); /// /// Gets the StandardOutputSensitivity exif tag. /// - public static ExifTag StandardOutputSensitivity { get; } = new ExifTag(ExifTagValue.StandardOutputSensitivity); + public static ExifTag StandardOutputSensitivity { get; } = new(ExifTagValue.StandardOutputSensitivity); /// /// Gets the RecommendedExposureIndex exif tag. /// - public static ExifTag RecommendedExposureIndex { get; } = new ExifTag(ExifTagValue.RecommendedExposureIndex); + public static ExifTag RecommendedExposureIndex { get; } = new(ExifTagValue.RecommendedExposureIndex); /// /// Gets the ISOSpeed exif tag. /// - public static ExifTag ISOSpeed { get; } = new ExifTag(ExifTagValue.ISOSpeed); + public static ExifTag ISOSpeed { get; } = new(ExifTagValue.ISOSpeed); /// /// Gets the ISOSpeedLatitudeyyy exif tag. /// - public static ExifTag ISOSpeedLatitudeyyy { get; } = new ExifTag(ExifTagValue.ISOSpeedLatitudeyyy); + public static ExifTag ISOSpeedLatitudeyyy { get; } = new(ExifTagValue.ISOSpeedLatitudeyyy); /// /// Gets the ISOSpeedLatitudezzz exif tag. /// - public static ExifTag ISOSpeedLatitudezzz { get; } = new ExifTag(ExifTagValue.ISOSpeedLatitudezzz); + public static ExifTag ISOSpeedLatitudezzz { get; } = new(ExifTagValue.ISOSpeedLatitudezzz); /// /// Gets the FaxRecvParams exif tag. /// - public static ExifTag FaxRecvParams { get; } = new ExifTag(ExifTagValue.FaxRecvParams); + public static ExifTag FaxRecvParams { get; } = new(ExifTagValue.FaxRecvParams); /// /// Gets the FaxRecvTime exif tag. /// - public static ExifTag FaxRecvTime { get; } = new ExifTag(ExifTagValue.FaxRecvTime); + public static ExifTag FaxRecvTime { get; } = new(ExifTagValue.FaxRecvTime); /// /// Gets the ImageNumber exif tag. /// - public static ExifTag ImageNumber { get; } = new ExifTag(ExifTagValue.ImageNumber); + public static ExifTag ImageNumber { get; } = new(ExifTagValue.ImageNumber); } diff --git a/src/ImageSharp/Metadata/Profiles/Exif/Tags/ExifTag.LongArray.cs b/src/ImageSharp/Metadata/Profiles/Exif/Tags/ExifTag.LongArray.cs index 4767ca852e..e6821651ac 100644 --- a/src/ImageSharp/Metadata/Profiles/Exif/Tags/ExifTag.LongArray.cs +++ b/src/ImageSharp/Metadata/Profiles/Exif/Tags/ExifTag.LongArray.cs @@ -9,55 +9,55 @@ public abstract partial class ExifTag /// /// Gets the FreeOffsets exif tag. /// - public static ExifTag FreeOffsets { get; } = new ExifTag(ExifTagValue.FreeOffsets); + public static ExifTag FreeOffsets { get; } = new(ExifTagValue.FreeOffsets); /// /// Gets the FreeByteCounts exif tag. /// - public static ExifTag FreeByteCounts { get; } = new ExifTag(ExifTagValue.FreeByteCounts); + public static ExifTag FreeByteCounts { get; } = new(ExifTagValue.FreeByteCounts); /// /// Gets the ColorResponseUnit exif tag. /// - public static ExifTag ColorResponseUnit { get; } = new ExifTag(ExifTagValue.ColorResponseUnit); + public static ExifTag ColorResponseUnit { get; } = new(ExifTagValue.ColorResponseUnit); /// /// Gets the SMinSampleValue exif tag. /// - public static ExifTag SMinSampleValue { get; } = new ExifTag(ExifTagValue.SMinSampleValue); + public static ExifTag SMinSampleValue { get; } = new(ExifTagValue.SMinSampleValue); /// /// Gets the SMaxSampleValue exif tag. /// - public static ExifTag SMaxSampleValue { get; } = new ExifTag(ExifTagValue.SMaxSampleValue); + public static ExifTag SMaxSampleValue { get; } = new(ExifTagValue.SMaxSampleValue); /// /// Gets the JPEGQTables exif tag. /// - public static ExifTag JPEGQTables { get; } = new ExifTag(ExifTagValue.JPEGQTables); + public static ExifTag JPEGQTables { get; } = new(ExifTagValue.JPEGQTables); /// /// Gets the JPEGDCTables exif tag. /// - public static ExifTag JPEGDCTables { get; } = new ExifTag(ExifTagValue.JPEGDCTables); + public static ExifTag JPEGDCTables { get; } = new(ExifTagValue.JPEGDCTables); /// /// Gets the JPEGACTables exif tag. /// - public static ExifTag JPEGACTables { get; } = new ExifTag(ExifTagValue.JPEGACTables); + public static ExifTag JPEGACTables { get; } = new(ExifTagValue.JPEGACTables); /// /// Gets the StripRowCounts exif tag. /// - public static ExifTag StripRowCounts { get; } = new ExifTag(ExifTagValue.StripRowCounts); + public static ExifTag StripRowCounts { get; } = new(ExifTagValue.StripRowCounts); /// /// Gets the IntergraphRegisters exif tag. /// - public static ExifTag IntergraphRegisters { get; } = new ExifTag(ExifTagValue.IntergraphRegisters); + public static ExifTag IntergraphRegisters { get; } = new(ExifTagValue.IntergraphRegisters); /// /// Gets the offset to child IFDs exif tag. /// - public static ExifTag SubIFDs { get; } = new ExifTag(ExifTagValue.SubIFDs); + public static ExifTag SubIFDs { get; } = new(ExifTagValue.SubIFDs); } diff --git a/src/ImageSharp/Metadata/Profiles/Exif/Tags/ExifTag.Number.cs b/src/ImageSharp/Metadata/Profiles/Exif/Tags/ExifTag.Number.cs index 2018e4cea0..e023beeb7a 100644 --- a/src/ImageSharp/Metadata/Profiles/Exif/Tags/ExifTag.Number.cs +++ b/src/ImageSharp/Metadata/Profiles/Exif/Tags/ExifTag.Number.cs @@ -9,45 +9,45 @@ public abstract partial class ExifTag /// /// Gets the ImageWidth exif tag. /// - public static ExifTag ImageWidth { get; } = new ExifTag(ExifTagValue.ImageWidth); + public static ExifTag ImageWidth { get; } = new(ExifTagValue.ImageWidth); /// /// Gets the ImageLength exif tag. /// - public static ExifTag ImageLength { get; } = new ExifTag(ExifTagValue.ImageLength); + public static ExifTag ImageLength { get; } = new(ExifTagValue.ImageLength); /// /// Gets the RowsPerStrip exif tag. /// - public static ExifTag RowsPerStrip { get; } = new ExifTag(ExifTagValue.RowsPerStrip); + public static ExifTag RowsPerStrip { get; } = new(ExifTagValue.RowsPerStrip); /// /// Gets the TileWidth exif tag. /// - public static ExifTag TileWidth { get; } = new ExifTag(ExifTagValue.TileWidth); + public static ExifTag TileWidth { get; } = new(ExifTagValue.TileWidth); /// /// Gets the TileLength exif tag. /// - public static ExifTag TileLength { get; } = new ExifTag(ExifTagValue.TileLength); + public static ExifTag TileLength { get; } = new(ExifTagValue.TileLength); /// /// Gets the BadFaxLines exif tag. /// - public static ExifTag BadFaxLines { get; } = new ExifTag(ExifTagValue.BadFaxLines); + public static ExifTag BadFaxLines { get; } = new(ExifTagValue.BadFaxLines); /// /// Gets the ConsecutiveBadFaxLines exif tag. /// - public static ExifTag ConsecutiveBadFaxLines { get; } = new ExifTag(ExifTagValue.ConsecutiveBadFaxLines); + public static ExifTag ConsecutiveBadFaxLines { get; } = new(ExifTagValue.ConsecutiveBadFaxLines); /// /// Gets the PixelXDimension exif tag. /// - public static ExifTag PixelXDimension { get; } = new ExifTag(ExifTagValue.PixelXDimension); + public static ExifTag PixelXDimension { get; } = new(ExifTagValue.PixelXDimension); /// /// Gets the PixelYDimension exif tag. /// - public static ExifTag PixelYDimension { get; } = new ExifTag(ExifTagValue.PixelYDimension); + public static ExifTag PixelYDimension { get; } = new(ExifTagValue.PixelYDimension); } diff --git a/src/ImageSharp/Metadata/Profiles/Exif/Tags/ExifTag.NumberArray.cs b/src/ImageSharp/Metadata/Profiles/Exif/Tags/ExifTag.NumberArray.cs index cd89681413..6a7438fc6e 100644 --- a/src/ImageSharp/Metadata/Profiles/Exif/Tags/ExifTag.NumberArray.cs +++ b/src/ImageSharp/Metadata/Profiles/Exif/Tags/ExifTag.NumberArray.cs @@ -9,25 +9,25 @@ public abstract partial class ExifTag /// /// Gets the StripOffsets exif tag. /// - public static ExifTag StripOffsets { get; } = new ExifTag(ExifTagValue.StripOffsets); + public static ExifTag StripOffsets { get; } = new(ExifTagValue.StripOffsets); /// /// Gets the StripByteCounts exif tag. /// - public static ExifTag StripByteCounts { get; } = new ExifTag(ExifTagValue.StripByteCounts); + public static ExifTag StripByteCounts { get; } = new(ExifTagValue.StripByteCounts); /// /// Gets the TileByteCounts exif tag. /// - public static ExifTag TileByteCounts { get; } = new ExifTag(ExifTagValue.TileByteCounts); + public static ExifTag TileByteCounts { get; } = new(ExifTagValue.TileByteCounts); /// /// Gets the TileOffsets exif tag. /// - public static ExifTag TileOffsets { get; } = new ExifTag(ExifTagValue.TileOffsets); + public static ExifTag TileOffsets { get; } = new(ExifTagValue.TileOffsets); /// /// Gets the ImageLayer exif tag. /// - public static ExifTag ImageLayer { get; } = new ExifTag(ExifTagValue.ImageLayer); + public static ExifTag ImageLayer { get; } = new(ExifTagValue.ImageLayer); } diff --git a/src/ImageSharp/Metadata/Profiles/Exif/Tags/ExifTag.Rational.cs b/src/ImageSharp/Metadata/Profiles/Exif/Tags/ExifTag.Rational.cs index e4fe13fe57..02526ac34d 100644 --- a/src/ImageSharp/Metadata/Profiles/Exif/Tags/ExifTag.Rational.cs +++ b/src/ImageSharp/Metadata/Profiles/Exif/Tags/ExifTag.Rational.cs @@ -9,165 +9,165 @@ public abstract partial class ExifTag /// /// Gets the XPosition exif tag. /// - public static ExifTag XPosition { get; } = new ExifTag(ExifTagValue.XPosition); + public static ExifTag XPosition { get; } = new(ExifTagValue.XPosition); /// /// Gets the YPosition exif tag. /// - public static ExifTag YPosition { get; } = new ExifTag(ExifTagValue.YPosition); + public static ExifTag YPosition { get; } = new(ExifTagValue.YPosition); /// /// Gets the XResolution exif tag. /// - public static ExifTag XResolution { get; } = new ExifTag(ExifTagValue.XResolution); + public static ExifTag XResolution { get; } = new(ExifTagValue.XResolution); /// /// Gets the YResolution exif tag. /// - public static ExifTag YResolution { get; } = new ExifTag(ExifTagValue.YResolution); + public static ExifTag YResolution { get; } = new(ExifTagValue.YResolution); /// /// Gets the BatteryLevel exif tag. /// - public static ExifTag BatteryLevel { get; } = new ExifTag(ExifTagValue.BatteryLevel); + public static ExifTag BatteryLevel { get; } = new(ExifTagValue.BatteryLevel); /// /// Gets the ExposureTime exif tag. /// - public static ExifTag ExposureTime { get; } = new ExifTag(ExifTagValue.ExposureTime); + public static ExifTag ExposureTime { get; } = new(ExifTagValue.ExposureTime); /// /// Gets the FNumber exif tag. /// - public static ExifTag FNumber { get; } = new ExifTag(ExifTagValue.FNumber); + public static ExifTag FNumber { get; } = new(ExifTagValue.FNumber); /// /// Gets the MDScalePixel exif tag. /// - public static ExifTag MDScalePixel { get; } = new ExifTag(ExifTagValue.MDScalePixel); + public static ExifTag MDScalePixel { get; } = new(ExifTagValue.MDScalePixel); /// /// Gets the CompressedBitsPerPixel exif tag. /// - public static ExifTag CompressedBitsPerPixel { get; } = new ExifTag(ExifTagValue.CompressedBitsPerPixel); + public static ExifTag CompressedBitsPerPixel { get; } = new(ExifTagValue.CompressedBitsPerPixel); /// /// Gets the ApertureValue exif tag. /// - public static ExifTag ApertureValue { get; } = new ExifTag(ExifTagValue.ApertureValue); + public static ExifTag ApertureValue { get; } = new(ExifTagValue.ApertureValue); /// /// Gets the MaxApertureValue exif tag. /// - public static ExifTag MaxApertureValue { get; } = new ExifTag(ExifTagValue.MaxApertureValue); + public static ExifTag MaxApertureValue { get; } = new(ExifTagValue.MaxApertureValue); /// /// Gets the SubjectDistance exif tag. /// - public static ExifTag SubjectDistance { get; } = new ExifTag(ExifTagValue.SubjectDistance); + public static ExifTag SubjectDistance { get; } = new(ExifTagValue.SubjectDistance); /// /// Gets the FocalLength exif tag. /// - public static ExifTag FocalLength { get; } = new ExifTag(ExifTagValue.FocalLength); + public static ExifTag FocalLength { get; } = new(ExifTagValue.FocalLength); /// /// Gets the FlashEnergy2 exif tag. /// - public static ExifTag FlashEnergy2 { get; } = new ExifTag(ExifTagValue.FlashEnergy2); + public static ExifTag FlashEnergy2 { get; } = new(ExifTagValue.FlashEnergy2); /// /// Gets the FocalPlaneXResolution2 exif tag. /// - public static ExifTag FocalPlaneXResolution2 { get; } = new ExifTag(ExifTagValue.FocalPlaneXResolution2); + public static ExifTag FocalPlaneXResolution2 { get; } = new(ExifTagValue.FocalPlaneXResolution2); /// /// Gets the FocalPlaneYResolution2 exif tag. /// - public static ExifTag FocalPlaneYResolution2 { get; } = new ExifTag(ExifTagValue.FocalPlaneYResolution2); + public static ExifTag FocalPlaneYResolution2 { get; } = new(ExifTagValue.FocalPlaneYResolution2); /// /// Gets the ExposureIndex2 exif tag. /// - public static ExifTag ExposureIndex2 { get; } = new ExifTag(ExifTagValue.ExposureIndex2); + public static ExifTag ExposureIndex2 { get; } = new(ExifTagValue.ExposureIndex2); /// /// Gets the Humidity exif tag. /// - public static ExifTag Humidity { get; } = new ExifTag(ExifTagValue.Humidity); + public static ExifTag Humidity { get; } = new(ExifTagValue.Humidity); /// /// Gets the Pressure exif tag. /// - public static ExifTag Pressure { get; } = new ExifTag(ExifTagValue.Pressure); + public static ExifTag Pressure { get; } = new(ExifTagValue.Pressure); /// /// Gets the Acceleration exif tag. /// - public static ExifTag Acceleration { get; } = new ExifTag(ExifTagValue.Acceleration); + public static ExifTag Acceleration { get; } = new(ExifTagValue.Acceleration); /// /// Gets the FlashEnergy exif tag. /// - public static ExifTag FlashEnergy { get; } = new ExifTag(ExifTagValue.FlashEnergy); + public static ExifTag FlashEnergy { get; } = new(ExifTagValue.FlashEnergy); /// /// Gets the FocalPlaneXResolution exif tag. /// - public static ExifTag FocalPlaneXResolution { get; } = new ExifTag(ExifTagValue.FocalPlaneXResolution); + public static ExifTag FocalPlaneXResolution { get; } = new(ExifTagValue.FocalPlaneXResolution); /// /// Gets the FocalPlaneYResolution exif tag. /// - public static ExifTag FocalPlaneYResolution { get; } = new ExifTag(ExifTagValue.FocalPlaneYResolution); + public static ExifTag FocalPlaneYResolution { get; } = new(ExifTagValue.FocalPlaneYResolution); /// /// Gets the ExposureIndex exif tag. /// - public static ExifTag ExposureIndex { get; } = new ExifTag(ExifTagValue.ExposureIndex); + public static ExifTag ExposureIndex { get; } = new(ExifTagValue.ExposureIndex); /// /// Gets the DigitalZoomRatio exif tag. /// - public static ExifTag DigitalZoomRatio { get; } = new ExifTag(ExifTagValue.DigitalZoomRatio); + public static ExifTag DigitalZoomRatio { get; } = new(ExifTagValue.DigitalZoomRatio); /// /// Gets the GPSAltitude exif tag. /// - public static ExifTag GPSAltitude { get; } = new ExifTag(ExifTagValue.GPSAltitude); + public static ExifTag GPSAltitude { get; } = new(ExifTagValue.GPSAltitude); /// /// Gets the GPSDOP exif tag. /// - public static ExifTag GPSDOP { get; } = new ExifTag(ExifTagValue.GPSDOP); + public static ExifTag GPSDOP { get; } = new(ExifTagValue.GPSDOP); /// /// Gets the GPSSpeed exif tag. /// - public static ExifTag GPSSpeed { get; } = new ExifTag(ExifTagValue.GPSSpeed); + public static ExifTag GPSSpeed { get; } = new(ExifTagValue.GPSSpeed); /// /// Gets the GPSTrack exif tag. /// - public static ExifTag GPSTrack { get; } = new ExifTag(ExifTagValue.GPSTrack); + public static ExifTag GPSTrack { get; } = new(ExifTagValue.GPSTrack); /// /// Gets the GPSImgDirection exif tag. /// - public static ExifTag GPSImgDirection { get; } = new ExifTag(ExifTagValue.GPSImgDirection); + public static ExifTag GPSImgDirection { get; } = new(ExifTagValue.GPSImgDirection); /// /// Gets the GPSDestBearing exif tag. /// - public static ExifTag GPSDestBearing { get; } = new ExifTag(ExifTagValue.GPSDestBearing); + public static ExifTag GPSDestBearing { get; } = new(ExifTagValue.GPSDestBearing); /// /// Gets the GPSDestDistance exif tag. /// - public static ExifTag GPSDestDistance { get; } = new ExifTag(ExifTagValue.GPSDestDistance); + public static ExifTag GPSDestDistance { get; } = new(ExifTagValue.GPSDestDistance); /// /// Gets the GPSHPositioningError exif tag. /// - public static ExifTag GPSHPositioningError { get; } = new ExifTag(ExifTagValue.GPSHPositioningError); + public static ExifTag GPSHPositioningError { get; } = new(ExifTagValue.GPSHPositioningError); } diff --git a/src/ImageSharp/Metadata/Profiles/Exif/Tags/ExifTag.RationalArray.cs b/src/ImageSharp/Metadata/Profiles/Exif/Tags/ExifTag.RationalArray.cs index 8b764c3f77..4ba140441d 100644 --- a/src/ImageSharp/Metadata/Profiles/Exif/Tags/ExifTag.RationalArray.cs +++ b/src/ImageSharp/Metadata/Profiles/Exif/Tags/ExifTag.RationalArray.cs @@ -9,50 +9,50 @@ public abstract partial class ExifTag /// /// Gets the WhitePoint exif tag. /// - public static ExifTag WhitePoint { get; } = new ExifTag(ExifTagValue.WhitePoint); + public static ExifTag WhitePoint { get; } = new(ExifTagValue.WhitePoint); /// /// Gets the PrimaryChromaticities exif tag. /// - public static ExifTag PrimaryChromaticities { get; } = new ExifTag(ExifTagValue.PrimaryChromaticities); + public static ExifTag PrimaryChromaticities { get; } = new(ExifTagValue.PrimaryChromaticities); /// /// Gets the YCbCrCoefficients exif tag. /// - public static ExifTag YCbCrCoefficients { get; } = new ExifTag(ExifTagValue.YCbCrCoefficients); + public static ExifTag YCbCrCoefficients { get; } = new(ExifTagValue.YCbCrCoefficients); /// /// Gets the ReferenceBlackWhite exif tag. /// - public static ExifTag ReferenceBlackWhite { get; } = new ExifTag(ExifTagValue.ReferenceBlackWhite); + public static ExifTag ReferenceBlackWhite { get; } = new(ExifTagValue.ReferenceBlackWhite); /// /// Gets the GPSLatitude exif tag. /// - public static ExifTag GPSLatitude { get; } = new ExifTag(ExifTagValue.GPSLatitude); + public static ExifTag GPSLatitude { get; } = new(ExifTagValue.GPSLatitude); /// /// Gets the GPSLongitude exif tag. /// - public static ExifTag GPSLongitude { get; } = new ExifTag(ExifTagValue.GPSLongitude); + public static ExifTag GPSLongitude { get; } = new(ExifTagValue.GPSLongitude); /// /// Gets the GPSTimestamp exif tag. /// - public static ExifTag GPSTimestamp { get; } = new ExifTag(ExifTagValue.GPSTimestamp); + public static ExifTag GPSTimestamp { get; } = new(ExifTagValue.GPSTimestamp); /// /// Gets the GPSDestLatitude exif tag. /// - public static ExifTag GPSDestLatitude { get; } = new ExifTag(ExifTagValue.GPSDestLatitude); + public static ExifTag GPSDestLatitude { get; } = new(ExifTagValue.GPSDestLatitude); /// /// Gets the GPSDestLongitude exif tag. /// - public static ExifTag GPSDestLongitude { get; } = new ExifTag(ExifTagValue.GPSDestLongitude); + public static ExifTag GPSDestLongitude { get; } = new(ExifTagValue.GPSDestLongitude); /// /// Gets the LensSpecification exif tag. /// - public static ExifTag LensSpecification { get; } = new ExifTag(ExifTagValue.LensSpecification); + public static ExifTag LensSpecification { get; } = new(ExifTagValue.LensSpecification); } diff --git a/src/ImageSharp/Metadata/Profiles/Exif/Tags/ExifTag.Short.cs b/src/ImageSharp/Metadata/Profiles/Exif/Tags/ExifTag.Short.cs index aeeda58bb0..52972811e6 100644 --- a/src/ImageSharp/Metadata/Profiles/Exif/Tags/ExifTag.Short.cs +++ b/src/ImageSharp/Metadata/Profiles/Exif/Tags/ExifTag.Short.cs @@ -9,235 +9,235 @@ public abstract partial class ExifTag /// /// Gets the OldSubfileType exif tag. /// - public static ExifTag OldSubfileType { get; } = new ExifTag(ExifTagValue.OldSubfileType); + public static ExifTag OldSubfileType { get; } = new(ExifTagValue.OldSubfileType); /// /// Gets the Compression exif tag. /// - public static ExifTag Compression { get; } = new ExifTag(ExifTagValue.Compression); + public static ExifTag Compression { get; } = new(ExifTagValue.Compression); /// /// Gets the PhotometricInterpretation exif tag. /// - public static ExifTag PhotometricInterpretation { get; } = new ExifTag(ExifTagValue.PhotometricInterpretation); + public static ExifTag PhotometricInterpretation { get; } = new(ExifTagValue.PhotometricInterpretation); /// /// Gets the Thresholding exif tag. /// - public static ExifTag Thresholding { get; } = new ExifTag(ExifTagValue.Thresholding); + public static ExifTag Thresholding { get; } = new(ExifTagValue.Thresholding); /// /// Gets the CellWidth exif tag. /// - public static ExifTag CellWidth { get; } = new ExifTag(ExifTagValue.CellWidth); + public static ExifTag CellWidth { get; } = new(ExifTagValue.CellWidth); /// /// Gets the CellLength exif tag. /// - public static ExifTag CellLength { get; } = new ExifTag(ExifTagValue.CellLength); + public static ExifTag CellLength { get; } = new(ExifTagValue.CellLength); /// /// Gets the FillOrder exif tag. /// - public static ExifTag FillOrder { get; } = new ExifTag(ExifTagValue.FillOrder); + public static ExifTag FillOrder { get; } = new(ExifTagValue.FillOrder); /// /// Gets the Orientation exif tag. /// - public static ExifTag Orientation { get; } = new ExifTag(ExifTagValue.Orientation); + public static ExifTag Orientation { get; } = new(ExifTagValue.Orientation); /// /// Gets the SamplesPerPixel exif tag. /// - public static ExifTag SamplesPerPixel { get; } = new ExifTag(ExifTagValue.SamplesPerPixel); + public static ExifTag SamplesPerPixel { get; } = new(ExifTagValue.SamplesPerPixel); /// /// Gets the PlanarConfiguration exif tag. /// - public static ExifTag PlanarConfiguration { get; } = new ExifTag(ExifTagValue.PlanarConfiguration); + public static ExifTag PlanarConfiguration { get; } = new(ExifTagValue.PlanarConfiguration); /// /// Gets the Predictor exif tag. /// - public static ExifTag Predictor { get; } = new ExifTag(ExifTagValue.Predictor); + public static ExifTag Predictor { get; } = new(ExifTagValue.Predictor); /// /// Gets the GrayResponseUnit exif tag. /// - public static ExifTag GrayResponseUnit { get; } = new ExifTag(ExifTagValue.GrayResponseUnit); + public static ExifTag GrayResponseUnit { get; } = new(ExifTagValue.GrayResponseUnit); /// /// Gets the ResolutionUnit exif tag. /// - public static ExifTag ResolutionUnit { get; } = new ExifTag(ExifTagValue.ResolutionUnit); + public static ExifTag ResolutionUnit { get; } = new(ExifTagValue.ResolutionUnit); /// /// Gets the CleanFaxData exif tag. /// - public static ExifTag CleanFaxData { get; } = new ExifTag(ExifTagValue.CleanFaxData); + public static ExifTag CleanFaxData { get; } = new(ExifTagValue.CleanFaxData); /// /// Gets the InkSet exif tag. /// - public static ExifTag InkSet { get; } = new ExifTag(ExifTagValue.InkSet); + public static ExifTag InkSet { get; } = new(ExifTagValue.InkSet); /// /// Gets the NumberOfInks exif tag. /// - public static ExifTag NumberOfInks { get; } = new ExifTag(ExifTagValue.NumberOfInks); + public static ExifTag NumberOfInks { get; } = new(ExifTagValue.NumberOfInks); /// /// Gets the DotRange exif tag. /// - public static ExifTag DotRange { get; } = new ExifTag(ExifTagValue.DotRange); + public static ExifTag DotRange { get; } = new(ExifTagValue.DotRange); /// /// Gets the Indexed exif tag. /// - public static ExifTag Indexed { get; } = new ExifTag(ExifTagValue.Indexed); + public static ExifTag Indexed { get; } = new(ExifTagValue.Indexed); /// /// Gets the OPIProxy exif tag. /// - public static ExifTag OPIProxy { get; } = new ExifTag(ExifTagValue.OPIProxy); + public static ExifTag OPIProxy { get; } = new(ExifTagValue.OPIProxy); /// /// Gets the JPEGProc exif tag. /// - public static ExifTag JPEGProc { get; } = new ExifTag(ExifTagValue.JPEGProc); + public static ExifTag JPEGProc { get; } = new(ExifTagValue.JPEGProc); /// /// Gets the JPEGRestartInterval exif tag. /// - public static ExifTag JPEGRestartInterval { get; } = new ExifTag(ExifTagValue.JPEGRestartInterval); + public static ExifTag JPEGRestartInterval { get; } = new(ExifTagValue.JPEGRestartInterval); /// /// Gets the YCbCrPositioning exif tag. /// - public static ExifTag YCbCrPositioning { get; } = new ExifTag(ExifTagValue.YCbCrPositioning); + public static ExifTag YCbCrPositioning { get; } = new(ExifTagValue.YCbCrPositioning); /// /// Gets the Rating exif tag. /// - public static ExifTag Rating { get; } = new ExifTag(ExifTagValue.Rating); + public static ExifTag Rating { get; } = new(ExifTagValue.Rating); /// /// Gets the RatingPercent exif tag. /// - public static ExifTag RatingPercent { get; } = new ExifTag(ExifTagValue.RatingPercent); + public static ExifTag RatingPercent { get; } = new(ExifTagValue.RatingPercent); /// /// Gets the ExposureProgram exif tag. /// - public static ExifTag ExposureProgram { get; } = new ExifTag(ExifTagValue.ExposureProgram); + public static ExifTag ExposureProgram { get; } = new(ExifTagValue.ExposureProgram); /// /// Gets the Interlace exif tag. /// - public static ExifTag Interlace { get; } = new ExifTag(ExifTagValue.Interlace); + public static ExifTag Interlace { get; } = new(ExifTagValue.Interlace); /// /// Gets the SelfTimerMode exif tag. /// - public static ExifTag SelfTimerMode { get; } = new ExifTag(ExifTagValue.SelfTimerMode); + public static ExifTag SelfTimerMode { get; } = new(ExifTagValue.SelfTimerMode); /// /// Gets the SensitivityType exif tag. /// - public static ExifTag SensitivityType { get; } = new ExifTag(ExifTagValue.SensitivityType); + public static ExifTag SensitivityType { get; } = new(ExifTagValue.SensitivityType); /// /// Gets the MeteringMode exif tag. /// - public static ExifTag MeteringMode { get; } = new ExifTag(ExifTagValue.MeteringMode); + public static ExifTag MeteringMode { get; } = new(ExifTagValue.MeteringMode); /// /// Gets the LightSource exif tag. /// - public static ExifTag LightSource { get; } = new ExifTag(ExifTagValue.LightSource); + public static ExifTag LightSource { get; } = new(ExifTagValue.LightSource); /// /// Gets the FocalPlaneResolutionUnit2 exif tag. /// - public static ExifTag FocalPlaneResolutionUnit2 { get; } = new ExifTag(ExifTagValue.FocalPlaneResolutionUnit2); + public static ExifTag FocalPlaneResolutionUnit2 { get; } = new(ExifTagValue.FocalPlaneResolutionUnit2); /// /// Gets the SensingMethod2 exif tag. /// - public static ExifTag SensingMethod2 { get; } = new ExifTag(ExifTagValue.SensingMethod2); + public static ExifTag SensingMethod2 { get; } = new(ExifTagValue.SensingMethod2); /// /// Gets the Flash exif tag. /// - public static ExifTag Flash { get; } = new ExifTag(ExifTagValue.Flash); + public static ExifTag Flash { get; } = new(ExifTagValue.Flash); /// /// Gets the ColorSpace exif tag. /// - public static ExifTag ColorSpace { get; } = new ExifTag(ExifTagValue.ColorSpace); + public static ExifTag ColorSpace { get; } = new(ExifTagValue.ColorSpace); /// /// Gets the FocalPlaneResolutionUnit exif tag. /// - public static ExifTag FocalPlaneResolutionUnit { get; } = new ExifTag(ExifTagValue.FocalPlaneResolutionUnit); + public static ExifTag FocalPlaneResolutionUnit { get; } = new(ExifTagValue.FocalPlaneResolutionUnit); /// /// Gets the SensingMethod exif tag. /// - public static ExifTag SensingMethod { get; } = new ExifTag(ExifTagValue.SensingMethod); + public static ExifTag SensingMethod { get; } = new(ExifTagValue.SensingMethod); /// /// Gets the CustomRendered exif tag. /// - public static ExifTag CustomRendered { get; } = new ExifTag(ExifTagValue.CustomRendered); + public static ExifTag CustomRendered { get; } = new(ExifTagValue.CustomRendered); /// /// Gets the ExposureMode exif tag. /// - public static ExifTag ExposureMode { get; } = new ExifTag(ExifTagValue.ExposureMode); + public static ExifTag ExposureMode { get; } = new(ExifTagValue.ExposureMode); /// /// Gets the WhiteBalance exif tag. /// - public static ExifTag WhiteBalance { get; } = new ExifTag(ExifTagValue.WhiteBalance); + public static ExifTag WhiteBalance { get; } = new(ExifTagValue.WhiteBalance); /// /// Gets the FocalLengthIn35mmFilm exif tag. /// - public static ExifTag FocalLengthIn35mmFilm { get; } = new ExifTag(ExifTagValue.FocalLengthIn35mmFilm); + public static ExifTag FocalLengthIn35mmFilm { get; } = new(ExifTagValue.FocalLengthIn35mmFilm); /// /// Gets the SceneCaptureType exif tag. /// - public static ExifTag SceneCaptureType { get; } = new ExifTag(ExifTagValue.SceneCaptureType); + public static ExifTag SceneCaptureType { get; } = new(ExifTagValue.SceneCaptureType); /// /// Gets the GainControl exif tag. /// - public static ExifTag GainControl { get; } = new ExifTag(ExifTagValue.GainControl); + public static ExifTag GainControl { get; } = new(ExifTagValue.GainControl); /// /// Gets the Contrast exif tag. /// - public static ExifTag Contrast { get; } = new ExifTag(ExifTagValue.Contrast); + public static ExifTag Contrast { get; } = new(ExifTagValue.Contrast); /// /// Gets the Saturation exif tag. /// - public static ExifTag Saturation { get; } = new ExifTag(ExifTagValue.Saturation); + public static ExifTag Saturation { get; } = new(ExifTagValue.Saturation); /// /// Gets the Sharpness exif tag. /// - public static ExifTag Sharpness { get; } = new ExifTag(ExifTagValue.Sharpness); + public static ExifTag Sharpness { get; } = new(ExifTagValue.Sharpness); /// /// Gets the SubjectDistanceRange exif tag. /// - public static ExifTag SubjectDistanceRange { get; } = new ExifTag(ExifTagValue.SubjectDistanceRange); + public static ExifTag SubjectDistanceRange { get; } = new(ExifTagValue.SubjectDistanceRange); /// /// Gets the GPSDifferential exif tag. /// - public static ExifTag GPSDifferential { get; } = new ExifTag(ExifTagValue.GPSDifferential); + public static ExifTag GPSDifferential { get; } = new(ExifTagValue.GPSDifferential); } diff --git a/src/ImageSharp/Metadata/Profiles/Exif/Tags/ExifTag.ShortArray.cs b/src/ImageSharp/Metadata/Profiles/Exif/Tags/ExifTag.ShortArray.cs index dc708c50f1..55e65517f1 100644 --- a/src/ImageSharp/Metadata/Profiles/Exif/Tags/ExifTag.ShortArray.cs +++ b/src/ImageSharp/Metadata/Profiles/Exif/Tags/ExifTag.ShortArray.cs @@ -9,100 +9,100 @@ public abstract partial class ExifTag /// /// Gets the BitsPerSample exif tag. /// - public static ExifTag BitsPerSample { get; } = new ExifTag(ExifTagValue.BitsPerSample); + public static ExifTag BitsPerSample { get; } = new(ExifTagValue.BitsPerSample); /// /// Gets the MinSampleValue exif tag. /// - public static ExifTag MinSampleValue { get; } = new ExifTag(ExifTagValue.MinSampleValue); + public static ExifTag MinSampleValue { get; } = new(ExifTagValue.MinSampleValue); /// /// Gets the MaxSampleValue exif tag. /// - public static ExifTag MaxSampleValue { get; } = new ExifTag(ExifTagValue.MaxSampleValue); + public static ExifTag MaxSampleValue { get; } = new(ExifTagValue.MaxSampleValue); /// /// Gets the GrayResponseCurve exif tag. /// - public static ExifTag GrayResponseCurve { get; } = new ExifTag(ExifTagValue.GrayResponseCurve); + public static ExifTag GrayResponseCurve { get; } = new(ExifTagValue.GrayResponseCurve); /// /// Gets the ColorMap exif tag. /// - public static ExifTag ColorMap { get; } = new ExifTag(ExifTagValue.ColorMap); + public static ExifTag ColorMap { get; } = new(ExifTagValue.ColorMap); /// /// Gets the ExtraSamples exif tag. /// - public static ExifTag ExtraSamples { get; } = new ExifTag(ExifTagValue.ExtraSamples); + public static ExifTag ExtraSamples { get; } = new(ExifTagValue.ExtraSamples); /// /// Gets the PageNumber exif tag. /// - public static ExifTag PageNumber { get; } = new ExifTag(ExifTagValue.PageNumber); + public static ExifTag PageNumber { get; } = new(ExifTagValue.PageNumber); /// /// Gets the TransferFunction exif tag. /// - public static ExifTag TransferFunction { get; } = new ExifTag(ExifTagValue.TransferFunction); + public static ExifTag TransferFunction { get; } = new(ExifTagValue.TransferFunction); /// /// Gets the HalftoneHints exif tag. /// - public static ExifTag HalftoneHints { get; } = new ExifTag(ExifTagValue.HalftoneHints); + public static ExifTag HalftoneHints { get; } = new(ExifTagValue.HalftoneHints); /// /// Gets the SampleFormat exif tag. /// - public static ExifTag SampleFormat { get; } = new ExifTag(ExifTagValue.SampleFormat); + public static ExifTag SampleFormat { get; } = new(ExifTagValue.SampleFormat); /// /// Gets the TransferRange exif tag. /// - public static ExifTag TransferRange { get; } = new ExifTag(ExifTagValue.TransferRange); + public static ExifTag TransferRange { get; } = new(ExifTagValue.TransferRange); /// /// Gets the DefaultImageColor exif tag. /// - public static ExifTag DefaultImageColor { get; } = new ExifTag(ExifTagValue.DefaultImageColor); + public static ExifTag DefaultImageColor { get; } = new(ExifTagValue.DefaultImageColor); /// /// Gets the JPEGLosslessPredictors exif tag. /// - public static ExifTag JPEGLosslessPredictors { get; } = new ExifTag(ExifTagValue.JPEGLosslessPredictors); + public static ExifTag JPEGLosslessPredictors { get; } = new(ExifTagValue.JPEGLosslessPredictors); /// /// Gets the JPEGPointTransforms exif tag. /// - public static ExifTag JPEGPointTransforms { get; } = new ExifTag(ExifTagValue.JPEGPointTransforms); + public static ExifTag JPEGPointTransforms { get; } = new(ExifTagValue.JPEGPointTransforms); /// /// Gets the YCbCrSubsampling exif tag. /// - public static ExifTag YCbCrSubsampling { get; } = new ExifTag(ExifTagValue.YCbCrSubsampling); + public static ExifTag YCbCrSubsampling { get; } = new(ExifTagValue.YCbCrSubsampling); /// /// Gets the CFARepeatPatternDim exif tag. /// - public static ExifTag CFARepeatPatternDim { get; } = new ExifTag(ExifTagValue.CFARepeatPatternDim); + public static ExifTag CFARepeatPatternDim { get; } = new(ExifTagValue.CFARepeatPatternDim); /// /// Gets the IntergraphPacketData exif tag. /// - public static ExifTag IntergraphPacketData { get; } = new ExifTag(ExifTagValue.IntergraphPacketData); + public static ExifTag IntergraphPacketData { get; } = new(ExifTagValue.IntergraphPacketData); /// /// Gets the ISOSpeedRatings exif tag. /// - public static ExifTag ISOSpeedRatings { get; } = new ExifTag(ExifTagValue.ISOSpeedRatings); + public static ExifTag ISOSpeedRatings { get; } = new(ExifTagValue.ISOSpeedRatings); /// /// Gets the SubjectArea exif tag. /// - public static ExifTag SubjectArea { get; } = new ExifTag(ExifTagValue.SubjectArea); + public static ExifTag SubjectArea { get; } = new(ExifTagValue.SubjectArea); /// /// Gets the SubjectLocation exif tag. /// - public static ExifTag SubjectLocation { get; } = new ExifTag(ExifTagValue.SubjectLocation); + public static ExifTag SubjectLocation { get; } = new(ExifTagValue.SubjectLocation); } diff --git a/src/ImageSharp/Metadata/Profiles/Exif/Tags/ExifTag.SignedRational.cs b/src/ImageSharp/Metadata/Profiles/Exif/Tags/ExifTag.SignedRational.cs index d645b5176a..8fbbba2177 100644 --- a/src/ImageSharp/Metadata/Profiles/Exif/Tags/ExifTag.SignedRational.cs +++ b/src/ImageSharp/Metadata/Profiles/Exif/Tags/ExifTag.SignedRational.cs @@ -9,30 +9,30 @@ public abstract partial class ExifTag /// /// Gets the ShutterSpeedValue exif tag. /// - public static ExifTag ShutterSpeedValue { get; } = new ExifTag(ExifTagValue.ShutterSpeedValue); + public static ExifTag ShutterSpeedValue { get; } = new(ExifTagValue.ShutterSpeedValue); /// /// Gets the BrightnessValue exif tag. /// - public static ExifTag BrightnessValue { get; } = new ExifTag(ExifTagValue.BrightnessValue); + public static ExifTag BrightnessValue { get; } = new(ExifTagValue.BrightnessValue); /// /// Gets the ExposureBiasValue exif tag. /// - public static ExifTag ExposureBiasValue { get; } = new ExifTag(ExifTagValue.ExposureBiasValue); + public static ExifTag ExposureBiasValue { get; } = new(ExifTagValue.ExposureBiasValue); /// /// Gets the AmbientTemperature exif tag. /// - public static ExifTag AmbientTemperature { get; } = new ExifTag(ExifTagValue.AmbientTemperature); + public static ExifTag AmbientTemperature { get; } = new(ExifTagValue.AmbientTemperature); /// /// Gets the WaterDepth exif tag. /// - public static ExifTag WaterDepth { get; } = new ExifTag(ExifTagValue.WaterDepth); + public static ExifTag WaterDepth { get; } = new(ExifTagValue.WaterDepth); /// /// Gets the CameraElevationAngle exif tag. /// - public static ExifTag CameraElevationAngle { get; } = new ExifTag(ExifTagValue.CameraElevationAngle); + public static ExifTag CameraElevationAngle { get; } = new(ExifTagValue.CameraElevationAngle); } diff --git a/src/ImageSharp/Metadata/Profiles/Exif/Tags/ExifTag.SignedRationalArray.cs b/src/ImageSharp/Metadata/Profiles/Exif/Tags/ExifTag.SignedRationalArray.cs index ef1e8afea4..a27108f8a0 100644 --- a/src/ImageSharp/Metadata/Profiles/Exif/Tags/ExifTag.SignedRationalArray.cs +++ b/src/ImageSharp/Metadata/Profiles/Exif/Tags/ExifTag.SignedRationalArray.cs @@ -9,5 +9,5 @@ public abstract partial class ExifTag /// /// Gets the Decode exif tag. /// - public static ExifTag Decode { get; } = new ExifTag(ExifTagValue.Decode); + public static ExifTag Decode { get; } = new(ExifTagValue.Decode); } diff --git a/src/ImageSharp/Metadata/Profiles/Exif/Tags/ExifTag.SignedShortArray.cs b/src/ImageSharp/Metadata/Profiles/Exif/Tags/ExifTag.SignedShortArray.cs index d6a9205143..0868426987 100644 --- a/src/ImageSharp/Metadata/Profiles/Exif/Tags/ExifTag.SignedShortArray.cs +++ b/src/ImageSharp/Metadata/Profiles/Exif/Tags/ExifTag.SignedShortArray.cs @@ -9,5 +9,5 @@ public abstract partial class ExifTag /// /// Gets the TimeZoneOffset exif tag. /// - public static ExifTag TimeZoneOffset { get; } = new ExifTag(ExifTagValue.TimeZoneOffset); + public static ExifTag TimeZoneOffset { get; } = new(ExifTagValue.TimeZoneOffset); } diff --git a/src/ImageSharp/Metadata/Profiles/Exif/Tags/ExifTag.String.cs b/src/ImageSharp/Metadata/Profiles/Exif/Tags/ExifTag.String.cs index 498dad3ebb..688403a65a 100644 --- a/src/ImageSharp/Metadata/Profiles/Exif/Tags/ExifTag.String.cs +++ b/src/ImageSharp/Metadata/Profiles/Exif/Tags/ExifTag.String.cs @@ -9,270 +9,270 @@ public abstract partial class ExifTag /// /// Gets the ImageDescription exif tag. /// - public static ExifTag ImageDescription { get; } = new ExifTag(ExifTagValue.ImageDescription); + public static ExifTag ImageDescription { get; } = new(ExifTagValue.ImageDescription); /// /// Gets the Make exif tag. /// - public static ExifTag Make { get; } = new ExifTag(ExifTagValue.Make); + public static ExifTag Make { get; } = new(ExifTagValue.Make); /// /// Gets the Model exif tag. /// - public static ExifTag Model { get; } = new ExifTag(ExifTagValue.Model); + public static ExifTag Model { get; } = new(ExifTagValue.Model); /// /// Gets the Software exif tag. /// - public static ExifTag Software { get; } = new ExifTag(ExifTagValue.Software); + public static ExifTag Software { get; } = new(ExifTagValue.Software); /// /// Gets the DateTime exif tag. /// - public static ExifTag DateTime { get; } = new ExifTag(ExifTagValue.DateTime); + public static ExifTag DateTime { get; } = new(ExifTagValue.DateTime); /// /// Gets the Artist exif tag. /// - public static ExifTag Artist { get; } = new ExifTag(ExifTagValue.Artist); + public static ExifTag Artist { get; } = new(ExifTagValue.Artist); /// /// Gets the HostComputer exif tag. /// - public static ExifTag HostComputer { get; } = new ExifTag(ExifTagValue.HostComputer); + public static ExifTag HostComputer { get; } = new(ExifTagValue.HostComputer); /// /// Gets the Copyright exif tag. /// - public static ExifTag Copyright { get; } = new ExifTag(ExifTagValue.Copyright); + public static ExifTag Copyright { get; } = new(ExifTagValue.Copyright); /// /// Gets the DocumentName exif tag. /// - public static ExifTag DocumentName { get; } = new ExifTag(ExifTagValue.DocumentName); + public static ExifTag DocumentName { get; } = new(ExifTagValue.DocumentName); /// /// Gets the PageName exif tag. /// - public static ExifTag PageName { get; } = new ExifTag(ExifTagValue.PageName); + public static ExifTag PageName { get; } = new(ExifTagValue.PageName); /// /// Gets the InkNames exif tag. /// - public static ExifTag InkNames { get; } = new ExifTag(ExifTagValue.InkNames); + public static ExifTag InkNames { get; } = new(ExifTagValue.InkNames); /// /// Gets the TargetPrinter exif tag. /// - public static ExifTag TargetPrinter { get; } = new ExifTag(ExifTagValue.TargetPrinter); + public static ExifTag TargetPrinter { get; } = new(ExifTagValue.TargetPrinter); /// /// Gets the ImageID exif tag. /// - public static ExifTag ImageID { get; } = new ExifTag(ExifTagValue.ImageID); + public static ExifTag ImageID { get; } = new(ExifTagValue.ImageID); /// /// Gets the MDLabName exif tag. /// - public static ExifTag MDLabName { get; } = new ExifTag(ExifTagValue.MDLabName); + public static ExifTag MDLabName { get; } = new(ExifTagValue.MDLabName); /// /// Gets the MDSampleInfo exif tag. /// - public static ExifTag MDSampleInfo { get; } = new ExifTag(ExifTagValue.MDSampleInfo); + public static ExifTag MDSampleInfo { get; } = new(ExifTagValue.MDSampleInfo); /// /// Gets the MDPrepDate exif tag. /// - public static ExifTag MDPrepDate { get; } = new ExifTag(ExifTagValue.MDPrepDate); + public static ExifTag MDPrepDate { get; } = new(ExifTagValue.MDPrepDate); /// /// Gets the MDPrepTime exif tag. /// - public static ExifTag MDPrepTime { get; } = new ExifTag(ExifTagValue.MDPrepTime); + public static ExifTag MDPrepTime { get; } = new(ExifTagValue.MDPrepTime); /// /// Gets the MDFileUnits exif tag. /// - public static ExifTag MDFileUnits { get; } = new ExifTag(ExifTagValue.MDFileUnits); + public static ExifTag MDFileUnits { get; } = new(ExifTagValue.MDFileUnits); /// /// Gets the SEMInfo exif tag. /// - public static ExifTag SEMInfo { get; } = new ExifTag(ExifTagValue.SEMInfo); + public static ExifTag SEMInfo { get; } = new(ExifTagValue.SEMInfo); /// /// Gets the SpectralSensitivity exif tag. /// - public static ExifTag SpectralSensitivity { get; } = new ExifTag(ExifTagValue.SpectralSensitivity); + public static ExifTag SpectralSensitivity { get; } = new(ExifTagValue.SpectralSensitivity); /// /// Gets the DateTimeOriginal exif tag. /// - public static ExifTag DateTimeOriginal { get; } = new ExifTag(ExifTagValue.DateTimeOriginal); + public static ExifTag DateTimeOriginal { get; } = new(ExifTagValue.DateTimeOriginal); /// /// Gets the DateTimeDigitized exif tag. /// - public static ExifTag DateTimeDigitized { get; } = new ExifTag(ExifTagValue.DateTimeDigitized); + public static ExifTag DateTimeDigitized { get; } = new(ExifTagValue.DateTimeDigitized); /// /// Gets the SubsecTime exif tag. /// - public static ExifTag SubsecTime { get; } = new ExifTag(ExifTagValue.SubsecTime); + public static ExifTag SubsecTime { get; } = new(ExifTagValue.SubsecTime); /// /// Gets the SubsecTimeOriginal exif tag. /// - public static ExifTag SubsecTimeOriginal { get; } = new ExifTag(ExifTagValue.SubsecTimeOriginal); + public static ExifTag SubsecTimeOriginal { get; } = new(ExifTagValue.SubsecTimeOriginal); /// /// Gets the SubsecTimeDigitized exif tag. /// - public static ExifTag SubsecTimeDigitized { get; } = new ExifTag(ExifTagValue.SubsecTimeDigitized); + public static ExifTag SubsecTimeDigitized { get; } = new(ExifTagValue.SubsecTimeDigitized); /// /// Gets the RelatedSoundFile exif tag. /// - public static ExifTag RelatedSoundFile { get; } = new ExifTag(ExifTagValue.RelatedSoundFile); + public static ExifTag RelatedSoundFile { get; } = new(ExifTagValue.RelatedSoundFile); /// /// Gets the FaxSubaddress exif tag. /// - public static ExifTag FaxSubaddress { get; } = new ExifTag(ExifTagValue.FaxSubaddress); + public static ExifTag FaxSubaddress { get; } = new(ExifTagValue.FaxSubaddress); /// /// Gets the OffsetTime exif tag. /// - public static ExifTag OffsetTime { get; } = new ExifTag(ExifTagValue.OffsetTime); + public static ExifTag OffsetTime { get; } = new(ExifTagValue.OffsetTime); /// /// Gets the OffsetTimeOriginal exif tag. /// - public static ExifTag OffsetTimeOriginal { get; } = new ExifTag(ExifTagValue.OffsetTimeOriginal); + public static ExifTag OffsetTimeOriginal { get; } = new(ExifTagValue.OffsetTimeOriginal); /// /// Gets the OffsetTimeDigitized exif tag. /// - public static ExifTag OffsetTimeDigitized { get; } = new ExifTag(ExifTagValue.OffsetTimeDigitized); + public static ExifTag OffsetTimeDigitized { get; } = new(ExifTagValue.OffsetTimeDigitized); /// /// Gets the SecurityClassification exif tag. /// - public static ExifTag SecurityClassification { get; } = new ExifTag(ExifTagValue.SecurityClassification); + public static ExifTag SecurityClassification { get; } = new(ExifTagValue.SecurityClassification); /// /// Gets the ImageHistory exif tag. /// - public static ExifTag ImageHistory { get; } = new ExifTag(ExifTagValue.ImageHistory); + public static ExifTag ImageHistory { get; } = new(ExifTagValue.ImageHistory); /// /// Gets the ImageUniqueID exif tag. /// - public static ExifTag ImageUniqueID { get; } = new ExifTag(ExifTagValue.ImageUniqueID); + public static ExifTag ImageUniqueID { get; } = new(ExifTagValue.ImageUniqueID); /// /// Gets the OwnerName exif tag. /// - public static ExifTag OwnerName { get; } = new ExifTag(ExifTagValue.OwnerName); + public static ExifTag OwnerName { get; } = new(ExifTagValue.OwnerName); /// /// Gets the SerialNumber exif tag. /// - public static ExifTag SerialNumber { get; } = new ExifTag(ExifTagValue.SerialNumber); + public static ExifTag SerialNumber { get; } = new(ExifTagValue.SerialNumber); /// /// Gets the LensMake exif tag. /// - public static ExifTag LensMake { get; } = new ExifTag(ExifTagValue.LensMake); + public static ExifTag LensMake { get; } = new(ExifTagValue.LensMake); /// /// Gets the LensModel exif tag. /// - public static ExifTag LensModel { get; } = new ExifTag(ExifTagValue.LensModel); + public static ExifTag LensModel { get; } = new(ExifTagValue.LensModel); /// /// Gets the LensSerialNumber exif tag. /// - public static ExifTag LensSerialNumber { get; } = new ExifTag(ExifTagValue.LensSerialNumber); + public static ExifTag LensSerialNumber { get; } = new(ExifTagValue.LensSerialNumber); /// /// Gets the GDALMetadata exif tag. /// - public static ExifTag GDALMetadata { get; } = new ExifTag(ExifTagValue.GDALMetadata); + public static ExifTag GDALMetadata { get; } = new(ExifTagValue.GDALMetadata); /// /// Gets the GDALNoData exif tag. /// - public static ExifTag GDALNoData { get; } = new ExifTag(ExifTagValue.GDALNoData); + public static ExifTag GDALNoData { get; } = new(ExifTagValue.GDALNoData); /// /// Gets the GPSLatitudeRef exif tag. /// - public static ExifTag GPSLatitudeRef { get; } = new ExifTag(ExifTagValue.GPSLatitudeRef); + public static ExifTag GPSLatitudeRef { get; } = new(ExifTagValue.GPSLatitudeRef); /// /// Gets the GPSLongitudeRef exif tag. /// - public static ExifTag GPSLongitudeRef { get; } = new ExifTag(ExifTagValue.GPSLongitudeRef); + public static ExifTag GPSLongitudeRef { get; } = new(ExifTagValue.GPSLongitudeRef); /// /// Gets the GPSSatellites exif tag. /// - public static ExifTag GPSSatellites { get; } = new ExifTag(ExifTagValue.GPSSatellites); + public static ExifTag GPSSatellites { get; } = new(ExifTagValue.GPSSatellites); /// /// Gets the GPSStatus exif tag. /// - public static ExifTag GPSStatus { get; } = new ExifTag(ExifTagValue.GPSStatus); + public static ExifTag GPSStatus { get; } = new(ExifTagValue.GPSStatus); /// /// Gets the GPSMeasureMode exif tag. /// - public static ExifTag GPSMeasureMode { get; } = new ExifTag(ExifTagValue.GPSMeasureMode); + public static ExifTag GPSMeasureMode { get; } = new(ExifTagValue.GPSMeasureMode); /// /// Gets the GPSSpeedRef exif tag. /// - public static ExifTag GPSSpeedRef { get; } = new ExifTag(ExifTagValue.GPSSpeedRef); + public static ExifTag GPSSpeedRef { get; } = new(ExifTagValue.GPSSpeedRef); /// /// Gets the GPSTrackRef exif tag. /// - public static ExifTag GPSTrackRef { get; } = new ExifTag(ExifTagValue.GPSTrackRef); + public static ExifTag GPSTrackRef { get; } = new(ExifTagValue.GPSTrackRef); /// /// Gets the GPSImgDirectionRef exif tag. /// - public static ExifTag GPSImgDirectionRef { get; } = new ExifTag(ExifTagValue.GPSImgDirectionRef); + public static ExifTag GPSImgDirectionRef { get; } = new(ExifTagValue.GPSImgDirectionRef); /// /// Gets the GPSMapDatum exif tag. /// - public static ExifTag GPSMapDatum { get; } = new ExifTag(ExifTagValue.GPSMapDatum); + public static ExifTag GPSMapDatum { get; } = new(ExifTagValue.GPSMapDatum); /// /// Gets the GPSDestLatitudeRef exif tag. /// - public static ExifTag GPSDestLatitudeRef { get; } = new ExifTag(ExifTagValue.GPSDestLatitudeRef); + public static ExifTag GPSDestLatitudeRef { get; } = new(ExifTagValue.GPSDestLatitudeRef); /// /// Gets the GPSDestLongitudeRef exif tag. /// - public static ExifTag GPSDestLongitudeRef { get; } = new ExifTag(ExifTagValue.GPSDestLongitudeRef); + public static ExifTag GPSDestLongitudeRef { get; } = new(ExifTagValue.GPSDestLongitudeRef); /// /// Gets the GPSDestBearingRef exif tag. /// - public static ExifTag GPSDestBearingRef { get; } = new ExifTag(ExifTagValue.GPSDestBearingRef); + public static ExifTag GPSDestBearingRef { get; } = new(ExifTagValue.GPSDestBearingRef); /// /// Gets the GPSDestDistanceRef exif tag. /// - public static ExifTag GPSDestDistanceRef { get; } = new ExifTag(ExifTagValue.GPSDestDistanceRef); + public static ExifTag GPSDestDistanceRef { get; } = new(ExifTagValue.GPSDestDistanceRef); /// /// Gets the GPSDateStamp exif tag. /// - public static ExifTag GPSDateStamp { get; } = new ExifTag(ExifTagValue.GPSDateStamp); + public static ExifTag GPSDateStamp { get; } = new(ExifTagValue.GPSDateStamp); } diff --git a/src/ImageSharp/Metadata/Profiles/Exif/Tags/ExifTag.Ucs2String.cs b/src/ImageSharp/Metadata/Profiles/Exif/Tags/ExifTag.Ucs2String.cs index 65acc4bd75..e13b3b30e4 100644 --- a/src/ImageSharp/Metadata/Profiles/Exif/Tags/ExifTag.Ucs2String.cs +++ b/src/ImageSharp/Metadata/Profiles/Exif/Tags/ExifTag.Ucs2String.cs @@ -9,25 +9,25 @@ public abstract partial class ExifTag /// /// Gets the title tag used by Windows (encoded in UCS2). /// - public static ExifTag XPTitle => new ExifTag(ExifTagValue.XPTitle); + public static ExifTag XPTitle => new(ExifTagValue.XPTitle); /// /// Gets the comment tag used by Windows (encoded in UCS2). /// - public static ExifTag XPComment => new ExifTag(ExifTagValue.XPComment); + public static ExifTag XPComment => new(ExifTagValue.XPComment); /// /// Gets the author tag used by Windows (encoded in UCS2). /// - public static ExifTag XPAuthor => new ExifTag(ExifTagValue.XPAuthor); + public static ExifTag XPAuthor => new(ExifTagValue.XPAuthor); /// /// Gets the keywords tag used by Windows (encoded in UCS2). /// - public static ExifTag XPKeywords => new ExifTag(ExifTagValue.XPKeywords); + public static ExifTag XPKeywords => new(ExifTagValue.XPKeywords); /// /// Gets the subject tag used by Windows (encoded in UCS2). /// - public static ExifTag XPSubject => new ExifTag(ExifTagValue.XPSubject); + public static ExifTag XPSubject => new(ExifTagValue.XPSubject); } diff --git a/src/ImageSharp/Metadata/Profiles/Exif/Tags/ExifTag.Undefined.cs b/src/ImageSharp/Metadata/Profiles/Exif/Tags/ExifTag.Undefined.cs index 417673b4ae..e822c2a111 100644 --- a/src/ImageSharp/Metadata/Profiles/Exif/Tags/ExifTag.Undefined.cs +++ b/src/ImageSharp/Metadata/Profiles/Exif/Tags/ExifTag.Undefined.cs @@ -9,70 +9,70 @@ public abstract partial class ExifTag /// /// Gets the JPEGTables exif tag. /// - public static ExifTag JPEGTables { get; } = new ExifTag(ExifTagValue.JPEGTables); + public static ExifTag JPEGTables { get; } = new(ExifTagValue.JPEGTables); /// /// Gets the OECF exif tag. /// - public static ExifTag OECF { get; } = new ExifTag(ExifTagValue.OECF); + public static ExifTag OECF { get; } = new(ExifTagValue.OECF); /// /// Gets the ExifVersion exif tag. /// - public static ExifTag ExifVersion { get; } = new ExifTag(ExifTagValue.ExifVersion); + public static ExifTag ExifVersion { get; } = new(ExifTagValue.ExifVersion); /// /// Gets the ComponentsConfiguration exif tag. /// - public static ExifTag ComponentsConfiguration { get; } = new ExifTag(ExifTagValue.ComponentsConfiguration); + public static ExifTag ComponentsConfiguration { get; } = new(ExifTagValue.ComponentsConfiguration); /// /// Gets the MakerNote exif tag. /// - public static ExifTag MakerNote { get; } = new ExifTag(ExifTagValue.MakerNote); + public static ExifTag MakerNote { get; } = new(ExifTagValue.MakerNote); /// /// Gets the FlashpixVersion exif tag. /// - public static ExifTag FlashpixVersion { get; } = new ExifTag(ExifTagValue.FlashpixVersion); + public static ExifTag FlashpixVersion { get; } = new(ExifTagValue.FlashpixVersion); /// /// Gets the SpatialFrequencyResponse exif tag. /// - public static ExifTag SpatialFrequencyResponse { get; } = new ExifTag(ExifTagValue.SpatialFrequencyResponse); + public static ExifTag SpatialFrequencyResponse { get; } = new(ExifTagValue.SpatialFrequencyResponse); /// /// Gets the SpatialFrequencyResponse2 exif tag. /// - public static ExifTag SpatialFrequencyResponse2 { get; } = new ExifTag(ExifTagValue.SpatialFrequencyResponse2); + public static ExifTag SpatialFrequencyResponse2 { get; } = new(ExifTagValue.SpatialFrequencyResponse2); /// /// Gets the Noise exif tag. /// - public static ExifTag Noise { get; } = new ExifTag(ExifTagValue.Noise); + public static ExifTag Noise { get; } = new(ExifTagValue.Noise); /// /// Gets the CFAPattern exif tag. /// - public static ExifTag CFAPattern { get; } = new ExifTag(ExifTagValue.CFAPattern); + public static ExifTag CFAPattern { get; } = new(ExifTagValue.CFAPattern); /// /// Gets the DeviceSettingDescription exif tag. /// - public static ExifTag DeviceSettingDescription { get; } = new ExifTag(ExifTagValue.DeviceSettingDescription); + public static ExifTag DeviceSettingDescription { get; } = new(ExifTagValue.DeviceSettingDescription); /// /// Gets the ImageSourceData exif tag. /// - public static ExifTag ImageSourceData { get; } = new ExifTag(ExifTagValue.ImageSourceData); + public static ExifTag ImageSourceData { get; } = new(ExifTagValue.ImageSourceData); /// /// Gets the FileSource exif tag. /// - public static ExifTag FileSource { get; } = new ExifTag(ExifTagValue.FileSource); + public static ExifTag FileSource { get; } = new(ExifTagValue.FileSource); /// /// Gets the ImageDescription exif tag. /// - public static ExifTag SceneType { get; } = new ExifTag(ExifTagValue.SceneType); + public static ExifTag SceneType { get; } = new(ExifTagValue.SceneType); } diff --git a/src/ImageSharp/Metadata/Profiles/Exif/Values/ExifArrayValue{TValueType}.cs b/src/ImageSharp/Metadata/Profiles/Exif/Values/ExifArrayValue{TValueType}.cs index 64b8d23137..630709beca 100644 --- a/src/ImageSharp/Metadata/Profiles/Exif/Values/ExifArrayValue{TValueType}.cs +++ b/src/ImageSharp/Metadata/Profiles/Exif/Values/ExifArrayValue{TValueType}.cs @@ -43,7 +43,7 @@ public override bool TrySetValue(object? value) if (type == typeof(TValueType)) { - this.Value = new TValueType[] { (TValueType)value }; + this.Value = [(TValueType)value]; return true; } diff --git a/src/ImageSharp/Metadata/Profiles/Exif/Values/ExifByteArray.cs b/src/ImageSharp/Metadata/Profiles/Exif/Values/ExifByteArray.cs index 6811fc6f9c..1ce261e0aa 100644 --- a/src/ImageSharp/Metadata/Profiles/Exif/Values/ExifByteArray.cs +++ b/src/ImageSharp/Metadata/Profiles/Exif/Values/ExifByteArray.cs @@ -32,7 +32,7 @@ public override bool TrySetValue(object? value) { if (intValue >= byte.MinValue && intValue <= byte.MaxValue) { - this.Value = new byte[] { (byte)intValue }; + this.Value = [(byte)intValue]; } return true; diff --git a/src/ImageSharp/Metadata/Profiles/Exif/Values/ExifEncodedString.cs b/src/ImageSharp/Metadata/Profiles/Exif/Values/ExifEncodedString.cs index cce7cf3e89..8131a48691 100644 --- a/src/ImageSharp/Metadata/Profiles/Exif/Values/ExifEncodedString.cs +++ b/src/ImageSharp/Metadata/Profiles/Exif/Values/ExifEncodedString.cs @@ -33,7 +33,7 @@ public override bool TrySetValue(object? value) if (value is string stringValue) { - this.Value = new EncodedString(stringValue); + this.Value = new(stringValue); return true; } else if (value is byte[] buffer) diff --git a/src/ImageSharp/Metadata/Profiles/Exif/Values/ExifLong8Array.cs b/src/ImageSharp/Metadata/Profiles/Exif/Values/ExifLong8Array.cs index b7756e62bd..42cc07c73d 100644 --- a/src/ImageSharp/Metadata/Profiles/Exif/Values/ExifLong8Array.cs +++ b/src/ImageSharp/Metadata/Profiles/Exif/Values/ExifLong8Array.cs @@ -96,13 +96,13 @@ public override bool TrySetValue(object? value) private bool SetSingle(ulong value) { - this.Value = new[] { value }; + this.Value = [value]; return true; } private bool SetArray(long[] values) { - var numbers = new ulong[values.Length]; + ulong[] numbers = new ulong[values.Length]; for (int i = 0; i < values.Length; i++) { numbers[i] = (ulong)(values[i] < 0 ? 0 : values[i]); @@ -120,7 +120,7 @@ private bool SetArray(ulong[] values) private bool SetArray(int[] values) { - var numbers = new ulong[values.Length]; + ulong[] numbers = new ulong[values.Length]; for (int i = 0; i < values.Length; i++) { numbers[i] = (ulong)Numerics.Clamp(values[i], 0, int.MaxValue); @@ -132,7 +132,7 @@ private bool SetArray(int[] values) private bool SetArray(uint[] values) { - var numbers = new ulong[values.Length]; + ulong[] numbers = new ulong[values.Length]; for (int i = 0; i < values.Length; i++) { numbers[i] = (ulong)values[i]; @@ -144,7 +144,7 @@ private bool SetArray(uint[] values) private bool SetArray(short[] values) { - var numbers = new ulong[values.Length]; + ulong[] numbers = new ulong[values.Length]; for (int i = 0; i < values.Length; i++) { numbers[i] = (ulong)Numerics.Clamp(values[i], 0, short.MaxValue); @@ -156,7 +156,7 @@ private bool SetArray(short[] values) private bool SetArray(ushort[] values) { - var numbers = new ulong[values.Length]; + ulong[] numbers = new ulong[values.Length]; for (int i = 0; i < values.Length; i++) { numbers[i] = (ulong)values[i]; diff --git a/src/ImageSharp/Metadata/Profiles/Exif/Values/ExifNumberArray.cs b/src/ImageSharp/Metadata/Profiles/Exif/Values/ExifNumberArray.cs index 1162c25ea9..5b1baac0fc 100644 --- a/src/ImageSharp/Metadata/Profiles/Exif/Values/ExifNumberArray.cs +++ b/src/ImageSharp/Metadata/Profiles/Exif/Values/ExifNumberArray.cs @@ -80,13 +80,13 @@ public override bool TrySetValue(object? value) private bool SetSingle(Number value) { - this.Value = new[] { value }; + this.Value = [value]; return true; } private bool SetArray(int[] values) { - var numbers = new Number[values.Length]; + Number[] numbers = new Number[values.Length]; for (int i = 0; i < values.Length; i++) { numbers[i] = values[i]; @@ -98,7 +98,7 @@ private bool SetArray(int[] values) private bool SetArray(uint[] values) { - var numbers = new Number[values.Length]; + Number[] numbers = new Number[values.Length]; for (int i = 0; i < values.Length; i++) { numbers[i] = values[i]; @@ -110,7 +110,7 @@ private bool SetArray(uint[] values) private bool SetArray(short[] values) { - var numbers = new Number[values.Length]; + Number[] numbers = new Number[values.Length]; for (int i = 0; i < values.Length; i++) { numbers[i] = values[i]; @@ -122,7 +122,7 @@ private bool SetArray(short[] values) private bool SetArray(ushort[] values) { - var numbers = new Number[values.Length]; + Number[] numbers = new Number[values.Length]; for (int i = 0; i < values.Length; i++) { numbers[i] = values[i]; diff --git a/src/ImageSharp/Metadata/Profiles/Exif/Values/ExifRational.cs b/src/ImageSharp/Metadata/Profiles/Exif/Values/ExifRational.cs index c25f0f5dc1..e5c27f60a8 100644 --- a/src/ImageSharp/Metadata/Profiles/Exif/Values/ExifRational.cs +++ b/src/ImageSharp/Metadata/Profiles/Exif/Values/ExifRational.cs @@ -39,7 +39,7 @@ public override bool TrySetValue(object? value) if (signed.Numerator >= uint.MinValue && signed.Denominator >= uint.MinValue) { - this.Value = new Rational((uint)signed.Numerator, (uint)signed.Denominator); + this.Value = new((uint)signed.Numerator, (uint)signed.Denominator); } return true; diff --git a/src/ImageSharp/Metadata/Profiles/Exif/Values/ExifRationalArray.cs b/src/ImageSharp/Metadata/Profiles/Exif/Values/ExifRationalArray.cs index ac6453edc7..4e2dc583a2 100644 --- a/src/ImageSharp/Metadata/Profiles/Exif/Values/ExifRationalArray.cs +++ b/src/ImageSharp/Metadata/Profiles/Exif/Values/ExifRationalArray.cs @@ -38,7 +38,7 @@ public override bool TrySetValue(object? value) { if (signed.Numerator >= 0 && signed.Denominator >= 0) { - this.Value = new[] { new Rational((uint)signed.Numerator, (uint)signed.Denominator) }; + this.Value = [new Rational((uint)signed.Numerator, (uint)signed.Denominator)]; } return true; @@ -56,11 +56,11 @@ private bool TrySetSignedArray(SignedRational[] signed) return false; } - var unsigned = new Rational[signed.Length]; + Rational[] unsigned = new Rational[signed.Length]; for (int i = 0; i < signed.Length; i++) { SignedRational s = signed[i]; - unsigned[i] = new Rational((uint)s.Numerator, (uint)s.Denominator); + unsigned[i] = new((uint)s.Numerator, (uint)s.Denominator); } this.Value = unsigned; diff --git a/src/ImageSharp/Metadata/Profiles/Exif/Values/ExifShortArray.cs b/src/ImageSharp/Metadata/Profiles/Exif/Values/ExifShortArray.cs index a205e77dee..74941455d6 100644 --- a/src/ImageSharp/Metadata/Profiles/Exif/Values/ExifShortArray.cs +++ b/src/ImageSharp/Metadata/Profiles/Exif/Values/ExifShortArray.cs @@ -43,7 +43,7 @@ public override bool TrySetValue(object? value) { if (signedInt >= ushort.MinValue && signedInt <= ushort.MaxValue) { - this.Value = new ushort[] { (ushort)signedInt }; + this.Value = [(ushort)signedInt]; } return true; @@ -53,7 +53,7 @@ public override bool TrySetValue(object? value) { if (signedShort >= ushort.MinValue) { - this.Value = new ushort[] { (ushort)signedShort }; + this.Value = [(ushort)signedShort]; } return true; @@ -71,7 +71,7 @@ private bool TrySetSignedIntArray(int[] signed) return false; } - var unsigned = new ushort[signed.Length]; + ushort[] unsigned = new ushort[signed.Length]; for (int i = 0; i < signed.Length; i++) { int s = signed[i]; @@ -89,7 +89,7 @@ private bool TrySetSignedShortArray(short[] signed) return false; } - var unsigned = new ushort[signed.Length]; + ushort[] unsigned = new ushort[signed.Length]; for (int i = 0; i < signed.Length; i++) { short s = signed[i]; diff --git a/src/ImageSharp/Metadata/Profiles/Exif/Values/ExifSignedShortArray.cs b/src/ImageSharp/Metadata/Profiles/Exif/Values/ExifSignedShortArray.cs index 206417f667..acc0366188 100644 --- a/src/ImageSharp/Metadata/Profiles/Exif/Values/ExifSignedShortArray.cs +++ b/src/ImageSharp/Metadata/Profiles/Exif/Values/ExifSignedShortArray.cs @@ -38,7 +38,7 @@ public override bool TrySetValue(object? value) { if (intValue >= short.MinValue && intValue <= short.MaxValue) { - this.Value = new short[] { (short)intValue }; + this.Value = [(short)intValue]; } return true; @@ -56,7 +56,7 @@ private bool TrySetSignedArray(int[] intArray) return false; } - var value = new short[intArray.Length]; + short[] value = new short[intArray.Length]; for (int i = 0; i < intArray.Length; i++) { int s = intArray[i]; diff --git a/src/ImageSharp/Metadata/Profiles/ICC/DataReader/IccDataReader.Curves.cs b/src/ImageSharp/Metadata/Profiles/ICC/DataReader/IccDataReader.Curves.cs index 3cf66c0c16..3e061c9d84 100644 --- a/src/ImageSharp/Metadata/Profiles/ICC/DataReader/IccDataReader.Curves.cs +++ b/src/ImageSharp/Metadata/Profiles/ICC/DataReader/IccDataReader.Curves.cs @@ -18,19 +18,19 @@ public IccOneDimensionalCurve ReadOneDimensionalCurve() { ushort segmentCount = this.ReadUInt16(); this.AddIndex(2); // 2 bytes reserved - var breakPoints = new float[segmentCount - 1]; + float[] breakPoints = new float[segmentCount - 1]; for (int i = 0; i < breakPoints.Length; i++) { breakPoints[i] = this.ReadSingle(); } - var segments = new IccCurveSegment[segmentCount]; + IccCurveSegment[] segments = new IccCurveSegment[segmentCount]; for (int i = 0; i < segmentCount; i++) { segments[i] = this.ReadCurveSegment(); } - return new IccOneDimensionalCurve(breakPoints, segments); + return new(breakPoints, segments); } /// @@ -40,20 +40,20 @@ public IccOneDimensionalCurve ReadOneDimensionalCurve() /// The read curve public IccResponseCurve ReadResponseCurve(int channelCount) { - var type = (IccCurveMeasurementEncodings)this.ReadUInt32(); - var measurement = new uint[channelCount]; + IccCurveMeasurementEncodings type = (IccCurveMeasurementEncodings)this.ReadUInt32(); + uint[] measurement = new uint[channelCount]; for (int i = 0; i < channelCount; i++) { measurement[i] = this.ReadUInt32(); } - var xyzValues = new Vector3[channelCount]; + Vector3[] xyzValues = new Vector3[channelCount]; for (int i = 0; i < channelCount; i++) { xyzValues[i] = this.ReadXyzNumber(); } - var response = new IccResponseNumber[channelCount][]; + IccResponseNumber[][] response = new IccResponseNumber[channelCount][]; for (int i = 0; i < channelCount; i++) { response[i] = new IccResponseNumber[measurement[i]]; @@ -63,7 +63,7 @@ public IccResponseCurve ReadResponseCurve(int channelCount) } } - return new IccResponseCurve(type, xyzValues, response); + return new(type, xyzValues, response); } /// @@ -106,11 +106,11 @@ public IccParametricCurve ReadParametricCurve() switch (type) { - case 0: return new IccParametricCurve(gamma); - case 1: return new IccParametricCurve(gamma, a, b); - case 2: return new IccParametricCurve(gamma, a, b, c); - case 3: return new IccParametricCurve(gamma, a, b, c, d); - case 4: return new IccParametricCurve(gamma, a, b, c, d, e, f); + case 0: return new(gamma); + case 1: return new(gamma, a, b); + case 2: return new(gamma, a, b, c); + case 3: return new(gamma, a, b, c, d); + case 4: return new(gamma, a, b, c, d, e, f); default: throw new InvalidIccProfileException($"Invalid parametric curve type of {type}"); } } @@ -121,7 +121,7 @@ public IccParametricCurve ReadParametricCurve() /// The read segment public IccCurveSegment ReadCurveSegment() { - var signature = (IccCurveSegmentSignature)this.ReadUInt32(); + IccCurveSegmentSignature signature = (IccCurveSegmentSignature)this.ReadUInt32(); this.AddIndex(4); // 4 bytes reserved switch (signature) @@ -141,7 +141,7 @@ public IccCurveSegment ReadCurveSegment() /// The read segment public IccFormulaCurveElement ReadFormulaCurveElement() { - var type = (IccFormulaCurveType)this.ReadUInt16(); + IccFormulaCurveType type = (IccFormulaCurveType)this.ReadUInt16(); this.AddIndex(2); // 2 bytes reserved float gamma, a, b, c, d, e; gamma = d = e = 0; @@ -165,7 +165,7 @@ public IccFormulaCurveElement ReadFormulaCurveElement() e = this.ReadSingle(); } - return new IccFormulaCurveElement(type, gamma, a, b, c, d, e); + return new(type, gamma, a, b, c, d, e); } /// @@ -175,13 +175,13 @@ public IccFormulaCurveElement ReadFormulaCurveElement() public IccSampledCurveElement ReadSampledCurveElement() { uint count = this.ReadUInt32(); - var entries = new float[count]; + float[] entries = new float[count]; for (int i = 0; i < count; i++) { entries[i] = this.ReadSingle(); } - return new IccSampledCurveElement(entries); + return new(entries); } /// @@ -191,7 +191,7 @@ public IccSampledCurveElement ReadSampledCurveElement() /// The curve data private IccTagDataEntry[] ReadCurves(int count) { - var tdata = new IccTagDataEntry[count]; + IccTagDataEntry[] tdata = new IccTagDataEntry[count]; for (int i = 0; i < count; i++) { IccTypeSignature type = this.ReadTagDataEntryHeader(); diff --git a/src/ImageSharp/Metadata/Profiles/ICC/DataReader/IccDataReader.Lut.cs b/src/ImageSharp/Metadata/Profiles/ICC/DataReader/IccDataReader.Lut.cs index e88dd8d9e1..cdcaf9f1bc 100644 --- a/src/ImageSharp/Metadata/Profiles/ICC/DataReader/IccDataReader.Lut.cs +++ b/src/ImageSharp/Metadata/Profiles/ICC/DataReader/IccDataReader.Lut.cs @@ -14,7 +14,7 @@ internal sealed partial class IccDataReader /// The read LUT public IccLut ReadLut8() { - return new IccLut(this.ReadBytes(256)); + return new(this.ReadBytes(256)); } /// @@ -24,13 +24,13 @@ public IccLut ReadLut8() /// The read LUT public IccLut ReadLut16(int count) { - var values = new ushort[count]; + ushort[] values = new ushort[count]; for (int i = 0; i < count; i++) { values[i] = this.ReadUInt16(); } - return new IccLut(values); + return new(values); } /// @@ -44,7 +44,7 @@ public IccLut ReadLut16(int count) public IccClut ReadClut(int inChannelCount, int outChannelCount, bool isFloat) { // Grid-points are always 16 bytes long but only 0-inChCount are used - var gridPointCount = new byte[inChannelCount]; + byte[] gridPointCount = new byte[inChannelCount]; Buffer.BlockCopy(this.data, this.AddIndex(16), gridPointCount, 0, inChannelCount); if (!isFloat) @@ -86,7 +86,7 @@ public IccClut ReadClut8(int inChannelCount, int outChannelCount, byte[] gridPoi const float Max = byte.MaxValue; - var values = new float[length][]; + float[][] values = new float[length][]; for (int i = 0; i < length; i++) { values[i] = new float[outChannelCount]; @@ -97,7 +97,7 @@ public IccClut ReadClut8(int inChannelCount, int outChannelCount, byte[] gridPoi } this.currentIndex = start + (length * outChannelCount); - return new IccClut(values, gridPointCount, IccClutDataType.UInt8); + return new(values, gridPointCount, IccClutDataType.UInt8); } /// @@ -120,7 +120,7 @@ public IccClut ReadClut16(int inChannelCount, int outChannelCount, byte[] gridPo const float Max = ushort.MaxValue; - var values = new float[length][]; + float[][] values = new float[length][]; for (int i = 0; i < length; i++) { values[i] = new float[outChannelCount]; @@ -131,7 +131,7 @@ public IccClut ReadClut16(int inChannelCount, int outChannelCount, byte[] gridPo } this.currentIndex = start + (length * outChannelCount * 2); - return new IccClut(values, gridPointCount, IccClutDataType.UInt16); + return new(values, gridPointCount, IccClutDataType.UInt16); } /// @@ -152,7 +152,7 @@ public IccClut ReadClutF32(int inChCount, int outChCount, byte[] gridPointCount) length /= inChCount; - var values = new float[length][]; + float[][] values = new float[length][]; for (int i = 0; i < length; i++) { values[i] = new float[outChCount]; @@ -163,6 +163,6 @@ public IccClut ReadClutF32(int inChCount, int outChCount, byte[] gridPointCount) } this.currentIndex = start + (length * outChCount * 4); - return new IccClut(values, gridPointCount, IccClutDataType.Float); + return new(values, gridPointCount, IccClutDataType.Float); } } diff --git a/src/ImageSharp/Metadata/Profiles/ICC/DataReader/IccDataReader.Matrix.cs b/src/ImageSharp/Metadata/Profiles/ICC/DataReader/IccDataReader.Matrix.cs index 61ecda4aab..f80ac4e446 100644 --- a/src/ImageSharp/Metadata/Profiles/ICC/DataReader/IccDataReader.Matrix.cs +++ b/src/ImageSharp/Metadata/Profiles/ICC/DataReader/IccDataReader.Matrix.cs @@ -17,7 +17,7 @@ internal sealed partial class IccDataReader /// The read matrix public float[,] ReadMatrix(int xCount, int yCount, bool isSingle) { - var matrix = new float[xCount, yCount]; + float[,] matrix = new float[xCount, yCount]; for (int y = 0; y < yCount; y++) { for (int x = 0; x < xCount; x++) @@ -44,7 +44,7 @@ internal sealed partial class IccDataReader /// The read matrix public float[] ReadMatrix(int yCount, bool isSingle) { - var matrix = new float[yCount]; + float[] matrix = new float[yCount]; for (int i = 0; i < yCount; i++) { if (isSingle) diff --git a/src/ImageSharp/Metadata/Profiles/ICC/DataReader/IccDataReader.MultiProcessElement.cs b/src/ImageSharp/Metadata/Profiles/ICC/DataReader/IccDataReader.MultiProcessElement.cs index 5baa904048..bff5e31bc5 100644 --- a/src/ImageSharp/Metadata/Profiles/ICC/DataReader/IccDataReader.MultiProcessElement.cs +++ b/src/ImageSharp/Metadata/Profiles/ICC/DataReader/IccDataReader.MultiProcessElement.cs @@ -48,14 +48,14 @@ public IccMultiProcessElement ReadMultiProcessElement() /// The read public IccCurveSetProcessElement ReadCurveSetProcessElement(int inChannelCount, int outChannelCount) { - var curves = new IccOneDimensionalCurve[inChannelCount]; + IccOneDimensionalCurve[] curves = new IccOneDimensionalCurve[inChannelCount]; for (int i = 0; i < inChannelCount; i++) { curves[i] = this.ReadOneDimensionalCurve(); this.AddPadding(); } - return new IccCurveSetProcessElement(curves); + return new(curves); } /// @@ -66,7 +66,7 @@ public IccCurveSetProcessElement ReadCurveSetProcessElement(int inChannelCount, /// The read public IccMatrixProcessElement ReadMatrixProcessElement(int inChannelCount, int outChannelCount) { - return new IccMatrixProcessElement( + return new( this.ReadMatrix(inChannelCount, outChannelCount, true), this.ReadMatrix(outChannelCount, true)); } @@ -79,6 +79,6 @@ public IccMatrixProcessElement ReadMatrixProcessElement(int inChannelCount, int /// The read public IccClutProcessElement ReadClutProcessElement(int inChannelCount, int outChannelCount) { - return new IccClutProcessElement(this.ReadClut(inChannelCount, outChannelCount, true)); + return new(this.ReadClut(inChannelCount, outChannelCount, true)); } } diff --git a/src/ImageSharp/Metadata/Profiles/ICC/DataReader/IccDataReader.NonPrimitives.cs b/src/ImageSharp/Metadata/Profiles/ICC/DataReader/IccDataReader.NonPrimitives.cs index d5369e5fc4..0462577555 100644 --- a/src/ImageSharp/Metadata/Profiles/ICC/DataReader/IccDataReader.NonPrimitives.cs +++ b/src/ImageSharp/Metadata/Profiles/ICC/DataReader/IccDataReader.NonPrimitives.cs @@ -18,7 +18,7 @@ public DateTime ReadDateTime() { try { - return new DateTime( + return new( year: this.ReadUInt16(), month: this.ReadUInt16(), day: this.ReadUInt16(), @@ -45,7 +45,7 @@ public IccVersion ReadVersionNumber() int minor = (version >> 20) & 0x0F; int bugfix = (version >> 16) & 0x0F; - return new IccVersion(major, minor, bugfix); + return new(major, minor, bugfix); } /// @@ -54,7 +54,7 @@ public IccVersion ReadVersionNumber() /// the XYZ number public Vector3 ReadXyzNumber() { - return new Vector3( + return new( x: this.ReadFix16(), y: this.ReadFix16(), z: this.ReadFix16()); @@ -66,7 +66,7 @@ public Vector3 ReadXyzNumber() /// the profile ID public IccProfileId ReadProfileId() { - return new IccProfileId( + return new( p1: this.ReadUInt32(), p2: this.ReadUInt32(), p3: this.ReadUInt32(), @@ -79,7 +79,7 @@ public IccProfileId ReadProfileId() /// the position number public IccPositionNumber ReadPositionNumber() { - return new IccPositionNumber( + return new( offset: this.ReadUInt32(), size: this.ReadUInt32()); } @@ -90,7 +90,7 @@ public IccPositionNumber ReadPositionNumber() /// the response number public IccResponseNumber ReadResponseNumber() { - return new IccResponseNumber( + return new( deviceCode: this.ReadUInt16(), measurementValue: this.ReadFix16()); } @@ -103,15 +103,15 @@ public IccResponseNumber ReadResponseNumber() public IccNamedColor ReadNamedColor(uint deviceCoordCount) { string name = this.ReadAsciiString(32); - ushort[] pcsCoord = { this.ReadUInt16(), this.ReadUInt16(), this.ReadUInt16() }; - var deviceCoord = new ushort[deviceCoordCount]; + ushort[] pcsCoord = [this.ReadUInt16(), this.ReadUInt16(), this.ReadUInt16()]; + ushort[] deviceCoord = new ushort[deviceCoordCount]; for (int i = 0; i < deviceCoordCount; i++) { deviceCoord[i] = this.ReadUInt16(); } - return new IccNamedColor(name, pcsCoord, deviceCoord); + return new(name, pcsCoord, deviceCoord); } /// @@ -122,13 +122,13 @@ public IccProfileDescription ReadProfileDescription() { uint manufacturer = this.ReadUInt32(); uint model = this.ReadUInt32(); - var attributes = (IccDeviceAttribute)this.ReadInt64(); - var technologyInfo = (IccProfileTag)this.ReadUInt32(); + IccDeviceAttribute attributes = (IccDeviceAttribute)this.ReadInt64(); + IccProfileTag technologyInfo = (IccProfileTag)this.ReadUInt32(); IccMultiLocalizedUnicodeTagDataEntry manufacturerInfo = ReadText(); IccMultiLocalizedUnicodeTagDataEntry modelInfo = ReadText(); - return new IccProfileDescription( + return new( manufacturer, model, attributes, @@ -158,7 +158,7 @@ IccMultiLocalizedUnicodeTagDataEntry ReadText() /// the profile description public IccColorantTableEntry ReadColorantTableEntry() { - return new IccColorantTableEntry( + return new( name: this.ReadAsciiString(32), pcs1: this.ReadUInt16(), pcs2: this.ReadUInt16(), @@ -171,7 +171,7 @@ public IccColorantTableEntry ReadColorantTableEntry() /// the screening channel public IccScreeningChannel ReadScreeningChannel() { - return new IccScreeningChannel( + return new( frequency: this.ReadFix16(), angle: this.ReadFix16(), spotShape: (IccScreeningSpotType)this.ReadInt32()); diff --git a/src/ImageSharp/Metadata/Profiles/ICC/DataReader/IccDataReader.Primitives.cs b/src/ImageSharp/Metadata/Profiles/ICC/DataReader/IccDataReader.Primitives.cs index 47d946d443..c2a54c93ec 100644 --- a/src/ImageSharp/Metadata/Profiles/ICC/DataReader/IccDataReader.Primitives.cs +++ b/src/ImageSharp/Metadata/Profiles/ICC/DataReader/IccDataReader.Primitives.cs @@ -164,7 +164,7 @@ public float ReadUFix8() /// The read bytes public byte[] ReadBytes(int count) { - var bytes = new byte[count]; + byte[] bytes = new byte[count]; Buffer.BlockCopy(this.data, this.AddIndex(count), bytes, 0, count); return bytes; } diff --git a/src/ImageSharp/Metadata/Profiles/ICC/DataReader/IccDataReader.TagDataEntry.cs b/src/ImageSharp/Metadata/Profiles/ICC/DataReader/IccDataReader.TagDataEntry.cs index 0d50b98095..4669e1ca43 100644 --- a/src/ImageSharp/Metadata/Profiles/ICC/DataReader/IccDataReader.TagDataEntry.cs +++ b/src/ImageSharp/Metadata/Profiles/ICC/DataReader/IccDataReader.TagDataEntry.cs @@ -106,7 +106,7 @@ public IccTagDataEntry ReadTagDataEntry(IccTagTableEntry info) /// The read signature public IccTypeSignature ReadTagDataEntryHeader() { - var type = (IccTypeSignature)this.ReadUInt32(); + IccTypeSignature type = (IccTypeSignature)this.ReadUInt32(); this.AddIndex(4); // 4 bytes are not used return type; } @@ -132,7 +132,7 @@ public void ReadCheckTagDataEntryHeader(IccTypeSignature expected) public IccUnknownTagDataEntry ReadUnknownTagDataEntry(uint size) { int count = (int)size - 8; // 8 is the tag header size - return new IccUnknownTagDataEntry(this.ReadBytes(count)); + return new(this.ReadBytes(count)); } /// @@ -142,13 +142,13 @@ public IccUnknownTagDataEntry ReadUnknownTagDataEntry(uint size) public IccChromaticityTagDataEntry ReadChromaticityTagDataEntry() { ushort channelCount = this.ReadUInt16(); - var colorant = (IccColorantEncoding)this.ReadUInt16(); + IccColorantEncoding colorant = (IccColorantEncoding)this.ReadUInt16(); if (Enum.IsDefined(typeof(IccColorantEncoding), colorant) && colorant != IccColorantEncoding.Unknown) { // The type is known and so are the values (they are constant) // channelCount should always be 3 but it doesn't really matter if it's not - return new IccChromaticityTagDataEntry(colorant); + return new(colorant); } else { @@ -156,10 +156,10 @@ public IccChromaticityTagDataEntry ReadChromaticityTagDataEntry() double[][] values = new double[channelCount][]; for (int i = 0; i < channelCount; i++) { - values[i] = new double[] { this.ReadUFix16(), this.ReadUFix16() }; + values[i] = [this.ReadUFix16(), this.ReadUFix16()]; } - return new IccChromaticityTagDataEntry(values); + return new(values); } } @@ -171,7 +171,7 @@ public IccColorantOrderTagDataEntry ReadColorantOrderTagDataEntry() { uint colorantCount = this.ReadUInt32(); byte[] number = this.ReadBytes((int)colorantCount); - return new IccColorantOrderTagDataEntry(number); + return new(number); } /// @@ -181,13 +181,13 @@ public IccColorantOrderTagDataEntry ReadColorantOrderTagDataEntry() public IccColorantTableTagDataEntry ReadColorantTableTagDataEntry() { uint colorantCount = this.ReadUInt32(); - var cdata = new IccColorantTableEntry[colorantCount]; + IccColorantTableEntry[] cdata = new IccColorantTableEntry[colorantCount]; for (int i = 0; i < colorantCount; i++) { cdata[i] = this.ReadColorantTableEntry(); } - return new IccColorantTableTagDataEntry(cdata); + return new(cdata); } /// @@ -200,12 +200,12 @@ public IccCurveTagDataEntry ReadCurveTagDataEntry() if (pointCount == 0) { - return new IccCurveTagDataEntry(); + return new(); } if (pointCount == 1) { - return new IccCurveTagDataEntry(this.ReadUFix8()); + return new(this.ReadUFix8()); } float[] cdata = new float[pointCount]; @@ -214,7 +214,7 @@ public IccCurveTagDataEntry ReadCurveTagDataEntry() cdata[i] = this.ReadUInt16() / 65535f; } - return new IccCurveTagDataEntry(cdata); + return new(cdata); // TODO: If the input is PCSXYZ, 1+(32 767/32 768) shall be mapped to the value 1,0. If the output is PCSXYZ, the value 1,0 shall be mapped to 1+(32 767/32 768). } @@ -234,7 +234,7 @@ public IccDataTagDataEntry ReadDataTagDataEntry(uint size) int length = (int)size - 12; byte[] cdata = this.ReadBytes(length); - return new IccDataTagDataEntry(cdata, ascii); + return new(cdata, ascii); } /// @@ -243,7 +243,7 @@ public IccDataTagDataEntry ReadDataTagDataEntry(uint size) /// The read entry public IccDateTimeTagDataEntry ReadDateTimeTagDataEntry() { - return new IccDateTimeTagDataEntry(this.ReadDateTime()); + return new(this.ReadDateTime()); } /// @@ -263,7 +263,7 @@ public IccLut16TagDataEntry ReadLut16TagDataEntry() ushort outTableCount = this.ReadUInt16(); // Input LUT - var inValues = new IccLut[inChCount]; + IccLut[] inValues = new IccLut[inChCount]; byte[] gridPointCount = new byte[inChCount]; for (int i = 0; i < inChCount; i++) { @@ -275,13 +275,13 @@ public IccLut16TagDataEntry ReadLut16TagDataEntry() IccClut clut = this.ReadClut16(inChCount, outChCount, gridPointCount); // Output LUT - var outValues = new IccLut[outChCount]; + IccLut[] outValues = new IccLut[outChCount]; for (int i = 0; i < outChCount; i++) { outValues[i] = this.ReadLut16(outTableCount); } - return new IccLut16TagDataEntry(matrix, inValues, clut, outValues); + return new(matrix, inValues, clut, outValues); } /// @@ -298,7 +298,7 @@ public IccLut8TagDataEntry ReadLut8TagDataEntry() float[,] matrix = this.ReadMatrix(3, 3, false); // Input LUT - var inValues = new IccLut[inChCount]; + IccLut[] inValues = new IccLut[inChCount]; byte[] gridPointCount = new byte[inChCount]; for (int i = 0; i < inChCount; i++) { @@ -310,13 +310,13 @@ public IccLut8TagDataEntry ReadLut8TagDataEntry() IccClut clut = this.ReadClut8(inChCount, outChCount, gridPointCount); // Output LUT - var outValues = new IccLut[outChCount]; + IccLut[] outValues = new IccLut[outChCount]; for (int i = 0; i < outChCount; i++) { outValues[i] = this.ReadLut8(); } - return new IccLut8TagDataEntry(matrix, inValues, clut, outValues); + return new(matrix, inValues, clut, outValues); } /// @@ -375,7 +375,7 @@ public IccLutAToBTagDataEntry ReadLutAtoBTagDataEntry() matrix3x1 = this.ReadMatrix(3, false); } - return new IccLutAToBTagDataEntry(bCurve, matrix3x3, matrix3x1, mCurve, clut, aCurve); + return new(bCurve, matrix3x3, matrix3x1, mCurve, clut, aCurve); } /// @@ -434,7 +434,7 @@ public IccLutBToATagDataEntry ReadLutBtoATagDataEntry() matrix3x1 = this.ReadMatrix(3, false); } - return new IccLutBToATagDataEntry(bCurve, matrix3x3, matrix3x1, mCurve, clut, aCurve); + return new(bCurve, matrix3x3, matrix3x1, mCurve, clut, aCurve); } /// @@ -443,7 +443,7 @@ public IccLutBToATagDataEntry ReadLutBtoATagDataEntry() /// The read entry public IccMeasurementTagDataEntry ReadMeasurementTagDataEntry() { - return new IccMeasurementTagDataEntry( + return new( observer: (IccStandardObserver)this.ReadUInt32(), xyzBacking: this.ReadXyzNumber(), geometry: (IccMeasurementGeometry)this.ReadUInt32(), @@ -461,9 +461,9 @@ public IccMultiLocalizedUnicodeTagDataEntry ReadMultiLocalizedUnicodeTagDataEntr uint recordCount = this.ReadUInt32(); this.ReadUInt32(); // Record size (always 12) - var text = new IccLocalizedString[recordCount]; + IccLocalizedString[] text = new IccLocalizedString[recordCount]; - var culture = new CultureInfo[recordCount]; + CultureInfo[] culture = new CultureInfo[recordCount]; uint[] length = new uint[recordCount]; uint[] offset = new uint[recordCount]; @@ -480,10 +480,10 @@ public IccMultiLocalizedUnicodeTagDataEntry ReadMultiLocalizedUnicodeTagDataEntr for (int i = 0; i < recordCount; i++) { this.currentIndex = (int)(start + offset[i]); - text[i] = new IccLocalizedString(culture[i], this.ReadUnicodeString((int)length[i])); + text[i] = new(culture[i], this.ReadUnicodeString((int)length[i])); } - return new IccMultiLocalizedUnicodeTagDataEntry(text); + return new(text); CultureInfo ReadCulture(string language, string country) { @@ -495,7 +495,7 @@ CultureInfo ReadCulture(string language, string country) { try { - return new CultureInfo(language); + return new(language); } catch (CultureNotFoundException) { @@ -506,7 +506,7 @@ CultureInfo ReadCulture(string language, string country) { try { - return new CultureInfo($"{language}-{country}"); + return new($"{language}-{country}"); } catch (CultureNotFoundException) { @@ -528,20 +528,20 @@ public IccMultiProcessElementsTagDataEntry ReadMultiProcessElementsTagDataEntry( this.ReadUInt16(); uint elementCount = this.ReadUInt32(); - var positionTable = new IccPositionNumber[elementCount]; + IccPositionNumber[] positionTable = new IccPositionNumber[elementCount]; for (int i = 0; i < elementCount; i++) { positionTable[i] = this.ReadPositionNumber(); } - var elements = new IccMultiProcessElement[elementCount]; + IccMultiProcessElement[] elements = new IccMultiProcessElement[elementCount]; for (int i = 0; i < elementCount; i++) { this.currentIndex = (int)positionTable[i].Offset + start; elements[i] = this.ReadMultiProcessElement(); } - return new IccMultiProcessElementsTagDataEntry(elements); + return new(elements); } /// @@ -556,13 +556,13 @@ public IccNamedColor2TagDataEntry ReadNamedColor2TagDataEntry() string prefix = this.ReadAsciiString(32); string suffix = this.ReadAsciiString(32); - var colors = new IccNamedColor[colorCount]; + IccNamedColor[] colors = new IccNamedColor[colorCount]; for (int i = 0; i < colorCount; i++) { colors[i] = this.ReadNamedColor(coordCount); } - return new IccNamedColor2TagDataEntry(vendorFlag, prefix, suffix, colors); + return new(vendorFlag, prefix, suffix, colors); } /// @@ -571,7 +571,7 @@ public IccNamedColor2TagDataEntry ReadNamedColor2TagDataEntry() /// The read entry public IccParametricCurveTagDataEntry ReadParametricCurveTagDataEntry() { - return new IccParametricCurveTagDataEntry(this.ReadParametricCurve()); + return new(this.ReadParametricCurve()); } /// @@ -581,13 +581,13 @@ public IccParametricCurveTagDataEntry ReadParametricCurveTagDataEntry() public IccProfileSequenceDescTagDataEntry ReadProfileSequenceDescTagDataEntry() { uint count = this.ReadUInt32(); - var description = new IccProfileDescription[count]; + IccProfileDescription[] description = new IccProfileDescription[count]; for (int i = 0; i < count; i++) { description[i] = this.ReadProfileDescription(); } - return new IccProfileSequenceDescTagDataEntry(description); + return new(description); } /// @@ -598,23 +598,23 @@ public IccProfileSequenceIdentifierTagDataEntry ReadProfileSequenceIdentifierTag { int start = this.currentIndex - 8; // 8 is the tag header size uint count = this.ReadUInt32(); - var table = new IccPositionNumber[count]; + IccPositionNumber[] table = new IccPositionNumber[count]; for (int i = 0; i < count; i++) { table[i] = this.ReadPositionNumber(); } - var entries = new IccProfileSequenceIdentifier[count]; + IccProfileSequenceIdentifier[] entries = new IccProfileSequenceIdentifier[count]; for (int i = 0; i < count; i++) { this.currentIndex = (int)(start + table[i].Offset); IccProfileId id = this.ReadProfileId(); this.ReadCheckTagDataEntryHeader(IccTypeSignature.MultiLocalizedUnicode); IccMultiLocalizedUnicodeTagDataEntry description = this.ReadMultiLocalizedUnicodeTagDataEntry(); - entries[i] = new IccProfileSequenceIdentifier(id, description.Texts); + entries[i] = new(id, description.Texts); } - return new IccProfileSequenceIdentifierTagDataEntry(entries); + return new(entries); } /// @@ -633,14 +633,14 @@ public IccResponseCurveSet16TagDataEntry ReadResponseCurveSet16TagDataEntry() offset[i] = this.ReadUInt32(); } - var curves = new IccResponseCurve[measurementCount]; + IccResponseCurve[] curves = new IccResponseCurve[measurementCount]; for (int i = 0; i < measurementCount; i++) { this.currentIndex = (int)(start + offset[i]); curves[i] = this.ReadResponseCurve(channelCount); } - return new IccResponseCurveSet16TagDataEntry(curves); + return new(curves); } /// @@ -657,7 +657,7 @@ public IccFix16ArrayTagDataEntry ReadFix16ArrayTagDataEntry(uint size) arrayData[i] = this.ReadFix16() / 256f; } - return new IccFix16ArrayTagDataEntry(arrayData); + return new(arrayData); } /// @@ -666,7 +666,7 @@ public IccFix16ArrayTagDataEntry ReadFix16ArrayTagDataEntry(uint size) /// The read entry public IccSignatureTagDataEntry ReadSignatureTagDataEntry() { - return new IccSignatureTagDataEntry(this.ReadAsciiString(4)); + return new(this.ReadAsciiString(4)); } /// @@ -676,7 +676,7 @@ public IccSignatureTagDataEntry ReadSignatureTagDataEntry() /// The read entry public IccTextTagDataEntry ReadTextTagDataEntry(uint size) { - return new IccTextTagDataEntry(this.ReadAsciiString((int)size - 8)); // 8 is the tag header size + return new(this.ReadAsciiString((int)size - 8)); // 8 is the tag header size } /// @@ -693,7 +693,7 @@ public IccUFix16ArrayTagDataEntry ReadUFix16ArrayTagDataEntry(uint size) arrayData[i] = this.ReadUFix16(); } - return new IccUFix16ArrayTagDataEntry(arrayData); + return new(arrayData); } /// @@ -710,7 +710,7 @@ public IccUInt16ArrayTagDataEntry ReadUInt16ArrayTagDataEntry(uint size) arrayData[i] = this.ReadUInt16(); } - return new IccUInt16ArrayTagDataEntry(arrayData); + return new(arrayData); } /// @@ -727,7 +727,7 @@ public IccUInt32ArrayTagDataEntry ReadUInt32ArrayTagDataEntry(uint size) arrayData[i] = this.ReadUInt32(); } - return new IccUInt32ArrayTagDataEntry(arrayData); + return new(arrayData); } /// @@ -744,7 +744,7 @@ public IccUInt64ArrayTagDataEntry ReadUInt64ArrayTagDataEntry(uint size) arrayData[i] = this.ReadUInt64(); } - return new IccUInt64ArrayTagDataEntry(arrayData); + return new(arrayData); } /// @@ -757,7 +757,7 @@ public IccUInt8ArrayTagDataEntry ReadUInt8ArrayTagDataEntry(uint size) int count = (int)size - 8; // 8 is the tag header size byte[] adata = this.ReadBytes(count); - return new IccUInt8ArrayTagDataEntry(adata); + return new(adata); } /// @@ -766,7 +766,7 @@ public IccUInt8ArrayTagDataEntry ReadUInt8ArrayTagDataEntry(uint size) /// The read entry public IccViewingConditionsTagDataEntry ReadViewingConditionsTagDataEntry() { - return new IccViewingConditionsTagDataEntry( + return new( illuminantXyz: this.ReadXyzNumber(), surroundXyz: this.ReadXyzNumber(), illuminant: (IccStandardIlluminant)this.ReadUInt32()); @@ -780,13 +780,13 @@ public IccViewingConditionsTagDataEntry ReadViewingConditionsTagDataEntry() public IccXyzTagDataEntry ReadXyzTagDataEntry(uint size) { uint count = (size - 8) / 12; - var arrayData = new Vector3[count]; + Vector3[] arrayData = new Vector3[count]; for (int i = 0; i < count; i++) { arrayData[i] = this.ReadXyzNumber(); } - return new IccXyzTagDataEntry(arrayData); + return new(arrayData); } /// @@ -821,7 +821,7 @@ public IccTextDescriptionTagDataEntry ReadTextDescriptionTagDataEntry() this.AddIndex(1); // Null terminator } - return new IccTextDescriptionTagDataEntry( + return new( asciiValue, unicodeValue, scriptcodeValue, @@ -850,7 +850,7 @@ public IccCrdInfoTagDataEntry ReadCrdInfoTagDataEntry() uint crd3Count = this.ReadUInt32(); string crd3Name = this.ReadAsciiString((int)crd3Count); - return new IccCrdInfoTagDataEntry(productName, crd0Name, crd1Name, crd2Name, crd3Name); + return new(productName, crd0Name, crd1Name, crd2Name, crd3Name); } /// @@ -859,15 +859,15 @@ public IccCrdInfoTagDataEntry ReadCrdInfoTagDataEntry() /// The read entry public IccScreeningTagDataEntry ReadScreeningTagDataEntry() { - var flags = (IccScreeningFlag)this.ReadInt32(); + IccScreeningFlag flags = (IccScreeningFlag)this.ReadInt32(); uint channelCount = this.ReadUInt32(); - var channels = new IccScreeningChannel[channelCount]; + IccScreeningChannel[] channels = new IccScreeningChannel[channelCount]; for (int i = 0; i < channels.Length; i++) { channels[i] = this.ReadScreeningChannel(); } - return new IccScreeningTagDataEntry(flags, channels); + return new(flags, channels); } /// @@ -896,6 +896,6 @@ public IccUcrBgTagDataEntry ReadUcrBgTagDataEntry(uint size) int descriptionLength = (int)(size - 8 - dataSize); // 8 is the tag header size string description = this.ReadAsciiString(descriptionLength); - return new IccUcrBgTagDataEntry(ucrCurve, bgCurve, description); + return new(ucrCurve, bgCurve, description); } } diff --git a/src/ImageSharp/Metadata/Profiles/ICC/DataWriter/IccDataWriter.NonPrimitives.cs b/src/ImageSharp/Metadata/Profiles/ICC/DataWriter/IccDataWriter.NonPrimitives.cs index db199b4381..8ad81415d9 100644 --- a/src/ImageSharp/Metadata/Profiles/ICC/DataWriter/IccDataWriter.NonPrimitives.cs +++ b/src/ImageSharp/Metadata/Profiles/ICC/DataWriter/IccDataWriter.NonPrimitives.cs @@ -111,9 +111,9 @@ public int WriteProfileDescription(in IccProfileDescription value) + this.WriteInt64((long)value.DeviceAttributes) + this.WriteUInt32((uint)value.TechnologyInformation) + this.WriteTagDataEntryHeader(IccTypeSignature.MultiLocalizedUnicode) - + this.WriteMultiLocalizedUnicodeTagDataEntry(new IccMultiLocalizedUnicodeTagDataEntry(value.DeviceManufacturerInfo)) + + this.WriteMultiLocalizedUnicodeTagDataEntry(new(value.DeviceManufacturerInfo)) + this.WriteTagDataEntryHeader(IccTypeSignature.MultiLocalizedUnicode) - + this.WriteMultiLocalizedUnicodeTagDataEntry(new IccMultiLocalizedUnicodeTagDataEntry(value.DeviceModelInfo)); + + this.WriteMultiLocalizedUnicodeTagDataEntry(new(value.DeviceModelInfo)); } /// diff --git a/src/ImageSharp/Metadata/Profiles/ICC/DataWriter/IccDataWriter.TagDataEntry.cs b/src/ImageSharp/Metadata/Profiles/ICC/DataWriter/IccDataWriter.TagDataEntry.cs index 1f9c101fb5..00f189351f 100644 --- a/src/ImageSharp/Metadata/Profiles/ICC/DataWriter/IccDataWriter.TagDataEntry.cs +++ b/src/ImageSharp/Metadata/Profiles/ICC/DataWriter/IccDataWriter.TagDataEntry.cs @@ -20,7 +20,7 @@ public int WriteTagDataEntry(IccTagDataEntry data, out IccTagTableEntry table) uint offset = (uint)this.dataStream.Position; int count = this.WriteTagDataEntry(data); this.WritePadding(); - table = new IccTagTableEntry(data.TagSignature, offset, (uint)count); + table = new(data.TagSignature, offset, (uint)count); return count; } @@ -546,7 +546,7 @@ public int WriteMultiProcessElementsTagDataEntry(IccMultiProcessElementsTagDataE uint offset = (uint)(this.dataStream.Position - start); int size = this.WriteMultiProcessElement(value.Data[i]); count += this.WritePadding(); - posTable[i] = new IccPositionNumber(offset, (uint)size); + posTable[i] = new(offset, (uint)size); count += size; } @@ -634,7 +634,7 @@ public int WriteProfileSequenceIdentifierTagDataEntry(IccProfileSequenceIdentifi int size = this.WriteProfileId(sequenceIdentifier.Id); size += this.WriteTagDataEntry(new IccMultiLocalizedUnicodeTagDataEntry(sequenceIdentifier.Description)); size += this.WritePadding(); - table[i] = new IccPositionNumber(offset, (uint)size); + table[i] = new(offset, (uint)size); count += size; } diff --git a/src/ImageSharp/Metadata/Profiles/ICC/DataWriter/IccDataWriter.cs b/src/ImageSharp/Metadata/Profiles/ICC/DataWriter/IccDataWriter.cs index ce53325442..941d3bb658 100644 --- a/src/ImageSharp/Metadata/Profiles/ICC/DataWriter/IccDataWriter.cs +++ b/src/ImageSharp/Metadata/Profiles/ICC/DataWriter/IccDataWriter.cs @@ -23,7 +23,7 @@ internal sealed partial class IccDataWriter : IDisposable /// public IccDataWriter() { - this.dataStream = new MemoryStream(); + this.dataStream = new(); } /// diff --git a/src/ImageSharp/Metadata/Profiles/ICC/IccProfile.cs b/src/ImageSharp/Metadata/Profiles/ICC/IccProfile.cs index be7350bc44..8845f0e933 100644 --- a/src/ImageSharp/Metadata/Profiles/ICC/IccProfile.cs +++ b/src/ImageSharp/Metadata/Profiles/ICC/IccProfile.cs @@ -186,7 +186,7 @@ private void InitializeHeader() if (this.data is null) { - this.header = new IccProfileHeader(); + this.header = new(); return; } @@ -203,7 +203,7 @@ private void InitializeEntries() if (this.data is null) { - this.entries = Array.Empty(); + this.entries = []; return; } diff --git a/src/ImageSharp/Metadata/Profiles/ICC/IccReader.cs b/src/ImageSharp/Metadata/Profiles/ICC/IccReader.cs index 45074c9a6e..afd67ba8c4 100644 --- a/src/ImageSharp/Metadata/Profiles/ICC/IccReader.cs +++ b/src/ImageSharp/Metadata/Profiles/ICC/IccReader.cs @@ -22,7 +22,7 @@ public static IccProfile Read(byte[] data) IccProfileHeader header = ReadHeader(reader); IccTagDataEntry[] tagData = ReadTagData(reader); - return new IccProfile(header, tagData); + return new(header, tagData); } /// @@ -57,7 +57,7 @@ private static IccProfileHeader ReadHeader(IccDataReader reader) { reader.SetIndex(0); - return new IccProfileHeader + return new() { Size = reader.ReadUInt32(), CmmType = reader.ReadAsciiString(4), @@ -124,7 +124,7 @@ private static IccTagTableEntry[] ReadTagTable(IccDataReader reader) // A normal profile usually has 5-15 entries if (tagCount > 100) { - return Array.Empty(); + return []; } List table = new((int)tagCount); @@ -137,7 +137,7 @@ private static IccTagTableEntry[] ReadTagTable(IccDataReader reader) // Exclude entries that have nonsense values and could cause exceptions further on if (tagOffset < reader.DataLength && tagSize < reader.DataLength - 128) { - table.Add(new IccTagTableEntry((IccProfileTag)tagSignature, tagOffset, tagSize)); + table.Add(new((IccProfileTag)tagSignature, tagOffset, tagSize)); } } diff --git a/src/ImageSharp/Metadata/Profiles/ICC/IccWriter.cs b/src/ImageSharp/Metadata/Profiles/ICC/IccWriter.cs index 5e73e2dd00..7daedc181b 100644 --- a/src/ImageSharp/Metadata/Profiles/ICC/IccWriter.cs +++ b/src/ImageSharp/Metadata/Profiles/ICC/IccWriter.cs @@ -71,13 +71,13 @@ private static IccTagTableEntry[] WriteTagData(IccDataWriter writer, IccTagDataE // (Header size) + (entry count) + (nr of entries) * (size of table entry) writer.SetIndex(128 + 4 + (entries.Length * 12)); - List table = new(); + List table = []; foreach (IGrouping group in grouped) { writer.WriteTagDataEntry(group.Key, out IccTagTableEntry tableEntry); foreach (IccTagDataEntry item in group) { - table.Add(new IccTagTableEntry(item.TagSignature, tableEntry.Offset, tableEntry.DataSize)); + table.Add(new(item.TagSignature, tableEntry.Offset, tableEntry.DataSize)); } } diff --git a/src/ImageSharp/Metadata/Profiles/ICC/TagDataEntries/IccChromaticityTagDataEntry.cs b/src/ImageSharp/Metadata/Profiles/ICC/TagDataEntries/IccChromaticityTagDataEntry.cs index cc44762919..1938ad6302 100644 --- a/src/ImageSharp/Metadata/Profiles/ICC/TagDataEntries/IccChromaticityTagDataEntry.cs +++ b/src/ImageSharp/Metadata/Profiles/ICC/TagDataEntries/IccChromaticityTagDataEntry.cs @@ -112,33 +112,33 @@ private static double[][] GetColorantArray(IccColorantEncoding colorantType) switch (colorantType) { case IccColorantEncoding.EbuTech3213E: - return new[] - { - new[] { 0.640, 0.330 }, - new[] { 0.290, 0.600 }, - new[] { 0.150, 0.060 }, - }; + return + [ + [0.640, 0.330], + [0.290, 0.600], + [0.150, 0.060] + ]; case IccColorantEncoding.ItuRBt709_2: - return new[] - { - new[] { 0.640, 0.330 }, - new[] { 0.300, 0.600 }, - new[] { 0.150, 0.060 }, - }; + return + [ + [0.640, 0.330], + [0.300, 0.600], + [0.150, 0.060] + ]; case IccColorantEncoding.P22: - return new[] - { - new[] { 0.625, 0.340 }, - new[] { 0.280, 0.605 }, - new[] { 0.155, 0.070 }, - }; + return + [ + [0.625, 0.340], + [0.280, 0.605], + [0.155, 0.070] + ]; case IccColorantEncoding.SmpteRp145: - return new[] - { - new[] { 0.630, 0.340 }, - new[] { 0.310, 0.595 }, - new[] { 0.155, 0.070 }, - }; + return + [ + [0.630, 0.340], + [0.310, 0.595], + [0.155, 0.070] + ]; default: throw new ArgumentException("Unrecognized colorant encoding"); } diff --git a/src/ImageSharp/Metadata/Profiles/ICC/TagDataEntries/IccCurveTagDataEntry.cs b/src/ImageSharp/Metadata/Profiles/ICC/TagDataEntries/IccCurveTagDataEntry.cs index 5605d92559..7330cbdf00 100644 --- a/src/ImageSharp/Metadata/Profiles/ICC/TagDataEntries/IccCurveTagDataEntry.cs +++ b/src/ImageSharp/Metadata/Profiles/ICC/TagDataEntries/IccCurveTagDataEntry.cs @@ -12,7 +12,7 @@ internal sealed class IccCurveTagDataEntry : IccTagDataEntry, IEquatable class. /// public IccCurveTagDataEntry() - : this(Array.Empty(), IccProfileTag.Unknown) + : this([], IccProfileTag.Unknown) { } @@ -21,7 +21,7 @@ public IccCurveTagDataEntry() /// /// Gamma value public IccCurveTagDataEntry(float gamma) - : this(new[] { gamma }, IccProfileTag.Unknown) + : this([gamma], IccProfileTag.Unknown) { } @@ -39,7 +39,7 @@ public IccCurveTagDataEntry(float[] curveData) /// /// Tag Signature public IccCurveTagDataEntry(IccProfileTag tagSignature) - : this(Array.Empty(), tagSignature) + : this([], tagSignature) { } @@ -49,7 +49,7 @@ public IccCurveTagDataEntry(IccProfileTag tagSignature) /// Gamma value /// Tag Signature public IccCurveTagDataEntry(float gamma, IccProfileTag tagSignature) - : this(new[] { gamma }, tagSignature) + : this([gamma], tagSignature) { } @@ -61,7 +61,7 @@ public IccCurveTagDataEntry(float gamma, IccProfileTag tagSignature) public IccCurveTagDataEntry(float[] curveData, IccProfileTag tagSignature) : base(IccTypeSignature.Curve, tagSignature) { - this.CurveData = curveData ?? Array.Empty(); + this.CurveData = curveData ?? []; } /// diff --git a/src/ImageSharp/Metadata/Profiles/ICC/TagDataEntries/IccLut16TagDataEntry.cs b/src/ImageSharp/Metadata/Profiles/ICC/TagDataEntries/IccLut16TagDataEntry.cs index 9ddd0ce13d..b8c29ae096 100644 --- a/src/ImageSharp/Metadata/Profiles/ICC/TagDataEntries/IccLut16TagDataEntry.cs +++ b/src/ImageSharp/Metadata/Profiles/ICC/TagDataEntries/IccLut16TagDataEntry.cs @@ -147,7 +147,7 @@ public override int GetHashCode() private static Matrix4x4 CreateMatrix(float[,] matrix) { - return new Matrix4x4( + return new( matrix[0, 0], matrix[0, 1], matrix[0, 2], diff --git a/src/ImageSharp/Metadata/Profiles/ICC/TagDataEntries/IccTextDescriptionTagDataEntry.cs b/src/ImageSharp/Metadata/Profiles/ICC/TagDataEntries/IccTextDescriptionTagDataEntry.cs index 7db26e5c58..e96fdbb53d 100644 --- a/src/ImageSharp/Metadata/Profiles/ICC/TagDataEntries/IccTextDescriptionTagDataEntry.cs +++ b/src/ImageSharp/Metadata/Profiles/ICC/TagDataEntries/IccTextDescriptionTagDataEntry.cs @@ -86,23 +86,23 @@ public static explicit operator IccMultiLocalizedUnicodeTagDataEntry(IccTextDesc { CultureInfo culture = GetCulture(textEntry.UnicodeLanguageCode); localString = culture != null - ? new IccLocalizedString(culture, textEntry.Unicode) + ? new(culture, textEntry.Unicode) : new IccLocalizedString(textEntry.Unicode); } else if (!string.IsNullOrEmpty(textEntry.Ascii)) { - localString = new IccLocalizedString(textEntry.Ascii); + localString = new(textEntry.Ascii); } else if (!string.IsNullOrEmpty(textEntry.ScriptCode)) { - localString = new IccLocalizedString(textEntry.ScriptCode); + localString = new(textEntry.ScriptCode); } else { - localString = new IccLocalizedString(string.Empty); + localString = new(string.Empty); } - return new IccMultiLocalizedUnicodeTagDataEntry(new[] { localString }, textEntry.TagSignature); + return new([localString], textEntry.TagSignature); static CultureInfo GetCulture(uint value) { @@ -123,7 +123,7 @@ static CultureInfo GetCulture(uint value) && p4 >= 0x41 && p4 <= 0x5A) { string culture = new(new[] { (char)p1, (char)p2, '-', (char)p3, (char)p4 }); - return new CultureInfo(culture); + return new(culture); } return null; diff --git a/src/ImageSharp/Metadata/Profiles/IPTC/IptcProfile.cs b/src/ImageSharp/Metadata/Profiles/IPTC/IptcProfile.cs index 162fae96b3..ddfa590119 100644 --- a/src/ImageSharp/Metadata/Profiles/IPTC/IptcProfile.cs +++ b/src/ImageSharp/Metadata/Profiles/IPTC/IptcProfile.cs @@ -15,7 +15,7 @@ namespace SixLabors.ImageSharp.Metadata.Profiles.Iptc; /// public sealed class IptcProfile : IDeepCloneable { - private readonly Collection values = new(); + private readonly Collection values = []; private const byte IptcTagMarkerByte = 0x1c; @@ -68,7 +68,7 @@ private IptcProfile(IptcProfile other) /// /// Gets a byte array marking that UTF-8 encoding is used in application records. /// - private static ReadOnlySpan CodedCharacterSetUtf8Value => new byte[] { 0x1B, 0x25, 0x47 }; // Uses C#'s optimization to refer to the data segment in the assembly directly, no allocation occurs. + private static ReadOnlySpan CodedCharacterSetUtf8Value => [0x1B, 0x25, 0x47]; // Uses C#'s optimization to refer to the data segment in the assembly directly, no allocation occurs. /// /// Gets the byte data of the IPTC profile. @@ -90,7 +90,7 @@ private IptcProfile(IptcProfile other) /// The values found with the specified tag. public List GetValues(IptcTag tag) { - List iptcValues = new(); + List iptcValues = []; foreach (IptcValue iptcValue in this.Values) { if (iptcValue.Tag == tag) @@ -186,7 +186,7 @@ public void SetValue(IptcTag tag, Encoding encoding, string value, bool strict = } } - this.values.Add(new IptcValue(tag, encoding, value, strict)); + this.values.Add(new(tag, encoding, value, strict)); } /// @@ -323,7 +323,7 @@ private void Initialize() { byte[] iptcData = new byte[byteCount]; Buffer.BlockCopy(this.Data, offset, iptcData, 0, (int)byteCount); - this.values.Add(new IptcValue(tag, iptcData, false)); + this.values.Add(new(tag, iptcData, false)); } offset += (int)byteCount; diff --git a/src/ImageSharp/Metadata/Profiles/IPTC/IptcValue.cs b/src/ImageSharp/Metadata/Profiles/IPTC/IptcValue.cs index 78f7f6de08..7735810b3f 100644 --- a/src/ImageSharp/Metadata/Profiles/IPTC/IptcValue.cs +++ b/src/ImageSharp/Metadata/Profiles/IPTC/IptcValue.cs @@ -12,7 +12,7 @@ namespace SixLabors.ImageSharp.Metadata.Profiles.Iptc; [DebuggerDisplay("{Tag} = {ToString(),nq} ({GetType().Name,nq})")] public sealed class IptcValue : IDeepCloneable { - private byte[] data = Array.Empty(); + private byte[] data = []; private Encoding encoding; internal IptcValue(IptcValue other) @@ -91,7 +91,7 @@ public string Value { if (string.IsNullOrEmpty(value)) { - this.data = Array.Empty(); + this.data = []; } else { @@ -124,7 +124,7 @@ public string Value public int Length => this.data.Length; /// - public IptcValue DeepClone() => new IptcValue(this); + public IptcValue DeepClone() => new(this); /// /// Determines whether the specified object is equal to the current . @@ -191,7 +191,7 @@ public bool Equals(IptcValue? other) /// A array. public byte[] ToByteArray() { - var result = new byte[this.data.Length]; + byte[] result = new byte[this.data.Length]; this.data.CopyTo(result, 0); return result; } diff --git a/src/ImageSharp/PixelFormats/PixelBlenders/PorterDuffFunctions.cs b/src/ImageSharp/PixelFormats/PixelBlenders/PorterDuffFunctions.cs index ca358be31c..63630dd55e 100644 --- a/src/ImageSharp/PixelFormats/PixelBlenders/PorterDuffFunctions.cs +++ b/src/ImageSharp/PixelFormats/PixelBlenders/PorterDuffFunctions.cs @@ -179,7 +179,7 @@ public static Vector4 Overlay(Vector4 backdrop, Vector4 source) float cg = OverlayValueFunction(backdrop.Y, source.Y); float cb = OverlayValueFunction(backdrop.Z, source.Z); - return Vector4.Min(Vector4.One, new Vector4(cr, cg, cb, 0)); + return Vector4.Min(Vector4.One, new(cr, cg, cb, 0)); } /// @@ -208,7 +208,7 @@ public static Vector4 HardLight(Vector4 backdrop, Vector4 source) float cg = OverlayValueFunction(source.Y, backdrop.Y); float cb = OverlayValueFunction(source.Z, backdrop.Z); - return Vector4.Min(Vector4.One, new Vector4(cr, cg, cb, 0)); + return Vector4.Min(Vector4.One, new(cr, cg, cb, 0)); } /// diff --git a/src/ImageSharp/PixelFormats/PixelComponentInfo.cs b/src/ImageSharp/PixelFormats/PixelComponentInfo.cs index 1444b344b6..00be93b22b 100644 --- a/src/ImageSharp/PixelFormats/PixelComponentInfo.cs +++ b/src/ImageSharp/PixelFormats/PixelComponentInfo.cs @@ -81,7 +81,7 @@ public static PixelComponentInfo Create(int count, int bitsPerPixel, params int[ sum += p; } - return new PixelComponentInfo(count, bitsPerPixel - sum, precisionData1, precisionData2); + return new(count, bitsPerPixel - sum, precisionData1, precisionData2); } /// diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/Bgr565.cs b/src/ImageSharp/PixelFormats/PixelImplementations/Bgr565.cs index 87055bf22d..e81b3e66f4 100644 --- a/src/ImageSharp/PixelFormats/PixelImplementations/Bgr565.cs +++ b/src/ImageSharp/PixelFormats/PixelImplementations/Bgr565.cs @@ -28,7 +28,7 @@ public partial struct Bgr565(Vector3 vector) : IPixel, IPackedVectorThe y-component /// The z-component public Bgr565(float x, float y, float z) - : this(new Vector3(x, y, z)) + : this(new(x, y, z)) { } @@ -84,7 +84,7 @@ public static PixelTypeInfo GetPixelTypeInfo() /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Bgr565 FromVector4(Vector4 source) => new() { PackedValue = Pack(new Vector3(source.X, source.Y, source.Z)) }; + public static Bgr565 FromVector4(Vector4 source) => new() { PackedValue = Pack(new(source.X, source.Y, source.Z)) }; /// [MethodImpl(MethodImplOptions.AggressiveInlining)] diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/Bgra4444.cs b/src/ImageSharp/PixelFormats/PixelImplementations/Bgra4444.cs index 55971210c3..d6ffa47237 100644 --- a/src/ImageSharp/PixelFormats/PixelImplementations/Bgra4444.cs +++ b/src/ImageSharp/PixelFormats/PixelImplementations/Bgra4444.cs @@ -22,7 +22,7 @@ public partial struct Bgra4444 : IPixel, IPackedVector /// The z-component /// The w-component public Bgra4444(float x, float y, float z, float w) - : this(new Vector4(x, y, z, w)) + : this(new(x, y, z, w)) { } diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/Bgra5551.cs b/src/ImageSharp/PixelFormats/PixelImplementations/Bgra5551.cs index 4c94dea5f1..45f013fb1b 100644 --- a/src/ImageSharp/PixelFormats/PixelImplementations/Bgra5551.cs +++ b/src/ImageSharp/PixelFormats/PixelImplementations/Bgra5551.cs @@ -23,7 +23,7 @@ public partial struct Bgra5551 : IPixel, IPackedVector /// The z-component /// The w-component public Bgra5551(float x, float y, float z, float w) - : this(new Vector4(x, y, z, w)) + : this(new(x, y, z, w)) { } diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/Byte4.cs b/src/ImageSharp/PixelFormats/PixelImplementations/Byte4.cs index 680a7ee0bd..b4479fd509 100644 --- a/src/ImageSharp/PixelFormats/PixelImplementations/Byte4.cs +++ b/src/ImageSharp/PixelFormats/PixelImplementations/Byte4.cs @@ -25,7 +25,7 @@ public partial struct Byte4 : IPixel, IPackedVector /// The z-component /// The w-component public Byte4(float x, float y, float z, float w) - : this(new Vector4(x, y, z, w)) + : this(new(x, y, z, w)) { } diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/HalfSingle.cs b/src/ImageSharp/PixelFormats/PixelImplementations/HalfSingle.cs index 888d992d8c..3ef711d6a1 100644 --- a/src/ImageSharp/PixelFormats/PixelImplementations/HalfSingle.cs +++ b/src/ImageSharp/PixelFormats/PixelImplementations/HalfSingle.cs @@ -55,7 +55,7 @@ public readonly Vector4 ToScaledVector4() { float single = this.ToSingle() + 1F; single /= 2F; - return new Vector4(single, 0, 0, 1F); + return new(single, 0, 0, 1F); } /// diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/HalfVector4.cs b/src/ImageSharp/PixelFormats/PixelImplementations/HalfVector4.cs index d0b57d788f..254e9290d8 100644 --- a/src/ImageSharp/PixelFormats/PixelImplementations/HalfVector4.cs +++ b/src/ImageSharp/PixelFormats/PixelImplementations/HalfVector4.cs @@ -22,7 +22,7 @@ public partial struct HalfVector4 : IPixel, IPackedVector /// The z-component. /// The w-component. public HalfVector4(float x, float y, float z, float w) - : this(new Vector4(x, y, z, w)) + : this(new(x, y, z, w)) { } diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/L16.cs b/src/ImageSharp/PixelFormats/PixelImplementations/L16.cs index 64a22060c0..faad37ab5d 100644 --- a/src/ImageSharp/PixelFormats/PixelImplementations/L16.cs +++ b/src/ImageSharp/PixelFormats/PixelImplementations/L16.cs @@ -64,7 +64,7 @@ public readonly Rgba32 ToRgba32() public readonly Vector4 ToVector4() { float scaled = this.PackedValue / Max; - return new Vector4(scaled, scaled, scaled, 1f); + return new(scaled, scaled, scaled, 1f); } /// diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/L8.cs b/src/ImageSharp/PixelFormats/PixelImplementations/L8.cs index cf8646cfa0..1ef5951feb 100644 --- a/src/ImageSharp/PixelFormats/PixelImplementations/L8.cs +++ b/src/ImageSharp/PixelFormats/PixelImplementations/L8.cs @@ -66,7 +66,7 @@ public readonly Rgba32 ToRgba32() public readonly Vector4 ToVector4() { float rgb = this.PackedValue / 255f; - return new Vector4(rgb, rgb, rgb, 1f); + return new(rgb, rgb, rgb, 1f); } /// diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/La16.cs b/src/ImageSharp/PixelFormats/PixelImplementations/La16.cs index 026d0c299d..b1149dc3eb 100644 --- a/src/ImageSharp/PixelFormats/PixelImplementations/La16.cs +++ b/src/ImageSharp/PixelFormats/PixelImplementations/La16.cs @@ -93,7 +93,7 @@ public readonly Vector4 ToVector4() { const float max = 255f; float rgb = this.L / max; - return new Vector4(rgb, rgb, rgb, this.A / max); + return new(rgb, rgb, rgb, this.A / max); } /// diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/La32.cs b/src/ImageSharp/PixelFormats/PixelImplementations/La32.cs index 0ddcf16a1f..ec2c38e3ea 100644 --- a/src/ImageSharp/PixelFormats/PixelImplementations/La32.cs +++ b/src/ImageSharp/PixelFormats/PixelImplementations/La32.cs @@ -90,7 +90,7 @@ public readonly Rgba32 ToRgba32() public readonly Vector4 ToVector4() { float rgb = this.L / Max; - return new Vector4(rgb, rgb, rgb, this.A / Max); + return new(rgb, rgb, rgb, this.A / Max); } /// diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/NormalizedByte2.cs b/src/ImageSharp/PixelFormats/PixelImplementations/NormalizedByte2.cs index 9551d7242f..c4b6bf8187 100644 --- a/src/ImageSharp/PixelFormats/PixelImplementations/NormalizedByte2.cs +++ b/src/ImageSharp/PixelFormats/PixelImplementations/NormalizedByte2.cs @@ -24,7 +24,7 @@ public partial struct NormalizedByte2 : IPixel, IPackedVectorThe x-component. /// The y-component. public NormalizedByte2(float x, float y) - : this(new Vector2(x, y)) + : this(new(x, y)) { } @@ -70,7 +70,7 @@ public readonly Vector4 ToScaledVector4() Vector2 scaled = this.ToVector2(); scaled += Vector2.One; scaled /= 2f; - return new Vector4(scaled, 0f, 1f); + return new(scaled, 0f, 1f); } /// @@ -98,7 +98,7 @@ public static NormalizedByte2 FromScaledVector4(Vector4 source) /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static NormalizedByte2 FromVector4(Vector4 source) => new() { PackedValue = Pack(new Vector2(source.X, source.Y)) }; + public static NormalizedByte2 FromVector4(Vector4 source) => new() { PackedValue = Pack(new(source.X, source.Y)) }; /// [MethodImpl(MethodImplOptions.AggressiveInlining)] diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/NormalizedByte4.cs b/src/ImageSharp/PixelFormats/PixelImplementations/NormalizedByte4.cs index 1fb386725a..380465f4e2 100644 --- a/src/ImageSharp/PixelFormats/PixelImplementations/NormalizedByte4.cs +++ b/src/ImageSharp/PixelFormats/PixelImplementations/NormalizedByte4.cs @@ -27,7 +27,7 @@ public partial struct NormalizedByte4 : IPixel, IPackedVectorThe z-component. /// The w-component. public NormalizedByte4(float x, float y, float z, float w) - : this(new Vector4(x, y, z, w)) + : this(new(x, y, z, w)) { } diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/NormalizedShort2.cs b/src/ImageSharp/PixelFormats/PixelImplementations/NormalizedShort2.cs index a17868f6df..edd2271ec0 100644 --- a/src/ImageSharp/PixelFormats/PixelImplementations/NormalizedShort2.cs +++ b/src/ImageSharp/PixelFormats/PixelImplementations/NormalizedShort2.cs @@ -26,7 +26,7 @@ public partial struct NormalizedShort2 : IPixel, IPackedVector /// The x-component. /// The y-component. public NormalizedShort2(float x, float y) - : this(new Vector2(x, y)) + : this(new(x, y)) { } @@ -72,7 +72,7 @@ public readonly Vector4 ToScaledVector4() Vector2 scaled = this.ToVector2(); scaled += Vector2.One; scaled /= 2f; - return new Vector4(scaled, 0f, 1f); + return new(scaled, 0f, 1f); } /// @@ -100,7 +100,7 @@ public static NormalizedShort2 FromScaledVector4(Vector4 source) /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static NormalizedShort2 FromVector4(Vector4 source) => new() { PackedValue = Pack(new Vector2(source.X, source.Y)) }; + public static NormalizedShort2 FromVector4(Vector4 source) => new() { PackedValue = Pack(new(source.X, source.Y)) }; /// [MethodImpl(MethodImplOptions.AggressiveInlining)] diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/NormalizedShort4.cs b/src/ImageSharp/PixelFormats/PixelImplementations/NormalizedShort4.cs index 2b33fec27a..2c30a0a569 100644 --- a/src/ImageSharp/PixelFormats/PixelImplementations/NormalizedShort4.cs +++ b/src/ImageSharp/PixelFormats/PixelImplementations/NormalizedShort4.cs @@ -28,7 +28,7 @@ public partial struct NormalizedShort4 : IPixel, IPackedVector /// The z-component. /// The w-component. public NormalizedShort4(float x, float y, float z, float w) - : this(new Vector4(x, y, z, w)) + : this(new(x, y, z, w)) { } diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/Rg32.cs b/src/ImageSharp/PixelFormats/PixelImplementations/Rg32.cs index e7c97269e1..89b2a65b2e 100644 --- a/src/ImageSharp/PixelFormats/PixelImplementations/Rg32.cs +++ b/src/ImageSharp/PixelFormats/PixelImplementations/Rg32.cs @@ -22,7 +22,7 @@ public partial struct Rg32 : IPixel, IPackedVector /// The x-component /// The y-component public Rg32(float x, float y) - : this(new Vector2(x, y)) + : this(new(x, y)) { } @@ -90,7 +90,7 @@ public static PixelTypeInfo GetPixelTypeInfo() /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Rg32 FromVector4(Vector4 source) => new() { PackedValue = Pack(new Vector2(source.X, source.Y)) }; + public static Rg32 FromVector4(Vector4 source) => new() { PackedValue = Pack(new(source.X, source.Y)) }; /// [MethodImpl(MethodImplOptions.AggressiveInlining)] diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/Rgb24.cs b/src/ImageSharp/PixelFormats/PixelImplementations/Rgb24.cs index 0aa7bad237..16d420d3c3 100644 --- a/src/ImageSharp/PixelFormats/PixelImplementations/Rgb24.cs +++ b/src/ImageSharp/PixelFormats/PixelImplementations/Rgb24.cs @@ -61,7 +61,7 @@ public Rgb24(byte r, byte g, byte b) /// The instance of to convert. /// An instance of . [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static implicit operator Rgb24(Rgb color) => FromScaledVector4(new Vector4(color.ToVector3(), 1f)); + public static implicit operator Rgb24(Rgb color) => FromScaledVector4(new(color.ToVector3(), 1f)); /// /// Compares two objects for equality. diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/Rgba1010102.cs b/src/ImageSharp/PixelFormats/PixelImplementations/Rgba1010102.cs index cdee22964d..a022476fd5 100644 --- a/src/ImageSharp/PixelFormats/PixelImplementations/Rgba1010102.cs +++ b/src/ImageSharp/PixelFormats/PixelImplementations/Rgba1010102.cs @@ -25,7 +25,7 @@ public partial struct Rgba1010102 : IPixel, IPackedVector /// The z-component /// The w-component public Rgba1010102(float x, float y, float z, float w) - : this(new Vector4(x, y, z, w)) + : this(new(x, y, z, w)) { } diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/Rgba32.cs b/src/ImageSharp/PixelFormats/PixelImplementations/Rgba32.cs index 0491553430..b19b3866b0 100644 --- a/src/ImageSharp/PixelFormats/PixelImplementations/Rgba32.cs +++ b/src/ImageSharp/PixelFormats/PixelImplementations/Rgba32.cs @@ -187,7 +187,7 @@ public uint PackedValue /// The instance of to convert. /// An instance of . [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static implicit operator Rgba32(Rgb color) => FromScaledVector4(new Vector4(color.ToVector3(), 1F)); + public static implicit operator Rgba32(Rgb color) => FromScaledVector4(new(color.ToVector3(), 1F)); /// /// Compares two objects for equality. @@ -444,6 +444,6 @@ private static Rgba32 Pack(Vector4 vector) char g = hex[1]; char r = hex[0]; - return new string(new[] { r, r, g, g, b, b, a, a }); + return new(new[] { r, r, g, g, b, b, a, a }); } } diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/Short2.cs b/src/ImageSharp/PixelFormats/PixelImplementations/Short2.cs index 403d3fbea3..c76f870477 100644 --- a/src/ImageSharp/PixelFormats/PixelImplementations/Short2.cs +++ b/src/ImageSharp/PixelFormats/PixelImplementations/Short2.cs @@ -29,7 +29,7 @@ public partial struct Short2 : IPixel, IPackedVector /// The x-component. /// The y-component. public Short2(float x, float y) - : this(new Vector2(x, y)) + : this(new(x, y)) { } @@ -75,7 +75,7 @@ public readonly Vector4 ToScaledVector4() Vector2 scaled = this.ToVector2(); scaled += new Vector2(32767f); scaled /= 65534F; - return new Vector4(scaled, 0f, 1f); + return new(scaled, 0f, 1f); } /// @@ -103,7 +103,7 @@ public static Short2 FromScaledVector4(Vector4 source) /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Short2 FromVector4(Vector4 source) => new() { PackedValue = Pack(new Vector2(source.X, source.Y)) }; + public static Short2 FromVector4(Vector4 source) => new() { PackedValue = Pack(new(source.X, source.Y)) }; /// [MethodImpl(MethodImplOptions.AggressiveInlining)] diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/Short4.cs b/src/ImageSharp/PixelFormats/PixelImplementations/Short4.cs index b6cece2bef..c657263c0e 100644 --- a/src/ImageSharp/PixelFormats/PixelImplementations/Short4.cs +++ b/src/ImageSharp/PixelFormats/PixelImplementations/Short4.cs @@ -31,7 +31,7 @@ public partial struct Short4 : IPixel, IPackedVector /// The z-component. /// The w-component. public Short4(float x, float y, float z, float w) - : this(new Vector4(x, y, z, w)) + : this(new(x, y, z, w)) { } diff --git a/src/ImageSharp/Primitives/ColorMatrix.Impl.cs b/src/ImageSharp/Primitives/ColorMatrix.Impl.cs index 559fcdde08..7eb95569df 100644 --- a/src/ImageSharp/Primitives/ColorMatrix.Impl.cs +++ b/src/ImageSharp/Primitives/ColorMatrix.Impl.cs @@ -181,11 +181,11 @@ public void Init( float m41, float m42, float m43, float m44, float m51, float m52, float m53, float m54) { - this.X = new Vector4(m11, m12, m13, m14); - this.Y = new Vector4(m21, m22, m23, m24); - this.Z = new Vector4(m31, m32, m33, m34); - this.W = new Vector4(m41, m42, m43, m44); - this.V = new Vector4(m51, m52, m53, m54); + this.X = new(m11, m12, m13, m14); + this.Y = new(m21, m22, m23, m24); + this.Z = new(m31, m32, m33, m34); + this.W = new(m41, m42, m43, m44); + this.V = new(m51, m52, m53, m54); } [MethodImpl(MethodImplOptions.AggressiveInlining)] diff --git a/src/ImageSharp/Primitives/Complex64.cs b/src/ImageSharp/Primitives/Complex64.cs index 4baedd9bae..2a16df969c 100644 --- a/src/ImageSharp/Primitives/Complex64.cs +++ b/src/ImageSharp/Primitives/Complex64.cs @@ -42,7 +42,7 @@ public Complex64(float real, float imaginary) /// The scalar to use to multiply the value. /// The result [MethodImpl(InliningOptions.ShortMethod)] - public static Complex64 operator *(Complex64 value, float scalar) => new Complex64(value.Real * scalar, value.Imaginary * scalar); + public static Complex64 operator *(Complex64 value, float scalar) => new(value.Real * scalar, value.Imaginary * scalar); /// /// Performs the multiplication operation between a instance and a . @@ -53,7 +53,7 @@ public Complex64(float real, float imaginary) [MethodImpl(InliningOptions.ShortMethod)] public static ComplexVector4 operator *(Complex64 value, Vector4 vector) { - return new ComplexVector4 { Real = vector * value.Real, Imaginary = vector * value.Imaginary }; + return new() { Real = vector * value.Real, Imaginary = vector * value.Imaginary }; } /// @@ -67,7 +67,7 @@ public Complex64(float real, float imaginary) { Vector4 real = (value.Real * vector.Real) - (value.Imaginary * vector.Imaginary); Vector4 imaginary = (value.Real * vector.Imaginary) + (value.Imaginary * vector.Real); - return new ComplexVector4 { Real = real, Imaginary = imaginary }; + return new() { Real = real, Imaginary = imaginary }; } /// diff --git a/src/ImageSharp/Primitives/DenseMatrix{T}.cs b/src/ImageSharp/Primitives/DenseMatrix{T}.cs index 9849e0211f..b39f306cbf 100644 --- a/src/ImageSharp/Primitives/DenseMatrix{T}.cs +++ b/src/ImageSharp/Primitives/DenseMatrix{T}.cs @@ -36,7 +36,7 @@ public DenseMatrix(int columns, int rows) this.Rows = rows; this.Columns = columns; - this.Size = new Size(columns, rows); + this.Size = new(columns, rows); this.Count = columns * rows; this.Data = new T[this.Columns * this.Rows]; } @@ -56,7 +56,7 @@ public DenseMatrix(T[,] data) this.Rows = rows; this.Columns = columns; - this.Size = new Size(columns, rows); + this.Size = new(columns, rows); this.Count = this.Columns * this.Rows; this.Data = new T[this.Columns * this.Rows]; @@ -84,7 +84,7 @@ public DenseMatrix(int columns, int rows, Span data) this.Rows = rows; this.Columns = columns; - this.Size = new Size(columns, rows); + this.Size = new(columns, rows); this.Count = this.Columns * this.Rows; this.Data = new T[this.Columns * this.Rows]; @@ -198,7 +198,7 @@ public DenseMatrix(int columns, int rows, Span data) [MethodImpl(MethodImplOptions.AggressiveInlining)] public DenseMatrix Transpose() { - DenseMatrix result = new DenseMatrix(this.Rows, this.Columns); + DenseMatrix result = new(this.Rows, this.Columns); for (int y = 0; y < this.Rows; y++) { diff --git a/src/ImageSharp/Primitives/LongRational.cs b/src/ImageSharp/Primitives/LongRational.cs index 69139ac9c4..0b3380ca97 100644 --- a/src/ImageSharp/Primitives/LongRational.cs +++ b/src/ImageSharp/Primitives/LongRational.cs @@ -133,22 +133,22 @@ public static LongRational FromDouble(double value, bool bestPrecision) { if (value == 0.0) { - return new LongRational(0, 1); + return new(0, 1); } if (double.IsNaN(value)) { - return new LongRational(0, 0); + return new(0, 0); } if (double.IsPositiveInfinity(value)) { - return new LongRational(1, 0); + return new(1, 0); } if (double.IsNegativeInfinity(value)) { - return new LongRational(-1, 0); + return new(-1, 0); } long numerator = 1; @@ -208,14 +208,14 @@ public LongRational Simplify() if (this.Numerator == this.Denominator) { - return new LongRational(1, 1); + return new(1, 1); } long gcd = GreatestCommonDivisor(Math.Abs(this.Numerator), Math.Abs(this.Denominator)); if (gcd > 1) { - return new LongRational(this.Numerator / gcd, this.Denominator / gcd); + return new(this.Numerator / gcd, this.Denominator / gcd); } return this; diff --git a/src/ImageSharp/Primitives/Number.cs b/src/ImageSharp/Primitives/Number.cs index fae67bbea1..a996a94f4d 100644 --- a/src/ImageSharp/Primitives/Number.cs +++ b/src/ImageSharp/Primitives/Number.cs @@ -47,19 +47,19 @@ public Number(uint value) /// Converts the specified to an instance of this type. /// /// The value. - public static implicit operator Number(int value) => new Number(value); + public static implicit operator Number(int value) => new(value); /// /// Converts the specified to an instance of this type. /// /// The value. - public static implicit operator Number(uint value) => new Number(value); + public static implicit operator Number(uint value) => new(value); /// /// Converts the specified to an instance of this type. /// /// The value. - public static implicit operator Number(ushort value) => new Number((uint)value); + public static implicit operator Number(ushort value) => new((uint)value); /// /// Converts the specified to a . diff --git a/src/ImageSharp/Primitives/Point.cs b/src/ImageSharp/Primitives/Point.cs index 8ace7ffacf..5eae087ed9 100644 --- a/src/ImageSharp/Primitives/Point.cs +++ b/src/ImageSharp/Primitives/Point.cs @@ -232,7 +232,7 @@ public Point(Size size) /// The transformation matrix used. /// The transformed . [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Point Transform(Point point, Matrix3x2 matrix) => Round(Vector2.Transform(new Vector2(point.X, point.Y), matrix)); + public static Point Transform(Point point, Matrix3x2 matrix) => Round(Vector2.Transform(new(point.X, point.Y), matrix)); /// /// Deconstructs this point into two integers. diff --git a/src/ImageSharp/Primitives/Rectangle.cs b/src/ImageSharp/Primitives/Rectangle.cs index e2ae5071ef..a3cb89cf01 100644 --- a/src/ImageSharp/Primitives/Rectangle.cs +++ b/src/ImageSharp/Primitives/Rectangle.cs @@ -214,7 +214,7 @@ public static Rectangle Intersect(Rectangle a, Rectangle b) if (x2 >= x1 && y2 >= y1) { - return new Rectangle(x1, y1, x2 - x1, y2 - y1); + return new(x1, y1, x2 - x1, y2 - y1); } return Empty; @@ -245,7 +245,7 @@ public static Rectangle Ceiling(RectangleF rectangle) { unchecked { - return new Rectangle( + return new( (int)MathF.Ceiling(rectangle.X), (int)MathF.Ceiling(rectangle.Y), (int)MathF.Ceiling(rectangle.Width), @@ -261,9 +261,9 @@ public static Rectangle Ceiling(RectangleF rectangle) /// A transformed rectangle. public static RectangleF Transform(Rectangle rectangle, Matrix3x2 matrix) { - PointF bottomRight = Point.Transform(new Point(rectangle.Right, rectangle.Bottom), matrix); + PointF bottomRight = Point.Transform(new(rectangle.Right, rectangle.Bottom), matrix); PointF topLeft = Point.Transform(rectangle.Location, matrix); - return new RectangleF(topLeft, new SizeF(bottomRight - topLeft)); + return new(topLeft, new(bottomRight - topLeft)); } /// @@ -276,7 +276,7 @@ public static Rectangle Truncate(RectangleF rectangle) { unchecked { - return new Rectangle( + return new( (int)rectangle.X, (int)rectangle.Y, (int)rectangle.Width, @@ -294,7 +294,7 @@ public static Rectangle Round(RectangleF rectangle) { unchecked { - return new Rectangle( + return new( (int)MathF.Round(rectangle.X), (int)MathF.Round(rectangle.Y), (int)MathF.Round(rectangle.Width), @@ -316,7 +316,7 @@ public static Rectangle Union(Rectangle a, Rectangle b) int y1 = Math.Min(a.Y, b.Y); int y2 = Math.Max(a.Bottom, b.Bottom); - return new Rectangle(x1, y1, x2 - x1, y2 - y1); + return new(x1, y1, x2 - x1, y2 - y1); } /// diff --git a/src/ImageSharp/Primitives/RectangleF.cs b/src/ImageSharp/Primitives/RectangleF.cs index 68add77d09..9a7a97a13c 100644 --- a/src/ImageSharp/Primitives/RectangleF.cs +++ b/src/ImageSharp/Primitives/RectangleF.cs @@ -207,7 +207,7 @@ public static RectangleF Intersect(RectangleF a, RectangleF b) if (x2 >= x1 && y2 >= y1) { - return new RectangleF(x1, y1, x2 - x1, y2 - y1); + return new(x1, y1, x2 - x1, y2 - y1); } return Empty; @@ -236,9 +236,9 @@ public static RectangleF Inflate(RectangleF rectangle, float x, float y) /// A transformed . public static RectangleF Transform(RectangleF rectangle, Matrix3x2 matrix) { - PointF bottomRight = PointF.Transform(new PointF(rectangle.Right, rectangle.Bottom), matrix); + PointF bottomRight = PointF.Transform(new(rectangle.Right, rectangle.Bottom), matrix); PointF topLeft = PointF.Transform(rectangle.Location, matrix); - return new RectangleF(topLeft, new SizeF(bottomRight - topLeft)); + return new(topLeft, new(bottomRight - topLeft)); } /// @@ -255,7 +255,7 @@ public static RectangleF Union(RectangleF a, RectangleF b) float y1 = MathF.Min(a.Y, b.Y); float y2 = MathF.Max(a.Bottom, b.Bottom); - return new RectangleF(x1, y1, x2 - x1, y2 - y1); + return new(x1, y1, x2 - x1, y2 - y1); } /// diff --git a/src/ImageSharp/Primitives/SignedRational.cs b/src/ImageSharp/Primitives/SignedRational.cs index d56ea825e6..2b62b4c3e7 100644 --- a/src/ImageSharp/Primitives/SignedRational.cs +++ b/src/ImageSharp/Primitives/SignedRational.cs @@ -42,7 +42,7 @@ public SignedRational(int numerator, int denominator, bool simplify) { if (simplify) { - var rational = new LongRational(numerator, denominator).Simplify(); + LongRational rational = new LongRational(numerator, denominator).Simplify(); this.Numerator = (int)rational.Numerator; this.Denominator = (int)rational.Denominator; @@ -70,7 +70,7 @@ public SignedRational(double value) /// Whether to use the best possible precision when parsing the value. public SignedRational(double value, bool bestPrecision) { - var rational = LongRational.FromDouble(value, bestPrecision); + LongRational rational = LongRational.FromDouble(value, bestPrecision); this.Numerator = (int)rational.Numerator; this.Denominator = (int)rational.Denominator; @@ -117,7 +117,7 @@ public SignedRational(double value, bool bestPrecision) /// public static SignedRational FromDouble(double value) { - return new SignedRational(value, false); + return new(value, false); } /// @@ -130,7 +130,7 @@ public static SignedRational FromDouble(double value) /// public static SignedRational FromDouble(double value, bool bestPrecision) { - return new SignedRational(value, bestPrecision); + return new(value, bestPrecision); } /// @@ -142,8 +142,8 @@ public override bool Equals(object? obj) /// public bool Equals(SignedRational other) { - var left = new LongRational(this.Numerator, this.Denominator); - var right = new LongRational(other.Numerator, other.Denominator); + LongRational left = new(this.Numerator, this.Denominator); + LongRational right = new(other.Numerator, other.Denominator); return left.Equals(right); } @@ -151,7 +151,7 @@ public bool Equals(SignedRational other) /// public override int GetHashCode() { - var self = new LongRational(this.Numerator, this.Denominator); + LongRational self = new(this.Numerator, this.Denominator); return self.GetHashCode(); } @@ -182,7 +182,7 @@ public override string ToString() /// The public string ToString(IFormatProvider provider) { - var rational = new LongRational(this.Numerator, this.Denominator); + LongRational rational = new(this.Numerator, this.Denominator); return rational.ToString(provider); } } diff --git a/src/ImageSharp/Primitives/Size.cs b/src/ImageSharp/Primitives/Size.cs index 945b680daa..5ceab493f9 100644 --- a/src/ImageSharp/Primitives/Size.cs +++ b/src/ImageSharp/Primitives/Size.cs @@ -85,14 +85,14 @@ public Size(Point point) /// /// The point. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static implicit operator SizeF(Size size) => new SizeF(size.Width, size.Height); + public static implicit operator SizeF(Size size) => new(size.Width, size.Height); /// /// Converts the given into a . /// /// The size. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static explicit operator Point(Size size) => new Point(size.Width, size.Height); + public static explicit operator Point(Size size) => new(size.Width, size.Height); /// /// Computes the sum of adding two sizes. @@ -138,7 +138,7 @@ public Size(Point point) /// Dividend of type . /// Divisor of type . /// Result of type . - public static Size operator /(Size left, int right) => new Size(unchecked(left.Width / right), unchecked(left.Height / right)); + public static Size operator /(Size left, int right) => new(unchecked(left.Width / right), unchecked(left.Height / right)); /// /// Multiplies by a producing . @@ -163,7 +163,7 @@ public Size(Point point) /// Divisor of type . /// Result of type . public static SizeF operator /(Size left, float right) - => new SizeF(left.Width / right, left.Height / right); + => new(left.Width / right, left.Height / right); /// /// Compares two objects for equality. @@ -202,7 +202,7 @@ public Size(Point point) /// The size on the right hand of the operand. /// The . [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Size Add(Size left, Size right) => new Size(unchecked(left.Width + right.Width), unchecked(left.Height + right.Height)); + public static Size Add(Size left, Size right) => new(unchecked(left.Width + right.Width), unchecked(left.Height + right.Height)); /// /// Contracts a by another . @@ -211,7 +211,7 @@ public Size(Point point) /// The size on the right hand of the operand. /// The . [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Size Subtract(Size left, Size right) => new Size(unchecked(left.Width - right.Width), unchecked(left.Height - right.Height)); + public static Size Subtract(Size left, Size right) => new(unchecked(left.Width - right.Width), unchecked(left.Height - right.Height)); /// /// Converts a to a by performing a ceiling operation on all the dimensions. @@ -219,7 +219,7 @@ public Size(Point point) /// The size. /// The . [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Size Ceiling(SizeF size) => new Size(unchecked((int)MathF.Ceiling(size.Width)), unchecked((int)MathF.Ceiling(size.Height))); + public static Size Ceiling(SizeF size) => new(unchecked((int)MathF.Ceiling(size.Width)), unchecked((int)MathF.Ceiling(size.Height))); /// /// Converts a to a by performing a round operation on all the dimensions. @@ -227,7 +227,7 @@ public Size(Point point) /// The size. /// The . [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Size Round(SizeF size) => new Size(unchecked((int)MathF.Round(size.Width)), unchecked((int)MathF.Round(size.Height))); + public static Size Round(SizeF size) => new(unchecked((int)MathF.Round(size.Width)), unchecked((int)MathF.Round(size.Height))); /// /// Transforms a size by the given matrix. @@ -237,9 +237,9 @@ public Size(Point point) /// A transformed size. public static SizeF Transform(Size size, Matrix3x2 matrix) { - var v = Vector2.Transform(new Vector2(size.Width, size.Height), matrix); + Vector2 v = Vector2.Transform(new(size.Width, size.Height), matrix); - return new SizeF(v.X, v.Y); + return new(v.X, v.Y); } /// @@ -248,7 +248,7 @@ public static SizeF Transform(Size size, Matrix3x2 matrix) /// The size. /// The . [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Size Truncate(SizeF size) => new Size(unchecked((int)size.Width), unchecked((int)size.Height)); + public static Size Truncate(SizeF size) => new(unchecked((int)size.Width), unchecked((int)size.Height)); /// /// Deconstructs this size into two integers. @@ -281,7 +281,7 @@ public void Deconstruct(out int width, out int height) /// Multiplier of type . /// Product of type . private static Size Multiply(Size size, int multiplier) => - new Size(unchecked(size.Width * multiplier), unchecked(size.Height * multiplier)); + new(unchecked(size.Width * multiplier), unchecked(size.Height * multiplier)); /// /// Multiplies by a producing . @@ -290,5 +290,5 @@ private static Size Multiply(Size size, int multiplier) => /// Multiplier of type . /// Product of type SizeF. private static SizeF Multiply(Size size, float multiplier) => - new SizeF(size.Width * multiplier, size.Height * multiplier); + new(size.Width * multiplier, size.Height * multiplier); } diff --git a/src/ImageSharp/Primitives/SizeF.cs b/src/ImageSharp/Primitives/SizeF.cs index 36cf9eb8ef..88c3b8319a 100644 --- a/src/ImageSharp/Primitives/SizeF.cs +++ b/src/ImageSharp/Primitives/SizeF.cs @@ -191,9 +191,9 @@ public SizeF(PointF point) /// A transformed size. public static SizeF Transform(SizeF size, Matrix3x2 matrix) { - var v = Vector2.Transform(new Vector2(size.Width, size.Height), matrix); + Vector2 v = Vector2.Transform(new(size.Width, size.Height), matrix); - return new SizeF(v.X, v.Y); + return new(v.X, v.Y); } /// diff --git a/src/ImageSharp/Primitives/ValueSize.cs b/src/ImageSharp/Primitives/ValueSize.cs index f572dd658f..9a76269b3b 100644 --- a/src/ImageSharp/Primitives/ValueSize.cs +++ b/src/ImageSharp/Primitives/ValueSize.cs @@ -68,7 +68,7 @@ public enum ValueSizeType /// a Values size with type PercentageOfWidth public static ValueSize PercentageOfWidth(float percentage) { - return new ValueSize(percentage, ValueSizeType.PercentageOfWidth); + return new(percentage, ValueSizeType.PercentageOfWidth); } /// @@ -78,7 +78,7 @@ public static ValueSize PercentageOfWidth(float percentage) /// a Values size with type PercentageOfHeight public static ValueSize PercentageOfHeight(float percentage) { - return new ValueSize(percentage, ValueSizeType.PercentageOfHeight); + return new(percentage, ValueSizeType.PercentageOfHeight); } /// @@ -88,7 +88,7 @@ public static ValueSize PercentageOfHeight(float percentage) /// a Values size with type Absolute. public static ValueSize Absolute(float value) { - return new ValueSize(value, ValueSizeType.Absolute); + return new(value, ValueSizeType.Absolute); } /// diff --git a/src/ImageSharp/Processing/Extensions/Convolution/BoxBlurExtensions.cs b/src/ImageSharp/Processing/Extensions/Convolution/BoxBlurExtensions.cs index 6611af742b..3f75388140 100644 --- a/src/ImageSharp/Processing/Extensions/Convolution/BoxBlurExtensions.cs +++ b/src/ImageSharp/Processing/Extensions/Convolution/BoxBlurExtensions.cs @@ -57,7 +57,7 @@ public static IImageProcessingContext BoxBlur(this IImageProcessingContext sourc /// The . public static IImageProcessingContext BoxBlur(this IImageProcessingContext source, int radius, Rectangle rectangle, BorderWrappingMode borderWrapModeX, BorderWrappingMode borderWrapModeY) { - var processor = new BoxBlurProcessor(radius, borderWrapModeX, borderWrapModeY); + BoxBlurProcessor processor = new(radius, borderWrapModeX, borderWrapModeY); return source.ApplyProcessor(processor, rectangle); } } diff --git a/src/ImageSharp/Processing/Extensions/Convolution/DetectEdgesExtensions.cs b/src/ImageSharp/Processing/Extensions/Convolution/DetectEdgesExtensions.cs index b044c3966f..1cf65c8864 100644 --- a/src/ImageSharp/Processing/Extensions/Convolution/DetectEdgesExtensions.cs +++ b/src/ImageSharp/Processing/Extensions/Convolution/DetectEdgesExtensions.cs @@ -58,7 +58,7 @@ public static IImageProcessingContext DetectEdges( EdgeDetector2DKernel kernel, bool grayscale) { - var processor = new EdgeDetector2DProcessor(kernel, grayscale); + EdgeDetector2DProcessor processor = new(kernel, grayscale); source.ApplyProcessor(processor); return source; } @@ -96,7 +96,7 @@ public static IImageProcessingContext DetectEdges( bool grayscale, Rectangle rectangle) { - var processor = new EdgeDetector2DProcessor(kernel, grayscale); + EdgeDetector2DProcessor processor = new(kernel, grayscale); source.ApplyProcessor(processor, rectangle); return source; } @@ -126,7 +126,7 @@ public static IImageProcessingContext DetectEdges( EdgeDetectorKernel kernel, bool grayscale) { - var processor = new EdgeDetectorProcessor(kernel, grayscale); + EdgeDetectorProcessor processor = new(kernel, grayscale); source.ApplyProcessor(processor); return source; } @@ -164,7 +164,7 @@ public static IImageProcessingContext DetectEdges( bool grayscale, Rectangle rectangle) { - var processor = new EdgeDetectorProcessor(kernel, grayscale); + EdgeDetectorProcessor processor = new(kernel, grayscale); source.ApplyProcessor(processor, rectangle); return source; } @@ -194,7 +194,7 @@ public static IImageProcessingContext DetectEdges( EdgeDetectorCompassKernel kernel, bool grayscale) { - var processor = new EdgeDetectorCompassProcessor(kernel, grayscale); + EdgeDetectorCompassProcessor processor = new(kernel, grayscale); source.ApplyProcessor(processor); return source; } @@ -232,7 +232,7 @@ public static IImageProcessingContext DetectEdges( bool grayscale, Rectangle rectangle) { - var processor = new EdgeDetectorCompassProcessor(kernel, grayscale); + EdgeDetectorCompassProcessor processor = new(kernel, grayscale); source.ApplyProcessor(processor, rectangle); return source; } diff --git a/src/ImageSharp/Processing/Extensions/Convolution/GaussianBlurExtensions.cs b/src/ImageSharp/Processing/Extensions/Convolution/GaussianBlurExtensions.cs index b851482008..64e0be3eac 100644 --- a/src/ImageSharp/Processing/Extensions/Convolution/GaussianBlurExtensions.cs +++ b/src/ImageSharp/Processing/Extensions/Convolution/GaussianBlurExtensions.cs @@ -57,7 +57,7 @@ public static IImageProcessingContext GaussianBlur(this IImageProcessingContext /// The . public static IImageProcessingContext GaussianBlur(this IImageProcessingContext source, float sigma, Rectangle rectangle, BorderWrappingMode borderWrapModeX, BorderWrappingMode borderWrapModeY) { - var processor = new GaussianBlurProcessor(sigma, borderWrapModeX, borderWrapModeY); + GaussianBlurProcessor processor = new(sigma, borderWrapModeX, borderWrapModeY); return source.ApplyProcessor(processor, rectangle); } } diff --git a/src/ImageSharp/Processing/Extensions/Convolution/GaussianSharpenExtensions.cs b/src/ImageSharp/Processing/Extensions/Convolution/GaussianSharpenExtensions.cs index 4a94df0963..b576007aac 100644 --- a/src/ImageSharp/Processing/Extensions/Convolution/GaussianSharpenExtensions.cs +++ b/src/ImageSharp/Processing/Extensions/Convolution/GaussianSharpenExtensions.cs @@ -60,7 +60,7 @@ public static IImageProcessingContext GaussianSharpen( /// The . public static IImageProcessingContext GaussianSharpen(this IImageProcessingContext source, float sigma, Rectangle rectangle, BorderWrappingMode borderWrapModeX, BorderWrappingMode borderWrapModeY) { - var processor = new GaussianSharpenProcessor(sigma, borderWrapModeX, borderWrapModeY); + GaussianSharpenProcessor processor = new(sigma, borderWrapModeX, borderWrapModeY); return source.ApplyProcessor(processor, rectangle); } } diff --git a/src/ImageSharp/Processing/Extensions/Normalization/HistogramEqualizationExtensions.cs b/src/ImageSharp/Processing/Extensions/Normalization/HistogramEqualizationExtensions.cs index d7f4ba3594..6af61338d1 100644 --- a/src/ImageSharp/Processing/Extensions/Normalization/HistogramEqualizationExtensions.cs +++ b/src/ImageSharp/Processing/Extensions/Normalization/HistogramEqualizationExtensions.cs @@ -16,7 +16,7 @@ public static class HistogramEqualizationExtensions /// The current image processing context. /// The . public static IImageProcessingContext HistogramEqualization(this IImageProcessingContext source) => - HistogramEqualization(source, new HistogramEqualizationOptions()); + HistogramEqualization(source, new()); /// /// Equalizes the histogram of an image to increases the contrast. diff --git a/src/ImageSharp/Processing/Extensions/ProcessingExtensions.IntegralImage.cs b/src/ImageSharp/Processing/Extensions/ProcessingExtensions.IntegralImage.cs index 713d4d5b77..3d1c3d2e0e 100644 --- a/src/ImageSharp/Processing/Extensions/ProcessingExtensions.IntegralImage.cs +++ b/src/ImageSharp/Processing/Extensions/ProcessingExtensions.IntegralImage.cs @@ -56,7 +56,7 @@ public static Buffer2D CalculateIntegralImage(this ImageFrameThe target image height. /// The . public static IImageProcessingContext Crop(this IImageProcessingContext source, int width, int height) => - Crop(source, new Rectangle(0, 0, width, height)); + Crop(source, new(0, 0, width, height)); /// /// Crops an image to the given rectangle. diff --git a/src/ImageSharp/Processing/Extensions/Transforms/PadExtensions.cs b/src/ImageSharp/Processing/Extensions/Transforms/PadExtensions.cs index b6db0172dc..cca3e42412 100644 --- a/src/ImageSharp/Processing/Extensions/Transforms/PadExtensions.cs +++ b/src/ImageSharp/Processing/Extensions/Transforms/PadExtensions.cs @@ -30,10 +30,10 @@ public static IImageProcessingContext Pad(this IImageProcessingContext source, i public static IImageProcessingContext Pad(this IImageProcessingContext source, int width, int height, Color color) { Size size = source.GetCurrentSize(); - var options = new ResizeOptions + ResizeOptions options = new() { // Prevent downsizing. - Size = new Size(Math.Max(width, size.Width), Math.Max(height, size.Height)), + Size = new(Math.Max(width, size.Width), Math.Max(height, size.Height)), Mode = ResizeMode.BoxPad, Sampler = KnownResamplers.NearestNeighbor, PadColor = color diff --git a/src/ImageSharp/Processing/Extensions/Transforms/ResizeExtensions.cs b/src/ImageSharp/Processing/Extensions/Transforms/ResizeExtensions.cs index 01f296d096..3ac9553d4d 100644 --- a/src/ImageSharp/Processing/Extensions/Transforms/ResizeExtensions.cs +++ b/src/ImageSharp/Processing/Extensions/Transforms/ResizeExtensions.cs @@ -77,7 +77,7 @@ public static IImageProcessingContext Resize(this IImageProcessingContext source /// The . /// Passing zero for one of height or width will automatically preserve the aspect ratio of the original image or the nearest possible ratio. public static IImageProcessingContext Resize(this IImageProcessingContext source, Size size, IResampler sampler, bool compand) - => Resize(source, size.Width, size.Height, sampler, new Rectangle(0, 0, size.Width, size.Height), compand); + => Resize(source, size.Width, size.Height, sampler, new(0, 0, size.Width, size.Height), compand); /// /// Resizes an image to the given width and height with the given sampler. @@ -90,7 +90,7 @@ public static IImageProcessingContext Resize(this IImageProcessingContext source /// The . /// Passing zero for one of height or width will automatically preserve the aspect ratio of the original image or the nearest possible ratio. public static IImageProcessingContext Resize(this IImageProcessingContext source, int width, int height, IResampler sampler, bool compand) - => Resize(source, width, height, sampler, new Rectangle(0, 0, width, height), compand); + => Resize(source, width, height, sampler, new(0, 0, width, height), compand); /// /// Resizes an image to the given width and height with the given sampler and @@ -118,9 +118,9 @@ public static IImageProcessingContext Resize( Rectangle targetRectangle, bool compand) { - var options = new ResizeOptions + ResizeOptions options = new() { - Size = new Size(width, height), + Size = new(width, height), Mode = ResizeMode.Manual, Sampler = sampler, TargetRectangle = targetRectangle, @@ -151,9 +151,9 @@ public static IImageProcessingContext Resize( Rectangle targetRectangle, bool compand) { - var options = new ResizeOptions + ResizeOptions options = new() { - Size = new Size(width, height), + Size = new(width, height), Mode = ResizeMode.Manual, Sampler = sampler, TargetRectangle = targetRectangle, diff --git a/src/ImageSharp/Processing/Extensions/Transforms/TransformExtensions.cs b/src/ImageSharp/Processing/Extensions/Transforms/TransformExtensions.cs index 60f90b10f2..dedde797bd 100644 --- a/src/ImageSharp/Processing/Extensions/Transforms/TransformExtensions.cs +++ b/src/ImageSharp/Processing/Extensions/Transforms/TransformExtensions.cs @@ -34,7 +34,7 @@ public static IImageProcessingContext Transform( this IImageProcessingContext source, AffineTransformBuilder builder, IResampler sampler) => - source.Transform(new Rectangle(Point.Empty, source.GetCurrentSize()), builder, sampler); + source.Transform(new(Point.Empty, source.GetCurrentSize()), builder, sampler); /// /// Performs an affine transform of an image using the specified sampling algorithm. @@ -96,7 +96,7 @@ public static IImageProcessingContext Transform( this IImageProcessingContext source, ProjectiveTransformBuilder builder, IResampler sampler) => - source.Transform(new Rectangle(Point.Empty, source.GetCurrentSize()), builder, sampler); + source.Transform(new(Point.Empty, source.GetCurrentSize()), builder, sampler); /// /// Performs a projective transform of an image using the specified sampling algorithm. diff --git a/src/ImageSharp/Processing/KnownFilterMatrices.cs b/src/ImageSharp/Processing/KnownFilterMatrices.cs index b312287b52..0b40fa945d 100644 --- a/src/ImageSharp/Processing/KnownFilterMatrices.cs +++ b/src/ImageSharp/Processing/KnownFilterMatrices.cs @@ -20,7 +20,7 @@ public static class KnownFilterMatrices /// /// Gets a filter recreating Achromatomaly (Color desensitivity) color blindness /// - public static ColorMatrix AchromatomalyFilter { get; } = new ColorMatrix + public static ColorMatrix AchromatomalyFilter { get; } = new() { M11 = .618F, M12 = .163F, @@ -37,7 +37,7 @@ public static class KnownFilterMatrices /// /// Gets a filter recreating Achromatopsia (Monochrome) color blindness. /// - public static ColorMatrix AchromatopsiaFilter { get; } = new ColorMatrix + public static ColorMatrix AchromatopsiaFilter { get; } = new() { M11 = .299F, M12 = .299F, @@ -54,7 +54,7 @@ public static class KnownFilterMatrices /// /// Gets a filter recreating Deuteranomaly (Green-Weak) color blindness. /// - public static ColorMatrix DeuteranomalyFilter { get; } = new ColorMatrix + public static ColorMatrix DeuteranomalyFilter { get; } = new() { M11 = .8F, M12 = .258F, @@ -68,7 +68,7 @@ public static class KnownFilterMatrices /// /// Gets a filter recreating Deuteranopia (Green-Blind) color blindness. /// - public static ColorMatrix DeuteranopiaFilter { get; } = new ColorMatrix + public static ColorMatrix DeuteranopiaFilter { get; } = new() { M11 = .625F, M12 = .7F, @@ -82,7 +82,7 @@ public static class KnownFilterMatrices /// /// Gets a filter recreating Protanomaly (Red-Weak) color blindness. /// - public static ColorMatrix ProtanomalyFilter { get; } = new ColorMatrix + public static ColorMatrix ProtanomalyFilter { get; } = new() { M11 = .817F, M12 = .333F, @@ -96,7 +96,7 @@ public static class KnownFilterMatrices /// /// Gets a filter recreating Protanopia (Red-Blind) color blindness. /// - public static ColorMatrix ProtanopiaFilter { get; } = new ColorMatrix + public static ColorMatrix ProtanopiaFilter { get; } = new() { M11 = .567F, M12 = .558F, @@ -110,7 +110,7 @@ public static class KnownFilterMatrices /// /// Gets a filter recreating Tritanomaly (Blue-Weak) color blindness. /// - public static ColorMatrix TritanomalyFilter { get; } = new ColorMatrix + public static ColorMatrix TritanomalyFilter { get; } = new() { M11 = .967F, M21 = .33F, @@ -124,7 +124,7 @@ public static class KnownFilterMatrices /// /// Gets a filter recreating Tritanopia (Blue-Blind) color blindness. /// - public static ColorMatrix TritanopiaFilter { get; } = new ColorMatrix + public static ColorMatrix TritanopiaFilter { get; } = new() { M11 = .95F, M21 = .05F, @@ -138,7 +138,7 @@ public static class KnownFilterMatrices /// /// Gets an approximated black and white filter /// - public static ColorMatrix BlackWhiteFilter { get; } = new ColorMatrix + public static ColorMatrix BlackWhiteFilter { get; } = new() { M11 = 1.5F, M12 = 1.5F, @@ -190,7 +190,7 @@ public static class KnownFilterMatrices /// /// Gets a filter recreating an old Polaroid camera effect. /// - public static ColorMatrix PolaroidFilter { get; } = new ColorMatrix + public static ColorMatrix PolaroidFilter { get; } = new() { M11 = 1.538F, M12 = -.062F, @@ -221,7 +221,7 @@ public static ColorMatrix CreateBrightnessFilter(float amount) Guard.MustBeGreaterThanOrEqualTo(amount, 0, nameof(amount)); // See https://cs.chromium.org/chromium/src/cc/paint/render_surface_filters.cc - return new ColorMatrix + return new() { M11 = amount, M22 = amount, @@ -246,7 +246,7 @@ public static ColorMatrix CreateContrastFilter(float amount) // See https://cs.chromium.org/chromium/src/cc/paint/render_surface_filters.cc float contrast = (-.5F * amount) + .5F; - return new ColorMatrix + return new() { M11 = amount, M22 = amount, @@ -338,7 +338,7 @@ public static ColorMatrix CreateHueFilter(float degrees) // The matrix is set up to preserve the luminance of the image. // See http://graficaobscura.com/matrix/index.html // Number are taken from https://msdn.microsoft.com/en-us/library/jj192162(v=vs.85).aspx - return new ColorMatrix + return new() { M11 = .213F + (cosRadian * .787F) - (sinRadian * .213F), M21 = .715F - (cosRadian * .715F) - (sinRadian * .715F), @@ -367,7 +367,7 @@ public static ColorMatrix CreateInvertFilter(float amount) // See https://cs.chromium.org/chromium/src/cc/paint/render_surface_filters.cc float invert = 1F - (2F * amount); - return new ColorMatrix + return new() { M11 = invert, M22 = invert, @@ -389,7 +389,7 @@ public static ColorMatrix CreateOpacityFilter(float amount) Guard.MustBeBetweenOrEqualTo(amount, 0, 1, nameof(amount)); // See https://cs.chromium.org/chromium/src/cc/paint/render_surface_filters.cc - return new ColorMatrix + return new() { M11 = 1F, M22 = 1F, @@ -443,7 +443,7 @@ public static ColorMatrix CreateLightnessFilter(float amount) Guard.MustBeGreaterThanOrEqualTo(amount, 0, nameof(amount)); amount--; - return new ColorMatrix + return new() { M11 = 1F, M22 = 1F, @@ -467,7 +467,7 @@ public static ColorMatrix CreateSepiaFilter(float amount) amount = 1F - amount; // See https://cs.chromium.org/chromium/src/cc/paint/render_surface_filters.cc - return new ColorMatrix + return new() { M11 = .393F + (.607F * amount), M21 = .769F - (.769F * amount), diff --git a/src/ImageSharp/Processing/Processors/Binarization/AdaptiveThresholdProcessor{TPixel}.cs b/src/ImageSharp/Processing/Processors/Binarization/AdaptiveThresholdProcessor{TPixel}.cs index 73c7c3302d..651d9a5c45 100644 --- a/src/ImageSharp/Processing/Processors/Binarization/AdaptiveThresholdProcessor{TPixel}.cs +++ b/src/ImageSharp/Processing/Processors/Binarization/AdaptiveThresholdProcessor{TPixel}.cs @@ -30,7 +30,7 @@ public AdaptiveThresholdProcessor(Configuration configuration, AdaptiveThreshold /// protected override void OnFrameApply(ImageFrame source) { - var interest = Rectangle.Intersect(this.SourceRectangle, source.Bounds()); + Rectangle interest = Rectangle.Intersect(this.SourceRectangle, source.Bounds()); Configuration configuration = this.Configuration; TPixel upper = this.definition.Upper.ToPixel(); diff --git a/src/ImageSharp/Processing/Processors/Binarization/BinaryThresholdProcessor{TPixel}.cs b/src/ImageSharp/Processing/Processors/Binarization/BinaryThresholdProcessor{TPixel}.cs index 1c76ea6a45..410c53c0d8 100644 --- a/src/ImageSharp/Processing/Processors/Binarization/BinaryThresholdProcessor{TPixel}.cs +++ b/src/ImageSharp/Processing/Processors/Binarization/BinaryThresholdProcessor{TPixel}.cs @@ -38,8 +38,8 @@ protected override void OnFrameApply(ImageFrame source) Rectangle sourceRectangle = this.SourceRectangle; Configuration configuration = this.Configuration; - var interest = Rectangle.Intersect(sourceRectangle, source.Bounds()); - var operation = new RowOperation( + Rectangle interest = Rectangle.Intersect(sourceRectangle, source.Bounds()); + RowOperation operation = new( interest.X, source.PixelBuffer, upper, diff --git a/src/ImageSharp/Processing/Processors/CloningImageProcessor{TPixel}.cs b/src/ImageSharp/Processing/Processors/CloningImageProcessor{TPixel}.cs index abe32e3882..af509df419 100644 --- a/src/ImageSharp/Processing/Processors/CloningImageProcessor{TPixel}.cs +++ b/src/ImageSharp/Processing/Processors/CloningImageProcessor{TPixel}.cs @@ -160,7 +160,7 @@ private Image CreateTarget() ImageFrame[] destinationFrames = new ImageFrame[source.Frames.Count]; for (int i = 0; i < destinationFrames.Length; i++) { - destinationFrames[i] = new ImageFrame( + destinationFrames[i] = new( this.Configuration, destinationSize.Width, destinationSize.Height, @@ -168,7 +168,7 @@ private Image CreateTarget() } // Use the overload to prevent an extra frame being added. - return new Image(this.Configuration, source.Metadata.DeepClone(), destinationFrames); + return new(this.Configuration, source.Metadata.DeepClone(), destinationFrames); } private void CheckFrameCount(Image a, Image b) diff --git a/src/ImageSharp/Processing/Processors/Convolution/BokehBlurProcessor{TPixel}.cs b/src/ImageSharp/Processing/Processors/Convolution/BokehBlurProcessor{TPixel}.cs index 5931b7c402..725e99bae6 100644 --- a/src/ImageSharp/Processing/Processors/Convolution/BokehBlurProcessor{TPixel}.cs +++ b/src/ImageSharp/Processing/Processors/Convolution/BokehBlurProcessor{TPixel}.cs @@ -75,12 +75,12 @@ public BokehBlurProcessor(Configuration configuration, BokehBlurProcessor defini /// protected override void OnFrameApply(ImageFrame source) { - var sourceRectangle = Rectangle.Intersect(this.SourceRectangle, source.Bounds()); + Rectangle sourceRectangle = Rectangle.Intersect(this.SourceRectangle, source.Bounds()); // Preliminary gamma highlight pass if (this.gamma == 3F) { - var gammaOperation = new ApplyGamma3ExposureRowOperation(sourceRectangle, source.PixelBuffer, this.Configuration); + ApplyGamma3ExposureRowOperation gammaOperation = new(sourceRectangle, source.PixelBuffer, this.Configuration); ParallelRowIterator.IterateRows( this.Configuration, sourceRectangle, @@ -88,7 +88,7 @@ protected override void OnFrameApply(ImageFrame source) } else { - var gammaOperation = new ApplyGammaExposureRowOperation(sourceRectangle, source.PixelBuffer, this.Configuration, this.gamma); + ApplyGammaExposureRowOperation gammaOperation = new(sourceRectangle, source.PixelBuffer, this.Configuration, this.gamma); ParallelRowIterator.IterateRows( this.Configuration, sourceRectangle, @@ -104,7 +104,7 @@ protected override void OnFrameApply(ImageFrame source) // Apply the inverse gamma exposure pass, and write the final pixel data if (this.gamma == 3F) { - var operation = new ApplyInverseGamma3ExposureRowOperation(sourceRectangle, source.PixelBuffer, processingBuffer, this.Configuration); + ApplyInverseGamma3ExposureRowOperation operation = new(sourceRectangle, source.PixelBuffer, processingBuffer, this.Configuration); ParallelRowIterator.IterateRows( this.Configuration, sourceRectangle, @@ -112,7 +112,7 @@ protected override void OnFrameApply(ImageFrame source) } else { - var operation = new ApplyInverseGammaExposureRowOperation(sourceRectangle, source.PixelBuffer, processingBuffer, this.Configuration, 1 / this.gamma); + ApplyInverseGammaExposureRowOperation operation = new(sourceRectangle, source.PixelBuffer, processingBuffer, this.Configuration, 1 / this.gamma); ParallelRowIterator.IterateRows( this.Configuration, sourceRectangle, @@ -146,7 +146,7 @@ private void OnFrameApplyCore( // doing two 1D convolutions with the same kernel, we can use a single kernel sampling map as if // we were using a 2D kernel with each dimension being the same as the length of our kernel, and // use the two sampling offset spans resulting from this same map. This saves some extra work. - using var mapXY = new KernelSamplingMap(configuration.MemoryAllocator); + using KernelSamplingMap mapXY = new(configuration.MemoryAllocator); mapXY.BuildSamplingOffsetMap(this.kernelSize, this.kernelSize, sourceRectangle); @@ -161,7 +161,7 @@ private void OnFrameApplyCore( Vector4 parameters = Unsafe.Add(ref paramsRef, (uint)i); // Horizontal convolution - var horizontalOperation = new FirstPassConvolutionRowOperation( + FirstPassConvolutionRowOperation horizontalOperation = new( sourceRectangle, firstPassBuffer, source.PixelBuffer, @@ -175,7 +175,7 @@ private void OnFrameApplyCore( in horizontalOperation); // Vertical 1D convolutions to accumulate the partial results on the target buffer - var verticalOperation = new BokehBlurProcessor.SecondPassConvolutionRowOperation( + BokehBlurProcessor.SecondPassConvolutionRowOperation verticalOperation = new( sourceRectangle, processingBuffer, firstPassBuffer, @@ -391,7 +391,7 @@ public ApplyInverseGammaExposureRowOperation( public void Invoke(int y) { Vector4 low = Vector4.Zero; - var high = new Vector4(float.PositiveInfinity, float.PositiveInfinity, float.PositiveInfinity, float.PositiveInfinity); + Vector4 high = new(float.PositiveInfinity, float.PositiveInfinity, float.PositiveInfinity, float.PositiveInfinity); Span targetPixelSpan = this.targetPixels.DangerousGetRowSpan(y)[this.bounds.X..]; Span sourceRowSpan = this.sourceValues.DangerousGetRowSpan(y)[this.bounds.X..]; diff --git a/src/ImageSharp/Processing/Processors/Convolution/BoxBlurProcessor{TPixel}.cs b/src/ImageSharp/Processing/Processors/Convolution/BoxBlurProcessor{TPixel}.cs index ff3b30e9c1..727e8e96aa 100644 --- a/src/ImageSharp/Processing/Processors/Convolution/BoxBlurProcessor{TPixel}.cs +++ b/src/ImageSharp/Processing/Processors/Convolution/BoxBlurProcessor{TPixel}.cs @@ -68,7 +68,7 @@ public BoxBlurProcessor( /// protected override void OnFrameApply(ImageFrame source) { - using var processor = new Convolution2PassProcessor(this.Configuration, this.Kernel, false, this.Source, this.SourceRectangle, this.BorderWrapModeX, this.BorderWrapModeY); + using Convolution2PassProcessor processor = new(this.Configuration, this.Kernel, false, this.Source, this.SourceRectangle, this.BorderWrapModeX, this.BorderWrapModeY); processor.Apply(source); } @@ -80,7 +80,7 @@ protected override void OnFrameApply(ImageFrame source) /// The . private static float[] CreateBoxKernel(int kernelSize) { - var kernel = new float[kernelSize]; + float[] kernel = new float[kernelSize]; kernel.AsSpan().Fill(1F / kernelSize); diff --git a/src/ImageSharp/Processing/Processors/Convolution/Convolution2DProcessor{TPixel}.cs b/src/ImageSharp/Processing/Processors/Convolution/Convolution2DProcessor{TPixel}.cs index 8a7c424815..8f5ddd1690 100644 --- a/src/ImageSharp/Processing/Processors/Convolution/Convolution2DProcessor{TPixel}.cs +++ b/src/ImageSharp/Processing/Processors/Convolution/Convolution2DProcessor{TPixel}.cs @@ -62,14 +62,14 @@ protected override void OnFrameApply(ImageFrame source) source.CopyTo(targetPixels); - var interest = Rectangle.Intersect(this.SourceRectangle, source.Bounds()); + Rectangle interest = Rectangle.Intersect(this.SourceRectangle, source.Bounds()); - using (var map = new KernelSamplingMap(allocator)) + using (KernelSamplingMap map = new(allocator)) { // Since the kernel sizes are identical we can use a single map. map.BuildSamplingOffsetMap(this.KernelY, interest); - var operation = new Convolution2DRowOperation( + Convolution2DRowOperation operation = new( interest, targetPixels, source.PixelBuffer, diff --git a/src/ImageSharp/Processing/Processors/Convolution/Convolution2DRowOperation{TPixel}.cs b/src/ImageSharp/Processing/Processors/Convolution/Convolution2DRowOperation{TPixel}.cs index 2a4a1abf02..bccf191748 100644 --- a/src/ImageSharp/Processing/Processors/Convolution/Convolution2DRowOperation{TPixel}.cs +++ b/src/ImageSharp/Processing/Processors/Convolution/Convolution2DRowOperation{TPixel}.cs @@ -75,7 +75,7 @@ private void Convolve3(int y, Span span) Span targetYBuffer = span.Slice(boundsWidth, boundsWidth); Span targetXBuffer = span.Slice(boundsWidth * 2, boundsWidth); - var state = new Convolution2DState(in this.kernelMatrixY, in this.kernelMatrixX, this.map); + Convolution2DState state = new(in this.kernelMatrixY, in this.kernelMatrixX, this.map); ref int sampleRowBase = ref state.GetSampleRow((uint)(y - this.bounds.Y)); // Clear the target buffers for each row run. @@ -141,7 +141,7 @@ private void Convolve4(int y, Span span) Span targetYBuffer = span.Slice(boundsWidth, boundsWidth); Span targetXBuffer = span.Slice(boundsWidth * 2, boundsWidth); - var state = new Convolution2DState(in this.kernelMatrixY, in this.kernelMatrixX, this.map); + Convolution2DState state = new(in this.kernelMatrixY, in this.kernelMatrixX, this.map); ref int sampleRowBase = ref state.GetSampleRow((uint)(y - this.bounds.Y)); // Clear the target buffers for each row run. diff --git a/src/ImageSharp/Processing/Processors/Convolution/Convolution2DState.cs b/src/ImageSharp/Processing/Processors/Convolution/Convolution2DState.cs index 6f5388e22b..b3dae6baac 100644 --- a/src/ImageSharp/Processing/Processors/Convolution/Convolution2DState.cs +++ b/src/ImageSharp/Processing/Processors/Convolution/Convolution2DState.cs @@ -22,8 +22,8 @@ public Convolution2DState( KernelSamplingMap map) { // We check the kernels are the same size upstream. - this.KernelY = new ReadOnlyKernel(kernelY); - this.KernelX = new ReadOnlyKernel(kernelX); + this.KernelY = new(kernelY); + this.KernelX = new(kernelX); this.kernelHeight = (uint)kernelY.Rows; this.kernelWidth = (uint)kernelY.Columns; this.rowOffsetMap = map.GetRowOffsetSpan(); diff --git a/src/ImageSharp/Processing/Processors/Convolution/Convolution2PassProcessor{TPixel}.cs b/src/ImageSharp/Processing/Processors/Convolution/Convolution2PassProcessor{TPixel}.cs index 10780a21e2..d7617f7699 100644 --- a/src/ImageSharp/Processing/Processors/Convolution/Convolution2PassProcessor{TPixel}.cs +++ b/src/ImageSharp/Processing/Processors/Convolution/Convolution2PassProcessor{TPixel}.cs @@ -68,16 +68,16 @@ protected override void OnFrameApply(ImageFrame source) { using Buffer2D firstPassPixels = this.Configuration.MemoryAllocator.Allocate2D(source.Size); - var interest = Rectangle.Intersect(this.SourceRectangle, source.Bounds()); + Rectangle interest = Rectangle.Intersect(this.SourceRectangle, source.Bounds()); // We can create a single sampling map with the size as if we were using the non separated 2D kernel // the two 1D kernels represent, and reuse it across both convolution steps, like in the bokeh blur. - using var mapXY = new KernelSamplingMap(this.Configuration.MemoryAllocator); + using KernelSamplingMap mapXY = new(this.Configuration.MemoryAllocator); mapXY.BuildSamplingOffsetMap(this.Kernel.Length, this.Kernel.Length, interest, this.BorderWrapModeX, this.BorderWrapModeY); // Horizontal convolution - var horizontalOperation = new HorizontalConvolutionRowOperation( + HorizontalConvolutionRowOperation horizontalOperation = new( interest, firstPassPixels, source.PixelBuffer, @@ -92,7 +92,7 @@ protected override void OnFrameApply(ImageFrame source) in horizontalOperation); // Vertical convolution - var verticalOperation = new VerticalConvolutionRowOperation( + VerticalConvolutionRowOperation verticalOperation = new( interest, source.PixelBuffer, firstPassPixels, diff --git a/src/ImageSharp/Processing/Processors/Convolution/ConvolutionProcessor{TPixel}.cs b/src/ImageSharp/Processing/Processors/Convolution/ConvolutionProcessor{TPixel}.cs index ae79f2c31d..84d0f6322a 100644 --- a/src/ImageSharp/Processing/Processors/Convolution/ConvolutionProcessor{TPixel}.cs +++ b/src/ImageSharp/Processing/Processors/Convolution/ConvolutionProcessor{TPixel}.cs @@ -55,13 +55,13 @@ protected override void OnFrameApply(ImageFrame source) source.CopyTo(targetPixels); - var interest = Rectangle.Intersect(this.SourceRectangle, source.Bounds()); + Rectangle interest = Rectangle.Intersect(this.SourceRectangle, source.Bounds()); - using (var map = new KernelSamplingMap(allocator)) + using (KernelSamplingMap map = new(allocator)) { map.BuildSamplingOffsetMap(this.KernelXY, interest); - var operation = new RowOperation(interest, targetPixels, source.PixelBuffer, map, this.KernelXY, this.Configuration, this.PreserveAlpha); + RowOperation operation = new(interest, targetPixels, source.PixelBuffer, map, this.KernelXY, this.Configuration, this.PreserveAlpha); ParallelRowIterator.IterateRows( this.Configuration, interest, @@ -121,7 +121,7 @@ public void Invoke(int y, Span span) ref Vector4 targetRowRef = ref MemoryMarshal.GetReference(span); Span targetRowSpan = this.targetPixels.DangerousGetRowSpan(y).Slice(boundsX, boundsWidth); - var state = new ConvolutionState(in this.kernel, this.map); + ConvolutionState state = new(in this.kernel, this.map); int row = y - this.bounds.Y; ref int sampleRowBase = ref state.GetSampleRow((uint)row); diff --git a/src/ImageSharp/Processing/Processors/Convolution/ConvolutionState.cs b/src/ImageSharp/Processing/Processors/Convolution/ConvolutionState.cs index 6663c45021..20e95d0582 100644 --- a/src/ImageSharp/Processing/Processors/Convolution/ConvolutionState.cs +++ b/src/ImageSharp/Processing/Processors/Convolution/ConvolutionState.cs @@ -20,7 +20,7 @@ public ConvolutionState( in DenseMatrix kernel, KernelSamplingMap map) { - this.Kernel = new ReadOnlyKernel(kernel); + this.Kernel = new(kernel); this.kernelHeight = (uint)kernel.Rows; this.kernelWidth = (uint)kernel.Columns; this.rowOffsetMap = map.GetRowOffsetSpan(); diff --git a/src/ImageSharp/Processing/Processors/Convolution/EdgeDetector2DProcessor{TPixel}.cs b/src/ImageSharp/Processing/Processors/Convolution/EdgeDetector2DProcessor{TPixel}.cs index 5af4360442..502c344028 100644 --- a/src/ImageSharp/Processing/Processors/Convolution/EdgeDetector2DProcessor{TPixel}.cs +++ b/src/ImageSharp/Processing/Processors/Convolution/EdgeDetector2DProcessor{TPixel}.cs @@ -55,7 +55,7 @@ protected override void BeforeImageApply() /// protected override void OnFrameApply(ImageFrame source) { - using var processor = new Convolution2DProcessor( + using Convolution2DProcessor processor = new( this.Configuration, in this.kernelX, in this.kernelY, diff --git a/src/ImageSharp/Processing/Processors/Convolution/EdgeDetectorCompassProcessor{TPixel}.cs b/src/ImageSharp/Processing/Processors/Convolution/EdgeDetectorCompassProcessor{TPixel}.cs index ae891f3507..a1fa4db973 100644 --- a/src/ImageSharp/Processing/Processors/Convolution/EdgeDetectorCompassProcessor{TPixel}.cs +++ b/src/ImageSharp/Processing/Processors/Convolution/EdgeDetectorCompassProcessor{TPixel}.cs @@ -58,12 +58,12 @@ protected override void BeforeImageApply() /// protected override void OnFrameApply(ImageFrame source) { - var interest = Rectangle.Intersect(this.SourceRectangle, source.Bounds()); + Rectangle interest = Rectangle.Intersect(this.SourceRectangle, source.Bounds()); // We need a clean copy for each pass to start from using ImageFrame cleanCopy = source.Clone(); - using (var processor = new ConvolutionProcessor(this.Configuration, in this.kernels[0], true, this.Source, interest)) + using (ConvolutionProcessor processor = new(this.Configuration, in this.kernels[0], true, this.Source, interest)) { processor.Apply(source); } @@ -78,12 +78,12 @@ protected override void OnFrameApply(ImageFrame source) { using ImageFrame pass = cleanCopy.Clone(); - using (var processor = new ConvolutionProcessor(this.Configuration, in this.kernels[i], true, this.Source, interest)) + using (ConvolutionProcessor processor = new(this.Configuration, in this.kernels[i], true, this.Source, interest)) { processor.Apply(pass); } - var operation = new RowOperation(source.PixelBuffer, pass.PixelBuffer, interest); + RowOperation operation = new(source.PixelBuffer, pass.PixelBuffer, interest); ParallelRowIterator.IterateRows( this.Configuration, interest, diff --git a/src/ImageSharp/Processing/Processors/Convolution/EdgeDetectorProcessor{TPixel}.cs b/src/ImageSharp/Processing/Processors/Convolution/EdgeDetectorProcessor{TPixel}.cs index c353f46b5f..3139d24bb4 100644 --- a/src/ImageSharp/Processing/Processors/Convolution/EdgeDetectorProcessor{TPixel}.cs +++ b/src/ImageSharp/Processing/Processors/Convolution/EdgeDetectorProcessor{TPixel}.cs @@ -53,7 +53,7 @@ protected override void BeforeImageApply() /// protected override void OnFrameApply(ImageFrame source) { - using var processor = new ConvolutionProcessor(this.Configuration, in this.kernelXY, true, this.Source, this.SourceRectangle); + using ConvolutionProcessor processor = new(this.Configuration, in this.kernelXY, true, this.Source, this.SourceRectangle); processor.Apply(source); } } diff --git a/src/ImageSharp/Processing/Processors/Convolution/GaussianBlurProcessor{TPixel}.cs b/src/ImageSharp/Processing/Processors/Convolution/GaussianBlurProcessor{TPixel}.cs index 6518375b9e..3a2d75630f 100644 --- a/src/ImageSharp/Processing/Processors/Convolution/GaussianBlurProcessor{TPixel}.cs +++ b/src/ImageSharp/Processing/Processors/Convolution/GaussianBlurProcessor{TPixel}.cs @@ -72,7 +72,7 @@ public GaussianBlurProcessor( /// protected override void OnFrameApply(ImageFrame source) { - using var processor = new Convolution2PassProcessor(this.Configuration, this.Kernel, false, this.Source, this.SourceRectangle, this.BorderWrapModeX, this.BorderWrapModeY); + using Convolution2PassProcessor processor = new(this.Configuration, this.Kernel, false, this.Source, this.SourceRectangle, this.BorderWrapModeX, this.BorderWrapModeY); processor.Apply(source); } diff --git a/src/ImageSharp/Processing/Processors/Convolution/GaussianSharpenProcessor{TPixel}.cs b/src/ImageSharp/Processing/Processors/Convolution/GaussianSharpenProcessor{TPixel}.cs index a286201dff..9c53e85302 100644 --- a/src/ImageSharp/Processing/Processors/Convolution/GaussianSharpenProcessor{TPixel}.cs +++ b/src/ImageSharp/Processing/Processors/Convolution/GaussianSharpenProcessor{TPixel}.cs @@ -70,7 +70,7 @@ public GaussianSharpenProcessor( /// protected override void OnFrameApply(ImageFrame source) { - using var processor = new Convolution2PassProcessor(this.Configuration, this.Kernel, false, this.Source, this.SourceRectangle, this.BorderWrapModeX, this.BorderWrapModeY); + using Convolution2PassProcessor processor = new(this.Configuration, this.Kernel, false, this.Source, this.SourceRectangle, this.BorderWrapModeX, this.BorderWrapModeY); processor.Apply(source); } diff --git a/src/ImageSharp/Processing/Processors/Convolution/Kernels/EdgeDetectorCompassKernel.cs b/src/ImageSharp/Processing/Processors/Convolution/Kernels/EdgeDetectorCompassKernel.cs index 0c456eb88e..1dbc666f6f 100644 --- a/src/ImageSharp/Processing/Processors/Convolution/Kernels/EdgeDetectorCompassKernel.cs +++ b/src/ImageSharp/Processing/Processors/Convolution/Kernels/EdgeDetectorCompassKernel.cs @@ -152,9 +152,8 @@ public override int GetHashCode() this.NorthEast); internal DenseMatrix[] Flatten() => - new[] - { - this.North, this.NorthWest, this.West, this.SouthWest, + [ + this.North, this.NorthWest, this.West, this.SouthWest, this.South, this.SouthEast, this.East, this.NorthEast - }; + ]; } diff --git a/src/ImageSharp/Processing/Processors/Convolution/Kernels/Implementation/LaplacianKernelFactory.cs b/src/ImageSharp/Processing/Processors/Convolution/Kernels/Implementation/LaplacianKernelFactory.cs index 7efcbf3a6c..b51ed1819e 100644 --- a/src/ImageSharp/Processing/Processors/Convolution/Kernels/Implementation/LaplacianKernelFactory.cs +++ b/src/ImageSharp/Processing/Processors/Convolution/Kernels/Implementation/LaplacianKernelFactory.cs @@ -19,7 +19,7 @@ public static DenseMatrix CreateKernel(uint length) Guard.MustBeGreaterThanOrEqualTo(length, 3u, nameof(length)); Guard.IsFalse(length % 2 == 0, nameof(length), "The kernel length must be an odd number."); - var kernel = new DenseMatrix((int)length); + DenseMatrix kernel = new((int)length); kernel.Fill(-1); int mid = (int)(length / 2); diff --git a/src/ImageSharp/Processing/Processors/Convolution/MedianConvolutionState.cs b/src/ImageSharp/Processing/Processors/Convolution/MedianConvolutionState.cs index 137334c29e..5b2c903baf 100644 --- a/src/ImageSharp/Processing/Processors/Convolution/MedianConvolutionState.cs +++ b/src/ImageSharp/Processing/Processors/Convolution/MedianConvolutionState.cs @@ -21,7 +21,7 @@ public MedianConvolutionState( in DenseMatrix kernel, KernelSamplingMap map) { - this.Kernel = new Kernel(kernel); + this.Kernel = new(kernel); this.kernelHeight = kernel.Rows; this.kernelWidth = kernel.Columns; this.rowOffsetMap = map.GetRowOffsetSpan(); diff --git a/src/ImageSharp/Processing/Processors/Convolution/MedianRowOperation{TPixel}.cs b/src/ImageSharp/Processing/Processors/Convolution/MedianRowOperation{TPixel}.cs index ca2cabab55..64fd40f153 100644 --- a/src/ImageSharp/Processing/Processors/Convolution/MedianRowOperation{TPixel}.cs +++ b/src/ImageSharp/Processing/Processors/Convolution/MedianRowOperation{TPixel}.cs @@ -153,7 +153,7 @@ private static Vector4 FindMedian3(ReadOnlySpan kernelSpan, Span // Taking the W value from the source pixels, where the middle index in the kernelSpan is by definition the resulting pixel. // This will preserve the alpha value. - return new Vector4(xChannel[halfLength], yChannel[halfLength], zChannel[halfLength], kernelSpan[halfLength].W); + return new(xChannel[halfLength], yChannel[halfLength], zChannel[halfLength], kernelSpan[halfLength].W); } [MethodImpl(MethodImplOptions.AggressiveInlining)] @@ -176,6 +176,6 @@ private static Vector4 FindMedian4(ReadOnlySpan kernelSpan, Span zChannel.Sort(); wChannel.Sort(); - return new Vector4(xChannel[halfLength], yChannel[halfLength], zChannel[halfLength], wChannel[halfLength]); + return new(xChannel[halfLength], yChannel[halfLength], zChannel[halfLength], wChannel[halfLength]); } } diff --git a/src/ImageSharp/Processing/Processors/Convolution/Parameters/BokehBlurKernelDataProvider.cs b/src/ImageSharp/Processing/Processors/Convolution/Parameters/BokehBlurKernelDataProvider.cs index a680393c8c..5906df4b7f 100644 --- a/src/ImageSharp/Processing/Processors/Convolution/Parameters/BokehBlurKernelDataProvider.cs +++ b/src/ImageSharp/Processing/Processors/Convolution/Parameters/BokehBlurKernelDataProvider.cs @@ -16,66 +16,61 @@ internal static class BokehBlurKernelDataProvider /// /// The mapping of initialized complex kernels and parameters, to speed up the initialization of new instances /// - private static readonly ConcurrentDictionary Cache = new ConcurrentDictionary(); + private static readonly ConcurrentDictionary Cache = new(); /// /// Gets the kernel scales to adjust the component values in each kernel /// - private static IReadOnlyList KernelScales { get; } = new[] { 1.4f, 1.2f, 1.2f, 1.2f, 1.2f, 1.2f }; + private static IReadOnlyList KernelScales { get; } = [1.4f, 1.2f, 1.2f, 1.2f, 1.2f, 1.2f]; /// /// Gets the available bokeh blur kernel parameters /// - private static IReadOnlyList KernelComponents { get; } = new[] - { + private static IReadOnlyList KernelComponents { get; } = + [ // 1 component - new[] { new Vector4(0.862325f, 1.624835f, 0.767583f, 1.862321f) }, + [new Vector4(0.862325f, 1.624835f, 0.767583f, 1.862321f)], // 2 components - new[] - { + [ new Vector4(0.886528f, 5.268909f, 0.411259f, -0.548794f), new Vector4(1.960518f, 1.558213f, 0.513282f, 4.56111f) - }, + ], // 3 components - new[] - { + [ new Vector4(2.17649f, 5.043495f, 1.621035f, -2.105439f), new Vector4(1.019306f, 9.027613f, -0.28086f, -0.162882f), new Vector4(2.81511f, 1.597273f, -0.366471f, 10.300301f) - }, + ], // 4 components - new[] - { + [ new Vector4(4.338459f, 1.553635f, -5.767909f, 46.164397f), new Vector4(3.839993f, 4.693183f, 9.795391f, -15.227561f), new Vector4(2.791880f, 8.178137f, -3.048324f, 0.302959f), new Vector4(1.342190f, 12.328289f, 0.010001f, 0.244650f) - }, + ], // 5 components - new[] - { + [ new Vector4(4.892608f, 1.685979f, -22.356787f, 85.91246f), new Vector4(4.71187f, 4.998496f, 35.918936f, -28.875618f), new Vector4(4.052795f, 8.244168f, -13.212253f, -1.578428f), new Vector4(2.929212f, 11.900859f, 0.507991f, 1.816328f), new Vector4(1.512961f, 16.116382f, 0.138051f, -0.01f) - }, + ], // 6 components - new[] - { + [ new Vector4(5.143778f, 2.079813f, -82.326596f, 111.231024f), new Vector4(5.612426f, 6.153387f, 113.878661f, 58.004879f), new Vector4(5.982921f, 9.802895f, 39.479083f, -162.028887f), new Vector4(6.505167f, 11.059237f, -71.286026f, 95.027069f), new Vector4(3.869579f, 14.81052f, 1.405746f, -3.704914f), new Vector4(2.201904f, 19.032909f, -0.152784f, -0.107988f) - } - }; + ] + ]; /// /// Gets the bokeh blur kernel data for the specified parameters. @@ -90,7 +85,7 @@ public static BokehBlurKernelData GetBokehBlurKernelData( int componentsCount) { // Reuse the initialized values from the cache, if possible - var parameters = new BokehBlurParameters(radius, componentsCount); + BokehBlurParameters parameters = new(radius, componentsCount); if (!Cache.TryGetValue(parameters, out BokehBlurKernelData info)) { // Initialize the complex kernels and parameters with the current arguments @@ -99,7 +94,7 @@ public static BokehBlurKernelData GetBokehBlurKernelData( NormalizeKernels(kernels, kernelParameters); // Store them in the cache for future use - info = new BokehBlurKernelData(kernelParameters, kernels); + info = new(kernelParameters, kernels); Cache.TryAdd(parameters, info); } @@ -130,7 +125,7 @@ private static Complex64[][] CreateComplexKernels( int kernelSize, float kernelsScale) { - var kernels = new Complex64[kernelParameters.Length][]; + Complex64[][] kernels = new Complex64[kernelParameters.Length][]; ref Vector4 baseRef = ref MemoryMarshal.GetReference(kernelParameters.AsSpan()); for (int i = 0; i < kernelParameters.Length; i++) { @@ -156,7 +151,7 @@ private static Complex64[] CreateComplex1DKernel( float a, float b) { - var kernel = new Complex64[kernelSize]; + Complex64[] kernel = new Complex64[kernelSize]; ref Complex64 baseRef = ref MemoryMarshal.GetReference(kernel.AsSpan()); int r = radius, n = -r; @@ -167,7 +162,7 @@ private static Complex64[] CreateComplex1DKernel( value *= value; // Fill in the complex kernel values - Unsafe.Add(ref baseRef, (uint)i) = new Complex64( + Unsafe.Add(ref baseRef, (uint)i) = new( MathF.Exp(-a * value) * MathF.Cos(b * value), MathF.Exp(-a * value) * MathF.Sin(b * value)); } diff --git a/src/ImageSharp/Processing/Processors/Dithering/ErroDither.KnownTypes.cs b/src/ImageSharp/Processing/Processors/Dithering/ErroDither.KnownTypes.cs index 57d8ef59a6..d58f9020c3 100644 --- a/src/ImageSharp/Processing/Processors/Dithering/ErroDither.KnownTypes.cs +++ b/src/ImageSharp/Processing/Processors/Dithering/ErroDither.KnownTypes.cs @@ -65,7 +65,7 @@ private static ErrorDither CreateAtkinson() { 0, 1 / divisor, 0, 0 } }; - return new ErrorDither(matrix, offset); + return new(matrix, offset); } private static ErrorDither CreateBurks() @@ -79,7 +79,7 @@ private static ErrorDither CreateBurks() { 2 / divisor, 4 / divisor, 8 / divisor, 4 / divisor, 2 / divisor } }; - return new ErrorDither(matrix, offset); + return new(matrix, offset); } private static ErrorDither CreateFloydSteinberg() @@ -93,7 +93,7 @@ private static ErrorDither CreateFloydSteinberg() { 3 / divisor, 5 / divisor, 1 / divisor } }; - return new ErrorDither(matrix, offset); + return new(matrix, offset); } private static ErrorDither CreateJarvisJudiceNinke() @@ -108,7 +108,7 @@ private static ErrorDither CreateJarvisJudiceNinke() { 1 / divisor, 3 / divisor, 5 / divisor, 3 / divisor, 1 / divisor } }; - return new ErrorDither(matrix, offset); + return new(matrix, offset); } private static ErrorDither CreateSierra2() @@ -122,7 +122,7 @@ private static ErrorDither CreateSierra2() { 1 / divisor, 2 / divisor, 3 / divisor, 2 / divisor, 1 / divisor } }; - return new ErrorDither(matrix, offset); + return new(matrix, offset); } private static ErrorDither CreateSierra3() @@ -137,7 +137,7 @@ private static ErrorDither CreateSierra3() { 0, 2 / divisor, 3 / divisor, 2 / divisor, 0 } }; - return new ErrorDither(matrix, offset); + return new(matrix, offset); } private static ErrorDither CreateSierraLite() @@ -151,7 +151,7 @@ private static ErrorDither CreateSierraLite() { 1 / divisor, 1 / divisor, 0 } }; - return new ErrorDither(matrix, offset); + return new(matrix, offset); } private static ErrorDither CreateStevensonArce() @@ -167,7 +167,7 @@ private static ErrorDither CreateStevensonArce() { 5 / divisor, 0, 12 / divisor, 0, 12 / divisor, 0, 5 / divisor } }; - return new ErrorDither(matrix, offset); + return new(matrix, offset); } private static ErrorDither CreateStucki() @@ -182,6 +182,6 @@ private static ErrorDither CreateStucki() { 1 / divisor, 2 / divisor, 4 / divisor, 2 / divisor, 1 / divisor } }; - return new ErrorDither(matrix, offset); + return new(matrix, offset); } } diff --git a/src/ImageSharp/Processing/Processors/Dithering/OrderedDither.cs b/src/ImageSharp/Processing/Processors/Dithering/OrderedDither.cs index d1f46c7441..b0622cac58 100644 --- a/src/ImageSharp/Processing/Processors/Dithering/OrderedDither.cs +++ b/src/ImageSharp/Processing/Processors/Dithering/OrderedDither.cs @@ -32,7 +32,7 @@ public OrderedDither(uint length) // We don't want to adjust the original matrix generation code as that // creates known, easy to test values. // https://en.wikipedia.org/wiki/Ordered_dithering#Algorithm - var thresholdMatrix = new DenseMatrix((int)length); + DenseMatrix thresholdMatrix = new((int)length); float m2 = length * length; for (int y = 0; y < length; y++) { diff --git a/src/ImageSharp/Processing/Processors/Dithering/OrderedDitherFactory.cs b/src/ImageSharp/Processing/Processors/Dithering/OrderedDitherFactory.cs index 7f8b347243..ec82f01d7a 100644 --- a/src/ImageSharp/Processing/Processors/Dithering/OrderedDitherFactory.cs +++ b/src/ImageSharp/Processing/Processors/Dithering/OrderedDitherFactory.cs @@ -29,7 +29,7 @@ public static DenseMatrix CreateDitherMatrix(uint length) while (length > bayerLength); // Create our Bayer matrix that matches the given exponent and dimensions - var matrix = new DenseMatrix((int)length); + DenseMatrix matrix = new((int)length); uint i = 0; for (int y = 0; y < length; y++) { diff --git a/src/ImageSharp/Processing/Processors/Dithering/PaletteDitherProcessor{TPixel}.cs b/src/ImageSharp/Processing/Processors/Dithering/PaletteDitherProcessor{TPixel}.cs index 982cc7d46c..d2e6ad6648 100644 --- a/src/ImageSharp/Processing/Processors/Dithering/PaletteDitherProcessor{TPixel}.cs +++ b/src/ImageSharp/Processing/Processors/Dithering/PaletteDitherProcessor{TPixel}.cs @@ -37,7 +37,7 @@ public PaletteDitherProcessor(Configuration configuration, PaletteDitherProcesso this.paletteOwner = this.Configuration.MemoryAllocator.Allocate(sourcePalette.Length); Color.ToPixel(sourcePalette, this.paletteOwner.Memory.Span); - this.ditherProcessor = new DitherProcessor( + this.ditherProcessor = new( this.Configuration, this.paletteOwner.Memory, definition.DitherScale); @@ -89,7 +89,7 @@ public DitherProcessor( float ditherScale) { this.Configuration = configuration; - this.pixelMap = new EuclideanPixelMap(configuration, palette); + this.pixelMap = new(configuration, palette); this.Palette = palette; this.DitherScale = ditherScale; } diff --git a/src/ImageSharp/Processing/Processors/Effects/OilPaintingProcessor{TPixel}.cs b/src/ImageSharp/Processing/Processors/Effects/OilPaintingProcessor{TPixel}.cs index f811bae0f7..5e491c1ee6 100644 --- a/src/ImageSharp/Processing/Processors/Effects/OilPaintingProcessor{TPixel}.cs +++ b/src/ImageSharp/Processing/Processors/Effects/OilPaintingProcessor{TPixel}.cs @@ -174,7 +174,7 @@ public void Invoke(in RowInterval rows) float green = greenBinSpan[maxIndex] / maxIntensity; float alpha = sourceRowVector4Span[x].W; - targetRowVector4Span[x] = new Vector4(red, green, blue, alpha); + targetRowVector4Span[x] = new(red, green, blue, alpha); } } diff --git a/src/ImageSharp/Processing/Processors/Effects/PixelRowDelegateProcessor.cs b/src/ImageSharp/Processing/Processors/Effects/PixelRowDelegateProcessor.cs index 847a211a5a..bef7a8771a 100644 --- a/src/ImageSharp/Processing/Processors/Effects/PixelRowDelegateProcessor.cs +++ b/src/ImageSharp/Processing/Processors/Effects/PixelRowDelegateProcessor.cs @@ -38,7 +38,7 @@ public IImageProcessor CreatePixelSpecificProcessor(Configuratio where TPixel : unmanaged, IPixel { return new PixelRowDelegateProcessor( - new PixelRowDelegate(this.PixelRowOperation), + new(this.PixelRowOperation), configuration, this.Modifiers, source, diff --git a/src/ImageSharp/Processing/Processors/Effects/PixelRowDelegateProcessor{TPixel,TDelegate}.cs b/src/ImageSharp/Processing/Processors/Effects/PixelRowDelegateProcessor{TPixel,TDelegate}.cs index 36bb327cf2..8937e6d955 100644 --- a/src/ImageSharp/Processing/Processors/Effects/PixelRowDelegateProcessor{TPixel,TDelegate}.cs +++ b/src/ImageSharp/Processing/Processors/Effects/PixelRowDelegateProcessor{TPixel,TDelegate}.cs @@ -48,8 +48,8 @@ public PixelRowDelegateProcessor( /// protected override void OnFrameApply(ImageFrame source) { - var interest = Rectangle.Intersect(this.SourceRectangle, source.Bounds()); - var operation = new RowOperation(interest.X, source.PixelBuffer, this.Configuration, this.modifiers, this.rowDelegate); + Rectangle interest = Rectangle.Intersect(this.SourceRectangle, source.Bounds()); + RowOperation operation = new(interest.X, source.PixelBuffer, this.Configuration, this.modifiers, this.rowDelegate); ParallelRowIterator.IterateRows( this.Configuration, @@ -96,7 +96,7 @@ public void Invoke(int y, Span span) PixelOperations.Instance.ToVector4(this.configuration, rowSpan, span, this.modifiers); // Run the user defined pixel shader to the current row of pixels - Unsafe.AsRef(in this.rowProcessor).Invoke(span, new Point(this.startX, y)); + Unsafe.AsRef(in this.rowProcessor).Invoke(span, new(this.startX, y)); PixelOperations.Instance.FromVector4Destructive(this.configuration, span, rowSpan, this.modifiers); } diff --git a/src/ImageSharp/Processing/Processors/Effects/PixelateProcessor{TPixel}.cs b/src/ImageSharp/Processing/Processors/Effects/PixelateProcessor{TPixel}.cs index 68000ba3e8..33e3a3613b 100644 --- a/src/ImageSharp/Processing/Processors/Effects/PixelateProcessor{TPixel}.cs +++ b/src/ImageSharp/Processing/Processors/Effects/PixelateProcessor{TPixel}.cs @@ -32,7 +32,7 @@ public PixelateProcessor(Configuration configuration, PixelateProcessor definiti /// protected override void OnFrameApply(ImageFrame source) { - var interest = Rectangle.Intersect(this.SourceRectangle, source.Bounds()); + Rectangle interest = Rectangle.Intersect(this.SourceRectangle, source.Bounds()); int size = this.Size; Guard.MustBeBetweenOrEqualTo(size, 0, interest.Width, nameof(size)); diff --git a/src/ImageSharp/Processing/Processors/Effects/PositionAwarePixelRowDelegateProcessor.cs b/src/ImageSharp/Processing/Processors/Effects/PositionAwarePixelRowDelegateProcessor.cs index 6786eb5f50..a54a7bfd25 100644 --- a/src/ImageSharp/Processing/Processors/Effects/PositionAwarePixelRowDelegateProcessor.cs +++ b/src/ImageSharp/Processing/Processors/Effects/PositionAwarePixelRowDelegateProcessor.cs @@ -38,7 +38,7 @@ public IImageProcessor CreatePixelSpecificProcessor(Configuratio where TPixel : unmanaged, IPixel { return new PixelRowDelegateProcessor( - new PixelRowDelegate(this.PixelRowOperation), + new(this.PixelRowOperation), configuration, this.Modifiers, source, diff --git a/src/ImageSharp/Processing/Processors/Filters/FilterProcessor{TPixel}.cs b/src/ImageSharp/Processing/Processors/Filters/FilterProcessor{TPixel}.cs index 5109139647..3562c60b3a 100644 --- a/src/ImageSharp/Processing/Processors/Filters/FilterProcessor{TPixel}.cs +++ b/src/ImageSharp/Processing/Processors/Filters/FilterProcessor{TPixel}.cs @@ -34,8 +34,8 @@ public FilterProcessor(Configuration configuration, FilterProcessor definition, /// protected override void OnFrameApply(ImageFrame source) { - var interest = Rectangle.Intersect(this.SourceRectangle, source.Bounds()); - var operation = new RowOperation(interest.X, source.PixelBuffer, this.definition.Matrix, this.Configuration); + Rectangle interest = Rectangle.Intersect(this.SourceRectangle, source.Bounds()); + RowOperation operation = new(interest.X, source.PixelBuffer, this.definition.Matrix, this.Configuration); ParallelRowIterator.IterateRows( this.Configuration, diff --git a/src/ImageSharp/Processing/Processors/Filters/OpaqueProcessor{TPixel}.cs b/src/ImageSharp/Processing/Processors/Filters/OpaqueProcessor{TPixel}.cs index 93e600106a..962ca567d2 100644 --- a/src/ImageSharp/Processing/Processors/Filters/OpaqueProcessor{TPixel}.cs +++ b/src/ImageSharp/Processing/Processors/Filters/OpaqueProcessor{TPixel}.cs @@ -23,9 +23,9 @@ public OpaqueProcessor( protected override void OnFrameApply(ImageFrame source) { - var interest = Rectangle.Intersect(this.SourceRectangle, source.Bounds()); + Rectangle interest = Rectangle.Intersect(this.SourceRectangle, source.Bounds()); - var operation = new OpaqueRowOperation(this.Configuration, source.PixelBuffer, interest); + OpaqueRowOperation operation = new(this.Configuration, source.PixelBuffer, interest); ParallelRowIterator.IterateRows(this.Configuration, interest, in operation); } diff --git a/src/ImageSharp/Processing/Processors/Normalization/AdaptiveHistogramEqualizationProcessor{TPixel}.cs b/src/ImageSharp/Processing/Processors/Normalization/AdaptiveHistogramEqualizationProcessor{TPixel}.cs index 78085eaab5..e911249586 100644 --- a/src/ImageSharp/Processing/Processors/Normalization/AdaptiveHistogramEqualizationProcessor{TPixel}.cs +++ b/src/ImageSharp/Processing/Processors/Normalization/AdaptiveHistogramEqualizationProcessor{TPixel}.cs @@ -81,7 +81,7 @@ protected override void OnFrameApply(ImageFrame source) RowIntervalOperation operation = new(cdfData, tileYStartPositions, tileWidth, tileHeight, tileCount, halfTileWidth, luminanceLevels, source.PixelBuffer); ParallelRowIterator.IterateRowIntervals( this.Configuration, - new Rectangle(0, 0, sourceWidth, tileYStartPositions.Count), + new(0, 0, sourceWidth, tileYStartPositions.Count), in operation); // Fix left column @@ -191,7 +191,7 @@ private static void ProcessBorderColumn( { ref TPixel pixel = ref rowSpan[dx]; float luminanceEqualized = InterpolateBetweenTwoTiles(pixel, cdfData, cdfX, cdfY, cdfX, cdfY + 1, tileY, tileHeight, luminanceLevels); - pixel = TPixel.FromVector4(new Vector4(luminanceEqualized, luminanceEqualized, luminanceEqualized, pixel.ToVector4().W)); + pixel = TPixel.FromVector4(new(luminanceEqualized, luminanceEqualized, luminanceEqualized, pixel.ToVector4().W)); } tileY++; @@ -243,7 +243,7 @@ private static void ProcessBorderRow( { ref TPixel pixel = ref rowSpan[dx]; float luminanceEqualized = InterpolateBetweenTwoTiles(pixel, cdfData, cdfX, cdfY, cdfX + 1, cdfY, tileX, tileWidth, luminanceLevels); - pixel = TPixel.FromVector4(new Vector4(luminanceEqualized, luminanceEqualized, luminanceEqualized, pixel.ToVector4().W)); + pixel = TPixel.FromVector4(new(luminanceEqualized, luminanceEqualized, luminanceEqualized, pixel.ToVector4().W)); tileX++; } } @@ -432,7 +432,7 @@ public void Invoke(in RowInterval rows) this.tileHeight, this.luminanceLevels); - pixel = TPixel.FromVector4(new Vector4(luminanceEqualized, luminanceEqualized, luminanceEqualized, pixel.ToVector4().W)); + pixel = TPixel.FromVector4(new(luminanceEqualized, luminanceEqualized, luminanceEqualized, pixel.ToVector4().W)); tileX++; } @@ -515,7 +515,7 @@ public void CalculateLookupTables(ImageFrame source, HistogramEqualizati ParallelRowIterator.IterateRowIntervals( this.configuration, - new Rectangle(0, 0, this.sourceWidth, this.tileYStartPositions.Count), + new(0, 0, this.sourceWidth, this.tileYStartPositions.Count), in operation); } diff --git a/src/ImageSharp/Processing/Processors/Normalization/AutoLevelProcessor{TPixel}.cs b/src/ImageSharp/Processing/Processors/Normalization/AutoLevelProcessor{TPixel}.cs index 6f4493f951..86836a32b8 100644 --- a/src/ImageSharp/Processing/Processors/Normalization/AutoLevelProcessor{TPixel}.cs +++ b/src/ImageSharp/Processing/Processors/Normalization/AutoLevelProcessor{TPixel}.cs @@ -54,12 +54,12 @@ protected override void OnFrameApply(ImageFrame source) { MemoryAllocator memoryAllocator = this.Configuration.MemoryAllocator; int numberOfPixels = source.Width * source.Height; - var interest = Rectangle.Intersect(this.SourceRectangle, source.Bounds()); + Rectangle interest = Rectangle.Intersect(this.SourceRectangle, source.Bounds()); using IMemoryOwner histogramBuffer = memoryAllocator.Allocate(this.LuminanceLevels, AllocationOptions.Clean); // Build the histogram of the grayscale levels. - var grayscaleOperation = new GrayscaleLevelsRowOperation(this.Configuration, interest, histogramBuffer, source.PixelBuffer, this.LuminanceLevels); + GrayscaleLevelsRowOperation grayscaleOperation = new(this.Configuration, interest, histogramBuffer, source.PixelBuffer, this.LuminanceLevels); ParallelRowIterator.IterateRows, Vector4>( this.Configuration, interest, @@ -83,7 +83,7 @@ ref MemoryMarshal.GetReference(histogram), if (this.SyncChannels) { - var cdfOperation = new SynchronizedChannelsRowOperation(this.Configuration, interest, cdfBuffer, source.PixelBuffer, this.LuminanceLevels, numberOfPixelsMinusCdfMin); + SynchronizedChannelsRowOperation cdfOperation = new(this.Configuration, interest, cdfBuffer, source.PixelBuffer, this.LuminanceLevels, numberOfPixelsMinusCdfMin); ParallelRowIterator.IterateRows( this.Configuration, interest, @@ -91,7 +91,7 @@ ref MemoryMarshal.GetReference(histogram), } else { - var cdfOperation = new SeperateChannelsRowOperation(this.Configuration, interest, cdfBuffer, source.PixelBuffer, this.LuminanceLevels, numberOfPixelsMinusCdfMin); + SeperateChannelsRowOperation cdfOperation = new(this.Configuration, interest, cdfBuffer, source.PixelBuffer, this.LuminanceLevels, numberOfPixelsMinusCdfMin); ParallelRowIterator.IterateRows( this.Configuration, interest, @@ -139,7 +139,7 @@ public void Invoke(int y, Span span) Span vectorBuffer = span.Slice(0, this.bounds.Width); ref Vector4 vectorRef = ref MemoryMarshal.GetReference(vectorBuffer); ref int cdfBase = ref MemoryMarshal.GetReference(this.cdfBuffer.GetSpan()); - var sourceAccess = new PixelAccessor(this.source); + PixelAccessor sourceAccess = new(this.source); int levels = this.luminanceLevels; float noOfPixelsMinusCdfMin = this.numberOfPixelsMinusCdfMin; @@ -148,11 +148,11 @@ public void Invoke(int y, Span span) for (int x = 0; x < this.bounds.Width; x++) { - var vector = Unsafe.Add(ref vectorRef, (uint)x); + Vector4 vector = Unsafe.Add(ref vectorRef, (uint)x); int luminance = ColorNumerics.GetBT709Luminance(ref vector, levels); float scaledLuminance = Unsafe.Add(ref cdfBase, (uint)luminance) / noOfPixelsMinusCdfMin; float scalingFactor = scaledLuminance * levels / luminance; - Vector4 scaledVector = new Vector4(scalingFactor * vector.X, scalingFactor * vector.Y, scalingFactor * vector.Z, vector.W); + Vector4 scaledVector = new(scalingFactor * vector.X, scalingFactor * vector.Y, scalingFactor * vector.Z, vector.W); Unsafe.Add(ref vectorRef, (uint)x) = scaledVector; } @@ -200,7 +200,7 @@ public void Invoke(int y, Span span) Span vectorBuffer = span.Slice(0, this.bounds.Width); ref Vector4 vectorRef = ref MemoryMarshal.GetReference(vectorBuffer); ref int cdfBase = ref MemoryMarshal.GetReference(this.cdfBuffer.GetSpan()); - var sourceAccess = new PixelAccessor(this.source); + PixelAccessor sourceAccess = new(this.source); int levelsMinusOne = this.luminanceLevels - 1; float noOfPixelsMinusCdfMin = this.numberOfPixelsMinusCdfMin; @@ -209,7 +209,7 @@ public void Invoke(int y, Span span) for (int x = 0; x < this.bounds.Width; x++) { - var vector = Unsafe.Add(ref vectorRef, (uint)x) * levelsMinusOne; + Vector4 vector = Unsafe.Add(ref vectorRef, (uint)x) * levelsMinusOne; uint originalX = (uint)MathF.Round(vector.X); float scaledX = Unsafe.Add(ref cdfBase, originalX) / noOfPixelsMinusCdfMin; @@ -217,7 +217,7 @@ public void Invoke(int y, Span span) float scaledY = Unsafe.Add(ref cdfBase, originalY) / noOfPixelsMinusCdfMin; uint originalZ = (uint)MathF.Round(vector.Z); float scaledZ = Unsafe.Add(ref cdfBase, originalZ) / noOfPixelsMinusCdfMin; - Unsafe.Add(ref vectorRef, (uint)x) = new Vector4(scaledX, scaledY, scaledZ, vector.W); + Unsafe.Add(ref vectorRef, (uint)x) = new(scaledX, scaledY, scaledZ, vector.W); } PixelOperations.Instance.FromVector4Destructive(this.configuration, vectorBuffer, pixelRow); diff --git a/src/ImageSharp/Processing/Processors/Normalization/GlobalHistogramEqualizationProcessor{TPixel}.cs b/src/ImageSharp/Processing/Processors/Normalization/GlobalHistogramEqualizationProcessor{TPixel}.cs index e7433899bf..0cfd4d2cf9 100644 --- a/src/ImageSharp/Processing/Processors/Normalization/GlobalHistogramEqualizationProcessor{TPixel}.cs +++ b/src/ImageSharp/Processing/Processors/Normalization/GlobalHistogramEqualizationProcessor{TPixel}.cs @@ -46,12 +46,12 @@ protected override void OnFrameApply(ImageFrame source) { MemoryAllocator memoryAllocator = this.Configuration.MemoryAllocator; int numberOfPixels = source.Width * source.Height; - var interest = Rectangle.Intersect(this.SourceRectangle, source.Bounds()); + Rectangle interest = Rectangle.Intersect(this.SourceRectangle, source.Bounds()); using IMemoryOwner histogramBuffer = memoryAllocator.Allocate(this.LuminanceLevels, AllocationOptions.Clean); // Build the histogram of the grayscale levels. - var grayscaleOperation = new GrayscaleLevelsRowOperation(this.Configuration, interest, histogramBuffer, source.PixelBuffer, this.LuminanceLevels); + GrayscaleLevelsRowOperation grayscaleOperation = new(this.Configuration, interest, histogramBuffer, source.PixelBuffer, this.LuminanceLevels); ParallelRowIterator.IterateRows, Vector4>( this.Configuration, interest, @@ -74,7 +74,7 @@ ref MemoryMarshal.GetReference(histogram), float numberOfPixelsMinusCdfMin = numberOfPixels - cdfMin; // Apply the cdf to each pixel of the image - var cdfOperation = new CdfApplicationRowOperation(this.Configuration, interest, cdfBuffer, source.PixelBuffer, this.LuminanceLevels, numberOfPixelsMinusCdfMin); + CdfApplicationRowOperation cdfOperation = new(this.Configuration, interest, cdfBuffer, source.PixelBuffer, this.LuminanceLevels, numberOfPixelsMinusCdfMin); ParallelRowIterator.IterateRows( this.Configuration, interest, @@ -129,10 +129,10 @@ public void Invoke(int y, Span span) for (int x = 0; x < this.bounds.Width; x++) { - var vector = Unsafe.Add(ref vectorRef, (uint)x); + Vector4 vector = Unsafe.Add(ref vectorRef, (uint)x); int luminance = ColorNumerics.GetBT709Luminance(ref vector, levels); float luminanceEqualized = Unsafe.Add(ref cdfBase, (uint)luminance) / noOfPixelsMinusCdfMin; - Unsafe.Add(ref vectorRef, (uint)x) = new Vector4(luminanceEqualized, luminanceEqualized, luminanceEqualized, vector.W); + Unsafe.Add(ref vectorRef, (uint)x) = new(luminanceEqualized, luminanceEqualized, luminanceEqualized, vector.W); } PixelOperations.Instance.FromVector4Destructive(this.configuration, vectorBuffer, pixelRow); diff --git a/src/ImageSharp/Processing/Processors/Normalization/GrayscaleLevelsRowOperation{TPixel}.cs b/src/ImageSharp/Processing/Processors/Normalization/GrayscaleLevelsRowOperation{TPixel}.cs index 0a8690ba70..3584f2954a 100644 --- a/src/ImageSharp/Processing/Processors/Normalization/GrayscaleLevelsRowOperation{TPixel}.cs +++ b/src/ImageSharp/Processing/Processors/Normalization/GrayscaleLevelsRowOperation{TPixel}.cs @@ -56,7 +56,7 @@ public void Invoke(int y, Span span) for (int x = 0; x < this.bounds.Width; x++) { - var vector = Unsafe.Add(ref vectorRef, (uint)x); + Vector4 vector = Unsafe.Add(ref vectorRef, (uint)x); int luminance = ColorNumerics.GetBT709Luminance(ref vector, levels); Interlocked.Increment(ref Unsafe.Add(ref histogramBase, (uint)luminance)); } diff --git a/src/ImageSharp/Processing/Processors/Overlays/BackgroundColorProcessor{TPixel}.cs b/src/ImageSharp/Processing/Processors/Overlays/BackgroundColorProcessor{TPixel}.cs index 1e43458253..e70fe89d7f 100644 --- a/src/ImageSharp/Processing/Processors/Overlays/BackgroundColorProcessor{TPixel}.cs +++ b/src/ImageSharp/Processing/Processors/Overlays/BackgroundColorProcessor{TPixel}.cs @@ -35,7 +35,7 @@ protected override void OnFrameApply(ImageFrame source) TPixel color = this.definition.Color.ToPixel(); GraphicsOptions graphicsOptions = this.definition.GraphicsOptions; - var interest = Rectangle.Intersect(this.SourceRectangle, source.Bounds()); + Rectangle interest = Rectangle.Intersect(this.SourceRectangle, source.Bounds()); Configuration configuration = this.Configuration; MemoryAllocator memoryAllocator = configuration.MemoryAllocator; @@ -48,7 +48,7 @@ protected override void OnFrameApply(ImageFrame source) PixelBlender blender = PixelOperations.Instance.GetPixelBlender(graphicsOptions); - var operation = new RowOperation(configuration, interest, blender, amount, colors, source.PixelBuffer); + RowOperation operation = new(configuration, interest, blender, amount, colors, source.PixelBuffer); ParallelRowIterator.IterateRows( configuration, interest, diff --git a/src/ImageSharp/Processing/Processors/Overlays/GlowProcessor{TPixel}.cs b/src/ImageSharp/Processing/Processors/Overlays/GlowProcessor{TPixel}.cs index 19ce6c417d..5258c7c488 100644 --- a/src/ImageSharp/Processing/Processors/Overlays/GlowProcessor{TPixel}.cs +++ b/src/ImageSharp/Processing/Processors/Overlays/GlowProcessor{TPixel}.cs @@ -40,7 +40,7 @@ protected override void OnFrameApply(ImageFrame source) TPixel glowColor = this.definition.GlowColor.ToPixel(); float blendPercent = this.definition.GraphicsOptions.BlendPercentage; - var interest = Rectangle.Intersect(this.SourceRectangle, source.Bounds()); + Rectangle interest = Rectangle.Intersect(this.SourceRectangle, source.Bounds()); Vector2 center = Rectangle.Center(interest); float finalRadius = this.definition.Radius.Calculate(interest.Size); @@ -54,7 +54,7 @@ protected override void OnFrameApply(ImageFrame source) using IMemoryOwner rowColors = allocator.Allocate(interest.Width); rowColors.GetSpan().Fill(glowColor); - var operation = new RowOperation(configuration, interest, rowColors, this.blender, center, maxDistance, blendPercent, source.PixelBuffer); + RowOperation operation = new(configuration, interest, rowColors, this.blender, center, maxDistance, blendPercent, source.PixelBuffer); ParallelRowIterator.IterateRows( configuration, interest, @@ -105,7 +105,7 @@ public void Invoke(int y, Span span) for (int i = 0; i < this.bounds.Width; i++) { - float distance = Vector2.Distance(this.center, new Vector2(i + this.bounds.X, y)); + float distance = Vector2.Distance(this.center, new(i + this.bounds.X, y)); span[i] = Numerics.Clamp(this.blendPercent * (1 - (.95F * (distance / this.maxDistance))), 0, 1F); } diff --git a/src/ImageSharp/Processing/Processors/Overlays/VignetteProcessor{TPixel}.cs b/src/ImageSharp/Processing/Processors/Overlays/VignetteProcessor{TPixel}.cs index a327deec1c..e8a2a23b4f 100644 --- a/src/ImageSharp/Processing/Processors/Overlays/VignetteProcessor{TPixel}.cs +++ b/src/ImageSharp/Processing/Processors/Overlays/VignetteProcessor{TPixel}.cs @@ -40,7 +40,7 @@ protected override void OnFrameApply(ImageFrame source) TPixel vignetteColor = this.definition.VignetteColor.ToPixel(); float blendPercent = this.definition.GraphicsOptions.BlendPercentage; - var interest = Rectangle.Intersect(this.SourceRectangle, source.Bounds()); + Rectangle interest = Rectangle.Intersect(this.SourceRectangle, source.Bounds()); Vector2 center = Rectangle.Center(interest); float finalRadiusX = this.definition.RadiusX.Calculate(interest.Size); @@ -62,7 +62,7 @@ protected override void OnFrameApply(ImageFrame source) using IMemoryOwner rowColors = allocator.Allocate(interest.Width); rowColors.GetSpan().Fill(vignetteColor); - var operation = new RowOperation(configuration, interest, rowColors, this.blender, center, maxDistance, blendPercent, source.PixelBuffer); + RowOperation operation = new(configuration, interest, rowColors, this.blender, center, maxDistance, blendPercent, source.PixelBuffer); ParallelRowIterator.IterateRows( configuration, interest, @@ -113,7 +113,7 @@ public void Invoke(int y, Span span) for (int i = 0; i < this.bounds.Width; i++) { - float distance = Vector2.Distance(this.center, new Vector2(i + this.bounds.X, y)); + float distance = Vector2.Distance(this.center, new(i + this.bounds.X, y)); span[i] = Numerics.Clamp(this.blendPercent * (.9F * (distance / this.maxDistance)), 0, 1F); } diff --git a/src/ImageSharp/Processing/Processors/Quantization/EuclideanPixelMap{TPixel}.cs b/src/ImageSharp/Processing/Processors/Quantization/EuclideanPixelMap{TPixel}.cs index 4fd37d479d..2e381caade 100644 --- a/src/ImageSharp/Processing/Processors/Quantization/EuclideanPixelMap{TPixel}.cs +++ b/src/ImageSharp/Processing/Processors/Quantization/EuclideanPixelMap{TPixel}.cs @@ -51,7 +51,7 @@ public EuclideanPixelMap(Configuration configuration, ReadOnlyMemory pal this.configuration = configuration; this.Palette = palette; this.rgbaPalette = new Rgba32[palette.Length]; - this.cache = new ColorDistanceCache(configuration.MemoryAllocator); + this.cache = new(configuration.MemoryAllocator); PixelOperations.Instance.ToRgba32(configuration, this.Palette.Span, this.rgbaPalette); this.transparentIndex = transparentIndex; diff --git a/src/ImageSharp/Processing/Processors/Quantization/OctreeQuantizer.cs b/src/ImageSharp/Processing/Processors/Quantization/OctreeQuantizer.cs index 0a1032bf0d..9a46a9883a 100644 --- a/src/ImageSharp/Processing/Processors/Quantization/OctreeQuantizer.cs +++ b/src/ImageSharp/Processing/Processors/Quantization/OctreeQuantizer.cs @@ -16,7 +16,7 @@ public class OctreeQuantizer : IQuantizer /// using the default . /// public OctreeQuantizer() - : this(new QuantizerOptions()) + : this(new()) { } diff --git a/src/ImageSharp/Processing/Processors/Quantization/OctreeQuantizer{TPixel}.cs b/src/ImageSharp/Processing/Processors/Quantization/OctreeQuantizer{TPixel}.cs index 8b39b74579..0891ee5111 100644 --- a/src/ImageSharp/Processing/Processors/Quantization/OctreeQuantizer{TPixel}.cs +++ b/src/ImageSharp/Processing/Processors/Quantization/OctreeQuantizer{TPixel}.cs @@ -45,7 +45,7 @@ public OctreeQuantizer(Configuration configuration, QuantizerOptions options) this.maxColors = this.Options.MaxColors; this.bitDepth = Numerics.Clamp(ColorNumerics.GetBitsNeededForColorDepth(this.maxColors), 1, 8); - this.octree = new Octree(this.bitDepth); + this.octree = new(this.bitDepth); this.paletteOwner = configuration.MemoryAllocator.Allocate(this.maxColors, AllocationOptions.Clean); this.pixelMap = default; this.palette = default; @@ -113,7 +113,7 @@ public void AddPaletteColors(Buffer2DRegion pixelRegion) // this prevents memory churn caused by reallocation. if (this.pixelMap is null) { - this.pixelMap = new EuclideanPixelMap(this.Configuration, result); + this.pixelMap = new(this.Configuration, result); } else { @@ -194,7 +194,7 @@ public Octree(int maxColorBits) this.maxColorBits = maxColorBits; this.Leaves = 0; this.ReducibleNodes = new OctreeNode[9]; - this.root = new OctreeNode(0, this.maxColorBits, this); + this.root = new(0, this.maxColorBits, this); this.previousColor = default; this.previousNode = null; } @@ -419,7 +419,7 @@ public void AddColor(ref Rgba32 color, int colorBits, int level, Octree octree) if (child is null) { // Create a new child node and store it in the array - child = new OctreeNode(level + 1, colorBits, octree); + child = new(level + 1, colorBits, octree); this.children[index] = child; } @@ -473,9 +473,9 @@ public void ConstructPalette(Span palette, ref int index) Vector3 vector = Vector3.Clamp( new Vector3(this.red, this.green, this.blue) / this.pixelCount, Vector3.Zero, - new Vector3(255)); + new(255)); - palette[index] = TPixel.FromRgba32(new Rgba32((byte)vector.X, (byte)vector.Y, (byte)vector.Z)); + palette[index] = TPixel.FromRgba32(new((byte)vector.X, (byte)vector.Y, (byte)vector.Z)); // Consume the next palette index this.paletteIndex = index++; diff --git a/src/ImageSharp/Processing/Processors/Quantization/PaletteQuantizer.cs b/src/ImageSharp/Processing/Processors/Quantization/PaletteQuantizer.cs index 13a59a26de..cac91b834d 100644 --- a/src/ImageSharp/Processing/Processors/Quantization/PaletteQuantizer.cs +++ b/src/ImageSharp/Processing/Processors/Quantization/PaletteQuantizer.cs @@ -18,7 +18,7 @@ public class PaletteQuantizer : IQuantizer /// /// The color palette. public PaletteQuantizer(ReadOnlyMemory palette) - : this(palette, new QuantizerOptions()) + : this(palette, new()) { } diff --git a/src/ImageSharp/Processing/Processors/Quantization/PaletteQuantizer{TPixel}.cs b/src/ImageSharp/Processing/Processors/Quantization/PaletteQuantizer{TPixel}.cs index 092975d28a..46292ab71d 100644 --- a/src/ImageSharp/Processing/Processors/Quantization/PaletteQuantizer{TPixel}.cs +++ b/src/ImageSharp/Processing/Processors/Quantization/PaletteQuantizer{TPixel}.cs @@ -41,7 +41,7 @@ public PaletteQuantizer( this.Configuration = configuration; this.Options = options; - this.pixelMap = new EuclideanPixelMap(configuration, palette, transparentIndex); + this.pixelMap = new(configuration, palette, transparentIndex); } /// diff --git a/src/ImageSharp/Processing/Processors/Quantization/WebSafePaletteQuantizer.cs b/src/ImageSharp/Processing/Processors/Quantization/WebSafePaletteQuantizer.cs index 604cae6681..ff5fc1c641 100644 --- a/src/ImageSharp/Processing/Processors/Quantization/WebSafePaletteQuantizer.cs +++ b/src/ImageSharp/Processing/Processors/Quantization/WebSafePaletteQuantizer.cs @@ -12,7 +12,7 @@ public class WebSafePaletteQuantizer : PaletteQuantizer /// Initializes a new instance of the class. /// public WebSafePaletteQuantizer() - : this(new QuantizerOptions()) + : this(new()) { } diff --git a/src/ImageSharp/Processing/Processors/Quantization/WernerPaletteQuantizer.cs b/src/ImageSharp/Processing/Processors/Quantization/WernerPaletteQuantizer.cs index 023ee7f2e0..36599421f0 100644 --- a/src/ImageSharp/Processing/Processors/Quantization/WernerPaletteQuantizer.cs +++ b/src/ImageSharp/Processing/Processors/Quantization/WernerPaletteQuantizer.cs @@ -13,7 +13,7 @@ public class WernerPaletteQuantizer : PaletteQuantizer /// Initializes a new instance of the class. /// public WernerPaletteQuantizer() - : this(new QuantizerOptions()) + : this(new()) { } diff --git a/src/ImageSharp/Processing/Processors/Quantization/WuQuantizer.cs b/src/ImageSharp/Processing/Processors/Quantization/WuQuantizer.cs index 86d798d965..cda78c7d1a 100644 --- a/src/ImageSharp/Processing/Processors/Quantization/WuQuantizer.cs +++ b/src/ImageSharp/Processing/Processors/Quantization/WuQuantizer.cs @@ -15,7 +15,7 @@ public class WuQuantizer : IQuantizer /// using the default . /// public WuQuantizer() - : this(new QuantizerOptions()) + : this(new()) { } diff --git a/src/ImageSharp/Processing/Processors/Quantization/WuQuantizer{TPixel}.cs b/src/ImageSharp/Processing/Processors/Quantization/WuQuantizer{TPixel}.cs index ba2ab825ad..3a0fccbb0a 100644 --- a/src/ImageSharp/Processing/Processors/Quantization/WuQuantizer{TPixel}.cs +++ b/src/ImageSharp/Processing/Processors/Quantization/WuQuantizer{TPixel}.cs @@ -153,7 +153,7 @@ public void AddPaletteColors(Buffer2DRegion pixelRegion) // this prevents memory churn caused by reallocation. if (this.pixelMap is null) { - this.pixelMap = new EuclideanPixelMap(this.Configuration, result); + this.pixelMap = new(this.Configuration, result); } else { @@ -528,7 +528,7 @@ private readonly float Maximize(ref Box cube, int direction, int first, int last continue; } - vector = new Vector4(half.R, half.G, half.B, half.A); + vector = new(half.R, half.G, half.B, half.A); temp += Vector4.Dot(vector, vector) / half.Weight; if (temp > max) diff --git a/src/ImageSharp/Processing/Processors/Transforms/CropProcessor{TPixel}.cs b/src/ImageSharp/Processing/Processors/Transforms/CropProcessor{TPixel}.cs index 1d82dd12ad..37e61b7d76 100644 --- a/src/ImageSharp/Processing/Processors/Transforms/CropProcessor{TPixel}.cs +++ b/src/ImageSharp/Processing/Processors/Transforms/CropProcessor{TPixel}.cs @@ -29,7 +29,7 @@ public CropProcessor(Configuration configuration, CropProcessor definition, Imag => this.cropRectangle = definition.CropRectangle; /// - protected override Size GetDestinationSize() => new Size(this.cropRectangle.Width, this.cropRectangle.Height); + protected override Size GetDestinationSize() => new(this.cropRectangle.Width, this.cropRectangle.Height); /// protected override void OnFrameApply(ImageFrame source, ImageFrame destination) @@ -50,7 +50,7 @@ protected override void OnFrameApply(ImageFrame source, ImageFrame temp = new(this.Configuration, this.Source.Metadata.DeepClone(), new[] { this.Source.Frames.RootFrame.Clone() })) + using (Image temp = new(this.Configuration, this.Source.Metadata.DeepClone(), [this.Source.Frames.RootFrame.Clone() + ])) { Configuration configuration = this.Source.Configuration; diff --git a/src/ImageSharp/Processing/Processors/Transforms/Linear/AffineTransformProcessor{TPixel}.cs b/src/ImageSharp/Processing/Processors/Transforms/Linear/AffineTransformProcessor{TPixel}.cs index c5c2a778eb..a6c0a25f49 100644 --- a/src/ImageSharp/Processing/Processors/Transforms/Linear/AffineTransformProcessor{TPixel}.cs +++ b/src/ImageSharp/Processing/Processors/Transforms/Linear/AffineTransformProcessor{TPixel}.cs @@ -61,7 +61,7 @@ public void ApplyTransform(in TResampler sampler) if (matrix.Equals(Matrix3x2.Identity)) { // The clone will be blank here copy all the pixel data over - var interest = Rectangle.Intersect(this.SourceRectangle, destination.Bounds()); + Rectangle interest = Rectangle.Intersect(this.SourceRectangle, destination.Bounds()); Buffer2DRegion sourceBuffer = source.PixelBuffer.GetRegion(interest); Buffer2DRegion destbuffer = destination.PixelBuffer.GetRegion(interest); for (int y = 0; y < sourceBuffer.Height; y++) @@ -77,7 +77,7 @@ public void ApplyTransform(in TResampler sampler) if (sampler is NearestNeighborResampler) { - var nnOperation = new NNAffineOperation( + NNAffineOperation nnOperation = new( source.PixelBuffer, Rectangle.Intersect(this.SourceRectangle, source.Bounds()), destination.PixelBuffer, @@ -91,7 +91,7 @@ public void ApplyTransform(in TResampler sampler) return; } - var operation = new AffineOperation( + AffineOperation operation = new( configuration, source.PixelBuffer, Rectangle.Intersect(this.SourceRectangle, source.Bounds()), @@ -132,7 +132,7 @@ public void Invoke(int y) for (int x = 0; x < destRow.Length; x++) { - var point = Vector2.Transform(new Vector2(x, y), this.matrix); + Vector2 point = Vector2.Transform(new(x, y), this.matrix); int px = (int)MathF.Round(point.X); int py = (int)MathF.Round(point.Y); @@ -204,7 +204,7 @@ public void Invoke(in RowInterval rows, Span span) for (int x = 0; x < span.Length; x++) { - var point = Vector2.Transform(new Vector2(x, y), matrix); + Vector2 point = Vector2.Transform(new(x, y), matrix); float pY = point.Y; float pX = point.X; diff --git a/src/ImageSharp/Processing/Processors/Transforms/Linear/FlipProcessor{TPixel}.cs b/src/ImageSharp/Processing/Processors/Transforms/Linear/FlipProcessor{TPixel}.cs index 14da3ac890..1a7dbf20dc 100644 --- a/src/ImageSharp/Processing/Processors/Transforms/Linear/FlipProcessor{TPixel}.cs +++ b/src/ImageSharp/Processing/Processors/Transforms/Linear/FlipProcessor{TPixel}.cs @@ -72,7 +72,7 @@ private static void FlipX(Buffer2D source, Configuration configuration) /// The configuration. private static void FlipY(ImageFrame source, Configuration configuration) { - var operation = new RowOperation(source.PixelBuffer); + RowOperation operation = new(source.PixelBuffer); ParallelRowIterator.IterateRows( configuration, source.Bounds(), diff --git a/src/ImageSharp/Processing/Processors/Transforms/Linear/ProjectiveTransformProcessor{TPixel}.cs b/src/ImageSharp/Processing/Processors/Transforms/Linear/ProjectiveTransformProcessor{TPixel}.cs index b741dc4ee6..cf815f13de 100644 --- a/src/ImageSharp/Processing/Processors/Transforms/Linear/ProjectiveTransformProcessor{TPixel}.cs +++ b/src/ImageSharp/Processing/Processors/Transforms/Linear/ProjectiveTransformProcessor{TPixel}.cs @@ -61,7 +61,7 @@ public void ApplyTransform(in TResampler sampler) if (matrix.Equals(Matrix4x4.Identity)) { // The clone will be blank here copy all the pixel data over - var interest = Rectangle.Intersect(this.SourceRectangle, destination.Bounds()); + Rectangle interest = Rectangle.Intersect(this.SourceRectangle, destination.Bounds()); Buffer2DRegion sourceBuffer = source.PixelBuffer.GetRegion(interest); Buffer2DRegion destbuffer = destination.PixelBuffer.GetRegion(interest); for (int y = 0; y < sourceBuffer.Height; y++) @@ -77,7 +77,7 @@ public void ApplyTransform(in TResampler sampler) if (sampler is NearestNeighborResampler) { - var nnOperation = new NNProjectiveOperation( + NNProjectiveOperation nnOperation = new( source.PixelBuffer, Rectangle.Intersect(this.SourceRectangle, source.Bounds()), destination.PixelBuffer, @@ -91,7 +91,7 @@ public void ApplyTransform(in TResampler sampler) return; } - var operation = new ProjectiveOperation( + ProjectiveOperation operation = new( configuration, source.PixelBuffer, Rectangle.Intersect(this.SourceRectangle, source.Bounds()), diff --git a/src/ImageSharp/Processing/Processors/Transforms/Linear/RotateProcessor{TPixel}.cs b/src/ImageSharp/Processing/Processors/Transforms/Linear/RotateProcessor{TPixel}.cs index 3ffb1ab518..0e08aecd7a 100644 --- a/src/ImageSharp/Processing/Processors/Transforms/Linear/RotateProcessor{TPixel}.cs +++ b/src/ImageSharp/Processing/Processors/Transforms/Linear/RotateProcessor{TPixel}.cs @@ -130,7 +130,7 @@ private bool OptimizedApply( /// The configuration. private static void Rotate180(ImageFrame source, ImageFrame destination, Configuration configuration) { - var operation = new Rotate180RowOperation(source.Width, source.Height, source.PixelBuffer, destination.PixelBuffer); + Rotate180RowOperation operation = new(source.Width, source.Height, source.PixelBuffer, destination.PixelBuffer); ParallelRowIterator.IterateRows( configuration, source.Bounds(), @@ -145,7 +145,7 @@ private static void Rotate180(ImageFrame source, ImageFrame dest /// The configuration. private static void Rotate270(ImageFrame source, ImageFrame destination, Configuration configuration) { - var operation = new Rotate270RowIntervalOperation(destination.Bounds(), source.Width, source.Height, source.PixelBuffer, destination.PixelBuffer); + Rotate270RowIntervalOperation operation = new(destination.Bounds(), source.Width, source.Height, source.PixelBuffer, destination.PixelBuffer); ParallelRowIterator.IterateRowIntervals( configuration, source.Bounds(), @@ -160,7 +160,7 @@ private static void Rotate270(ImageFrame source, ImageFrame dest /// The configuration. private static void Rotate90(ImageFrame source, ImageFrame destination, Configuration configuration) { - var operation = new Rotate90RowOperation(destination.Bounds(), source.Width, source.Height, source.PixelBuffer, destination.PixelBuffer); + Rotate90RowOperation operation = new(destination.Bounds(), source.Width, source.Height, source.PixelBuffer, destination.PixelBuffer); ParallelRowIterator.IterateRows( configuration, source.Bounds(), diff --git a/src/ImageSharp/Processing/Processors/Transforms/Resize/ResizeHelper.cs b/src/ImageSharp/Processing/Processors/Transforms/Resize/ResizeHelper.cs index d90f948b6f..e9e2849ae4 100644 --- a/src/ImageSharp/Processing/Processors/Transforms/Resize/ResizeHelper.cs +++ b/src/ImageSharp/Processing/Processors/Transforms/Resize/ResizeHelper.cs @@ -72,7 +72,7 @@ public static (Size Size, Rectangle Rectangle) CalculateTargetLocationAndBounds( // case ResizeMode.Stretch: default: - return (new Size(Sanitize(width), Sanitize(height)), new Rectangle(0, 0, Sanitize(width), Sanitize(height))); + return (new(Sanitize(width), Sanitize(height)), new(0, 0, Sanitize(width), Sanitize(height))); } } @@ -143,7 +143,7 @@ private static (Size Size, Rectangle Rectangle) CalculateBoxPadRectangle( } // Target image width and height can be different to the rectangle width and height. - return (new Size(Sanitize(width), Sanitize(height)), new Rectangle(targetX, targetY, Sanitize(targetWidth), Sanitize(targetHeight))); + return (new(Sanitize(width), Sanitize(height)), new(targetX, targetY, Sanitize(targetWidth), Sanitize(targetHeight))); } // Switch to pad mode to downscale and calculate from there. @@ -253,7 +253,7 @@ private static (Size Size, Rectangle Rectangle) CalculateCropRectangle( } // Target image width and height can be different to the rectangle width and height. - return (new Size(Sanitize(width), Sanitize(height)), new Rectangle(targetX, targetY, Sanitize(targetWidth), Sanitize(targetHeight))); + return (new(Sanitize(width), Sanitize(height)), new(targetX, targetY, Sanitize(targetWidth), Sanitize(targetHeight))); } private static (Size Size, Rectangle Rectangle) CalculateMaxRectangle( @@ -282,7 +282,7 @@ private static (Size Size, Rectangle Rectangle) CalculateMaxRectangle( } // Replace the size to match the rectangle. - return (new Size(Sanitize(targetWidth), Sanitize(targetHeight)), new Rectangle(0, 0, Sanitize(targetWidth), Sanitize(targetHeight))); + return (new(Sanitize(targetWidth), Sanitize(targetHeight)), new(0, 0, Sanitize(targetWidth), Sanitize(targetHeight))); } private static (Size Size, Rectangle Rectangle) CalculateMinRectangle( @@ -298,7 +298,7 @@ private static (Size Size, Rectangle Rectangle) CalculateMinRectangle( // Don't upscale if (width > sourceWidth || height > sourceHeight) { - return (new Size(sourceWidth, sourceHeight), new Rectangle(0, 0, sourceWidth, sourceHeight)); + return (new(sourceWidth, sourceHeight), new(0, 0, sourceWidth, sourceHeight)); } // Find the shortest distance to go. @@ -330,7 +330,7 @@ private static (Size Size, Rectangle Rectangle) CalculateMinRectangle( } // Replace the size to match the rectangle. - return (new Size(Sanitize(targetWidth), Sanitize(targetHeight)), new Rectangle(0, 0, Sanitize(targetWidth), Sanitize(targetHeight))); + return (new(Sanitize(targetWidth), Sanitize(targetHeight)), new(0, 0, Sanitize(targetWidth), Sanitize(targetHeight))); } private static (Size Size, Rectangle Rectangle) CalculatePadRectangle( @@ -398,7 +398,7 @@ private static (Size Size, Rectangle Rectangle) CalculatePadRectangle( } // Target image width and height can be different to the rectangle width and height. - return (new Size(Sanitize(width), Sanitize(height)), new Rectangle(targetX, targetY, Sanitize(targetWidth), Sanitize(targetHeight))); + return (new(Sanitize(width), Sanitize(height)), new(targetX, targetY, Sanitize(targetWidth), Sanitize(targetHeight))); } private static (Size Size, Rectangle Rectangle) CalculateManualRectangle( @@ -419,7 +419,7 @@ private static (Size Size, Rectangle Rectangle) CalculateManualRectangle( int targetHeight = targetRectangle.Height > 0 ? targetRectangle.Height : height; // Target image width and height can be different to the rectangle width and height. - return (new Size(Sanitize(width), Sanitize(height)), new Rectangle(targetX, targetY, Sanitize(targetWidth), Sanitize(targetHeight))); + return (new(Sanitize(width), Sanitize(height)), new(targetX, targetY, Sanitize(targetWidth), Sanitize(targetHeight))); } [DoesNotReturn] diff --git a/src/ImageSharp/Processing/Processors/Transforms/Resize/ResizeKernel.cs b/src/ImageSharp/Processing/Processors/Transforms/Resize/ResizeKernel.cs index 51a739d35e..26cf60034d 100644 --- a/src/ImageSharp/Processing/Processors/Transforms/Resize/ResizeKernel.cs +++ b/src/ImageSharp/Processing/Processors/Transforms/Resize/ResizeKernel.cs @@ -74,13 +74,13 @@ public Vector4 ConvolveCore(ref Vector4 rowStartRef) float* bufferEnd = bufferStart + (this.Length & ~3); Vector256 result256_0 = Vector256.Zero; Vector256 result256_1 = Vector256.Zero; - ReadOnlySpan maskBytes = new byte[] - { + ReadOnlySpan maskBytes = + [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, - 1, 0, 0, 0, 1, 0, 0, 0, - }; + 1, 0, 0, 0, 1, 0, 0, 0 + ]; Vector256 mask = Unsafe.ReadUnaligned>(ref MemoryMarshal.GetReference(maskBytes)); while (bufferStart < bufferEnd) diff --git a/src/ImageSharp/Processing/Processors/Transforms/Resize/ResizeKernelMap.cs b/src/ImageSharp/Processing/Processors/Transforms/Resize/ResizeKernelMap.cs index c1907bb520..fb4d319883 100644 --- a/src/ImageSharp/Processing/Processors/Transforms/Resize/ResizeKernelMap.cs +++ b/src/ImageSharp/Processing/Processors/Transforms/Resize/ResizeKernelMap.cs @@ -255,7 +255,7 @@ private unsafe ResizeKernel CreateKernel(int dataRowIndex, int left, int right) ref float rowReference = ref MemoryMarshal.GetReference(rowSpan); float* rowPtr = (float*)Unsafe.AsPointer(ref rowReference); - return new ResizeKernel(left, rowPtr, length); + return new(left, rowPtr, length); } [Conditional("DEBUG")] diff --git a/src/ImageSharp/Processing/Processors/Transforms/Resize/ResizeProcessor{TPixel}.cs b/src/ImageSharp/Processing/Processors/Transforms/Resize/ResizeProcessor{TPixel}.cs index cfc30edc0f..a047015d95 100644 --- a/src/ImageSharp/Processing/Processors/Transforms/Resize/ResizeProcessor{TPixel}.cs +++ b/src/ImageSharp/Processing/Processors/Transforms/Resize/ResizeProcessor{TPixel}.cs @@ -81,7 +81,7 @@ public void ApplyTransform(in TResampler sampler) return; } - var interest = Rectangle.Intersect(destinationRectangle, destination.Bounds); + Rectangle interest = Rectangle.Intersect(destinationRectangle, destination.Bounds); if (sampler is NearestNeighborResampler) { @@ -110,13 +110,13 @@ public void ApplyTransform(in TResampler sampler) // Since all image frame dimensions have to be the same we can calculate // the kernel maps and reuse for all frames. MemoryAllocator allocator = configuration.MemoryAllocator; - using var horizontalKernelMap = ResizeKernelMap.Calculate( + using ResizeKernelMap horizontalKernelMap = ResizeKernelMap.Calculate( in sampler, destinationRectangle.Width, sourceRectangle.Width, allocator); - using var verticalKernelMap = ResizeKernelMap.Calculate( + using ResizeKernelMap verticalKernelMap = ResizeKernelMap.Calculate( in sampler, destinationRectangle.Height, sourceRectangle.Height, @@ -158,7 +158,7 @@ private static void ApplyNNResizeFrameTransform( float widthFactor = sourceRectangle.Width / (float)destinationRectangle.Width; float heightFactor = sourceRectangle.Height / (float)destinationRectangle.Height; - var operation = new NNRowOperation( + NNRowOperation operation = new( sourceRectangle, destinationRectangle, interest, @@ -208,7 +208,7 @@ private static void ApplyResizeFrameTransform( // To reintroduce parallel processing, we would launch multiple workers // for different row intervals of the image. - using var worker = new ResizeWorker( + using ResizeWorker worker = new( configuration, sourceRegion, conversionModifiers, @@ -218,7 +218,7 @@ private static void ApplyResizeFrameTransform( destinationRectangle.Location); worker.Initialize(); - var workingInterval = new RowInterval(interest.Top, interest.Bottom); + RowInterval workingInterval = new(interest.Top, interest.Bottom); worker.FillDestinationPixels(workingInterval, destination.PixelBuffer); } diff --git a/src/ImageSharp/Processing/Processors/Transforms/Resize/ResizeWorker.cs b/src/ImageSharp/Processing/Processors/Transforms/Resize/ResizeWorker.cs index cce27a401c..3da3fcb6ac 100644 --- a/src/ImageSharp/Processing/Processors/Transforms/Resize/ResizeWorker.cs +++ b/src/ImageSharp/Processing/Processors/Transforms/Resize/ResizeWorker.cs @@ -89,7 +89,7 @@ public ResizeWorker( this.tempRowBuffer = configuration.MemoryAllocator.Allocate(this.sourceRectangle.Width); this.tempColumnBuffer = configuration.MemoryAllocator.Allocate(targetWorkingRect.Width); - this.currentWindow = new RowInterval(0, this.workerHeight); + this.currentWindow = new(0, this.workerHeight); } public void Dispose() @@ -158,7 +158,7 @@ private void Slide() 0, this.windowBandHeight); - this.currentWindow = new RowInterval(minY, maxY); + this.currentWindow = new(minY, maxY); // Calculate the remainder: this.CalculateFirstPassValues(this.currentWindow.Slice(this.windowBandHeight)); diff --git a/src/ImageSharp/Processing/Processors/Transforms/TransformUtils.cs b/src/ImageSharp/Processing/Processors/Transforms/TransformUtils.cs index 62ea5e830d..f0e4ba33e9 100644 --- a/src/ImageSharp/Processing/Processors/Transforms/TransformUtils.cs +++ b/src/ImageSharp/Processing/Processors/Transforms/TransformUtils.cs @@ -340,10 +340,10 @@ public static Size GetTransformedSize(Matrix4x4 matrix, Size size) float scaleY = 1F / new Vector2(matrix.M12, matrix.M22).Length(); // sqrt(M12^2 + M22^2) // Apply the offset relative to the scale - SizeF offsetSize = usePixelSpace ? new SizeF(scaleX, scaleY) : SizeF.Empty; + SizeF offsetSize = usePixelSpace ? new(scaleX, scaleY) : SizeF.Empty; // Subtract the offset size to translate to the appropriate space (pixel or coordinate). - if (TryGetTransformedRectangle(new RectangleF(Point.Empty, size - offsetSize), matrix, out Rectangle bounds)) + if (TryGetTransformedRectangle(new(Point.Empty, size - offsetSize), matrix, out Rectangle bounds)) { // Add the offset size back to translate the transformed bounds to the correct space. return Size.Ceiling(ConstrainSize(bounds) + offsetSize); @@ -392,7 +392,7 @@ private static Size GetTransformedSize(Matrix3x2 matrix, Size size, TransformSpa } // Subtract the offset size to translate to the pixel space. - if (TryGetTransformedRectangle(new RectangleF(Point.Empty, size - offsetSize), matrix, out Rectangle bounds)) + if (TryGetTransformedRectangle(new(Point.Empty, size - offsetSize), matrix, out Rectangle bounds)) { // Add the offset size back to translate the transformed bounds to the coordinate space. return Size.Ceiling((constrain ? ConstrainSize(bounds) : bounds.Size) + offsetSize); @@ -418,10 +418,10 @@ private static bool TryGetTransformedRectangle(RectangleF rectangle, Matrix3x2 m return false; } - Vector2 tl = Vector2.Transform(new Vector2(rectangle.Left, rectangle.Top), matrix); - Vector2 tr = Vector2.Transform(new Vector2(rectangle.Right, rectangle.Top), matrix); - Vector2 bl = Vector2.Transform(new Vector2(rectangle.Left, rectangle.Bottom), matrix); - Vector2 br = Vector2.Transform(new Vector2(rectangle.Right, rectangle.Bottom), matrix); + Vector2 tl = Vector2.Transform(new(rectangle.Left, rectangle.Top), matrix); + Vector2 tr = Vector2.Transform(new(rectangle.Right, rectangle.Top), matrix); + Vector2 bl = Vector2.Transform(new(rectangle.Left, rectangle.Bottom), matrix); + Vector2 br = Vector2.Transform(new(rectangle.Right, rectangle.Bottom), matrix); bounds = GetBoundingRectangle(tl, tr, bl, br); return true; @@ -473,7 +473,7 @@ private static Size ConstrainSize(Rectangle rectangle) width = rectangle.Width; } - return new Size(width, height); + return new(width, height); } [MethodImpl(MethodImplOptions.AggressiveInlining)] diff --git a/src/ImageSharp/Processing/ProjectiveTransformBuilder.cs b/src/ImageSharp/Processing/ProjectiveTransformBuilder.cs index 9027ee7266..f1eb86aabe 100644 --- a/src/ImageSharp/Processing/ProjectiveTransformBuilder.cs +++ b/src/ImageSharp/Processing/ProjectiveTransformBuilder.cs @@ -11,7 +11,7 @@ namespace SixLabors.ImageSharp.Processing; /// public class ProjectiveTransformBuilder { - private readonly List> transformMatrixFactories = new(); + private readonly List> transformMatrixFactories = []; /// /// Initializes a new instance of the class. @@ -69,7 +69,7 @@ public ProjectiveTransformBuilder PrependRotationDegrees(float degrees) /// The amount of rotation, in radians. /// The . public ProjectiveTransformBuilder PrependRotationRadians(float radians) - => this.Prepend(size => new Matrix4x4(TransformUtils.CreateRotationTransformMatrixRadians(radians, size, this.TransformSpace))); + => this.Prepend(size => new(TransformUtils.CreateRotationTransformMatrixRadians(radians, size, this.TransformSpace))); /// /// Prepends a centered rotation matrix using the given rotation in degrees at the given origin. @@ -87,7 +87,7 @@ internal ProjectiveTransformBuilder PrependRotationDegrees(float degrees, Vector /// The rotation origin point. /// The . internal ProjectiveTransformBuilder PrependRotationRadians(float radians, Vector2 origin) - => this.PrependMatrix(Matrix4x4.CreateRotationZ(radians, new Vector3(origin, 0))); + => this.PrependMatrix(Matrix4x4.CreateRotationZ(radians, new(origin, 0))); /// /// Appends a centered rotation matrix using the given rotation in degrees. @@ -103,7 +103,7 @@ public ProjectiveTransformBuilder AppendRotationDegrees(float degrees) /// The amount of rotation, in radians. /// The . public ProjectiveTransformBuilder AppendRotationRadians(float radians) - => this.Append(size => new Matrix4x4(TransformUtils.CreateRotationTransformMatrixRadians(radians, size, this.TransformSpace))); + => this.Append(size => new(TransformUtils.CreateRotationTransformMatrixRadians(radians, size, this.TransformSpace))); /// /// Appends a centered rotation matrix using the given rotation in degrees at the given origin. @@ -121,7 +121,7 @@ internal ProjectiveTransformBuilder AppendRotationDegrees(float degrees, Vector2 /// The rotation origin point. /// The . internal ProjectiveTransformBuilder AppendRotationRadians(float radians, Vector2 origin) - => this.AppendMatrix(Matrix4x4.CreateRotationZ(radians, new Vector3(origin, 0))); + => this.AppendMatrix(Matrix4x4.CreateRotationZ(radians, new(origin, 0))); /// /// Prepends a scale matrix from the given uniform scale. @@ -187,7 +187,7 @@ internal ProjectiveTransformBuilder PrependSkewDegrees(float degreesX, float deg /// The Y angle, in radians. /// The . public ProjectiveTransformBuilder PrependSkewRadians(float radiansX, float radiansY) - => this.Prepend(size => new Matrix4x4(TransformUtils.CreateSkewTransformMatrixRadians(radiansX, radiansY, size, this.TransformSpace))); + => this.Prepend(size => new(TransformUtils.CreateSkewTransformMatrixRadians(radiansX, radiansY, size, this.TransformSpace))); /// /// Prepends a skew matrix using the given angles in degrees at the given origin. @@ -207,7 +207,7 @@ public ProjectiveTransformBuilder PrependSkewDegrees(float degreesX, float degre /// The skew origin point. /// The . public ProjectiveTransformBuilder PrependSkewRadians(float radiansX, float radiansY, Vector2 origin) - => this.PrependMatrix(new Matrix4x4(Matrix3x2.CreateSkew(radiansX, radiansY, origin))); + => this.PrependMatrix(new(Matrix3x2.CreateSkew(radiansX, radiansY, origin))); /// /// Appends a centered skew matrix from the give angles in degrees. @@ -225,7 +225,7 @@ internal ProjectiveTransformBuilder AppendSkewDegrees(float degreesX, float degr /// The Y angle, in radians. /// The . public ProjectiveTransformBuilder AppendSkewRadians(float radiansX, float radiansY) - => this.Append(size => new Matrix4x4(TransformUtils.CreateSkewTransformMatrixRadians(radiansX, radiansY, size, this.TransformSpace))); + => this.Append(size => new(TransformUtils.CreateSkewTransformMatrixRadians(radiansX, radiansY, size, this.TransformSpace))); /// /// Appends a skew matrix using the given angles in degrees at the given origin. @@ -245,7 +245,7 @@ public ProjectiveTransformBuilder AppendSkewDegrees(float degreesX, float degree /// The skew origin point. /// The . public ProjectiveTransformBuilder AppendSkewRadians(float radiansX, float radiansY, Vector2 origin) - => this.AppendMatrix(new Matrix4x4(Matrix3x2.CreateSkew(radiansX, radiansY, origin))); + => this.AppendMatrix(new(Matrix3x2.CreateSkew(radiansX, radiansY, origin))); /// /// Prepends a translation matrix from the given vector. @@ -261,7 +261,7 @@ public ProjectiveTransformBuilder PrependTranslation(PointF position) /// The translation position. /// The . public ProjectiveTransformBuilder PrependTranslation(Vector2 position) - => this.PrependMatrix(Matrix4x4.CreateTranslation(new Vector3(position, 0))); + => this.PrependMatrix(Matrix4x4.CreateTranslation(new(position, 0))); /// /// Appends a translation matrix from the given vector. @@ -277,7 +277,7 @@ public ProjectiveTransformBuilder AppendTranslation(PointF position) /// The translation position. /// The . public ProjectiveTransformBuilder AppendTranslation(Vector2 position) - => this.AppendMatrix(Matrix4x4.CreateTranslation(new Vector3(position, 0))); + => this.AppendMatrix(Matrix4x4.CreateTranslation(new(position, 0))); /// /// Prepends a raw matrix. @@ -335,7 +335,7 @@ public Matrix4x4 BuildMatrix(Rectangle sourceRectangle) Guard.MustBeGreaterThan(sourceRectangle.Height, 0, nameof(sourceRectangle)); // Translate the origin matrix to cater for source rectangle offsets. - Matrix4x4 matrix = Matrix4x4.CreateTranslation(new Vector3(-sourceRectangle.Location, 0)); + Matrix4x4 matrix = Matrix4x4.CreateTranslation(new(-sourceRectangle.Location, 0)); Size size = sourceRectangle.Size; @@ -364,7 +364,7 @@ public Size GetTransformedSize(Rectangle sourceRectangle) Size size = sourceRectangle.Size; // Translate the origin matrix to cater for source rectangle offsets. - Matrix4x4 matrix = Matrix4x4.CreateTranslation(new Vector3(-sourceRectangle.Location, 0)); + Matrix4x4 matrix = Matrix4x4.CreateTranslation(new(-sourceRectangle.Location, 0)); foreach (Func factory in this.transformMatrixFactories) { diff --git a/tests/ImageSharp.Benchmarks/Bulk/FromRgba32Bytes.cs b/tests/ImageSharp.Benchmarks/Bulk/FromRgba32Bytes.cs index 6cae208538..b9f12aa238 100644 --- a/tests/ImageSharp.Benchmarks/Bulk/FromRgba32Bytes.cs +++ b/tests/ImageSharp.Benchmarks/Bulk/FromRgba32Bytes.cs @@ -49,7 +49,7 @@ public void Naive() for (int i = 0; i < this.Count; i++) { int i4 = i * 4; - d[i] = TPixel.FromRgba32(new Rgba32(s[i4], s[i4 + 1], s[i4 + 2], s[i4 + 3])); + d[i] = TPixel.FromRgba32(new(s[i4], s[i4 + 1], s[i4 + 2], s[i4 + 3])); } } diff --git a/tests/ImageSharp.Benchmarks/Bulk/FromVector4.cs b/tests/ImageSharp.Benchmarks/Bulk/FromVector4.cs index 53c26a57ea..80b0963440 100644 --- a/tests/ImageSharp.Benchmarks/Bulk/FromVector4.cs +++ b/tests/ImageSharp.Benchmarks/Bulk/FromVector4.cs @@ -73,7 +73,8 @@ public void UseHwIntrinsics() SimdUtils.HwIntrinsics.NormalizedFloatToByteSaturate(sBytes, dFloats); } - private static ReadOnlySpan PermuteMaskDeinterleave8x32 => new byte[] { 0, 0, 0, 0, 4, 0, 0, 0, 1, 0, 0, 0, 5, 0, 0, 0, 2, 0, 0, 0, 6, 0, 0, 0, 3, 0, 0, 0, 7, 0, 0, 0 }; + private static ReadOnlySpan PermuteMaskDeinterleave8x32 => [0, 0, 0, 0, 4, 0, 0, 0, 1, 0, 0, 0, 5, 0, 0, 0, 2, 0, 0, 0, 6, 0, 0, 0, 3, 0, 0, 0, 7, 0, 0, 0 + ]; [Benchmark] public void UseAvx2_Grouped() diff --git a/tests/ImageSharp.Benchmarks/Codecs/Bmp/DecodeBmp.cs b/tests/ImageSharp.Benchmarks/Codecs/Bmp/DecodeBmp.cs index eb5b3c49d9..4d3b46cf68 100644 --- a/tests/ImageSharp.Benchmarks/Codecs/Bmp/DecodeBmp.cs +++ b/tests/ImageSharp.Benchmarks/Codecs/Bmp/DecodeBmp.cs @@ -32,16 +32,16 @@ public void ReadImages() [Benchmark(Baseline = true, Description = "System.Drawing Bmp")] public SDSize BmpSystemDrawing() { - using var memoryStream = new MemoryStream(this.bmpBytes); - using var image = SDImage.FromStream(memoryStream); + using MemoryStream memoryStream = new(this.bmpBytes); + using SDImage image = SDImage.FromStream(memoryStream); return image.Size; } [Benchmark(Description = "ImageSharp Bmp")] public Size BmpImageSharp() { - using var memoryStream = new MemoryStream(this.bmpBytes); - using var image = Image.Load(memoryStream); - return new Size(image.Width, image.Height); + using MemoryStream memoryStream = new(this.bmpBytes); + using Image image = Image.Load(memoryStream); + return new(image.Width, image.Height); } } diff --git a/tests/ImageSharp.Benchmarks/Codecs/Bmp/EncodeBmp.cs b/tests/ImageSharp.Benchmarks/Codecs/Bmp/EncodeBmp.cs index 3e6cfa51b0..3017bbc1ed 100644 --- a/tests/ImageSharp.Benchmarks/Codecs/Bmp/EncodeBmp.cs +++ b/tests/ImageSharp.Benchmarks/Codecs/Bmp/EncodeBmp.cs @@ -40,14 +40,14 @@ public void Cleanup() [Benchmark(Baseline = true, Description = "System.Drawing Bmp")] public void BmpSystemDrawing() { - using var memoryStream = new MemoryStream(); + using MemoryStream memoryStream = new(); this.bmpDrawing.Save(memoryStream, ImageFormat.Bmp); } [Benchmark(Description = "ImageSharp Bmp")] public void BmpImageSharp() { - using var memoryStream = new MemoryStream(); + using MemoryStream memoryStream = new(); this.bmpCore.SaveAsBmp(memoryStream); } } diff --git a/tests/ImageSharp.Benchmarks/Codecs/Bmp/EncodeBmpMultiple.cs b/tests/ImageSharp.Benchmarks/Codecs/Bmp/EncodeBmpMultiple.cs index fdef1b2bfc..ce54c133b0 100644 --- a/tests/ImageSharp.Benchmarks/Codecs/Bmp/EncodeBmpMultiple.cs +++ b/tests/ImageSharp.Benchmarks/Codecs/Bmp/EncodeBmpMultiple.cs @@ -10,7 +10,7 @@ namespace SixLabors.ImageSharp.Benchmarks.Codecs; [Config(typeof(Config.Short))] public class EncodeBmpMultiple : MultiImageBenchmarkBase.WithImagesPreloaded { - protected override IEnumerable InputImageSubfoldersOrFiles => new[] { "Bmp/", "Jpg/baseline" }; + protected override IEnumerable InputImageSubfoldersOrFiles => ["Bmp/", "Jpg/baseline"]; [Benchmark(Description = "EncodeBmpMultiple - ImageSharp")] public void EncodeBmpImageSharp() diff --git a/tests/ImageSharp.Benchmarks/Codecs/Gif/DecodeGif.cs b/tests/ImageSharp.Benchmarks/Codecs/Gif/DecodeGif.cs index 525e9f5e5a..930a85a75d 100644 --- a/tests/ImageSharp.Benchmarks/Codecs/Gif/DecodeGif.cs +++ b/tests/ImageSharp.Benchmarks/Codecs/Gif/DecodeGif.cs @@ -32,16 +32,16 @@ public void ReadImages() [Benchmark(Baseline = true, Description = "System.Drawing Gif")] public SDSize GifSystemDrawing() { - using var memoryStream = new MemoryStream(this.gifBytes); - using var image = SDImage.FromStream(memoryStream); + using MemoryStream memoryStream = new(this.gifBytes); + using SDImage image = SDImage.FromStream(memoryStream); return image.Size; } [Benchmark(Description = "ImageSharp Gif")] public Size GifImageSharp() { - using var memoryStream = new MemoryStream(this.gifBytes); - using var image = Image.Load(memoryStream); - return new Size(image.Width, image.Height); + using MemoryStream memoryStream = new(this.gifBytes); + using Image image = Image.Load(memoryStream); + return new(image.Width, image.Height); } } diff --git a/tests/ImageSharp.Benchmarks/Codecs/Gif/EncodeGif.cs b/tests/ImageSharp.Benchmarks/Codecs/Gif/EncodeGif.cs index c3644221e1..19101eb3ae 100644 --- a/tests/ImageSharp.Benchmarks/Codecs/Gif/EncodeGif.cs +++ b/tests/ImageSharp.Benchmarks/Codecs/Gif/EncodeGif.cs @@ -21,9 +21,9 @@ public class EncodeGif private Image bmpCore; // Try to get as close to System.Drawing's output as possible - private readonly GifEncoder encoder = new GifEncoder + private readonly GifEncoder encoder = new() { - Quantizer = new WebSafePaletteQuantizer(new QuantizerOptions { Dither = KnownDitherings.Bayer4x4 }) + Quantizer = new WebSafePaletteQuantizer(new() { Dither = KnownDitherings.Bayer4x4 }) }; [Params(TestImages.Bmp.Car, TestImages.Png.Rgb48Bpp)] @@ -53,14 +53,14 @@ public void Cleanup() [Benchmark(Baseline = true, Description = "System.Drawing Gif")] public void GifSystemDrawing() { - using var memoryStream = new MemoryStream(); + using MemoryStream memoryStream = new(); this.bmpDrawing.Save(memoryStream, ImageFormat.Gif); } [Benchmark(Description = "ImageSharp Gif")] public void GifImageSharp() { - using var memoryStream = new MemoryStream(); + using MemoryStream memoryStream = new(); this.bmpCore.SaveAsGif(memoryStream, this.encoder); } } diff --git a/tests/ImageSharp.Benchmarks/Codecs/Gif/EncodeGifMultiple.cs b/tests/ImageSharp.Benchmarks/Codecs/Gif/EncodeGifMultiple.cs index 9557f616ca..8d8c2f966b 100644 --- a/tests/ImageSharp.Benchmarks/Codecs/Gif/EncodeGifMultiple.cs +++ b/tests/ImageSharp.Benchmarks/Codecs/Gif/EncodeGifMultiple.cs @@ -15,16 +15,16 @@ public class EncodeGifMultiple : MultiImageBenchmarkBase.WithImagesPreloaded [Params(InputImageCategory.AllImages)] public override InputImageCategory InputCategory { get; set; } - protected override IEnumerable InputImageSubfoldersOrFiles => new[] { "Gif/" }; + protected override IEnumerable InputImageSubfoldersOrFiles => ["Gif/"]; [Benchmark(Description = "EncodeGifMultiple - ImageSharp")] public void EncodeGifImageSharp() => this.ForEachImageSharpImage((img, ms) => { // Try to get as close to System.Drawing's output as possible - var options = new GifEncoder + GifEncoder options = new() { - Quantizer = new WebSafePaletteQuantizer(new QuantizerOptions { Dither = KnownDitherings.Bayer4x4 }) + Quantizer = new WebSafePaletteQuantizer(new() { Dither = KnownDitherings.Bayer4x4 }) }; img.Save(ms, options); diff --git a/tests/ImageSharp.Benchmarks/Codecs/Jpeg/BlockOperations/Block8x8F_CopyTo2x2.cs b/tests/ImageSharp.Benchmarks/Codecs/Jpeg/BlockOperations/Block8x8F_CopyTo2x2.cs index 72b6bb72e8..4ea0a92f19 100644 --- a/tests/ImageSharp.Benchmarks/Codecs/Jpeg/BlockOperations/Block8x8F_CopyTo2x2.cs +++ b/tests/ImageSharp.Benchmarks/Codecs/Jpeg/BlockOperations/Block8x8F_CopyTo2x2.cs @@ -185,15 +185,15 @@ private static void WidenCopyImpl2x2_Vector2(ref Block8x8F src, ref Vector2 dest ref Vector2 dBottomLeft = ref Unsafe.Add(ref dTopLeft, (uint)destStride); ref Vector2 dBottomRight = ref Unsafe.Add(ref dBottomLeft, 4); - var xLeft = new Vector2(sLeft.X); - var yLeft = new Vector2(sLeft.Y); - var zLeft = new Vector2(sLeft.Z); - var wLeft = new Vector2(sLeft.W); + Vector2 xLeft = new(sLeft.X); + Vector2 yLeft = new(sLeft.Y); + Vector2 zLeft = new(sLeft.Z); + Vector2 wLeft = new(sLeft.W); - var xRight = new Vector2(sRight.X); - var yRight = new Vector2(sRight.Y); - var zRight = new Vector2(sRight.Z); - var wRight = new Vector2(sRight.W); + Vector2 xRight = new(sRight.X); + Vector2 yRight = new(sRight.Y); + Vector2 zRight = new(sRight.Z); + Vector2 wRight = new(sRight.W); dTopLeft = xLeft; Unsafe.Add(ref dTopLeft, 1) = yLeft; @@ -245,15 +245,15 @@ private static void WidenCopyImpl2x2_Vector4(ref Block8x8F src, ref Vector2 dest ref Vector2 dBottomLeft = ref Unsafe.Add(ref dTopLeft, (uint)destStride); ref Vector2 dBottomRight = ref Unsafe.Add(ref dBottomLeft, 4); - var xLeft = new Vector4(sLeft.X); - var yLeft = new Vector4(sLeft.Y); - var zLeft = new Vector4(sLeft.Z); - var wLeft = new Vector4(sLeft.W); + Vector4 xLeft = new(sLeft.X); + Vector4 yLeft = new(sLeft.Y); + Vector4 zLeft = new(sLeft.Z); + Vector4 wLeft = new(sLeft.W); - var xRight = new Vector4(sRight.X); - var yRight = new Vector4(sRight.Y); - var zRight = new Vector4(sRight.Z); - var wRight = new Vector4(sRight.W); + Vector4 xRight = new(sRight.X); + Vector4 yRight = new(sRight.Y); + Vector4 zRight = new(sRight.Z); + Vector4 wRight = new(sRight.W); Unsafe.As(ref dTopLeft) = xLeft; Unsafe.As(ref Unsafe.Add(ref dTopLeft, 1)) = yLeft; @@ -303,15 +303,15 @@ private static void WidenCopyImpl2x2_Vector4_SafeRightCorner(ref Block8x8F src, ref Vector2 dTopLeft = ref Unsafe.Add(ref destBase, (uint)(2 * row * destStride)); ref Vector2 dBottomLeft = ref Unsafe.Add(ref dTopLeft, (uint)destStride); - var xLeft = new Vector4(sLeft.X); - var yLeft = new Vector4(sLeft.Y); - var zLeft = new Vector4(sLeft.Z); - var wLeft = new Vector4(sLeft.W); + Vector4 xLeft = new(sLeft.X); + Vector4 yLeft = new(sLeft.Y); + Vector4 zLeft = new(sLeft.Z); + Vector4 wLeft = new(sLeft.W); - var xRight = new Vector4(sRight.X); - var yRight = new Vector4(sRight.Y); - var zRight = new Vector4(sRight.Z); - var wRight = new Vector2(sRight.W); + Vector4 xRight = new(sRight.X); + Vector4 yRight = new(sRight.Y); + Vector4 zRight = new(sRight.Z); + Vector2 wRight = new(sRight.W); Unsafe.As(ref dTopLeft) = xLeft; Unsafe.As(ref Unsafe.Add(ref dTopLeft, 1)) = yLeft; @@ -362,25 +362,25 @@ private static void WidenCopyImpl2x2_Vector4_V2(ref Block8x8F src, ref Vector2 d ref Vector4 dTopLeft = ref Unsafe.As(ref Unsafe.Add(ref destBase, (uint)offset)); ref Vector4 dBottomLeft = ref Unsafe.As(ref Unsafe.Add(ref destBase, (uint)(offset + destStride))); - var xyLeft = new Vector4(sLeft.X) + Vector4 xyLeft = new(sLeft.X) { Z = sLeft.Y, W = sLeft.Y }; - var zwLeft = new Vector4(sLeft.Z) + Vector4 zwLeft = new(sLeft.Z) { Z = sLeft.W, W = sLeft.W }; - var xyRight = new Vector4(sRight.X) + Vector4 xyRight = new(sRight.X) { Z = sRight.Y, W = sRight.Y }; - var zwRight = new Vector4(sRight.Z) + Vector4 zwRight = new(sRight.Z) { Z = sRight.W, W = sRight.W diff --git a/tests/ImageSharp.Benchmarks/Codecs/Jpeg/BlockOperations/Block8x8F_DivideRound.cs b/tests/ImageSharp.Benchmarks/Codecs/Jpeg/BlockOperations/Block8x8F_DivideRound.cs index efc347586c..45c6f63b9c 100644 --- a/tests/ImageSharp.Benchmarks/Codecs/Jpeg/BlockOperations/Block8x8F_DivideRound.cs +++ b/tests/ImageSharp.Benchmarks/Codecs/Jpeg/BlockOperations/Block8x8F_DivideRound.cs @@ -19,8 +19,8 @@ namespace SixLabors.ImageSharp.Benchmarks.Codecs.Jpeg.BlockOperations; public unsafe class Block8x8F_DivideRound { private const int ExecutionCount = 5; // Added this to reduce the effect of copying the blocks - private static readonly Vector4 MinusOne = new Vector4(-1); - private static readonly Vector4 Half = new Vector4(0.5f); + private static readonly Vector4 MinusOne = new(-1); + private static readonly Vector4 Half = new(0.5f); private Block8x8F inputDividend; private Block8x8F inputDivisor; @@ -140,7 +140,7 @@ private static void DivideRoundAll(ref Block8x8F a, ref Block8x8F b) [MethodImpl(MethodImplOptions.AggressiveInlining)] private static Vector4 DivideRound(Vector4 dividend, Vector4 divisor) { - var sign = Vector4.Min(dividend, Vector4.One); + Vector4 sign = Vector4.Min(dividend, Vector4.One); sign = Vector4.Max(sign, MinusOne); return (dividend / divisor) + (sign * Half); diff --git a/tests/ImageSharp.Benchmarks/Codecs/Jpeg/BlockOperations/Block8x8F_MultiplyInPlaceBlock.cs b/tests/ImageSharp.Benchmarks/Codecs/Jpeg/BlockOperations/Block8x8F_MultiplyInPlaceBlock.cs index 722b095870..3c03f3e056 100644 --- a/tests/ImageSharp.Benchmarks/Codecs/Jpeg/BlockOperations/Block8x8F_MultiplyInPlaceBlock.cs +++ b/tests/ImageSharp.Benchmarks/Codecs/Jpeg/BlockOperations/Block8x8F_MultiplyInPlaceBlock.cs @@ -20,7 +20,7 @@ public void MultiplyInPlaceBlock() private static Block8x8F Create8x8FloatData() { - var result = new float[64]; + float[] result = new float[64]; for (int i = 0; i < 8; i++) { for (int j = 0; j < 8; j++) diff --git a/tests/ImageSharp.Benchmarks/Codecs/Jpeg/BlockOperations/Block8x8F_Round.cs b/tests/ImageSharp.Benchmarks/Codecs/Jpeg/BlockOperations/Block8x8F_Round.cs index 8a520b22d3..51477e5a41 100644 --- a/tests/ImageSharp.Benchmarks/Codecs/Jpeg/BlockOperations/Block8x8F_Round.cs +++ b/tests/ImageSharp.Benchmarks/Codecs/Jpeg/BlockOperations/Block8x8F_Round.cs @@ -36,7 +36,7 @@ public void Setup() if (ptr % 16 != 0) { - throw new Exception("ptr is unaligned"); + throw new("ptr is unaligned"); } this.alignedPtr = (float*)ptr; diff --git a/tests/ImageSharp.Benchmarks/Codecs/Jpeg/ColorConversion/CmykColorConversion.cs b/tests/ImageSharp.Benchmarks/Codecs/Jpeg/ColorConversion/CmykColorConversion.cs index 9189bec376..d7a2a9aa61 100644 --- a/tests/ImageSharp.Benchmarks/Codecs/Jpeg/ColorConversion/CmykColorConversion.cs +++ b/tests/ImageSharp.Benchmarks/Codecs/Jpeg/ColorConversion/CmykColorConversion.cs @@ -17,7 +17,7 @@ public CmykColorConversion() [Benchmark(Baseline = true)] public void Scalar() { - var values = new JpegColorConverterBase.ComponentValues(this.Input, 0); + JpegColorConverterBase.ComponentValues values = new(this.Input, 0); new JpegColorConverterBase.CmykScalar(8).ConvertToRgbInplace(values); } @@ -25,7 +25,7 @@ public void Scalar() [Benchmark] public void SimdVector8() { - var values = new JpegColorConverterBase.ComponentValues(this.Input, 0); + JpegColorConverterBase.ComponentValues values = new(this.Input, 0); new JpegColorConverterBase.CmykVector(8).ConvertToRgbInplace(values); } @@ -33,7 +33,7 @@ public void SimdVector8() [Benchmark] public void SimdVectorAvx() { - var values = new JpegColorConverterBase.ComponentValues(this.Input, 0); + JpegColorConverterBase.ComponentValues values = new(this.Input, 0); new JpegColorConverterBase.CmykAvx(8).ConvertToRgbInplace(values); } @@ -41,7 +41,7 @@ public void SimdVectorAvx() [Benchmark] public void SimdVectorArm64() { - var values = new JpegColorConverterBase.ComponentValues(this.Input, 0); + JpegColorConverterBase.ComponentValues values = new(this.Input, 0); new JpegColorConverterBase.CmykArm64(8).ConvertToRgbInplace(values); } diff --git a/tests/ImageSharp.Benchmarks/Codecs/Jpeg/ColorConversion/ColorConversionBenchmark.cs b/tests/ImageSharp.Benchmarks/Codecs/Jpeg/ColorConversion/ColorConversionBenchmark.cs index 8964667b74..436aa9bcda 100644 --- a/tests/ImageSharp.Benchmarks/Codecs/Jpeg/ColorConversion/ColorConversionBenchmark.cs +++ b/tests/ImageSharp.Benchmarks/Codecs/Jpeg/ColorConversion/ColorConversionBenchmark.cs @@ -38,11 +38,11 @@ private static Buffer2D[] CreateRandomValues( float minVal = 0f, float maxVal = 255f) { - var rnd = new Random(42); - var buffers = new Buffer2D[componentCount]; + Random rnd = new(42); + Buffer2D[] buffers = new Buffer2D[componentCount]; for (int i = 0; i < componentCount; i++) { - var values = new float[inputBufferLength]; + float[] values = new float[inputBufferLength]; for (int j = 0; j < inputBufferLength; j++) { diff --git a/tests/ImageSharp.Benchmarks/Codecs/Jpeg/ColorConversion/GrayscaleColorConversion.cs b/tests/ImageSharp.Benchmarks/Codecs/Jpeg/ColorConversion/GrayscaleColorConversion.cs index a1d85ef466..b95537ad91 100644 --- a/tests/ImageSharp.Benchmarks/Codecs/Jpeg/ColorConversion/GrayscaleColorConversion.cs +++ b/tests/ImageSharp.Benchmarks/Codecs/Jpeg/ColorConversion/GrayscaleColorConversion.cs @@ -17,7 +17,7 @@ public GrayscaleColorConversion() [Benchmark(Baseline = true)] public void Scalar() { - var values = new JpegColorConverterBase.ComponentValues(this.Input, 0); + JpegColorConverterBase.ComponentValues values = new(this.Input, 0); new JpegColorConverterBase.GrayscaleScalar(8).ConvertToRgbInplace(values); } @@ -25,7 +25,7 @@ public void Scalar() [Benchmark] public void SimdVectorAvx() { - var values = new JpegColorConverterBase.ComponentValues(this.Input, 0); + JpegColorConverterBase.ComponentValues values = new(this.Input, 0); new JpegColorConverterBase.GrayscaleAvx(8).ConvertToRgbInplace(values); } @@ -33,7 +33,7 @@ public void SimdVectorAvx() [Benchmark] public void SimdVectorArm() { - var values = new JpegColorConverterBase.ComponentValues(this.Input, 0); + JpegColorConverterBase.ComponentValues values = new(this.Input, 0); new JpegColorConverterBase.GrayscaleArm(8).ConvertToRgbInplace(values); } diff --git a/tests/ImageSharp.Benchmarks/Codecs/Jpeg/ColorConversion/RgbColorConversion.cs b/tests/ImageSharp.Benchmarks/Codecs/Jpeg/ColorConversion/RgbColorConversion.cs index 5e2b6fe860..077b6c34ce 100644 --- a/tests/ImageSharp.Benchmarks/Codecs/Jpeg/ColorConversion/RgbColorConversion.cs +++ b/tests/ImageSharp.Benchmarks/Codecs/Jpeg/ColorConversion/RgbColorConversion.cs @@ -17,7 +17,7 @@ public RgbColorConversion() [Benchmark(Baseline = true)] public void Scalar() { - var values = new JpegColorConverterBase.ComponentValues(this.Input, 0); + JpegColorConverterBase.ComponentValues values = new(this.Input, 0); new JpegColorConverterBase.RgbScalar(8).ConvertToRgbInplace(values); } @@ -25,7 +25,7 @@ public void Scalar() [Benchmark] public void SimdVector8() { - var values = new JpegColorConverterBase.ComponentValues(this.Input, 0); + JpegColorConverterBase.ComponentValues values = new(this.Input, 0); new JpegColorConverterBase.RgbVector(8).ConvertToRgbInplace(values); } @@ -33,7 +33,7 @@ public void SimdVector8() [Benchmark] public void SimdVectorAvx() { - var values = new JpegColorConverterBase.ComponentValues(this.Input, 0); + JpegColorConverterBase.ComponentValues values = new(this.Input, 0); new JpegColorConverterBase.RgbAvx(8).ConvertToRgbInplace(values); } @@ -41,7 +41,7 @@ public void SimdVectorAvx() [Benchmark] public void SimdVectorArm() { - var values = new JpegColorConverterBase.ComponentValues(this.Input, 0); + JpegColorConverterBase.ComponentValues values = new(this.Input, 0); new JpegColorConverterBase.RgbArm(8).ConvertToRgbInplace(values); } diff --git a/tests/ImageSharp.Benchmarks/Codecs/Jpeg/ColorConversion/YCbCrColorConversion.cs b/tests/ImageSharp.Benchmarks/Codecs/Jpeg/ColorConversion/YCbCrColorConversion.cs index f8621c2500..fed06acc76 100644 --- a/tests/ImageSharp.Benchmarks/Codecs/Jpeg/ColorConversion/YCbCrColorConversion.cs +++ b/tests/ImageSharp.Benchmarks/Codecs/Jpeg/ColorConversion/YCbCrColorConversion.cs @@ -17,7 +17,7 @@ public YCbCrColorConversion() [Benchmark] public void Scalar() { - var values = new JpegColorConverterBase.ComponentValues(this.Input, 0); + JpegColorConverterBase.ComponentValues values = new(this.Input, 0); new JpegColorConverterBase.YCbCrScalar(8).ConvertToRgbInplace(values); } @@ -25,7 +25,7 @@ public void Scalar() [Benchmark] public void SimdVector8() { - var values = new JpegColorConverterBase.ComponentValues(this.Input, 0); + JpegColorConverterBase.ComponentValues values = new(this.Input, 0); new JpegColorConverterBase.YCbCrVector(8).ConvertToRgbInplace(values); } @@ -33,7 +33,7 @@ public void SimdVector8() [Benchmark] public void SimdVectorAvx() { - var values = new JpegColorConverterBase.ComponentValues(this.Input, 0); + JpegColorConverterBase.ComponentValues values = new(this.Input, 0); new JpegColorConverterBase.YCbCrAvx(8).ConvertToRgbInplace(values); } @@ -41,7 +41,7 @@ public void SimdVectorAvx() [Benchmark] public void SimdVectorArm() { - var values = new JpegColorConverterBase.ComponentValues(this.Input, 0); + JpegColorConverterBase.ComponentValues values = new(this.Input, 0); new JpegColorConverterBase.YCbCrArm(8).ConvertToRgbInplace(values); } diff --git a/tests/ImageSharp.Benchmarks/Codecs/Jpeg/ColorConversion/YccKColorConverter.cs b/tests/ImageSharp.Benchmarks/Codecs/Jpeg/ColorConversion/YccKColorConverter.cs index a414b6ed47..6744aea29e 100644 --- a/tests/ImageSharp.Benchmarks/Codecs/Jpeg/ColorConversion/YccKColorConverter.cs +++ b/tests/ImageSharp.Benchmarks/Codecs/Jpeg/ColorConversion/YccKColorConverter.cs @@ -17,7 +17,7 @@ public YccKColorConverter() [Benchmark(Baseline = true)] public void Scalar() { - var values = new JpegColorConverterBase.ComponentValues(this.Input, 0); + JpegColorConverterBase.ComponentValues values = new(this.Input, 0); new JpegColorConverterBase.YccKScalar(8).ConvertToRgbInplace(values); } @@ -25,7 +25,7 @@ public void Scalar() [Benchmark] public void SimdVector8() { - var values = new JpegColorConverterBase.ComponentValues(this.Input, 0); + JpegColorConverterBase.ComponentValues values = new(this.Input, 0); new JpegColorConverterBase.YccKVector(8).ConvertToRgbInplace(values); } @@ -33,7 +33,7 @@ public void SimdVector8() [Benchmark] public void SimdVectorAvx2() { - var values = new JpegColorConverterBase.ComponentValues(this.Input, 0); + JpegColorConverterBase.ComponentValues values = new(this.Input, 0); new JpegColorConverterBase.YccKAvx(8).ConvertToRgbInplace(values); } @@ -41,7 +41,7 @@ public void SimdVectorAvx2() [Benchmark] public void SimdVectorArm64() { - var values = new JpegColorConverterBase.ComponentValues(this.Input, 0); + JpegColorConverterBase.ComponentValues values = new(this.Input, 0); new JpegColorConverterBase.YccKArm64(8).ConvertToRgbInplace(values); } diff --git a/tests/ImageSharp.Benchmarks/Codecs/Jpeg/DecodeJpeg.cs b/tests/ImageSharp.Benchmarks/Codecs/Jpeg/DecodeJpeg.cs index 0dc6d26bc7..95879083f9 100644 --- a/tests/ImageSharp.Benchmarks/Codecs/Jpeg/DecodeJpeg.cs +++ b/tests/ImageSharp.Benchmarks/Codecs/Jpeg/DecodeJpeg.cs @@ -18,7 +18,7 @@ private void GenericSetup(string imageSubpath) { this.decoder = JpegDecoder.Instance; byte[] bytes = File.ReadAllBytes(Path.Combine(TestEnvironment.InputImagesDirectoryFullPath, imageSubpath)); - this.preloadedImageStream = new MemoryStream(bytes); + this.preloadedImageStream = new(bytes); } private void GenericBechmark() diff --git a/tests/ImageSharp.Benchmarks/Codecs/Jpeg/DecodeJpegParseStreamOnly.cs b/tests/ImageSharp.Benchmarks/Codecs/Jpeg/DecodeJpegParseStreamOnly.cs index f5178390f6..952f8d822d 100644 --- a/tests/ImageSharp.Benchmarks/Codecs/Jpeg/DecodeJpegParseStreamOnly.cs +++ b/tests/ImageSharp.Benchmarks/Codecs/Jpeg/DecodeJpegParseStreamOnly.cs @@ -27,20 +27,20 @@ public void Setup() [Benchmark(Baseline = true, Description = "System.Drawing FULL")] public SDSize JpegSystemDrawing() { - using var memoryStream = new MemoryStream(this.jpegBytes); - using var image = System.Drawing.Image.FromStream(memoryStream); + using MemoryStream memoryStream = new(this.jpegBytes); + using System.Drawing.Image image = System.Drawing.Image.FromStream(memoryStream); return image.Size; } [Benchmark(Description = "JpegDecoderCore.ParseStream")] public void ParseStream() { - using var memoryStream = new MemoryStream(this.jpegBytes); - using var bufferedStream = new BufferedReadStream(Configuration.Default, memoryStream); - var options = new JpegDecoderOptions() { GeneralOptions = new() { SkipMetadata = true } }; + using MemoryStream memoryStream = new(this.jpegBytes); + using BufferedReadStream bufferedStream = new(Configuration.Default, memoryStream); + JpegDecoderOptions options = new() { GeneralOptions = new() { SkipMetadata = true } }; - using var decoder = new JpegDecoderCore(options); - var spectralConverter = new NoopSpectralConverter(); + using JpegDecoderCore decoder = new(options); + NoopSpectralConverter spectralConverter = new(); decoder.ParseStream(bufferedStream, spectralConverter, cancellationToken: default); } diff --git a/tests/ImageSharp.Benchmarks/Codecs/Jpeg/DecodeJpeg_Aggregate.cs b/tests/ImageSharp.Benchmarks/Codecs/Jpeg/DecodeJpeg_Aggregate.cs index 389fec88be..9141c9d2e9 100644 --- a/tests/ImageSharp.Benchmarks/Codecs/Jpeg/DecodeJpeg_Aggregate.cs +++ b/tests/ImageSharp.Benchmarks/Codecs/Jpeg/DecodeJpeg_Aggregate.cs @@ -17,14 +17,14 @@ namespace SixLabors.ImageSharp.Benchmarks.Codecs.Jpeg; public class DecodeJpeg_Aggregate : MultiImageBenchmarkBase { protected override IEnumerable InputImageSubfoldersOrFiles - => new[] - { + => + [ TestImages.Jpeg.BenchmarkSuite.Jpeg400_SmallMonochrome, TestImages.Jpeg.BenchmarkSuite.Jpeg420Exif_MidSizeYCbCr, TestImages.Jpeg.BenchmarkSuite.Lake_Small444YCbCr, TestImages.Jpeg.BenchmarkSuite.MissingFF00ProgressiveBedroom159_MidSize420YCbCr, - TestImages.Jpeg.BenchmarkSuite.ExifGetString750Transform_Huge420YCbCr, - }; + TestImages.Jpeg.BenchmarkSuite.ExifGetString750Transform_Huge420YCbCr + ]; [Params(InputImageCategory.AllImages)] public override InputImageCategory InputCategory { get; set; } diff --git a/tests/ImageSharp.Benchmarks/Codecs/Jpeg/DecodeJpeg_ImageSpecific.cs b/tests/ImageSharp.Benchmarks/Codecs/Jpeg/DecodeJpeg_ImageSpecific.cs index 08df2580db..355aa348e2 100644 --- a/tests/ImageSharp.Benchmarks/Codecs/Jpeg/DecodeJpeg_ImageSpecific.cs +++ b/tests/ImageSharp.Benchmarks/Codecs/Jpeg/DecodeJpeg_ImageSpecific.cs @@ -45,17 +45,17 @@ public void ReadImages() [Benchmark(Baseline = true)] public SDSize SystemDrawing() { - using var memoryStream = new MemoryStream(this.jpegBytes); - using var image = SDImage.FromStream(memoryStream); + using MemoryStream memoryStream = new(this.jpegBytes); + using SDImage image = SDImage.FromStream(memoryStream); return image.Size; } [Benchmark] public Size ImageSharp() { - using var memoryStream = new MemoryStream(this.jpegBytes); - using var image = Image.Load(new DecoderOptions() { SkipMetadata = true }, memoryStream); - return new Size(image.Width, image.Height); + using MemoryStream memoryStream = new(this.jpegBytes); + using Image image = Image.Load(new() { SkipMetadata = true }, memoryStream); + return new(image.Width, image.Height); } /* diff --git a/tests/ImageSharp.Benchmarks/Codecs/Jpeg/EncodeJpegComparison.cs b/tests/ImageSharp.Benchmarks/Codecs/Jpeg/EncodeJpegComparison.cs index deb3125b30..d5e1534437 100644 --- a/tests/ImageSharp.Benchmarks/Codecs/Jpeg/EncodeJpegComparison.cs +++ b/tests/ImageSharp.Benchmarks/Codecs/Jpeg/EncodeJpegComparison.cs @@ -39,9 +39,9 @@ public void SetupImageSharp() using FileStream imageBinaryStream = File.OpenRead(Path.Combine(TestEnvironment.InputImagesDirectoryFullPath, TestImage)); this.imageImageSharp = Image.Load(imageBinaryStream); - this.encoderImageSharp = new JpegEncoder { Quality = this.Quality, ColorType = JpegColorType.YCbCrRatio420 }; + this.encoderImageSharp = new() { Quality = this.Quality, ColorType = JpegColorType.YCbCrRatio420 }; - this.destinationStream = new MemoryStream(); + this.destinationStream = new(); } [GlobalCleanup(Target = nameof(BenchmarkImageSharp))] @@ -68,7 +68,7 @@ public void SetupSkiaSharp() this.imageSkiaSharp = SKBitmap.Decode(imageBinaryStream); - this.destinationStream = new MemoryStream(); + this.destinationStream = new(); } [GlobalCleanup(Target = nameof(BenchmarkSkiaSharp))] diff --git a/tests/ImageSharp.Benchmarks/Codecs/Jpeg/EncodeJpegFeatures.cs b/tests/ImageSharp.Benchmarks/Codecs/Jpeg/EncodeJpegFeatures.cs index 0692c5a3b5..afdc123aa8 100644 --- a/tests/ImageSharp.Benchmarks/Codecs/Jpeg/EncodeJpegFeatures.cs +++ b/tests/ImageSharp.Benchmarks/Codecs/Jpeg/EncodeJpegFeatures.cs @@ -20,13 +20,13 @@ public class EncodeJpegFeatures // No metadata private const string TestImage = TestImages.Jpeg.Baseline.Calliphora; - public static IEnumerable ColorSpaceValues => new[] - { + public static IEnumerable ColorSpaceValues => + [ JpegColorType.Luminance, JpegColorType.Rgb, JpegColorType.YCbCrRatio420, - JpegColorType.YCbCrRatio444, - }; + JpegColorType.YCbCrRatio444 + ]; [Params(75, 90, 100)] public int Quality; @@ -44,13 +44,13 @@ public void Setup() { using FileStream imageBinaryStream = File.OpenRead(Path.Combine(TestEnvironment.InputImagesDirectoryFullPath, TestImage)); this.bmpCore = Image.Load(imageBinaryStream); - this.encoder = new JpegEncoder + this.encoder = new() { Quality = this.Quality, ColorType = this.TargetColorSpace, Interleaved = true, }; - this.destinationStream = new MemoryStream(); + this.destinationStream = new(); } [GlobalCleanup] diff --git a/tests/ImageSharp.Benchmarks/Codecs/MultiImageBenchmarkBase.cs b/tests/ImageSharp.Benchmarks/Codecs/MultiImageBenchmarkBase.cs index b75d012f97..0a1a2295f2 100644 --- a/tests/ImageSharp.Benchmarks/Codecs/MultiImageBenchmarkBase.cs +++ b/tests/ImageSharp.Benchmarks/Codecs/MultiImageBenchmarkBase.cs @@ -11,11 +11,11 @@ namespace SixLabors.ImageSharp.Benchmarks.Codecs; public abstract class MultiImageBenchmarkBase { - protected Dictionary FileNamesToBytes { get; set; } = new Dictionary(); + protected Dictionary FileNamesToBytes { get; set; } = new(); - protected Dictionary> FileNamesToImageSharpImages { get; set; } = new Dictionary>(); + protected Dictionary> FileNamesToImageSharpImages { get; set; } = new(); - protected Dictionary FileNamesToSystemDrawingImages { get; set; } = new Dictionary(); + protected Dictionary FileNamesToSystemDrawingImages { get; set; } = new(); /// /// The values of this enum separate input files into categories. @@ -43,12 +43,12 @@ public enum InputImageCategory protected virtual string BaseFolder => TestEnvironment.InputImagesDirectoryFullPath; - protected virtual IEnumerable SearchPatterns => new[] { "*.*" }; + protected virtual IEnumerable SearchPatterns => ["*.*"]; /// /// Gets the file names containing these strings are substrings are not processed by the benchmark. /// - protected virtual IEnumerable ExcludeSubstringsInFileNames => new[] { "badeof", "BadEof", "CriticalEOF" }; + protected virtual IEnumerable ExcludeSubstringsInFileNames => ["badeof", "BadEof", "CriticalEOF"]; /// /// Gets folders containing files OR files to be processed by the benchmark. @@ -86,7 +86,7 @@ public virtual void Setup() { if (!Vector.IsHardwareAccelerated) { - throw new Exception("Vector.IsHardwareAccelerated == false! Check your build settings!"); + throw new("Vector.IsHardwareAccelerated == false! Check your build settings!"); } // Console.WriteLine("Vector.IsHardwareAccelerated: " + Vector.IsHardwareAccelerated); @@ -126,7 +126,7 @@ protected void ForEachStream(Func operation) { foreach (KeyValuePair kv in this.FileNames2Bytes) { - using var memoryStream = new MemoryStream(kv.Value); + using MemoryStream memoryStream = new(kv.Value); try { object obj = operation(memoryStream); @@ -150,12 +150,12 @@ protected override void ReadFilesImpl() byte[] bytes = kv.Value; string fn = kv.Key; - using (var ms1 = new MemoryStream(bytes)) + using (MemoryStream ms1 = new(bytes)) { this.FileNamesToImageSharpImages[fn] = Image.Load(ms1); } - this.FileNamesToSystemDrawingImages[fn] = new Bitmap(new MemoryStream(bytes)); + this.FileNamesToSystemDrawingImages[fn] = new(new MemoryStream(bytes)); } } @@ -191,7 +191,7 @@ protected void ForEachImageSharpImage(Func, object> operation) protected void ForEachImageSharpImage(Func, MemoryStream, object> operation) { - using var workStream = new MemoryStream(); + using MemoryStream workStream = new(); this.ForEachImageSharpImage( img => { @@ -222,7 +222,7 @@ protected void ForEachSystemDrawingImage(Func operation) protected void ForEachSystemDrawingImage(Func operation) { - using var workStream = new MemoryStream(); + using MemoryStream workStream = new(); this.ForEachSystemDrawingImage( img => { diff --git a/tests/ImageSharp.Benchmarks/Codecs/Png/EncodeIndexedPng.cs b/tests/ImageSharp.Benchmarks/Codecs/Png/EncodeIndexedPng.cs index a45e7aea9b..ff6c45f08a 100644 --- a/tests/ImageSharp.Benchmarks/Codecs/Png/EncodeIndexedPng.cs +++ b/tests/ImageSharp.Benchmarks/Codecs/Png/EncodeIndexedPng.cs @@ -43,48 +43,48 @@ public void Cleanup() [Benchmark(Baseline = true, Description = "ImageSharp Octree Png")] public void PngCoreOctree() { - using var memoryStream = new MemoryStream(); - var options = new PngEncoder { Quantizer = KnownQuantizers.Octree }; + using MemoryStream memoryStream = new(); + PngEncoder options = new() { Quantizer = KnownQuantizers.Octree }; this.bmpCore.SaveAsPng(memoryStream, options); } [Benchmark(Description = "ImageSharp Octree NoDither Png")] public void PngCoreOctreeNoDither() { - using var memoryStream = new MemoryStream(); - var options = new PngEncoder { Quantizer = new OctreeQuantizer(new QuantizerOptions { Dither = null }) }; + using MemoryStream memoryStream = new(); + PngEncoder options = new() { Quantizer = new OctreeQuantizer(new() { Dither = null }) }; this.bmpCore.SaveAsPng(memoryStream, options); } [Benchmark(Description = "ImageSharp Palette Png")] public void PngCorePalette() { - using var memoryStream = new MemoryStream(); - var options = new PngEncoder { Quantizer = KnownQuantizers.WebSafe }; + using MemoryStream memoryStream = new(); + PngEncoder options = new() { Quantizer = KnownQuantizers.WebSafe }; this.bmpCore.SaveAsPng(memoryStream, options); } [Benchmark(Description = "ImageSharp Palette NoDither Png")] public void PngCorePaletteNoDither() { - using var memoryStream = new MemoryStream(); - var options = new PngEncoder { Quantizer = new WebSafePaletteQuantizer(new QuantizerOptions { Dither = null }) }; + using MemoryStream memoryStream = new(); + PngEncoder options = new() { Quantizer = new WebSafePaletteQuantizer(new() { Dither = null }) }; this.bmpCore.SaveAsPng(memoryStream, options); } [Benchmark(Description = "ImageSharp Wu Png")] public void PngCoreWu() { - using var memoryStream = new MemoryStream(); - var options = new PngEncoder { Quantizer = KnownQuantizers.Wu }; + using MemoryStream memoryStream = new(); + PngEncoder options = new() { Quantizer = KnownQuantizers.Wu }; this.bmpCore.SaveAsPng(memoryStream, options); } [Benchmark(Description = "ImageSharp Wu NoDither Png")] public void PngCoreWuNoDither() { - using var memoryStream = new MemoryStream(); - var options = new PngEncoder { Quantizer = new WuQuantizer(new QuantizerOptions { Dither = null }), ColorType = PngColorType.Palette }; + using MemoryStream memoryStream = new(); + PngEncoder options = new() { Quantizer = new WuQuantizer(new() { Dither = null }), ColorType = PngColorType.Palette }; this.bmpCore.SaveAsPng(memoryStream, options); } } diff --git a/tests/ImageSharp.Benchmarks/Codecs/Png/EncodePng.cs b/tests/ImageSharp.Benchmarks/Codecs/Png/EncodePng.cs index 4287914783..881ccddd0f 100644 --- a/tests/ImageSharp.Benchmarks/Codecs/Png/EncodePng.cs +++ b/tests/ImageSharp.Benchmarks/Codecs/Png/EncodePng.cs @@ -46,15 +46,15 @@ public void Cleanup() [Benchmark(Baseline = true, Description = "System.Drawing Png")] public void PngSystemDrawing() { - using var memoryStream = new MemoryStream(); + using MemoryStream memoryStream = new(); this.bmpDrawing.Save(memoryStream, ImageFormat.Png); } [Benchmark(Description = "ImageSharp Png")] public void PngCore() { - using var memoryStream = new MemoryStream(); - var encoder = new PngEncoder { FilterMethod = PngFilterMethod.None }; + using MemoryStream memoryStream = new(); + PngEncoder encoder = new() { FilterMethod = PngFilterMethod.None }; this.bmpCore.SaveAsPng(memoryStream, encoder); } } diff --git a/tests/ImageSharp.Benchmarks/Codecs/Tga/DecodeTga.cs b/tests/ImageSharp.Benchmarks/Codecs/Tga/DecodeTga.cs index 2ebab5e001..c7afb2858b 100644 --- a/tests/ImageSharp.Benchmarks/Codecs/Tga/DecodeTga.cs +++ b/tests/ImageSharp.Benchmarks/Codecs/Tga/DecodeTga.cs @@ -29,22 +29,22 @@ public void SetupData() [Benchmark(Baseline = true, Description = "ImageMagick Tga")] public int TgaImageMagick() { - var settings = new MagickReadSettings { Format = MagickFormat.Tga }; - using var image = new MagickImage(new MemoryStream(this.data), settings); + MagickReadSettings settings = new() { Format = MagickFormat.Tga }; + using MagickImage image = new(new MemoryStream(this.data), settings); return image.Width; } [Benchmark(Description = "ImageSharp Tga")] public int TgaImageSharp() { - using var image = Image.Load(this.data); + using Image image = Image.Load(this.data); return image.Width; } [Benchmark(Description = "Pfim Tga")] public int TgaPfim() { - using var image = Targa.Create(this.data, this.pfimConfig); + using Targa image = Targa.Create(this.data, this.pfimConfig); return image.Width; } diff --git a/tests/ImageSharp.Benchmarks/Codecs/Tga/EncodeTga.cs b/tests/ImageSharp.Benchmarks/Codecs/Tga/EncodeTga.cs index a7f5e35893..c9ab74eda6 100644 --- a/tests/ImageSharp.Benchmarks/Codecs/Tga/EncodeTga.cs +++ b/tests/ImageSharp.Benchmarks/Codecs/Tga/EncodeTga.cs @@ -26,7 +26,7 @@ public void ReadImages() if (this.tga == null) { this.tga = Image.Load(this.TestImageFullPath); - this.tgaMagick = new MagickImage(this.TestImageFullPath); + this.tgaMagick = new(this.TestImageFullPath); } } @@ -41,14 +41,14 @@ public void Cleanup() [Benchmark(Baseline = true, Description = "Magick Tga")] public void MagickTga() { - using var memoryStream = new MemoryStream(); + using MemoryStream memoryStream = new(); this.tgaMagick.Write(memoryStream, MagickFormat.Tga); } [Benchmark(Description = "ImageSharp Tga")] public void ImageSharpTga() { - using var memoryStream = new MemoryStream(); + using MemoryStream memoryStream = new(); this.tga.SaveAsTga(memoryStream); } } diff --git a/tests/ImageSharp.Benchmarks/Codecs/Tiff/EncodeTiff.cs b/tests/ImageSharp.Benchmarks/Codecs/Tiff/EncodeTiff.cs index d3e3944051..9a195a9b4b 100644 --- a/tests/ImageSharp.Benchmarks/Codecs/Tiff/EncodeTiff.cs +++ b/tests/ImageSharp.Benchmarks/Codecs/Tiff/EncodeTiff.cs @@ -60,12 +60,12 @@ public void Cleanup() public void SystemDrawing() { ImageCodecInfo codec = FindCodecForType("image/tiff"); - using var parameters = new EncoderParameters(1) + using EncoderParameters parameters = new(1) { - Param = { [0] = new EncoderParameter(Encoder.Compression, (long)Cast(this.Compression)) } + Param = { [0] = new(Encoder.Compression, (long)Cast(this.Compression)) } }; - using var memoryStream = new MemoryStream(); + using MemoryStream memoryStream = new(); this.drawing.Save(memoryStream, codec, parameters); } @@ -77,8 +77,8 @@ public void TiffCore() TiffPhotometricInterpretation.WhiteIsZero : TiffPhotometricInterpretation.Rgb; - var encoder = new TiffEncoder() { Compression = this.Compression, PhotometricInterpretation = photometricInterpretation }; - using var memoryStream = new MemoryStream(); + TiffEncoder encoder = new() { Compression = this.Compression, PhotometricInterpretation = photometricInterpretation }; + using MemoryStream memoryStream = new(); this.core.SaveAsTiff(memoryStream, encoder); } diff --git a/tests/ImageSharp.Benchmarks/Codecs/Webp/DecodeWebp.cs b/tests/ImageSharp.Benchmarks/Codecs/Webp/DecodeWebp.cs index 6c71a62b50..ee287543b7 100644 --- a/tests/ImageSharp.Benchmarks/Codecs/Webp/DecodeWebp.cs +++ b/tests/ImageSharp.Benchmarks/Codecs/Webp/DecodeWebp.cs @@ -44,34 +44,34 @@ public void ReadImages() [Benchmark(Description = "Magick Lossy Webp")] public int WebpLossyMagick() { - var settings = new MagickReadSettings { Format = MagickFormat.WebP }; - using var memoryStream = new MemoryStream(this.webpLossyBytes); - using var image = new MagickImage(memoryStream, settings); + MagickReadSettings settings = new() { Format = MagickFormat.WebP }; + using MemoryStream memoryStream = new(this.webpLossyBytes); + using MagickImage image = new(memoryStream, settings); return image.Width; } [Benchmark(Description = "ImageSharp Lossy Webp")] public int WebpLossy() { - using var memoryStream = new MemoryStream(this.webpLossyBytes); - using var image = Image.Load(memoryStream); + using MemoryStream memoryStream = new(this.webpLossyBytes); + using Image image = Image.Load(memoryStream); return image.Height; } [Benchmark(Description = "Magick Lossless Webp")] public int WebpLosslessMagick() { - var settings = new MagickReadSettings { Format = MagickFormat.WebP }; - using var memoryStream = new MemoryStream(this.webpLossyBytes); - using var image = new MagickImage(memoryStream, settings); + MagickReadSettings settings = new() { Format = MagickFormat.WebP }; + using MemoryStream memoryStream = new(this.webpLossyBytes); + using MagickImage image = new(memoryStream, settings); return image.Width; } [Benchmark(Description = "ImageSharp Lossless Webp")] public int WebpLossless() { - using var memoryStream = new MemoryStream(this.webpLosslessBytes); - using var image = Image.Load(memoryStream); + using MemoryStream memoryStream = new(this.webpLosslessBytes); + using Image image = Image.Load(memoryStream); return image.Height; } diff --git a/tests/ImageSharp.Benchmarks/Codecs/Webp/EncodeWebp.cs b/tests/ImageSharp.Benchmarks/Codecs/Webp/EncodeWebp.cs index 5be46a2220..74077e435b 100644 --- a/tests/ImageSharp.Benchmarks/Codecs/Webp/EncodeWebp.cs +++ b/tests/ImageSharp.Benchmarks/Codecs/Webp/EncodeWebp.cs @@ -29,7 +29,7 @@ public void ReadImages() if (this.webp == null) { this.webp = Image.Load(this.TestImageFullPath); - this.webpMagick = new MagickImage(this.TestImageFullPath); + this.webpMagick = new(this.TestImageFullPath); } } diff --git a/tests/ImageSharp.Benchmarks/Color/ColorEquality.cs b/tests/ImageSharp.Benchmarks/Color/ColorEquality.cs index 5166c89a93..38715e6ca0 100644 --- a/tests/ImageSharp.Benchmarks/Color/ColorEquality.cs +++ b/tests/ImageSharp.Benchmarks/Color/ColorEquality.cs @@ -15,5 +15,5 @@ public bool SystemDrawingColorEqual() [Benchmark(Description = "ImageSharp Color Equals")] public bool ColorEqual() - => new Rgba32(128, 128, 128, 128).Equals(new Rgba32(128, 128, 128, 128)); + => new Rgba32(128, 128, 128, 128).Equals(new(128, 128, 128, 128)); } diff --git a/tests/ImageSharp.Benchmarks/Color/RgbWorkingSpaceAdapt.cs b/tests/ImageSharp.Benchmarks/Color/RgbWorkingSpaceAdapt.cs index 6cd8df3fc7..270749a371 100644 --- a/tests/ImageSharp.Benchmarks/Color/RgbWorkingSpaceAdapt.cs +++ b/tests/ImageSharp.Benchmarks/Color/RgbWorkingSpaceAdapt.cs @@ -13,7 +13,7 @@ public class RgbWorkingSpaceAdapt private static readonly RGBColor RGBColor = new(0.206162, 0.260277, 0.746717); - private static readonly ColorProfileConverter ColorProfileConverter = new(new ColorConversionOptions { RgbWorkingSpace = KnownRgbWorkingSpaces.WideGamutRgb, TargetRgbWorkingSpace = KnownRgbWorkingSpaces.SRgb }); + private static readonly ColorProfileConverter ColorProfileConverter = new(new() { RgbWorkingSpace = KnownRgbWorkingSpaces.WideGamutRgb, TargetRgbWorkingSpace = KnownRgbWorkingSpaces.SRgb }); private static readonly IColorConverter ColourfulConverter = new ConverterBuilder().FromRGB(RGBWorkingSpaces.WideGamutRGB).ToRGB(RGBWorkingSpaces.sRGB).Build(); diff --git a/tests/ImageSharp.Benchmarks/Color/YcbCrToRgb.cs b/tests/ImageSharp.Benchmarks/Color/YcbCrToRgb.cs index 093397ad5f..37db166aee 100644 --- a/tests/ImageSharp.Benchmarks/Color/YcbCrToRgb.cs +++ b/tests/ImageSharp.Benchmarks/Color/YcbCrToRgb.cs @@ -22,7 +22,7 @@ public Vector3 YcbCrToRgba() byte g = (byte)Numerics.Clamp(y - (0.34414F * ccb) - (0.71414F * ccr), 0, 255); byte b = (byte)Numerics.Clamp(y + (1.772F * ccb), 0, 255); - return new Vector3(r, g, b); + return new(r, g, b); } [Benchmark(Description = "Scaled Integer Conversion")] @@ -45,6 +45,6 @@ public Vector3 YcbCrToRgbaScaled() byte g = (byte)Numerics.Clamp(y - (g0 >> 10) - (g1 >> 10), 0, 255); byte b = (byte)Numerics.Clamp(y + (b0 >> 10), 0, 255); - return new Vector3(r, g, b); + return new(r, g, b); } } diff --git a/tests/ImageSharp.Benchmarks/Config.cs b/tests/ImageSharp.Benchmarks/Config.cs index 06e857484d..2428859637 100644 --- a/tests/ImageSharp.Benchmarks/Config.cs +++ b/tests/ImageSharp.Benchmarks/Config.cs @@ -32,7 +32,8 @@ public Config() public class Standard : Config { public Standard() => this.AddJob( - Job.Default.WithRuntime(CoreRuntime.Core80).WithArguments(new Argument[] { new MsBuildArgument("/p:DebugType=portable") })); + Job.Default.WithRuntime(CoreRuntime.Core80).WithArguments([new MsBuildArgument("/p:DebugType=portable") + ])); } public class Short : Config @@ -42,7 +43,7 @@ public Short() => this.AddJob( .WithLaunchCount(1) .WithWarmupCount(3) .WithIterationCount(3) - .WithArguments(new Argument[] { new MsBuildArgument("/p:DebugType=portable") })); + .WithArguments([new MsBuildArgument("/p:DebugType=portable")])); } #if OS_WINDOWS diff --git a/tests/ImageSharp.Benchmarks/General/Adler32Benchmark.cs b/tests/ImageSharp.Benchmarks/General/Adler32Benchmark.cs index 30023feca8..64a8092c63 100644 --- a/tests/ImageSharp.Benchmarks/General/Adler32Benchmark.cs +++ b/tests/ImageSharp.Benchmarks/General/Adler32Benchmark.cs @@ -11,7 +11,7 @@ namespace SixLabors.ImageSharp.Benchmarks.General; public class Adler32Benchmark { private byte[] data; - private readonly SharpAdler32 adler = new SharpAdler32(); + private readonly SharpAdler32 adler = new(); [Params(1024, 2048, 4096)] public int Count { get; set; } diff --git a/tests/ImageSharp.Benchmarks/General/Array2D.cs b/tests/ImageSharp.Benchmarks/General/Array2D.cs index f0a36ee1d6..2d244607b1 100644 --- a/tests/ImageSharp.Benchmarks/General/Array2D.cs +++ b/tests/ImageSharp.Benchmarks/General/Array2D.cs @@ -44,7 +44,7 @@ public void SetUp() this.jaggedData[i] = new float[this.Count]; } - this.matrix = new DenseMatrix(this.array2D); + this.matrix = new(this.array2D); this.Min = (this.Count / 2) - 10; this.Min = Math.Max(0, this.Min); diff --git a/tests/ImageSharp.Benchmarks/General/BasicMath/ClampFloat.cs b/tests/ImageSharp.Benchmarks/General/BasicMath/ClampFloat.cs index dd0bc28785..317295144f 100644 --- a/tests/ImageSharp.Benchmarks/General/BasicMath/ClampFloat.cs +++ b/tests/ImageSharp.Benchmarks/General/BasicMath/ClampFloat.cs @@ -10,7 +10,7 @@ public class ClampFloat { private readonly float min = -1.5f; private readonly float max = 2.5f; - private static readonly float[] Values = { -10, -5, -3, -1.5f, -0.5f, 0f, 1f, 1.5f, 2.5f, 3, 10 }; + private static readonly float[] Values = [-10, -5, -3, -1.5f, -0.5f, 0f, 1f, 1.5f, 2.5f, 3, 10]; [Benchmark(Baseline = true)] public float UsingMathF() diff --git a/tests/ImageSharp.Benchmarks/General/BasicMath/ClampSpan.cs b/tests/ImageSharp.Benchmarks/General/BasicMath/ClampSpan.cs index d47fcb687e..b61ba27ffb 100644 --- a/tests/ImageSharp.Benchmarks/General/BasicMath/ClampSpan.cs +++ b/tests/ImageSharp.Benchmarks/General/BasicMath/ClampSpan.cs @@ -12,7 +12,7 @@ public class ClampSpan public void Setup() { - var r = new Random(); + Random r = new(); for (int i = 0; i < A.Length; i++) { diff --git a/tests/ImageSharp.Benchmarks/General/BasicMath/ClampVector4.cs b/tests/ImageSharp.Benchmarks/General/BasicMath/ClampVector4.cs index 186f88bb71..07e31bab94 100644 --- a/tests/ImageSharp.Benchmarks/General/BasicMath/ClampVector4.cs +++ b/tests/ImageSharp.Benchmarks/General/BasicMath/ClampVector4.cs @@ -11,7 +11,7 @@ public class ClampVector4 { private readonly float min = -1.5f; private readonly float max = 2.5f; - private static readonly float[] Values = { -10, -5, -3, -1.5f, -0.5f, 0f, 1f, 1.5f, 2.5f, 3, 10 }; + private static readonly float[] Values = [-10, -5, -3, -1.5f, -0.5f, 0f, 1f, 1.5f, 2.5f, 3, 10]; [Benchmark(Baseline = true)] public Vector4 UsingVectorClamp() @@ -42,13 +42,13 @@ public Vector4 UsingVectorMinMax() [MethodImpl(MethodImplOptions.AggressiveInlining)] private static Vector4 ClampUsingVectorClamp(float x, float min, float max) { - return Vector4.Clamp(new Vector4(x), new Vector4(min), new Vector4(max)); + return Vector4.Clamp(new(x), new(min), new(max)); } [MethodImpl(MethodImplOptions.AggressiveInlining)] private static Vector4 ClampUsingVectorMinMax(float x, float min, float max) { - return Vector4.Min(new Vector4(max), Vector4.Max(new Vector4(min), new Vector4(x))); + return Vector4.Min(new(max), Vector4.Max(new(min), new(x))); } // RESULTS diff --git a/tests/ImageSharp.Benchmarks/General/CopyBuffers.cs b/tests/ImageSharp.Benchmarks/General/CopyBuffers.cs index 031f9ecf27..85daa5bd26 100644 --- a/tests/ImageSharp.Benchmarks/General/CopyBuffers.cs +++ b/tests/ImageSharp.Benchmarks/General/CopyBuffers.cs @@ -36,11 +36,11 @@ public class CopyBuffers public void Setup() { this.sourceArray = new byte[this.Count]; - this.sourceMemory = new Memory(this.sourceArray); + this.sourceMemory = new(this.sourceArray); this.sourceHandle = this.sourceMemory.Pin(); this.destArray = new byte[this.Count]; - this.destMemory = new Memory(this.destArray); + this.destMemory = new(this.destArray); this.destHandle = this.destMemory.Pin(); } diff --git a/tests/ImageSharp.Benchmarks/General/IO/BufferedStreams.cs b/tests/ImageSharp.Benchmarks/General/IO/BufferedStreams.cs index 9560d6ee71..a2dcdffd99 100644 --- a/tests/ImageSharp.Benchmarks/General/IO/BufferedStreams.cs +++ b/tests/ImageSharp.Benchmarks/General/IO/BufferedStreams.cs @@ -31,28 +31,28 @@ public class BufferedStreams [GlobalSetup] public void CreateStreams() { - this.stream1 = new MemoryStream(this.buffer); - this.stream2 = new MemoryStream(this.buffer); - this.stream3 = new MemoryStream(this.buffer); - this.stream4 = new MemoryStream(this.buffer); - this.stream5 = new MemoryStream(this.buffer); - this.stream6 = new MemoryStream(this.buffer); - this.stream6 = new MemoryStream(this.buffer); - - this.chunkedMemoryStream1 = new ChunkedMemoryStream(Configuration.Default.MemoryAllocator); + this.stream1 = new(this.buffer); + this.stream2 = new(this.buffer); + this.stream3 = new(this.buffer); + this.stream4 = new(this.buffer); + this.stream5 = new(this.buffer); + this.stream6 = new(this.buffer); + this.stream6 = new(this.buffer); + + this.chunkedMemoryStream1 = new(Configuration.Default.MemoryAllocator); this.chunkedMemoryStream1.Write(this.buffer); this.chunkedMemoryStream1.Position = 0; - this.chunkedMemoryStream2 = new ChunkedMemoryStream(Configuration.Default.MemoryAllocator); + this.chunkedMemoryStream2 = new(Configuration.Default.MemoryAllocator); this.chunkedMemoryStream2.Write(this.buffer); this.chunkedMemoryStream2.Position = 0; - this.bufferedStream1 = new BufferedReadStream(Configuration.Default, this.stream3); - this.bufferedStream2 = new BufferedReadStream(Configuration.Default, this.stream4); - this.bufferedStream3 = new BufferedReadStream(Configuration.Default, this.chunkedMemoryStream1); - this.bufferedStream4 = new BufferedReadStream(Configuration.Default, this.chunkedMemoryStream2); - this.bufferedStreamWrap1 = new BufferedReadStreamWrapper(this.stream5); - this.bufferedStreamWrap2 = new BufferedReadStreamWrapper(this.stream6); + this.bufferedStream1 = new(Configuration.Default, this.stream3); + this.bufferedStream2 = new(Configuration.Default, this.stream4); + this.bufferedStream3 = new(Configuration.Default, this.chunkedMemoryStream1); + this.bufferedStream4 = new(Configuration.Default, this.chunkedMemoryStream2); + this.bufferedStreamWrap1 = new(this.stream5); + this.bufferedStreamWrap2 = new(this.stream6); } [GlobalCleanup] @@ -205,8 +205,8 @@ public int ArrayReadByte() private static byte[] CreateTestBytes() { - var buffer = new byte[Configuration.Default.StreamProcessingBufferSize * 3]; - var random = new Random(); + byte[] buffer = new byte[Configuration.Default.StreamProcessingBufferSize * 3]; + Random random = new(); random.NextBytes(buffer); return buffer; diff --git a/tests/ImageSharp.Benchmarks/General/PixelConversion/PixelConversion_ConvertFromRgba32.cs b/tests/ImageSharp.Benchmarks/General/PixelConversion/PixelConversion_ConvertFromRgba32.cs index 1d83b94dc8..bbe9e72d18 100644 --- a/tests/ImageSharp.Benchmarks/General/PixelConversion/PixelConversion_ConvertFromRgba32.cs +++ b/tests/ImageSharp.Benchmarks/General/PixelConversion/PixelConversion_ConvertFromRgba32.cs @@ -96,9 +96,9 @@ public readonly void RunFromBytesConversion() [GlobalSetup] public void Setup() { - this.CompatibleMemLayoutRunner = new ConversionRunner(this.Count); - this.PermutedRunnerRgbaToArgb = new ConversionRunner(this.Count); - this.RunnerRgbaToRgbaVector = new ConversionRunner(this.Count); + this.CompatibleMemLayoutRunner = new(this.Count); + this.PermutedRunnerRgbaToArgb = new(this.Count); + this.RunnerRgbaToRgbaVector = new(this.Count); } } diff --git a/tests/ImageSharp.Benchmarks/General/PixelConversion/PixelConversion_ConvertFromVector4.cs b/tests/ImageSharp.Benchmarks/General/PixelConversion/PixelConversion_ConvertFromVector4.cs index 57f79ba1f3..c0dd6b93d5 100644 --- a/tests/ImageSharp.Benchmarks/General/PixelConversion/PixelConversion_ConvertFromVector4.cs +++ b/tests/ImageSharp.Benchmarks/General/PixelConversion/PixelConversion_ConvertFromVector4.cs @@ -65,8 +65,8 @@ public void RunByValConversion() [GlobalSetup] public void Setup() { - this.nonVectorRunner = new ConversionRunner(this.Count); - this.vectorRunner = new ConversionRunner(this.Count); + this.nonVectorRunner = new(this.Count); + this.vectorRunner = new(this.Count); } [Benchmark(Baseline = true)] diff --git a/tests/ImageSharp.Benchmarks/General/PixelConversion/PixelConversion_ConvertToRgba32.cs b/tests/ImageSharp.Benchmarks/General/PixelConversion/PixelConversion_ConvertToRgba32.cs index 1a03a0c04f..4a36e9cf1a 100644 --- a/tests/ImageSharp.Benchmarks/General/PixelConversion/PixelConversion_ConvertToRgba32.cs +++ b/tests/ImageSharp.Benchmarks/General/PixelConversion/PixelConversion_ConvertToRgba32.cs @@ -69,8 +69,8 @@ public void RunCopyToConversion() [GlobalSetup] public void Setup() { - this.compatibleMemoryLayoutRunner = new ConversionRunner(this.Count); - this.permutedRunner = new ConversionRunner(this.Count); + this.compatibleMemoryLayoutRunner = new(this.Count); + this.permutedRunner = new(this.Count); } [Benchmark(Baseline = true)] diff --git a/tests/ImageSharp.Benchmarks/General/PixelConversion/PixelConversion_ConvertToRgba32_AsPartOfCompositeOperation.cs b/tests/ImageSharp.Benchmarks/General/PixelConversion/PixelConversion_ConvertToRgba32_AsPartOfCompositeOperation.cs index 69a71734a3..ad2e71626a 100644 --- a/tests/ImageSharp.Benchmarks/General/PixelConversion/PixelConversion_ConvertToRgba32_AsPartOfCompositeOperation.cs +++ b/tests/ImageSharp.Benchmarks/General/PixelConversion/PixelConversion_ConvertToRgba32_AsPartOfCompositeOperation.cs @@ -76,8 +76,8 @@ public void RunCopyToConversion() [GlobalSetup] public void Setup() { - this.compatibleMemoryLayoutRunner = new ConversionRunner(this.Count); - this.permutedRunner = new ConversionRunner(this.Count); + this.compatibleMemoryLayoutRunner = new(this.Count); + this.permutedRunner = new(this.Count); } [Benchmark(Baseline = true)] diff --git a/tests/ImageSharp.Benchmarks/General/PixelConversion/PixelConversion_ConvertToVector4.cs b/tests/ImageSharp.Benchmarks/General/PixelConversion/PixelConversion_ConvertToVector4.cs index 9b498b0f2e..ee0fbb4996 100644 --- a/tests/ImageSharp.Benchmarks/General/PixelConversion/PixelConversion_ConvertToVector4.cs +++ b/tests/ImageSharp.Benchmarks/General/PixelConversion/PixelConversion_ConvertToVector4.cs @@ -59,7 +59,7 @@ public void RunCopyToConversion() [GlobalSetup] public void Setup() { - this.runner = new ConversionRunner(this.Count); + this.runner = new(this.Count); } [Benchmark(Baseline = true)] diff --git a/tests/ImageSharp.Benchmarks/General/PixelConversion/PixelConversion_ConvertToVector4_AsPartOfCompositeOperation.cs b/tests/ImageSharp.Benchmarks/General/PixelConversion/PixelConversion_ConvertToVector4_AsPartOfCompositeOperation.cs index 50c3d0d131..d9723b0e3a 100644 --- a/tests/ImageSharp.Benchmarks/General/PixelConversion/PixelConversion_ConvertToVector4_AsPartOfCompositeOperation.cs +++ b/tests/ImageSharp.Benchmarks/General/PixelConversion/PixelConversion_ConvertToVector4_AsPartOfCompositeOperation.cs @@ -73,7 +73,7 @@ public void RunCopyToConversion() [GlobalSetup] public void Setup() { - this.runner = new ConversionRunner(this.Count); + this.runner = new(this.Count); } [Benchmark(Baseline = true)] diff --git a/tests/ImageSharp.Benchmarks/General/PixelConversion/PixelConversion_PackFromRgbPlanes.cs b/tests/ImageSharp.Benchmarks/General/PixelConversion/PixelConversion_PackFromRgbPlanes.cs index a42c6c253c..226dcc7775 100644 --- a/tests/ImageSharp.Benchmarks/General/PixelConversion/PixelConversion_PackFromRgbPlanes.cs +++ b/tests/ImageSharp.Benchmarks/General/PixelConversion/PixelConversion_PackFromRgbPlanes.cs @@ -209,7 +209,7 @@ public void Rgba32_Avx2_Float() Vector256 vcontrol = SimdUtils.HwIntrinsics.PermuteMaskEvenOdd8x32().AsInt32(); - var va = Vector256.Create(1F); + Vector256 va = Vector256.Create(1F); for (nuint i = 0; i < count; i++) { diff --git a/tests/ImageSharp.Benchmarks/General/PixelConversion/PixelConversion_Rgba32_To_Bgra32.cs b/tests/ImageSharp.Benchmarks/General/PixelConversion/PixelConversion_Rgba32_To_Bgra32.cs index f4fb9e4204..232d8b3e27 100644 --- a/tests/ImageSharp.Benchmarks/General/PixelConversion/PixelConversion_Rgba32_To_Bgra32.cs +++ b/tests/ImageSharp.Benchmarks/General/PixelConversion/PixelConversion_Rgba32_To_Bgra32.cs @@ -252,8 +252,8 @@ private struct C private static void BitopsSimdImpl(ref Octet s, ref Octet d) { Vector sVec = Unsafe.As, Vector>(ref s); - var aMask = new Vector(0xFF00FF00); - var bMask = new Vector(0x00FF00FF); + Vector aMask = new(0xFF00FF00); + Vector bMask = new(0x00FF00FF); Vector aa = sVec & aMask; Vector bb = sVec & bMask; diff --git a/tests/ImageSharp.Benchmarks/General/Vector4Constants.cs b/tests/ImageSharp.Benchmarks/General/Vector4Constants.cs index 2cd6a5a52a..c7df2467bc 100644 --- a/tests/ImageSharp.Benchmarks/General/Vector4Constants.cs +++ b/tests/ImageSharp.Benchmarks/General/Vector4Constants.cs @@ -12,10 +12,10 @@ namespace SixLabors.ImageSharp.Benchmarks.General; /// public class Vector4Constants { - private static readonly Vector4 A = new Vector4(1.2f); - private static readonly Vector4 B = new Vector4(3.4f); - private static readonly Vector4 C = new Vector4(5.6f); - private static readonly Vector4 D = new Vector4(7.8f); + private static readonly Vector4 A = new(1.2f); + private static readonly Vector4 B = new(3.4f); + private static readonly Vector4 C = new(5.6f); + private static readonly Vector4 D = new(7.8f); private Random random; @@ -24,8 +24,8 @@ public class Vector4Constants [GlobalSetup] public void Setup() { - this.random = new Random(42); - this.parameter = new Vector4( + this.random = new(42); + this.parameter = new( this.GetRandomFloat(), this.GetRandomFloat(), this.GetRandomFloat(), @@ -39,8 +39,8 @@ public Vector4 Static() Vector4 x = (p * A / B) + (p * C / D); Vector4 y = (p / A * B) + (p / C * D); - var z = Vector4.Min(p, A); - var w = Vector4.Max(p, B); + Vector4 z = Vector4.Min(p, A); + Vector4 w = Vector4.Max(p, B); return x + y + z + w; } @@ -51,8 +51,8 @@ public Vector4 Inlined() Vector4 x = (p * new Vector4(1.2f) / new Vector4(2.3f)) + (p * new Vector4(4.5f) / new Vector4(6.7f)); Vector4 y = (p / new Vector4(1.2f) * new Vector4(2.3f)) + (p / new Vector4(4.5f) * new Vector4(6.7f)); - var z = Vector4.Min(p, new Vector4(1.2f)); - var w = Vector4.Max(p, new Vector4(2.3f)); + Vector4 z = Vector4.Min(p, new(1.2f)); + Vector4 w = Vector4.Max(p, new(2.3f)); return x + y + z + w; } diff --git a/tests/ImageSharp.Benchmarks/General/Vectorization/BitwiseOrUint32.cs b/tests/ImageSharp.Benchmarks/General/Vectorization/BitwiseOrUint32.cs index 4d8d9b1ed6..2f9b02b59f 100644 --- a/tests/ImageSharp.Benchmarks/General/Vectorization/BitwiseOrUint32.cs +++ b/tests/ImageSharp.Benchmarks/General/Vectorization/BitwiseOrUint32.cs @@ -43,11 +43,11 @@ public void Standard() [Benchmark] public void Simd() { - var v = new Vector(this.testValue); + Vector v = new(this.testValue); for (int i = 0; i < this.input.Length; i += Vector.Count) { - var a = new Vector(this.input, i); + Vector a = new(this.input, i); a = Vector.BitwiseOr(a, v); a.CopyTo(this.result, i); } diff --git a/tests/ImageSharp.Benchmarks/General/Vectorization/DivFloat.cs b/tests/ImageSharp.Benchmarks/General/Vectorization/DivFloat.cs index 1b2c56ab97..fd243638b2 100644 --- a/tests/ImageSharp.Benchmarks/General/Vectorization/DivFloat.cs +++ b/tests/ImageSharp.Benchmarks/General/Vectorization/DivFloat.cs @@ -43,11 +43,11 @@ public void Standard() [Benchmark] public void Simd() { - var v = new Vector(this.testValue); + Vector v = new(this.testValue); for (int i = 0; i < this.input.Length; i += Vector.Count) { - var a = new Vector(this.input, i); + Vector a = new(this.input, i); a = a / v; a.CopyTo(this.result, i); } diff --git a/tests/ImageSharp.Benchmarks/General/Vectorization/DivUInt32.cs b/tests/ImageSharp.Benchmarks/General/Vectorization/DivUInt32.cs index d102164e2c..0d2923b619 100644 --- a/tests/ImageSharp.Benchmarks/General/Vectorization/DivUInt32.cs +++ b/tests/ImageSharp.Benchmarks/General/Vectorization/DivUInt32.cs @@ -44,11 +44,11 @@ public void Standard() [Benchmark] public void Simd() { - var v = new Vector(this.testValue); + Vector v = new(this.testValue); for (int i = 0; i < this.input.Length; i += Vector.Count) { - var a = new Vector(this.input, i); + Vector a = new(this.input, i); a = a / v; a.CopyTo(this.result, i); diff --git a/tests/ImageSharp.Benchmarks/General/Vectorization/Divide.cs b/tests/ImageSharp.Benchmarks/General/Vectorization/Divide.cs index 9c95c22e0f..d7d734539c 100644 --- a/tests/ImageSharp.Benchmarks/General/Vectorization/Divide.cs +++ b/tests/ImageSharp.Benchmarks/General/Vectorization/Divide.cs @@ -57,7 +57,7 @@ public class DivInt16 : SIMDBenchmarkBase.Divide { protected override short GetTestValue() => 42; - protected override Vector GetTestVector() => new Vector(new short[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17 }); + protected override Vector GetTestVector() => new(new short[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17 }); [Benchmark(Baseline = true)] public void Standard() diff --git a/tests/ImageSharp.Benchmarks/General/Vectorization/MulFloat.cs b/tests/ImageSharp.Benchmarks/General/Vectorization/MulFloat.cs index a2eb8d417a..801b0e1613 100644 --- a/tests/ImageSharp.Benchmarks/General/Vectorization/MulFloat.cs +++ b/tests/ImageSharp.Benchmarks/General/Vectorization/MulFloat.cs @@ -43,11 +43,11 @@ public void Standard() [Benchmark] public void SimdMultiplyByVector() { - var v = new Vector(this.testValue); + Vector v = new(this.testValue); for (int i = 0; i < this.input.Length; i += Vector.Count) { - var a = new Vector(this.input, i); + Vector a = new(this.input, i); a = a * v; a.CopyTo(this.result, i); } @@ -60,7 +60,7 @@ public void SimdMultiplyByScalar() for (int i = 0; i < this.input.Length; i += Vector.Count) { - var a = new Vector(this.input, i); + Vector a = new(this.input, i); a = a * v; a.CopyTo(this.result, i); } diff --git a/tests/ImageSharp.Benchmarks/General/Vectorization/MulUInt32.cs b/tests/ImageSharp.Benchmarks/General/Vectorization/MulUInt32.cs index a234970a51..db64486ada 100644 --- a/tests/ImageSharp.Benchmarks/General/Vectorization/MulUInt32.cs +++ b/tests/ImageSharp.Benchmarks/General/Vectorization/MulUInt32.cs @@ -43,11 +43,11 @@ public void Standard() [Benchmark] public void Simd() { - var v = new Vector(this.testValue); + Vector v = new(this.testValue); for (int i = 0; i < this.input.Length; i += Vector.Count) { - var a = new Vector(this.input, i); + Vector a = new(this.input, i); a = a * v; a.CopyTo(this.result, i); } diff --git a/tests/ImageSharp.Benchmarks/General/Vectorization/Multiply.cs b/tests/ImageSharp.Benchmarks/General/Vectorization/Multiply.cs index fe48c3301b..d7562d47f8 100644 --- a/tests/ImageSharp.Benchmarks/General/Vectorization/Multiply.cs +++ b/tests/ImageSharp.Benchmarks/General/Vectorization/Multiply.cs @@ -40,7 +40,7 @@ public class MulInt16 : SIMDBenchmarkBase.Multiply { protected override short GetTestValue() => 42; - protected override Vector GetTestVector() => new Vector(new short[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17 }); + protected override Vector GetTestVector() => new(new short[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17 }); [Benchmark(Baseline = true)] public void Standard() diff --git a/tests/ImageSharp.Benchmarks/General/Vectorization/Premultiply.cs b/tests/ImageSharp.Benchmarks/General/Vectorization/Premultiply.cs index 29b90accc5..f99b141b4e 100644 --- a/tests/ImageSharp.Benchmarks/General/Vectorization/Premultiply.cs +++ b/tests/ImageSharp.Benchmarks/General/Vectorization/Premultiply.cs @@ -12,14 +12,14 @@ public class Premultiply [Benchmark(Baseline = true)] public Vector4 PremultiplyByVal() { - var input = new Vector4(.5F); + Vector4 input = new(.5F); return Vector4Utils.Premultiply(input); } [Benchmark] public Vector4 PremultiplyByRef() { - var input = new Vector4(.5F); + Vector4 input = new(.5F); Vector4Utils.PremultiplyRef(ref input); return input; } @@ -27,7 +27,7 @@ public Vector4 PremultiplyByRef() [Benchmark] public Vector4 PremultiplyRefWithPropertyAssign() { - var input = new Vector4(.5F); + Vector4 input = new(.5F); Vector4Utils.PremultiplyRefWithPropertyAssign(ref input); return input; } diff --git a/tests/ImageSharp.Benchmarks/General/Vectorization/ReinterpretUInt32AsFloat.cs b/tests/ImageSharp.Benchmarks/General/Vectorization/ReinterpretUInt32AsFloat.cs index 7d626d7856..557d8ff38b 100644 --- a/tests/ImageSharp.Benchmarks/General/Vectorization/ReinterpretUInt32AsFloat.cs +++ b/tests/ImageSharp.Benchmarks/General/Vectorization/ReinterpretUInt32AsFloat.cs @@ -53,8 +53,8 @@ public void Simd() { for (int i = 0; i < this.input.Length; i += Vector.Count) { - var a = new Vector(this.input, i); - var b = Vector.AsVectorSingle(a); + Vector a = new(this.input, i); + Vector b = Vector.AsVectorSingle(a); b.CopyTo(this.result, i); } } diff --git a/tests/ImageSharp.Benchmarks/General/Vectorization/SIMDBenchmarkBase.cs b/tests/ImageSharp.Benchmarks/General/Vectorization/SIMDBenchmarkBase.cs index 90d81a0583..4eef631c42 100644 --- a/tests/ImageSharp.Benchmarks/General/Vectorization/SIMDBenchmarkBase.cs +++ b/tests/ImageSharp.Benchmarks/General/Vectorization/SIMDBenchmarkBase.cs @@ -20,7 +20,7 @@ public abstract class SIMDBenchmarkBase protected virtual T GetTestValue() => default; - protected virtual Vector GetTestVector() => new Vector(this.GetTestValue()); + protected virtual Vector GetTestVector() => new(this.GetTestValue()); [Params(32)] public int InputSize { get; set; } diff --git a/tests/ImageSharp.Benchmarks/General/Vectorization/UInt32ToSingle.cs b/tests/ImageSharp.Benchmarks/General/Vectorization/UInt32ToSingle.cs index 5f1f5666de..4048bc210e 100644 --- a/tests/ImageSharp.Benchmarks/General/Vectorization/UInt32ToSingle.cs +++ b/tests/ImageSharp.Benchmarks/General/Vectorization/UInt32ToSingle.cs @@ -27,20 +27,20 @@ public void MagicMethod() nuint n = Count / (uint)Vector.Count; - var bVec = new Vector(256.0f / 255.0f); - var magicFloat = new Vector(32768.0f); - var magicInt = new Vector(1191182336); // reinterpreted value of 32768.0f - var mask = new Vector(255); + Vector bVec = new(256.0f / 255.0f); + Vector magicFloat = new(32768.0f); + Vector magicInt = new(1191182336); // reinterpreted value of 32768.0f + Vector mask = new(255); for (nuint i = 0; i < n; i++) { ref Vector df = ref Unsafe.Add(ref b, i); - var vi = Vector.AsVectorUInt32(df); + Vector vi = Vector.AsVectorUInt32(df); vi &= mask; vi |= magicInt; - var vf = Vector.AsVectorSingle(vi); + Vector vf = Vector.AsVectorSingle(vi); vf = (vf - magicFloat) * bVec; df = vf; @@ -55,7 +55,7 @@ public void StandardSimd() ref Vector bf = ref Unsafe.As>(ref this.data[0]); ref Vector bu = ref Unsafe.As, Vector>(ref bf); - var scale = new Vector(1f / 255f); + Vector scale = new(1f / 255f); for (nuint i = 0; i < n; i++) { @@ -74,7 +74,7 @@ public void StandardSimdFromInt() ref Vector bf = ref Unsafe.As>(ref this.data[0]); ref Vector bu = ref Unsafe.As, Vector>(ref bf); - var scale = new Vector(1f / 255f); + Vector scale = new(1f / 255f); for (nuint i = 0; i < n; i++) { @@ -91,7 +91,7 @@ public void StandardSimdFromInt_RefCast() nuint n = Count / (uint)Vector.Count; ref Vector bf = ref Unsafe.As>(ref this.data[0]); - var scale = new Vector(1f / 255f); + Vector scale = new(1f / 255f); for (nuint i = 0; i < n; i++) { diff --git a/tests/ImageSharp.Benchmarks/General/Vectorization/VectorFetching.cs b/tests/ImageSharp.Benchmarks/General/Vectorization/VectorFetching.cs index 5d20f29d18..9c7fd5b6cc 100644 --- a/tests/ImageSharp.Benchmarks/General/Vectorization/VectorFetching.cs +++ b/tests/ImageSharp.Benchmarks/General/Vectorization/VectorFetching.cs @@ -47,11 +47,11 @@ public void Baseline() [Benchmark] public void FetchWithVectorConstructor() { - var v = new Vector(this.testValue); + Vector v = new(this.testValue); for (int i = 0; i < this.data.Length; i += Vector.Count) { - var a = new Vector(this.data, i); + Vector a = new(this.data, i); a = a * v; a.CopyTo(this.data, i); } @@ -60,7 +60,7 @@ public void FetchWithVectorConstructor() [Benchmark] public void FetchWithUnsafeCast() { - var v = new Vector(this.testValue); + Vector v = new(this.testValue); ref Vector start = ref Unsafe.As>(ref this.data[0]); nuint n = (uint)this.InputSize / (uint)Vector.Count; @@ -79,7 +79,7 @@ public void FetchWithUnsafeCast() [Benchmark] public void FetchWithUnsafeCastNoTempVector() { - var v = new Vector(this.testValue); + Vector v = new(this.testValue); ref Vector start = ref Unsafe.As>(ref this.data[0]); nuint n = (uint)this.InputSize / (uint)Vector.Count; @@ -94,9 +94,9 @@ public void FetchWithUnsafeCastNoTempVector() [Benchmark] public void FetchWithUnsafeCastFromReference() { - var v = new Vector(this.testValue); + Vector v = new(this.testValue); - var span = new Span(this.data); + Span span = new(this.data); ref Vector start = ref Unsafe.As>(ref MemoryMarshal.GetReference(span)); diff --git a/tests/ImageSharp.Benchmarks/LoadResizeSave/LoadResizeSaveStressBenchmarks.cs b/tests/ImageSharp.Benchmarks/LoadResizeSave/LoadResizeSaveStressBenchmarks.cs index 04621695c6..ff32ed1539 100644 --- a/tests/ImageSharp.Benchmarks/LoadResizeSave/LoadResizeSaveStressBenchmarks.cs +++ b/tests/ImageSharp.Benchmarks/LoadResizeSave/LoadResizeSaveStressBenchmarks.cs @@ -18,7 +18,7 @@ public class LoadResizeSaveStressBenchmarks [GlobalSetup] public void Setup() { - this.runner = new LoadResizeSaveStressRunner() + this.runner = new() { ImageCount = Environment.ProcessorCount, Filter = Filter @@ -34,12 +34,12 @@ private void ForEachImage(Action action, int maxDegreeOfParallelism) } public int[] ParallelismValues { get; } = - { + [ // Environment.ProcessorCount, // Environment.ProcessorCount / 2, // Environment.ProcessorCount / 4, 1 - }; + ]; [Benchmark] [ArgumentsSource(nameof(ParallelismValues))] diff --git a/tests/ImageSharp.Benchmarks/LoadResizeSave/LoadResizeSaveStressRunner.cs b/tests/ImageSharp.Benchmarks/LoadResizeSave/LoadResizeSaveStressRunner.cs index a06784f1b1..0f939aa86a 100644 --- a/tests/ImageSharp.Benchmarks/LoadResizeSave/LoadResizeSaveStressRunner.cs +++ b/tests/ImageSharp.Benchmarks/LoadResizeSave/LoadResizeSaveStressRunner.cs @@ -52,7 +52,7 @@ public class LoadResizeSaveStressRunner public int ThumbnailSize { get; set; } = 150; private static readonly string[] ProgressiveFiles = - { + [ "ancyloscelis-apiformis-m-paraguay-face_2014-08-08-095255-zs-pmax_15046500892_o.jpg", "acanthopus-excellens-f-face-brasil_2014-08-06-132105-zs-pmax_14792513890_o.jpg", "bee-ceratina-monster-f-ukraine-face_2014-08-09-123342-zs-pmax_15068816101_o.jpg", @@ -83,8 +83,8 @@ public class LoadResizeSaveStressRunner "triepeolus-simplex-m-face-md-kent-county_2014-07-22-100937-zs-pmax_14805405233_o.jpg", "washed-megachile-f-face-chile_2014-08-06-103414-zs-pmax_14977843152_o.jpg", "xylocopa-balck-violetwing-f-kyrgystan-angle_2014-08-09-182433-zs-pmax_15123416061_o.jpg", - "xylocopa-india-yellow-m-india-face_2014-08-10-111701-zs-pmax_15166559172_o.jpg", - }; + "xylocopa-india-yellow-m-india-face_2014-08-10-111701-zs-pmax_15166559172_o.jpg" + ]; public void Init() { @@ -116,7 +116,7 @@ static JpegKind GetJpegType(string f) => public void ForEachImageParallel(Action action) => Parallel.ForEach( this.Images, - new ParallelOptions { MaxDegreeOfParallelism = this.MaxDegreeOfParallelism }, + new() { MaxDegreeOfParallelism = this.MaxDegreeOfParallelism }, action); public Task ForEachImageParallelAsync(Func action) @@ -126,7 +126,7 @@ public Task ForEachImageParallelAsync(Func action) : Environment.ProcessorCount; int partitionSize = (int)Math.Ceiling((double)this.Images.Length / maxDegreeOfParallelism); - List tasks = new(); + List tasks = []; for (int i = 0; i < this.Images.Length; i += partitionSize) { int end = Math.Min(i + partitionSize, this.Images.Length); @@ -147,7 +147,7 @@ Task RunPartition(int start, int end) => Task.Run(async () => private void LogImageProcessed(int width, int height) { - this.LastProcessedImageSize = new Size(width, height); + this.LastProcessedImageSize = new(width, height); double pixels = width * (double)height; this.TotalProcessedMegapixels += pixels / 1_000_000.0; } @@ -176,13 +176,13 @@ private string OutputPath(string inputPath, [CallerMemberName] string postfix = public void SystemDrawingResize(string input) { - using var image = SystemDrawingImage.FromFile(input, true); + using SystemDrawingImage image = SystemDrawingImage.FromFile(input, true); this.LogImageProcessed(image.Width, image.Height); (int Width, int Height) scaled = this.ScaledSize(image.Width, image.Height, this.ThumbnailSize); - var resized = new Bitmap(scaled.Width, scaled.Height); - using var graphics = Graphics.FromImage(resized); - using var attributes = new ImageAttributes(); + Bitmap resized = new(scaled.Width, scaled.Height); + using Graphics graphics = Graphics.FromImage(resized); + using ImageAttributes attributes = new(); attributes.SetWrapMode(WrapMode.TileFlipXY); graphics.PixelOffsetMode = PixelOffsetMode.HighQuality; graphics.CompositingMode = CompositingMode.SourceCopy; @@ -191,8 +191,8 @@ public void SystemDrawingResize(string input) graphics.DrawImage(image, System.Drawing.Rectangle.FromLTRB(0, 0, resized.Width, resized.Height), 0, 0, image.Width, image.Height, GraphicsUnit.Pixel, attributes); // Save the results - using var encoderParams = new EncoderParameters(1); - using var qualityParam = new EncoderParameter(Encoder.Quality, (long)Quality); + using EncoderParameters encoderParams = new(1); + using EncoderParameter qualityParam = new(Encoder.Quality, (long)Quality); encoderParams.Param[0] = qualityParam; resized.Save(this.OutputPath(input), this.systemDrawingJpegCodec, encoderParams); } @@ -246,7 +246,7 @@ public async Task ImageSharpResizeAsync(string input) public void MagickResize(string input) { - using var image = new MagickImage(input); + using MagickImage image = new(input); this.LogImageProcessed(image.Width, image.Height); // Resize it to fit a 150x150 square @@ -264,7 +264,7 @@ public void MagickResize(string input) public void MagicScalerResize(string input) { - var settings = new ProcessImageSettings() + ProcessImageSettings settings = new() { Width = this.ThumbnailSize, Height = this.ThumbnailSize, @@ -273,17 +273,17 @@ public void MagicScalerResize(string input) }; // TODO: Is there a way to capture input dimensions for IncreaseTotalMegapixels? - using var output = new FileStream(this.OutputPath(input), FileMode.Create); + using FileStream output = new(this.OutputPath(input), FileMode.Create); MagicImageProcessor.ProcessImage(input, output, settings); } public void SkiaCanvasResize(string input) { - using var original = SKBitmap.Decode(input); + using SKBitmap original = SKBitmap.Decode(input); this.LogImageProcessed(original.Width, original.Height); (int Width, int Height) scaled = this.ScaledSize(original.Width, original.Height, this.ThumbnailSize); - using var surface = SKSurface.Create(new SKImageInfo(scaled.Width, scaled.Height, original.ColorType, original.AlphaType)); - using var paint = new SKPaint() { FilterQuality = SKFilterQuality.High }; + using SKSurface surface = SKSurface.Create(new SKImageInfo(scaled.Width, scaled.Height, original.ColorType, original.AlphaType)); + using SKPaint paint = new() { FilterQuality = SKFilterQuality.High }; SKCanvas canvas = surface.Canvas; canvas.Scale((float)scaled.Width / original.Width); canvas.DrawBitmap(original, 0, 0, paint); @@ -297,16 +297,16 @@ public void SkiaCanvasResize(string input) public void SkiaBitmapResize(string input) { - using var original = SKBitmap.Decode(input); + using SKBitmap original = SKBitmap.Decode(input); this.LogImageProcessed(original.Width, original.Height); (int Width, int Height) scaled = this.ScaledSize(original.Width, original.Height, this.ThumbnailSize); - using var resized = original.Resize(new SKImageInfo(scaled.Width, scaled.Height), SKFilterQuality.High); + using SKBitmap resized = original.Resize(new SKImageInfo(scaled.Width, scaled.Height), SKFilterQuality.High); if (resized == null) { return; } - using var image = SKImage.FromBitmap(resized); + using SKImage image = SKImage.FromBitmap(resized); using FileStream output = File.OpenWrite(this.OutputPath(input)); image.Encode(SKEncodedImageFormat.Jpeg, Quality) .SaveTo(output); @@ -314,21 +314,21 @@ public void SkiaBitmapResize(string input) public void SkiaBitmapDecodeToTargetSize(string input) { - using var codec = SKCodec.Create(input); + using SKCodec codec = SKCodec.Create(input); SKImageInfo info = codec.Info; this.LogImageProcessed(info.Width, info.Height); (int Width, int Height) scaled = this.ScaledSize(info.Width, info.Height, this.ThumbnailSize); SKSizeI supportedScale = codec.GetScaledDimensions((float)scaled.Width / info.Width); - using var original = SKBitmap.Decode(codec, new SKImageInfo(supportedScale.Width, supportedScale.Height)); + using SKBitmap original = SKBitmap.Decode(codec, new(supportedScale.Width, supportedScale.Height)); using SKBitmap resized = original.Resize(new SKImageInfo(scaled.Width, scaled.Height), SKFilterQuality.High); if (resized == null) { return; } - using var image = SKImage.FromBitmap(resized); + using SKImage image = SKImage.FromBitmap(resized); using FileStream output = File.OpenWrite(this.OutputPath(input, nameof(this.SkiaBitmapDecodeToTargetSize))); image.Encode(SKEncodedImageFormat.Jpeg, Quality) @@ -338,7 +338,7 @@ public void SkiaBitmapDecodeToTargetSize(string input) public void NetVipsResize(string input) { // Thumbnail to fit a 150x150 square - using var thumb = NetVipsImage.Thumbnail(input, this.ThumbnailSize, this.ThumbnailSize); + using NetVipsImage thumb = NetVipsImage.Thumbnail(input, this.ThumbnailSize, this.ThumbnailSize); // Save the results thumb.Jpegsave(this.OutputPath(input), q: Quality, keep: NetVips.Enums.ForeignKeep.None); diff --git a/tests/ImageSharp.Benchmarks/PixelBlenders/PorterDuffBulkVsPixel.cs b/tests/ImageSharp.Benchmarks/PixelBlenders/PorterDuffBulkVsPixel.cs index a308c0c468..9f75f9dc26 100644 --- a/tests/ImageSharp.Benchmarks/PixelBlenders/PorterDuffBulkVsPixel.cs +++ b/tests/ImageSharp.Benchmarks/PixelBlenders/PorterDuffBulkVsPixel.cs @@ -73,7 +73,7 @@ public Size BulkVectorConvert() BulkVectorConvert(span, span, span, amounts.GetSpan()); } - return new Size(image.Width, image.Height); + return new(image.Width, image.Height); } [Benchmark(Description = "ImageSharp BulkPixelConvert")] @@ -89,6 +89,6 @@ public Size BulkPixelConvert() BulkPixelConvert(span, span, span, amounts.GetSpan()); } - return new Size(image.Width, image.Height); + return new(image.Width, image.Height); } } diff --git a/tests/ImageSharp.Benchmarks/Processing/Crop.cs b/tests/ImageSharp.Benchmarks/Processing/Crop.cs index 0432b76249..d526c6ba4a 100644 --- a/tests/ImageSharp.Benchmarks/Processing/Crop.cs +++ b/tests/ImageSharp.Benchmarks/Processing/Crop.cs @@ -17,14 +17,14 @@ public class Crop [Benchmark(Baseline = true, Description = "System.Drawing Crop")] public SDSize CropSystemDrawing() { - using var source = new Bitmap(800, 800); - using var destination = new Bitmap(100, 100); - using var graphics = Graphics.FromImage(destination); + using Bitmap source = new(800, 800); + using Bitmap destination = new(100, 100); + using Graphics graphics = Graphics.FromImage(destination); graphics.InterpolationMode = InterpolationMode.HighQualityBicubic; graphics.PixelOffsetMode = PixelOffsetMode.HighQuality; graphics.CompositingQuality = CompositingQuality.HighQuality; - graphics.DrawImage(source, new SDRectangle(0, 0, 100, 100), 0, 0, 100, 100, GraphicsUnit.Pixel); + graphics.DrawImage(source, new(0, 0, 100, 100), 0, 0, 100, 100, GraphicsUnit.Pixel); return destination.Size; } @@ -32,8 +32,8 @@ public SDSize CropSystemDrawing() [Benchmark(Description = "ImageSharp Crop")] public Size CropImageSharp() { - using var image = new Image(800, 800); + using Image image = new(800, 800); image.Mutate(x => x.Crop(100, 100)); - return new Size(image.Width, image.Height); + return new(image.Width, image.Height); } } diff --git a/tests/ImageSharp.Benchmarks/Processing/HistogramEqualization.cs b/tests/ImageSharp.Benchmarks/Processing/HistogramEqualization.cs index 135145a312..8be48260ab 100644 --- a/tests/ImageSharp.Benchmarks/Processing/HistogramEqualization.cs +++ b/tests/ImageSharp.Benchmarks/Processing/HistogramEqualization.cs @@ -33,7 +33,7 @@ public void Cleanup() [Benchmark(Description = "Global Histogram Equalization")] public void GlobalHistogramEqualization() => this.image.Mutate(img => img.HistogramEqualization( - new HistogramEqualizationOptions() + new() { LuminanceLevels = 256, Method = HistogramEqualizationMethod.Global @@ -42,7 +42,7 @@ public void GlobalHistogramEqualization() [Benchmark(Description = "AdaptiveHistogramEqualization (Tile interpolation)")] public void AdaptiveHistogramEqualization() => this.image.Mutate(img => img.HistogramEqualization( - new HistogramEqualizationOptions() + new() { LuminanceLevels = 256, Method = HistogramEqualizationMethod.AdaptiveTileInterpolation diff --git a/tests/ImageSharp.Benchmarks/Processing/OilPaint.cs b/tests/ImageSharp.Benchmarks/Processing/OilPaint.cs index e3e413fe49..42ee7a5faa 100644 --- a/tests/ImageSharp.Benchmarks/Processing/OilPaint.cs +++ b/tests/ImageSharp.Benchmarks/Processing/OilPaint.cs @@ -13,7 +13,7 @@ public class OilPaint [Benchmark] public void DoOilPaint() { - using Image image = new Image(1920, 1200, new(127, 191, 255)); + using Image image = new(1920, 1200, new(127, 191, 255)); image.Mutate(ctx => ctx.OilPaint()); } } diff --git a/tests/ImageSharp.Benchmarks/Processing/Resize.cs b/tests/ImageSharp.Benchmarks/Processing/Resize.cs index 05baceb6a0..4d7bbce275 100644 --- a/tests/ImageSharp.Benchmarks/Processing/Resize.cs +++ b/tests/ImageSharp.Benchmarks/Processing/Resize.cs @@ -22,7 +22,7 @@ public abstract class Resize private SDImage sourceBitmap; - protected Configuration Configuration { get; } = new Configuration(new JpegConfigurationModule()); + protected Configuration Configuration { get; } = new(new JpegConfigurationModule()); protected int DestSize { get; private set; } @@ -35,7 +35,7 @@ public virtual void Setup() this.sourceImage = Image.Load(this.bytes); - var ms1 = new MemoryStream(this.bytes); + MemoryStream ms1 = new(this.bytes); this.sourceBitmap = SDImage.FromStream(ms1); this.DestSize = this.sourceBitmap.Width / 2; } @@ -52,9 +52,9 @@ public void Cleanup() [Benchmark(Baseline = true)] public int SystemDrawing() { - using (var destination = new Bitmap(this.DestSize, this.DestSize)) + using (Bitmap destination = new(this.DestSize, this.DestSize)) { - using (var g = Graphics.FromImage(destination)) + using (Graphics g = Graphics.FromImage(destination)) { g.CompositingMode = CompositingMode.SourceCopy; g.InterpolationMode = InterpolationMode.HighQualityBicubic; @@ -222,9 +222,9 @@ public class Resize_Bicubic_Compare_Rgba32_Rgb24 [GlobalSetup] public void Setup() { - this.rgb24 = new Resize_Bicubic_Rgb24(); + this.rgb24 = new(); this.rgb24.Setup(); - this.rgba32 = new Resize_Bicubic_Rgba32(); + this.rgba32 = new(); this.rgba32.Setup(); } diff --git a/tests/ImageSharp.Tests.ProfilingSandbox/LoadResizeSaveParallelMemoryStress.cs b/tests/ImageSharp.Tests.ProfilingSandbox/LoadResizeSaveParallelMemoryStress.cs index 248912b14f..79128cfee9 100644 --- a/tests/ImageSharp.Tests.ProfilingSandbox/LoadResizeSaveParallelMemoryStress.cs +++ b/tests/ImageSharp.Tests.ProfilingSandbox/LoadResizeSaveParallelMemoryStress.cs @@ -17,7 +17,7 @@ internal class LoadResizeSaveParallelMemoryStress { private LoadResizeSaveParallelMemoryStress() { - this.Benchmarks = new LoadResizeSaveStressRunner() + this.Benchmarks = new() { Filter = JpegKind.Baseline, }; @@ -38,7 +38,7 @@ public static void Run(string[] args) Console.WriteLine($"64 bit: {Environment.Is64BitProcess}"); CommandLineOptions options = args.Length > 0 ? CommandLineOptions.Parse(args) : null; - var lrs = new LoadResizeSaveParallelMemoryStress(); + LoadResizeSaveParallelMemoryStress lrs = new(); if (options != null) { lrs.Benchmarks.MaxDegreeOfParallelism = options.MaxDegreeOfParallelism; @@ -108,7 +108,7 @@ public static void Run(string[] args) } } - var stats = new Stats(timer, lrs.Benchmarks.TotalProcessedMegapixels); + Stats stats = new(timer, lrs.Benchmarks.TotalProcessedMegapixels); Console.WriteLine($"Total Megapixels: {stats.TotalMegapixels}, TotalOomRetries: {UnmanagedMemoryHandle.TotalOomRetries}, TotalOutstandingHandles: {UnmanagedMemoryHandle.TotalOutstandingHandles}, Total Gen2 GC count: {GC.CollectionCount(2)}"); Console.WriteLine(stats.GetMarkdown()); if (options?.FileOutput != null) @@ -203,7 +203,7 @@ public Stats(Stopwatch sw, double totalMegapixels) public string GetMarkdown() { - var bld = new StringBuilder(); + StringBuilder bld = new(); bld.AppendLine($"| {nameof(this.TotalSeconds)} | {nameof(this.MegapixelsPerSec)} | {nameof(this.MegapixelsPerSecPerCpu)} |"); bld.AppendLine( $"| {L(nameof(this.TotalSeconds))} | {L(nameof(this.MegapixelsPerSec))} | {L(nameof(this.MegapixelsPerSecPerCpu))} |"); @@ -295,7 +295,7 @@ public MemoryAllocator CreateMemoryAllocator() (int)B(this.MaxContiguousPoolBufferMegaBytes), B(this.MaxPoolSizeMegaBytes), (int)B(this.MaxCapacityOfNonPoolBuffersMegaBytes), - new UniformUnmanagedMemoryPool.TrimSettings + new() { TrimPeriodMilliseconds = this.TrimTimeSeconds.Value * 1000 }); diff --git a/tests/ImageSharp.Tests.ProfilingSandbox/Program.cs b/tests/ImageSharp.Tests.ProfilingSandbox/Program.cs index b5c8b70cde..8ba862560b 100644 --- a/tests/ImageSharp.Tests.ProfilingSandbox/Program.cs +++ b/tests/ImageSharp.Tests.ProfilingSandbox/Program.cs @@ -52,7 +52,7 @@ private static Version GetNetCoreVersion() { Assembly assembly = typeof(System.Runtime.GCSettings).GetTypeInfo().Assembly; Console.WriteLine(assembly.Location); - string[] assemblyPath = assembly.Location.Split(new[] { '/', '\\' }, StringSplitOptions.RemoveEmptyEntries); + string[] assemblyPath = assembly.Location.Split(['/', '\\'], StringSplitOptions.RemoveEmptyEntries); int netCoreAppIndex = Array.IndexOf(assemblyPath, "Microsoft.NETCore.App"); if (netCoreAppIndex > 0 && netCoreAppIndex < assemblyPath.Length - 2) { @@ -64,13 +64,13 @@ private static Version GetNetCoreVersion() private static void RunResizeProfilingTest() { - var test = new ResizeProfilingBenchmarks(new ConsoleOutput()); + ResizeProfilingBenchmarks test = new(new ConsoleOutput()); test.ResizeBicubic(4000, 4000); } private static void RunToVector4ProfilingTest() { - var tests = new PixelOperationsTests.Rgba32_OperationsTests(new ConsoleOutput()); + PixelOperationsTests.Rgba32_OperationsTests tests = new(new ConsoleOutput()); tests.Benchmark_ToVector4(); } } diff --git a/tests/ImageSharp.Tests/Color/ColorTests.CastTo.cs b/tests/ImageSharp.Tests/Color/ColorTests.CastTo.cs index 4247345c7b..6c3377d10d 100644 --- a/tests/ImageSharp.Tests/Color/ColorTests.CastTo.cs +++ b/tests/ImageSharp.Tests/Color/ColorTests.CastTo.cs @@ -13,10 +13,10 @@ public class CastTo [Fact] public void Rgba64() { - var source = new Rgba64(100, 2222, 3333, 4444); + Rgba64 source = new(100, 2222, 3333, 4444); // Act: - var color = Color.FromPixel(source); + Color color = Color.FromPixel(source); // Assert: Rgba64 data = color.ToPixel(); @@ -26,10 +26,10 @@ public void Rgba64() [Fact] public void Rgba32() { - var source = new Rgba32(1, 22, 33, 231); + Rgba32 source = new(1, 22, 33, 231); // Act: - var color = Color.FromPixel(source); + Color color = Color.FromPixel(source); // Assert: Rgba32 data = color.ToPixel(); @@ -39,10 +39,10 @@ public void Rgba32() [Fact] public void Argb32() { - var source = new Argb32(1, 22, 33, 231); + Argb32 source = new(1, 22, 33, 231); // Act: - var color = Color.FromPixel(source); + Color color = Color.FromPixel(source); // Assert: Argb32 data = color.ToPixel(); @@ -52,10 +52,10 @@ public void Argb32() [Fact] public void Bgra32() { - var source = new Bgra32(1, 22, 33, 231); + Bgra32 source = new(1, 22, 33, 231); // Act: - var color = Color.FromPixel(source); + Color color = Color.FromPixel(source); // Assert: Bgra32 data = color.ToPixel(); @@ -65,10 +65,10 @@ public void Bgra32() [Fact] public void Abgr32() { - var source = new Abgr32(1, 22, 33, 231); + Abgr32 source = new(1, 22, 33, 231); // Act: - var color = Color.FromPixel(source); + Color color = Color.FromPixel(source); // Assert: Abgr32 data = color.ToPixel(); @@ -78,10 +78,10 @@ public void Abgr32() [Fact] public void Rgb24() { - var source = new Rgb24(1, 22, 231); + Rgb24 source = new(1, 22, 231); // Act: - var color = Color.FromPixel(source); + Color color = Color.FromPixel(source); // Assert: Rgb24 data = color.ToPixel(); @@ -91,10 +91,10 @@ public void Rgb24() [Fact] public void Bgr24() { - var source = new Bgr24(1, 22, 231); + Bgr24 source = new(1, 22, 231); // Act: - var color = Color.FromPixel(source); + Color color = Color.FromPixel(source); // Assert: Bgr24 data = color.ToPixel(); @@ -108,10 +108,10 @@ public void Vector4Constructor() Color color = Color.FromScaledVector(Vector4.One); // Assert: - Assert.Equal(new RgbaVector(1, 1, 1, 1), color.ToPixel()); - Assert.Equal(new Rgba64(65535, 65535, 65535, 65535), color.ToPixel()); - Assert.Equal(new Rgba32(255, 255, 255, 255), color.ToPixel()); - Assert.Equal(new L8(255), color.ToPixel()); + Assert.Equal(new(1, 1, 1, 1), color.ToPixel()); + Assert.Equal(new(65535, 65535, 65535, 65535), color.ToPixel()); + Assert.Equal(new(255, 255, 255, 255), color.ToPixel()); + Assert.Equal(new(255), color.ToPixel()); } [Fact] @@ -129,7 +129,7 @@ private static void AssertGenericPixelRoundTrip(TPixel source) where TPixel : unmanaged, IPixel { // Act: - var color = Color.FromPixel(source); + Color color = Color.FromPixel(source); // Assert: TPixel actual = color.ToPixel(); @@ -150,7 +150,7 @@ private static void AssertGenericPixelDifferentPrecision(TPixel where TPixel2 : unmanaged, IPixel { // Act: - var color = Color.FromPixel(source); + Color color = Color.FromPixel(source); // Assert: TPixel2 actual = color.ToPixel(); diff --git a/tests/ImageSharp.Tests/Color/ColorTests.cs b/tests/ImageSharp.Tests/Color/ColorTests.cs index d430df5b44..8b636ee39f 100644 --- a/tests/ImageSharp.Tests/Color/ColorTests.cs +++ b/tests/ImageSharp.Tests/Color/ColorTests.cs @@ -108,29 +108,29 @@ public class FromHex [Fact] public void ShortHex() { - Assert.Equal(new Rgb24(255, 255, 255), Color.ParseHex("#fff").ToPixel()); - Assert.Equal(new Rgb24(255, 255, 255), Color.ParseHex("fff").ToPixel()); - Assert.Equal(new Rgba32(0, 0, 0, 255), Color.ParseHex("000f").ToPixel()); + Assert.Equal(new(255, 255, 255), Color.ParseHex("#fff").ToPixel()); + Assert.Equal(new(255, 255, 255), Color.ParseHex("fff").ToPixel()); + Assert.Equal(new(0, 0, 0, 255), Color.ParseHex("000f").ToPixel()); } [Fact] public void TryShortHex() { Assert.True(Color.TryParseHex("#fff", out Color actual)); - Assert.Equal(new Rgb24(255, 255, 255), actual.ToPixel()); + Assert.Equal(new(255, 255, 255), actual.ToPixel()); Assert.True(Color.TryParseHex("fff", out actual)); - Assert.Equal(new Rgb24(255, 255, 255), actual.ToPixel()); + Assert.Equal(new(255, 255, 255), actual.ToPixel()); Assert.True(Color.TryParseHex("000f", out actual)); - Assert.Equal(new Rgba32(0, 0, 0, 255), actual.ToPixel()); + Assert.Equal(new(0, 0, 0, 255), actual.ToPixel()); } [Fact] public void LeadingPoundIsOptional() { - Assert.Equal(new Rgb24(0, 128, 128), Color.ParseHex("#008080").ToPixel()); - Assert.Equal(new Rgb24(0, 128, 128), Color.ParseHex("008080").ToPixel()); + Assert.Equal(new(0, 128, 128), Color.ParseHex("#008080").ToPixel()); + Assert.Equal(new(0, 128, 128), Color.ParseHex("008080").ToPixel()); } [Fact] diff --git a/tests/ImageSharp.Tests/Color/ReferencePalette.cs b/tests/ImageSharp.Tests/Color/ReferencePalette.cs index 8e26961092..88787afd4f 100644 --- a/tests/ImageSharp.Tests/Color/ReferencePalette.cs +++ b/tests/ImageSharp.Tests/Color/ReferencePalette.cs @@ -9,7 +9,7 @@ internal static class ReferencePalette /// Gets a collection of named, web safe, colors as defined in the CSS Color Module Level 4. /// public static readonly Color[] WebSafeColors = - { + [ Color.AliceBlue, Color.AntiqueWhite, Color.Aqua, @@ -152,14 +152,14 @@ internal static class ReferencePalette Color.WhiteSmoke, Color.Yellow, Color.YellowGreen - }; + ]; /// /// Gets a collection of colors as defined in the original second edition of Werner’s Nomenclature of Colours 1821. /// The hex codes were collected and defined by Nicholas Rougeux /// public static readonly Color[] WernerColors = - { + [ Color.ParseHex("#f1e9cd"), Color.ParseHex("#f2e7cf"), Color.ParseHex("#ece6d0"), @@ -270,10 +270,10 @@ internal static class ReferencePalette Color.ParseHex("#9b856b"), Color.ParseHex("#766051"), Color.ParseHex("#453b32") - }; + ]; public static readonly Dictionary ColorNames = - new Dictionary(StringComparer.OrdinalIgnoreCase) + new(StringComparer.OrdinalIgnoreCase) { { nameof(Color.AliceBlue), Color.AliceBlue }, { nameof(Color.AntiqueWhite), Color.AntiqueWhite }, diff --git a/tests/ImageSharp.Tests/ColorProfiles/CieLabTests.cs b/tests/ImageSharp.Tests/ColorProfiles/CieLabTests.cs index 3c015259b1..4c1ffcaae3 100644 --- a/tests/ImageSharp.Tests/ColorProfiles/CieLabTests.cs +++ b/tests/ImageSharp.Tests/ColorProfiles/CieLabTests.cs @@ -34,8 +34,8 @@ public void CieLabEquality() Assert.True(new CieLab(1, 0, 1) != default); Assert.False(new CieLab(1, 0, 1) == default); Assert.Equal(default, default(CieLab)); - Assert.Equal(new CieLab(1, 0, 1), new CieLab(1, 0, 1)); - Assert.Equal(new CieLab(Vector3.One), new CieLab(Vector3.One)); + Assert.Equal(new(1, 0, 1), new CieLab(1, 0, 1)); + Assert.Equal(new(Vector3.One), new CieLab(Vector3.One)); Assert.False(x.Equals(y)); Assert.False(new CieLab(1, 0, 1) == default); Assert.False(x.Equals((object)y)); diff --git a/tests/ImageSharp.Tests/ColorProfiles/CieLchTests.cs b/tests/ImageSharp.Tests/ColorProfiles/CieLchTests.cs index 484db3e8cf..e2bf8655e5 100644 --- a/tests/ImageSharp.Tests/ColorProfiles/CieLchTests.cs +++ b/tests/ImageSharp.Tests/ColorProfiles/CieLchTests.cs @@ -33,8 +33,8 @@ public void CieLchEquality() Assert.True(default == default(CieLch)); Assert.False(default != default(CieLch)); Assert.Equal(default, default(CieLch)); - Assert.Equal(new CieLch(1, 0, 1), new CieLch(1, 0, 1)); - Assert.Equal(new CieLch(Vector3.One), new CieLch(Vector3.One)); + Assert.Equal(new(1, 0, 1), new CieLch(1, 0, 1)); + Assert.Equal(new(Vector3.One), new CieLch(Vector3.One)); Assert.False(x.Equals(y)); Assert.False(x.Equals((object)y)); Assert.False(x.GetHashCode().Equals(y.GetHashCode())); diff --git a/tests/ImageSharp.Tests/ColorProfiles/CieLchuvTests.cs b/tests/ImageSharp.Tests/ColorProfiles/CieLchuvTests.cs index 0b737cdfca..167fe51239 100644 --- a/tests/ImageSharp.Tests/ColorProfiles/CieLchuvTests.cs +++ b/tests/ImageSharp.Tests/ColorProfiles/CieLchuvTests.cs @@ -33,8 +33,8 @@ public void CieLchuvEquality() Assert.True(default == default(CieLchuv)); Assert.False(default != default(CieLchuv)); Assert.Equal(default, default(CieLchuv)); - Assert.Equal(new CieLchuv(1, 0, 1), new CieLchuv(1, 0, 1)); - Assert.Equal(new CieLchuv(Vector3.One), new CieLchuv(Vector3.One)); + Assert.Equal(new(1, 0, 1), new CieLchuv(1, 0, 1)); + Assert.Equal(new(Vector3.One), new CieLchuv(Vector3.One)); Assert.False(x.Equals(y)); Assert.False(x.Equals((object)y)); Assert.False(x.GetHashCode().Equals(y.GetHashCode())); diff --git a/tests/ImageSharp.Tests/ColorProfiles/CieLuvTests.cs b/tests/ImageSharp.Tests/ColorProfiles/CieLuvTests.cs index db903a0bf5..c1f137c2ce 100644 --- a/tests/ImageSharp.Tests/ColorProfiles/CieLuvTests.cs +++ b/tests/ImageSharp.Tests/ColorProfiles/CieLuvTests.cs @@ -33,8 +33,8 @@ public void CieLuvEquality() Assert.True(default == default(CieLuv)); Assert.False(default != default(CieLuv)); Assert.Equal(default, default(CieLuv)); - Assert.Equal(new CieLuv(1, 0, 1), new CieLuv(1, 0, 1)); - Assert.Equal(new CieLuv(Vector3.One), new CieLuv(Vector3.One)); + Assert.Equal(new(1, 0, 1), new CieLuv(1, 0, 1)); + Assert.Equal(new(Vector3.One), new CieLuv(Vector3.One)); Assert.False(x.Equals(y)); Assert.False(x.Equals((object)y)); Assert.False(x.GetHashCode().Equals(y.GetHashCode())); diff --git a/tests/ImageSharp.Tests/ColorProfiles/CieXyChromaticityCoordinatesTests.cs b/tests/ImageSharp.Tests/ColorProfiles/CieXyChromaticityCoordinatesTests.cs index a85a08a21e..deca959bae 100644 --- a/tests/ImageSharp.Tests/ColorProfiles/CieXyChromaticityCoordinatesTests.cs +++ b/tests/ImageSharp.Tests/ColorProfiles/CieXyChromaticityCoordinatesTests.cs @@ -31,8 +31,8 @@ public void CieXyChromaticityCoordinatesEquality() Assert.True(new CieXyChromaticityCoordinates(1, 0) != default); Assert.False(new CieXyChromaticityCoordinates(1, 0) == default); Assert.Equal(default, default(CieXyChromaticityCoordinates)); - Assert.Equal(new CieXyChromaticityCoordinates(1, 0), new CieXyChromaticityCoordinates(1, 0)); - Assert.Equal(new CieXyChromaticityCoordinates(1, 1), new CieXyChromaticityCoordinates(1, 1)); + Assert.Equal(new(1, 0), new CieXyChromaticityCoordinates(1, 0)); + Assert.Equal(new(1, 1), new CieXyChromaticityCoordinates(1, 1)); Assert.False(x.Equals(y)); Assert.False(new CieXyChromaticityCoordinates(1, 0) == default); Assert.False(x.Equals((object)y)); diff --git a/tests/ImageSharp.Tests/ColorProfiles/CieXyyTests.cs b/tests/ImageSharp.Tests/ColorProfiles/CieXyyTests.cs index 245512f8a8..e15736d17e 100644 --- a/tests/ImageSharp.Tests/ColorProfiles/CieXyyTests.cs +++ b/tests/ImageSharp.Tests/ColorProfiles/CieXyyTests.cs @@ -33,8 +33,8 @@ public void CieXyyEquality() Assert.True(default == default(CieXyy)); Assert.False(default != default(CieXyy)); Assert.Equal(default, default(CieXyy)); - Assert.Equal(new CieXyy(1, 0, 1), new CieXyy(1, 0, 1)); - Assert.Equal(new CieXyy(Vector3.One), new CieXyy(Vector3.One)); + Assert.Equal(new(1, 0, 1), new CieXyy(1, 0, 1)); + Assert.Equal(new(Vector3.One), new CieXyy(Vector3.One)); Assert.False(x.Equals(y)); Assert.False(x.Equals((object)y)); Assert.False(x.GetHashCode().Equals(y.GetHashCode())); diff --git a/tests/ImageSharp.Tests/ColorProfiles/CieXyzTests.cs b/tests/ImageSharp.Tests/ColorProfiles/CieXyzTests.cs index 88138304a8..7634d97106 100644 --- a/tests/ImageSharp.Tests/ColorProfiles/CieXyzTests.cs +++ b/tests/ImageSharp.Tests/ColorProfiles/CieXyzTests.cs @@ -33,8 +33,8 @@ public void CieXyzEquality() Assert.True(default == default(CieXyz)); Assert.False(default != default(CieXyz)); Assert.Equal(default, default(CieXyz)); - Assert.Equal(new CieXyz(1, 0, 1), new CieXyz(1, 0, 1)); - Assert.Equal(new CieXyz(Vector3.One), new CieXyz(Vector3.One)); + Assert.Equal(new(1, 0, 1), new CieXyz(1, 0, 1)); + Assert.Equal(new(Vector3.One), new CieXyz(Vector3.One)); Assert.False(x.Equals(y)); Assert.False(x.Equals((object)y)); Assert.False(x.GetHashCode().Equals(y.GetHashCode())); diff --git a/tests/ImageSharp.Tests/ColorProfiles/CmykTests.cs b/tests/ImageSharp.Tests/ColorProfiles/CmykTests.cs index e2044a75d0..7de9cbacc8 100644 --- a/tests/ImageSharp.Tests/ColorProfiles/CmykTests.cs +++ b/tests/ImageSharp.Tests/ColorProfiles/CmykTests.cs @@ -35,8 +35,8 @@ public void CmykEquality() Assert.True(default == default(Cmyk)); Assert.False(default != default(Cmyk)); Assert.Equal(default, default(Cmyk)); - Assert.Equal(new Cmyk(1, 0, 1, 0), new Cmyk(1, 0, 1, 0)); - Assert.Equal(new Cmyk(Vector4.One), new Cmyk(Vector4.One)); + Assert.Equal(new(1, 0, 1, 0), new Cmyk(1, 0, 1, 0)); + Assert.Equal(new(Vector4.One), new Cmyk(Vector4.One)); Assert.False(x.Equals(y)); Assert.False(x.Equals((object)y)); Assert.False(x.GetHashCode().Equals(y.GetHashCode())); diff --git a/tests/ImageSharp.Tests/ColorProfiles/CompandingTests.cs b/tests/ImageSharp.Tests/ColorProfiles/CompandingTests.cs index 1bdefa1095..24b221155e 100644 --- a/tests/ImageSharp.Tests/ColorProfiles/CompandingTests.cs +++ b/tests/ImageSharp.Tests/ColorProfiles/CompandingTests.cs @@ -102,7 +102,7 @@ public void LCompanding_IsCorrect() private static void CompandingIsCorrectImpl(Vector4 e, Vector4 c, float expanded, Vector4 compressed) { // W (alpha) is already the linear representation of the color. - Assert.Equal(new Vector4(expanded, expanded, expanded, e.W), e, Comparer); + Assert.Equal(new(expanded, expanded, expanded, e.W), e, Comparer); Assert.Equal(compressed, c, Comparer); } } diff --git a/tests/ImageSharp.Tests/ColorProfiles/HslTests.cs b/tests/ImageSharp.Tests/ColorProfiles/HslTests.cs index d18e65117e..cdf4ac0d4f 100644 --- a/tests/ImageSharp.Tests/ColorProfiles/HslTests.cs +++ b/tests/ImageSharp.Tests/ColorProfiles/HslTests.cs @@ -33,8 +33,8 @@ public void HslEquality() Assert.True(default == default(Hsl)); Assert.False(default != default(Hsl)); Assert.Equal(default, default(Hsl)); - Assert.Equal(new Hsl(1, 0, 1), new Hsl(1, 0, 1)); - Assert.Equal(new Hsl(Vector3.One), new Hsl(Vector3.One)); + Assert.Equal(new(1, 0, 1), new Hsl(1, 0, 1)); + Assert.Equal(new(Vector3.One), new Hsl(Vector3.One)); Assert.False(x.Equals(y)); Assert.False(x.Equals((object)y)); Assert.False(x.GetHashCode().Equals(y.GetHashCode())); diff --git a/tests/ImageSharp.Tests/ColorProfiles/HsvTests.cs b/tests/ImageSharp.Tests/ColorProfiles/HsvTests.cs index 46f58b18e2..2cf17c724a 100644 --- a/tests/ImageSharp.Tests/ColorProfiles/HsvTests.cs +++ b/tests/ImageSharp.Tests/ColorProfiles/HsvTests.cs @@ -33,8 +33,8 @@ public void HsvEquality() Assert.True(default == default(Hsv)); Assert.False(default != default(Hsv)); Assert.Equal(default, default(Hsv)); - Assert.Equal(new Hsv(1, 0, 1), new Hsv(1, 0, 1)); - Assert.Equal(new Hsv(Vector3.One), new Hsv(Vector3.One)); + Assert.Equal(new(1, 0, 1), new Hsv(1, 0, 1)); + Assert.Equal(new(Vector3.One), new Hsv(Vector3.One)); Assert.False(x.Equals(y)); Assert.False(x.Equals((object)y)); Assert.False(x.GetHashCode().Equals(y.GetHashCode())); diff --git a/tests/ImageSharp.Tests/ColorProfiles/HunterLabTests.cs b/tests/ImageSharp.Tests/ColorProfiles/HunterLabTests.cs index 5fbdd0788f..92b06d2936 100644 --- a/tests/ImageSharp.Tests/ColorProfiles/HunterLabTests.cs +++ b/tests/ImageSharp.Tests/ColorProfiles/HunterLabTests.cs @@ -34,8 +34,8 @@ public void HunterLabEquality() Assert.True(new HunterLab(1, 0, 1) != default); Assert.False(new HunterLab(1, 0, 1) == default); Assert.Equal(default, default(HunterLab)); - Assert.Equal(new HunterLab(1, 0, 1), new HunterLab(1, 0, 1)); - Assert.Equal(new HunterLab(Vector3.One), new HunterLab(Vector3.One)); + Assert.Equal(new(1, 0, 1), new HunterLab(1, 0, 1)); + Assert.Equal(new(Vector3.One), new HunterLab(Vector3.One)); Assert.False(x.Equals(y)); Assert.False(x.Equals((object)y)); Assert.False(x.GetHashCode().Equals(y.GetHashCode())); diff --git a/tests/ImageSharp.Tests/ColorProfiles/LmsTests.cs b/tests/ImageSharp.Tests/ColorProfiles/LmsTests.cs index 138fd544da..79f10e5a43 100644 --- a/tests/ImageSharp.Tests/ColorProfiles/LmsTests.cs +++ b/tests/ImageSharp.Tests/ColorProfiles/LmsTests.cs @@ -34,8 +34,8 @@ public void LmsEquality() Assert.True(new Lms(1, 0, 1) != default); Assert.False(new Lms(1, 0, 1) == default); Assert.Equal(default, default(Lms)); - Assert.Equal(new Lms(1, 0, 1), new Lms(1, 0, 1)); - Assert.Equal(new Lms(Vector3.One), new Lms(Vector3.One)); + Assert.Equal(new(1, 0, 1), new Lms(1, 0, 1)); + Assert.Equal(new(Vector3.One), new Lms(Vector3.One)); Assert.False(x.Equals(y)); Assert.False(x.Equals((object)y)); Assert.False(x.GetHashCode().Equals(y.GetHashCode())); diff --git a/tests/ImageSharp.Tests/ColorProfiles/RgbTests.cs b/tests/ImageSharp.Tests/ColorProfiles/RgbTests.cs index 7e4d4ee0e7..094fcd3027 100644 --- a/tests/ImageSharp.Tests/ColorProfiles/RgbTests.cs +++ b/tests/ImageSharp.Tests/ColorProfiles/RgbTests.cs @@ -34,8 +34,8 @@ public void RgbEquality() Assert.True(default == default(Rgb)); Assert.False(default != default(Rgb)); Assert.Equal(default, default(Rgb)); - Assert.Equal(new Rgb(1, 0, 1), new Rgb(1, 0, 1)); - Assert.Equal(new Rgb(Vector3.One), new Rgb(Vector3.One)); + Assert.Equal(new(1, 0, 1), new Rgb(1, 0, 1)); + Assert.Equal(new(Vector3.One), new Rgb(Vector3.One)); Assert.False(x.Equals(y)); Assert.False(x.Equals((object)y)); Assert.False(x.GetHashCode().Equals(y.GetHashCode())); diff --git a/tests/ImageSharp.Tests/ColorProfiles/StringRepresentationTests.cs b/tests/ImageSharp.Tests/ColorProfiles/StringRepresentationTests.cs index 770c987dba..2cc6227025 100644 --- a/tests/ImageSharp.Tests/ColorProfiles/StringRepresentationTests.cs +++ b/tests/ImageSharp.Tests/ColorProfiles/StringRepresentationTests.cs @@ -48,7 +48,7 @@ public class StringRepresentationTests { new HunterLab(Random), "HunterLab(42.4, 94.5, 83.4)" }, { new Lms(Random), "Lms(42.4, 94.5, 83.4)" }, { new Rgb(Random), "Rgb(42.4, 94.5, 83.4)" }, - { Rgb.Clamp(new Rgb(Random)), "Rgb(1, 1, 1)" }, + { Rgb.Clamp(new(Random)), "Rgb(1, 1, 1)" }, { new Hsl(Random), "Hsl(42.4, 1, 1)" }, // clamping to 1 is expected { new Hsv(Random), "Hsv(42.4, 1, 1)" }, // clamping to 1 is expected { new YCbCr(Random), "YCbCr(42.4, 94.5, 83.4)" }, diff --git a/tests/ImageSharp.Tests/ColorProfiles/YCbCrTests.cs b/tests/ImageSharp.Tests/ColorProfiles/YCbCrTests.cs index f8404ad948..b95d23d4b3 100644 --- a/tests/ImageSharp.Tests/ColorProfiles/YCbCrTests.cs +++ b/tests/ImageSharp.Tests/ColorProfiles/YCbCrTests.cs @@ -33,8 +33,8 @@ public void YCbCrEquality() Assert.True(default == default(YCbCr)); Assert.False(default != default(YCbCr)); Assert.Equal(default, default(YCbCr)); - Assert.Equal(new YCbCr(1, 0, 1), new YCbCr(1, 0, 1)); - Assert.Equal(new YCbCr(Vector3.One), new YCbCr(Vector3.One)); + Assert.Equal(new(1, 0, 1), new YCbCr(1, 0, 1)); + Assert.Equal(new(Vector3.One), new YCbCr(Vector3.One)); Assert.False(x.Equals(y)); Assert.False(x.Equals((object)y)); Assert.False(x.GetHashCode().Equals(y.GetHashCode())); diff --git a/tests/ImageSharp.Tests/Common/EncoderExtensionsTests.cs b/tests/ImageSharp.Tests/Common/EncoderExtensionsTests.cs index 190bfe1dc6..943c643c15 100644 --- a/tests/ImageSharp.Tests/Common/EncoderExtensionsTests.cs +++ b/tests/ImageSharp.Tests/Common/EncoderExtensionsTests.cs @@ -10,7 +10,7 @@ public class EncoderExtensionsTests [Fact] public void GetString_EmptyBuffer_ReturnsEmptyString() { - var buffer = default(ReadOnlySpan); + ReadOnlySpan buffer = default(ReadOnlySpan); string result = Encoding.UTF8.GetString(buffer); @@ -20,7 +20,7 @@ public void GetString_EmptyBuffer_ReturnsEmptyString() [Fact] public void GetString_Buffer_ReturnsString() { - var buffer = new ReadOnlySpan(new byte[] { 73, 109, 97, 103, 101, 83, 104, 97, 114, 112 }); + ReadOnlySpan buffer = new([73, 109, 97, 103, 101, 83, 104, 97, 114, 112]); string result = Encoding.UTF8.GetString(buffer); diff --git a/tests/ImageSharp.Tests/Common/NumericsTests.cs b/tests/ImageSharp.Tests/Common/NumericsTests.cs index 2b92769436..ebee570600 100644 --- a/tests/ImageSharp.Tests/Common/NumericsTests.cs +++ b/tests/ImageSharp.Tests/Common/NumericsTests.cs @@ -28,7 +28,7 @@ public void DivideCeil_DivideZero() [InlineData(1, 100)] public void DivideCeil_RandomValues(int seed, int count) { - var rng = new Random(seed); + Random rng = new(seed); for (int i = 0; i < count; i++) { uint value = (uint)rng.Next(); diff --git a/tests/ImageSharp.Tests/Common/SimdUtilsTests.cs b/tests/ImageSharp.Tests/Common/SimdUtilsTests.cs index 36b3012640..e4d9a04b45 100644 --- a/tests/ImageSharp.Tests/Common/SimdUtilsTests.cs +++ b/tests/ImageSharp.Tests/Common/SimdUtilsTests.cs @@ -51,7 +51,7 @@ private static Vector CreateExactTestVector1() data[i] = data[i - 4] + 100f; } - return new Vector(data); + return new(data); } private static Vector CreateRandomTestVector(int seed, float min, float max) @@ -66,7 +66,7 @@ private static Vector CreateRandomTestVector(int seed, float min, float m data[i] = v; } - return new Vector(data); + return new(data); } [Fact] @@ -287,7 +287,7 @@ internal static void TestPackFromRgbPlanes(int count, Action false; - public List Counts = new List(); + public List Counts = []; public NonSeekableStream() : base(4) diff --git a/tests/ImageSharp.Tests/ConfigurationTests.cs b/tests/ImageSharp.Tests/ConfigurationTests.cs index c8e6cd2657..b90579a024 100644 --- a/tests/ImageSharp.Tests/ConfigurationTests.cs +++ b/tests/ImageSharp.Tests/ConfigurationTests.cs @@ -27,7 +27,7 @@ public ConfigurationTests() // The shallow copy of configuration should behave exactly like the default configuration, // so by using the copy, we test both the default and the copy. this.DefaultConfiguration = Configuration.CreateDefaultInstance().Clone(); - this.ConfigurationEmpty = new Configuration(); + this.ConfigurationEmpty = new(); } [Fact] @@ -58,7 +58,7 @@ public void TestDefaultConfigurationMaxDegreeOfParallelism() { Assert.True(this.DefaultConfiguration.MaxDegreeOfParallelism == Environment.ProcessorCount); - var cfg = new Configuration(); + Configuration cfg = new(); Assert.True(cfg.MaxDegreeOfParallelism == Environment.ProcessorCount); } @@ -71,7 +71,7 @@ public void TestDefaultConfigurationMaxDegreeOfParallelism() [InlineData(5, false)] public void MaxDegreeOfParallelism_CompatibleWith_ParallelOptions(int maxDegreeOfParallelism, bool throws) { - var cfg = new Configuration(); + Configuration cfg = new(); if (throws) { Assert.Throws( @@ -87,8 +87,8 @@ public void MaxDegreeOfParallelism_CompatibleWith_ParallelOptions(int maxDegreeO [Fact] public void ConstructorCallConfigureOnFormatProvider() { - var provider = new Mock(); - var config = new Configuration(provider.Object); + Mock provider = new(); + Configuration config = new(provider.Object); provider.Verify(x => x.Configure(config)); } @@ -96,8 +96,8 @@ public void ConstructorCallConfigureOnFormatProvider() [Fact] public void AddFormatCallsConfig() { - var provider = new Mock(); - var config = new Configuration(); + Mock provider = new(); + Configuration config = new(); config.Configure(provider.Object); provider.Verify(x => x.Configure(config)); @@ -118,7 +118,7 @@ public void ConfigurationCannotAddDuplicates() [Fact] public void DefaultConfigurationHasCorrectFormatCount() { - var config = Configuration.CreateDefaultInstance(); + Configuration config = Configuration.CreateDefaultInstance(); Assert.Equal(this.expectedDefaultConfigurationCount, config.ImageFormats.Count()); } @@ -140,7 +140,7 @@ public void StreamBufferSize_DefaultIsCorrect() [Fact] public void StreamBufferSize_CannotGoBelowMinimum() { - var config = new Configuration(); + Configuration config = new(); Assert.Throws( () => config.StreamProcessingBufferSize = 0); @@ -150,14 +150,14 @@ public void StreamBufferSize_CannotGoBelowMinimum() public void MemoryAllocator_Setter_Roundtrips() { MemoryAllocator customAllocator = new SimpleGcMemoryAllocator(); - var config = new Configuration() { MemoryAllocator = customAllocator }; + Configuration config = new() { MemoryAllocator = customAllocator }; Assert.Same(customAllocator, config.MemoryAllocator); } [Fact] public void MemoryAllocator_SetNull_ThrowsArgumentNullException() { - var config = new Configuration(); + Configuration config = new(); Assert.Throws(() => config.MemoryAllocator = null); } @@ -168,9 +168,9 @@ public void InheritsDefaultMemoryAllocatorInstance() static void RunTest() { - var c1 = new Configuration(); - var c2 = new Configuration(new MockConfigurationModule()); - var c3 = Configuration.CreateDefaultInstance(); + Configuration c1 = new(); + Configuration c2 = new(new MockConfigurationModule()); + Configuration c3 = Configuration.CreateDefaultInstance(); Assert.Same(MemoryAllocator.Default, Configuration.Default.MemoryAllocator); Assert.Same(MemoryAllocator.Default, c1.MemoryAllocator); diff --git a/tests/ImageSharp.Tests/Drawing/DrawImageTests.cs b/tests/ImageSharp.Tests/Drawing/DrawImageTests.cs index 88f4cde7ac..2e2c30784c 100644 --- a/tests/ImageSharp.Tests/Drawing/DrawImageTests.cs +++ b/tests/ImageSharp.Tests/Drawing/DrawImageTests.cs @@ -195,9 +195,9 @@ public void Issue2447_A(TestImageProvider provider) where TPixel : unmanaged, IPixel { using Image foreground = provider.GetImage(); - using Image background = new(100, 100, new Rgba32(0, 255, 255)); + using Image background = new(100, 100, new(0, 255, 255)); - background.Mutate(c => c.DrawImage(foreground, new Point(64, 10), new Rectangle(32, 32, 32, 32), 1F)); + background.Mutate(c => c.DrawImage(foreground, new(64, 10), new Rectangle(32, 32, 32, 32), 1F)); background.DebugSave( provider, @@ -216,9 +216,9 @@ public void Issue2447_B(TestImageProvider provider) where TPixel : unmanaged, IPixel { using Image foreground = provider.GetImage(); - using Image background = new(100, 100, new Rgba32(0, 255, 255)); + using Image background = new(100, 100, new(0, 255, 255)); - background.Mutate(c => c.DrawImage(foreground, new Point(10, 10), new Rectangle(320, 128, 32, 32), 1F)); + background.Mutate(c => c.DrawImage(foreground, new(10, 10), new Rectangle(320, 128, 32, 32), 1F)); background.DebugSave( provider, @@ -237,9 +237,9 @@ public void Issue2447_C(TestImageProvider provider) where TPixel : unmanaged, IPixel { using Image foreground = provider.GetImage(); - using Image background = new(100, 100, new Rgba32(0, 255, 255)); + using Image background = new(100, 100, new(0, 255, 255)); - background.Mutate(c => c.DrawImage(foreground, new Point(10, 10), new Rectangle(32, 32, 32, 32), 1F)); + background.Mutate(c => c.DrawImage(foreground, new(10, 10), new Rectangle(32, 32, 32, 32), 1F)); background.DebugSave( provider, @@ -258,9 +258,9 @@ public void Issue2608_NegOffset(TestImageProvider provider) where TPixel : unmanaged, IPixel { using Image foreground = provider.GetImage(); - using Image background = new(100, 100, new Rgba32(0, 255, 255)); + using Image background = new(100, 100, new(0, 255, 255)); - background.Mutate(c => c.DrawImage(foreground, new Point(-10, -10), new Rectangle(32, 32, 32, 32), 1F)); + background.Mutate(c => c.DrawImage(foreground, new(-10, -10), new Rectangle(32, 32, 32, 32), 1F)); background.DebugSave( provider, @@ -279,9 +279,9 @@ public void Issue2603(TestImageProvider provider) where TPixel : unmanaged, IPixel { using Image foreground = provider.GetImage(); - using Image background = new(100, 100, new Rgba32(0, 255, 255)); + using Image background = new(100, 100, new(0, 255, 255)); - background.Mutate(c => c.DrawImage(foreground, new Point(80, 80), new Rectangle(32, 32, 32, 32), 1F)); + background.Mutate(c => c.DrawImage(foreground, new(80, 80), new Rectangle(32, 32, 32, 32), 1F)); background.DebugSave( provider, diff --git a/tests/ImageSharp.Tests/Formats/Bmp/BmpFileHeaderTests.cs b/tests/ImageSharp.Tests/Formats/Bmp/BmpFileHeaderTests.cs index d8ec7c9009..00a19466a3 100644 --- a/tests/ImageSharp.Tests/Formats/Bmp/BmpFileHeaderTests.cs +++ b/tests/ImageSharp.Tests/Formats/Bmp/BmpFileHeaderTests.cs @@ -11,9 +11,9 @@ public class BmpFileHeaderTests [Fact] public void TestWrite() { - var header = new BmpFileHeader(1, 2, 3, 4); + BmpFileHeader header = new(1, 2, 3, 4); - var buffer = new byte[14]; + byte[] buffer = new byte[14]; header.WriteTo(buffer); diff --git a/tests/ImageSharp.Tests/Formats/Bmp/ImageExtensionsTest.cs b/tests/ImageSharp.Tests/Formats/Bmp/ImageExtensionsTest.cs index 14b017bee1..988e8935a0 100644 --- a/tests/ImageSharp.Tests/Formats/Bmp/ImageExtensionsTest.cs +++ b/tests/ImageSharp.Tests/Formats/Bmp/ImageExtensionsTest.cs @@ -47,7 +47,7 @@ public void SaveAsBmp_Path_Encoder() using (Image image = new(10, 10)) { - image.SaveAsBmp(file, new BmpEncoder()); + image.SaveAsBmp(file, new()); } IImageFormat format = Image.DetectFormat(file); @@ -108,7 +108,7 @@ public void SaveAsBmp_Stream_Encoder() using (Image image = new(10, 10)) { - image.SaveAsBmp(memoryStream, new BmpEncoder()); + image.SaveAsBmp(memoryStream, new()); } memoryStream.Position = 0; diff --git a/tests/ImageSharp.Tests/Formats/GeneralFormatTests.cs b/tests/ImageSharp.Tests/Formats/GeneralFormatTests.cs index 27511f7beb..072b04fa0d 100644 --- a/tests/ImageSharp.Tests/Formats/GeneralFormatTests.cs +++ b/tests/ImageSharp.Tests/Formats/GeneralFormatTests.cs @@ -16,24 +16,23 @@ public class GeneralFormatTests /// A collection made up of one file for each image format. /// public static readonly IEnumerable DefaultFiles = - new[] - { - TestImages.Bmp.Car, + [ + TestImages.Bmp.Car, TestImages.Jpeg.Baseline.Calliphora, TestImages.Png.Splash, TestImages.Gif.Trans - }; + ]; /// /// The collection of image files to test against. /// - protected static readonly List Files = new() - { + protected static readonly List Files = + [ TestFile.Create(TestImages.Jpeg.Baseline.Calliphora), TestFile.Create(TestImages.Bmp.Car), TestFile.Create(TestImages.Png.Splash), - TestFile.Create(TestImages.Gif.Rings), - }; + TestFile.Create(TestImages.Gif.Rings) + ]; [Theory] [WithFileCollection(nameof(DefaultFiles), PixelTypes.Rgba32)] @@ -151,7 +150,7 @@ public void QuantizeImageShouldPreserveMaximumColorPrecision(TestImagePr private static IQuantizer GetQuantizer(string name) { PropertyInfo property = typeof(KnownQuantizers).GetTypeInfo().GetProperty(name); - return (IQuantizer)property.GetMethod.Invoke(null, Array.Empty()); + return (IQuantizer)property.GetMethod.Invoke(null, []); } [Fact] diff --git a/tests/ImageSharp.Tests/Formats/Gif/GifDecoderTests.cs b/tests/ImageSharp.Tests/Formats/Gif/GifDecoderTests.cs index f4e6487a57..19296db22e 100644 --- a/tests/ImageSharp.Tests/Formats/Gif/GifDecoderTests.cs +++ b/tests/ImageSharp.Tests/Formats/Gif/GifDecoderTests.cs @@ -20,9 +20,9 @@ public class GifDecoderTests private const PixelTypes TestPixelTypes = PixelTypes.Rgba32 | PixelTypes.RgbaVector | PixelTypes.Argb32; public static readonly string[] MultiFrameTestFiles = - { + [ TestImages.Gif.Giphy, TestImages.Gif.Kumin - }; + ]; [Theory] [WithFileCollection(nameof(MultiFrameTestFiles), PixelTypes.Rgba32)] diff --git a/tests/ImageSharp.Tests/Formats/Gif/GifEncoderTests.cs b/tests/ImageSharp.Tests/Formats/Gif/GifEncoderTests.cs index 77ac51e8a1..7b31dc9fb0 100644 --- a/tests/ImageSharp.Tests/Formats/Gif/GifEncoderTests.cs +++ b/tests/ImageSharp.Tests/Formats/Gif/GifEncoderTests.cs @@ -56,7 +56,7 @@ public void EncodeGeneratedPatterns(TestImageProvider provider, { // Use the palette quantizer without dithering to ensure results // are consistent - Quantizer = new WebSafePaletteQuantizer(new QuantizerOptions { Dither = null }) + Quantizer = new WebSafePaletteQuantizer(new() { Dither = null }) }; // Always save as we need to compare the encoded output. @@ -115,7 +115,7 @@ public void EncodeGlobalPaletteReturnsSmallerFile(TestImageProvider(TestImageProvider image = testFile.CreateRgba32Image(GifDecoder.Instance); GifMetadata metadata = image.Metadata.GetGifMetadata(); Assert.Equal(2, metadata.Comments.Count); - Assert.Equal(new string('c', 349), metadata.Comments[0]); + Assert.Equal(new('c', 349), metadata.Comments[0]); Assert.Equal("ImageSharp", metadata.Comments[1]); } @@ -104,7 +104,7 @@ public void Encode_PreservesTextData() using Image image = decoder.Decode(DecoderOptions.Default, memoryStream); GifMetadata metadata = image.Metadata.GetGifMetadata(); Assert.Equal(2, metadata.Comments.Count); - Assert.Equal(new string('c', 349), metadata.Comments[0]); + Assert.Equal(new('c', 349), metadata.Comments[0]); Assert.Equal("ImageSharp", metadata.Comments[1]); } diff --git a/tests/ImageSharp.Tests/Formats/Gif/ImageExtensionsTest.cs b/tests/ImageSharp.Tests/Formats/Gif/ImageExtensionsTest.cs index 97fdb38e76..d23efdd79d 100644 --- a/tests/ImageSharp.Tests/Formats/Gif/ImageExtensionsTest.cs +++ b/tests/ImageSharp.Tests/Formats/Gif/ImageExtensionsTest.cs @@ -47,7 +47,7 @@ public void SaveAsGif_Path_Encoder() using (Image image = new(10, 10)) { - image.SaveAsGif(file, new GifEncoder()); + image.SaveAsGif(file, new()); } IImageFormat format = Image.DetectFormat(file); @@ -108,7 +108,7 @@ public void SaveAsGif_Stream_Encoder() using (Image image = new(10, 10)) { - image.SaveAsGif(memoryStream, new GifEncoder()); + image.SaveAsGif(memoryStream, new()); } memoryStream.Position = 0; diff --git a/tests/ImageSharp.Tests/Formats/ImageFormatManagerTests.cs b/tests/ImageSharp.Tests/Formats/ImageFormatManagerTests.cs index 324bd4783a..480569c626 100644 --- a/tests/ImageSharp.Tests/Formats/ImageFormatManagerTests.cs +++ b/tests/ImageSharp.Tests/Formats/ImageFormatManagerTests.cs @@ -24,7 +24,7 @@ public class ImageFormatManagerTests public ImageFormatManagerTests() { this.DefaultFormatsManager = Configuration.CreateDefaultInstance().ImageFormatsManager; - this.FormatsManagerEmpty = new ImageFormatManager(); + this.FormatsManagerEmpty = new(); } [Fact] @@ -123,7 +123,7 @@ public void DetectFormatAllocatesCleanBuffer() IImageFormat format = Image.DetectFormat(jpegImage); Assert.IsType(format); - byte[] invalidImage = { 1, 2, 3 }; + byte[] invalidImage = [1, 2, 3]; Assert.Throws(() => Image.DetectFormat(invalidImage)); } } diff --git a/tests/ImageSharp.Tests/Formats/Jpg/AdobeMarkerTests.cs b/tests/ImageSharp.Tests/Formats/Jpg/AdobeMarkerTests.cs index 740b410feb..aee064ccc6 100644 --- a/tests/ImageSharp.Tests/Formats/Jpg/AdobeMarkerTests.cs +++ b/tests/ImageSharp.Tests/Formats/Jpg/AdobeMarkerTests.cs @@ -10,10 +10,10 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg; public class AdobeMarkerTests { // Taken from actual test image - private readonly byte[] bytes = { 0x41, 0x64, 0x6F, 0x62, 0x65, 0x0, 0x64, 0x0, 0x0, 0x0, 0x0, 0x2 }; + private readonly byte[] bytes = [0x41, 0x64, 0x6F, 0x62, 0x65, 0x0, 0x64, 0x0, 0x0, 0x0, 0x0, 0x2]; // Altered components - private readonly byte[] bytes2 = { 0x41, 0x64, 0x6F, 0x62, 0x65, 0x0, 0x64, 0x0, 0x0, 0x1, 0x1, 0x1 }; + private readonly byte[] bytes2 = [0x41, 0x64, 0x6F, 0x62, 0x65, 0x0, 0x64, 0x0, 0x0, 0x1, 0x1, 0x1]; [Fact] public void MarkerLengthIsCorrect() @@ -36,7 +36,7 @@ public void MarkerReturnsCorrectParsedValue() [Fact] public void MarkerIgnoresIncorrectValue() { - bool isAdobe = AdobeMarker.TryParse(new byte[] { 0, 0, 0, 0 }, out AdobeMarker marker); + bool isAdobe = AdobeMarker.TryParse([0, 0, 0, 0], out AdobeMarker marker); Assert.False(isAdobe); Assert.Equal(default, marker); diff --git a/tests/ImageSharp.Tests/Formats/Jpg/Block8x8FTests.cs b/tests/ImageSharp.Tests/Formats/Jpg/Block8x8FTests.cs index cde9e776b2..54d9882f46 100644 --- a/tests/ImageSharp.Tests/Formats/Jpg/Block8x8FTests.cs +++ b/tests/ImageSharp.Tests/Formats/Jpg/Block8x8FTests.cs @@ -43,7 +43,7 @@ public void Indexer() Times, () => { - var block = default(Block8x8F); + Block8x8F block = default(Block8x8F); for (int i = 0; i < Block8x8F.Size; i++) { @@ -240,7 +240,7 @@ public void RoundInto() float[] data = Create8x8RandomFloatData(-1000, 1000); Block8x8F source = Block8x8F.Load(data); - var dest = default(Block8x8); + Block8x8 dest = default(Block8x8); source.RoundInto(ref dest); @@ -352,7 +352,7 @@ public void LoadFromUInt16Scalar() short[] data = Create8x8ShortData(); - var source = Block8x8.Load(data); + Block8x8 source = Block8x8.Load(data); Block8x8F dest = default; dest.LoadFromInt16Scalar(ref source); @@ -373,7 +373,7 @@ public void LoadFromUInt16ExtendedAvx2() short[] data = Create8x8ShortData(); - var source = Block8x8.Load(data); + Block8x8 source = Block8x8.Load(data); Block8x8F dest = default; dest.LoadFromInt16ExtendedAvx2(ref source); diff --git a/tests/ImageSharp.Tests/Formats/Jpg/Block8x8Tests.cs b/tests/ImageSharp.Tests/Formats/Jpg/Block8x8Tests.cs index b5d364dd38..9481b75f3f 100644 --- a/tests/ImageSharp.Tests/Formats/Jpg/Block8x8Tests.cs +++ b/tests/ImageSharp.Tests/Formats/Jpg/Block8x8Tests.cs @@ -21,7 +21,7 @@ public void Construct_And_Indexer_Get() { short[] data = Create8x8ShortData(); - var block = Block8x8.Load(data); + Block8x8 block = Block8x8.Load(data); for (int i = 0; i < Block8x8.Size; i++) { @@ -47,7 +47,7 @@ public void AsFloatBlock() { short[] data = Create8x8ShortData(); - var source = Block8x8.Load(data); + Block8x8 source = Block8x8.Load(data); Block8x8F dest = source.AsFloatBlock(); @@ -61,7 +61,7 @@ public void AsFloatBlock() public void ToArray() { short[] data = Create8x8ShortData(); - var block = Block8x8.Load(data); + Block8x8 block = Block8x8.Load(data); short[] result = block.ToArray(); @@ -72,8 +72,8 @@ public void ToArray() public void Equality_WhenFalse() { short[] data = Create8x8ShortData(); - var block1 = Block8x8.Load(data); - var block2 = Block8x8.Load(data); + Block8x8 block1 = Block8x8.Load(data); + Block8x8 block2 = Block8x8.Load(data); block1[0] = 42; block2[0] = 666; @@ -96,8 +96,8 @@ public void IndexerXY() public void TotalDifference() { short[] data = Create8x8ShortData(); - var block1 = Block8x8.Load(data); - var block2 = Block8x8.Load(data); + Block8x8 block1 = Block8x8.Load(data); + Block8x8 block2 = Block8x8.Load(data); block2[10] += 7; block2[63] += 8; @@ -157,7 +157,7 @@ public void GetLastNonZeroIndex_RandomFilledSingle(int seed) static void RunTest(string seedSerialized) { int seed = FeatureTestRunner.Deserialize(seedSerialized); - var rng = new Random(seed); + Random rng = new(seed); for (int i = 0; i < 1000; i++) { @@ -188,7 +188,7 @@ public void GetLastNonZeroIndex_RandomFilledPartially(int seed) static void RunTest(string seedSerialized) { int seed = FeatureTestRunner.Deserialize(seedSerialized); - var rng = new Random(seed); + Random rng = new(seed); for (int i = 0; i < 1000; i++) { @@ -223,7 +223,7 @@ public void GetLastNonZeroIndex_RandomFilledFragmented(int seed) static void RunTest(string seedSerialized) { int seed = FeatureTestRunner.Deserialize(seedSerialized); - var rng = new Random(seed); + Random rng = new(seed); for (int i = 0; i < 1000; i++) { diff --git a/tests/ImageSharp.Tests/Formats/Jpg/DCTTests.cs b/tests/ImageSharp.Tests/Formats/Jpg/DCTTests.cs index 5a1488c411..71174a843c 100644 --- a/tests/ImageSharp.Tests/Formats/Jpg/DCTTests.cs +++ b/tests/ImageSharp.Tests/Formats/Jpg/DCTTests.cs @@ -46,7 +46,7 @@ public void LLM_TransformIDCT_CompareToNonOptimized(int seed) { float[] sourceArray = Create8x8RandomFloatData(MinInputValue, MaxInputValue, seed); - var srcBlock = Block8x8F.Load(sourceArray); + Block8x8F srcBlock = Block8x8F.Load(sourceArray); // reference Block8x8F expected = ReferenceImplementations.LLM_FloatingPoint_DCT.TransformIDCT(ref srcBlock); @@ -79,7 +79,7 @@ public void LLM_TransformIDCT_CompareToAccurate(int seed) { float[] sourceArray = Create8x8RandomFloatData(MinInputValue, MaxInputValue, seed); - var srcBlock = Block8x8F.Load(sourceArray); + Block8x8F srcBlock = Block8x8F.Load(sourceArray); // reference Block8x8F expected = ReferenceImplementations.AccurateDCT.TransformIDCT(ref srcBlock); diff --git a/tests/ImageSharp.Tests/Formats/Jpg/HuffmanScanEncoderTests.cs b/tests/ImageSharp.Tests/Formats/Jpg/HuffmanScanEncoderTests.cs index b89d9ad27a..36b792fa1c 100644 --- a/tests/ImageSharp.Tests/Formats/Jpg/HuffmanScanEncoderTests.cs +++ b/tests/ImageSharp.Tests/Formats/Jpg/HuffmanScanEncoderTests.cs @@ -69,7 +69,7 @@ public void GetHuffmanEncodingLength_Random(int seed) { int maxNumber = 1 << 16; - var rng = new Random(seed); + Random rng = new(seed); for (int i = 0; i < 1000; i++) { uint number = (uint)rng.Next(0, maxNumber); diff --git a/tests/ImageSharp.Tests/Formats/Jpg/ImageExtensionsTest.cs b/tests/ImageSharp.Tests/Formats/Jpg/ImageExtensionsTest.cs index b1f7997323..0d8bf3a743 100644 --- a/tests/ImageSharp.Tests/Formats/Jpg/ImageExtensionsTest.cs +++ b/tests/ImageSharp.Tests/Formats/Jpg/ImageExtensionsTest.cs @@ -48,7 +48,7 @@ public void SaveAsJpeg_Path_Encoder() using (Image image = new(10, 10)) { - image.SaveAsJpeg(file, new JpegEncoder()); + image.SaveAsJpeg(file, new()); } IImageFormat format = Image.DetectFormat(file); @@ -109,7 +109,7 @@ public void SaveAsJpeg_Stream_Encoder() using (Image image = new(10, 10)) { - image.SaveAsJpeg(memoryStream, new JpegEncoder()); + image.SaveAsJpeg(memoryStream, new()); } memoryStream.Position = 0; diff --git a/tests/ImageSharp.Tests/Formats/Jpg/JFifMarkerTests.cs b/tests/ImageSharp.Tests/Formats/Jpg/JFifMarkerTests.cs index 3b7e20eb4e..22b25a2bef 100644 --- a/tests/ImageSharp.Tests/Formats/Jpg/JFifMarkerTests.cs +++ b/tests/ImageSharp.Tests/Formats/Jpg/JFifMarkerTests.cs @@ -10,13 +10,13 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg; public class JFifMarkerTests { // Taken from actual test image - private readonly byte[] bytes = { 0x4A, 0x46, 0x49, 0x46, 0x0, 0x1, 0x1, 0x1, 0x0, 0x60, 0x0, 0x60, 0x0 }; + private readonly byte[] bytes = [0x4A, 0x46, 0x49, 0x46, 0x0, 0x1, 0x1, 0x1, 0x0, 0x60, 0x0, 0x60, 0x0]; // Altered components - private readonly byte[] bytes2 = { 0x4A, 0x46, 0x49, 0x46, 0x0, 0x1, 0x1, 0x1, 0x0, 0x48, 0x0, 0x48, 0x0 }; + private readonly byte[] bytes2 = [0x4A, 0x46, 0x49, 0x46, 0x0, 0x1, 0x1, 0x1, 0x0, 0x48, 0x0, 0x48, 0x0]; // Incorrect density values. Zero is invalid. - private readonly byte[] bytes3 = { 0x4A, 0x46, 0x49, 0x46, 0x0, 0x1, 0x1, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0 }; + private readonly byte[] bytes3 = [0x4A, 0x46, 0x49, 0x46, 0x0, 0x1, 0x1, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0]; [Fact] public void MarkerLengthIsCorrect() @@ -40,7 +40,7 @@ public void MarkerReturnsCorrectParsedValue() [Fact] public void MarkerIgnoresIncorrectValue() { - bool isJFif = JFifMarker.TryParse(new byte[] { 0, 0, 0, 0 }, out JFifMarker marker); + bool isJFif = JFifMarker.TryParse([0, 0, 0, 0], out JFifMarker marker); Assert.False(isJFif); Assert.Equal(default, marker); diff --git a/tests/ImageSharp.Tests/Formats/Jpg/JpegColorConverterTests.cs b/tests/ImageSharp.Tests/Formats/Jpg/JpegColorConverterTests.cs index 7aabdaa588..11f8733425 100644 --- a/tests/ImageSharp.Tests/Formats/Jpg/JpegColorConverterTests.cs +++ b/tests/ImageSharp.Tests/Formats/Jpg/JpegColorConverterTests.cs @@ -637,10 +637,10 @@ private static JpegColorConverterBase.ComponentValues CreateRandomValues( // no need to dispose when buffer is not array owner Memory memory = new(values); MemoryGroup source = MemoryGroup.Wrap(memory); - buffers[i] = new Buffer2D(source, values.Length, 1); + buffers[i] = new(source, values.Length, 1); } - return new JpegColorConverterBase.ComponentValues(buffers, 0); + return new(buffers, 0); } private static float[] CreateRandomValues(int length, Random rnd) @@ -791,7 +791,7 @@ private static void ValidateYCbCr(in JpegColorConverterBase.ComponentValues valu float y = values.Component0[i]; float cb = values.Component1[i]; float cr = values.Component2[i]; - Rgb expected = ColorSpaceConverter.Convert(new YCbCr(y, cb, cr)); + Rgb expected = ColorSpaceConverter.Convert(new(y, cb, cr)); Rgb actual = Rgb.Clamp(new(result.Component0[i], result.Component1[i], result.Component2[i])); diff --git a/tests/ImageSharp.Tests/Formats/Jpg/JpegDecoderTests.Images.cs b/tests/ImageSharp.Tests/Formats/Jpg/JpegDecoderTests.Images.cs index 85fad3f826..a4a71c6731 100644 --- a/tests/ImageSharp.Tests/Formats/Jpg/JpegDecoderTests.Images.cs +++ b/tests/ImageSharp.Tests/Formats/Jpg/JpegDecoderTests.Images.cs @@ -7,7 +7,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg; public partial class JpegDecoderTests { public static string[] BaselineTestJpegs = - { + [ TestImages.Jpeg.Baseline.Calliphora, TestImages.Jpeg.Baseline.Cmyk, TestImages.Jpeg.Baseline.Ycck, @@ -41,11 +41,11 @@ public partial class JpegDecoderTests TestImages.Jpeg.Baseline.Testorig12bit, // Grayscale jpeg with 2x2 sampling factors (not a usual thing to encounter in the wild) - TestImages.Jpeg.Baseline.GrayscaleSampling2x2, - }; + TestImages.Jpeg.Baseline.GrayscaleSampling2x2 + ]; public static string[] ProgressiveTestJpegs = - { + [ TestImages.Jpeg.Progressive.Fb, TestImages.Jpeg.Progressive.Progress, TestImages.Jpeg.Progressive.Festzug, @@ -61,20 +61,20 @@ public partial class JpegDecoderTests TestImages.Jpeg.Issues.OrderedInterleavedProgressive723A, TestImages.Jpeg.Issues.OrderedInterleavedProgressive723B, TestImages.Jpeg.Issues.OrderedInterleavedProgressive723C - }; + ]; public static string[] UnsupportedTestJpegs = - { + [ // Invalid componentCount value (2 or > 4) TestImages.Jpeg.Issues.Fuzz.NullReferenceException823, TestImages.Jpeg.Issues.MalformedUnsupportedComponentCount, // Lossless jpeg TestImages.Jpeg.Baseline.Lossless - }; + ]; public static string[] UnrecoverableTestJpegs = - { + [ TestImages.Jpeg.Issues.CriticalEOF214, TestImages.Jpeg.Issues.Fuzz.NullReferenceException797, TestImages.Jpeg.Issues.Fuzz.AccessViolationException798, @@ -98,8 +98,8 @@ public partial class JpegDecoderTests TestImages.Jpeg.Issues.Fuzz.IndexOutOfRangeException1693A, TestImages.Jpeg.Issues.Fuzz.IndexOutOfRangeException1693B, TestImages.Jpeg.Issues.Fuzz.IndexOutOfRangeException824C, - TestImages.Jpeg.Issues.Fuzz.NullReferenceException2085, - }; + TestImages.Jpeg.Issues.Fuzz.NullReferenceException2085 + ]; private static readonly Dictionary CustomToleranceValues = new() { diff --git a/tests/ImageSharp.Tests/Formats/Jpg/JpegDecoderTests.Internal.cs b/tests/ImageSharp.Tests/Formats/Jpg/JpegDecoderTests.Internal.cs index 6cf6250cb1..b780b14fb1 100644 --- a/tests/ImageSharp.Tests/Formats/Jpg/JpegDecoderTests.Internal.cs +++ b/tests/ImageSharp.Tests/Formats/Jpg/JpegDecoderTests.Internal.cs @@ -19,7 +19,7 @@ public partial class JpegDecoderTests [InlineData(4, JpegConstants.Adobe.ColorTransformYcck, JpegColorSpace.Ycck)] internal void DeduceJpegColorSpaceAdobeMarker_ShouldReturnValidColorSpace(byte componentCount, byte adobeFlag, JpegColorSpace expectedColorSpace) { - byte[] adobeMarkerPayload = new byte[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, adobeFlag }; + byte[] adobeMarkerPayload = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, adobeFlag]; ProfileResolver.AdobeMarker.CopyTo(adobeMarkerPayload); _ = AdobeMarker.TryParse(adobeMarkerPayload, out AdobeMarker adobeMarker); diff --git a/tests/ImageSharp.Tests/Formats/Jpg/JpegDecoderTests.Metadata.cs b/tests/ImageSharp.Tests/Formats/Jpg/JpegDecoderTests.Metadata.cs index a803372537..9a09ada4ab 100644 --- a/tests/ImageSharp.Tests/Formats/Jpg/JpegDecoderTests.Metadata.cs +++ b/tests/ImageSharp.Tests/Formats/Jpg/JpegDecoderTests.Metadata.cs @@ -400,10 +400,10 @@ public void EncodedStringTags_WriteAndRead() exif.SetValue(ExifTag.XPSubject, "This is a subject"); // exif.SetValue(ExifTag.UserComment, new EncodedString(EncodedString.CharacterCode.JIS, "ビッ")); - exif.SetValue(ExifTag.UserComment, new EncodedString(EncodedString.CharacterCode.JIS, "eng comment text (JIS)")); + exif.SetValue(ExifTag.UserComment, new(EncodedString.CharacterCode.JIS, "eng comment text (JIS)")); - exif.SetValue(ExifTag.GPSProcessingMethod, new EncodedString(EncodedString.CharacterCode.ASCII, "GPS processing method (ASCII)")); - exif.SetValue(ExifTag.GPSAreaInformation, new EncodedString(EncodedString.CharacterCode.Unicode, "GPS area info (Unicode)")); + exif.SetValue(ExifTag.GPSProcessingMethod, new(EncodedString.CharacterCode.ASCII, "GPS processing method (ASCII)")); + exif.SetValue(ExifTag.GPSAreaInformation, new(EncodedString.CharacterCode.Unicode, "GPS area info (Unicode)")); image.Metadata.ExifProfile = exif; @@ -441,7 +441,7 @@ public void JpegDecoder_DecodeMetadataComment(TestImageProvider image.CompareToOriginal(provider); } - + // https://github.com/SixLabors/ImageSharp/issues/2758 [Theory] [WithFile(TestImages.Jpeg.Issues.Issue2758, PixelTypes.L8)] diff --git a/tests/ImageSharp.Tests/Formats/Jpg/JpegDecoderTests.cs b/tests/ImageSharp.Tests/Formats/Jpg/JpegDecoderTests.cs index 950265bd56..ad015317b7 100644 --- a/tests/ImageSharp.Tests/Formats/Jpg/JpegDecoderTests.cs +++ b/tests/ImageSharp.Tests/Formats/Jpg/JpegDecoderTests.cs @@ -45,8 +45,8 @@ private static ImageComparer GetImageComparer(TestImageProvider private static bool SkipTest(ITestImageProvider provider) { string[] largeImagesToSkipOn32Bit = - { - TestImages.Jpeg.Baseline.Jpeg420Exif, + [ + TestImages.Jpeg.Baseline.Jpeg420Exif, TestImages.Jpeg.Issues.MissingFF00ProgressiveBedroom159, TestImages.Jpeg.Issues.BadZigZagProgressive385, TestImages.Jpeg.Issues.NoEoiProgressive517, @@ -54,7 +54,7 @@ private static bool SkipTest(ITestImageProvider provider) TestImages.Jpeg.Issues.InvalidEOI695, TestImages.Jpeg.Issues.ExifResizeOutOfRange696, TestImages.Jpeg.Issues.ExifGetString750Transform - }; + ]; return !TestEnvironment.Is64BitProcess && largeImagesToSkipOn32Bit.Contains(provider.SourceFileOrDescription); } diff --git a/tests/ImageSharp.Tests/Formats/Jpg/JpegEncoderTests.Metadata.cs b/tests/ImageSharp.Tests/Formats/Jpg/JpegEncoderTests.Metadata.cs index 039215bbc5..79926aa741 100644 --- a/tests/ImageSharp.Tests/Formats/Jpg/JpegEncoderTests.Metadata.cs +++ b/tests/ImageSharp.Tests/Formats/Jpg/JpegEncoderTests.Metadata.cs @@ -56,7 +56,7 @@ public void Encode_PreservesExifProfile() { // arrange using Image input = new(1, 1); - input.Metadata.ExifProfile = new ExifProfile(); + input.Metadata.ExifProfile = new(); input.Metadata.ExifProfile.SetValue(ExifTag.Software, "unit_test"); // act @@ -77,7 +77,7 @@ public void Encode_PreservesIccProfile() { // arrange using Image input = new(1, 1); - input.Metadata.IccProfile = new IccProfile(IccTestDataProfiles.Profile_Random_Array); + input.Metadata.IccProfile = new(IccTestDataProfiles.Profile_Random_Array); // act using MemoryStream memStream = new(); diff --git a/tests/ImageSharp.Tests/Formats/Jpg/JpegEncoderTests.cs b/tests/ImageSharp.Tests/Formats/Jpg/JpegEncoderTests.cs index 1f4b3e4656..fd21d74e02 100644 --- a/tests/ImageSharp.Tests/Formats/Jpg/JpegEncoderTests.cs +++ b/tests/ImageSharp.Tests/Formats/Jpg/JpegEncoderTests.cs @@ -200,8 +200,8 @@ public static void Issue2595(TestImageProvider provider) using Image image = provider.GetImage(); image.Mutate(x => x.Crop(132, 1606)); - int[] quality = new int[] { 100, 50 }; - JpegColorType[] colors = new[] { JpegColorType.YCbCrRatio444, JpegColorType.YCbCrRatio420 }; + int[] quality = [100, 50]; + JpegColorType[] colors = [JpegColorType.YCbCrRatio444, JpegColorType.YCbCrRatio420]; for (int i = 0; i < quality.Length; i++) { int q = quality[i]; diff --git a/tests/ImageSharp.Tests/Formats/Jpg/JpegFileMarkerTests.cs b/tests/ImageSharp.Tests/Formats/Jpg/JpegFileMarkerTests.cs index df74d266cb..62362ec801 100644 --- a/tests/ImageSharp.Tests/Formats/Jpg/JpegFileMarkerTests.cs +++ b/tests/ImageSharp.Tests/Formats/Jpg/JpegFileMarkerTests.cs @@ -14,7 +14,7 @@ public void MarkerConstructorAssignsProperties() { const byte app1 = JpegConstants.Markers.APP1; const int position = 5; - var marker = new JpegFileMarker(app1, position); + JpegFileMarker marker = new(app1, position); Assert.Equal(app1, marker.Marker); Assert.Equal(position, marker.Position); diff --git a/tests/ImageSharp.Tests/Formats/Jpg/JpegMetadataTests.cs b/tests/ImageSharp.Tests/Formats/Jpg/JpegMetadataTests.cs index 19b5265a17..6ea5288182 100644 --- a/tests/ImageSharp.Tests/Formats/Jpg/JpegMetadataTests.cs +++ b/tests/ImageSharp.Tests/Formats/Jpg/JpegMetadataTests.cs @@ -12,8 +12,8 @@ public class JpegMetadataTests [Fact] public void CloneIsDeep() { - var meta = new JpegMetadata { ColorType = JpegColorType.Luminance }; - var clone = (JpegMetadata)meta.DeepClone(); + JpegMetadata meta = new() { ColorType = JpegColorType.Luminance }; + JpegMetadata clone = (JpegMetadata)meta.DeepClone(); clone.ColorType = JpegColorType.YCbCrRatio420; @@ -23,7 +23,7 @@ public void CloneIsDeep() [Fact] public void Quality_DefaultQuality() { - var meta = new JpegMetadata(); + JpegMetadata meta = new(); Assert.Equal(meta.Quality, ImageSharp.Formats.Jpeg.Components.Quantization.DefaultQualityFactor); } @@ -33,7 +33,7 @@ public void Quality_LuminanceOnlyQuality() { int quality = 50; - var meta = new JpegMetadata { LuminanceQuality = quality }; + JpegMetadata meta = new() { LuminanceQuality = quality }; Assert.Equal(meta.Quality, quality); } @@ -43,7 +43,7 @@ public void Quality_BothComponentsQuality() { int quality = 50; - var meta = new JpegMetadata { LuminanceQuality = quality, ChrominanceQuality = quality }; + JpegMetadata meta = new() { LuminanceQuality = quality, ChrominanceQuality = quality }; Assert.Equal(meta.Quality, quality); } @@ -54,7 +54,7 @@ public void Quality_ReturnsMaxQuality() int qualityLuma = 50; int qualityChroma = 30; - var meta = new JpegMetadata { LuminanceQuality = qualityLuma, ChrominanceQuality = qualityChroma }; + JpegMetadata meta = new() { LuminanceQuality = qualityLuma, ChrominanceQuality = qualityChroma }; Assert.Equal(meta.Quality, qualityLuma); } @@ -62,7 +62,7 @@ public void Quality_ReturnsMaxQuality() [Fact] public void Comment_EmptyComment() { - var meta = new JpegMetadata(); + JpegMetadata meta = new(); Assert.True(Array.Empty().SequenceEqual(meta.Comments)); } @@ -71,9 +71,9 @@ public void Comment_EmptyComment() public void Comment_OnlyComment() { string comment = "test comment"; - var expectedCollection = new Collection { comment }; + Collection expectedCollection = [comment]; - var meta = new JpegMetadata(); + JpegMetadata meta = new(); meta.Comments.Add(JpegComData.FromString(comment)); Assert.Equal(1, meta.Comments.Count); diff --git a/tests/ImageSharp.Tests/Formats/Jpg/ParseStreamTests.cs b/tests/ImageSharp.Tests/Formats/Jpg/ParseStreamTests.cs index b202fd9ec3..b6a59fa93e 100644 --- a/tests/ImageSharp.Tests/Formats/Jpg/ParseStreamTests.cs +++ b/tests/ImageSharp.Tests/Formats/Jpg/ParseStreamTests.cs @@ -27,7 +27,7 @@ public ParseStreamTests(ITestOutputHelper output) [InlineData(TestImages.Jpeg.Baseline.Cmyk, JpegColorSpace.Cmyk)] public void ColorSpace_IsDeducedCorrectly(string imageFile, object expectedColorSpaceValue) { - var expectedColorSpace = (JpegColorSpace)expectedColorSpaceValue; + JpegColorSpace expectedColorSpace = (JpegColorSpace)expectedColorSpaceValue; using (JpegDecoderCore decoder = JpegFixture.ParseJpegStream(imageFile, metaDataOnly: true)) { @@ -47,7 +47,7 @@ public void ComponentScalingIsCorrect_1ChannelJpeg() Assert.Equal(expectedSizeInBlocks, decoder.Frame.McuSize); - var uniform1 = new Size(1, 1); + Size uniform1 = new(1, 1); IJpegComponent c0 = decoder.Components[0]; VerifyJpeg.VerifyComponent(c0, expectedSizeInBlocks, uniform1, uniform1); } @@ -62,7 +62,7 @@ public void ComponentScalingIsCorrect_1ChannelJpeg() [InlineData(TestImages.Jpeg.Baseline.Cmyk)] public void PrintComponentData(string imageFile) { - var sb = new StringBuilder(); + StringBuilder sb = new(); using (JpegDecoderCore decoder = JpegFixture.ParseJpegStream(imageFile)) { @@ -98,8 +98,8 @@ public void ComponentScalingIsCorrect_MultiChannelJpeg( object expectedLumaFactors, object expectedChromaFactors) { - var fLuma = (Size)expectedLumaFactors; - var fChroma = (Size)expectedChromaFactors; + Size fLuma = (Size)expectedLumaFactors; + Size fChroma = (Size)expectedChromaFactors; using (JpegDecoderCore decoder = JpegFixture.ParseJpegStream(imageFile)) { @@ -110,7 +110,7 @@ public void ComponentScalingIsCorrect_MultiChannelJpeg( IJpegComponent c1 = decoder.Components[1]; IJpegComponent c2 = decoder.Components[2]; - var uniform1 = new Size(1, 1); + Size uniform1 = new(1, 1); Size expectedLumaSizeInBlocks = decoder.Frame.McuSize.MultiplyBy(fLuma); diff --git a/tests/ImageSharp.Tests/Formats/Jpg/ReferenceImplementationsTests.FastFloatingPointDCT.cs b/tests/ImageSharp.Tests/Formats/Jpg/ReferenceImplementationsTests.FastFloatingPointDCT.cs index f5d7c159ba..2fcd953ae0 100644 --- a/tests/ImageSharp.Tests/Formats/Jpg/ReferenceImplementationsTests.FastFloatingPointDCT.cs +++ b/tests/ImageSharp.Tests/Formats/Jpg/ReferenceImplementationsTests.FastFloatingPointDCT.cs @@ -53,7 +53,7 @@ public void LLM_IDCT_IsEquivalentTo_AccurateImplementation(int seed, int range) { float[] sourceArray = Create8x8RandomFloatData(-range, range, seed); - var source = Block8x8F.Load(sourceArray); + Block8x8F source = Block8x8F.Load(sourceArray); Block8x8F expected = ReferenceImplementations.AccurateDCT.TransformIDCT(ref source); diff --git a/tests/ImageSharp.Tests/Formats/Jpg/SpectralJpegTests.cs b/tests/ImageSharp.Tests/Formats/Jpg/SpectralJpegTests.cs index 805ee586a8..14dd0aa229 100644 --- a/tests/ImageSharp.Tests/Formats/Jpg/SpectralJpegTests.cs +++ b/tests/ImageSharp.Tests/Formats/Jpg/SpectralJpegTests.cs @@ -21,19 +21,19 @@ public class SpectralJpegTests private ITestOutputHelper Output { get; } public static readonly string[] BaselineTestJpegs = - { - TestImages.Jpeg.Baseline.Calliphora, TestImages.Jpeg.Baseline.Cmyk, TestImages.Jpeg.Baseline.Jpeg400, + [ + TestImages.Jpeg.Baseline.Calliphora, TestImages.Jpeg.Baseline.Cmyk, TestImages.Jpeg.Baseline.Jpeg400, TestImages.Jpeg.Baseline.Jpeg444, TestImages.Jpeg.Baseline.Testorig420, TestImages.Jpeg.Baseline.Jpeg420Small, TestImages.Jpeg.Baseline.Bad.BadEOF, TestImages.Jpeg.Baseline.MultiScanBaselineCMYK - }; + ]; public static readonly string[] ProgressiveTestJpegs = - { - TestImages.Jpeg.Progressive.Fb, TestImages.Jpeg.Progressive.Progress, + [ + TestImages.Jpeg.Progressive.Fb, TestImages.Jpeg.Progressive.Progress, TestImages.Jpeg.Progressive.Festzug, TestImages.Jpeg.Progressive.Bad.BadEOF, - TestImages.Jpeg.Progressive.Bad.ExifUndefType, - }; + TestImages.Jpeg.Progressive.Bad.ExifUndefType + ]; public static readonly string[] AllTestJpegs = BaselineTestJpegs.Concat(ProgressiveTestJpegs).ToArray(); @@ -46,13 +46,13 @@ public void Decoder_ParseStream_SaveSpectralResult(TestImageProvider(); - var scanDecoder = new HuffmanScanDecoder(bufferedStream, debugConverter, cancellationToken: default); + DebugSpectralConverter debugConverter = new(); + HuffmanScanDecoder scanDecoder = new(bufferedStream, debugConverter, cancellationToken: default); // This would parse entire image decoder.ParseStream(bufferedStream, debugConverter, cancellationToken: default); @@ -76,12 +76,12 @@ public void VerifySpectralCorrectness(TestImageProvider provider byte[] sourceBytes = TestFile.Create(provider.SourceFileOrDescription).Bytes; JpegDecoderOptions options = new(); - using var decoder = new JpegDecoderCore(options); - using var ms = new MemoryStream(sourceBytes); - using var bufferedStream = new BufferedReadStream(Configuration.Default, ms); + using JpegDecoderCore decoder = new(options); + using MemoryStream ms = new(sourceBytes); + using BufferedReadStream bufferedStream = new(Configuration.Default, ms); // internal scan decoder which we substitute to assert spectral correctness - var debugConverter = new DebugSpectralConverter(); + DebugSpectralConverter debugConverter = new(); // This would parse entire image decoder.ParseStream(bufferedStream, debugConverter, cancellationToken: default); @@ -100,7 +100,7 @@ private void VerifySpectralCorrectnessImpl( int componentCount = imageSharpData.ComponentCount; if (libJpegData.ComponentCount != componentCount) { - throw new Exception("libJpegData.ComponentCount != componentCount"); + throw new("libJpegData.ComponentCount != componentCount"); } double averageDifference = 0; @@ -197,14 +197,14 @@ public override void InjectFrameData(JpegFrame frame, IRawJpegData jpegData) public override void PrepareForDecoding() { - var spectralComponents = new LibJpegTools.ComponentData[this.frame.ComponentCount]; + LibJpegTools.ComponentData[] spectralComponents = new LibJpegTools.ComponentData[this.frame.ComponentCount]; for (int i = 0; i < spectralComponents.Length; i++) { JpegComponent component = this.frame.Components[i]; - spectralComponents[i] = new LibJpegTools.ComponentData(component.WidthInBlocks, component.HeightInBlocks, component.Index); + spectralComponents[i] = new(component.WidthInBlocks, component.HeightInBlocks, component.Index); } - this.spectralData = new LibJpegTools.SpectralData(spectralComponents); + this.spectralData = new(spectralComponents); } } } diff --git a/tests/ImageSharp.Tests/Formats/Jpg/SpectralToPixelConversionTests.cs b/tests/ImageSharp.Tests/Formats/Jpg/SpectralToPixelConversionTests.cs index 25929182fb..b55f6442de 100644 --- a/tests/ImageSharp.Tests/Formats/Jpg/SpectralToPixelConversionTests.cs +++ b/tests/ImageSharp.Tests/Formats/Jpg/SpectralToPixelConversionTests.cs @@ -15,12 +15,12 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg; public class SpectralToPixelConversionTests { public static readonly string[] BaselineTestJpegs = - { + [ TestImages.Jpeg.Baseline.Calliphora, TestImages.Jpeg.Baseline.Cmyk, TestImages.Jpeg.Baseline.Jpeg400, TestImages.Jpeg.Baseline.Jpeg444, TestImages.Jpeg.Baseline.Testorig420, TestImages.Jpeg.Baseline.Jpeg420Small, TestImages.Jpeg.Baseline.Bad.BadEOF, TestImages.Jpeg.Baseline.MultiScanBaselineCMYK - }; + ]; public SpectralToPixelConversionTests(ITestOutputHelper output) => this.Output = output; @@ -33,14 +33,14 @@ public void Decoder_PixelBufferComparison(TestImageProvider prov { // Stream byte[] sourceBytes = TestFile.Create(provider.SourceFileOrDescription).Bytes; - using var ms = new MemoryStream(sourceBytes); - using var bufferedStream = new BufferedReadStream(Configuration.Default, ms); + using MemoryStream ms = new(sourceBytes); + using BufferedReadStream bufferedStream = new(Configuration.Default, ms); // Decoding JpegDecoderOptions options = new(); - using var converter = new SpectralConverter(Configuration.Default); - using var decoder = new JpegDecoderCore(options); - var scanDecoder = new HuffmanScanDecoder(bufferedStream, converter, cancellationToken: default); + using SpectralConverter converter = new(Configuration.Default); + using JpegDecoderCore decoder = new(options); + HuffmanScanDecoder scanDecoder = new(bufferedStream, converter, cancellationToken: default); decoder.ParseStream(bufferedStream, converter, cancellationToken: default); // Test metadata @@ -48,7 +48,7 @@ public void Decoder_PixelBufferComparison(TestImageProvider prov provider.Utility.TestName = JpegDecoderTests.DecodeBaselineJpegOutputName; // Comparison - using var image = new Image(Configuration.Default, converter.GetPixelBuffer(CancellationToken.None), new ImageMetadata()); + using Image image = new(Configuration.Default, converter.GetPixelBuffer(CancellationToken.None), new()); using Image referenceImage = provider.GetReferenceOutputImage(appendPixelTypeToFileName: false); ImageSimilarityReport report = ImageComparer.Exact.CompareImagesOrFrames(referenceImage, image); diff --git a/tests/ImageSharp.Tests/Formats/Jpg/Utils/JpegFixture.cs b/tests/ImageSharp.Tests/Formats/Jpg/Utils/JpegFixture.cs index a3fbe4018e..33e95c5aa0 100644 --- a/tests/ImageSharp.Tests/Formats/Jpg/Utils/JpegFixture.cs +++ b/tests/ImageSharp.Tests/Formats/Jpg/Utils/JpegFixture.cs @@ -72,7 +72,7 @@ public static short[] Create8x8ShortData() // ReSharper disable once InconsistentNaming public static int[] Create8x8RandomIntData(int minValue, int maxValue, int seed = 42) { - var rnd = new Random(seed); + Random rnd = new(seed); int[] result = new int[64]; for (int i = 0; i < 8; i++) { @@ -87,7 +87,7 @@ public static int[] Create8x8RandomIntData(int minValue, int maxValue, int seed public static float[] Create8x8RandomFloatData(float minValue, float maxValue, int seed = 42, int xBorder = 8, int yBorder = 8) { - var rnd = new Random(seed); + Random rnd = new(seed); float[] result = new float[64]; for (int y = 0; y < yBorder; y++) { @@ -112,7 +112,7 @@ internal static Block8x8F CreateRandomFloatBlock(float minValue, float maxValue, internal void Print8x8Data(Span data) { - var bld = new StringBuilder(); + StringBuilder bld = new(); for (int i = 0; i < 8; i++) { for (int j = 0; j < 8; j++) @@ -135,7 +135,7 @@ internal void PrintLinearData(Span data, int count = -1) count = data.Length; } - var sb = new StringBuilder(); + StringBuilder sb = new(); for (int i = 0; i < count; i++) { sb.Append($"{data[i],3} "); @@ -158,7 +158,7 @@ internal void CompareBlocks(Block8x8F a, Block8x8F b, float tolerance) internal void CompareBlocks(Span a, Span b, float tolerance) { - var comparer = new ApproximateFloatComparer(tolerance); + ApproximateFloatComparer comparer = new(tolerance); double totalDifference = 0.0; bool failed = false; @@ -192,7 +192,7 @@ internal static bool CompareBlocks(Block8x8F a, Block8x8F b, float tolerance, ou internal static bool CompareBlocks(Span a, Span b, float tolerance, out float diff) { - var comparer = new ApproximateFloatComparer(tolerance); + ApproximateFloatComparer comparer = new(tolerance); bool failed = false; diff = 0; diff --git a/tests/ImageSharp.Tests/Formats/Jpg/Utils/LibJpegTools.cs b/tests/ImageSharp.Tests/Formats/Jpg/Utils/LibJpegTools.cs index bd1df33772..b08202df50 100644 --- a/tests/ImageSharp.Tests/Formats/Jpg/Utils/LibJpegTools.cs +++ b/tests/ImageSharp.Tests/Formats/Jpg/Utils/LibJpegTools.cs @@ -18,12 +18,12 @@ public static (double Total, double Average) CalculateDifference(ComponentData e BigInteger totalDiff = 0; if (actual.WidthInBlocks < expected.WidthInBlocks) { - throw new Exception("actual.WidthInBlocks < expected.WidthInBlocks"); + throw new("actual.WidthInBlocks < expected.WidthInBlocks"); } if (actual.HeightInBlocks < expected.HeightInBlocks) { - throw new Exception("actual.HeightInBlocks < expected.HeightInBlocks"); + throw new("actual.HeightInBlocks < expected.HeightInBlocks"); } int w = expected.WidthInBlocks; @@ -65,7 +65,7 @@ public static void RunDumpJpegCoeffsTool(string sourceFile, string destFile) } string args = $@"""{sourceFile}"" ""{destFile}"""; - var process = new Process + Process process = new() { StartInfo = { @@ -95,21 +95,21 @@ public static SpectralData ExtractSpectralData(string inputFile) { RunDumpJpegCoeffsTool(testFile.FullPath, coeffFileFullPath); - using (var dumpStream = new FileStream(coeffFileFullPath, FileMode.Open)) - using (var rdr = new BinaryReader(dumpStream)) + using (FileStream dumpStream = new(coeffFileFullPath, FileMode.Open)) + using (BinaryReader rdr = new(dumpStream)) { int componentCount = rdr.ReadInt16(); - var result = new ComponentData[componentCount]; + ComponentData[] result = new ComponentData[componentCount]; for (int i = 0; i < componentCount; i++) { int widthInBlocks = rdr.ReadInt16(); int heightInBlocks = rdr.ReadInt16(); - var resultComponent = new ComponentData(widthInBlocks, heightInBlocks, i); + ComponentData resultComponent = new(widthInBlocks, heightInBlocks, i); result[i] = resultComponent; } - var buffer = new byte[64 * sizeof(short)]; + byte[] buffer = new byte[64 * sizeof(short)]; for (int i = 0; i < result.Length; i++) { @@ -127,7 +127,7 @@ public static SpectralData ExtractSpectralData(string inputFile) } } - return new SpectralData(result); + return new(result); } } finally diff --git a/tests/ImageSharp.Tests/Formats/Jpg/Utils/ReferenceImplementations.AccurateDCT.cs b/tests/ImageSharp.Tests/Formats/Jpg/Utils/ReferenceImplementations.AccurateDCT.cs index b6e7b29a62..2d4db15dfc 100644 --- a/tests/ImageSharp.Tests/Formats/Jpg/Utils/ReferenceImplementations.AccurateDCT.cs +++ b/tests/ImageSharp.Tests/Formats/Jpg/Utils/ReferenceImplementations.AccurateDCT.cs @@ -30,7 +30,7 @@ public static Block8x8 TransformIDCT(ref Block8x8 block) public static void TransformIDCTInplace(Span span) { - var temp = default(Block8x8); + Block8x8 temp = default(Block8x8); temp.LoadFrom(span); Block8x8 result = TransformIDCT(ref temp); result.CopyTo(span); @@ -45,7 +45,7 @@ public static Block8x8 TransformFDCT(ref Block8x8 block) public static void TransformFDCTInplace(Span span) { - var temp = default(Block8x8); + Block8x8 temp = default(Block8x8); temp.LoadFrom(span); Block8x8 result = TransformFDCT(ref temp); result.CopyTo(span); diff --git a/tests/ImageSharp.Tests/Formats/Jpg/Utils/ReferenceImplementations.LLM_FloatingPoint_DCT.cs b/tests/ImageSharp.Tests/Formats/Jpg/Utils/ReferenceImplementations.LLM_FloatingPoint_DCT.cs index 0d5f3114d1..acb3d27e37 100644 --- a/tests/ImageSharp.Tests/Formats/Jpg/Utils/ReferenceImplementations.LLM_FloatingPoint_DCT.cs +++ b/tests/ImageSharp.Tests/Formats/Jpg/Utils/ReferenceImplementations.LLM_FloatingPoint_DCT.cs @@ -208,8 +208,8 @@ public static void FDCT2D8x4_32f(Span s, Span d) /*y[0] = c0 + c1; y[4] = c0 - c1;*/ - var w0 = new Vector4(0.541196f); - var w1 = new Vector4(1.306563f); + Vector4 w0 = new(0.541196f); + Vector4 w1 = new(1.306563f); _mm_store_ps(d, 16, (w0 * c2) + (w1 * c3)); @@ -219,8 +219,8 @@ public static void FDCT2D8x4_32f(Span s, Span d) y[6] = c3 * r[6] - c2 * r[2]; */ - w0 = new Vector4(1.175876f); - w1 = new Vector4(0.785695f); + w0 = new(1.175876f); + w1 = new(0.785695f); c3 = (w0 * t4) + (w1 * t7); c0 = (w0 * t7) - (w1 * t4); /* @@ -228,8 +228,8 @@ public static void FDCT2D8x4_32f(Span s, Span d) c0 = t7 * r[3] - t4 * r[5]; */ - w0 = new Vector4(1.387040f); - w1 = new Vector4(0.275899f); + w0 = new(1.387040f); + w1 = new(0.275899f); c2 = (w0 * t5) + (w1 * t6); c1 = (w0 * t6) - (w1 * t5); /* @@ -242,7 +242,7 @@ public static void FDCT2D8x4_32f(Span s, Span d) _mm_store_ps(d, 40, c3 - c1); // y[5] = c3 - c1; y[3] = c0 - c2; - var invsqrt2 = new Vector4(0.707107f); + Vector4 invsqrt2 = new(0.707107f); c0 = (c0 + c2) * invsqrt2; c3 = (c3 + c1) * invsqrt2; @@ -272,7 +272,7 @@ public static void FDCT8x8_llm_sse(Span s, Span d, Span tem FDCT2D8x4_32f(temp.Slice(4), d.Slice(4)); - var c = new Vector4(0.1250f); + Vector4 c = new(0.1250f); #pragma warning disable SA1107 // Code should not contain multiple statements on one line _mm_store_ps(d, 0, _mm_load_ps(d, 0) * c); d = d.Slice(4); // 0 @@ -300,7 +300,7 @@ private static Vector4 _mm_load_ps(Span src, int offset) #pragma warning restore SA1300 // Element should begin with upper-case letter { src = src.Slice(offset); - return new Vector4(src[0], src[1], src[2], src[3]); + return new(src[0], src[1], src[2], src[3]); } [MethodImpl(MethodImplOptions.AggressiveInlining)] @@ -318,29 +318,29 @@ private static void _mm_store_ps(Span dest, int offset, Vector4 src) // Accurate variants of constants from: // https://github.com/mozilla/mozjpeg/blob/master/simd/jfdctint-altivec.c #pragma warning disable SA1309 // Field names should not begin with underscore - private static readonly Vector4 _1_175876 = new Vector4(1.175875602f); + private static readonly Vector4 _1_175876 = new(1.175875602f); - private static readonly Vector4 _1_961571 = new Vector4(-1.961570560f); + private static readonly Vector4 _1_961571 = new(-1.961570560f); - private static readonly Vector4 _0_390181 = new Vector4(-0.390180644f); + private static readonly Vector4 _0_390181 = new(-0.390180644f); - private static readonly Vector4 _0_899976 = new Vector4(-0.899976223f); + private static readonly Vector4 _0_899976 = new(-0.899976223f); - private static readonly Vector4 _2_562915 = new Vector4(-2.562915447f); + private static readonly Vector4 _2_562915 = new(-2.562915447f); - private static readonly Vector4 _0_298631 = new Vector4(0.298631336f); + private static readonly Vector4 _0_298631 = new(0.298631336f); - private static readonly Vector4 _2_053120 = new Vector4(2.053119869f); + private static readonly Vector4 _2_053120 = new(2.053119869f); - private static readonly Vector4 _3_072711 = new Vector4(3.072711026f); + private static readonly Vector4 _3_072711 = new(3.072711026f); - private static readonly Vector4 _1_501321 = new Vector4(1.501321110f); + private static readonly Vector4 _1_501321 = new(1.501321110f); - private static readonly Vector4 _0_541196 = new Vector4(0.541196100f); + private static readonly Vector4 _0_541196 = new(0.541196100f); - private static readonly Vector4 _1_847759 = new Vector4(-1.847759065f); + private static readonly Vector4 _1_847759 = new(-1.847759065f); - private static readonly Vector4 _0_765367 = new Vector4(0.765366865f); + private static readonly Vector4 _0_765367 = new(0.765366865f); #pragma warning restore SA1309 // Field names should not begin with underscore /// diff --git a/tests/ImageSharp.Tests/Formats/Jpg/Utils/ReferenceImplementations.StandardIntegerDCT.cs b/tests/ImageSharp.Tests/Formats/Jpg/Utils/ReferenceImplementations.StandardIntegerDCT.cs index 95ab076b0b..10019c609e 100644 --- a/tests/ImageSharp.Tests/Formats/Jpg/Utils/ReferenceImplementations.StandardIntegerDCT.cs +++ b/tests/ImageSharp.Tests/Formats/Jpg/Utils/ReferenceImplementations.StandardIntegerDCT.cs @@ -71,10 +71,10 @@ public static class StandardIntegerDCT public static Block8x8 Subtract128_TransformFDCT_Upscale8(ref Block8x8 block) { - var temp = new int[Block8x8.Size]; + int[] temp = new int[Block8x8.Size]; block.CopyTo(temp); Subtract128_TransformFDCT_Upscale8_Inplace(temp); - var result = default(Block8x8); + Block8x8 result = default(Block8x8); result.LoadFrom(temp); return result; } @@ -82,10 +82,10 @@ public static Block8x8 Subtract128_TransformFDCT_Upscale8(ref Block8x8 block) // [Obsolete("Looks like this method produces really bad results for bigger values!")] public static Block8x8 TransformIDCT(ref Block8x8 block) { - var temp = new int[Block8x8.Size]; + int[] temp = new int[Block8x8.Size]; block.CopyTo(temp); TransformIDCTInplace(temp); - var result = default(Block8x8); + Block8x8 result = default(Block8x8); result.LoadFrom(temp); return result; } diff --git a/tests/ImageSharp.Tests/Formats/Jpg/Utils/SpanExtensions.cs b/tests/ImageSharp.Tests/Formats/Jpg/Utils/SpanExtensions.cs index 240a338f9b..d7c2c0bbbb 100644 --- a/tests/ImageSharp.Tests/Formats/Jpg/Utils/SpanExtensions.cs +++ b/tests/ImageSharp.Tests/Formats/Jpg/Utils/SpanExtensions.cs @@ -74,7 +74,7 @@ public static void LoadFrom(this Span data, ref Vector4 v) /// A new with float values public static float[] ConvertAllToFloat(this int[] src) { - var result = new float[src.Length]; + float[] result = new float[src.Length]; for (int i = 0; i < src.Length; i++) { result[i] = src[i]; @@ -91,7 +91,7 @@ public static float[] ConvertAllToFloat(this int[] src) /// A new instance of public static Span AddScalarToAllValues(this Span src, float scalar) { - var result = new float[src.Length]; + float[] result = new float[src.Length]; for (int i = 0; i < src.Length; i++) { result[i] = src[i] + scalar; @@ -108,7 +108,7 @@ public static Span AddScalarToAllValues(this Span src, float scala /// A new instance of public static Span AddScalarToAllValues(this Span src, int scalar) { - var result = new int[src.Length]; + int[] result = new int[src.Length]; for (int i = 0; i < src.Length; i++) { result[i] = src[i] + scalar; diff --git a/tests/ImageSharp.Tests/Formats/Jpg/Utils/VerifyJpeg.cs b/tests/ImageSharp.Tests/Formats/Jpg/Utils/VerifyJpeg.cs index 7a31e35d0c..d7b0b64b2d 100644 --- a/tests/ImageSharp.Tests/Formats/Jpg/Utils/VerifyJpeg.cs +++ b/tests/ImageSharp.Tests/Formats/Jpg/Utils/VerifyJpeg.cs @@ -11,7 +11,7 @@ internal static class VerifyJpeg { internal static void VerifySize(IJpegComponent component, int expectedBlocksX, int expectedBlocksY) { - Assert.Equal(new Size(expectedBlocksX, expectedBlocksY), component.SizeInBlocks); + Assert.Equal(new(expectedBlocksX, expectedBlocksY), component.SizeInBlocks); } internal static void VerifyComponent( diff --git a/tests/ImageSharp.Tests/Formats/Pbm/ImageExtensionsTest.cs b/tests/ImageSharp.Tests/Formats/Pbm/ImageExtensionsTest.cs index 5cbdd3dab0..1b71f49d5b 100644 --- a/tests/ImageSharp.Tests/Formats/Pbm/ImageExtensionsTest.cs +++ b/tests/ImageSharp.Tests/Formats/Pbm/ImageExtensionsTest.cs @@ -47,7 +47,7 @@ public void SaveAsPbm_Path_Encoder() using (Image image = new(10, 10)) { - image.SaveAsPbm(file, new PbmEncoder()); + image.SaveAsPbm(file, new()); } IImageFormat format = Image.DetectFormat(file); @@ -108,7 +108,7 @@ public void SaveAsPbm_Stream_Encoder() using (Image image = new(10, 10)) { - image.SaveAsPbm(memoryStream, new PbmEncoder()); + image.SaveAsPbm(memoryStream, new()); } memoryStream.Position = 0; diff --git a/tests/ImageSharp.Tests/Formats/Pbm/PbmDecoderTests.cs b/tests/ImageSharp.Tests/Formats/Pbm/PbmDecoderTests.cs index 11dd1cd58c..2da8015324 100644 --- a/tests/ImageSharp.Tests/Formats/Pbm/PbmDecoderTests.cs +++ b/tests/ImageSharp.Tests/Formats/Pbm/PbmDecoderTests.cs @@ -29,11 +29,11 @@ public class PbmDecoderTests public void ImageLoadCanDecode(string imagePath, PbmColorType expectedColorType, PbmComponentType expectedComponentType) { // Arrange - var testFile = TestFile.Create(imagePath); - using var stream = new MemoryStream(testFile.Bytes, false); + TestFile testFile = TestFile.Create(imagePath); + using MemoryStream stream = new(testFile.Bytes, false); // Act - using var image = Image.Load(stream); + using Image image = Image.Load(stream); // Assert Assert.NotNull(image); @@ -53,11 +53,11 @@ public void ImageLoadCanDecode(string imagePath, PbmColorType expectedColorType, public void ImageLoadL8CanDecode(string imagePath) { // Arrange - var testFile = TestFile.Create(imagePath); - using var stream = new MemoryStream(testFile.Bytes, false); + TestFile testFile = TestFile.Create(imagePath); + using MemoryStream stream = new(testFile.Bytes, false); // Act - using var image = Image.Load(stream); + using Image image = Image.Load(stream); // Assert Assert.NotNull(image); @@ -70,11 +70,11 @@ public void ImageLoadL8CanDecode(string imagePath) public void ImageLoadRgb24CanDecode(string imagePath) { // Arrange - var testFile = TestFile.Create(imagePath); - using var stream = new MemoryStream(testFile.Bytes, false); + TestFile testFile = TestFile.Create(imagePath); + using MemoryStream stream = new(testFile.Bytes, false); // Act - using var image = Image.Load(stream); + using Image image = Image.Load(stream); // Assert Assert.NotNull(image); @@ -130,7 +130,7 @@ public void PlainText_PrematureEof() using EofHitCounter eofHitCounter = EofHitCounter.RunDecoder(bytes); Assert.True(eofHitCounter.EofHitCount <= 2); - Assert.Equal(new Size(100, 100), eofHitCounter.Image.Size); + Assert.Equal(new(100, 100), eofHitCounter.Image.Size); } [Fact] @@ -139,6 +139,6 @@ public void Binary_PrematureEof() using EofHitCounter eofHitCounter = EofHitCounter.RunDecoder(RgbBinaryPrematureEof); Assert.True(eofHitCounter.EofHitCount <= 2); - Assert.Equal(new Size(29, 30), eofHitCounter.Image.Size); + Assert.Equal(new(29, 30), eofHitCounter.Image.Size); } } diff --git a/tests/ImageSharp.Tests/Formats/Pbm/PbmEncoderTests.cs b/tests/ImageSharp.Tests/Formats/Pbm/PbmEncoderTests.cs index 05f1d963b2..0fea65f6ea 100644 --- a/tests/ImageSharp.Tests/Formats/Pbm/PbmEncoderTests.cs +++ b/tests/ImageSharp.Tests/Formats/Pbm/PbmEncoderTests.cs @@ -38,16 +38,16 @@ public class PbmEncoderTests [MemberData(nameof(PbmColorTypeFiles))] public void PbmEncoder_PreserveColorType(string imagePath, PbmColorType pbmColorType) { - var options = new PbmEncoder(); + PbmEncoder options = new(); - var testFile = TestFile.Create(imagePath); + TestFile testFile = TestFile.Create(imagePath); using (Image input = testFile.CreateRgba32Image()) { - using (var memStream = new MemoryStream()) + using (MemoryStream memStream = new()) { input.Save(memStream, options); memStream.Position = 0; - using (var output = Image.Load(memStream)) + using (Image output = Image.Load(memStream)) { PbmMetadata meta = output.Metadata.GetPbmMetadata(); Assert.Equal(pbmColorType, meta.ColorType); @@ -60,15 +60,15 @@ public void PbmEncoder_PreserveColorType(string imagePath, PbmColorType pbmColor [MemberData(nameof(PbmColorTypeFiles))] public void PbmEncoder_WithPlainEncoding_PreserveBitsPerPixel(string imagePath, PbmColorType pbmColorType) { - var options = new PbmEncoder() + PbmEncoder options = new() { Encoding = PbmEncoding.Plain }; - var testFile = TestFile.Create(imagePath); + TestFile testFile = TestFile.Create(imagePath); using (Image input = testFile.CreateRgba32Image()) { - using (var memStream = new MemoryStream()) + using (MemoryStream memStream = new()) { input.Save(memStream, options); @@ -78,7 +78,7 @@ public void PbmEncoder_WithPlainEncoding_PreserveBitsPerPixel(string imagePath, Assert.Equal(0x20, lastByte); memStream.Seek(0, SeekOrigin.Begin); - using (var output = Image.Load(memStream)) + using (Image output = Image.Load(memStream)) { PbmMetadata meta = output.Metadata.GetPbmMetadata(); Assert.Equal(pbmColorType, meta.ColorType); @@ -132,13 +132,13 @@ private static void TestPbmEncoderCore( { using (Image image = provider.GetImage()) { - var encoder = new PbmEncoder { ColorType = colorType, Encoding = encoding }; + PbmEncoder encoder = new() { ColorType = colorType, Encoding = encoding }; - using (var memStream = new MemoryStream()) + using (MemoryStream memStream = new()) { image.Save(memStream, encoder); memStream.Position = 0; - using (var encodedImage = (Image)Image.Load(memStream)) + using (Image encodedImage = (Image)Image.Load(memStream)) { ImageComparingUtils.CompareWithReferenceDecoder(provider, encodedImage, useExactComparer, compareTolerance); } diff --git a/tests/ImageSharp.Tests/Formats/Pbm/PbmRoundTripTests.cs b/tests/ImageSharp.Tests/Formats/Pbm/PbmRoundTripTests.cs index b7ce32ed8f..6524b35065 100644 --- a/tests/ImageSharp.Tests/Formats/Pbm/PbmRoundTripTests.cs +++ b/tests/ImageSharp.Tests/Formats/Pbm/PbmRoundTripTests.cs @@ -21,11 +21,11 @@ public class PbmRoundTripTests public void PbmGrayscaleImageCanRoundTrip(string imagePath) { // Arrange - var testFile = TestFile.Create(imagePath); - using var stream = new MemoryStream(testFile.Bytes, false); + TestFile testFile = TestFile.Create(imagePath); + using MemoryStream stream = new(testFile.Bytes, false); // Act - using var originalImage = Image.Load(stream); + using Image originalImage = Image.Load(stream); using Image colorImage = originalImage.CloneAs(); using Image encodedImage = this.RoundTrip(colorImage); @@ -42,11 +42,11 @@ public void PbmGrayscaleImageCanRoundTrip(string imagePath) public void PbmColorImageCanRoundTrip(string imagePath) { // Arrange - var testFile = TestFile.Create(imagePath); - using var stream = new MemoryStream(testFile.Bytes, false); + TestFile testFile = TestFile.Create(imagePath); + using MemoryStream stream = new(testFile.Bytes, false); // Act - using var originalImage = Image.Load(stream); + using Image originalImage = Image.Load(stream); using Image encodedImage = this.RoundTrip(originalImage); // Assert @@ -57,10 +57,10 @@ public void PbmColorImageCanRoundTrip(string imagePath) private Image RoundTrip(Image originalImage) where TPixel : unmanaged, IPixel { - using var decodedStream = new MemoryStream(); + using MemoryStream decodedStream = new(); originalImage.SaveAsPbm(decodedStream); decodedStream.Seek(0, SeekOrigin.Begin); - var encodedImage = Image.Load(decodedStream); + Image encodedImage = Image.Load(decodedStream); return encodedImage; } } diff --git a/tests/ImageSharp.Tests/Formats/Png/Adler32Tests.cs b/tests/ImageSharp.Tests/Formats/Png/Adler32Tests.cs index 1b66c4cc3c..c2b640a1de 100644 --- a/tests/ImageSharp.Tests/Formats/Png/Adler32Tests.cs +++ b/tests/ImageSharp.Tests/Formats/Png/Adler32Tests.cs @@ -30,7 +30,7 @@ private static void CalculateAdlerAndCompareToReference(int length) { // arrange byte[] data = GetBuffer(length); - var adler = new SharpAdler32(); + SharpAdler32 adler = new(); adler.Update(data); long expected = adler.Value; @@ -60,7 +60,7 @@ private static byte[] GetBuffer(int length) private static void RunCalculateAdlerTest() { - int[] testData = { 0, 8, 215, 1024, 1024 + 15, 2034, 4096 }; + int[] testData = [0, 8, 215, 1024, 1024 + 15, 2034, 4096]; for (int i = 0; i < testData.Length; i++) { CalculateAdlerAndCompareToReference(testData[i]); diff --git a/tests/ImageSharp.Tests/Formats/Png/ImageExtensionsTest.cs b/tests/ImageSharp.Tests/Formats/Png/ImageExtensionsTest.cs index a03e1a7aa4..145cc1d68f 100644 --- a/tests/ImageSharp.Tests/Formats/Png/ImageExtensionsTest.cs +++ b/tests/ImageSharp.Tests/Formats/Png/ImageExtensionsTest.cs @@ -48,7 +48,7 @@ public void SaveAsPng_Path_Encoder() using (Image image = new(10, 10)) { - image.SaveAsPng(file, new PngEncoder()); + image.SaveAsPng(file, new()); } IImageFormat format = Image.DetectFormat(file); @@ -109,7 +109,7 @@ public void SaveAsPng_Stream_Encoder() using (Image image = new(10, 10)) { - image.SaveAsPng(memoryStream, new PngEncoder()); + image.SaveAsPng(memoryStream, new()); } memoryStream.Position = 0; diff --git a/tests/ImageSharp.Tests/Formats/Png/PngDecoderFilterTests.cs b/tests/ImageSharp.Tests/Formats/Png/PngDecoderFilterTests.cs index f5c42c734b..00db13d4b2 100644 --- a/tests/ImageSharp.Tests/Formats/Png/PngDecoderFilterTests.cs +++ b/tests/ImageSharp.Tests/Formats/Png/PngDecoderFilterTests.cs @@ -13,33 +13,33 @@ private static void RunAverageFilterTest() { // arrange byte[] scanline = - { + [ 3, 39, 39, 39, 0, 4, 4, 4, 0, 1, 1, 1, 0, 1, 1, 1, 0, 2, 2, 2, 0, 2, 2, 2, 0, 2, 2, 2, 0, 4, 4, 4, 0, 2, 2, 2, 0, 3, 3, 3, 0, 1, 1, 1, 0, 3, 3, 3, 0, 3, 3, 3, 0, 1, 1, 1, 0, 3, 3, 3, 0, 2, 2, 2, 0, 1, 1, 1, 0, 3, 3, 3, 0, 1, 1, 1, 0, 3, 3, 3, 0, 1, 1, 1, 0, 3, 3, 3, 0, 3, 3, 3, 0, 254, 254, 254, 0, 6, 6, 6, 14, 71, 71, 71, 157, 254, 254, 254, 28, 251, 251, 251, 0, 4, 4, 4, 0, 2, 2, 2, 0, 11, 11, 11, 0, 226, 226, 226, 0, 255, 128, 234 - }; + ]; byte[] previousScanline = - { + [ 3, 74, 74, 74, 0, 73, 73, 73, 0, 73, 73, 73, 0, 74, 74, 74, 0, 74, 74, 74, 0, 73, 73, 73, 0, 72, 72, 72, 0, 72, 72, 72, 0, 73, 73, 73, 0, 74, 74, 74, 0, 73, 73, 73, 0, 72, 72, 72, 0, 72, 72, 72, 0, 74, 74, 74, 0, 72, 72, 72, 0, 73, 73, 73, 0, 75, 75, 75, 0, 73, 73, 73, 0, 74, 74, 74, 0, 72, 72, 72, 0, 73, 73, 73, 0, 73, 73, 73, 0, 72, 72, 72, 0, 74, 74, 74, 0, 61, 61, 61, 0, 101, 101, 101, 78, 197, 197, 197, 251, 152, 152, 152, 255, 155, 155, 155, 255, 162, 162, 162, 255, 175, 175, 175, 255, 160, 160, 160, 255, 139, 128, 134 - }; + ]; byte[] expected = - { + [ 3, 76, 76, 76, 0, 78, 78, 78, 0, 76, 76, 76, 0, 76, 76, 76, 0, 77, 77, 77, 0, 77, 77, 77, 0, 76, 76, 76, 0, 78, 78, 78, 0, 77, 77, 77, 0, 78, 78, 78, 0, 76, 76, 76, 0, 77, 77, 77, 0, 77, 77, 77, 0, 76, 76, 76, 0, 77, 77, 77, 0, 77, 77, 77, 0, 77, 77, 77, 0, 78, 78, 78, 0, 77, 77, 77, 0, 77, 77, 77, 0, 76, 76, 76, 0, 77, 77, 77, 0, 77, 77, 77, 0, 73, 73, 73, 0, 73, 73, 73, 14, 158, 158, 158, 203, 175, 175, 175, 255, 158, 158, 158, 255, 160, 160, 160, 255, 163, 163, 163, 255, 180, 180, 180, 255, 140, 140, 140, 255, 138, 6, 115 - }; + ]; // act AverageFilter.Decode(scanline, previousScanline, 4); @@ -52,25 +52,25 @@ private static void RunUpFilterTest() { // arrange byte[] scanline = - { + [ 62, 23, 186, 150, 174, 4, 205, 59, 153, 134, 158, 86, 240, 173, 191, 58, 111, 183, 77, 37, 85, 23, 93, 204, 110, 139, 9, 20, 87, 154, 176, 54, 207, 214, 40, 11, 179, 199, 7, 219, 174, 242, 112, 220, 149, 5, 9, 110, 103, 107, 231, 241, 13, 70, 216, 39, 186, 237, 39, 34, 251, 185, 228, 254 - }; + ]; byte[] previousScanline = - { + [ 214, 103, 135, 26, 133, 179, 134, 168, 175, 114, 118, 99, 167, 129, 55, 105, 129, 154, 173, 235, 179, 191, 41, 137, 253, 0, 81, 198, 159, 228, 224, 245, 14, 113, 5, 45, 126, 239, 233, 179, 229, 62, 66, 155, 207, 117, 128, 56, 181, 190, 160, 96, 11, 248, 74, 23, 62, 253, 29, 132, 98, 192, 9, 202 - }; + ]; byte[] expected = - { + [ 62, 126, 65, 176, 51, 183, 83, 227, 72, 248, 20, 185, 151, 46, 246, 163, 240, 81, 250, 16, 8, 214, 134, 85, 107, 139, 90, 218, 246, 126, 144, 43, 221, 71, 45, 56, 49, 182, 240, 142, 147, 48, 178, 119, 100, 122, 137, 166, 28, 41, 135, 81, 24, 62, 34, 62, 248, 234, 68, 166, 93, 121, 237, 200 - }; + ]; // act UpFilter.Decode(scanline, previousScanline); @@ -83,18 +83,18 @@ private static void RunSubFilterTest() { // arrange byte[] scanline = - { + [ 62, 23, 186, 150, 174, 4, 205, 59, 153, 134, 158, 86, 240, 173, 191, 58, 111, 183, 77, 37, 85, 23, 93, 204, 110, 139, 9, 20, 87, 154, 176, 54, 207, 214, 40, 11, 179, 199, 7, 219, 174, 242, 112, 220, 149, 5, 9, 110, 103, 107, 231, 241, 13, 70, 216, 39, 186, 237, 39, 34, 251, 185, 228, 254 - }; + ]; byte[] expected = - { + [ 62, 23, 186, 150, 174, 27, 135, 209, 71, 161, 37, 39, 55, 78, 228, 97, 166, 5, 49, 134, 251, 28, 142, 82, 105, 167, 151, 102, 192, 65, 71, 156, 143, 23, 111, 167, 66, 222, 118, 130, 240, 208, 230, 94, 133, 213, 239, 204, 236, 64, 214, 189, 249, 134, 174, 228, 179, 115, 213, 6, 174, 44, 185, 4 - }; + ]; // act SubFilter.Decode(scanline, 4); @@ -107,25 +107,25 @@ private static void RunPaethFilterTest() { // arrange byte[] scanline = - { + [ 62, 23, 186, 150, 174, 4, 205, 59, 153, 134, 158, 86, 240, 173, 191, 58, 111, 183, 77, 37, 85, 23, 93, 204, 110, 139, 9, 20, 87, 154, 176, 54, 207, 214, 40, 11, 179, 199, 7, 219, 174, 242, 112, 220, 149, 5, 9, 110, 103, 107, 231, 241, 13, 70, 216, 39, 186, 237, 39, 34, 251, 185, 228, 254 - }; + ]; byte[] previousScanline = - { + [ 214, 103, 135, 26, 133, 179, 134, 168, 175, 114, 118, 99, 167, 129, 55, 105, 129, 154, 173, 235, 179, 191, 41, 137, 253, 0, 81, 198, 159, 228, 224, 245, 14, 113, 5, 45, 126, 239, 233, 179, 229, 62, 66, 155, 207, 117, 128, 56, 181, 190, 160, 96, 11, 248, 74, 23, 62, 253, 29, 132, 98, 192, 9, 202 - }; + ]; byte[] expected = - { + [ 62, 126, 65, 176, 51, 183, 14, 235, 30, 248, 172, 254, 14, 165, 53, 56, 125, 92, 250, 16, 8, 177, 10, 220, 118, 139, 50, 240, 205, 126, 144, 43, 221, 71, 45, 54, 144, 182, 240, 142, 147, 48, 178, 106, 40, 122, 187, 166, 143, 41, 162, 151, 24, 111, 34, 135, 248, 92, 68, 169, 243, 21, 1, 200 - }; + ]; // act PaethFilter.Decode(scanline, previousScanline, 4); diff --git a/tests/ImageSharp.Tests/Formats/Png/PngDecoderTests.Chunks.cs b/tests/ImageSharp.Tests/Formats/Png/PngDecoderTests.Chunks.cs index aff8bc12a2..8dfa987488 100644 --- a/tests/ImageSharp.Tests/Formats/Png/PngDecoderTests.Chunks.cs +++ b/tests/ImageSharp.Tests/Formats/Png/PngDecoderTests.Chunks.cs @@ -14,12 +14,12 @@ namespace SixLabors.ImageSharp.Tests.Formats.Png; public partial class PngDecoderTests { // Represents ASCII string of "123456789" - private readonly byte[] check = { 49, 50, 51, 52, 53, 54, 55, 56, 57 }; + private readonly byte[] check = [49, 50, 51, 52, 53, 54, 55, 56, 57]; // Contains the png marker, IHDR and pHYs chunks of a 1x1 pixel 32bit png 1 a single black pixel. private static readonly byte[] Raw1X1PngIhdrAndpHYs = - { - // PNG Identifier + [ + // PNG Identifier 0x89, 0x50, 0x4E, 0x47, 0x0D, 0x0A, 0x1A, 0x0A, // IHDR @@ -36,12 +36,12 @@ public partial class PngDecoderTests // pHYS CRC 0xC7, 0x6F, 0xA8, 0x64 - }; + ]; // Contains the png marker, IDAT and IEND chunks of a 1x1 pixel 32bit png 1 a single black pixel. private static readonly byte[] Raw1X1PngIdatAndIend = - { - // IDAT + [ + // IDAT 0x00, 0x00, 0x00, 0x0C, 0x49, 0x44, 0x41, 0x54, 0x18, 0x57, 0x63, 0x60, 0x60, 0x60, 0x00, 0x00, 0x00, 0x04, 0x00, 0x01, @@ -54,7 +54,7 @@ public partial class PngDecoderTests // IEND CRC 0xAE, 0x42, 0x60, 0x82 - }; + ]; [Theory] [InlineData((uint)PngChunkType.Header)] // IHDR @@ -64,7 +64,7 @@ public void Decode_IncorrectCRCForCriticalChunk_ExceptionIsThrown(uint chunkType { string chunkName = GetChunkTypeName(chunkType); - using (var memStream = new MemoryStream()) + using (MemoryStream memStream = new()) { WriteHeaderChunk(memStream); WriteChunk(memStream, chunkName); @@ -94,10 +94,10 @@ private static void WriteHeaderChunk(MemoryStream memStream) => private static void WriteChunk(MemoryStream memStream, string chunkName) { // Needs a minimum length of 9 for pHYs chunk. - memStream.Write(new byte[] { 0, 0, 0, 9 }, 0, 4); + memStream.Write([0, 0, 0, 9], 0, 4); memStream.Write(Encoding.ASCII.GetBytes(chunkName), 0, 4); // 4 bytes chunk header - memStream.Write(new byte[] { 0, 0, 0, 0, 0, 0, 0, 0, 0 }, 0, 9); // 9 bytes of chunk data - memStream.Write(new byte[] { 0, 0, 0, 0 }, 0, 4); // Junk Crc + memStream.Write([0, 0, 0, 0, 0, 0, 0, 0, 0], 0, 9); // 9 bytes of chunk data + memStream.Write([0, 0, 0, 0], 0, 4); // Junk Crc } private static void WriteDataChunk(MemoryStream memStream) diff --git a/tests/ImageSharp.Tests/Formats/Png/PngDecoderTests.cs b/tests/ImageSharp.Tests/Formats/Png/PngDecoderTests.cs index 9f3c5f6828..7c55501ad1 100644 --- a/tests/ImageSharp.Tests/Formats/Png/PngDecoderTests.cs +++ b/tests/ImageSharp.Tests/Formats/Png/PngDecoderTests.cs @@ -21,7 +21,7 @@ public partial class PngDecoderTests private const PixelTypes TestPixelTypes = PixelTypes.Rgba32 | PixelTypes.RgbaVector | PixelTypes.Argb32; public static readonly string[] CommonTestImages = - { + [ TestImages.Png.Splash, TestImages.Png.FilterVar, @@ -35,29 +35,29 @@ public partial class PngDecoderTests TestImages.Png.Rgb24BppTrans, TestImages.Png.Bad.ChunkLength1, - TestImages.Png.Bad.ChunkLength2, - }; + TestImages.Png.Bad.ChunkLength2 + ]; public static readonly string[] TestImagesIssue1014 = - { + [ TestImages.Png.Issue1014_1, TestImages.Png.Issue1014_2, TestImages.Png.Issue1014_3, TestImages.Png.Issue1014_4, TestImages.Png.Issue1014_5, TestImages.Png.Issue1014_6 - }; + ]; public static readonly string[] TestImagesIssue1177 = - { + [ TestImages.Png.Issue1177_1, TestImages.Png.Issue1177_2 - }; + ]; public static readonly string[] CorruptedTestImages = - { + [ TestImages.Png.Bad.CorruptedChunk, TestImages.Png.Bad.ZlibOverflow, TestImages.Png.Bad.ZlibOverflow2, - TestImages.Png.Bad.ZlibZtxtBadHeader, - }; + TestImages.Png.Bad.ZlibZtxtBadHeader + ]; public static readonly TheoryData PixelFormatRange = new() { @@ -79,7 +79,7 @@ public partial class PngDecoderTests }; public static readonly string[] MultiFrameTestFiles = - { + [ TestImages.Png.APng, TestImages.Png.SplitIDatZeroLength, TestImages.Png.DisposeNone, @@ -90,7 +90,7 @@ public partial class PngDecoderTests TestImages.Png.BlendOverMultiple, TestImages.Png.FrameOffset, TestImages.Png.DefaultNotAnimated - }; + ]; [Theory] [MemberData(nameof(PixelFormatRange))] @@ -389,7 +389,7 @@ public void Identify_IgnoreCrcErrors(string imagePath, int expectedPixelSize) TestFile testFile = TestFile.Create(imagePath); using MemoryStream stream = new(testFile.Bytes, false); - ImageInfo imageInfo = Image.Identify(new DecoderOptions() { SegmentIntegrityHandling = SegmentIntegrityHandling.IgnoreData }, stream); + ImageInfo imageInfo = Image.Identify(new() { SegmentIntegrityHandling = SegmentIntegrityHandling.IgnoreData }, stream); Assert.NotNull(imageInfo); Assert.Equal(expectedPixelSize, imageInfo.PixelType.BitsPerPixel); @@ -679,7 +679,7 @@ public void Binary_PrematureEof() // TODO: Try to reduce this to 1. Assert.True(eofHitCounter.EofHitCount <= 3); - Assert.Equal(new Size(200, 120), eofHitCounter.Image.Size); + Assert.Equal(new(200, 120), eofHitCounter.Image.Size); } [Fact] diff --git a/tests/ImageSharp.Tests/Formats/Png/PngEncoderFilterTests.cs b/tests/ImageSharp.Tests/Formats/Png/PngEncoderFilterTests.cs index 796d35bf72..a930426b6d 100644 --- a/tests/ImageSharp.Tests/Formats/Png/PngEncoderFilterTests.cs +++ b/tests/ImageSharp.Tests/Formats/Png/PngEncoderFilterTests.cs @@ -31,7 +31,7 @@ public void Average() { static void RunTest() { - var data = new TestData(PngFilterMethod.Average, Size); + TestData data = new(PngFilterMethod.Average, Size); data.TestFilter(); } @@ -45,7 +45,7 @@ public void AverageSse2() { static void RunTest() { - var data = new TestData(PngFilterMethod.Average, Size); + TestData data = new(PngFilterMethod.Average, Size); data.TestFilter(); } @@ -59,7 +59,7 @@ public void AverageSsse3() { static void RunTest() { - var data = new TestData(PngFilterMethod.Average, Size); + TestData data = new(PngFilterMethod.Average, Size); data.TestFilter(); } @@ -73,7 +73,7 @@ public void AverageAvx2() { static void RunTest() { - var data = new TestData(PngFilterMethod.Average, Size); + TestData data = new(PngFilterMethod.Average, Size); data.TestFilter(); } @@ -87,7 +87,7 @@ public void Paeth() { static void RunTest() { - var data = new TestData(PngFilterMethod.Paeth, Size); + TestData data = new(PngFilterMethod.Paeth, Size); data.TestFilter(); } @@ -101,7 +101,7 @@ public void PaethAvx2() { static void RunTest() { - var data = new TestData(PngFilterMethod.Paeth, Size); + TestData data = new(PngFilterMethod.Paeth, Size); data.TestFilter(); } @@ -115,7 +115,7 @@ public void PaethVector() { static void RunTest() { - var data = new TestData(PngFilterMethod.Paeth, Size); + TestData data = new(PngFilterMethod.Paeth, Size); data.TestFilter(); } @@ -129,7 +129,7 @@ public void Up() { static void RunTest() { - var data = new TestData(PngFilterMethod.Up, Size); + TestData data = new(PngFilterMethod.Up, Size); data.TestFilter(); } @@ -143,7 +143,7 @@ public void UpAvx2() { static void RunTest() { - var data = new TestData(PngFilterMethod.Up, Size); + TestData data = new(PngFilterMethod.Up, Size); data.TestFilter(); } @@ -157,7 +157,7 @@ public void UpVector() { static void RunTest() { - var data = new TestData(PngFilterMethod.Up, Size); + TestData data = new(PngFilterMethod.Up, Size); data.TestFilter(); } @@ -171,7 +171,7 @@ public void Sub() { static void RunTest() { - var data = new TestData(PngFilterMethod.Sub, Size); + TestData data = new(PngFilterMethod.Sub, Size); data.TestFilter(); } @@ -185,7 +185,7 @@ public void SubAvx2() { static void RunTest() { - var data = new TestData(PngFilterMethod.Sub, Size); + TestData data = new(PngFilterMethod.Sub, Size); data.TestFilter(); } @@ -199,7 +199,7 @@ public void SubVector() { static void RunTest() { - var data = new TestData(PngFilterMethod.Sub, Size); + TestData data = new(PngFilterMethod.Sub, Size); data.TestFilter(); } @@ -227,7 +227,7 @@ public TestData(PngFilterMethod filter, int size, int bpp = 4) this.expectedResult = new byte[1 + (size * size * bpp)]; this.resultBuffer = new byte[1 + (size * size * bpp)]; - var rng = new Random(12345678); + Random rng = new(12345678); byte[] tmp = new byte[6]; for (int i = 0; i < this.previousScanline.Length; i += bpp) { diff --git a/tests/ImageSharp.Tests/Formats/Png/PngEncoderTests.Chunks.cs b/tests/ImageSharp.Tests/Formats/Png/PngEncoderTests.Chunks.cs index 76fd260dd5..fdaa70e031 100644 --- a/tests/ImageSharp.Tests/Formats/Png/PngEncoderTests.Chunks.cs +++ b/tests/ImageSharp.Tests/Formats/Png/PngEncoderTests.Chunks.cs @@ -188,15 +188,15 @@ public void IgnoreMetadata_WillExcludeAllAncillaryChunks() { PngChunkType.Data, false }, { PngChunkType.End, false } }; - List excludedChunkTypes = new() - { + List excludedChunkTypes = + [ PngChunkType.Gamma, PngChunkType.Exif, PngChunkType.Physical, PngChunkType.Text, PngChunkType.InternationalText, - PngChunkType.CompressedText, - }; + PngChunkType.CompressedText + ]; // act input.Save(memStream, encoder); @@ -252,7 +252,7 @@ public void ExcludeFilter_Works(object filterObj) { PngChunkType.Data, false }, { PngChunkType.End, false } }; - List excludedChunkTypes = new(); + List excludedChunkTypes = []; switch (chunkFilter) { case PngChunkFilter.ExcludeGammaChunk: @@ -326,8 +326,8 @@ public void ExcludeFilter_WithNone_DoesNotExcludeChunks() using Image input = testFile.CreateRgba32Image(); using MemoryStream memStream = new(); PngEncoder encoder = new() { ChunkFilter = PngChunkFilter.None, TextCompressionThreshold = 8 }; - List expectedChunkTypes = new() - { + List expectedChunkTypes = + [ PngChunkType.Header, PngChunkType.Gamma, PngChunkType.EmbeddedColorProfile, @@ -338,8 +338,8 @@ public void ExcludeFilter_WithNone_DoesNotExcludeChunks() PngChunkType.Exif, PngChunkType.Physical, PngChunkType.Data, - PngChunkType.End, - }; + PngChunkType.End + ]; // act input.Save(memStream, encoder); diff --git a/tests/ImageSharp.Tests/Formats/Png/PngEncoderTests.cs b/tests/ImageSharp.Tests/Formats/Png/PngEncoderTests.cs index 009327c17f..0f91fff21a 100644 --- a/tests/ImageSharp.Tests/Formats/Png/PngEncoderTests.cs +++ b/tests/ImageSharp.Tests/Formats/Png/PngEncoderTests.cs @@ -88,11 +88,11 @@ public static readonly TheoryData CompressionLevels 80, 100, 120, 230 }; - public static readonly PngInterlaceMode[] InterlaceMode = new[] - { + public static readonly PngInterlaceMode[] InterlaceMode = + [ PngInterlaceMode.None, PngInterlaceMode.Adam7 - }; + ]; public static readonly TheoryData RatioFiles = new() @@ -289,8 +289,8 @@ public void WritesFileMarker(TestImageProvider provider) byte[] data = ms.ToArray().Take(8).ToArray(); byte[] expected = - { - 0x89, // Set the high bit. + [ + 0x89, // Set the high bit. 0x50, // P 0x4E, // N 0x47, // G @@ -298,7 +298,7 @@ public void WritesFileMarker(TestImageProvider provider) 0x0A, // Line ending CRLF 0x1A, // EOF 0x0A // LF - }; + ]; Assert.Equal(expected, data); } @@ -380,7 +380,7 @@ public void Encode_WithPngTransparentColorBehaviorClear_Works(PngColorType color if (colorType is PngColorType.Grayscale or PngColorType.GrayscaleWithAlpha) { byte luminance = ColorNumerics.Get8BitBT709Luminance(expectedColor.R, expectedColor.G, expectedColor.B); - expectedColor = new Rgba32(luminance, luminance, luminance); + expectedColor = new(luminance, luminance, luminance); } actual.ProcessPixelRows(accessor => @@ -681,7 +681,7 @@ private static void TestPngEncoderCore( FilterMethod = pngFilterMethod, CompressionLevel = compressionLevel, BitDepth = bitDepth, - Quantizer = new WuQuantizer(new QuantizerOptions { MaxColors = paletteSize }), + Quantizer = new WuQuantizer(new() { MaxColors = paletteSize }), InterlaceMethod = interlaceMode, ChunkFilter = optimizeMethod, }; diff --git a/tests/ImageSharp.Tests/Formats/Png/PngMetadataTests.cs b/tests/ImageSharp.Tests/Formats/Png/PngMetadataTests.cs index 225e4deef2..6902990240 100644 --- a/tests/ImageSharp.Tests/Formats/Png/PngMetadataTests.cs +++ b/tests/ImageSharp.Tests/Formats/Png/PngMetadataTests.cs @@ -31,7 +31,7 @@ public void CloneIsDeep() ColorType = PngColorType.GrayscaleWithAlpha, InterlaceMethod = PngInterlaceMode.Adam7, Gamma = 2, - TextData = new List { new PngTextData("name", "value", "foo", "bar") }, + TextData = new List { new("name", "value", "foo", "bar") }, RepeatCount = 123, AnimateRootFrame = false }; @@ -111,10 +111,10 @@ public void Encode_UseCompression_WhenTextIsGreaterThenThreshold_Works(T using MemoryStream memoryStream = new(); // This will be a zTXt chunk. - PngTextData expectedText = new("large-text", new string('c', 100), string.Empty, string.Empty); + PngTextData expectedText = new("large-text", new('c', 100), string.Empty, string.Empty); // This will be a iTXt chunk. - PngTextData expectedTextNoneLatin = new("large-text-non-latin", new string('Ф', 100), "language-tag", "translated-keyword"); + PngTextData expectedTextNoneLatin = new("large-text-non-latin", new('Ф', 100), "language-tag", "translated-keyword"); PngMetadata inputMetadata = input.Metadata.GetFormatMetadata(PngFormat.Instance); inputMetadata.TextData.Add(expectedText); inputMetadata.TextData.Add(expectedTextNoneLatin); diff --git a/tests/ImageSharp.Tests/Formats/Png/PngTextDataTests.cs b/tests/ImageSharp.Tests/Formats/Png/PngTextDataTests.cs index 878f3fb8d4..f4c2f58978 100644 --- a/tests/ImageSharp.Tests/Formats/Png/PngTextDataTests.cs +++ b/tests/ImageSharp.Tests/Formats/Png/PngTextDataTests.cs @@ -17,8 +17,8 @@ public class PngTextDataTests [Fact] public void AreEqual() { - var property1 = new PngTextData("Foo", "Bar", "foo", "bar"); - var property2 = new PngTextData("Foo", "Bar", "foo", "bar"); + PngTextData property1 = new("Foo", "Bar", "foo", "bar"); + PngTextData property2 = new("Foo", "Bar", "foo", "bar"); Assert.Equal(property1, property2); Assert.True(property1 == property2); @@ -30,10 +30,10 @@ public void AreEqual() [Fact] public void AreNotEqual() { - var property1 = new PngTextData("Foo", "Bar", "foo", "bar"); - var property2 = new PngTextData("Foo", "Foo", string.Empty, string.Empty); - var property3 = new PngTextData("Bar", "Bar", "unit", "test"); - var property4 = new PngTextData("Foo", null, "test", "case"); + PngTextData property1 = new("Foo", "Bar", "foo", "bar"); + PngTextData property2 = new("Foo", "Foo", string.Empty, string.Empty); + PngTextData property3 = new("Bar", "Bar", "unit", "test"); + PngTextData property4 = new("Foo", null, "test", "case"); Assert.NotEqual(property1, property2); Assert.True(property1 != property2); @@ -59,13 +59,13 @@ public void ConstructorThrowsWhenKeywordIsNullOrEmpty() [Fact] public void ConstructorAssignsProperties() { - var property = new PngTextData("Foo", null, "unit", "test"); + PngTextData property = new("Foo", null, "unit", "test"); Assert.Equal("Foo", property.Keyword); Assert.Null(property.Value); Assert.Equal("unit", property.LanguageTag); Assert.Equal("test", property.TranslatedKeyword); - property = new PngTextData("Foo", string.Empty, string.Empty, null); + property = new("Foo", string.Empty, string.Empty, null); Assert.Equal("Foo", property.Keyword); Assert.Equal(string.Empty, property.Value); Assert.Equal(string.Empty, property.LanguageTag); diff --git a/tests/ImageSharp.Tests/Formats/Qoi/ImageExtensionsTest.cs b/tests/ImageSharp.Tests/Formats/Qoi/ImageExtensionsTest.cs index 31ec27da0c..11e79512ef 100644 --- a/tests/ImageSharp.Tests/Formats/Qoi/ImageExtensionsTest.cs +++ b/tests/ImageSharp.Tests/Formats/Qoi/ImageExtensionsTest.cs @@ -47,7 +47,7 @@ public void SaveAsQoi_Path_Encoder() using (Image image = new(10, 10)) { - image.SaveAsQoi(file, new QoiEncoder()); + image.SaveAsQoi(file, new()); } IImageFormat format = Image.DetectFormat(file); @@ -108,7 +108,7 @@ public void SaveAsQoi_Stream_Encoder() using (Image image = new(10, 10)) { - image.SaveAsQoi(memoryStream, new QoiEncoder()); + image.SaveAsQoi(memoryStream, new()); } memoryStream.Position = 0; diff --git a/tests/ImageSharp.Tests/Formats/Tga/ImageExtensionsTest.cs b/tests/ImageSharp.Tests/Formats/Tga/ImageExtensionsTest.cs index 9b6daee4c9..9648f93e52 100644 --- a/tests/ImageSharp.Tests/Formats/Tga/ImageExtensionsTest.cs +++ b/tests/ImageSharp.Tests/Formats/Tga/ImageExtensionsTest.cs @@ -47,7 +47,7 @@ public void SaveAsTga_Path_Encoder() using (Image image = new(10, 10)) { - image.SaveAsTga(file, new TgaEncoder()); + image.SaveAsTga(file, new()); } IImageFormat format = Image.DetectFormat(file); @@ -108,7 +108,7 @@ public void SaveAsTga_Stream_Encoder() using (Image image = new(10, 10)) { - image.SaveAsTga(memoryStream, new TgaEncoder()); + image.SaveAsTga(memoryStream, new()); } memoryStream.Position = 0; diff --git a/tests/ImageSharp.Tests/Formats/Tga/TgaEncoderTests.cs b/tests/ImageSharp.Tests/Formats/Tga/TgaEncoderTests.cs index 615e0fc921..58d1563517 100644 --- a/tests/ImageSharp.Tests/Formats/Tga/TgaEncoderTests.cs +++ b/tests/ImageSharp.Tests/Formats/Tga/TgaEncoderTests.cs @@ -32,16 +32,16 @@ public class TgaEncoderTests [MemberData(nameof(TgaBitsPerPixelFiles))] public void TgaEncoder_PreserveBitsPerPixel(string imagePath, TgaBitsPerPixel bmpBitsPerPixel) { - var options = new TgaEncoder(); + TgaEncoder options = new(); - var testFile = TestFile.Create(imagePath); + TestFile testFile = TestFile.Create(imagePath); using (Image input = testFile.CreateRgba32Image()) { - using (var memStream = new MemoryStream()) + using (MemoryStream memStream = new()) { input.Save(memStream, options); memStream.Position = 0; - using (var output = Image.Load(memStream)) + using (Image output = Image.Load(memStream)) { TgaMetadata meta = output.Metadata.GetTgaMetadata(); Assert.Equal(bmpBitsPerPixel, meta.BitsPerPixel); @@ -54,15 +54,15 @@ public void TgaEncoder_PreserveBitsPerPixel(string imagePath, TgaBitsPerPixel bm [MemberData(nameof(TgaBitsPerPixelFiles))] public void TgaEncoder_WithCompression_PreserveBitsPerPixel(string imagePath, TgaBitsPerPixel bmpBitsPerPixel) { - var options = new TgaEncoder() { Compression = TgaCompression.RunLength }; - var testFile = TestFile.Create(imagePath); + TgaEncoder options = new() { Compression = TgaCompression.RunLength }; + TestFile testFile = TestFile.Create(imagePath); using (Image input = testFile.CreateRgba32Image()) { - using (var memStream = new MemoryStream()) + using (MemoryStream memStream = new()) { input.Save(memStream, options); memStream.Position = 0; - using (var output = Image.Load(memStream)) + using (Image output = Image.Load(memStream)) { TgaMetadata meta = output.Metadata.GetTgaMetadata(); Assert.Equal(bmpBitsPerPixel, meta.BitsPerPixel); @@ -136,11 +136,11 @@ public void TgaEncoder_DoesNotAlwaysUseRunLengthPackets(TestImageProvide [Fact] public void TgaEncoder_RunLengthDoesNotCrossRowBoundaries() { - var options = new TgaEncoder() { Compression = TgaCompression.RunLength }; + TgaEncoder options = new() { Compression = TgaCompression.RunLength }; - using (var input = new Image(30, 30)) + using (Image input = new(30, 30)) { - using (var memStream = new MemoryStream()) + using (MemoryStream memStream = new()) { input.Save(memStream, options); byte[] imageBytes = memStream.ToArray(); @@ -169,14 +169,14 @@ private static void TestTgaEncoderCore( { using (Image image = provider.GetImage()) { - var encoder = new TgaEncoder { BitsPerPixel = bitsPerPixel, Compression = compression }; + TgaEncoder encoder = new() { BitsPerPixel = bitsPerPixel, Compression = compression }; - using (var memStream = new MemoryStream()) + using (MemoryStream memStream = new()) { image.DebugSave(provider, encoder); image.Save(memStream, encoder); memStream.Position = 0; - using (var encodedImage = (Image)Image.Load(memStream)) + using (Image encodedImage = (Image)Image.Load(memStream)) { ImageComparingUtils.CompareWithReferenceDecoder(provider, encodedImage, useExactComparer, compareTolerance); } diff --git a/tests/ImageSharp.Tests/Formats/Tiff/BigTiffMetadataTests.cs b/tests/ImageSharp.Tests/Formats/Tiff/BigTiffMetadataTests.cs index 4646de7f82..ba4f4fe4e8 100644 --- a/tests/ImageSharp.Tests/Formats/Tiff/BigTiffMetadataTests.cs +++ b/tests/ImageSharp.Tests/Formats/Tiff/BigTiffMetadataTests.cs @@ -16,7 +16,7 @@ public class BigTiffMetadataTests [Fact] public void ExifLong8() { - var long8 = new ExifLong8(ExifTagValue.StripByteCounts); + ExifLong8 long8 = new(ExifTagValue.StripByteCounts); Assert.True(long8.TrySetValue(0)); Assert.Equal(0UL, long8.GetValue()); @@ -34,7 +34,7 @@ public void ExifLong8() [Fact] public void ExifSignedLong8() { - var long8 = new ExifSignedLong8(ExifTagValue.ImageID); + ExifSignedLong8 long8 = new(ExifTagValue.ImageID); Assert.False(long8.TrySetValue(0)); @@ -53,7 +53,7 @@ public void ExifSignedLong8() [Fact] public void ExifLong8Array() { - var long8 = new ExifLong8Array(ExifTagValue.StripOffsets); + ExifLong8Array long8 = new(ExifTagValue.StripOffsets); Assert.True(long8.TrySetValue((short)-123)); Assert.Equal(new[] { 0UL }, long8.GetValue()); @@ -91,7 +91,7 @@ public void ExifLong8Array() [Fact] public void ExifSignedLong8Array() { - var long8 = new ExifSignedLong8Array(ExifTagValue.StripOffsets); + ExifSignedLong8Array long8 = new(ExifTagValue.StripOffsets); Assert.True(long8.TrySetValue(new[] { 0L })); Assert.Equal(new[] { 0L }, long8.GetValue()); @@ -105,9 +105,9 @@ public void ExifSignedLong8Array() [Fact] public void NotCoveredTags() { - using var input = new Image(10, 10); + using Image input = new(10, 10); - var testTags = new Dictionary + Dictionary testTags = new() { { new ExifTag((ExifTagValue)0xdd01), (ExifDataType.SingleFloat, new float[] { 1.2f, 2.3f, 4.5f }) }, { new ExifTag((ExifTagValue)0xdd02), (ExifDataType.SingleFloat, 2.345f) }, @@ -122,7 +122,7 @@ public void NotCoveredTags() }; // arrange - var values = new List(); + List values = []; foreach (KeyValuePair tag in testTags) { ExifValue newExifValue = ExifValues.Create((ExifTagValue)(ushort)tag.Key, tag.Value.DataType, tag.Value.Value is Array); @@ -131,16 +131,16 @@ public void NotCoveredTags() values.Add(newExifValue); } - input.Frames.RootFrame.Metadata.ExifProfile = new ExifProfile(values, Array.Empty()); + input.Frames.RootFrame.Metadata.ExifProfile = new(values, Array.Empty()); // act - var encoder = new TiffEncoder(); - using var memStream = new MemoryStream(); + TiffEncoder encoder = new(); + using MemoryStream memStream = new(); input.Save(memStream, encoder); // assert memStream.Position = 0; - using var output = Image.Load(memStream); + using Image output = Image.Load(memStream); ImageFrameMetadata loadedFrameMetadata = output.Frames.RootFrame.Metadata; foreach (KeyValuePair tag in testTags) { @@ -158,7 +158,7 @@ public void NotCoveredTags() [Fact] public void NotCoveredTags64bit() { - var testTags = new Dictionary + Dictionary testTags = new() { { new ExifTag((ExifTagValue)0xdd11), (ExifDataType.Long8, ulong.MaxValue) }, { new ExifTag((ExifTagValue)0xdd12), (ExifDataType.SignedLong8, long.MaxValue) }, @@ -167,7 +167,7 @@ public void NotCoveredTags64bit() ////{ new ExifTag((ExifTagValue)0xdd14), (ExifDataType.SignedLong8, new long[] { -1234, 56789L, long.MaxValue }) }, }; - var values = new List(); + List values = []; foreach (KeyValuePair tag in testTags) { ExifValue newExifValue = ExifValues.Create((ExifTagValue)(ushort)tag.Key, tag.Value.DataType, tag.Value.Value is Array); @@ -179,7 +179,7 @@ public void NotCoveredTags64bit() // act byte[] inputBytes = WriteIfdTags64Bit(values); Configuration config = Configuration.Default; - var reader = new EntryReader( + EntryReader reader = new( new MemoryStream(inputBytes), BitConverter.IsLittleEndian ? ByteOrder.LittleEndian : ByteOrder.BigEndian, config.MemoryAllocator); @@ -205,8 +205,8 @@ public void NotCoveredTags64bit() private static byte[] WriteIfdTags64Bit(List values) { byte[] buffer = new byte[8]; - var ms = new MemoryStream(); - var writer = new TiffStreamWriter(ms); + MemoryStream ms = new(); + TiffStreamWriter writer = new(ms); WriteLong8(writer, buffer, (ulong)values.Count); foreach (IExifValue entry in values) diff --git a/tests/ImageSharp.Tests/Formats/Tiff/Compression/DeflateTiffCompressionTests.cs b/tests/ImageSharp.Tests/Formats/Tiff/Compression/DeflateTiffCompressionTests.cs index 1b12adac23..0f6c05556b 100644 --- a/tests/ImageSharp.Tests/Formats/Tiff/Compression/DeflateTiffCompressionTests.cs +++ b/tests/ImageSharp.Tests/Formats/Tiff/Compression/DeflateTiffCompressionTests.cs @@ -23,7 +23,7 @@ public void Compress_Decompress_Roundtrip_Works(byte[] data) using BufferedReadStream stream = CreateCompressedStream(data); byte[] buffer = new byte[data.Length]; - using var decompressor = new DeflateTiffCompression(Configuration.Default.MemoryAllocator, 10, 8, TiffColorType.BlackIsZero8, TiffPredictor.None, false); + using DeflateTiffCompression decompressor = new(Configuration.Default.MemoryAllocator, 10, 8, TiffColorType.BlackIsZero8, TiffPredictor.None, false); decompressor.Decompress(stream, 0, (uint)stream.Length, 1, buffer, default); @@ -41,6 +41,6 @@ private static BufferedReadStream CreateCompressedStream(byte[] data) } compressedStream.Seek(0, SeekOrigin.Begin); - return new BufferedReadStream(Configuration.Default, compressedStream); + return new(Configuration.Default, compressedStream); } } diff --git a/tests/ImageSharp.Tests/Formats/Tiff/Compression/LzwTiffCompressionTests.cs b/tests/ImageSharp.Tests/Formats/Tiff/Compression/LzwTiffCompressionTests.cs index 635a3a33e4..41c3c38d7a 100644 --- a/tests/ImageSharp.Tests/Formats/Tiff/Compression/LzwTiffCompressionTests.cs +++ b/tests/ImageSharp.Tests/Formats/Tiff/Compression/LzwTiffCompressionTests.cs @@ -37,7 +37,7 @@ public void Compress_Decompress_Roundtrip_Works(byte[] data) using BufferedReadStream stream = CreateCompressedStream(data); byte[] buffer = new byte[data.Length]; - using var decompressor = new LzwTiffCompression(Configuration.Default.MemoryAllocator, 10, 8, TiffColorType.BlackIsZero8, TiffPredictor.None, false); + using LzwTiffCompression decompressor = new(Configuration.Default.MemoryAllocator, 10, 8, TiffColorType.BlackIsZero8, TiffPredictor.None, false); decompressor.Decompress(stream, 0, (uint)stream.Length, 1, buffer, default); Assert.Equal(data, buffer); @@ -47,13 +47,13 @@ private static BufferedReadStream CreateCompressedStream(byte[] inputData) { Stream compressedStream = new MemoryStream(); - using (var encoder = new TiffLzwEncoder(Configuration.Default.MemoryAllocator)) + using (TiffLzwEncoder encoder = new(Configuration.Default.MemoryAllocator)) { encoder.Encode(inputData, compressedStream); } compressedStream.Seek(0, SeekOrigin.Begin); - return new BufferedReadStream(Configuration.Default, compressedStream); + return new(Configuration.Default, compressedStream); } } diff --git a/tests/ImageSharp.Tests/Formats/Tiff/Compression/NoneTiffCompressionTests.cs b/tests/ImageSharp.Tests/Formats/Tiff/Compression/NoneTiffCompressionTests.cs index e79ed7ce77..b911d1b177 100644 --- a/tests/ImageSharp.Tests/Formats/Tiff/Compression/NoneTiffCompressionTests.cs +++ b/tests/ImageSharp.Tests/Formats/Tiff/Compression/NoneTiffCompressionTests.cs @@ -14,11 +14,11 @@ public class NoneTiffCompressionTests [InlineData(new byte[] { 10, 15, 20, 25, 30, 35, 40, 45 }, 5, new byte[] { 10, 15, 20, 25, 30 })] public void Decompress_ReadsData(byte[] inputData, uint byteCount, byte[] expectedResult) { - using var memoryStream = new MemoryStream(inputData); - using var stream = new BufferedReadStream(Configuration.Default, memoryStream); + using MemoryStream memoryStream = new(inputData); + using BufferedReadStream stream = new(Configuration.Default, memoryStream); byte[] buffer = new byte[expectedResult.Length]; - using var decompressor = new NoneTiffCompression(default, default, default); + using NoneTiffCompression decompressor = new(default, default, default); decompressor.Decompress(stream, 0, byteCount, 1, buffer, default); Assert.Equal(expectedResult, buffer); diff --git a/tests/ImageSharp.Tests/Formats/Tiff/Compression/PackBitsTiffCompressionTests.cs b/tests/ImageSharp.Tests/Formats/Tiff/Compression/PackBitsTiffCompressionTests.cs index c91ab0e7fe..8f71cdda74 100644 --- a/tests/ImageSharp.Tests/Formats/Tiff/Compression/PackBitsTiffCompressionTests.cs +++ b/tests/ImageSharp.Tests/Formats/Tiff/Compression/PackBitsTiffCompressionTests.cs @@ -22,11 +22,11 @@ public class PackBitsTiffCompressionTests [InlineData(new byte[] { 0xFE, 0xAA, 0x02, 0x80, 0x00, 0x2A, 0xFD, 0xAA, 0x03, 0x80, 0x00, 0x2A, 0x22, 0xF7, 0xAA }, new byte[] { 0xAA, 0xAA, 0xAA, 0x80, 0x00, 0x2A, 0xAA, 0xAA, 0xAA, 0xAA, 0x80, 0x00, 0x2A, 0x22, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA })] // Apple PackBits sample public void Decompress_ReadsData(byte[] inputData, byte[] expectedResult) { - using var memoryStream = new MemoryStream(inputData); - using var stream = new BufferedReadStream(Configuration.Default, memoryStream); + using MemoryStream memoryStream = new(inputData); + using BufferedReadStream stream = new(Configuration.Default, memoryStream); byte[] buffer = new byte[expectedResult.Length]; - using var decompressor = new PackBitsTiffCompression(MemoryAllocator.Create(), default, default); + using PackBitsTiffCompression decompressor = new(MemoryAllocator.Create(), default, default); decompressor.Decompress(stream, 0, (uint)inputData.Length, 1, buffer, default); Assert.Equal(expectedResult, buffer); diff --git a/tests/ImageSharp.Tests/Formats/Tiff/ImageExtensionsTest.cs b/tests/ImageSharp.Tests/Formats/Tiff/ImageExtensionsTest.cs index bf9e73ea6e..69d70e5e7e 100644 --- a/tests/ImageSharp.Tests/Formats/Tiff/ImageExtensionsTest.cs +++ b/tests/ImageSharp.Tests/Formats/Tiff/ImageExtensionsTest.cs @@ -48,7 +48,7 @@ public void SaveAsTiff_Path_Encoder() using (Image image = new(10, 10)) { - image.SaveAsTiff(file, new TiffEncoder()); + image.SaveAsTiff(file, new()); } IImageFormat format = Image.DetectFormat(file); @@ -109,7 +109,7 @@ public void SaveAsTiff_Stream_Encoder() using (Image image = new(10, 10)) { - image.SaveAsTiff(memoryStream, new TiffEncoder()); + image.SaveAsTiff(memoryStream, new()); } memoryStream.Position = 0; diff --git a/tests/ImageSharp.Tests/Formats/Tiff/PhotometricInterpretation/BlackIsZeroTiffColorTests.cs b/tests/ImageSharp.Tests/Formats/Tiff/PhotometricInterpretation/BlackIsZeroTiffColorTests.cs index 0fa7e01e8e..f359eeafcf 100644 --- a/tests/ImageSharp.Tests/Formats/Tiff/PhotometricInterpretation/BlackIsZeroTiffColorTests.cs +++ b/tests/ImageSharp.Tests/Formats/Tiff/PhotometricInterpretation/BlackIsZeroTiffColorTests.cs @@ -20,100 +20,100 @@ public class BlackIsZeroTiffColorTests : PhotometricInterpretationTestBase private static readonly Rgba32 Bit1 = new(255, 255, 255, 255); private static readonly byte[] BilevelBytes4X4 = - { + [ 0b01010000, 0b11110000, 0b01110000, 0b10010000 - }; + ]; private static readonly Rgba32[][] BilevelResult4X4 = - { - new[] { Bit0, Bit1, Bit0, Bit1 }, - new[] { Bit1, Bit1, Bit1, Bit1 }, - new[] { Bit0, Bit1, Bit1, Bit1 }, - new[] { Bit1, Bit0, Bit0, Bit1 } - }; + [ + [Bit0, Bit1, Bit0, Bit1], + [Bit1, Bit1, Bit1, Bit1], + [Bit0, Bit1, Bit1, Bit1], + [Bit1, Bit0, Bit0, Bit1] + ]; private static readonly byte[] BilevelBytes12X4 = - { + [ 0b01010101, 0b01010000, 0b11111111, 0b11111111, 0b01101001, 0b10100000, 0b10010000, 0b01100000 - }; + ]; private static readonly Rgba32[][] BilevelResult12X4 = - { - new[] { Bit0, Bit1, Bit0, Bit1, Bit0, Bit1, Bit0, Bit1, Bit0, Bit1, Bit0, Bit1 }, - new[] { Bit1, Bit1, Bit1, Bit1, Bit1, Bit1, Bit1, Bit1, Bit1, Bit1, Bit1, Bit1 }, - new[] { Bit0, Bit1, Bit1, Bit0, Bit1, Bit0, Bit0, Bit1, Bit1, Bit0, Bit1, Bit0 }, - new[] { Bit1, Bit0, Bit0, Bit1, Bit0, Bit0, Bit0, Bit0, Bit0, Bit1, Bit1, Bit0 } - }; + [ + [Bit0, Bit1, Bit0, Bit1, Bit0, Bit1, Bit0, Bit1, Bit0, Bit1, Bit0, Bit1], + [Bit1, Bit1, Bit1, Bit1, Bit1, Bit1, Bit1, Bit1, Bit1, Bit1, Bit1, Bit1], + [Bit0, Bit1, Bit1, Bit0, Bit1, Bit0, Bit0, Bit1, Bit1, Bit0, Bit1, Bit0], + [Bit1, Bit0, Bit0, Bit1, Bit0, Bit0, Bit0, Bit0, Bit0, Bit1, Bit1, Bit0] + ]; private static readonly byte[] Grayscale4Bytes4X4 = - { + [ 0x8F, 0x0F, 0xFF, 0xFF, 0x08, 0x8F, 0xF0, 0xF8 - }; + ]; private static readonly Rgba32[][] Grayscale4Result4X4 = - { - new[] { Gray8, GrayF, Gray0, GrayF }, - new[] { GrayF, GrayF, GrayF, GrayF }, - new[] { Gray0, Gray8, Gray8, GrayF }, - new[] { GrayF, Gray0, GrayF, Gray8 } - }; + [ + [Gray8, GrayF, Gray0, GrayF], + [GrayF, GrayF, GrayF, GrayF], + [Gray0, Gray8, Gray8, GrayF], + [GrayF, Gray0, GrayF, Gray8] + ]; private static readonly byte[] Grayscale4Bytes3X4 = - { + [ 0x8F, 0x00, 0xFF, 0xF0, 0x08, 0x80, 0xF0, 0xF0 - }; + ]; private static readonly Rgba32[][] Grayscale4Result3X4 = - { - new[] { Gray8, GrayF, Gray0 }, - new[] { GrayF, GrayF, GrayF }, - new[] { Gray0, Gray8, Gray8 }, - new[] { GrayF, Gray0, GrayF } - }; + [ + [Gray8, GrayF, Gray0], + [GrayF, GrayF, GrayF], + [Gray0, Gray8, Gray8], + [GrayF, Gray0, GrayF] + ]; private static readonly byte[] Grayscale8Bytes4X4 = - { + [ 128, 255, 000, 255, 255, 255, 255, 255, 000, 128, 128, 255, 255, 000, 255, 128 - }; + ]; private static readonly Rgba32[][] Grayscale8Result4X4 = - { - new[] { Gray128, Gray255, Gray000, Gray255 }, - new[] { Gray255, Gray255, Gray255, Gray255 }, - new[] { Gray000, Gray128, Gray128, Gray255 }, - new[] { Gray255, Gray000, Gray255, Gray128 } - }; + [ + [Gray128, Gray255, Gray000, Gray255], + [Gray255, Gray255, Gray255, Gray255], + [Gray000, Gray128, Gray128, Gray255], + [Gray255, Gray000, Gray255, Gray128] + ]; public static IEnumerable BilevelData { get { - yield return new object[] { BilevelBytes4X4, 1, 0, 0, 4, 4, BilevelResult4X4 }; - yield return new object[] { BilevelBytes4X4, 1, 0, 0, 4, 4, Offset(BilevelResult4X4, 0, 0, 6, 6) }; - yield return new object[] { BilevelBytes4X4, 1, 1, 0, 4, 4, Offset(BilevelResult4X4, 1, 0, 6, 6) }; - yield return new object[] { BilevelBytes4X4, 1, 0, 1, 4, 4, Offset(BilevelResult4X4, 0, 1, 6, 6) }; - yield return new object[] { BilevelBytes4X4, 1, 1, 1, 4, 4, Offset(BilevelResult4X4, 1, 1, 6, 6) }; - - yield return new object[] { BilevelBytes12X4, 1, 0, 0, 12, 4, BilevelResult12X4 }; - yield return new object[] { BilevelBytes12X4, 1, 0, 0, 12, 4, Offset(BilevelResult12X4, 0, 0, 18, 6) }; - yield return new object[] { BilevelBytes12X4, 1, 1, 0, 12, 4, Offset(BilevelResult12X4, 1, 0, 18, 6) }; - yield return new object[] { BilevelBytes12X4, 1, 0, 1, 12, 4, Offset(BilevelResult12X4, 0, 1, 18, 6) }; - yield return new object[] { BilevelBytes12X4, 1, 1, 1, 12, 4, Offset(BilevelResult12X4, 1, 1, 18, 6) }; + yield return [BilevelBytes4X4, 1, 0, 0, 4, 4, BilevelResult4X4]; + yield return [BilevelBytes4X4, 1, 0, 0, 4, 4, Offset(BilevelResult4X4, 0, 0, 6, 6)]; + yield return [BilevelBytes4X4, 1, 1, 0, 4, 4, Offset(BilevelResult4X4, 1, 0, 6, 6)]; + yield return [BilevelBytes4X4, 1, 0, 1, 4, 4, Offset(BilevelResult4X4, 0, 1, 6, 6)]; + yield return [BilevelBytes4X4, 1, 1, 1, 4, 4, Offset(BilevelResult4X4, 1, 1, 6, 6)]; + + yield return [BilevelBytes12X4, 1, 0, 0, 12, 4, BilevelResult12X4]; + yield return [BilevelBytes12X4, 1, 0, 0, 12, 4, Offset(BilevelResult12X4, 0, 0, 18, 6)]; + yield return [BilevelBytes12X4, 1, 1, 0, 12, 4, Offset(BilevelResult12X4, 1, 0, 18, 6)]; + yield return [BilevelBytes12X4, 1, 0, 1, 12, 4, Offset(BilevelResult12X4, 0, 1, 18, 6)]; + yield return [BilevelBytes12X4, 1, 1, 1, 12, 4, Offset(BilevelResult12X4, 1, 1, 18, 6)]; } } @@ -121,17 +121,17 @@ public static IEnumerable Grayscale4_Data { get { - yield return new object[] { Grayscale4Bytes4X4, 4, 0, 0, 4, 4, Grayscale4Result4X4 }; - yield return new object[] { Grayscale4Bytes4X4, 4, 0, 0, 4, 4, Offset(Grayscale4Result4X4, 0, 0, 6, 6) }; - yield return new object[] { Grayscale4Bytes4X4, 4, 1, 0, 4, 4, Offset(Grayscale4Result4X4, 1, 0, 6, 6) }; - yield return new object[] { Grayscale4Bytes4X4, 4, 0, 1, 4, 4, Offset(Grayscale4Result4X4, 0, 1, 6, 6) }; - yield return new object[] { Grayscale4Bytes4X4, 4, 1, 1, 4, 4, Offset(Grayscale4Result4X4, 1, 1, 6, 6) }; - - yield return new object[] { Grayscale4Bytes3X4, 4, 0, 0, 3, 4, Grayscale4Result3X4 }; - yield return new object[] { Grayscale4Bytes3X4, 4, 0, 0, 3, 4, Offset(Grayscale4Result3X4, 0, 0, 6, 6) }; - yield return new object[] { Grayscale4Bytes3X4, 4, 1, 0, 3, 4, Offset(Grayscale4Result3X4, 1, 0, 6, 6) }; - yield return new object[] { Grayscale4Bytes3X4, 4, 0, 1, 3, 4, Offset(Grayscale4Result3X4, 0, 1, 6, 6) }; - yield return new object[] { Grayscale4Bytes3X4, 4, 1, 1, 3, 4, Offset(Grayscale4Result3X4, 1, 1, 6, 6) }; + yield return [Grayscale4Bytes4X4, 4, 0, 0, 4, 4, Grayscale4Result4X4]; + yield return [Grayscale4Bytes4X4, 4, 0, 0, 4, 4, Offset(Grayscale4Result4X4, 0, 0, 6, 6)]; + yield return [Grayscale4Bytes4X4, 4, 1, 0, 4, 4, Offset(Grayscale4Result4X4, 1, 0, 6, 6)]; + yield return [Grayscale4Bytes4X4, 4, 0, 1, 4, 4, Offset(Grayscale4Result4X4, 0, 1, 6, 6)]; + yield return [Grayscale4Bytes4X4, 4, 1, 1, 4, 4, Offset(Grayscale4Result4X4, 1, 1, 6, 6)]; + + yield return [Grayscale4Bytes3X4, 4, 0, 0, 3, 4, Grayscale4Result3X4]; + yield return [Grayscale4Bytes3X4, 4, 0, 0, 3, 4, Offset(Grayscale4Result3X4, 0, 0, 6, 6)]; + yield return [Grayscale4Bytes3X4, 4, 1, 0, 3, 4, Offset(Grayscale4Result3X4, 1, 0, 6, 6)]; + yield return [Grayscale4Bytes3X4, 4, 0, 1, 3, 4, Offset(Grayscale4Result3X4, 0, 1, 6, 6)]; + yield return [Grayscale4Bytes3X4, 4, 1, 1, 3, 4, Offset(Grayscale4Result3X4, 1, 1, 6, 6)]; } } @@ -139,11 +139,11 @@ public static IEnumerable Grayscale8_Data { get { - yield return new object[] { Grayscale8Bytes4X4, 8, 0, 0, 4, 4, Grayscale8Result4X4 }; - yield return new object[] { Grayscale8Bytes4X4, 8, 0, 0, 4, 4, Offset(Grayscale8Result4X4, 0, 0, 6, 6) }; - yield return new object[] { Grayscale8Bytes4X4, 8, 1, 0, 4, 4, Offset(Grayscale8Result4X4, 1, 0, 6, 6) }; - yield return new object[] { Grayscale8Bytes4X4, 8, 0, 1, 4, 4, Offset(Grayscale8Result4X4, 0, 1, 6, 6) }; - yield return new object[] { Grayscale8Bytes4X4, 8, 1, 1, 4, 4, Offset(Grayscale8Result4X4, 1, 1, 6, 6) }; + yield return [Grayscale8Bytes4X4, 8, 0, 0, 4, 4, Grayscale8Result4X4]; + yield return [Grayscale8Bytes4X4, 8, 0, 0, 4, 4, Offset(Grayscale8Result4X4, 0, 0, 6, 6)]; + yield return [Grayscale8Bytes4X4, 8, 1, 0, 4, 4, Offset(Grayscale8Result4X4, 1, 0, 6, 6)]; + yield return [Grayscale8Bytes4X4, 8, 0, 1, 4, 4, Offset(Grayscale8Result4X4, 0, 1, 6, 6)]; + yield return [Grayscale8Bytes4X4, 8, 1, 1, 4, 4, Offset(Grayscale8Result4X4, 1, 1, 6, 6)]; } } @@ -154,7 +154,7 @@ public static IEnumerable Grayscale8_Data public void Decode_WritesPixelData(byte[] inputData, ushort bitsPerSample, int left, int top, int width, int height, Rgba32[][] expectedResult) => AssertDecode( expectedResult, - pixels => new BlackIsZeroTiffColor(new TiffBitsPerSample(bitsPerSample, 0, 0)).Decode(inputData, pixels, left, top, width, height)); + pixels => new BlackIsZeroTiffColor(new(bitsPerSample, 0, 0)).Decode(inputData, pixels, left, top, width, height)); [Theory] [MemberData(nameof(BilevelData))] diff --git a/tests/ImageSharp.Tests/Formats/Tiff/PhotometricInterpretation/PaletteTiffColorTests.cs b/tests/ImageSharp.Tests/Formats/Tiff/PhotometricInterpretation/PaletteTiffColorTests.cs index c809c6c7f9..66f5bdce39 100644 --- a/tests/ImageSharp.Tests/Formats/Tiff/PhotometricInterpretation/PaletteTiffColorTests.cs +++ b/tests/ImageSharp.Tests/Formats/Tiff/PhotometricInterpretation/PaletteTiffColorTests.cs @@ -15,39 +15,43 @@ public class PaletteTiffColorTests : PhotometricInterpretationTestBase public static ushort[] Palette4ColorMap => GenerateColorMap(Palette4ColorPalette); private static readonly byte[] Palette4Bytes4X4 = - { + [ 0x01, 0x23, 0x4A, 0xD2, 0x12, 0x34, 0xAB, 0xEF - }; + ]; private static readonly Rgba32[][] Palette4Result4X4 = GenerateResult( Palette4ColorPalette, - new[] { new[] { 0x00, 0x01, 0x02, 0x03 }, new[] { 0x04, 0x0A, 0x0D, 0x02 }, new[] { 0x01, 0x02, 0x03, 0x04 }, new[] { 0x0A, 0x0B, 0x0E, 0x0F } }); + [ + [0x00, 0x01, 0x02, 0x03], [0x04, 0x0A, 0x0D, 0x02], [0x01, 0x02, 0x03, 0x04], [0x0A, 0x0B, 0x0E, 0x0F] + ]); private static readonly byte[] Palette4Bytes3X4 = - { + [ 0x01, 0x20, 0x4A, 0xD0, 0x12, 0x30, 0xAB, 0xE0 - }; + ]; - private static readonly Rgba32[][] Palette4Result3X4 = GenerateResult(Palette4ColorPalette, new[] { new[] { 0x00, 0x01, 0x02 }, new[] { 0x04, 0x0A, 0x0D }, new[] { 0x01, 0x02, 0x03 }, new[] { 0x0A, 0x0B, 0x0E } }); + private static readonly Rgba32[][] Palette4Result3X4 = GenerateResult(Palette4ColorPalette, [ + [0x00, 0x01, 0x02], [0x04, 0x0A, 0x0D], [0x01, 0x02, 0x03], [0x0A, 0x0B, 0x0E] + ]); public static IEnumerable Palette4Data { get { - yield return new object[] { Palette4Bytes4X4, 4, Palette4ColorMap, 0, 0, 4, 4, Palette4Result4X4 }; - yield return new object[] { Palette4Bytes4X4, 4, Palette4ColorMap, 0, 0, 4, 4, Offset(Palette4Result4X4, 0, 0, 6, 6) }; - yield return new object[] { Palette4Bytes4X4, 4, Palette4ColorMap, 1, 0, 4, 4, Offset(Palette4Result4X4, 1, 0, 6, 6) }; - yield return new object[] { Palette4Bytes4X4, 4, Palette4ColorMap, 0, 1, 4, 4, Offset(Palette4Result4X4, 0, 1, 6, 6) }; - yield return new object[] { Palette4Bytes4X4, 4, Palette4ColorMap, 1, 1, 4, 4, Offset(Palette4Result4X4, 1, 1, 6, 6) }; - - yield return new object[] { Palette4Bytes3X4, 4, Palette4ColorMap, 0, 0, 3, 4, Palette4Result3X4 }; - yield return new object[] { Palette4Bytes3X4, 4, Palette4ColorMap, 0, 0, 3, 4, Offset(Palette4Result3X4, 0, 0, 6, 6) }; - yield return new object[] { Palette4Bytes3X4, 4, Palette4ColorMap, 1, 0, 3, 4, Offset(Palette4Result3X4, 1, 0, 6, 6) }; - yield return new object[] { Palette4Bytes3X4, 4, Palette4ColorMap, 0, 1, 3, 4, Offset(Palette4Result3X4, 0, 1, 6, 6) }; - yield return new object[] { Palette4Bytes3X4, 4, Palette4ColorMap, 1, 1, 3, 4, Offset(Palette4Result3X4, 1, 1, 6, 6) }; + yield return [Palette4Bytes4X4, 4, Palette4ColorMap, 0, 0, 4, 4, Palette4Result4X4]; + yield return [Palette4Bytes4X4, 4, Palette4ColorMap, 0, 0, 4, 4, Offset(Palette4Result4X4, 0, 0, 6, 6)]; + yield return [Palette4Bytes4X4, 4, Palette4ColorMap, 1, 0, 4, 4, Offset(Palette4Result4X4, 1, 0, 6, 6)]; + yield return [Palette4Bytes4X4, 4, Palette4ColorMap, 0, 1, 4, 4, Offset(Palette4Result4X4, 0, 1, 6, 6)]; + yield return [Palette4Bytes4X4, 4, Palette4ColorMap, 1, 1, 4, 4, Offset(Palette4Result4X4, 1, 1, 6, 6)]; + + yield return [Palette4Bytes3X4, 4, Palette4ColorMap, 0, 0, 3, 4, Palette4Result3X4]; + yield return [Palette4Bytes3X4, 4, Palette4ColorMap, 0, 0, 3, 4, Offset(Palette4Result3X4, 0, 0, 6, 6)]; + yield return [Palette4Bytes3X4, 4, Palette4ColorMap, 1, 0, 3, 4, Offset(Palette4Result3X4, 1, 0, 6, 6)]; + yield return [Palette4Bytes3X4, 4, Palette4ColorMap, 0, 1, 3, 4, Offset(Palette4Result3X4, 0, 1, 6, 6)]; + yield return [Palette4Bytes3X4, 4, Palette4ColorMap, 1, 1, 3, 4, Offset(Palette4Result3X4, 1, 1, 6, 6)]; } } @@ -56,24 +60,26 @@ public static IEnumerable Palette4Data public static ushort[] Palette8ColorMap => GenerateColorMap(Palette8ColorPalette); private static readonly byte[] Palette8Bytes4X4 = - { + [ 000, 001, 002, 003, 100, 110, 120, 130, 000, 255, 128, 255, 050, 100, 150, 200 - }; + ]; - private static readonly Rgba32[][] Palette8Result4X4 = GenerateResult(Palette8ColorPalette, new[] { new[] { 000, 001, 002, 003 }, new[] { 100, 110, 120, 130 }, new[] { 000, 255, 128, 255 }, new[] { 050, 100, 150, 200 } }); + private static readonly Rgba32[][] Palette8Result4X4 = GenerateResult(Palette8ColorPalette, [ + [000, 001, 002, 003], [100, 110, 120, 130], [000, 255, 128, 255], [050, 100, 150, 200] + ]); public static IEnumerable Palette8Data { get { - yield return new object[] { Palette8Bytes4X4, 8, Palette8ColorMap, 0, 0, 4, 4, Palette8Result4X4 }; - yield return new object[] { Palette8Bytes4X4, 8, Palette8ColorMap, 0, 0, 4, 4, Offset(Palette8Result4X4, 0, 0, 6, 6) }; - yield return new object[] { Palette8Bytes4X4, 8, Palette8ColorMap, 1, 0, 4, 4, Offset(Palette8Result4X4, 1, 0, 6, 6) }; - yield return new object[] { Palette8Bytes4X4, 8, Palette8ColorMap, 0, 1, 4, 4, Offset(Palette8Result4X4, 0, 1, 6, 6) }; - yield return new object[] { Palette8Bytes4X4, 8, Palette8ColorMap, 1, 1, 4, 4, Offset(Palette8Result4X4, 1, 1, 6, 6) }; + yield return [Palette8Bytes4X4, 8, Palette8ColorMap, 0, 0, 4, 4, Palette8Result4X4]; + yield return [Palette8Bytes4X4, 8, Palette8ColorMap, 0, 0, 4, 4, Offset(Palette8Result4X4, 0, 0, 6, 6)]; + yield return [Palette8Bytes4X4, 8, Palette8ColorMap, 1, 0, 4, 4, Offset(Palette8Result4X4, 1, 0, 6, 6)]; + yield return [Palette8Bytes4X4, 8, Palette8ColorMap, 0, 1, 4, 4, Offset(Palette8Result4X4, 0, 1, 6, 6)]; + yield return [Palette8Bytes4X4, 8, Palette8ColorMap, 1, 1, 4, 4, Offset(Palette8Result4X4, 1, 1, 6, 6)]; } } @@ -83,16 +89,16 @@ public static IEnumerable Palette8Data public void Decode_WritesPixelData(byte[] inputData, ushort bitsPerSample, ushort[] colorMap, int left, int top, int width, int height, Rgba32[][] expectedResult) => AssertDecode(expectedResult, pixels => { - new PaletteTiffColor(new TiffBitsPerSample(bitsPerSample, 0, 0), colorMap).Decode(inputData, pixels, left, top, width, height); + new PaletteTiffColor(new(bitsPerSample, 0, 0), colorMap).Decode(inputData, pixels, left, top, width, height); }); private static uint[][] GeneratePalette(int count) { - var palette = new uint[count][]; + uint[][] palette = new uint[count][]; for (uint i = 0; i < count; i++) { - palette[i] = new[] { (i * 2u) % 65536u, (i * 2625u) % 65536u, (i * 29401u) % 65536u }; + palette[i] = [(i * 2u) % 65536u, (i * 2625u) % 65536u, (i * 29401u) % 65536u]; } return palette; @@ -101,7 +107,7 @@ private static uint[][] GeneratePalette(int count) private static ushort[] GenerateColorMap(uint[][] colorPalette) { int colorCount = colorPalette.Length; - var colorMap = new ushort[colorCount * 3]; + ushort[] colorMap = new ushort[colorCount * 3]; for (int i = 0; i < colorCount; i++) { @@ -115,7 +121,7 @@ private static ushort[] GenerateColorMap(uint[][] colorPalette) private static Rgba32[][] GenerateResult(uint[][] colorPalette, int[][] pixelLookup) { - var result = new Rgba32[pixelLookup.Length][]; + Rgba32[][] result = new Rgba32[pixelLookup.Length][]; for (int y = 0; y < pixelLookup.Length; y++) { @@ -124,7 +130,7 @@ private static Rgba32[][] GenerateResult(uint[][] colorPalette, int[][] pixelLoo for (int x = 0; x < pixelLookup[y].Length; x++) { uint[] sourceColor = colorPalette[pixelLookup[y][x]]; - result[y][x] = new Rgba32(sourceColor[0] / 65535F, sourceColor[1] / 65535F, sourceColor[2] / 65535F); + result[y][x] = new(sourceColor[0] / 65535F, sourceColor[1] / 65535F, sourceColor[2] / 65535F); } } diff --git a/tests/ImageSharp.Tests/Formats/Tiff/PhotometricInterpretation/PhotometricInterpretationTestBase.cs b/tests/ImageSharp.Tests/Formats/Tiff/PhotometricInterpretation/PhotometricInterpretationTestBase.cs index 3582dc75a6..7040e167df 100644 --- a/tests/ImageSharp.Tests/Formats/Tiff/PhotometricInterpretation/PhotometricInterpretationTestBase.cs +++ b/tests/ImageSharp.Tests/Formats/Tiff/PhotometricInterpretation/PhotometricInterpretationTestBase.cs @@ -10,14 +10,14 @@ namespace SixLabors.ImageSharp.Tests.Formats.Tiff.PhotometricInterpretation; [Trait("Format", "Tiff")] public abstract class PhotometricInterpretationTestBase { - public static Rgba32 DefaultColor = new Rgba32(42, 96, 18, 128); + public static Rgba32 DefaultColor = new(42, 96, 18, 128); public static Rgba32[][] Offset(Rgba32[][] input, int xOffset, int yOffset, int width, int height) { int inputHeight = input.Length; int inputWidth = input[0].Length; - var output = new Rgba32[height][]; + Rgba32[][] output = new Rgba32[height][]; for (int y = 0; y < output.Length; y++) { @@ -45,7 +45,7 @@ internal static void AssertDecode(Rgba32[][] expectedResult, Action(resultWidth, resultHeight)) + using (Image image = new(resultWidth, resultHeight)) { image.Mutate(x => x.BackgroundColor(Color.FromPixel(DefaultColor))); Buffer2D pixels = image.GetRootFramePixelBuffer(); diff --git a/tests/ImageSharp.Tests/Formats/Tiff/PhotometricInterpretation/RgbPlanarTiffColorTests.cs b/tests/ImageSharp.Tests/Formats/Tiff/PhotometricInterpretation/RgbPlanarTiffColorTests.cs index d8249c3619..5df7c4d62f 100644 --- a/tests/ImageSharp.Tests/Formats/Tiff/PhotometricInterpretation/RgbPlanarTiffColorTests.cs +++ b/tests/ImageSharp.Tests/Formats/Tiff/PhotometricInterpretation/RgbPlanarTiffColorTests.cs @@ -12,226 +12,230 @@ namespace SixLabors.ImageSharp.Tests.Formats.Tiff.PhotometricInterpretation; [Trait("Format", "Tiff")] public class RgbPlanarTiffColorTests : PhotometricInterpretationTestBase { - private static readonly Rgba32 Rgb4_000 = new Rgba32(0, 0, 0, 255); - private static readonly Rgba32 Rgb4_444 = new Rgba32(68, 68, 68, 255); - private static readonly Rgba32 Rgb4_888 = new Rgba32(136, 136, 136, 255); - private static readonly Rgba32 Rgb4_CCC = new Rgba32(204, 204, 204, 255); - private static readonly Rgba32 Rgb4_FFF = new Rgba32(255, 255, 255, 255); - private static readonly Rgba32 Rgb4_F00 = new Rgba32(255, 0, 0, 255); - private static readonly Rgba32 Rgb4_0F0 = new Rgba32(0, 255, 0, 255); - private static readonly Rgba32 Rgb4_00F = new Rgba32(0, 0, 255, 255); - private static readonly Rgba32 Rgb4_F0F = new Rgba32(255, 0, 255, 255); - private static readonly Rgba32 Rgb4_400 = new Rgba32(68, 0, 0, 255); - private static readonly Rgba32 Rgb4_800 = new Rgba32(136, 0, 0, 255); - private static readonly Rgba32 Rgb4_C00 = new Rgba32(204, 0, 0, 255); - private static readonly Rgba32 Rgb4_48C = new Rgba32(68, 136, 204, 255); + private static readonly Rgba32 Rgb4_000 = new(0, 0, 0, 255); + private static readonly Rgba32 Rgb4_444 = new(68, 68, 68, 255); + private static readonly Rgba32 Rgb4_888 = new(136, 136, 136, 255); + private static readonly Rgba32 Rgb4_CCC = new(204, 204, 204, 255); + private static readonly Rgba32 Rgb4_FFF = new(255, 255, 255, 255); + private static readonly Rgba32 Rgb4_F00 = new(255, 0, 0, 255); + private static readonly Rgba32 Rgb4_0F0 = new(0, 255, 0, 255); + private static readonly Rgba32 Rgb4_00F = new(0, 0, 255, 255); + private static readonly Rgba32 Rgb4_F0F = new(255, 0, 255, 255); + private static readonly Rgba32 Rgb4_400 = new(68, 0, 0, 255); + private static readonly Rgba32 Rgb4_800 = new(136, 0, 0, 255); + private static readonly Rgba32 Rgb4_C00 = new(204, 0, 0, 255); + private static readonly Rgba32 Rgb4_48C = new(68, 136, 204, 255); private static readonly byte[] Rgb4Bytes4X4R = - { + [ 0x0F, 0x0F, 0xF0, 0x0F, 0x48, 0xC4, 0x04, 0x8C - }; + ]; private static readonly byte[] Rgb4Bytes4X4G = - { + [ 0x0F, 0x0F, 0x0F, 0x00, 0x00, 0x08, 0x04, 0x8C - }; + ]; private static readonly byte[] Rgb4Bytes4X4B = - { + [ 0x0F, 0x0F, 0x00, 0xFF, 0x00, 0x0C, 0x04, 0x8C - }; + ]; - private static readonly byte[][] Rgb4Bytes4X4 = { Rgb4Bytes4X4R, Rgb4Bytes4X4G, Rgb4Bytes4X4B }; + private static readonly byte[][] Rgb4Bytes4X4 = [Rgb4Bytes4X4R, Rgb4Bytes4X4G, Rgb4Bytes4X4B]; private static readonly Rgba32[][] Rgb4Result4X4 = - { - new[] { Rgb4_000, Rgb4_FFF, Rgb4_000, Rgb4_FFF }, - new[] { Rgb4_F00, Rgb4_0F0, Rgb4_00F, Rgb4_F0F }, - new[] { Rgb4_400, Rgb4_800, Rgb4_C00, Rgb4_48C }, - new[] { Rgb4_000, Rgb4_444, Rgb4_888, Rgb4_CCC } - }; + [ + [Rgb4_000, Rgb4_FFF, Rgb4_000, Rgb4_FFF], + [Rgb4_F00, Rgb4_0F0, Rgb4_00F, Rgb4_F0F], + [Rgb4_400, Rgb4_800, Rgb4_C00, Rgb4_48C], + [Rgb4_000, Rgb4_444, Rgb4_888, Rgb4_CCC] + ]; private static readonly byte[] Rgb4Bytes3X4R = - { + [ 0x0F, 0x00, 0xF0, 0x00, 0x48, 0xC0, 0x04, 0x80 - }; + ]; private static readonly byte[] Rgb4Bytes3X4G = - { + [ 0x0F, 0x00, 0x0F, 0x00, 0x00, 0x00, 0x04, 0x80 - }; + ]; private static readonly byte[] Rgb4Bytes3X4B = - { + [ 0x0F, 0x00, 0x00, 0xF0, 0x00, 0x00, 0x04, 0x80 - }; + ]; - private static readonly byte[][] Rgb4Bytes3X4 = { Rgb4Bytes3X4R, Rgb4Bytes3X4G, Rgb4Bytes3X4B }; + private static readonly byte[][] Rgb4Bytes3X4 = [Rgb4Bytes3X4R, Rgb4Bytes3X4G, Rgb4Bytes3X4B]; private static readonly Rgba32[][] Rgb4Result3X4 = - { - new[] { Rgb4_000, Rgb4_FFF, Rgb4_000 }, - new[] { Rgb4_F00, Rgb4_0F0, Rgb4_00F }, - new[] { Rgb4_400, Rgb4_800, Rgb4_C00 }, - new[] { Rgb4_000, Rgb4_444, Rgb4_888 } - }; + [ + [Rgb4_000, Rgb4_FFF, Rgb4_000], + [Rgb4_F00, Rgb4_0F0, Rgb4_00F], + [Rgb4_400, Rgb4_800, Rgb4_C00], + [Rgb4_000, Rgb4_444, Rgb4_888] + ]; public static IEnumerable Rgb4Data { get { - yield return new object[] { Rgb4Bytes4X4, new TiffBitsPerSample(4, 4, 4), 0, 0, 4, 4, Rgb4Result4X4 }; - yield return new object[] { Rgb4Bytes4X4, new TiffBitsPerSample(4, 4, 4), 0, 0, 4, 4, Offset(Rgb4Result4X4, 0, 0, 6, 6) }; - yield return new object[] { Rgb4Bytes4X4, new TiffBitsPerSample(4, 4, 4), 1, 0, 4, 4, Offset(Rgb4Result4X4, 1, 0, 6, 6) }; - yield return new object[] { Rgb4Bytes4X4, new TiffBitsPerSample(4, 4, 4), 0, 1, 4, 4, Offset(Rgb4Result4X4, 0, 1, 6, 6) }; - yield return new object[] { Rgb4Bytes4X4, new TiffBitsPerSample(4, 4, 4), 1, 1, 4, 4, Offset(Rgb4Result4X4, 1, 1, 6, 6) }; - - yield return new object[] { Rgb4Bytes3X4, new TiffBitsPerSample(4, 4, 4), 0, 0, 3, 4, Rgb4Result3X4 }; - yield return new object[] { Rgb4Bytes3X4, new TiffBitsPerSample(4, 4, 4), 0, 0, 3, 4, Offset(Rgb4Result3X4, 0, 0, 6, 6) }; - yield return new object[] { Rgb4Bytes3X4, new TiffBitsPerSample(4, 4, 4), 1, 0, 3, 4, Offset(Rgb4Result3X4, 1, 0, 6, 6) }; - yield return new object[] { Rgb4Bytes3X4, new TiffBitsPerSample(4, 4, 4), 0, 1, 3, 4, Offset(Rgb4Result3X4, 0, 1, 6, 6) }; - yield return new object[] { Rgb4Bytes3X4, new TiffBitsPerSample(4, 4, 4), 1, 1, 3, 4, Offset(Rgb4Result3X4, 1, 1, 6, 6) }; + yield return [Rgb4Bytes4X4, new TiffBitsPerSample(4, 4, 4), 0, 0, 4, 4, Rgb4Result4X4]; + yield return [Rgb4Bytes4X4, new TiffBitsPerSample(4, 4, 4), 0, 0, 4, 4, Offset(Rgb4Result4X4, 0, 0, 6, 6)]; + yield return [Rgb4Bytes4X4, new TiffBitsPerSample(4, 4, 4), 1, 0, 4, 4, Offset(Rgb4Result4X4, 1, 0, 6, 6)]; + yield return [Rgb4Bytes4X4, new TiffBitsPerSample(4, 4, 4), 0, 1, 4, 4, Offset(Rgb4Result4X4, 0, 1, 6, 6)]; + yield return [Rgb4Bytes4X4, new TiffBitsPerSample(4, 4, 4), 1, 1, 4, 4, Offset(Rgb4Result4X4, 1, 1, 6, 6)]; + + yield return [Rgb4Bytes3X4, new TiffBitsPerSample(4, 4, 4), 0, 0, 3, 4, Rgb4Result3X4]; + yield return [Rgb4Bytes3X4, new TiffBitsPerSample(4, 4, 4), 0, 0, 3, 4, Offset(Rgb4Result3X4, 0, 0, 6, 6)]; + yield return [Rgb4Bytes3X4, new TiffBitsPerSample(4, 4, 4), 1, 0, 3, 4, Offset(Rgb4Result3X4, 1, 0, 6, 6)]; + yield return [Rgb4Bytes3X4, new TiffBitsPerSample(4, 4, 4), 0, 1, 3, 4, Offset(Rgb4Result3X4, 0, 1, 6, 6)]; + yield return [Rgb4Bytes3X4, new TiffBitsPerSample(4, 4, 4), 1, 1, 3, 4, Offset(Rgb4Result3X4, 1, 1, 6, 6)]; } } - private static readonly Rgba32 Rgb8_000 = new Rgba32(0, 0, 0, 255); - private static readonly Rgba32 Rgb8_444 = new Rgba32(64, 64, 64, 255); - private static readonly Rgba32 Rgb8_888 = new Rgba32(128, 128, 128, 255); - private static readonly Rgba32 Rgb8_CCC = new Rgba32(192, 192, 192, 255); - private static readonly Rgba32 Rgb8_FFF = new Rgba32(255, 255, 255, 255); - private static readonly Rgba32 Rgb8_F00 = new Rgba32(255, 0, 0, 255); - private static readonly Rgba32 Rgb8_0F0 = new Rgba32(0, 255, 0, 255); - private static readonly Rgba32 Rgb8_00F = new Rgba32(0, 0, 255, 255); - private static readonly Rgba32 Rgb8_F0F = new Rgba32(255, 0, 255, 255); - private static readonly Rgba32 Rgb8_400 = new Rgba32(64, 0, 0, 255); - private static readonly Rgba32 Rgb8_800 = new Rgba32(128, 0, 0, 255); - private static readonly Rgba32 Rgb8_C00 = new Rgba32(192, 0, 0, 255); - private static readonly Rgba32 Rgb8_48C = new Rgba32(64, 128, 192, 255); + private static readonly Rgba32 Rgb8_000 = new(0, 0, 0, 255); + private static readonly Rgba32 Rgb8_444 = new(64, 64, 64, 255); + private static readonly Rgba32 Rgb8_888 = new(128, 128, 128, 255); + private static readonly Rgba32 Rgb8_CCC = new(192, 192, 192, 255); + private static readonly Rgba32 Rgb8_FFF = new(255, 255, 255, 255); + private static readonly Rgba32 Rgb8_F00 = new(255, 0, 0, 255); + private static readonly Rgba32 Rgb8_0F0 = new(0, 255, 0, 255); + private static readonly Rgba32 Rgb8_00F = new(0, 0, 255, 255); + private static readonly Rgba32 Rgb8_F0F = new(255, 0, 255, 255); + private static readonly Rgba32 Rgb8_400 = new(64, 0, 0, 255); + private static readonly Rgba32 Rgb8_800 = new(128, 0, 0, 255); + private static readonly Rgba32 Rgb8_C00 = new(192, 0, 0, 255); + private static readonly Rgba32 Rgb8_48C = new(64, 128, 192, 255); private static readonly byte[] Rgb8Bytes4X4R = - { + [ 000, 255, 000, 255, 255, 000, 000, 255, 064, 128, 192, 064, 000, 064, 128, 192 - }; + ]; private static readonly byte[] Rgb8Bytes4X4G = - { + [ 000, 255, 000, 255, 000, 255, 000, 000, 000, 000, 000, 128, 000, 064, 128, 192 - }; + ]; private static readonly byte[] Rgb8Bytes4X4B = - { + [ 000, 255, 000, 255, 000, 000, 255, 255, 000, 000, 000, 192, 000, 064, 128, 192 - }; + ]; private static readonly byte[][] Rgb8Bytes4X4 = - { + [ Rgb8Bytes4X4R, Rgb8Bytes4X4G, Rgb8Bytes4X4B - }; + ]; private static readonly Rgba32[][] Rgb8Result4X4 = - { - new[] { Rgb8_000, Rgb8_FFF, Rgb8_000, Rgb8_FFF }, - new[] { Rgb8_F00, Rgb8_0F0, Rgb8_00F, Rgb8_F0F }, - new[] { Rgb8_400, Rgb8_800, Rgb8_C00, Rgb8_48C }, - new[] { Rgb8_000, Rgb8_444, Rgb8_888, Rgb8_CCC } - }; + [ + [Rgb8_000, Rgb8_FFF, Rgb8_000, Rgb8_FFF], + [Rgb8_F00, Rgb8_0F0, Rgb8_00F, Rgb8_F0F], + [Rgb8_400, Rgb8_800, Rgb8_C00, Rgb8_48C], + [Rgb8_000, Rgb8_444, Rgb8_888, Rgb8_CCC] + ]; public static IEnumerable Rgb8Data { get { - yield return new object[] { Rgb8Bytes4X4, new TiffBitsPerSample(8, 8, 8), 0, 0, 4, 4, Rgb8Result4X4 }; - yield return new object[] { Rgb8Bytes4X4, new TiffBitsPerSample(8, 8, 8), 0, 0, 4, 4, Offset(Rgb8Result4X4, 0, 0, 6, 6) }; - yield return new object[] { Rgb8Bytes4X4, new TiffBitsPerSample(8, 8, 8), 1, 0, 4, 4, Offset(Rgb8Result4X4, 1, 0, 6, 6) }; - yield return new object[] { Rgb8Bytes4X4, new TiffBitsPerSample(8, 8, 8), 0, 1, 4, 4, Offset(Rgb8Result4X4, 0, 1, 6, 6) }; - yield return new object[] { Rgb8Bytes4X4, new TiffBitsPerSample(8, 8, 8), 1, 1, 4, 4, Offset(Rgb8Result4X4, 1, 1, 6, 6) }; + yield return [Rgb8Bytes4X4, new TiffBitsPerSample(8, 8, 8), 0, 0, 4, 4, Rgb8Result4X4]; + yield return [Rgb8Bytes4X4, new TiffBitsPerSample(8, 8, 8), 0, 0, 4, 4, Offset(Rgb8Result4X4, 0, 0, 6, 6)]; + yield return [Rgb8Bytes4X4, new TiffBitsPerSample(8, 8, 8), 1, 0, 4, 4, Offset(Rgb8Result4X4, 1, 0, 6, 6)]; + yield return [Rgb8Bytes4X4, new TiffBitsPerSample(8, 8, 8), 0, 1, 4, 4, Offset(Rgb8Result4X4, 0, 1, 6, 6)]; + yield return [Rgb8Bytes4X4, new TiffBitsPerSample(8, 8, 8), 1, 1, 4, 4, Offset(Rgb8Result4X4, 1, 1, 6, 6)]; } } - private static readonly Rgba32 Rgb484_000 = new Rgba32(0, 0, 0, 255); - private static readonly Rgba32 Rgb484_444 = new Rgba32(68, 64, 68, 255); - private static readonly Rgba32 Rgb484_888 = new Rgba32(136, 128, 136, 255); - private static readonly Rgba32 Rgb484_CCC = new Rgba32(204, 192, 204, 255); - private static readonly Rgba32 Rgb484_FFF = new Rgba32(255, 255, 255, 255); - private static readonly Rgba32 Rgb484_F00 = new Rgba32(255, 0, 0, 255); - private static readonly Rgba32 Rgb484_0F0 = new Rgba32(0, 255, 0, 255); - private static readonly Rgba32 Rgb484_00F = new Rgba32(0, 0, 255, 255); - private static readonly Rgba32 Rgb484_F0F = new Rgba32(255, 0, 255, 255); - private static readonly Rgba32 Rgb484_400 = new Rgba32(68, 0, 0, 255); - private static readonly Rgba32 Rgb484_800 = new Rgba32(136, 0, 0, 255); - private static readonly Rgba32 Rgb484_C00 = new Rgba32(204, 0, 0, 255); - private static readonly Rgba32 Rgb484_48C = new Rgba32(68, 128, 204, 255); + private static readonly Rgba32 Rgb484_000 = new(0, 0, 0, 255); + private static readonly Rgba32 Rgb484_444 = new(68, 64, 68, 255); + private static readonly Rgba32 Rgb484_888 = new(136, 128, 136, 255); + private static readonly Rgba32 Rgb484_CCC = new(204, 192, 204, 255); + private static readonly Rgba32 Rgb484_FFF = new(255, 255, 255, 255); + private static readonly Rgba32 Rgb484_F00 = new(255, 0, 0, 255); + private static readonly Rgba32 Rgb484_0F0 = new(0, 255, 0, 255); + private static readonly Rgba32 Rgb484_00F = new(0, 0, 255, 255); + private static readonly Rgba32 Rgb484_F0F = new(255, 0, 255, 255); + private static readonly Rgba32 Rgb484_400 = new(68, 0, 0, 255); + private static readonly Rgba32 Rgb484_800 = new(136, 0, 0, 255); + private static readonly Rgba32 Rgb484_C00 = new(204, 0, 0, 255); + private static readonly Rgba32 Rgb484_48C = new(68, 128, 204, 255); private static readonly byte[] Rgb484Bytes4X4R = - { + [ 0x0F, 0x0F, 0xF0, 0x0F, 0x48, 0xC4, 0x04, 0x8C - }; + ]; private static readonly byte[] Rgb484Bytes4X4G = - { + [ 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x40, 0x80, 0xC0 - }; + ]; private static readonly byte[] Rgb484Bytes4X4B = - { + [ 0x0F, 0x0F, 0x00, 0xFF, 0x00, 0x0C, 0x04, 0x8C - }; + ]; private static readonly Rgba32[][] Rgb484Result4X4 = - { - new[] { Rgb484_000, Rgb484_FFF, Rgb484_000, Rgb484_FFF }, - new[] { Rgb484_F00, Rgb484_0F0, Rgb484_00F, Rgb484_F0F }, - new[] { Rgb484_400, Rgb484_800, Rgb484_C00, Rgb484_48C }, - new[] { Rgb484_000, Rgb484_444, Rgb484_888, Rgb484_CCC } - }; + [ + [Rgb484_000, Rgb484_FFF, Rgb484_000, Rgb484_FFF], + [Rgb484_F00, Rgb484_0F0, Rgb484_00F, Rgb484_F0F], + [Rgb484_400, Rgb484_800, Rgb484_C00, Rgb484_48C], + [Rgb484_000, Rgb484_444, Rgb484_888, Rgb484_CCC] + ]; - private static readonly byte[][] Rgb484Bytes4X4 = { Rgb484Bytes4X4R, Rgb484Bytes4X4G, Rgb484Bytes4X4B }; + private static readonly byte[][] Rgb484Bytes4X4 = [Rgb484Bytes4X4R, Rgb484Bytes4X4G, Rgb484Bytes4X4B]; public static IEnumerable Rgb484_Data { get { - yield return new object[] { Rgb484Bytes4X4, new TiffBitsPerSample(4, 8, 4), 0, 0, 4, 4, Rgb484Result4X4 }; - yield return new object[] { Rgb484Bytes4X4, new TiffBitsPerSample(4, 8, 4), 0, 0, 4, 4, Offset(Rgb484Result4X4, 0, 0, 6, 6) }; - yield return new object[] { Rgb484Bytes4X4, new TiffBitsPerSample(4, 8, 4), 1, 0, 4, 4, Offset(Rgb484Result4X4, 1, 0, 6, 6) }; - yield return new object[] { Rgb484Bytes4X4, new TiffBitsPerSample(4, 8, 4), 0, 1, 4, 4, Offset(Rgb484Result4X4, 0, 1, 6, 6) }; - yield return new object[] { Rgb484Bytes4X4, new TiffBitsPerSample(4, 8, 4), 1, 1, 4, 4, Offset(Rgb484Result4X4, 1, 1, 6, 6) }; + yield return [Rgb484Bytes4X4, new TiffBitsPerSample(4, 8, 4), 0, 0, 4, 4, Rgb484Result4X4]; + yield return [Rgb484Bytes4X4, new TiffBitsPerSample(4, 8, 4), 0, 0, 4, 4, Offset(Rgb484Result4X4, 0, 0, 6, 6) + ]; + yield return [Rgb484Bytes4X4, new TiffBitsPerSample(4, 8, 4), 1, 0, 4, 4, Offset(Rgb484Result4X4, 1, 0, 6, 6) + ]; + yield return [Rgb484Bytes4X4, new TiffBitsPerSample(4, 8, 4), 0, 1, 4, 4, Offset(Rgb484Result4X4, 0, 1, 6, 6) + ]; + yield return [Rgb484Bytes4X4, new TiffBitsPerSample(4, 8, 4), 1, 1, 4, 4, Offset(Rgb484Result4X4, 1, 1, 6, 6) + ]; } } @@ -251,7 +255,7 @@ public void Decode_WritesPixelData( expectedResult, pixels => { - var buffers = new IMemoryOwner[inputData.Length]; + IMemoryOwner[] buffers = new IMemoryOwner[inputData.Length]; for (int i = 0; i < buffers.Length; i++) { buffers[i] = Configuration.Default.MemoryAllocator.Allocate(inputData[i].Length); diff --git a/tests/ImageSharp.Tests/Formats/Tiff/PhotometricInterpretation/RgbTiffColorTests.cs b/tests/ImageSharp.Tests/Formats/Tiff/PhotometricInterpretation/RgbTiffColorTests.cs index aeb135773c..6935d504ed 100644 --- a/tests/ImageSharp.Tests/Formats/Tiff/PhotometricInterpretation/RgbTiffColorTests.cs +++ b/tests/ImageSharp.Tests/Formats/Tiff/PhotometricInterpretation/RgbTiffColorTests.cs @@ -10,151 +10,155 @@ namespace SixLabors.ImageSharp.Tests.Formats.Tiff.PhotometricInterpretation; [Trait("Format", "Tiff")] public class RgbTiffColorTests : PhotometricInterpretationTestBase { - private static readonly Rgba32 Rgb4_000 = new Rgba32(0, 0, 0, 255); - private static readonly Rgba32 Rgb4_444 = new Rgba32(68, 68, 68, 255); - private static readonly Rgba32 Rgb4_888 = new Rgba32(136, 136, 136, 255); - private static readonly Rgba32 Rgb4_CCC = new Rgba32(204, 204, 204, 255); - private static readonly Rgba32 Rgb4_FFF = new Rgba32(255, 255, 255, 255); - private static readonly Rgba32 Rgb4_F00 = new Rgba32(255, 0, 0, 255); - private static readonly Rgba32 Rgb4_0F0 = new Rgba32(0, 255, 0, 255); - private static readonly Rgba32 Rgb4_00F = new Rgba32(0, 0, 255, 255); - private static readonly Rgba32 Rgb4_F0F = new Rgba32(255, 0, 255, 255); - private static readonly Rgba32 Rgb4_400 = new Rgba32(68, 0, 0, 255); - private static readonly Rgba32 Rgb4_800 = new Rgba32(136, 0, 0, 255); - private static readonly Rgba32 Rgb4_C00 = new Rgba32(204, 0, 0, 255); - private static readonly Rgba32 Rgb4_48C = new Rgba32(68, 136, 204, 255); + private static readonly Rgba32 Rgb4_000 = new(0, 0, 0, 255); + private static readonly Rgba32 Rgb4_444 = new(68, 68, 68, 255); + private static readonly Rgba32 Rgb4_888 = new(136, 136, 136, 255); + private static readonly Rgba32 Rgb4_CCC = new(204, 204, 204, 255); + private static readonly Rgba32 Rgb4_FFF = new(255, 255, 255, 255); + private static readonly Rgba32 Rgb4_F00 = new(255, 0, 0, 255); + private static readonly Rgba32 Rgb4_0F0 = new(0, 255, 0, 255); + private static readonly Rgba32 Rgb4_00F = new(0, 0, 255, 255); + private static readonly Rgba32 Rgb4_F0F = new(255, 0, 255, 255); + private static readonly Rgba32 Rgb4_400 = new(68, 0, 0, 255); + private static readonly Rgba32 Rgb4_800 = new(136, 0, 0, 255); + private static readonly Rgba32 Rgb4_C00 = new(204, 0, 0, 255); + private static readonly Rgba32 Rgb4_48C = new(68, 136, 204, 255); private static readonly byte[] Rgb4Bytes4X4 = - { + [ 0x00, 0x0F, 0xFF, 0x00, 0x0F, 0xFF, 0xF0, 0x00, 0xF0, 0x00, 0xFF, 0x0F, 0x40, 0x08, 0x00, 0xC0, 0x04, 0x8C, 0x00, 0x04, 0x44, 0x88, 0x8C, 0xCC - }; + ]; private static readonly Rgba32[][] Rgb4Result4X4 = - { - new[] { Rgb4_000, Rgb4_FFF, Rgb4_000, Rgb4_FFF }, - new[] { Rgb4_F00, Rgb4_0F0, Rgb4_00F, Rgb4_F0F }, - new[] { Rgb4_400, Rgb4_800, Rgb4_C00, Rgb4_48C }, - new[] { Rgb4_000, Rgb4_444, Rgb4_888, Rgb4_CCC } - }; + [ + [Rgb4_000, Rgb4_FFF, Rgb4_000, Rgb4_FFF], + [Rgb4_F00, Rgb4_0F0, Rgb4_00F, Rgb4_F0F], + [Rgb4_400, Rgb4_800, Rgb4_C00, Rgb4_48C], + [Rgb4_000, Rgb4_444, Rgb4_888, Rgb4_CCC] + ]; private static readonly byte[] Rgb4Bytes3X4 = - { + [ 0x00, 0x0F, 0xFF, 0x00, 0x00, 0xF0, 0x00, 0xF0, 0x00, 0xF0, 0x40, 0x08, 0x00, 0xC0, 0x00, 0x00, 0x04, 0x44, 0x88, 0x80 - }; + ]; private static readonly Rgba32[][] Rgb4Result3X4 = - { - new[] { Rgb4_000, Rgb4_FFF, Rgb4_000 }, - new[] { Rgb4_F00, Rgb4_0F0, Rgb4_00F }, - new[] { Rgb4_400, Rgb4_800, Rgb4_C00 }, - new[] { Rgb4_000, Rgb4_444, Rgb4_888 } - }; + [ + [Rgb4_000, Rgb4_FFF, Rgb4_000], + [Rgb4_F00, Rgb4_0F0, Rgb4_00F], + [Rgb4_400, Rgb4_800, Rgb4_C00], + [Rgb4_000, Rgb4_444, Rgb4_888] + ]; public static IEnumerable Rgb4Data { get { - yield return new object[] { Rgb4Bytes4X4, new TiffBitsPerSample(4, 4, 4), 0, 0, 4, 4, Rgb4Result4X4 }; - yield return new object[] { Rgb4Bytes4X4, new TiffBitsPerSample(4, 4, 4), 0, 0, 4, 4, Offset(Rgb4Result4X4, 0, 0, 6, 6) }; - yield return new object[] { Rgb4Bytes4X4, new TiffBitsPerSample(4, 4, 4), 1, 0, 4, 4, Offset(Rgb4Result4X4, 1, 0, 6, 6) }; - yield return new object[] { Rgb4Bytes4X4, new TiffBitsPerSample(4, 4, 4), 0, 1, 4, 4, Offset(Rgb4Result4X4, 0, 1, 6, 6) }; - yield return new object[] { Rgb4Bytes4X4, new TiffBitsPerSample(4, 4, 4), 1, 1, 4, 4, Offset(Rgb4Result4X4, 1, 1, 6, 6) }; - - yield return new object[] { Rgb4Bytes3X4, new TiffBitsPerSample(4, 4, 4), 0, 0, 3, 4, Rgb4Result3X4 }; - yield return new object[] { Rgb4Bytes3X4, new TiffBitsPerSample(4, 4, 4), 0, 0, 3, 4, Offset(Rgb4Result3X4, 0, 0, 6, 6) }; - yield return new object[] { Rgb4Bytes3X4, new TiffBitsPerSample(4, 4, 4), 1, 0, 3, 4, Offset(Rgb4Result3X4, 1, 0, 6, 6) }; - yield return new object[] { Rgb4Bytes3X4, new TiffBitsPerSample(4, 4, 4), 0, 1, 3, 4, Offset(Rgb4Result3X4, 0, 1, 6, 6) }; - yield return new object[] { Rgb4Bytes3X4, new TiffBitsPerSample(4, 4, 4), 1, 1, 3, 4, Offset(Rgb4Result3X4, 1, 1, 6, 6) }; + yield return [Rgb4Bytes4X4, new TiffBitsPerSample(4, 4, 4), 0, 0, 4, 4, Rgb4Result4X4]; + yield return [Rgb4Bytes4X4, new TiffBitsPerSample(4, 4, 4), 0, 0, 4, 4, Offset(Rgb4Result4X4, 0, 0, 6, 6)]; + yield return [Rgb4Bytes4X4, new TiffBitsPerSample(4, 4, 4), 1, 0, 4, 4, Offset(Rgb4Result4X4, 1, 0, 6, 6)]; + yield return [Rgb4Bytes4X4, new TiffBitsPerSample(4, 4, 4), 0, 1, 4, 4, Offset(Rgb4Result4X4, 0, 1, 6, 6)]; + yield return [Rgb4Bytes4X4, new TiffBitsPerSample(4, 4, 4), 1, 1, 4, 4, Offset(Rgb4Result4X4, 1, 1, 6, 6)]; + + yield return [Rgb4Bytes3X4, new TiffBitsPerSample(4, 4, 4), 0, 0, 3, 4, Rgb4Result3X4]; + yield return [Rgb4Bytes3X4, new TiffBitsPerSample(4, 4, 4), 0, 0, 3, 4, Offset(Rgb4Result3X4, 0, 0, 6, 6)]; + yield return [Rgb4Bytes3X4, new TiffBitsPerSample(4, 4, 4), 1, 0, 3, 4, Offset(Rgb4Result3X4, 1, 0, 6, 6)]; + yield return [Rgb4Bytes3X4, new TiffBitsPerSample(4, 4, 4), 0, 1, 3, 4, Offset(Rgb4Result3X4, 0, 1, 6, 6)]; + yield return [Rgb4Bytes3X4, new TiffBitsPerSample(4, 4, 4), 1, 1, 3, 4, Offset(Rgb4Result3X4, 1, 1, 6, 6)]; } } - private static readonly Rgba32 Rgb8_000 = new Rgba32(0, 0, 0, 255); - private static readonly Rgba32 Rgb8_444 = new Rgba32(64, 64, 64, 255); - private static readonly Rgba32 Rgb8_888 = new Rgba32(128, 128, 128, 255); - private static readonly Rgba32 Rgb8_CCC = new Rgba32(192, 192, 192, 255); - private static readonly Rgba32 Rgb8_FFF = new Rgba32(255, 255, 255, 255); - private static readonly Rgba32 Rgb8_F00 = new Rgba32(255, 0, 0, 255); - private static readonly Rgba32 Rgb8_0F0 = new Rgba32(0, 255, 0, 255); - private static readonly Rgba32 Rgb8_00F = new Rgba32(0, 0, 255, 255); - private static readonly Rgba32 Rgb8_F0F = new Rgba32(255, 0, 255, 255); - private static readonly Rgba32 Rgb8_400 = new Rgba32(64, 0, 0, 255); - private static readonly Rgba32 Rgb8_800 = new Rgba32(128, 0, 0, 255); - private static readonly Rgba32 Rgb8_C00 = new Rgba32(192, 0, 0, 255); - private static readonly Rgba32 Rgb8_48C = new Rgba32(64, 128, 192, 255); + private static readonly Rgba32 Rgb8_000 = new(0, 0, 0, 255); + private static readonly Rgba32 Rgb8_444 = new(64, 64, 64, 255); + private static readonly Rgba32 Rgb8_888 = new(128, 128, 128, 255); + private static readonly Rgba32 Rgb8_CCC = new(192, 192, 192, 255); + private static readonly Rgba32 Rgb8_FFF = new(255, 255, 255, 255); + private static readonly Rgba32 Rgb8_F00 = new(255, 0, 0, 255); + private static readonly Rgba32 Rgb8_0F0 = new(0, 255, 0, 255); + private static readonly Rgba32 Rgb8_00F = new(0, 0, 255, 255); + private static readonly Rgba32 Rgb8_F0F = new(255, 0, 255, 255); + private static readonly Rgba32 Rgb8_400 = new(64, 0, 0, 255); + private static readonly Rgba32 Rgb8_800 = new(128, 0, 0, 255); + private static readonly Rgba32 Rgb8_C00 = new(192, 0, 0, 255); + private static readonly Rgba32 Rgb8_48C = new(64, 128, 192, 255); private static readonly byte[] Rgb8Bytes4X4 = - { + [ 000, 000, 000, 255, 255, 255, 000, 000, 000, 255, 255, 255, 255, 000, 000, 000, 255, 000, 000, 000, 255, 255, 000, 255, 064, 000, 000, 128, 000, 000, 192, 000, 000, 064, 128, 192, 000, 000, 000, 064, 064, 064, 128, 128, 128, 192, 192, 192 - }; + ]; private static readonly Rgba32[][] Rgb8Result4X4 = - { - new[] { Rgb8_000, Rgb8_FFF, Rgb8_000, Rgb8_FFF }, - new[] { Rgb8_F00, Rgb8_0F0, Rgb8_00F, Rgb8_F0F }, - new[] { Rgb8_400, Rgb8_800, Rgb8_C00, Rgb8_48C }, - new[] { Rgb8_000, Rgb8_444, Rgb8_888, Rgb8_CCC } - }; + [ + [Rgb8_000, Rgb8_FFF, Rgb8_000, Rgb8_FFF], + [Rgb8_F00, Rgb8_0F0, Rgb8_00F, Rgb8_F0F], + [Rgb8_400, Rgb8_800, Rgb8_C00, Rgb8_48C], + [Rgb8_000, Rgb8_444, Rgb8_888, Rgb8_CCC] + ]; public static IEnumerable Rgb8Data { get { - yield return new object[] { Rgb8Bytes4X4, new TiffBitsPerSample(8, 8, 8), 0, 0, 4, 4, Rgb8Result4X4 }; - yield return new object[] { Rgb8Bytes4X4, new TiffBitsPerSample(8, 8, 8), 0, 0, 4, 4, Offset(Rgb8Result4X4, 0, 0, 6, 6) }; - yield return new object[] { Rgb8Bytes4X4, new TiffBitsPerSample(8, 8, 8), 1, 0, 4, 4, Offset(Rgb8Result4X4, 1, 0, 6, 6) }; - yield return new object[] { Rgb8Bytes4X4, new TiffBitsPerSample(8, 8, 8), 0, 1, 4, 4, Offset(Rgb8Result4X4, 0, 1, 6, 6) }; - yield return new object[] { Rgb8Bytes4X4, new TiffBitsPerSample(8, 8, 8), 1, 1, 4, 4, Offset(Rgb8Result4X4, 1, 1, 6, 6) }; + yield return [Rgb8Bytes4X4, new TiffBitsPerSample(8, 8, 8), 0, 0, 4, 4, Rgb8Result4X4]; + yield return [Rgb8Bytes4X4, new TiffBitsPerSample(8, 8, 8), 0, 0, 4, 4, Offset(Rgb8Result4X4, 0, 0, 6, 6)]; + yield return [Rgb8Bytes4X4, new TiffBitsPerSample(8, 8, 8), 1, 0, 4, 4, Offset(Rgb8Result4X4, 1, 0, 6, 6)]; + yield return [Rgb8Bytes4X4, new TiffBitsPerSample(8, 8, 8), 0, 1, 4, 4, Offset(Rgb8Result4X4, 0, 1, 6, 6)]; + yield return [Rgb8Bytes4X4, new TiffBitsPerSample(8, 8, 8), 1, 1, 4, 4, Offset(Rgb8Result4X4, 1, 1, 6, 6)]; } } - private static readonly Rgba32 Rgb484_000 = new Rgba32(0, 0, 0, 255); - private static readonly Rgba32 Rgb484_444 = new Rgba32(68, 64, 68, 255); - private static readonly Rgba32 Rgb484_888 = new Rgba32(136, 128, 136, 255); - private static readonly Rgba32 Rgb484_CCC = new Rgba32(204, 192, 204, 255); - private static readonly Rgba32 Rgb484_FFF = new Rgba32(255, 255, 255, 255); - private static readonly Rgba32 Rgb484_F00 = new Rgba32(255, 0, 0, 255); - private static readonly Rgba32 Rgb484_0F0 = new Rgba32(0, 255, 0, 255); - private static readonly Rgba32 Rgb484_00F = new Rgba32(0, 0, 255, 255); - private static readonly Rgba32 Rgb484_F0F = new Rgba32(255, 0, 255, 255); - private static readonly Rgba32 Rgb484_400 = new Rgba32(68, 0, 0, 255); - private static readonly Rgba32 Rgb484_800 = new Rgba32(136, 0, 0, 255); - private static readonly Rgba32 Rgb484_C00 = new Rgba32(204, 0, 0, 255); - private static readonly Rgba32 Rgb484_48C = new Rgba32(68, 128, 204, 255); + private static readonly Rgba32 Rgb484_000 = new(0, 0, 0, 255); + private static readonly Rgba32 Rgb484_444 = new(68, 64, 68, 255); + private static readonly Rgba32 Rgb484_888 = new(136, 128, 136, 255); + private static readonly Rgba32 Rgb484_CCC = new(204, 192, 204, 255); + private static readonly Rgba32 Rgb484_FFF = new(255, 255, 255, 255); + private static readonly Rgba32 Rgb484_F00 = new(255, 0, 0, 255); + private static readonly Rgba32 Rgb484_0F0 = new(0, 255, 0, 255); + private static readonly Rgba32 Rgb484_00F = new(0, 0, 255, 255); + private static readonly Rgba32 Rgb484_F0F = new(255, 0, 255, 255); + private static readonly Rgba32 Rgb484_400 = new(68, 0, 0, 255); + private static readonly Rgba32 Rgb484_800 = new(136, 0, 0, 255); + private static readonly Rgba32 Rgb484_C00 = new(204, 0, 0, 255); + private static readonly Rgba32 Rgb484_48C = new(68, 128, 204, 255); private static readonly byte[] Rgb484Bytes4X4 = - { + [ 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0xF0, 0x00, 0x0F, 0xF0, 0x00, 0x0F, 0xF0, 0x0F, 0x40, 0x00, 0x80, 0x00, 0xC0, 0x00, 0x48, 0x0C, 0x00, 0x00, 0x44, 0x04, 0x88, 0x08, 0xCC, 0x0C - }; + ]; private static readonly Rgba32[][] Rgb484Result4X4 = - { - new[] { Rgb484_000, Rgb484_FFF, Rgb484_000, Rgb484_FFF }, - new[] { Rgb484_F00, Rgb484_0F0, Rgb484_00F, Rgb484_F0F }, - new[] { Rgb484_400, Rgb484_800, Rgb484_C00, Rgb484_48C }, - new[] { Rgb484_000, Rgb484_444, Rgb484_888, Rgb484_CCC } - }; + [ + [Rgb484_000, Rgb484_FFF, Rgb484_000, Rgb484_FFF], + [Rgb484_F00, Rgb484_0F0, Rgb484_00F, Rgb484_F0F], + [Rgb484_400, Rgb484_800, Rgb484_C00, Rgb484_48C], + [Rgb484_000, Rgb484_444, Rgb484_888, Rgb484_CCC] + ]; public static IEnumerable Rgb484Data { get { - yield return new object[] { Rgb484Bytes4X4, new TiffBitsPerSample(4, 8, 4), 0, 0, 4, 4, Rgb484Result4X4 }; - yield return new object[] { Rgb484Bytes4X4, new TiffBitsPerSample(4, 8, 4), 0, 0, 4, 4, Offset(Rgb484Result4X4, 0, 0, 6, 6) }; - yield return new object[] { Rgb484Bytes4X4, new TiffBitsPerSample(4, 8, 4), 1, 0, 4, 4, Offset(Rgb484Result4X4, 1, 0, 6, 6) }; - yield return new object[] { Rgb484Bytes4X4, new TiffBitsPerSample(4, 8, 4), 0, 1, 4, 4, Offset(Rgb484Result4X4, 0, 1, 6, 6) }; - yield return new object[] { Rgb484Bytes4X4, new TiffBitsPerSample(4, 8, 4), 1, 1, 4, 4, Offset(Rgb484Result4X4, 1, 1, 6, 6) }; + yield return [Rgb484Bytes4X4, new TiffBitsPerSample(4, 8, 4), 0, 0, 4, 4, Rgb484Result4X4]; + yield return [Rgb484Bytes4X4, new TiffBitsPerSample(4, 8, 4), 0, 0, 4, 4, Offset(Rgb484Result4X4, 0, 0, 6, 6) + ]; + yield return [Rgb484Bytes4X4, new TiffBitsPerSample(4, 8, 4), 1, 0, 4, 4, Offset(Rgb484Result4X4, 1, 0, 6, 6) + ]; + yield return [Rgb484Bytes4X4, new TiffBitsPerSample(4, 8, 4), 0, 1, 4, 4, Offset(Rgb484Result4X4, 0, 1, 6, 6) + ]; + yield return [Rgb484Bytes4X4, new TiffBitsPerSample(4, 8, 4), 1, 1, 4, 4, Offset(Rgb484Result4X4, 1, 1, 6, 6) + ]; } } diff --git a/tests/ImageSharp.Tests/Formats/Tiff/PhotometricInterpretation/WhiteIsZeroTiffColorTests.cs b/tests/ImageSharp.Tests/Formats/Tiff/PhotometricInterpretation/WhiteIsZeroTiffColorTests.cs index 0b58e3891e..b3a1fb40fc 100644 --- a/tests/ImageSharp.Tests/Formats/Tiff/PhotometricInterpretation/WhiteIsZeroTiffColorTests.cs +++ b/tests/ImageSharp.Tests/Formats/Tiff/PhotometricInterpretation/WhiteIsZeroTiffColorTests.cs @@ -10,110 +10,110 @@ namespace SixLabors.ImageSharp.Tests.Formats.Tiff.PhotometricInterpretation; [Trait("Format", "Tiff")] public class WhiteIsZeroTiffColorTests : PhotometricInterpretationTestBase { - private static readonly Rgba32 Gray000 = new Rgba32(255, 255, 255, 255); - private static readonly Rgba32 Gray128 = new Rgba32(127, 127, 127, 255); - private static readonly Rgba32 Gray255 = new Rgba32(0, 0, 0, 255); - private static readonly Rgba32 Gray0 = new Rgba32(255, 255, 255, 255); - private static readonly Rgba32 Gray8 = new Rgba32(119, 119, 119, 255); - private static readonly Rgba32 GrayF = new Rgba32(0, 0, 0, 255); - private static readonly Rgba32 Bit0 = new Rgba32(255, 255, 255, 255); - private static readonly Rgba32 Bit1 = new Rgba32(0, 0, 0, 255); + private static readonly Rgba32 Gray000 = new(255, 255, 255, 255); + private static readonly Rgba32 Gray128 = new(127, 127, 127, 255); + private static readonly Rgba32 Gray255 = new(0, 0, 0, 255); + private static readonly Rgba32 Gray0 = new(255, 255, 255, 255); + private static readonly Rgba32 Gray8 = new(119, 119, 119, 255); + private static readonly Rgba32 GrayF = new(0, 0, 0, 255); + private static readonly Rgba32 Bit0 = new(255, 255, 255, 255); + private static readonly Rgba32 Bit1 = new(0, 0, 0, 255); private static readonly byte[] BilevelBytes4X4 = - { + [ 0b01010000, 0b11110000, 0b01110000, 0b10010000 - }; + ]; private static readonly Rgba32[][] BilevelResult4X4 = - { - new[] { Bit0, Bit1, Bit0, Bit1 }, - new[] { Bit1, Bit1, Bit1, Bit1 }, - new[] { Bit0, Bit1, Bit1, Bit1 }, - new[] { Bit1, Bit0, Bit0, Bit1 } - }; + [ + [Bit0, Bit1, Bit0, Bit1], + [Bit1, Bit1, Bit1, Bit1], + [Bit0, Bit1, Bit1, Bit1], + [Bit1, Bit0, Bit0, Bit1] + ]; private static readonly byte[] BilevelBytes12X4 = - { + [ 0b01010101, 0b01010000, 0b11111111, 0b11111111, 0b01101001, 0b10100000, 0b10010000, 0b01100000 - }; + ]; private static readonly Rgba32[][] BilevelResult12X4 = - { - new[] { Bit0, Bit1, Bit0, Bit1, Bit0, Bit1, Bit0, Bit1, Bit0, Bit1, Bit0, Bit1 }, - new[] { Bit1, Bit1, Bit1, Bit1, Bit1, Bit1, Bit1, Bit1, Bit1, Bit1, Bit1, Bit1 }, - new[] { Bit0, Bit1, Bit1, Bit0, Bit1, Bit0, Bit0, Bit1, Bit1, Bit0, Bit1, Bit0 }, - new[] { Bit1, Bit0, Bit0, Bit1, Bit0, Bit0, Bit0, Bit0, Bit0, Bit1, Bit1, Bit0 } - }; + [ + [Bit0, Bit1, Bit0, Bit1, Bit0, Bit1, Bit0, Bit1, Bit0, Bit1, Bit0, Bit1], + [Bit1, Bit1, Bit1, Bit1, Bit1, Bit1, Bit1, Bit1, Bit1, Bit1, Bit1, Bit1], + [Bit0, Bit1, Bit1, Bit0, Bit1, Bit0, Bit0, Bit1, Bit1, Bit0, Bit1, Bit0], + [Bit1, Bit0, Bit0, Bit1, Bit0, Bit0, Bit0, Bit0, Bit0, Bit1, Bit1, Bit0] + ]; private static readonly byte[] Grayscale4Bytes4X4 = - { + [ 0x8F, 0x0F, 0xFF, 0xFF, 0x08, 0x8F, 0xF0, 0xF8 - }; + ]; private static readonly Rgba32[][] Grayscale4Result4X4 = - { - new[] { Gray8, GrayF, Gray0, GrayF }, - new[] { GrayF, GrayF, GrayF, GrayF }, - new[] { Gray0, Gray8, Gray8, GrayF }, - new[] { GrayF, Gray0, GrayF, Gray8 } - }; + [ + [Gray8, GrayF, Gray0, GrayF], + [GrayF, GrayF, GrayF, GrayF], + [Gray0, Gray8, Gray8, GrayF], + [GrayF, Gray0, GrayF, Gray8] + ]; private static readonly byte[] Grayscale4Bytes3X4 = - { + [ 0x8F, 0x00, 0xFF, 0xF0, 0x08, 0x80, 0xF0, 0xF0 - }; + ]; private static readonly Rgba32[][] Grayscale4Result3X4 = - { - new[] { Gray8, GrayF, Gray0 }, - new[] { GrayF, GrayF, GrayF }, - new[] { Gray0, Gray8, Gray8 }, - new[] { GrayF, Gray0, GrayF } - }; + [ + [Gray8, GrayF, Gray0], + [GrayF, GrayF, GrayF], + [Gray0, Gray8, Gray8], + [GrayF, Gray0, GrayF] + ]; private static readonly byte[] Grayscale8Bytes4X4 = - { + [ 128, 255, 000, 255, 255, 255, 255, 255, 000, 128, 128, 255, 255, 000, 255, 128 - }; + ]; private static readonly Rgba32[][] Grayscale8Result4X4 = - { - new[] { Gray128, Gray255, Gray000, Gray255 }, - new[] { Gray255, Gray255, Gray255, Gray255 }, - new[] { Gray000, Gray128, Gray128, Gray255 }, - new[] { Gray255, Gray000, Gray255, Gray128 } - }; + [ + [Gray128, Gray255, Gray000, Gray255], + [Gray255, Gray255, Gray255, Gray255], + [Gray000, Gray128, Gray128, Gray255], + [Gray255, Gray000, Gray255, Gray128] + ]; public static IEnumerable BilevelData { get { - yield return new object[] { BilevelBytes4X4, 1, 0, 0, 4, 4, BilevelResult4X4 }; - yield return new object[] { BilevelBytes4X4, 1, 0, 0, 4, 4, Offset(BilevelResult4X4, 0, 0, 6, 6) }; - yield return new object[] { BilevelBytes4X4, 1, 1, 0, 4, 4, Offset(BilevelResult4X4, 1, 0, 6, 6) }; - yield return new object[] { BilevelBytes4X4, 1, 0, 1, 4, 4, Offset(BilevelResult4X4, 0, 1, 6, 6) }; - yield return new object[] { BilevelBytes4X4, 1, 1, 1, 4, 4, Offset(BilevelResult4X4, 1, 1, 6, 6) }; - - yield return new object[] { BilevelBytes12X4, 1, 0, 0, 12, 4, BilevelResult12X4 }; - yield return new object[] { BilevelBytes12X4, 1, 0, 0, 12, 4, Offset(BilevelResult12X4, 0, 0, 18, 6) }; - yield return new object[] { BilevelBytes12X4, 1, 1, 0, 12, 4, Offset(BilevelResult12X4, 1, 0, 18, 6) }; - yield return new object[] { BilevelBytes12X4, 1, 0, 1, 12, 4, Offset(BilevelResult12X4, 0, 1, 18, 6) }; - yield return new object[] { BilevelBytes12X4, 1, 1, 1, 12, 4, Offset(BilevelResult12X4, 1, 1, 18, 6) }; + yield return [BilevelBytes4X4, 1, 0, 0, 4, 4, BilevelResult4X4]; + yield return [BilevelBytes4X4, 1, 0, 0, 4, 4, Offset(BilevelResult4X4, 0, 0, 6, 6)]; + yield return [BilevelBytes4X4, 1, 1, 0, 4, 4, Offset(BilevelResult4X4, 1, 0, 6, 6)]; + yield return [BilevelBytes4X4, 1, 0, 1, 4, 4, Offset(BilevelResult4X4, 0, 1, 6, 6)]; + yield return [BilevelBytes4X4, 1, 1, 1, 4, 4, Offset(BilevelResult4X4, 1, 1, 6, 6)]; + + yield return [BilevelBytes12X4, 1, 0, 0, 12, 4, BilevelResult12X4]; + yield return [BilevelBytes12X4, 1, 0, 0, 12, 4, Offset(BilevelResult12X4, 0, 0, 18, 6)]; + yield return [BilevelBytes12X4, 1, 1, 0, 12, 4, Offset(BilevelResult12X4, 1, 0, 18, 6)]; + yield return [BilevelBytes12X4, 1, 0, 1, 12, 4, Offset(BilevelResult12X4, 0, 1, 18, 6)]; + yield return [BilevelBytes12X4, 1, 1, 1, 12, 4, Offset(BilevelResult12X4, 1, 1, 18, 6)]; } } @@ -121,17 +121,17 @@ public static IEnumerable Grayscale4Data { get { - yield return new object[] { Grayscale4Bytes4X4, 4, 0, 0, 4, 4, Grayscale4Result4X4 }; - yield return new object[] { Grayscale4Bytes4X4, 4, 0, 0, 4, 4, Offset(Grayscale4Result4X4, 0, 0, 6, 6) }; - yield return new object[] { Grayscale4Bytes4X4, 4, 1, 0, 4, 4, Offset(Grayscale4Result4X4, 1, 0, 6, 6) }; - yield return new object[] { Grayscale4Bytes4X4, 4, 0, 1, 4, 4, Offset(Grayscale4Result4X4, 0, 1, 6, 6) }; - yield return new object[] { Grayscale4Bytes4X4, 4, 1, 1, 4, 4, Offset(Grayscale4Result4X4, 1, 1, 6, 6) }; - - yield return new object[] { Grayscale4Bytes3X4, 4, 0, 0, 3, 4, Grayscale4Result3X4 }; - yield return new object[] { Grayscale4Bytes3X4, 4, 0, 0, 3, 4, Offset(Grayscale4Result3X4, 0, 0, 6, 6) }; - yield return new object[] { Grayscale4Bytes3X4, 4, 1, 0, 3, 4, Offset(Grayscale4Result3X4, 1, 0, 6, 6) }; - yield return new object[] { Grayscale4Bytes3X4, 4, 0, 1, 3, 4, Offset(Grayscale4Result3X4, 0, 1, 6, 6) }; - yield return new object[] { Grayscale4Bytes3X4, 4, 1, 1, 3, 4, Offset(Grayscale4Result3X4, 1, 1, 6, 6) }; + yield return [Grayscale4Bytes4X4, 4, 0, 0, 4, 4, Grayscale4Result4X4]; + yield return [Grayscale4Bytes4X4, 4, 0, 0, 4, 4, Offset(Grayscale4Result4X4, 0, 0, 6, 6)]; + yield return [Grayscale4Bytes4X4, 4, 1, 0, 4, 4, Offset(Grayscale4Result4X4, 1, 0, 6, 6)]; + yield return [Grayscale4Bytes4X4, 4, 0, 1, 4, 4, Offset(Grayscale4Result4X4, 0, 1, 6, 6)]; + yield return [Grayscale4Bytes4X4, 4, 1, 1, 4, 4, Offset(Grayscale4Result4X4, 1, 1, 6, 6)]; + + yield return [Grayscale4Bytes3X4, 4, 0, 0, 3, 4, Grayscale4Result3X4]; + yield return [Grayscale4Bytes3X4, 4, 0, 0, 3, 4, Offset(Grayscale4Result3X4, 0, 0, 6, 6)]; + yield return [Grayscale4Bytes3X4, 4, 1, 0, 3, 4, Offset(Grayscale4Result3X4, 1, 0, 6, 6)]; + yield return [Grayscale4Bytes3X4, 4, 0, 1, 3, 4, Offset(Grayscale4Result3X4, 0, 1, 6, 6)]; + yield return [Grayscale4Bytes3X4, 4, 1, 1, 3, 4, Offset(Grayscale4Result3X4, 1, 1, 6, 6)]; } } @@ -139,11 +139,11 @@ public static IEnumerable Grayscale8Data { get { - yield return new object[] { Grayscale8Bytes4X4, 8, 0, 0, 4, 4, Grayscale8Result4X4 }; - yield return new object[] { Grayscale8Bytes4X4, 8, 0, 0, 4, 4, Offset(Grayscale8Result4X4, 0, 0, 6, 6) }; - yield return new object[] { Grayscale8Bytes4X4, 8, 1, 0, 4, 4, Offset(Grayscale8Result4X4, 1, 0, 6, 6) }; - yield return new object[] { Grayscale8Bytes4X4, 8, 0, 1, 4, 4, Offset(Grayscale8Result4X4, 0, 1, 6, 6) }; - yield return new object[] { Grayscale8Bytes4X4, 8, 1, 1, 4, 4, Offset(Grayscale8Result4X4, 1, 1, 6, 6) }; + yield return [Grayscale8Bytes4X4, 8, 0, 0, 4, 4, Grayscale8Result4X4]; + yield return [Grayscale8Bytes4X4, 8, 0, 0, 4, 4, Offset(Grayscale8Result4X4, 0, 0, 6, 6)]; + yield return [Grayscale8Bytes4X4, 8, 1, 0, 4, 4, Offset(Grayscale8Result4X4, 1, 0, 6, 6)]; + yield return [Grayscale8Bytes4X4, 8, 0, 1, 4, 4, Offset(Grayscale8Result4X4, 0, 1, 6, 6)]; + yield return [Grayscale8Bytes4X4, 8, 1, 1, 4, 4, Offset(Grayscale8Result4X4, 1, 1, 6, 6)]; } } @@ -155,7 +155,7 @@ public void Decode_WritesPixelData(byte[] inputData, ushort bitsPerSample, int l { AssertDecode(expectedResult, pixels => { - new WhiteIsZeroTiffColor(new TiffBitsPerSample(bitsPerSample, 0, 0)).Decode(inputData, pixels, left, top, width, height); + new WhiteIsZeroTiffColor(new(bitsPerSample, 0, 0)).Decode(inputData, pixels, left, top, width, height); }); } diff --git a/tests/ImageSharp.Tests/Formats/Tiff/TiffEncoderBaseTester.cs b/tests/ImageSharp.Tests/Formats/Tiff/TiffEncoderBaseTester.cs index 1bf9f5a400..158a0d4730 100644 --- a/tests/ImageSharp.Tests/Formats/Tiff/TiffEncoderBaseTester.cs +++ b/tests/ImageSharp.Tests/Formats/Tiff/TiffEncoderBaseTester.cs @@ -26,9 +26,9 @@ protected static void TestStripLength( where TPixel : unmanaged, IPixel { // arrange - var tiffEncoder = new TiffEncoder() { PhotometricInterpretation = photometricInterpretation, Compression = compression }; + TiffEncoder tiffEncoder = new() { PhotometricInterpretation = photometricInterpretation, Compression = compression }; using Image input = provider.GetImage(); - using var memStream = new MemoryStream(); + using MemoryStream memStream = new(); TiffFrameMetadata inputMeta = input.Frames.RootFrame.Metadata.GetTiffMetadata(); TiffCompression inputCompression = inputMeta.Compression; @@ -37,7 +37,7 @@ protected static void TestStripLength( // assert memStream.Position = 0; - using var output = Image.Load(memStream); + using Image output = Image.Load(memStream); ExifProfile exifProfileOutput = output.Frames.RootFrame.Metadata.ExifProfile; TiffFrameMetadata outputMeta = output.Frames.RootFrame.Metadata.GetTiffMetadata(); ImageFrame rootFrame = output.Frames.RootFrame; @@ -89,7 +89,7 @@ protected static void TestTiffEncoderCore( where TPixel : unmanaged, IPixel { using Image image = provider.GetImage(); - var encoder = new TiffEncoder + TiffEncoder encoder = new() { PhotometricInterpretation = photometricInterpretation, BitsPerPixel = bitsPerPixel, diff --git a/tests/ImageSharp.Tests/Formats/Tiff/TiffEncoderMultiframeTests.cs b/tests/ImageSharp.Tests/Formats/Tiff/TiffEncoderMultiframeTests.cs index 716b978a71..9f6e74183f 100644 --- a/tests/ImageSharp.Tests/Formats/Tiff/TiffEncoderMultiframeTests.cs +++ b/tests/ImageSharp.Tests/Formats/Tiff/TiffEncoderMultiframeTests.cs @@ -46,7 +46,7 @@ public void TiffEncoder_EncodeMultiframe_RemoveFrames(TestImageProvider< image.Frames.RemoveFrame(0); TiffBitsPerPixel bitsPerPixel = TiffBitsPerPixel.Bit24; - var encoder = new TiffEncoder + TiffEncoder encoder = new() { PhotometricInterpretation = TiffPhotometricInterpretation.Rgb, BitsPerPixel = bitsPerPixel, @@ -69,27 +69,27 @@ public void TiffEncoder_EncodeMultiframe_AddFrames(TestImageProvider image = provider.GetImage(); Assert.Equal(1, image.Frames.Count); - using var image1 = new Image(image.Width, image.Height, Color.Green.ToPixel()); + using Image image1 = new(image.Width, image.Height, Color.Green.ToPixel()); - using var image2 = new Image(image.Width, image.Height, Color.Yellow.ToPixel()); + using Image image2 = new(image.Width, image.Height, Color.Yellow.ToPixel()); image.Frames.AddFrame(image1.Frames.RootFrame); image.Frames.AddFrame(image2.Frames.RootFrame); TiffBitsPerPixel bitsPerPixel = TiffBitsPerPixel.Bit24; - var encoder = new TiffEncoder + TiffEncoder encoder = new() { PhotometricInterpretation = TiffPhotometricInterpretation.Rgb, BitsPerPixel = bitsPerPixel, Compression = TiffCompression.Deflate }; - using (var ms = new System.IO.MemoryStream()) + using (MemoryStream ms = new()) { image.Save(ms, encoder); ms.Position = 0; - using var output = Image.Load(ms); + using Image output = Image.Load(ms); Assert.Equal(3, output.Frames.Count); @@ -121,11 +121,11 @@ public void TiffEncoder_EncodeMultiframe_Create(TestImageProvider image = provider.GetImage(); - using var image0 = new Image(image.Width, image.Height, Color.Red.ToPixel()); + using Image image0 = new(image.Width, image.Height, Color.Red.ToPixel()); - using var image1 = new Image(image.Width, image.Height, Color.Green.ToPixel()); + using Image image1 = new(image.Width, image.Height, Color.Green.ToPixel()); - using var image2 = new Image(image.Width, image.Height, Color.Yellow.ToPixel()); + using Image image2 = new(image.Width, image.Height, Color.Yellow.ToPixel()); image.Frames.AddFrame(image0.Frames.RootFrame); image.Frames.AddFrame(image1.Frames.RootFrame); @@ -133,19 +133,19 @@ public void TiffEncoder_EncodeMultiframe_Create(TestImageProvider(ms); + using Image output = Image.Load(ms); Assert.Equal(3, output.Frames.Count); diff --git a/tests/ImageSharp.Tests/Formats/Tiff/TiffEncoderTests.cs b/tests/ImageSharp.Tests/Formats/Tiff/TiffEncoderTests.cs index 0d59625ca7..ecdadd29b6 100644 --- a/tests/ImageSharp.Tests/Formats/Tiff/TiffEncoderTests.cs +++ b/tests/ImageSharp.Tests/Formats/Tiff/TiffEncoderTests.cs @@ -256,7 +256,7 @@ public void TiffEncoder_WritesIfdOffsetAtWordBoundary() TiffEncoder tiffEncoder = new(); using MemoryStream memStream = new(); using Image image = new(1, 1); - byte[] expectedIfdOffsetBytes = { 12, 0 }; + byte[] expectedIfdOffsetBytes = [12, 0]; // act image.Save(memStream, tiffEncoder); @@ -334,7 +334,7 @@ public void TiffEncoder_EncodesMultiFrameMipMap_WithScaling(TestImagePro foreach (ImageFrame frame in image.Frames) { TiffFrameMetadata metadata = frame.Metadata.GetTiffMetadata(); - encodedDimensions.Add(new Size(metadata.EncodingWidth, metadata.EncodingHeight)); + encodedDimensions.Add(new(metadata.EncodingWidth, metadata.EncodingHeight)); } const int scale = 2; diff --git a/tests/ImageSharp.Tests/Formats/Tiff/TiffMetadataTests.cs b/tests/ImageSharp.Tests/Formats/Tiff/TiffMetadataTests.cs index e31487cd23..20b3ec2bb2 100644 --- a/tests/ImageSharp.Tests/Formats/Tiff/TiffMetadataTests.cs +++ b/tests/ImageSharp.Tests/Formats/Tiff/TiffMetadataTests.cs @@ -208,8 +208,8 @@ public void BaselineTags(TestImageProvider provider) Rational expectedResolution = new(10, 1, simplify: false); Assert.Equal(expectedResolution, exifProfile.GetValue(ExifTag.XResolution).Value); Assert.Equal(expectedResolution, exifProfile.GetValue(ExifTag.YResolution).Value); - Assert.Equal(new Number[] { 8u }, exifProfile.GetValue(ExifTag.StripOffsets)?.Value, new NumberComparer()); - Assert.Equal(new Number[] { 285u }, exifProfile.GetValue(ExifTag.StripByteCounts)?.Value, new NumberComparer()); + Assert.Equal([8u], exifProfile.GetValue(ExifTag.StripOffsets)?.Value, new NumberComparer()); + Assert.Equal([285u], exifProfile.GetValue(ExifTag.StripByteCounts)?.Value, new NumberComparer()); Assert.Null(exifProfile.GetValue(ExifTag.ExtraSamples, false)?.Value); Assert.Equal(32u, exifProfile.GetValue(ExifTag.RowsPerStrip).Value); Assert.Null(exifProfile.GetValue(ExifTag.SampleFormat, false)); diff --git a/tests/ImageSharp.Tests/Formats/Tiff/Utils/TiffWriterTests.cs b/tests/ImageSharp.Tests/Formats/Tiff/Utils/TiffWriterTests.cs index 9b26ab2702..939baeeb68 100644 --- a/tests/ImageSharp.Tests/Formats/Tiff/Utils/TiffWriterTests.cs +++ b/tests/ImageSharp.Tests/Formats/Tiff/Utils/TiffWriterTests.cs @@ -11,8 +11,8 @@ public class TiffWriterTests [Fact] public void IsLittleEndian_IsTrueOnWindows() { - using var stream = new MemoryStream(); - using var writer = new TiffStreamWriter(stream); + using MemoryStream stream = new(); + using TiffStreamWriter writer = new(stream); Assert.True(TiffStreamWriter.IsLittleEndian); } @@ -22,8 +22,8 @@ public void IsLittleEndian_IsTrueOnWindows() [InlineData(new byte[] { 1, 2, 3, 4, 5 }, 5)] public void Position_EqualsTheStreamPosition(byte[] data, long expectedResult) { - using var stream = new MemoryStream(); - using var writer = new TiffStreamWriter(stream); + using MemoryStream stream = new(); + using TiffStreamWriter writer = new(stream); writer.Write(data); Assert.Equal(writer.Position, expectedResult); } @@ -31,8 +31,8 @@ public void Position_EqualsTheStreamPosition(byte[] data, long expectedResult) [Fact] public void Write_WritesByte() { - using var stream = new MemoryStream(); - using var writer = new TiffStreamWriter(stream); + using MemoryStream stream = new(); + using TiffStreamWriter writer = new(stream); writer.Write(42); Assert.Equal(new byte[] { 42 }, stream.ToArray()); @@ -41,8 +41,8 @@ public void Write_WritesByte() [Fact] public void Write_WritesByteArray() { - using var stream = new MemoryStream(); - using var writer = new TiffStreamWriter(stream); + using MemoryStream stream = new(); + using TiffStreamWriter writer = new(stream); writer.Write(new byte[] { 2, 4, 6, 8 }); Assert.Equal(new byte[] { 2, 4, 6, 8 }, stream.ToArray()); @@ -51,8 +51,8 @@ public void Write_WritesByteArray() [Fact] public void Write_WritesUInt16() { - using var stream = new MemoryStream(); - using var writer = new TiffStreamWriter(stream); + using MemoryStream stream = new(); + using TiffStreamWriter writer = new(stream); writer.Write(1234, stackalloc byte[2]); Assert.Equal(new byte[] { 0xD2, 0x04 }, stream.ToArray()); @@ -61,8 +61,8 @@ public void Write_WritesUInt16() [Fact] public void Write_WritesUInt32() { - using var stream = new MemoryStream(); - using var writer = new TiffStreamWriter(stream); + using MemoryStream stream = new(); + using TiffStreamWriter writer = new(stream); writer.Write(12345678U, stackalloc byte[4]); Assert.Equal(new byte[] { 0x4E, 0x61, 0xBC, 0x00 }, stream.ToArray()); @@ -78,8 +78,8 @@ public void Write_WritesUInt32() public void WritePadded_WritesByteArray(byte[] bytes, byte[] expectedResult) { - using var stream = new MemoryStream(); - using var writer = new TiffStreamWriter(stream); + using MemoryStream stream = new(); + using TiffStreamWriter writer = new(stream); writer.WritePadded(bytes); Assert.Equal(expectedResult, stream.ToArray()); @@ -88,10 +88,10 @@ public void WritePadded_WritesByteArray(byte[] bytes, byte[] expectedResult) [Fact] public void WriteMarker_WritesToPlacedPosition() { - using var stream = new MemoryStream(); + using MemoryStream stream = new(); Span buffer = stackalloc byte[4]; - using (var writer = new TiffStreamWriter(stream)) + using (TiffStreamWriter writer = new(stream)) { writer.Write(0x11111111, buffer); long marker = writer.PlaceMarker(buffer); diff --git a/tests/ImageSharp.Tests/Formats/WebP/ColorSpaceTransformUtilsTests.cs b/tests/ImageSharp.Tests/Formats/WebP/ColorSpaceTransformUtilsTests.cs index c5e8c975f1..853a6eff46 100644 --- a/tests/ImageSharp.Tests/Formats/WebP/ColorSpaceTransformUtilsTests.cs +++ b/tests/ImageSharp.Tests/Formats/WebP/ColorSpaceTransformUtilsTests.cs @@ -12,13 +12,13 @@ public class ColorSpaceTransformUtilsTests private static void RunCollectColorBlueTransformsTest() { uint[] pixelData = - { + [ 3074, 256, 256, 256, 0, 65280, 65280, 65280, 256, 256, 0, 256, 0, 65280, 0, 65280, 16711680, 256, 256, 0, 65024, 0, 256, 256, 0, 65280, 0, 65280, 0, 256, 0, 256 - }; + ]; int[] expectedOutput = - { + [ 31, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, @@ -27,7 +27,7 @@ private static void RunCollectColorBlueTransformsTest() 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; + ]; int[] histo = new int[256]; ColorSpaceTransformUtils.CollectColorBlueTransforms(pixelData, 0, 32, 1, 0, 0, histo); @@ -38,13 +38,13 @@ private static void RunCollectColorBlueTransformsTest() private static void RunCollectColorRedTransformsTest() { uint[] pixelData = - { + [ 3074, 256, 256, 256, 0, 65280, 65280, 65280, 256, 256, 0, 256, 0, 65280, 0, 65280, 16711680, 256, 256, 0, 65024, 0, 256, 256, 0, 65280, 0, 65280, 0, 256, 0, 256 - }; + ]; int[] expectedOutput = - { + [ 31, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, @@ -53,7 +53,7 @@ private static void RunCollectColorRedTransformsTest() 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 - }; + ]; int[] histo = new int[256]; ColorSpaceTransformUtils.CollectColorRedTransforms(pixelData, 0, 32, 1, 0, histo); diff --git a/tests/ImageSharp.Tests/Formats/WebP/ImageExtensionsTests.cs b/tests/ImageSharp.Tests/Formats/WebP/ImageExtensionsTests.cs index ea13fd7125..510d67103b 100644 --- a/tests/ImageSharp.Tests/Formats/WebP/ImageExtensionsTests.cs +++ b/tests/ImageSharp.Tests/Formats/WebP/ImageExtensionsTests.cs @@ -48,7 +48,7 @@ public void SaveAsWebp_Path_Encoder() using (Image image = new(10, 10)) { - image.SaveAsWebp(file, new WebpEncoder()); + image.SaveAsWebp(file, new()); } IImageFormat format = Image.DetectFormat(file); @@ -109,7 +109,7 @@ public void SaveAsWebp_Stream_Encoder() using (Image image = new(10, 10)) { - image.SaveAsWebp(memoryStream, new WebpEncoder()); + image.SaveAsWebp(memoryStream, new()); } memoryStream.Position = 0; diff --git a/tests/ImageSharp.Tests/Formats/WebP/LosslessUtilsTests.cs b/tests/ImageSharp.Tests/Formats/WebP/LosslessUtilsTests.cs index 4551e3e23e..982f0a5d5c 100644 --- a/tests/ImageSharp.Tests/Formats/WebP/LosslessUtilsTests.cs +++ b/tests/ImageSharp.Tests/Formats/WebP/LosslessUtilsTests.cs @@ -11,8 +11,10 @@ public class LosslessUtilsTests { private static void RunCombinedShannonEntropyTest() { - int[] x = { 3, 5, 2, 5, 3, 1, 2, 2, 3, 3, 1, 2, 1, 2, 1, 1, 0, 0, 0, 1, 1, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 2, 0, 1, 1, 0, 0, 2, 1, 1, 0, 3, 1, 2, 3, 2, 3 }; - int[] y = { 11, 12, 8, 3, 4, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 2, 2, 1, 1, 2, 4, 6, 4 }; + int[] x = [3, 5, 2, 5, 3, 1, 2, 2, 3, 3, 1, 2, 1, 2, 1, 1, 0, 0, 0, 1, 1, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 2, 0, 1, 1, 0, 0, 2, 1, 1, 0, 3, 1, 2, 3, 2, 3 + ]; + int[] y = [11, 12, 8, 3, 4, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 2, 2, 1, 1, 2, 4, 6, 4 + ]; const float expected = 884.7585f; float actual = LosslessUtils.CombinedShannonEntropy(x, y); @@ -23,7 +25,7 @@ private static void RunCombinedShannonEntropyTest() private static void RunSubtractGreenTest() { uint[] pixelData = - { + [ 4293035898, 4293101432, 4292903793, 4292838511, 4292837995, 4292771950, 4292903791, 4293299316, 4293563769, 4293629303, 4293363312, 4291913575, 4289282905, 4288692313, 4289349210, 4289809240, 4289743703, 4289874775, 4289940567, 4289743701, 4290137943, 4290860378, 4291058267, 4291386715, @@ -31,10 +33,10 @@ private static void RunSubtractGreenTest() 4291913571, 4292044130, 4291978850, 4291847521, 4291847524, 4291847779, 4291913571, 4291848293, 4291651689, 4291585895, 4291519584, 4291715936, 4291520355, 4291650658, 4291847263, 4291913313, 4291847777, 4291781731, 4291783015 - }; + ]; uint[] expectedOutput = - { + [ 4284188659, 4284254193, 4284318702, 4284187883, 4284318441, 4284383470, 4284318700, 4284124392, 4283799012, 4283864546, 4284581610, 4285163264, 4284891926, 4284497945, 4284761620, 4284893965, 4284828428, 4284959500, 4284959755, 4284828426, 4284960520, 4285289733, 4285159937, 4285292030, @@ -42,7 +44,7 @@ private static void RunSubtractGreenTest() 4285163516, 4285425149, 4285294332, 4285228540, 4285228543, 4285163261, 4285163516, 4285032701, 4284835841, 4284835584, 4284966140, 4285228029, 4284770300, 4285097214, 4285293819, 4285228795, 4285163259, 4285228287, 4284901886 - }; + ]; LosslessUtils.SubtractGreenFromBlueAndRed(pixelData); @@ -52,7 +54,7 @@ private static void RunSubtractGreenTest() private static void RunAddGreenToBlueAndRedTest() { uint[] pixelData = - { + [ 4284188659, 4284254193, 4284318702, 4284187883, 4284318441, 4284383470, 4284318700, 4284124392, 4283799012, 4283864546, 4284581610, 4285163264, 4284891926, 4284497945, 4284761620, 4284893965, 4284828428, 4284959500, 4284959755, 4284828426, 4284960520, 4285289733, 4285159937, 4285292030, @@ -60,10 +62,10 @@ private static void RunAddGreenToBlueAndRedTest() 4285163516, 4285425149, 4285294332, 4285228540, 4285228543, 4285163261, 4285163516, 4285032701, 4284835841, 4284835584, 4284966140, 4285228029, 4284770300, 4285097214, 4285293819, 4285228795, 4285163259, 4285228287, 4284901886 - }; + ]; uint[] expectedOutput = - { + [ 4293035898, 4293101432, 4292903793, 4292838511, 4292837995, 4292771950, 4292903791, 4293299316, 4293563769, 4293629303, 4293363312, 4291913575, 4289282905, 4288692313, 4289349210, 4289809240, 4289743703, 4289874775, 4289940567, 4289743701, 4290137943, 4290860378, 4291058267, 4291386715, @@ -71,7 +73,7 @@ private static void RunAddGreenToBlueAndRedTest() 4291913571, 4292044130, 4291978850, 4291847521, 4291847524, 4291847779, 4291913571, 4291848293, 4291651689, 4291585895, 4291519584, 4291715936, 4291520355, 4291650658, 4291847263, 4291913313, 4291847777, 4291781731, 4291783015 - }; + ]; LosslessUtils.AddGreenToBlueAndRed(pixelData); @@ -81,15 +83,15 @@ private static void RunAddGreenToBlueAndRedTest() private static void RunTransformColorTest() { uint[] pixelData = - { + [ 5998579, 65790, 130301, 16646653, 196350, 130565, 16712702, 16583164, 16452092, 65790, 782600, 647446, 16571414, 16448771, 263931, 132601, 16711935, 131072, 511, 16711679, 132350, 329469, 16647676, 132093, 66303, 16647169, 16515584, 196607, 196096, 16646655, 514, 131326, 16712192, 327169, 16646655, 16776960, 3, 16712190, 511, 16646401, 16580612, 65535, 196092, 327425, 16319743, 392450, 196861, 16712192, 16711680, 130564, 16451071 - }; + ]; - var m = new Vp8LMultipliers() + Vp8LMultipliers m = new() { GreenToBlue = 240, GreenToRed = 232, @@ -97,13 +99,13 @@ private static void RunTransformColorTest() }; uint[] expectedOutput = - { + [ 100279, 65790, 16710907, 16712190, 130813, 65028, 131840, 264449, 133377, 65790, 61697, 15917319, 14801924, 16317698, 591614, 394748, 16711935, 131072, 65792, 16711679, 328704, 656896, 132607, 328703, 197120, 66563, 16646657, 196607, 130815, 16711936, 131587, 131326, 66049, 261632, 16711936, 16776960, 3, 511, 65792, 16711938, 16580612, 65535, 65019, 327425, 16516097, 261377, 196861, 66049, 16711680, 65027, 16712962 - }; + ]; LosslessUtils.TransformColor(m, pixelData, pixelData.Length); @@ -113,15 +115,15 @@ private static void RunTransformColorTest() private static void RunTransformColorInverseTest() { uint[] pixelData = - { + [ 100279, 65790, 16710907, 16712190, 130813, 65028, 131840, 264449, 133377, 65790, 61697, 15917319, 14801924, 16317698, 591614, 394748, 16711935, 131072, 65792, 16711679, 328704, 656896, 132607, 328703, 197120, 66563, 16646657, 196607, 130815, 16711936, 131587, 131326, 66049, 261632, 16711936, 16776960, 3, 511, 65792, 16711938, 16580612, 65535, 65019, 327425, 16516097, 261377, 196861, 66049, 16711680, 65027, 16712962 - }; + ]; - var m = new Vp8LMultipliers() + Vp8LMultipliers m = new() { GreenToBlue = 240, GreenToRed = 232, @@ -129,13 +131,13 @@ private static void RunTransformColorInverseTest() }; uint[] expectedOutput = - { + [ 5998579, 65790, 130301, 16646653, 196350, 130565, 16712702, 16583164, 16452092, 65790, 782600, 647446, 16571414, 16448771, 263931, 132601, 16711935, 131072, 511, 16711679, 132350, 329469, 16647676, 132093, 66303, 16647169, 16515584, 196607, 196096, 16646655, 514, 131326, 16712192, 327169, 16646655, 16776960, 3, 16712190, 511, 16646401, 16580612, 65535, 196092, 327425, 16319743, 392450, 196861, 16712192, 16711680, 130564, 16451071 - }; + ]; LosslessUtils.TransformColorInverse(m, pixelData); @@ -145,7 +147,7 @@ private static void RunTransformColorInverseTest() private static void RunPredictor11Test() { // arrange - uint[] topData = { 4278258949, 4278258949 }; + uint[] topData = [4278258949, 4278258949]; const uint left = 4294839812; short[] scratch = new short[8]; const uint expectedResult = 4294839812; @@ -166,7 +168,7 @@ private static void RunPredictor11Test() private static void RunPredictor12Test() { // arrange - uint[] topData = { 4294844413, 4294779388 }; + uint[] topData = [4294844413, 4294779388]; const uint left = 4294844413; const uint expectedResult = 4294779388; @@ -186,10 +188,10 @@ private static void RunPredictor12Test() private static void RunPredictor13Test() { // arrange - uint[] topData0 = { 4278193922, 4278193666 }; + uint[] topData0 = [4278193922, 4278193666]; const uint left0 = 4278193410; const uint expectedResult0 = 4278193154; - uint[] topData1 = { 4294933015, 4278219803 }; + uint[] topData1 = [4294933015, 4278219803]; const uint left1 = 4278236686; const uint expectedResult1 = 4278231571; uint actual0 = 0; @@ -218,17 +220,18 @@ private static void RunPredictor13Test() public void BundleColorMap_WithXbitsZero_Works() { // arrange - byte[] row = { 238, 238, 238, 238, 238, 238, 240, 237, 240, 235, 223, 223, 218, 220, 226, 219, 220, 204, 218, 211, 218, 221, 254, 255 }; + byte[] row = [238, 238, 238, 238, 238, 238, 240, 237, 240, 235, 223, 223, 218, 220, 226, 219, 220, 204, 218, 211, 218, 221, 254, 255 + ]; int xBits = 0; uint[] actual = new uint[row.Length]; uint[] expected = - { + [ 4278251008, 4278251008, 4278251008, 4278251008, 4278251008, 4278251008, 4278251520, 4278250752, 4278251520, 4278250240, 4278247168, 4278247168, 4278245888, 4278246400, 4278247936, 4278246144, 4278246400, 4278242304, 4278245888, 4278244096, 4278245888, 4278246656, 4278255104, 4278255360 - }; + ]; // act LosslessUtils.BundleColorMap(row, actual.Length, xBits, actual); @@ -242,7 +245,7 @@ public void BundleColorMap_WithXbitsNoneZero_Works() { // arrange byte[] row = - { + [ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, @@ -251,17 +254,17 @@ public void BundleColorMap_WithXbitsNoneZero_Works() 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3 - }; + ]; int xBits = 2; uint[] actual = new uint[row.Length]; uint[] expected = - { + [ 4278233600, 4278233600, 4278233600, 4278233600, 4278255360, 4278255360, 4278255360, 4278255360, 4278233600, 4278233600, 4278233600, 4278233600, 4278255360, 4278255360, 4278255360, 4278255360, 4278211840, 4278211840, 4278211840, 4278211840, 4278255360, 4278255360, 4278255360, 4278255360, 4278255360, 4278255360, 4278255360, 4278255360, 4278255360, 4278255360, 4278255360, 4278206208, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; + ]; // act LosslessUtils.BundleColorMap(row, actual.Length, xBits, actual); diff --git a/tests/ImageSharp.Tests/Formats/WebP/LossyUtilsTests.cs b/tests/ImageSharp.Tests/Formats/WebP/LossyUtilsTests.cs index 73e7044f5b..f4189933fa 100644 --- a/tests/ImageSharp.Tests/Formats/WebP/LossyUtilsTests.cs +++ b/tests/ImageSharp.Tests/Formats/WebP/LossyUtilsTests.cs @@ -13,9 +13,10 @@ public class LossyUtilsTests private static void RunTransformTwoTest() { // arrange - short[] src = { 19, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 19, 23, 0, 0, -23, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; + short[] src = [19, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 19, 23, 0, 0, -23, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 + ]; byte[] dst = - { + [ 103, 103, 103, 103, 103, 103, 103, 103, 0, 0, 0, 0, 169, 169, 169, 169, 171, 171, 171, 171, 171, 171, 171, 171, 0, 0, 0, 0, 103, 103, 103, 103, 103, 103, 103, 103, 103, 103, 103, 103, 0, 0, 0, 0, 169, 169, 169, 169, 171, 171, 171, 171, 171, 171, 171, 171, 0, 0, 0, 0, @@ -23,16 +24,16 @@ private static void RunTransformTwoTest() 171, 171, 171, 171, 171, 171, 171, 171, 0, 0, 0, 0, 103, 103, 103, 103, 103, 103, 103, 103, 103, 103, 103, 103, 0, 0, 0, 0, 169, 169, 169, 169, 171, 171, 171, 171, 171, 171, 171, 171, 0, 0, 0, 0, 0, 0, 0, 0 - }; + ]; byte[] expected = - { + [ 105, 105, 105, 105, 105, 103, 100, 98, 0, 0, 0, 0, 169, 169, 169, 169, 171, 171, 171, 171, 171, 171, 171, 171, 0, 0, 0, 0, 103, 103, 103, 103, 105, 105, 105, 105, 108, 105, 102, 100, 0, 0, 0, 0, 169, 169, 169, 169, 171, 171, 171, 171, 171, 171, 171, 171, 0, 0, 0, 0, 103, 103, 103, 103, 105, 105, 105, 105, 111, 109, 106, 103, 0, 0, 0, 0, 169, 169, 169, 169, 171, 171, 171, 171, 171, 171, 171, 171, 0, 0, 0, 0, 103, 103, 103, 103, 105, 105, 105, 105, 113, 111, 108, 106, 0, 0, 0, 0, 169, 169, 169, 169, 171, 171, 171, 171, 171, 171, 171, 171, 0, 0, 0, 0, 0, 0, 0, 0 - }; + ]; int[] scratch = new int[16]; // act @@ -45,9 +46,9 @@ private static void RunTransformTwoTest() private static void RunTransformOneTest() { // arrange - short[] src = { -176, 0, 0, 0, 29, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; + short[] src = [-176, 0, 0, 0, 29, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]; byte[] dst = - { + [ 128, 128, 128, 128, 128, 128, 128, 128, 0, 0, 0, 0, 0, 0, 0, 129, 128, 128, 128, 128, 128, 128, 128, 128, 0, 0, 0, 0, 0, 0, 0, 129, 128, 128, 128, 128, 128, 128, 128, 128, 0, 0, 0, 0, 0, 0, 0, 129, 128, 128, 128, 128, 128, 128, 128, 128, 0, 0, 0, 0, @@ -55,9 +56,9 @@ private static void RunTransformOneTest() 128, 128, 128, 128, 128, 128, 128, 128, 0, 0, 0, 0, 0, 0, 0, 129, 128, 128, 128, 128, 128, 128, 128, 128, 0, 0, 0, 0, 0, 0, 0, 129, 128, 128, 128, 128, 128, 128, 128, 128, 0, 0, 0, 0, 0, 0, 0, 129 - }; + ]; byte[] expected = - { + [ 111, 111, 111, 111, 128, 128, 128, 128, 0, 0, 0, 0, 0, 0, 0, 129, 128, 128, 128, 128, 128, 128, 128, 128, 0, 0, 0, 0, 0, 0, 0, 129, 108, 108, 108, 108, 128, 128, 128, 128, 0, 0, 0, 0, 0, 0, 0, 129, 128, 128, 128, 128, 128, 128, 128, 128, 0, 0, 0, 0, @@ -65,7 +66,7 @@ private static void RunTransformOneTest() 128, 128, 128, 128, 128, 128, 128, 128, 0, 0, 0, 0, 0, 0, 0, 129, 101, 101, 101, 101, 128, 128, 128, 128, 0, 0, 0, 0, 0, 0, 0, 129, 128, 128, 128, 128, 128, 128, 128, 128, 0, 0, 0, 0, 0, 0, 0, 129 - }; + ]; int[] scratch = new int[16]; // act @@ -86,7 +87,7 @@ private static void RunVp8Sse16X16Test() a[i] = (byte)rand.Next(byte.MaxValue); b[i] = (byte)rand.Next(byte.MaxValue); } - int[] expected = { 2533110, 2818581, 2984663, 2891188, 2855134, 2634604, 2466504, 3061747, 2626010, 2640965 }; + int[] expected = [2533110, 2818581, 2984663, 2891188, 2855134, 2634604, 2466504, 3061747, 2626010, 2640965]; // act + assert int offset = 0; @@ -110,7 +111,7 @@ private static void RunVp8Sse16X8Test() a[i] = (byte)rand.Next(byte.MaxValue); b[i] = (byte)rand.Next(byte.MaxValue); } - int[] expected = { 1298274, 1234836, 1325264, 1493317, 1551995, 1432668, 1407891, 1483297, 1537930, 1317204 }; + int[] expected = [1298274, 1234836, 1325264, 1493317, 1551995, 1432668, 1407891, 1483297, 1537930, 1317204]; // act + assert int offset = 0; @@ -134,7 +135,7 @@ private static void RunVp8Sse4X4Test() a[i] = (byte)rand.Next(byte.MaxValue); b[i] = (byte)rand.Next(byte.MaxValue); } - int[] expected = { 194133, 125861, 165966, 195688, 106491, 173015, 266960, 200272, 311224, 122545 }; + int[] expected = [194133, 125861, 165966, 195688, 106491, 173015, 266960, 200272, 311224, 122545]; // act + assert int offset = 0; @@ -151,7 +152,7 @@ private static void RunMean16x4Test() { // arrange byte[] input = - { + [ 154, 145, 102, 115, 127, 129, 126, 125, 126, 120, 133, 152, 157, 153, 119, 94, 104, 116, 111, 113, 113, 109, 105, 124, 173, 175, 177, 170, 175, 172, 166, 164, 151, 141, 99, 114, 125, 126, 135, 150, 133, 115, 127, 149, 141, 168, 100, 54, 110, 117, 115, 116, 119, 115, 117, 130, 174, 174, 174, 157, @@ -159,9 +160,9 @@ private static void RunMean16x4Test() 109, 115, 113, 120, 120, 117, 128, 115, 174, 173, 173, 161, 152, 148, 153, 162, 105, 140, 96, 114, 115, 122, 141, 173, 190, 190, 142, 106, 151, 78, 66, 141, 110, 117, 123, 136, 118, 124, 127, 114, 173, 175, 166, 155, 155, 159, 159, 158 - }; + ]; uint[] dc = new uint[4]; - uint[] expectedDc = { 1940, 2139, 2252, 1813 }; + uint[] expectedDc = [1940, 2139, 2252, 1813]; // act LossyUtils.Mean16x4(input, dc); @@ -174,24 +175,24 @@ private static void RunHadamardTransformTest() { // arrange byte[] a = - { + [ 27, 27, 28, 29, 29, 28, 27, 27, 27, 28, 28, 29, 29, 28, 28, 27, 129, 129, 129, 129, 129, 129, 129, 129, 128, 128, 128, 128, 128, 128, 128, 128, 27, 27, 27, 27, 27, 27, 27, 27, 27, 28, 28, 29, 29, 28, 28, 27, 129, 129, 129, 129, 129, 129, 129, 129, 128, 128, 128, 128, 128, 128, 128, 128, 27, 27, 26, 26, 26, 26, 27, 27, 27, 28, 28, 29, 29, 28, 28, 27, 129, 129, 129, 129, 129, 129, 129, 129, 128, 128, 128, 128, 128, 128, 128, 128, 28, 27, 27, 26, 26, 27, 27, 28, 27, 28, 28, 29, 29, 28, 28, 27 - }; + ]; byte[] b = - { + [ 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28 - }; + ]; - ushort[] w = { 38, 32, 20, 9, 32, 28, 17, 7, 20, 17, 10, 4, 9, 7, 4, 2 }; + ushort[] w = [38, 32, 20, 9, 32, 28, 17, 7, 20, 17, 10, 4, 9, 7, 4, 2]; int expected = 2; // act diff --git a/tests/ImageSharp.Tests/Formats/WebP/PredictorEncoderTests.cs b/tests/ImageSharp.Tests/Formats/WebP/PredictorEncoderTests.cs index b4279b0454..8e20a39ada 100644 --- a/tests/ImageSharp.Tests/Formats/WebP/PredictorEncoderTests.cs +++ b/tests/ImageSharp.Tests/Formats/WebP/PredictorEncoderTests.cs @@ -43,7 +43,7 @@ private static void RunColorSpaceTransformTestWithPeakImage() { // arrange uint[] expectedData = - { + [ 4278191104, 4278191104, 4278191104, 4278191104, 4278191104, 4278191104, 4278191104, 4294577152, 4294707200, 4294707200, 4294707200, 4294707200, 4294837248, 4294837248, 4293926912, 4294316544, 4278191104, 4278191104, 4294837248, 4294837248, 4280287232, 4280350720, 4294447104, 4294707200, @@ -76,7 +76,7 @@ private static void RunColorSpaceTransformTestWithPeakImage() 4280287232, 4280287232, 4280287232, 4280287232, 4280287232, 4279503872, 4279503872, 4280288256, 4280287232, 4280287232, 4280287232, 4280287232, 4280287232, 4280287232, 4280287232, 4280287232, 4280287232, 4280287232, 4280287232, 4280287232, 4280287232, 4280287232, 4280287232, 4280287232 - }; + ]; // Convert image pixels to bgra array. byte[] imgBytes = File.ReadAllBytes(TestImageFullPath(TestImages.Webp.Peak)); @@ -100,13 +100,13 @@ private static void RunColorSpaceTransformTestWithBikeImage() { // arrange uint[] expectedData = - { + [ 4278714368, 4278192876, 4278198304, 4278198304, 4278190304, 4278190080, 4278190080, 4278198272, 4278197760, 4278198816, 4278197794, 4278197774, 4278190080, 4278190080, 4278198816, 4278197281, 4278197280, 4278197792, 4278200353, 4278191343, 4278190304, 4294713873, 4278198784, 4294844416, 4278201578, 4278200044, 4278191343, 4278190288, 4294705200, 4294717139, 4278203628, 4278201064, 4278201586, 4278197792, 4279240909 - }; + ]; // Convert image pixels to bgra array. byte[] imgBytes = File.ReadAllBytes(TestImageFullPath(TestImages.Webp.Lossy.BikeSmall)); @@ -150,7 +150,7 @@ private static Bgra32 ToBgra32(TPixel color) where TPixel : unmanaged, IPixel { Rgba32 rgba = color.ToRgba32(); - return new Bgra32(rgba.R, rgba.G, rgba.B, rgba.A); + return new(rgba.R, rgba.G, rgba.B, rgba.A); } private static string TestImageFullPath(string path) diff --git a/tests/ImageSharp.Tests/Formats/WebP/QuantEncTests.cs b/tests/ImageSharp.Tests/Formats/WebP/QuantEncTests.cs index 59691204be..fc7da8cf67 100644 --- a/tests/ImageSharp.Tests/Formats/WebP/QuantEncTests.cs +++ b/tests/ImageSharp.Tests/Formats/WebP/QuantEncTests.cs @@ -12,13 +12,14 @@ public class QuantEncTests private static unsafe void RunQuantizeBlockTest() { // arrange - short[] input = { 378, 777, -851, 888, 259, 148, 0, -111, -185, -185, -74, -37, 148, 74, 111, 74 }; + short[] input = [378, 777, -851, 888, 259, 148, 0, -111, -185, -185, -74, -37, 148, 74, 111, 74]; short[] output = new short[16]; - ushort[] q = { 42, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37 }; - ushort[] iq = { 3120, 3542, 3542, 3542, 3542, 3542, 3542, 3542, 3542, 3542, 3542, 3542, 3542, 3542, 3542, 3542 }; - uint[] bias = { 49152, 55296, 55296, 55296, 55296, 55296, 55296, 55296, 55296, 55296, 55296, 55296, 55296, 55296, 55296, 55296 }; - uint[] zthresh = { 26, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21 }; - short[] expectedOutput = { 9, 21, 7, -5, 4, -23, 24, 0, -5, 4, 2, -2, -3, -1, 3, 2 }; + ushort[] q = [42, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37]; + ushort[] iq = [3120, 3542, 3542, 3542, 3542, 3542, 3542, 3542, 3542, 3542, 3542, 3542, 3542, 3542, 3542, 3542]; + uint[] bias = [49152, 55296, 55296, 55296, 55296, 55296, 55296, 55296, 55296, 55296, 55296, 55296, 55296, 55296, 55296, 55296 + ]; + uint[] zthresh = [26, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21]; + short[] expectedOutput = [9, 21, 7, -5, 4, -23, 24, 0, -5, 4, 2, -2, -3, -1, 3, 2]; int expectedResult = 1; Vp8Matrix vp8Matrix = default; for (int i = 0; i < 16; i++) diff --git a/tests/ImageSharp.Tests/Formats/WebP/Vp8EncodingTests.cs b/tests/ImageSharp.Tests/Formats/WebP/Vp8EncodingTests.cs index dab0716927..c0b14cdd7e 100644 --- a/tests/ImageSharp.Tests/Formats/WebP/Vp8EncodingTests.cs +++ b/tests/ImageSharp.Tests/Formats/WebP/Vp8EncodingTests.cs @@ -12,12 +12,14 @@ public class Vp8EncodingTests private static void RunFTransform2Test() { // arrange - byte[] src = { 154, 154, 151, 151, 149, 148, 151, 157, 163, 163, 154, 132, 102, 98, 104, 108, 107, 104, 104, 103, 101, 106, 123, 119, 170, 171, 172, 171, 168, 175, 171, 173, 151, 151, 149, 150, 147, 147, 146, 159, 164, 165, 154, 129, 92, 90, 101, 105, 104, 103, 104, 101, 100, 105, 123, 117, 172, 172, 172, 168, 170, 177, 170, 175, 151, 149, 150, 150, 147, 147, 156, 161, 161, 161, 151, 126, 93, 90, 102, 107, 104, 103, 104, 101, 104, 104, 122, 117, 172, 172, 170, 168, 170, 177, 172, 175, 150, 149, 152, 151, 148, 151, 160, 159, 157, 157, 148, 133, 96, 90, 103, 107, 104, 104, 101, 100, 102, 102, 121, 117, 170, 170, 169, 171, 171, 179, 173, 175 }; - byte[] reference = { 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129 }; + byte[] src = [154, 154, 151, 151, 149, 148, 151, 157, 163, 163, 154, 132, 102, 98, 104, 108, 107, 104, 104, 103, 101, 106, 123, 119, 170, 171, 172, 171, 168, 175, 171, 173, 151, 151, 149, 150, 147, 147, 146, 159, 164, 165, 154, 129, 92, 90, 101, 105, 104, 103, 104, 101, 100, 105, 123, 117, 172, 172, 172, 168, 170, 177, 170, 175, 151, 149, 150, 150, 147, 147, 156, 161, 161, 161, 151, 126, 93, 90, 102, 107, 104, 103, 104, 101, 104, 104, 122, 117, 172, 172, 170, 168, 170, 177, 172, 175, 150, 149, 152, 151, 148, 151, 160, 159, 157, 157, 148, 133, 96, 90, 103, 107, 104, 104, 101, 100, 102, 102, 121, 117, 170, 170, 169, 171, 171, 179, 173, 175 + ]; + byte[] reference = [128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129 + ]; short[] actualOutput1 = new short[16]; short[] actualOutput2 = new short[16]; - short[] expectedOutput1 = { 182, 4, 1, 1, 6, 7, -1, -4, 5, 0, -2, 1, 2, 1, 1, 1 }; - short[] expectedOutput2 = { 192, -34, 10, 1, -11, 8, 10, -7, 6, 3, -8, 4, 5, -3, -2, 6 }; + short[] expectedOutput1 = [182, 4, 1, 1, 6, 7, -1, -4, 5, 0, -2, 1, 2, 1, 1, 1]; + short[] expectedOutput2 = [192, -34, 10, 1, -11, 8, 10, -7, 6, 3, -8, 4, 5, -3, -2, 6]; // act Vp8Encoding.FTransform2(src, reference, actualOutput1, actualOutput2, new int[16]); @@ -31,7 +33,7 @@ private static void RunFTransformTest() { // arrange byte[] src = - { + [ 154, 154, 151, 151, 149, 148, 151, 157, 163, 163, 154, 132, 102, 98, 104, 108, 107, 104, 104, 103, 101, 106, 123, 119, 170, 171, 172, 171, 168, 175, 171, 173, 151, 151, 149, 150, 147, 147, 146, 159, 164, 165, 154, 129, 92, 90, 101, 105, 104, 103, 104, 101, 100, 105, 123, 117, 172, 172, 172, 168, @@ -39,9 +41,9 @@ private static void RunFTransformTest() 104, 103, 104, 101, 104, 104, 122, 117, 172, 172, 170, 168, 170, 177, 172, 175, 150, 149, 152, 151, 148, 151, 160, 159, 157, 157, 148, 133, 96, 90, 103, 107, 104, 104, 101, 100, 102, 102, 121, 117, 170, 170, 169, 171, 171, 179, 173, 175 - }; + ]; byte[] reference = - { + [ 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, @@ -49,9 +51,9 @@ private static void RunFTransformTest() 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129 - }; + ]; short[] actualOutput = new short[16]; - short[] expectedOutput = { 182, 4, 1, 1, 6, 7, -1, -4, 5, 0, -2, 1, 2, 1, 1, 1 }; + short[] expectedOutput = [182, 4, 1, 1, 6, 7, -1, -4, 5, 0, -2, 1, 2, 1, 1, 1]; // act Vp8Encoding.FTransform(src, reference, actualOutput, new int[16]); @@ -64,7 +66,7 @@ private static void RunOneInverseTransformTest() { // arrange byte[] reference = - { + [ 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, @@ -72,17 +74,18 @@ private static void RunOneInverseTransformTest() 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129 - }; - short[] input = { 1, 216, -48, 0, 96, -24, -48, 24, 0, -24, 24, 0, 0, 0, 0, 0, 38, -240, -72, -24, 0, -24, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; + ]; + short[] input = [1, 216, -48, 0, 96, -24, -48, 24, 0, -24, 24, 0, 0, 0, 0, 0, 38, -240, -72, -24, 0, -24, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 + ]; byte[] dst = new byte[128]; byte[] expected = - { + [ 161, 160, 149, 105, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 160, 160, 133, 85, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 156, 147, 109, 76, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 152, 128, 87, 83, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; + ]; int[] scratch = new int[16]; // act @@ -96,7 +99,7 @@ private static void RunTwoInverseTransformTest() { // arrange byte[] reference = - { + [ 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, @@ -104,17 +107,18 @@ private static void RunTwoInverseTransformTest() 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129 - }; - short[] input = { 1, 216, -48, 0, 96, -24, -48, 24, 0, -24, 24, 0, 0, 0, 0, 0, 38, -240, -72, -24, 0, -24, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; + ]; + short[] input = [1, 216, -48, 0, 96, -24, -48, 24, 0, -24, 24, 0, 0, 0, 0, 0, 38, -240, -72, -24, 0, -24, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 + ]; byte[] dst = new byte[128]; byte[] expected = - { + [ 161, 160, 149, 105, 78, 127, 156, 170, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 160, 160, 133, 85, 81, 129, 155, 167, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 156, 147, 109, 76, 85, 130, 153, 163, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 152, 128, 87, 83, 88, 132, 152, 159, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; + ]; int[] scratch = new int[16]; // act diff --git a/tests/ImageSharp.Tests/Formats/WebP/Vp8HistogramTests.cs b/tests/ImageSharp.Tests/Formats/WebP/Vp8HistogramTests.cs index a18eff73ce..3825e50432 100644 --- a/tests/ImageSharp.Tests/Formats/WebP/Vp8HistogramTests.cs +++ b/tests/ImageSharp.Tests/Formats/WebP/Vp8HistogramTests.cs @@ -13,55 +13,61 @@ public static IEnumerable Data { get { - var result = new List(); - result.Add(new object[] - { - new byte[] + List result = + [ + new object[] { - 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 19, 16, 128, 128, 128, 128, 128, 128, - 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, - 16, 16, 16, 19, 16, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, - 128, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 19, 16, 128, 128, 128, 128, 128, - 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, - 16, 16, 16, 16, 19, 16, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, - 128, 128, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 19, 16, 128, 128, 128, 128, - 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 16, 16, 16, 16, 16, 16, 16, 16, 16, - 16, 16, 16, 16, 16, 19, 16, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, - 128, 128, 128, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 19, 16, 128, 128, 128, - 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 16, 16, 16, 16, 16, 16, 16, 16, - 16, 16, 16, 16, 16, 16, 19, 16, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, - 128, 128, 128, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 19, 16, 204, 204, 204, - 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 16, 16, 16, 16, 16, 16, 16, 16, - 16, 16, 16, 16, 16, 16, 19, 16, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, - 204, 204, 204, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 19, 16, 204, 204, 204, - 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 16, 16, 16, 16, 16, 16, 16, 16, - 16, 16, 16, 16, 16, 16, 19, 16, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, - 204, 204, 204, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 19, 16, 204, 204, 204, - 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 16, 16, 16, 16, 16, 16, 16, 16, - 16, 16, 16, 16, 16, 16, 19, 16, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, - 204, 204, 204, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 24, 16, 204, 204, 204, - 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 16, 16, 16, 16, 16, 16, 16, 16, - 16, 16, 16, 16, 16, 16, 16, 16, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, - 204, 204, 204 - }, - new byte[] - { - 128, 128, 128, 128, 129, 129, 129, 129, 127, 127, 127, 127, 129, 129, 129, 129, 128, 127, 127, - 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 128, 128, 128, 128, 129, 129, - 129, 129, 127, 127, 127, 127, 129, 129, 129, 129, 129, 128, 127, 127, 128, 127, 127, 127, 127, - 127, 127, 127, 127, 127, 127, 127, 128, 128, 128, 128, 129, 129, 129, 129, 127, 127, 127, 127, - 129, 129, 129, 129, 129, 129, 128, 127, 129, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, - 127, 128, 128, 128, 128, 129, 129, 129, 129, 127, 127, 127, 127, 129, 129, 129, 129, 129, 129, - 129, 128, 129, 128, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 128, 128, 127, 127, 129, - 129, 129, 129, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, - 204, 204, 204, 204, 204, 204, 204, 204, 129, 129, 128, 128, 129, 129, 129, 129, 204, 204, 204, - 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, - 204, 204, 129, 129, 129, 129, 129, 129, 129, 129, 204, 204, 204, 204, 204, 204, 204, 204, 204, - 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 129, 129, 129, 129, - 129, 129, 129, 129, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, - 204, 204, 204, 204, 204, 204, 204, 204, 204 + new byte[] + { + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 19, 16, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 19, 16, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 19, 16, + 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 19, 16, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 19, 16, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 19, 16, 128, + 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 19, 16, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, 128, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 19, 16, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 19, 16, 204, 204, + 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 19, 16, 204, 204, 204, 204, 204, 204, 204, 204, + 204, 204, 204, 204, 204, 204, 204, 204, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 19, 16, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, + 204, 204, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 19, 16, 204, 204, 204, + 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 19, 16, 204, 204, 204, 204, 204, 204, 204, 204, 204, + 204, 204, 204, 204, 204, 204, 204, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 19, 16, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, + 204, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 24, 16, 204, 204, 204, 204, + 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, + 204, 204, 204, 204, 204, 204 + }, + new byte[] + { + 128, 128, 128, 128, 129, 129, 129, 129, 127, 127, 127, 127, 129, 129, 129, 129, 128, + 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 128, 128, + 128, 128, 129, 129, 129, 129, 127, 127, 127, 127, 129, 129, 129, 129, 129, 128, 127, + 127, 128, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 128, 128, 128, 128, + 129, 129, 129, 129, 127, 127, 127, 127, 129, 129, 129, 129, 129, 129, 128, 127, 129, + 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 128, 128, 128, 128, 129, 129, + 129, 129, 127, 127, 127, 127, 129, 129, 129, 129, 129, 129, 129, 128, 129, 128, 127, + 127, 127, 127, 127, 127, 127, 127, 127, 127, 128, 128, 127, 127, 129, 129, 129, 129, + 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, + 204, 204, 204, 204, 204, 204, 204, 129, 129, 128, 128, 129, 129, 129, 129, 204, 204, + 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, + 204, 204, 204, 204, 204, 129, 129, 129, 129, 129, 129, 129, 129, 204, 204, 204, 204, + 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, + 204, 204, 204, 129, 129, 129, 129, 129, 129, 129, 129, 204, 204, 204, 204, 204, 204, + 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204 + } } - }); + + ]; return result; } } @@ -69,10 +75,10 @@ public static IEnumerable Data private static void RunCollectHistogramTest() { // arrange - var histogram = new Vp8Histogram(); + Vp8Histogram histogram = new(); byte[] reference = - { + [ 154, 154, 151, 151, 149, 148, 151, 157, 163, 163, 154, 132, 102, 98, 104, 108, 107, 104, 104, 103, 101, 106, 123, 119, 170, 171, 172, 171, 168, 175, 171, 173, 151, 151, 149, 150, 147, 147, 146, 159, 164, 165, 154, 129, 92, 90, 101, 105, 104, 103, 104, 101, 100, 105, 123, 117, 172, 172, 172, 168, @@ -99,9 +105,9 @@ private static void RunCollectHistogramTest() 95, 102, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 151, 130, 82, 82, 89, 134, 154, 161, 161, 157, 152, 129, 81, 77, 95, 102, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204 - }; + ]; byte[] pred = - { + [ 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, @@ -154,7 +160,7 @@ private static void RunCollectHistogramTest() 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129 - }; + ]; int expectedAlpha = 146; // act @@ -172,7 +178,7 @@ private static void RunCollectHistogramTest() public void GetAlpha_WithEmptyHistogram_Works() { // arrange - var histogram = new Vp8Histogram(); + Vp8Histogram histogram = new(); // act int alpha = histogram.GetAlpha(); @@ -186,7 +192,7 @@ public void GetAlpha_WithEmptyHistogram_Works() public void GetAlpha_Works(byte[] reference, byte[] pred) { // arrange - var histogram = new Vp8Histogram(); + Vp8Histogram histogram = new(); histogram.CollectHistogram(reference, pred, 0, 1); // act @@ -201,9 +207,9 @@ public void GetAlpha_Works(byte[] reference, byte[] pred) public void Merge_Works(byte[] reference, byte[] pred) { // arrange - var histogram1 = new Vp8Histogram(); + Vp8Histogram histogram1 = new(); histogram1.CollectHistogram(reference, pred, 0, 1); - var histogram2 = new Vp8Histogram(); + Vp8Histogram histogram2 = new(); histogram1.Merge(histogram2); // act diff --git a/tests/ImageSharp.Tests/Formats/WebP/Vp8LHistogramTests.cs b/tests/ImageSharp.Tests/Formats/WebP/Vp8LHistogramTests.cs index cfe79e49e6..12b0edc3cf 100644 --- a/tests/ImageSharp.Tests/Formats/WebP/Vp8LHistogramTests.cs +++ b/tests/ImageSharp.Tests/Formats/WebP/Vp8LHistogramTests.cs @@ -14,7 +14,7 @@ private static void RunAddVectorTest() { // arrange uint[] pixelData = - { + [ 4278191104, 4278191104, 4278191104, 4278191104, 4278191104, 4278191104, 4278191104, 4294577152, 4294707200, 4294707200, 4294707200, 4294707200, 4294837248, 4294837248, 4293926912, 4294316544, 4278191104, 4278191104, 4294837248, 4294837248, 4280287232, 4280350720, 4294447104, 4294707200, @@ -47,10 +47,10 @@ private static void RunAddVectorTest() 4280287232, 4280287232, 4280287232, 4280287232, 4280287232, 4279503872, 4279503872, 4280288256, 4280287232, 4280287232, 4280287232, 4280287232, 4280287232, 4280287232, 4280287232, 4280287232, 4280287232, 4280287232, 4280287232, 4280287232, 4280287232, 4280287232, 4280287232, 4280287232 - }; + ]; uint[] literals = - { + [ 198, 0, 14, 0, 46, 0, 22, 0, 36, 0, 24, 0, 12, 0, 10, 0, 10, 0, 2, 0, 2, 0, 0, 0, 0, 0, 6, 0, 0, 0, 10, 0, 24, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 4, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, @@ -59,7 +59,7 @@ private static void RunAddVectorTest() 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6, 0, 2, 0, 0, 0, 0, 0, 6, 0, 0, 0, 2, 0, 0, 0, 2, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 6, 0, 2, 0, 2, 0, 2, 0, 0, 0, 8, 0, 2, 0, 38, 0, 4 - }; + ]; uint[] expectedLiterals = new uint[1305]; @@ -69,7 +69,7 @@ private static void RunAddVectorTest() Vp8LBackwardRefs backwardRefs = new(pixelData.Length); for (int i = 0; i < pixelData.Length; i++) { - backwardRefs.Add(new PixOrCopy() + backwardRefs.Add(new() { BgraOrDistance = pixelData[i], Len = 1, diff --git a/tests/ImageSharp.Tests/Formats/WebP/Vp8ModeScoreTests.cs b/tests/ImageSharp.Tests/Formats/WebP/Vp8ModeScoreTests.cs index 0b85ececb9..ded637967a 100644 --- a/tests/ImageSharp.Tests/Formats/WebP/Vp8ModeScoreTests.cs +++ b/tests/ImageSharp.Tests/Formats/WebP/Vp8ModeScoreTests.cs @@ -11,7 +11,7 @@ public class Vp8ModeScoreTests [Fact] public void InitScore_Works() { - var score = new Vp8ModeScore(); + Vp8ModeScore score = new(); score.InitScore(); Assert.Equal(0, score.D); Assert.Equal(0, score.SD); @@ -25,7 +25,7 @@ public void InitScore_Works() public void CopyScore_Works() { // arrange - var score1 = new Vp8ModeScore + Vp8ModeScore score1 = new() { Score = 123, Nz = 1, @@ -36,7 +36,7 @@ public void CopyScore_Works() R = 6, SD = 7 }; - var score2 = new Vp8ModeScore(); + Vp8ModeScore score2 = new(); score2.InitScore(); // act @@ -55,7 +55,7 @@ public void CopyScore_Works() public void AddScore_Works() { // arrange - var score1 = new Vp8ModeScore + Vp8ModeScore score1 = new() { Score = 123, Nz = 1, @@ -66,7 +66,7 @@ public void AddScore_Works() R = 6, SD = 7 }; - var score2 = new Vp8ModeScore + Vp8ModeScore score2 = new() { Score = 123, Nz = 1, diff --git a/tests/ImageSharp.Tests/Formats/WebP/Vp8ResidualTests.cs b/tests/ImageSharp.Tests/Formats/WebP/Vp8ResidualTests.cs index 4982929c2c..90213ad6fd 100644 --- a/tests/ImageSharp.Tests/Formats/WebP/Vp8ResidualTests.cs +++ b/tests/ImageSharp.Tests/Formats/WebP/Vp8ResidualTests.cs @@ -80,7 +80,7 @@ private static Vp8Residual ReadVp8Residual(string fileName) Vp8BandProbas[] bandProbas = new Vp8BandProbas[8]; for (int i = 0; i < bandProbas.Length; i++) { - bandProbas[i] = new Vp8BandProbas(); + bandProbas[i] = new(); for (int j = 0; j < bandProbas[i].Probabilities.Length; j++) { for (int k = 0; k < 11; k++) @@ -95,7 +95,7 @@ private static Vp8Residual ReadVp8Residual(string fileName) residual.Costs = new Vp8Costs[16]; for (int i = 0; i < residual.Costs.Length; i++) { - residual.Costs[i] = new Vp8Costs(); + residual.Costs[i] = new(); Vp8CostArray[] costsArray = residual.Costs[i].Costs; for (int j = 0; j < costsArray.Length; j++) { @@ -109,7 +109,7 @@ private static Vp8Residual ReadVp8Residual(string fileName) residual.Stats = new Vp8Stats[8]; for (int i = 0; i < residual.Stats.Length; i++) { - residual.Stats[i] = new Vp8Stats(); + residual.Stats[i] = new(); for (int j = 0; j < residual.Stats[i].Stats.Length; j++) { for (int k = 0; k < residual.Stats[i].Stats[j].Stats.Length; k++) @@ -239,7 +239,7 @@ private static void RunSetCoeffsTest() { // arrange Vp8Residual residual = new(); - short[] coeffs = { 110, 0, -2, 0, 0, 0, 0, 0, 0, -1, 0, 0, 0, 0, 0, 0 }; + short[] coeffs = [110, 0, -2, 0, 0, 0, 0, 0, 0, -1, 0, 0, 0, 0, 0, 0]; // act residual.SetCoeffs(coeffs); diff --git a/tests/ImageSharp.Tests/Formats/WebP/WebpCommonUtilsTests.cs b/tests/ImageSharp.Tests/Formats/WebP/WebpCommonUtilsTests.cs index a3fe028db5..dc4fbcd9fc 100644 --- a/tests/ImageSharp.Tests/Formats/WebP/WebpCommonUtilsTests.cs +++ b/tests/ImageSharp.Tests/Formats/WebP/WebpCommonUtilsTests.cs @@ -45,7 +45,7 @@ private static void RunCheckNoneOpaqueWithNoneOpaquePixelsTest() { // arrange byte[] rowBytes = - { + [ 122, 120, 101, 255, 171, 165, 151, 255, 209, 208, 210, 255, @@ -104,8 +104,8 @@ private static void RunCheckNoneOpaqueWithNoneOpaquePixelsTest() 171, 165, 151, 0, 209, 208, 210, 100, 174, 183, 189, 255, - 148, 158, 158, 255, - }; + 148, 158, 158, 255 + ]; Span row = MemoryMarshal.Cast(rowBytes); bool noneOpaque; @@ -127,7 +127,7 @@ private static void RunCheckNoneOpaqueWithOpaquePixelsTest() { // arrange byte[] rowBytes = - { + [ 122, 120, 101, 255, 171, 165, 151, 255, 209, 208, 210, 255, @@ -186,8 +186,8 @@ private static void RunCheckNoneOpaqueWithOpaquePixelsTest() 171, 165, 151, 255, 209, 208, 210, 255, 174, 183, 189, 255, - 148, 158, 158, 255, - }; + 148, 158, 158, 255 + ]; Span row = MemoryMarshal.Cast(rowBytes); bool noneOpaque; diff --git a/tests/ImageSharp.Tests/Formats/WebP/WebpDecoderTests.cs b/tests/ImageSharp.Tests/Formats/WebP/WebpDecoderTests.cs index 657ab25546..6379134653 100644 --- a/tests/ImageSharp.Tests/Formats/WebP/WebpDecoderTests.cs +++ b/tests/ImageSharp.Tests/Formats/WebP/WebpDecoderTests.cs @@ -348,7 +348,7 @@ public void Decode_AnimatedLossy_IgnoreBackgroundColor_Works(TestImagePr WebpDecoderOptions options = new() { BackgroundColorHandling = BackgroundColorHandling.Ignore, - GeneralOptions = new DecoderOptions() + GeneralOptions = new() { MaxFrames = 1 } diff --git a/tests/ImageSharp.Tests/Formats/WebP/WebpMetaDataTests.cs b/tests/ImageSharp.Tests/Formats/WebP/WebpMetaDataTests.cs index ab8fef60f7..020b42f377 100644 --- a/tests/ImageSharp.Tests/Formats/WebP/WebpMetaDataTests.cs +++ b/tests/ImageSharp.Tests/Formats/WebP/WebpMetaDataTests.cs @@ -103,9 +103,9 @@ public async Task IgnoreMetadata_ControlsWhetherXmpIsParsed(TestImagePro public void Encode_WritesExifWithPadding(WebpFileFormatType fileFormatType) { // arrange - using var input = new Image(25, 25); - using var memoryStream = new MemoryStream(); - var expectedExif = new ExifProfile(); + using Image input = new(25, 25); + using MemoryStream memoryStream = new(); + ExifProfile expectedExif = new(); string expectedSoftware = "ImageSharp"; expectedExif.SetValue(ExifTag.Software, expectedSoftware); input.Metadata.ExifProfile = expectedExif; @@ -115,7 +115,7 @@ public void Encode_WritesExifWithPadding(WebpFileFormatType fileFormatType) memoryStream.Position = 0; // assert - using var image = Image.Load(memoryStream); + using Image image = Image.Load(memoryStream); ExifProfile actualExif = image.Metadata.ExifProfile; Assert.NotNull(actualExif); Assert.Equal(expectedExif.Values.Count, actualExif.Values.Count); @@ -129,7 +129,7 @@ public void EncodeLossyWebp_PreservesExif(TestImageProvider prov { // arrange using Image input = provider.GetImage(WebpDecoder.Instance); - using var memoryStream = new MemoryStream(); + using MemoryStream memoryStream = new(); ExifProfile expectedExif = input.Metadata.ExifProfile; // act @@ -137,7 +137,7 @@ public void EncodeLossyWebp_PreservesExif(TestImageProvider prov memoryStream.Position = 0; // assert - using var image = Image.Load(memoryStream); + using Image image = Image.Load(memoryStream); ExifProfile actualExif = image.Metadata.ExifProfile; Assert.NotNull(actualExif); Assert.Equal(expectedExif.Values.Count, actualExif.Values.Count); @@ -150,7 +150,7 @@ public void EncodeLosslessWebp_PreservesExif(TestImageProvider p { // arrange using Image input = provider.GetImage(WebpDecoder.Instance); - using var memoryStream = new MemoryStream(); + using MemoryStream memoryStream = new(); ExifProfile expectedExif = input.Metadata.ExifProfile; // act @@ -158,7 +158,7 @@ public void EncodeLosslessWebp_PreservesExif(TestImageProvider p memoryStream.Position = 0; // assert - using var image = Image.Load(memoryStream); + using Image image = Image.Load(memoryStream); ExifProfile actualExif = image.Metadata.ExifProfile; Assert.NotNull(actualExif); Assert.Equal(expectedExif.Values.Count, actualExif.Values.Count); @@ -174,14 +174,14 @@ public void Encode_PreservesColorProfile(TestImageProvider provi ImageSharp.Metadata.Profiles.Icc.IccProfile expectedProfile = input.Metadata.IccProfile; byte[] expectedProfileBytes = expectedProfile.ToByteArray(); - using var memStream = new MemoryStream(); + using MemoryStream memStream = new(); input.Save(memStream, new WebpEncoder() { FileFormat = fileFormat }); memStream.Position = 0; - using var output = Image.Load(memStream); + using Image output = Image.Load(memStream); ImageSharp.Metadata.Profiles.Icc.IccProfile actualProfile = output.Metadata.IccProfile; byte[] actualProfileBytes = actualProfile.ToByteArray(); diff --git a/tests/ImageSharp.Tests/Formats/WebP/YuvConversionTests.cs b/tests/ImageSharp.Tests/Formats/WebP/YuvConversionTests.cs index f50bc89335..e86642fea9 100644 --- a/tests/ImageSharp.Tests/Formats/WebP/YuvConversionTests.cs +++ b/tests/ImageSharp.Tests/Formats/WebP/YuvConversionTests.cs @@ -19,7 +19,7 @@ public class YuvConversionTests public static void RunUpSampleYuvToRgbTest() { - var provider = TestImageProvider.File(TestImageLossyFullPath); + TestImageProvider provider = TestImageProvider.File(TestImageLossyFullPath); using Image image = provider.GetImage(WebpDecoder.Instance); image.DebugSave(provider); image.CompareToOriginal(provider, ReferenceDecoder); @@ -52,7 +52,7 @@ public void ConvertRgbToYuv_Works(TestImageProvider provider) Span u = uBuffer.GetSpan(); Span v = vBuffer.GetSpan(); byte[] expectedY = - { + [ 82, 82, 82, 82, 128, 135, 134, 129, 167, 179, 176, 172, 192, 201, 200, 204, 188, 172, 175, 177, 168, 151, 154, 154, 153, 152, 151, 151, 152, 160, 160, 160, 160, 82, 82, 82, 82, 140, 137, 135, 116, 174, 183, 176, 162, 196, 199, 199, 210, 188, 166, 176, 181, 170, 145, 155, 154, 153, 154, 151, 151, 150, @@ -106,9 +106,9 @@ public void ConvertRgbToYuv_Works(TestImageProvider provider) 86, 75, 72, 77, 106, 96, 97, 96, 97, 100, 100, 100, 160, 160, 160, 159, 169, 170, 168, 170, 129, 115, 117, 123, 90, 71, 76, 79, 62, 51, 51, 47, 59, 79, 75, 74, 81, 100, 97, 98, 98, 100, 100, 100, 100 - }; + ]; byte[] expectedU = - { + [ 90, 90, 59, 63, 36, 38, 23, 20, 34, 35, 47, 48, 70, 82, 104, 121, 121, 90, 90, 61, 69, 37, 42, 22, 18, 33, 32, 47, 47, 67, 75, 97, 113, 120, 59, 61, 30, 37, 22, 20, 38, 36, 50, 50, 78, 83, 113, 122, 142, 166, 164, 63, 69, 37, 43, 20, 18, 34, 32, 48, 47, 70, 73, 102, 110, 136, 166, 166, 36, 37, 22, @@ -123,9 +123,9 @@ public void ConvertRgbToYuv_Works(TestImageProvider provider) 184, 212, 208, 227, 228, 227, 229, 218, 214, 196, 185, 188, 121, 113, 166, 166, 197, 191, 220, 217, 232, 237, 223, 222, 211, 208, 185, 173, 172, 121, 120, 164, 166, 193, 194, 217, 219, 232, 235, 224, 220, 212, 207, 188, 172, 172 - }; + ]; byte[] expectedV = - { + [ 240, 240, 201, 206, 172, 174, 136, 136, 92, 90, 55, 50, 37, 30, 26, 23, 23, 240, 240, 204, 213, 173, 179, 141, 141, 96, 98, 56, 54, 38, 31, 27, 25, 23, 201, 204, 164, 172, 129, 135, 82, 87, 46, 47, 33, 29, 25, 23, 20, 16, 16, 206, 213, 172, 180, 137, 141, 93, 99, 54, 54, 36, 31, 26, 25, 21, 17, 16, @@ -139,7 +139,7 @@ public void ConvertRgbToYuv_Works(TestImageProvider provider) 118, 151, 164, 188, 205, 206, 26, 27, 20, 21, 43, 39, 74, 69, 103, 102, 138, 143, 174, 188, 204, 216, 218, 23, 25, 16, 17, 55, 48, 85, 81, 117, 118, 159, 164, 195, 205, 216, 227, 227, 23, 23, 16, 16, 51, 52, 81, 83, 116, 122, 157, 168, 194, 206, 218, 227, 227 - }; + ]; // act YuvConversion.ConvertRgbToYuv(image.Frames.RootFrame.PixelBuffer.GetRegion(), config, memoryAllocator, y, u, v); @@ -169,7 +169,7 @@ public void ConvertRgbToYuv_WithAlpha_Works(TestImageProvider pr Span u = uBuffer.GetSpan(); Span v = vBuffer.GetSpan(); byte[] expectedY = - { + [ 16, 16, 16, 16, 16, 235, 235, 235, 235, 235, 16, 16, 16, 16, 16, 152, 41, 41, 152, 152, 41, 41, 152, 152, 41, 41, 152, 152, 41, 41, 152, 16, 16, 16, 16, 16, 235, 235, 235, 235, 235, 16, 16, 16, 16, 16, 152, 41, 41, 152, 152, 41, 41, 152, 152, 41, 41, 152, 152, 41, 41, 152, 16, 16, 16, 16, 16, 235, @@ -213,9 +213,9 @@ public void ConvertRgbToYuv_WithAlpha_Works(TestImageProvider pr 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 29, 106, 183, 66, 143, 130, 78, 90, 168, 116, 103, 180, 63, 140, 152, 75, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 93, 171, 53, 131, 118, 66, 78, 155, 103, 90, 167, 50, 128, 140, 63, 75 - }; + ]; byte[] expectedU = - { + [ 128, 128, 128, 128, 128, 128, 128, 139, 240, 139, 240, 139, 240, 139, 240, 139, 128, 128, 128, 128, 128, 128, 128, 139, 240, 139, 240, 139, 240, 139, 240, 139, 128, 128, 128, 128, 128, 128, 128, 139, 240, 139, 240, 139, 240, 139, 240, 139, 128, 128, 128, 128, 128, 128, 128, 139, 240, 139, 240, 139, @@ -229,9 +229,9 @@ public void ConvertRgbToYuv_WithAlpha_Works(TestImageProvider pr 159, 159, 159, 159, 159, 159, 159, 161, 112, 113, 138, 87, 143, 112, 88, 161, 240, 240, 240, 240, 240, 240, 240, 137, 110, 162, 110, 140, 158, 104, 159, 137, 240, 240, 240, 240, 240, 240, 240, 109, 150, 108, 140, 161, 80, 157, 162, 128 - }; + ]; byte[] expectedV = - { + [ 128, 128, 128, 128, 128, 128, 128, 189, 110, 189, 110, 189, 110, 189, 110, 189, 128, 128, 128, 128, 128, 128, 128, 189, 110, 189, 110, 189, 110, 189, 110, 189, 128, 128, 128, 128, 128, 128, 128, 189, 110, 189, 110, 189, 110, 189, 110, 189, 128, 128, 128, 128, 128, 128, 128, 189, 110, 189, 110, 189, @@ -245,7 +245,7 @@ public void ConvertRgbToYuv_WithAlpha_Works(TestImageProvider pr 141, 165, 126, 147, 173, 101, 101, 101, 101, 101, 101, 101, 135, 109, 129, 122, 124, 107, 108, 128, 138, 110, 110, 110, 110, 110, 110, 110, 117, 137, 151, 127, 114, 131, 139, 142, 120, 110, 110, 110, 110, 110, 110, 110, 142, 156, 119, 137, 167, 141, 151, 66, 85 - }; + ]; // act YuvConversion.ConvertRgbToYuv(image.Frames.RootFrame.PixelBuffer.GetRegion(), config, memoryAllocator, y, u, v); diff --git a/tests/ImageSharp.Tests/GraphicOptionsDefaultsExtensionsTests.cs b/tests/ImageSharp.Tests/GraphicOptionsDefaultsExtensionsTests.cs index d663a803b3..682f5373db 100644 --- a/tests/ImageSharp.Tests/GraphicOptionsDefaultsExtensionsTests.cs +++ b/tests/ImageSharp.Tests/GraphicOptionsDefaultsExtensionsTests.cs @@ -12,9 +12,9 @@ public class GraphicOptionsDefaultsExtensionsTests [Fact] public void SetDefaultOptionsOnProcessingContext() { - var option = new GraphicsOptions(); - var config = new Configuration(); - var context = new FakeImageOperationsProvider.FakeImageOperations(config, null, true); + GraphicsOptions option = new(); + Configuration config = new(); + FakeImageOperationsProvider.FakeImageOperations context = new(config, null, true); context.SetGraphicsOptions(option); @@ -26,12 +26,12 @@ public void SetDefaultOptionsOnProcessingContext() [Fact] public void UpdateDefaultOptionsOnProcessingContext_AlwaysNewInstance() { - var option = new GraphicsOptions() + GraphicsOptions option = new() { BlendPercentage = 0.9f }; - var config = new Configuration(); - var context = new FakeImageOperationsProvider.FakeImageOperations(config, null, true); + Configuration config = new(); + FakeImageOperationsProvider.FakeImageOperations context = new(config, null, true); context.SetGraphicsOptions(option); context.SetGraphicsOptions(o => @@ -40,7 +40,7 @@ public void UpdateDefaultOptionsOnProcessingContext_AlwaysNewInstance() o.BlendPercentage = 0.4f; }); - var returnedOption = context.GetGraphicsOptions(); + GraphicsOptions returnedOption = context.GetGraphicsOptions(); Assert.Equal(0.4f, returnedOption.BlendPercentage); Assert.Equal(0.9f, option.BlendPercentage); // hasn't been mutated } @@ -48,8 +48,8 @@ public void UpdateDefaultOptionsOnProcessingContext_AlwaysNewInstance() [Fact] public void SetDefaultOptionsOnConfiguration() { - var option = new GraphicsOptions(); - var config = new Configuration(); + GraphicsOptions option = new(); + Configuration config = new(); config.SetGraphicsOptions(option); @@ -59,11 +59,11 @@ public void SetDefaultOptionsOnConfiguration() [Fact] public void UpdateDefaultOptionsOnConfiguration_AlwaysNewInstance() { - var option = new GraphicsOptions() + GraphicsOptions option = new() { BlendPercentage = 0.9f }; - var config = new Configuration(); + Configuration config = new(); config.SetGraphicsOptions(option); config.SetGraphicsOptions(o => @@ -72,7 +72,7 @@ public void UpdateDefaultOptionsOnConfiguration_AlwaysNewInstance() o.BlendPercentage = 0.4f; }); - var returnedOption = config.GetGraphicsOptions(); + GraphicsOptions returnedOption = config.GetGraphicsOptions(); Assert.Equal(0.4f, returnedOption.BlendPercentage); Assert.Equal(0.9f, option.BlendPercentage); // hasn't been mutated } @@ -80,13 +80,13 @@ public void UpdateDefaultOptionsOnConfiguration_AlwaysNewInstance() [Fact] public void GetDefaultOptionsFromConfiguration_SettingNullThenReturnsNewInstance() { - var config = new Configuration(); + Configuration config = new(); - var options = config.GetGraphicsOptions(); + GraphicsOptions options = config.GetGraphicsOptions(); Assert.NotNull(options); config.SetGraphicsOptions((GraphicsOptions)null); - var options2 = config.GetGraphicsOptions(); + GraphicsOptions options2 = config.GetGraphicsOptions(); Assert.NotNull(options2); // we set it to null should now be a new instance @@ -96,10 +96,10 @@ public void GetDefaultOptionsFromConfiguration_SettingNullThenReturnsNewInstance [Fact] public void GetDefaultOptionsFromConfiguration_IgnoreIncorectlyTypesDictionEntry() { - var config = new Configuration(); + Configuration config = new(); config.Properties[typeof(GraphicsOptions)] = "wronge type"; - var options = config.GetGraphicsOptions(); + GraphicsOptions options = config.GetGraphicsOptions(); Assert.NotNull(options); Assert.IsType(options); } @@ -107,63 +107,63 @@ public void GetDefaultOptionsFromConfiguration_IgnoreIncorectlyTypesDictionEntry [Fact] public void GetDefaultOptionsFromConfiguration_AlwaysReturnsInstance() { - var config = new Configuration(); + Configuration config = new(); Assert.DoesNotContain(typeof(GraphicsOptions), config.Properties.Keys); - var options = config.GetGraphicsOptions(); + GraphicsOptions options = config.GetGraphicsOptions(); Assert.NotNull(options); } [Fact] public void GetDefaultOptionsFromConfiguration_AlwaysReturnsSameValue() { - var config = new Configuration(); + Configuration config = new(); - var options = config.GetGraphicsOptions(); - var options2 = config.GetGraphicsOptions(); + GraphicsOptions options = config.GetGraphicsOptions(); + GraphicsOptions options2 = config.GetGraphicsOptions(); Assert.Equal(options, options2); } [Fact] public void GetDefaultOptionsFromProcessingContext_AlwaysReturnsInstance() { - var config = new Configuration(); - var context = new FakeImageOperationsProvider.FakeImageOperations(config, null, true); + Configuration config = new(); + FakeImageOperationsProvider.FakeImageOperations context = new(config, null, true); - var ctxOptions = context.GetGraphicsOptions(); + GraphicsOptions ctxOptions = context.GetGraphicsOptions(); Assert.NotNull(ctxOptions); } [Fact] public void GetDefaultOptionsFromProcessingContext_AlwaysReturnsInstanceEvenIfSetToNull() { - var config = new Configuration(); - var context = new FakeImageOperationsProvider.FakeImageOperations(config, null, true); + Configuration config = new(); + FakeImageOperationsProvider.FakeImageOperations context = new(config, null, true); context.SetGraphicsOptions((GraphicsOptions)null); - var ctxOptions = context.GetGraphicsOptions(); + GraphicsOptions ctxOptions = context.GetGraphicsOptions(); Assert.NotNull(ctxOptions); } [Fact] public void GetDefaultOptionsFromProcessingContext_FallbackToConfigsInstance() { - var option = new GraphicsOptions(); - var config = new Configuration(); + GraphicsOptions option = new(); + Configuration config = new(); config.SetGraphicsOptions(option); - var context = new FakeImageOperationsProvider.FakeImageOperations(config, null, true); + FakeImageOperationsProvider.FakeImageOperations context = new(config, null, true); - var ctxOptions = context.GetGraphicsOptions(); + GraphicsOptions ctxOptions = context.GetGraphicsOptions(); Assert.Equal(option, ctxOptions); } [Fact] public void GetDefaultOptionsFromProcessingContext_IgnoreIncorectlyTypesDictionEntry() { - var config = new Configuration(); - var context = new FakeImageOperationsProvider.FakeImageOperations(config, null, true); + Configuration config = new(); + FakeImageOperationsProvider.FakeImageOperations context = new(config, null, true); context.Properties[typeof(GraphicsOptions)] = "wronge type"; - var options = context.GetGraphicsOptions(); + GraphicsOptions options = context.GetGraphicsOptions(); Assert.NotNull(options); Assert.IsType(options); } diff --git a/tests/ImageSharp.Tests/GraphicsOptionsTests.cs b/tests/ImageSharp.Tests/GraphicsOptionsTests.cs index 3531599866..0ccb80d3f5 100644 --- a/tests/ImageSharp.Tests/GraphicsOptionsTests.cs +++ b/tests/ImageSharp.Tests/GraphicsOptionsTests.cs @@ -8,8 +8,8 @@ namespace SixLabors.ImageSharp.Tests; public class GraphicsOptionsTests { - private static readonly GraphicsOptionsComparer GraphicsOptionsComparer = new GraphicsOptionsComparer(); - private readonly GraphicsOptions newGraphicsOptions = new GraphicsOptions(); + private static readonly GraphicsOptionsComparer GraphicsOptionsComparer = new(); + private readonly GraphicsOptions newGraphicsOptions = new(); private readonly GraphicsOptions cloneGraphicsOptions = new GraphicsOptions().DeepClone(); [Fact] @@ -57,7 +57,7 @@ public void DefaultGraphicsOptionsAlphaCompositionMode() [Fact] public void NonDefaultClone() { - var expected = new GraphicsOptions + GraphicsOptions expected = new() { AlphaCompositionMode = PixelAlphaCompositionMode.DestAtop, Antialias = false, @@ -74,7 +74,7 @@ public void NonDefaultClone() [Fact] public void CloneIsDeep() { - var expected = new GraphicsOptions(); + GraphicsOptions expected = new(); GraphicsOptions actual = expected.DeepClone(); actual.AlphaCompositionMode = PixelAlphaCompositionMode.DestAtop; diff --git a/tests/ImageSharp.Tests/Helpers/ColorNumericsTests.cs b/tests/ImageSharp.Tests/Helpers/ColorNumericsTests.cs index 4c06d0cd55..1bf137f34d 100644 --- a/tests/ImageSharp.Tests/Helpers/ColorNumericsTests.cs +++ b/tests/ImageSharp.Tests/Helpers/ColorNumericsTests.cs @@ -15,7 +15,7 @@ public class ColorNumericsTests public void GetBT709Luminance_WithVector4(float x, float y, float z, int luminanceLevels, int expected) { // arrange - var vector = new Vector4(x, y, z, 0.0f); + Vector4 vector = new(x, y, z, 0.0f); // act int actual = ColorNumerics.GetBT709Luminance(ref vector, luminanceLevels); diff --git a/tests/ImageSharp.Tests/Helpers/NumericsTests.cs b/tests/ImageSharp.Tests/Helpers/NumericsTests.cs index 75f988a4cb..1106144c4f 100644 --- a/tests/ImageSharp.Tests/Helpers/NumericsTests.cs +++ b/tests/ImageSharp.Tests/Helpers/NumericsTests.cs @@ -9,7 +9,7 @@ public class NumericsTests { private delegate void SpanAction(Span span, TArg arg, TArg1 arg1); - private readonly ApproximateFloatComparer approximateFloatComparer = new ApproximateFloatComparer(1e-6f); + private readonly ApproximateFloatComparer approximateFloatComparer = new(1e-6f); [Theory] [InlineData(0)] @@ -162,7 +162,7 @@ public void LeastCommonMultiple(int a, int b, int expected) [InlineData(63)] public void PremultiplyVectorSpan(int length) { - var rnd = new Random(42); + Random rnd = new(42); Vector4[] source = rnd.GenerateRandomVectorArray(length, 0, 1); Vector4[] expected = source.Select(v => { @@ -182,7 +182,7 @@ public void PremultiplyVectorSpan(int length) [InlineData(63)] public void UnPremultiplyVectorSpan(int length) { - var rnd = new Random(42); + Random rnd = new(42); Vector4[] source = rnd.GenerateRandomVectorArray(length, 0, 1); Vector4[] expected = source.Select(v => { @@ -280,7 +280,7 @@ private static void TestClampSpan( { Span actual = new T[length]; - var r = new Random(); + Random r = new(); for (int i = 0; i < length; i++) { actual[i] = (T)Convert.ChangeType(r.Next(byte.MinValue, byte.MaxValue), typeof(T)); diff --git a/tests/ImageSharp.Tests/Helpers/ParallelExecutionSettingsTests.cs b/tests/ImageSharp.Tests/Helpers/ParallelExecutionSettingsTests.cs index c13a30052c..983c3cc2b9 100644 --- a/tests/ImageSharp.Tests/Helpers/ParallelExecutionSettingsTests.cs +++ b/tests/ImageSharp.Tests/Helpers/ParallelExecutionSettingsTests.cs @@ -28,7 +28,7 @@ public void Constructor_MaxDegreeOfParallelism_CompatibleWith_ParallelOptions(in } else { - var parallelSettings = new ParallelExecutionSettings( + ParallelExecutionSettings parallelSettings = new( maxDegreeOfParallelism, Configuration.Default.MemoryAllocator); Assert.Equal(maxDegreeOfParallelism, parallelSettings.MaxDegreeOfParallelism); diff --git a/tests/ImageSharp.Tests/Helpers/ParallelRowIteratorTests.cs b/tests/ImageSharp.Tests/Helpers/ParallelRowIteratorTests.cs index d393850d6b..e5e6b18f80 100644 --- a/tests/ImageSharp.Tests/Helpers/ParallelRowIteratorTests.cs +++ b/tests/ImageSharp.Tests/Helpers/ParallelRowIteratorTests.cs @@ -26,7 +26,7 @@ public ParallelRowIteratorTests(ITestOutputHelper output) /// maxDegreeOfParallelism, minY, maxY, expectedStepLength, expectedLastStepLength /// public static TheoryData IterateRows_OverMinimumPixelsLimit_Data = - new TheoryData + new() { { 1, 0, 100, -1, 100, 1 }, { 2, 0, 9, 5, 4, 2 }, @@ -52,12 +52,12 @@ public void IterateRows_OverMinimumPixelsLimit_IntervalsAreCorrect( int expectedLastStepLength, int expectedNumberOfSteps) { - var parallelSettings = new ParallelExecutionSettings( + ParallelExecutionSettings parallelSettings = new( maxDegreeOfParallelism, 1, Configuration.Default.MemoryAllocator); - var rectangle = new Rectangle(0, minY, 10, maxY - minY); + Rectangle rectangle = new(0, minY, 10, maxY - minY); int actualNumberOfSteps = 0; @@ -73,7 +73,7 @@ void RowAction(RowInterval rows) Assert.Equal(expected, step); } - var operation = new TestRowIntervalOperation(RowAction); + TestRowIntervalOperation operation = new(RowAction); ParallelRowIterator.IterateRowIntervals( rectangle, @@ -93,15 +93,15 @@ public void IterateRows_OverMinimumPixelsLimit_ShouldVisitAllRows( int expectedLastStepLength, int expectedNumberOfSteps) { - var parallelSettings = new ParallelExecutionSettings( + ParallelExecutionSettings parallelSettings = new( maxDegreeOfParallelism, 1, Configuration.Default.MemoryAllocator); - var rectangle = new Rectangle(0, minY, 10, maxY - minY); + Rectangle rectangle = new(0, minY, 10, maxY - minY); int[] expectedData = Enumerable.Repeat(0, minY).Concat(Enumerable.Range(minY, maxY - minY)).ToArray(); - var actualData = new int[maxY]; + int[] actualData = new int[maxY]; void RowAction(RowInterval rows) { @@ -111,7 +111,7 @@ void RowAction(RowInterval rows) } } - var operation = new TestRowIntervalOperation(RowAction); + TestRowIntervalOperation operation = new(RowAction); ParallelRowIterator.IterateRowIntervals( rectangle, @@ -131,12 +131,12 @@ public void IterateRowsWithTempBuffer_OverMinimumPixelsLimit( int expectedLastStepLength, int expectedNumberOfSteps) { - var parallelSettings = new ParallelExecutionSettings( + ParallelExecutionSettings parallelSettings = new( maxDegreeOfParallelism, 1, Configuration.Default.MemoryAllocator); - var rectangle = new Rectangle(0, minY, 10, maxY - minY); + Rectangle rectangle = new(0, minY, 10, maxY - minY); int actualNumberOfSteps = 0; @@ -152,7 +152,7 @@ void RowAction(RowInterval rows, Span buffer) Assert.Equal(expected, step); } - var operation = new TestRowIntervalOperation(RowAction); + TestRowIntervalOperation operation = new(RowAction); ParallelRowIterator.IterateRowIntervals, Vector4>( rectangle, @@ -172,15 +172,15 @@ public void IterateRowsWithTempBuffer_OverMinimumPixelsLimit_ShouldVisitAllRows( int expectedLastStepLength, int expectedNumberOfSteps) { - var parallelSettings = new ParallelExecutionSettings( + ParallelExecutionSettings parallelSettings = new( maxDegreeOfParallelism, 1, Configuration.Default.MemoryAllocator); - var rectangle = new Rectangle(0, minY, 10, maxY - minY); + Rectangle rectangle = new(0, minY, 10, maxY - minY); int[] expectedData = Enumerable.Repeat(0, minY).Concat(Enumerable.Range(minY, maxY - minY)).ToArray(); - var actualData = new int[maxY]; + int[] actualData = new int[maxY]; void RowAction(RowInterval rows, Span buffer) { @@ -190,7 +190,7 @@ void RowAction(RowInterval rows, Span buffer) } } - var operation = new TestRowIntervalOperation(RowAction); + TestRowIntervalOperation operation = new(RowAction); ParallelRowIterator.IterateRowIntervals, Vector4>( rectangle, @@ -201,7 +201,7 @@ void RowAction(RowInterval rows, Span buffer) } public static TheoryData IterateRows_WithEffectiveMinimumPixelsLimit_Data = - new TheoryData + new() { { 2, 200, 50, 2, 1, -1, 2 }, { 2, 200, 200, 1, 1, -1, 1 }, @@ -223,12 +223,12 @@ public void IterateRows_WithEffectiveMinimumPixelsLimit( int expectedStepLength, int expectedLastStepLength) { - var parallelSettings = new ParallelExecutionSettings( + ParallelExecutionSettings parallelSettings = new( maxDegreeOfParallelism, minimumPixelsProcessedPerTask, Configuration.Default.MemoryAllocator); - var rectangle = new Rectangle(0, 0, width, height); + Rectangle rectangle = new(0, 0, width, height); int actualNumberOfSteps = 0; @@ -244,7 +244,7 @@ void RowAction(RowInterval rows) Assert.Equal(expected, step); } - var operation = new TestRowIntervalOperation(RowAction); + TestRowIntervalOperation operation = new(RowAction); ParallelRowIterator.IterateRowIntervals( rectangle, @@ -265,12 +265,12 @@ public void IterateRowsWithTempBuffer_WithEffectiveMinimumPixelsLimit( int expectedStepLength, int expectedLastStepLength) { - var parallelSettings = new ParallelExecutionSettings( + ParallelExecutionSettings parallelSettings = new( maxDegreeOfParallelism, minimumPixelsProcessedPerTask, Configuration.Default.MemoryAllocator); - var rectangle = new Rectangle(0, 0, width, height); + Rectangle rectangle = new(0, 0, width, height); int actualNumberOfSteps = 0; @@ -286,7 +286,7 @@ void RowAction(RowInterval rows, Span buffer) Assert.Equal(expected, step); } - var operation = new TestRowIntervalOperation(RowAction); + TestRowIntervalOperation operation = new(RowAction); ParallelRowIterator.IterateRowIntervals, Vector4>( rectangle, @@ -297,7 +297,7 @@ void RowAction(RowInterval rows, Span buffer) } public static readonly TheoryData IterateRectangularBuffer_Data = - new TheoryData + new() { { 8, 582, 453, 10, 10, 291, 226 }, // boundary data from DetectEdgesTest.DetectEdges_InBox { 2, 582, 453, 10, 10, 291, 226 }, @@ -322,13 +322,13 @@ public void IterateRectangularBuffer( using (Buffer2D expected = memoryAllocator.Allocate2D(bufferWidth, bufferHeight, AllocationOptions.Clean)) using (Buffer2D actual = memoryAllocator.Allocate2D(bufferWidth, bufferHeight, AllocationOptions.Clean)) { - var rect = new Rectangle(rectX, rectY, rectWidth, rectHeight); + Rectangle rect = new(rectX, rectY, rectWidth, rectHeight); void FillRow(int y, Buffer2D buffer) { for (int x = rect.Left; x < rect.Right; x++) { - buffer[x, y] = new Point(x, y); + buffer[x, y] = new(x, y); } } @@ -339,7 +339,7 @@ void FillRow(int y, Buffer2D buffer) } // Fill actual data using IterateRows: - var settings = new ParallelExecutionSettings(maxDegreeOfParallelism, memoryAllocator); + ParallelExecutionSettings settings = new(maxDegreeOfParallelism, memoryAllocator); void RowAction(RowInterval rows) { @@ -350,7 +350,7 @@ void RowAction(RowInterval rows) } } - var operation = new TestRowIntervalOperation(RowAction); + TestRowIntervalOperation operation = new(RowAction); ParallelRowIterator.IterateRowIntervals( rect, @@ -369,15 +369,15 @@ void RowAction(RowInterval rows) [InlineData(10, -10)] public void IterateRowsRequiresValidRectangle(int width, int height) { - var parallelSettings = default(ParallelExecutionSettings); + ParallelExecutionSettings parallelSettings = default(ParallelExecutionSettings); - var rect = new Rectangle(0, 0, width, height); + Rectangle rect = new(0, 0, width, height); void RowAction(RowInterval rows) { } - var operation = new TestRowIntervalOperation(RowAction); + TestRowIntervalOperation operation = new(RowAction); ArgumentOutOfRangeException ex = Assert.Throws( () => ParallelRowIterator.IterateRowIntervals(rect, in parallelSettings, in operation)); @@ -392,15 +392,15 @@ void RowAction(RowInterval rows) [InlineData(10, -10)] public void IterateRowsWithTempBufferRequiresValidRectangle(int width, int height) { - var parallelSettings = default(ParallelExecutionSettings); + ParallelExecutionSettings parallelSettings = default(ParallelExecutionSettings); - var rect = new Rectangle(0, 0, width, height); + Rectangle rect = new(0, 0, width, height); void RowAction(RowInterval rows, Span memory) { } - var operation = new TestRowIntervalOperation(RowAction); + TestRowIntervalOperation operation = new(RowAction); ArgumentOutOfRangeException ex = Assert.Throws( () => ParallelRowIterator.IterateRowIntervals, Rgba32>(rect, in parallelSettings, in operation)); @@ -434,7 +434,7 @@ public TestRowOperation() { } - public StrongBox MaxY { get; } = new StrongBox(); + public StrongBox MaxY { get; } = new(); public void Invoke(int y) { diff --git a/tests/ImageSharp.Tests/Helpers/RowIntervalTests.cs b/tests/ImageSharp.Tests/Helpers/RowIntervalTests.cs index 95f1d4e289..215cd58bcf 100644 --- a/tests/ImageSharp.Tests/Helpers/RowIntervalTests.cs +++ b/tests/ImageSharp.Tests/Helpers/RowIntervalTests.cs @@ -10,7 +10,7 @@ public class RowIntervalTests [Fact] public void Slice1() { - var rowInterval = new RowInterval(10, 20); + RowInterval rowInterval = new(10, 20); RowInterval sliced = rowInterval.Slice(5); Assert.Equal(15, sliced.Min); @@ -20,7 +20,7 @@ public void Slice1() [Fact] public void Slice2() { - var rowInterval = new RowInterval(10, 20); + RowInterval rowInterval = new(10, 20); RowInterval sliced = rowInterval.Slice(3, 5); Assert.Equal(13, sliced.Min); @@ -30,8 +30,8 @@ public void Slice2() [Fact] public void Equality_WhenTrue() { - var a = new RowInterval(42, 123); - var b = new RowInterval(42, 123); + RowInterval a = new(42, 123); + RowInterval b = new(42, 123); Assert.True(a.Equals(b)); Assert.True(a.Equals((object)b)); @@ -42,9 +42,9 @@ public void Equality_WhenTrue() [Fact] public void Equality_WhenFalse() { - var a = new RowInterval(42, 123); - var b = new RowInterval(42, 125); - var c = new RowInterval(40, 123); + RowInterval a = new(42, 123); + RowInterval b = new(42, 125); + RowInterval c = new(40, 123); Assert.False(a.Equals(b)); Assert.False(c.Equals(a)); diff --git a/tests/ImageSharp.Tests/Helpers/TolerantMathTests.cs b/tests/ImageSharp.Tests/Helpers/TolerantMathTests.cs index 64f79840ca..0cacbdc87a 100644 --- a/tests/ImageSharp.Tests/Helpers/TolerantMathTests.cs +++ b/tests/ImageSharp.Tests/Helpers/TolerantMathTests.cs @@ -7,7 +7,7 @@ namespace SixLabors.ImageSharp.Tests.Helpers; public class TolerantMathTests { - private readonly TolerantMath tolerantMath = new TolerantMath(0.1); + private readonly TolerantMath tolerantMath = new(0.1); [Theory] [InlineData(0)] diff --git a/tests/ImageSharp.Tests/IO/ChunkedMemoryStreamTests.cs b/tests/ImageSharp.Tests/IO/ChunkedMemoryStreamTests.cs index 1803cfddb9..86e5c00845 100644 --- a/tests/ImageSharp.Tests/IO/ChunkedMemoryStreamTests.cs +++ b/tests/ImageSharp.Tests/IO/ChunkedMemoryStreamTests.cs @@ -30,7 +30,7 @@ public class ChunkedMemoryStreamTests [Fact] public void MemoryStream_GetPositionTest_Negative() { - using var ms = new ChunkedMemoryStream(this.allocator); + using ChunkedMemoryStream ms = new(this.allocator); long iCurrentPos = ms.Position; for (int i = -1; i > -6; i--) { @@ -42,17 +42,17 @@ public void MemoryStream_GetPositionTest_Negative() [Fact] public void MemoryStream_ReadTest_Negative() { - var ms2 = new ChunkedMemoryStream(this.allocator); + ChunkedMemoryStream ms2 = new(this.allocator); Assert.Throws(() => ms2.Read(null, 0, 0)); - Assert.Throws(() => ms2.Read(new byte[] { 1 }, -1, 0)); - Assert.Throws(() => ms2.Read(new byte[] { 1 }, 0, -1)); - Assert.Throws(() => ms2.Read(new byte[] { 1 }, 2, 0)); - Assert.Throws(() => ms2.Read(new byte[] { 1 }, 0, 2)); + Assert.Throws(() => ms2.Read([1], -1, 0)); + Assert.Throws(() => ms2.Read([1], 0, -1)); + Assert.Throws(() => ms2.Read([1], 2, 0)); + Assert.Throws(() => ms2.Read([1], 0, 2)); ms2.Dispose(); - Assert.Throws(() => ms2.Read(new byte[] { 1 }, 0, 1)); + Assert.Throws(() => ms2.Read([1], 0, 1)); } [Theory] @@ -64,7 +64,7 @@ public void MemoryStream_ReadTest_Negative() public void MemoryStream_ReadByteTest(int length) { using MemoryStream ms = this.CreateTestStream(length); - using var cms = new ChunkedMemoryStream(this.allocator); + using ChunkedMemoryStream cms = new(this.allocator); ms.CopyTo(cms); cms.Position = 0; @@ -85,7 +85,7 @@ public void MemoryStream_ReadByteTest(int length) public void MemoryStream_ReadByteBufferTest(int length) { using MemoryStream ms = this.CreateTestStream(length); - using var cms = new ChunkedMemoryStream(this.allocator); + using ChunkedMemoryStream cms = new(this.allocator); ms.CopyTo(cms); cms.Position = 0; @@ -108,7 +108,7 @@ public void MemoryStream_ReadByteBufferTest(int length) public void MemoryStream_ReadByteBufferSpanTest(int length) { using MemoryStream ms = this.CreateTestStream(length); - using var cms = new ChunkedMemoryStream(this.allocator); + using ChunkedMemoryStream cms = new(this.allocator); ms.CopyTo(cms); cms.Position = 0; @@ -125,15 +125,15 @@ public void MemoryStream_ReadByteBufferSpanTest(int length) [Fact] public void MemoryStream_WriteToTests() { - using (var ms2 = new ChunkedMemoryStream(this.allocator)) + using (ChunkedMemoryStream ms2 = new(this.allocator)) { byte[] bytArrRet; - byte[] bytArr = new byte[] { byte.MinValue, byte.MaxValue, 1, 2, 3, 4, 5, 6, 128, 250 }; + byte[] bytArr = [byte.MinValue, byte.MaxValue, 1, 2, 3, 4, 5, 6, 128, 250]; // [] Write to memoryStream, check the memoryStream ms2.Write(bytArr, 0, bytArr.Length); - using var readonlyStream = new ChunkedMemoryStream(this.allocator); + using ChunkedMemoryStream readonlyStream = new(this.allocator); ms2.WriteTo(readonlyStream); readonlyStream.Flush(); readonlyStream.Position = 0; @@ -146,11 +146,11 @@ public void MemoryStream_WriteToTests() } // [] Write to memoryStream, check the memoryStream - using (var ms2 = new ChunkedMemoryStream(this.allocator)) - using (var ms3 = new ChunkedMemoryStream(this.allocator)) + using (ChunkedMemoryStream ms2 = new(this.allocator)) + using (ChunkedMemoryStream ms3 = new(this.allocator)) { byte[] bytArrRet; - byte[] bytArr = new byte[] { byte.MinValue, byte.MaxValue, 1, 2, 3, 4, 5, 6, 128, 250 }; + byte[] bytArr = [byte.MinValue, byte.MaxValue, 1, 2, 3, 4, 5, 6, 128, 250]; ms2.Write(bytArr, 0, bytArr.Length); ms2.WriteTo(ms3); @@ -167,7 +167,7 @@ public void MemoryStream_WriteToTests() [Fact] public void MemoryStream_WriteToSpanTests() { - using (var ms2 = new ChunkedMemoryStream(this.allocator)) + using (ChunkedMemoryStream ms2 = new(this.allocator)) { Span bytArrRet; Span bytArr = new byte[] { byte.MinValue, byte.MaxValue, 1, 2, 3, 4, 5, 6, 128, 250 }; @@ -175,7 +175,7 @@ public void MemoryStream_WriteToSpanTests() // [] Write to memoryStream, check the memoryStream ms2.Write(bytArr, 0, bytArr.Length); - using var readonlyStream = new ChunkedMemoryStream(this.allocator); + using ChunkedMemoryStream readonlyStream = new(this.allocator); ms2.WriteTo(readonlyStream); readonlyStream.Flush(); readonlyStream.Position = 0; @@ -188,8 +188,8 @@ public void MemoryStream_WriteToSpanTests() } // [] Write to memoryStream, check the memoryStream - using (var ms2 = new ChunkedMemoryStream(this.allocator)) - using (var ms3 = new ChunkedMemoryStream(this.allocator)) + using (ChunkedMemoryStream ms2 = new(this.allocator)) + using (ChunkedMemoryStream ms3 = new(this.allocator)) { Span bytArrRet; Span bytArr = new byte[] { byte.MinValue, byte.MaxValue, 1, 2, 3, 4, 5, 6, 128, 250 }; @@ -209,17 +209,17 @@ public void MemoryStream_WriteToSpanTests() [Fact] public void MemoryStream_WriteByteTests() { - using (var ms2 = new ChunkedMemoryStream(this.allocator)) + using (ChunkedMemoryStream ms2 = new(this.allocator)) { byte[] bytArrRet; - byte[] bytArr = new byte[] { byte.MinValue, byte.MaxValue, 1, 2, 3, 4, 5, 6, 128, 250 }; + byte[] bytArr = [byte.MinValue, byte.MaxValue, 1, 2, 3, 4, 5, 6, 128, 250]; for (int i = 0; i < bytArr.Length; i++) { ms2.WriteByte(bytArr[i]); } - using var readonlyStream = new ChunkedMemoryStream(this.allocator); + using ChunkedMemoryStream readonlyStream = new(this.allocator); ms2.WriteTo(readonlyStream); readonlyStream.Flush(); readonlyStream.Position = 0; @@ -235,11 +235,11 @@ public void MemoryStream_WriteByteTests() [Fact] public void MemoryStream_WriteToTests_Negative() { - using var ms2 = new ChunkedMemoryStream(this.allocator); + using ChunkedMemoryStream ms2 = new(this.allocator); Assert.Throws(() => ms2.WriteTo(null)); - ms2.Write(new byte[] { 1 }, 0, 1); - var readonlyStream = new MemoryStream(new byte[1028], false); + ms2.Write([1], 0, 1); + MemoryStream readonlyStream = new(new byte[1028], false); Assert.Throws(() => ms2.WriteTo(readonlyStream)); readonlyStream.Dispose(); @@ -253,7 +253,7 @@ public void MemoryStream_CopyTo_Invalid() { ChunkedMemoryStream memoryStream; const string bufferSize = nameof(bufferSize); - using (memoryStream = new ChunkedMemoryStream(this.allocator)) + using (memoryStream = new(this.allocator)) { const string destination = nameof(destination); Assert.Throws(destination, () => memoryStream.CopyTo(destination: null)); @@ -277,7 +277,7 @@ public void MemoryStream_CopyTo_Invalid() Assert.Throws(() => memoryStream.CopyTo(disposedStream, 1)); // Then for the destination being disposed. - memoryStream = new ChunkedMemoryStream(this.allocator); + memoryStream = new(this.allocator); Assert.Throws(() => memoryStream.CopyTo(disposedStream, 1)); memoryStream.Dispose(); } @@ -286,7 +286,7 @@ public void MemoryStream_CopyTo_Invalid() [MemberData(nameof(CopyToData))] public void CopyTo(Stream source, byte[] expected) { - using var destination = new ChunkedMemoryStream(this.allocator); + using ChunkedMemoryStream destination = new(this.allocator); source.CopyTo(destination); Assert.InRange(source.Position, source.Length, int.MaxValue); // Copying the data should have read to the end of the stream or stayed past the end. Assert.Equal(expected, destination.ToArray()); @@ -297,7 +297,7 @@ public static IEnumerable GetAllTestImages() IEnumerable allImageFiles = Directory.EnumerateFiles(TestEnvironment.InputImagesDirectoryFullPath, "*.*", SearchOption.AllDirectories) .Where(s => !s.EndsWith("txt", StringComparison.OrdinalIgnoreCase)); - var result = new List(); + List result = []; foreach (string path in allImageFiles) { result.Add(path.Substring(TestEnvironment.InputImagesDirectoryFullPath.Length)); @@ -334,9 +334,9 @@ public void DecoderIntegrationTest(TestImageProvider provider) ((TestImageProvider.FileProvider)provider).FilePath); using FileStream fs = File.OpenRead(fullPath); - using var nonSeekableStream = new NonSeekableStream(fs); + using NonSeekableStream nonSeekableStream = new(fs); - var actual = Image.Load(nonSeekableStream); + Image actual = Image.Load(nonSeekableStream); ImageComparer.Exact.VerifySimilarity(expected, actual); } @@ -344,30 +344,30 @@ public void DecoderIntegrationTest(TestImageProvider provider) public static IEnumerable CopyToData() { // Stream is positioned @ beginning of data - byte[] data1 = new byte[] { 1, 2, 3 }; - var stream1 = new MemoryStream(data1); + byte[] data1 = [1, 2, 3]; + MemoryStream stream1 = new(data1); - yield return new object[] { stream1, data1 }; + yield return [stream1, data1]; // Stream is positioned in the middle of data - byte[] data2 = new byte[] { 0xff, 0xf3, 0xf0 }; - var stream2 = new MemoryStream(data2) { Position = 1 }; + byte[] data2 = [0xff, 0xf3, 0xf0]; + MemoryStream stream2 = new(data2) { Position = 1 }; - yield return new object[] { stream2, new byte[] { 0xf3, 0xf0 } }; + yield return [stream2, new byte[] { 0xf3, 0xf0 }]; // Stream is positioned after end of data byte[] data3 = data2; - var stream3 = new MemoryStream(data3) { Position = data3.Length + 1 }; + MemoryStream stream3 = new(data3) { Position = data3.Length + 1 }; - yield return new object[] { stream3, Array.Empty() }; + yield return [stream3, Array.Empty()]; } private MemoryStream CreateTestStream(int length) { byte[] buffer = new byte[length]; - var random = new Random(); + Random random = new(); random.NextBytes(buffer); - return new MemoryStream(buffer); + return new(buffer); } } diff --git a/tests/ImageSharp.Tests/Image/ImageCloneTests.cs b/tests/ImageSharp.Tests/Image/ImageCloneTests.cs index 25674e6a8d..0680c9a823 100644 --- a/tests/ImageSharp.Tests/Image/ImageCloneTests.cs +++ b/tests/ImageSharp.Tests/Image/ImageCloneTests.cs @@ -10,7 +10,7 @@ public class ImageCloneTests [Fact] public void CloneAs_WhenDisposed_Throws() { - var image = new Image(5, 5); + Image image = new(5, 5); image.Dispose(); Assert.Throws(() => image.CloneAs()); @@ -19,7 +19,7 @@ public void CloneAs_WhenDisposed_Throws() [Fact] public void Clone_WhenDisposed_Throws() { - var image = new Image(5, 5); + Image image = new(5, 5); image.Dispose(); Assert.Throws(() => image.Clone()); diff --git a/tests/ImageSharp.Tests/Image/ImageFrameCollectionTests.Generic.cs b/tests/ImageSharp.Tests/Image/ImageFrameCollectionTests.Generic.cs index 71c9e07fc3..d7f2c7d28e 100644 --- a/tests/ImageSharp.Tests/Image/ImageFrameCollectionTests.Generic.cs +++ b/tests/ImageSharp.Tests/Image/ImageFrameCollectionTests.Generic.cs @@ -102,7 +102,7 @@ public void Constructor_FramesMustHaveSameSize() using ImageFrame imageFrame2 = new(Configuration.Default, 1, 1); new ImageFrameCollection( this.Image, - new[] { imageFrame1, imageFrame2 }); + [imageFrame1, imageFrame2]); }); Assert.StartsWith("Frame must have the same dimensions as the image.", ex.Message); @@ -114,7 +114,7 @@ public void RemoveAtFrame_ThrowIfRemovingLastFrame() using ImageFrame imageFrame = new(Configuration.Default, 10, 10); ImageFrameCollection collection = new( this.Image, - new[] { imageFrame }); + [imageFrame]); InvalidOperationException ex = Assert.Throws( () => collection.RemoveFrame(0)); @@ -128,7 +128,7 @@ public void RemoveAtFrame_CanRemoveFrameZeroIfMultipleFramesExist() using ImageFrame imageFrame2 = new(Configuration.Default, 10, 10); ImageFrameCollection collection = new( this.Image, - new[] { imageFrame1, imageFrame2 }); + [imageFrame1, imageFrame2]); collection.RemoveFrame(0); Assert.Equal(1, collection.Count); @@ -141,7 +141,7 @@ public void RootFrameIsFrameAtIndexZero() using ImageFrame imageFrame2 = new(Configuration.Default, 10, 10); ImageFrameCollection collection = new( this.Image, - new[] { imageFrame1, imageFrame2 }); + [imageFrame1, imageFrame2]); Assert.Equal(collection.RootFrame, collection[0]); } @@ -153,7 +153,7 @@ public void ConstructorPopulatesFrames() using ImageFrame imageFrame2 = new(Configuration.Default, 10, 10); ImageFrameCollection collection = new( this.Image, - new[] { imageFrame1, imageFrame2 }); + [imageFrame1, imageFrame2]); Assert.Equal(2, collection.Count); } @@ -165,7 +165,7 @@ public void DisposeClearsCollection() using ImageFrame imageFrame2 = new(Configuration.Default, 10, 10); ImageFrameCollection collection = new( this.Image, - new[] { imageFrame1, imageFrame2 }); + [imageFrame1, imageFrame2]); collection.Dispose(); @@ -179,7 +179,7 @@ public void Dispose_DisposesAllInnerFrames() using ImageFrame imageFrame2 = new(Configuration.Default, 10, 10); ImageFrameCollection collection = new( this.Image, - new[] { imageFrame1, imageFrame2 }); + [imageFrame1, imageFrame2]); IPixelSource[] framesSnapShot = collection.OfType>().ToArray(); diff --git a/tests/ImageSharp.Tests/Image/ImageFrameCollectionTests.NonGeneric.cs b/tests/ImageSharp.Tests/Image/ImageFrameCollectionTests.NonGeneric.cs index f70623f515..cd1213c230 100644 --- a/tests/ImageSharp.Tests/Image/ImageFrameCollectionTests.NonGeneric.cs +++ b/tests/ImageSharp.Tests/Image/ImageFrameCollectionTests.NonGeneric.cs @@ -247,7 +247,7 @@ public void PublicMethods_ThrowIfDisposed() { Image image = new(Configuration.Default, 10, 10); ImageFrameCollection frameCollection = image.Frames; - Rgba32[] rgba32Array = Array.Empty(); + Rgba32[] rgba32Array = []; image.Dispose(); // this should invalidate underlying collection as well diff --git a/tests/ImageSharp.Tests/Image/ImageFrameCollectionTests.cs b/tests/ImageSharp.Tests/Image/ImageFrameCollectionTests.cs index 14c38d1f70..c3ed16dcd2 100644 --- a/tests/ImageSharp.Tests/Image/ImageFrameCollectionTests.cs +++ b/tests/ImageSharp.Tests/Image/ImageFrameCollectionTests.cs @@ -14,10 +14,10 @@ public abstract partial class ImageFrameCollectionTests : IDisposable public ImageFrameCollectionTests() { // Needed to get English exception messages, which are checked in several tests. - System.Threading.Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo("en-US"); + System.Threading.Thread.CurrentThread.CurrentUICulture = new("en-US"); - this.Image = new Image(10, 10); - this.Collection = new ImageFrameCollection(this.Image, 10, 10, default(Rgba32)); + this.Image = new(10, 10); + this.Collection = new(this.Image, 10, 10, default(Rgba32)); } public void Dispose() diff --git a/tests/ImageSharp.Tests/Image/ImageFrameTests.cs b/tests/ImageSharp.Tests/Image/ImageFrameTests.cs index e09ef487a8..05610d8ca1 100644 --- a/tests/ImageSharp.Tests/Image/ImageFrameTests.cs +++ b/tests/ImageSharp.Tests/Image/ImageFrameTests.cs @@ -16,7 +16,7 @@ public class Indexer private void LimitBufferCapacity(int bufferCapacityInBytes) { - var allocator = new TestMemoryAllocator(); + TestMemoryAllocator allocator = new(); allocator.BufferCapacityInBytes = bufferCapacityInBytes; this.configuration.MemoryAllocator = allocator; } @@ -31,7 +31,7 @@ public void GetSet(bool enforceDisco) this.LimitBufferCapacity(100); } - using var image = new Image(this.configuration, 10, 10); + using Image image = new(this.configuration, 10, 10); ImageFrame frame = image.Frames.RootFrame; Rgba32 val = frame[3, 4]; Assert.Equal(default(Rgba32), val); @@ -40,7 +40,7 @@ public void GetSet(bool enforceDisco) Assert.Equal(Color.Red.ToPixel(), val); } - public static TheoryData OutOfRangeData = new TheoryData() + public static TheoryData OutOfRangeData = new() { { false, -1 }, { false, 10 }, @@ -57,7 +57,7 @@ public void Get_OutOfRangeX(bool enforceDisco, int x) this.LimitBufferCapacity(100); } - using var image = new Image(this.configuration, 10, 10); + using Image image = new(this.configuration, 10, 10); ImageFrame frame = image.Frames.RootFrame; ArgumentOutOfRangeException ex = Assert.Throws(() => _ = frame[x, 3]); Assert.Equal("x", ex.ParamName); @@ -72,7 +72,7 @@ public void Set_OutOfRangeX(bool enforceDisco, int x) this.LimitBufferCapacity(100); } - using var image = new Image(this.configuration, 10, 10); + using Image image = new(this.configuration, 10, 10); ImageFrame frame = image.Frames.RootFrame; ArgumentOutOfRangeException ex = Assert.Throws(() => frame[x, 3] = default); Assert.Equal("x", ex.ParamName); @@ -87,7 +87,7 @@ public void Set_OutOfRangeY(bool enforceDisco, int y) this.LimitBufferCapacity(100); } - using var image = new Image(this.configuration, 10, 10); + using Image image = new(this.configuration, 10, 10); ImageFrame frame = image.Frames.RootFrame; ArgumentOutOfRangeException ex = Assert.Throws(() => frame[3, y] = default); Assert.Equal("y", ex.ParamName); @@ -105,7 +105,7 @@ public void CopyPixelDataTo_Success(bool disco, bool byteSpan) this.LimitBufferCapacity(20); } - using var image = new Image(this.configuration, 10, 10); + using Image image = new(this.configuration, 10, 10); if (disco) { Assert.True(image.GetPixelMemoryGroup().Count > 1); @@ -131,7 +131,7 @@ public void CopyPixelDataTo_Success(bool disco, bool byteSpan) [InlineData(true)] public void CopyPixelDataTo_DestinationTooShort_Throws(bool byteSpan) { - using var image = new Image(this.configuration, 10, 10); + using Image image = new(this.configuration, 10, 10); Assert.ThrowsAny(() => { @@ -173,7 +173,7 @@ protected override void ProcessPixelRowsImpl( [Fact] public void NullReference_Throws() { - using var img = new Image(1, 1); + using Image img = new(1, 1); ImageFrame frame = img.Frames.RootFrame; Assert.Throws(() => frame.ProcessPixelRows(null)); diff --git a/tests/ImageSharp.Tests/Image/ImageRotationTests.cs b/tests/ImageSharp.Tests/Image/ImageRotationTests.cs index e7d3b548bc..e9bdd5128b 100644 --- a/tests/ImageSharp.Tests/Image/ImageRotationTests.cs +++ b/tests/ImageSharp.Tests/Image/ImageRotationTests.cs @@ -12,14 +12,14 @@ public class ImageRotationTests public void RotateImageByMinus90Degrees() { (Size original, Size rotated) = Rotate(-90); - Assert.Equal(new Size(original.Height, original.Width), rotated); + Assert.Equal(new(original.Height, original.Width), rotated); } [Fact] public void RotateImageBy90Degrees() { (Size original, Size rotated) = Rotate(90); - Assert.Equal(new Size(original.Height, original.Width), rotated); + Assert.Equal(new(original.Height, original.Width), rotated); } [Fact] @@ -33,7 +33,7 @@ public void RotateImageBy180Degrees() public void RotateImageBy270Degrees() { (Size original, Size rotated) = Rotate(270); - Assert.Equal(new Size(original.Height, original.Width), rotated); + Assert.Equal(new(original.Height, original.Width), rotated); } [Fact] diff --git a/tests/ImageSharp.Tests/Image/ImageSaveTests.cs b/tests/ImageSharp.Tests/Image/ImageSaveTests.cs index f9c01ab564..173772a21c 100644 --- a/tests/ImageSharp.Tests/Image/ImageSaveTests.cs +++ b/tests/ImageSharp.Tests/Image/ImageSaveTests.cs @@ -23,22 +23,22 @@ public class ImageSaveTests : IDisposable public ImageSaveTests() { - this.localImageFormat = new Mock(); - this.localImageFormat.Setup(x => x.FileExtensions).Returns(new[] { "png" }); + this.localImageFormat = new(); + this.localImageFormat.Setup(x => x.FileExtensions).Returns(["png"]); this.localMimeTypeDetector = new MockImageFormatDetector(this.localImageFormat.Object); - this.encoder = new Mock(); + this.encoder = new(); - this.encoderNotInFormat = new Mock(); + this.encoderNotInFormat = new(); - this.fileSystem = new Mock(); - var config = new Configuration + this.fileSystem = new(); + Configuration config = new() { FileSystem = this.fileSystem.Object }; config.ImageFormatsManager.AddImageFormatDetector(this.localMimeTypeDetector); config.ImageFormatsManager.SetEncoder(this.localImageFormat.Object, this.encoder.Object); - this.image = new Image(config, 1, 1); + this.image = new(config, 1, 1); } [Fact] diff --git a/tests/ImageSharp.Tests/Image/ImageTests.Decode_Cancellation.cs b/tests/ImageSharp.Tests/Image/ImageTests.Decode_Cancellation.cs index d8d9f4fe2a..ac52d1d667 100644 --- a/tests/ImageSharp.Tests/Image/ImageTests.Decode_Cancellation.cs +++ b/tests/ImageSharp.Tests/Image/ImageTests.Decode_Cancellation.cs @@ -12,9 +12,9 @@ public class Decode_Cancellation : ImageLoadTestBase { public Decode_Cancellation() => this.TopLevelConfiguration.StreamProcessingBufferSize = 128; - public static readonly string[] TestFileForEachCodec = new[] - { - TestImages.Jpeg.Baseline.Snake, + public static readonly string[] TestFileForEachCodec = + [ + TestImages.Jpeg.Baseline.Snake // TODO: Figure out Unix cancellation failures, and validate cancellation for each decoder. //TestImages.Bmp.Car, @@ -24,7 +24,7 @@ public class Decode_Cancellation : ImageLoadTestBase //TestImages.Tga.Bit32BottomRight, //TestImages.Webp.Lossless.WithExif, //TestImages.Pbm.GrayscaleBinaryWide - }; + ]; public static object[][] IdentifyData { get; } = TestFileForEachCodec.Select(f => new object[] { f }).ToArray(); @@ -39,7 +39,7 @@ public async Task IdentifyAsync_PreCancelled(string file) private static TheoryData CreateLoadData() { - double[] percentages = new[] { 0, 0.3, 0.7 }; + double[] percentages = [0, 0.3, 0.7]; TheoryData data = new(); diff --git a/tests/ImageSharp.Tests/Image/ImageTests.Identify.cs b/tests/ImageSharp.Tests/Image/ImageTests.Identify.cs index 7f6651d909..640d34fe19 100644 --- a/tests/ImageSharp.Tests/Image/ImageTests.Identify.cs +++ b/tests/ImageSharp.Tests/Image/ImageTests.Identify.cs @@ -141,9 +141,8 @@ public void FromStream_ZeroLength_Throws_UnknownImageFormatException() { // https://github.com/SixLabors/ImageSharp/issues/1903 using ZipArchive zipFile = new(new MemoryStream( - new byte[] - { - 0x50, 0x4B, 0x03, 0x04, 0x0A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x77, 0xAF, 0x94, 0x53, 0x00, 0x00, + [ + 0x50, 0x4B, 0x03, 0x04, 0x0A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x77, 0xAF, 0x94, 0x53, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x6D, 0x79, 0x73, 0x74, 0x65, 0x72, 0x79, 0x50, 0x4B, 0x01, 0x02, 0x3F, 0x00, 0x0A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x77, 0xAF, 0x94, 0x53, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, @@ -153,7 +152,7 @@ public void FromStream_ZeroLength_Throws_UnknownImageFormatException() 0xF9, 0x91, 0x27, 0xF6, 0xD7, 0x01, 0x55, 0xA1, 0xF9, 0x91, 0x27, 0xF6, 0xD7, 0x01, 0x50, 0x4B, 0x05, 0x06, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 0x59, 0x00, 0x00, 0x00, 0x25, 0x00, 0x00, 0x00, 0x00, 0x00 - })); + ])); using Stream stream = zipFile.Entries[0].Open(); Assert.Throws(() => Image.Identify(stream)); @@ -210,9 +209,8 @@ public async Task FromStreamAsync_ZeroLength_Throws_UnknownImageFormatException( { // https://github.com/SixLabors/ImageSharp/issues/1903 using ZipArchive zipFile = new(new MemoryStream( - new byte[] - { - 0x50, 0x4B, 0x03, 0x04, 0x0A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x77, 0xAF, 0x94, 0x53, 0x00, 0x00, + [ + 0x50, 0x4B, 0x03, 0x04, 0x0A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x77, 0xAF, 0x94, 0x53, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x6D, 0x79, 0x73, 0x74, 0x65, 0x72, 0x79, 0x50, 0x4B, 0x01, 0x02, 0x3F, 0x00, 0x0A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x77, 0xAF, 0x94, 0x53, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, @@ -222,7 +220,7 @@ public async Task FromStreamAsync_ZeroLength_Throws_UnknownImageFormatException( 0xF9, 0x91, 0x27, 0xF6, 0xD7, 0x01, 0x55, 0xA1, 0xF9, 0x91, 0x27, 0xF6, 0xD7, 0x01, 0x50, 0x4B, 0x05, 0x06, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 0x59, 0x00, 0x00, 0x00, 0x25, 0x00, 0x00, 0x00, 0x00, 0x00 - })); + ])); using Stream stream = zipFile.Entries[0].Open(); await Assert.ThrowsAsync(async () => await Image.IdentifyAsync(stream)); diff --git a/tests/ImageSharp.Tests/Image/ImageTests.ImageLoadTestBase.cs b/tests/ImageSharp.Tests/Image/ImageTests.ImageLoadTestBase.cs index 51e2a01a28..ae48fde397 100644 --- a/tests/ImageSharp.Tests/Image/ImageTests.ImageLoadTestBase.cs +++ b/tests/ImageSharp.Tests/Image/ImageTests.ImageLoadTestBase.cs @@ -35,7 +35,7 @@ public abstract class ImageLoadTestBase : IDisposable public Configuration LocalConfiguration { get; } - public TestFormat TestFormat { get; } = new TestFormat(); + public TestFormat TestFormat { get; } = new(); /// /// Gets the top-level configuration in the context of this test case. @@ -56,13 +56,13 @@ public abstract class ImageLoadTestBase : IDisposable protected ImageLoadTestBase() { // TODO: Remove all this mocking. It's too complicated and we can now use fakes. - this.localStreamReturnImageRgba32 = new Image(1, 1); - this.localStreamReturnImageAgnostic = new Image(1, 1); - this.LocalImageInfo = new(new(1, 1), new ImageMetadata() { DecodedImageFormat = PngFormat.Instance }); + this.localStreamReturnImageRgba32 = new(1, 1); + this.localStreamReturnImageAgnostic = new(1, 1); + this.LocalImageInfo = new(new(1, 1), new() { DecodedImageFormat = PngFormat.Instance }); - this.localImageFormatMock = new Mock(); + this.localImageFormatMock = new(); - this.localDecoder = new Mock(); + this.localDecoder = new(); this.localDecoder.Setup(x => x.Identify(It.IsAny(), It.IsAny())) .Returns(this.LocalImageInfo); @@ -111,15 +111,15 @@ protected ImageLoadTestBase() this.localMimeTypeDetector = new MockImageFormatDetector(this.localImageFormatMock.Object); - this.LocalConfiguration = new Configuration(); + this.LocalConfiguration = new(); this.LocalConfiguration.ImageFormatsManager.AddImageFormatDetector(this.localMimeTypeDetector); this.LocalConfiguration.ImageFormatsManager.SetDecoder(this.localImageFormatMock.Object, this.localDecoder.Object); - this.TopLevelConfiguration = new Configuration(this.TestFormat); + this.TopLevelConfiguration = new(this.TestFormat); this.Marker = Guid.NewGuid().ToByteArray(); - this.dataStreamLazy = new Lazy(this.CreateStream); + this.dataStreamLazy = new(this.CreateStream); Stream StreamFactory() => this.DataStream; this.LocalFileSystemMock.Setup(x => x.OpenRead(this.MockFilePath)).Returns(StreamFactory); diff --git a/tests/ImageSharp.Tests/Image/ImageTests.LoadPixelData.cs b/tests/ImageSharp.Tests/Image/ImageTests.LoadPixelData.cs index 5762264d21..47ae0daf72 100644 --- a/tests/ImageSharp.Tests/Image/ImageTests.LoadPixelData.cs +++ b/tests/ImageSharp.Tests/Image/ImageTests.LoadPixelData.cs @@ -15,7 +15,8 @@ public class LoadPixelData [ValidateDisposedMemoryAllocations] public void FromPixels(bool useSpan) { - Rgba32[] data = { Color.Black.ToPixel(), Color.White.ToPixel(), Color.White.ToPixel(), Color.Black.ToPixel(), }; + Rgba32[] data = [Color.Black.ToPixel(), Color.White.ToPixel(), Color.White.ToPixel(), Color.Black.ToPixel() + ]; using Image img = useSpan ? Image.LoadPixelData(data.AsSpan(), 2, 2) @@ -34,12 +35,12 @@ public void FromPixels(bool useSpan) public void FromBytes(bool useSpan) { byte[] data = - { + [ 0, 0, 0, 255, // 0,0 255, 255, 255, 255, // 0,1 255, 255, 255, 255, // 1,0 - 0, 0, 0, 255, // 1,1 - }; + 0, 0, 0, 255 // 1,1 + ]; using Image img = useSpan ? Image.LoadPixelData(data.AsSpan(), 2, 2) diff --git a/tests/ImageSharp.Tests/Image/ImageTests.Load_FileSystemPath_UseDefaultConfiguration.cs b/tests/ImageSharp.Tests/Image/ImageTests.Load_FileSystemPath_UseDefaultConfiguration.cs index 3e488be9a3..8c110d143a 100644 --- a/tests/ImageSharp.Tests/Image/ImageTests.Load_FileSystemPath_UseDefaultConfiguration.cs +++ b/tests/ImageSharp.Tests/Image/ImageTests.Load_FileSystemPath_UseDefaultConfiguration.cs @@ -12,7 +12,7 @@ public class Load_FileSystemPath_UseDefaultConfiguration { private string Path { get; } = TestFile.GetInputFileFullPath(TestImages.Bmp.Bit8); - private static void VerifyDecodedImage(Image img) => Assert.Equal(new Size(127, 64), img.Size); + private static void VerifyDecodedImage(Image img) => Assert.Equal(new(127, 64), img.Size); [Fact] public void Path_Specific() diff --git a/tests/ImageSharp.Tests/Image/ImageTests.Load_FromBytes_UseGlobalConfiguration.cs b/tests/ImageSharp.Tests/Image/ImageTests.Load_FromBytes_UseGlobalConfiguration.cs index 00ec985ac2..80a407a35c 100644 --- a/tests/ImageSharp.Tests/Image/ImageTests.Load_FromBytes_UseGlobalConfiguration.cs +++ b/tests/ImageSharp.Tests/Image/ImageTests.Load_FromBytes_UseGlobalConfiguration.cs @@ -14,7 +14,7 @@ public class Load_FromBytes_UseGlobalConfiguration private static Span ByteSpan => new(ByteArray); - private static void VerifyDecodedImage(Image img) => Assert.Equal(new Size(127, 64), img.Size); + private static void VerifyDecodedImage(Image img) => Assert.Equal(new(127, 64), img.Size); [Fact] public void Bytes_Specific() diff --git a/tests/ImageSharp.Tests/Image/ImageTests.Load_FromStream_ThrowsRightException.cs b/tests/ImageSharp.Tests/Image/ImageTests.Load_FromStream_ThrowsRightException.cs index 9b9f968bb4..a064b64723 100644 --- a/tests/ImageSharp.Tests/Image/ImageTests.Load_FromStream_ThrowsRightException.cs +++ b/tests/ImageSharp.Tests/Image/ImageTests.Load_FromStream_ThrowsRightException.cs @@ -10,9 +10,9 @@ public partial class ImageTests { public class Load_FromStream_Throws : IDisposable { - private static readonly byte[] Data = new byte[] { 0x01 }; + private static readonly byte[] Data = [0x01]; - private MemoryStream Stream { get; } = new MemoryStream(Data); + private MemoryStream Stream { get; } = new(Data); [Fact] public void Image_Load_Throws_UnknownImageFormatException() diff --git a/tests/ImageSharp.Tests/Image/ImageTests.Load_FromStream_UseDefaultConfiguration.cs b/tests/ImageSharp.Tests/Image/ImageTests.Load_FromStream_UseDefaultConfiguration.cs index 7a5bd186b7..c16a50b437 100644 --- a/tests/ImageSharp.Tests/Image/ImageTests.Load_FromStream_UseDefaultConfiguration.cs +++ b/tests/ImageSharp.Tests/Image/ImageTests.Load_FromStream_UseDefaultConfiguration.cs @@ -21,12 +21,12 @@ public class Load_FromStream_UseDefaultConfiguration : IDisposable public Load_FromStream_UseDefaultConfiguration() { - this.BaseStream = new MemoryStream(Data); - this.Stream = new AsyncStreamWrapper(this.BaseStream, () => this.AllowSynchronousIO); + this.BaseStream = new(Data); + this.Stream = new(this.BaseStream, () => this.AllowSynchronousIO); } private static void VerifyDecodedImage(Image img) - => Assert.Equal(new Size(127, 64), img.Size); + => Assert.Equal(new(127, 64), img.Size); [Fact] public void Stream_Specific() diff --git a/tests/ImageSharp.Tests/Image/ImageTests.WrapMemory.cs b/tests/ImageSharp.Tests/Image/ImageTests.WrapMemory.cs index e3c4a7df18..d38ed749a3 100644 --- a/tests/ImageSharp.Tests/Image/ImageTests.WrapMemory.cs +++ b/tests/ImageSharp.Tests/Image/ImageTests.WrapMemory.cs @@ -39,7 +39,7 @@ public BitmapMemoryManager(Bitmap bitmap) } this.bitmap = bitmap; - var rectangle = new System.Drawing.Rectangle(0, 0, bitmap.Width, bitmap.Height); + System.Drawing.Rectangle rectangle = new(0, 0, bitmap.Width, bitmap.Height); this.bmpData = bitmap.LockBits(rectangle, ImageLockMode.ReadWrite, bitmap.PixelFormat); this.length = bitmap.Width * bitmap.Height; } @@ -64,13 +64,13 @@ protected override void Dispose(bool disposing) public override unsafe Span GetSpan() { void* ptr = (void*)this.bmpData.Scan0; - return new Span(ptr, this.length); + return new(ptr, this.length); } public override unsafe MemoryHandle Pin(int elementIndex = 0) { void* ptr = (void*)this.bmpData.Scan0; - return new MemoryHandle(ptr, pinnable: this); + return new(ptr, pinnable: this); } public override void Unpin() @@ -124,13 +124,13 @@ public override void Unpin() [Fact] public void WrapMemory_CreatedImageIsCorrect() { - var cfg = Configuration.CreateDefaultInstance(); - var metaData = new ImageMetadata(); + Configuration cfg = Configuration.CreateDefaultInstance(); + ImageMetadata metaData = new(); - var array = new Rgba32[25]; - var memory = new Memory(array); + Rgba32[] array = new Rgba32[25]; + Memory memory = new(array); - using (var image = Image.WrapMemory(cfg, memory, 5, 5, metaData)) + using (Image image = Image.WrapMemory(cfg, memory, 5, 5, metaData)) { Assert.True(image.DangerousTryGetSinglePixelMemory(out Memory imageMem)); ref Rgba32 pixel0 = ref imageMem.Span[0]; @@ -149,22 +149,22 @@ public void WrapSystemDrawingBitmap_WhenObserved() return; } - using (var bmp = new Bitmap(51, 23)) + using (Bitmap bmp = new(51, 23)) { - using (var memoryManager = new BitmapMemoryManager(bmp)) + using (BitmapMemoryManager memoryManager = new(bmp)) { Memory memory = memoryManager.Memory; Bgra32 bg = Color.Red.ToPixel(); Bgra32 fg = Color.Green.ToPixel(); - using (var image = Image.WrapMemory(memory, bmp.Width, bmp.Height)) + using (Image image = Image.WrapMemory(memory, bmp.Width, bmp.Height)) { Assert.Equal(memory, image.GetRootFramePixelBuffer().DangerousGetSingleMemory()); image.GetPixelMemoryGroup().Fill(bg); image.ProcessPixelRows(accessor => { - for (var i = 10; i < 20; i++) + for (int i = 10; i < 20; i++) { accessor.GetRowSpan(i).Slice(10, 10).Fill(fg); } @@ -195,19 +195,19 @@ public void WrapSystemDrawingBitmap_WhenOwned() return; } - using (var bmp = new Bitmap(51, 23)) + using (Bitmap bmp = new(51, 23)) { - var memoryManager = new BitmapMemoryManager(bmp); + BitmapMemoryManager memoryManager = new(bmp); Bgra32 bg = Color.Red.ToPixel(); Bgra32 fg = Color.Green.ToPixel(); - using (var image = Image.WrapMemory(memoryManager, bmp.Width, bmp.Height)) + using (Image image = Image.WrapMemory(memoryManager, bmp.Width, bmp.Height)) { Assert.Equal(memoryManager.Memory, image.GetRootFramePixelBuffer().DangerousGetSingleMemory()); image.GetPixelMemoryGroup().Fill(bg); image.ProcessPixelRows(accessor => { - for (var i = 10; i < 20; i++) + for (int i = 10; i < 20; i++) { accessor.GetRowSpan(i).Slice(10, 10).Fill(fg); } @@ -227,13 +227,13 @@ public void WrapSystemDrawingBitmap_WhenOwned() [Fact] public void WrapMemory_FromBytes_CreatedImageIsCorrect() { - var cfg = Configuration.CreateDefaultInstance(); - var metaData = new ImageMetadata(); + Configuration cfg = Configuration.CreateDefaultInstance(); + ImageMetadata metaData = new(); - var array = new byte[25 * Unsafe.SizeOf()]; - var memory = new Memory(array); + byte[] array = new byte[25 * Unsafe.SizeOf()]; + Memory memory = new(array); - using (var image = Image.WrapMemory(cfg, memory, 5, 5, metaData)) + using (Image image = Image.WrapMemory(cfg, memory, 5, 5, metaData)) { Assert.True(image.DangerousTryGetSinglePixelMemory(out Memory imageMem)); ref Rgba32 pixel0 = ref imageMem.Span[0]; @@ -252,16 +252,16 @@ public void WrapSystemDrawingBitmap_FromBytes_WhenObserved() return; } - using (var bmp = new Bitmap(51, 23)) + using (Bitmap bmp = new(51, 23)) { - using (var memoryManager = new BitmapMemoryManager(bmp)) + using (BitmapMemoryManager memoryManager = new(bmp)) { Memory pixelMemory = memoryManager.Memory; Memory byteMemory = new CastMemoryManager(pixelMemory).Memory; Bgra32 bg = Color.Red.ToPixel(); Bgra32 fg = Color.Green.ToPixel(); - using (var image = Image.WrapMemory(byteMemory, bmp.Width, bmp.Height)) + using (Image image = Image.WrapMemory(byteMemory, bmp.Width, bmp.Height)) { Span pixelSpan = pixelMemory.Span; Span imageSpan = image.GetRootFramePixelBuffer().DangerousGetSingleMemory().Span; @@ -276,7 +276,7 @@ public void WrapSystemDrawingBitmap_FromBytes_WhenObserved() image.GetPixelMemoryGroup().Fill(bg); image.ProcessPixelRows(accessor => { - for (var i = 10; i < 20; i++) + for (int i = 10; i < 20; i++) { accessor.GetRowSpan(i).Slice(10, 10).Fill(fg); } @@ -300,16 +300,16 @@ public void WrapSystemDrawingBitmap_FromBytes_WhenObserved() [InlineData(65536, 65537, 65536)] public unsafe void WrapMemory_Throws_OnTooLessWrongSize(int size, int width, int height) { - var cfg = Configuration.CreateDefaultInstance(); - var metaData = new ImageMetadata(); + Configuration cfg = Configuration.CreateDefaultInstance(); + ImageMetadata metaData = new(); - var array = new Rgba32[size]; + Rgba32[] array = new Rgba32[size]; Exception thrownException = null; fixed (void* ptr = array) { try { - using var image = Image.WrapMemory(cfg, ptr, size * sizeof(Rgba32), width, height, metaData); + using Image image = Image.WrapMemory(cfg, ptr, size * sizeof(Rgba32), width, height, metaData); } catch (Exception e) { @@ -328,14 +328,14 @@ public unsafe void WrapMemory_Throws_OnTooLessWrongSize(int size, int width, int [InlineData(2048, 32, 32)] public unsafe void WrapMemory_FromPointer_CreatedImageIsCorrect(int size, int width, int height) { - var cfg = Configuration.CreateDefaultInstance(); - var metaData = new ImageMetadata(); + Configuration cfg = Configuration.CreateDefaultInstance(); + ImageMetadata metaData = new(); - var array = new Rgba32[size]; + Rgba32[] array = new Rgba32[size]; fixed (void* ptr = array) { - using (var image = Image.WrapMemory(cfg, ptr, size * sizeof(Rgba32), width, height, metaData)) + using (Image image = Image.WrapMemory(cfg, ptr, size * sizeof(Rgba32), width, height, metaData)) { Assert.True(image.DangerousTryGetSinglePixelMemory(out Memory imageMem)); Span imageSpan = imageMem.Span; @@ -359,9 +359,9 @@ public unsafe void WrapSystemDrawingBitmap_FromPointer() return; } - using (var bmp = new Bitmap(51, 23)) + using (Bitmap bmp = new(51, 23)) { - using (var memoryManager = new BitmapMemoryManager(bmp)) + using (BitmapMemoryManager memoryManager = new(bmp)) { Memory pixelMemory = memoryManager.Memory; Bgra32 bg = Color.Red.ToPixel(); @@ -369,7 +369,7 @@ public unsafe void WrapSystemDrawingBitmap_FromPointer() fixed (void* p = pixelMemory.Span) { - using (var image = Image.WrapMemory(p, pixelMemory.Length, bmp.Width, bmp.Height)) + using (Image image = Image.WrapMemory(p, pixelMemory.Length, bmp.Width, bmp.Height)) { Span pixelSpan = pixelMemory.Span; Span imageSpan = image.GetRootFramePixelBuffer().DangerousGetSingleMemory().Span; @@ -381,7 +381,7 @@ public unsafe void WrapSystemDrawingBitmap_FromPointer() image.GetPixelMemoryGroup().Fill(bg); image.ProcessPixelRows(accessor => { - for (var i = 10; i < 20; i++) + for (int i = 10; i < 20; i++) { accessor.GetRowSpan(i).Slice(10, 10).Fill(fg); } @@ -407,8 +407,8 @@ public unsafe void WrapSystemDrawingBitmap_FromPointer() [InlineData(65536, 65537, 65536)] public void WrapMemory_MemoryOfT_InvalidSize(int size, int height, int width) { - var array = new Rgba32[size]; - var memory = new Memory(array); + Rgba32[] array = new Rgba32[size]; + Memory memory = new(array); Assert.Throws(() => Image.WrapMemory(memory, height, width)); } @@ -421,8 +421,8 @@ public void WrapMemory_MemoryOfT_InvalidSize(int size, int height, int width) [InlineData(2048, 32, 32)] public void WrapMemory_MemoryOfT_ValidSize(int size, int height, int width) { - var array = new Rgba32[size]; - var memory = new Memory(array); + Rgba32[] array = new Rgba32[size]; + Memory memory = new(array); Image.WrapMemory(memory, height, width); } @@ -443,8 +443,8 @@ private class TestMemoryOwner : IMemoryOwner [InlineData(65536, 65537, 65536)] public void WrapMemory_IMemoryOwnerOfT_InvalidSize(int size, int height, int width) { - var array = new Rgba32[size]; - var memory = new TestMemoryOwner { Memory = array }; + Rgba32[] array = new Rgba32[size]; + TestMemoryOwner memory = new() { Memory = array }; Assert.Throws(() => Image.WrapMemory(memory, height, width)); } @@ -457,10 +457,10 @@ public void WrapMemory_IMemoryOwnerOfT_InvalidSize(int size, int height, int wid [InlineData(2048, 32, 32)] public void WrapMemory_IMemoryOwnerOfT_ValidSize(int size, int height, int width) { - var array = new Rgba32[size]; - var memory = new TestMemoryOwner { Memory = array }; + Rgba32[] array = new Rgba32[size]; + TestMemoryOwner memory = new() { Memory = array }; - using (var img = Image.WrapMemory(memory, width, height)) + using (Image img = Image.WrapMemory(memory, width, height)) { Assert.Equal(width, img.Width); Assert.Equal(height, img.Height); @@ -469,7 +469,7 @@ public void WrapMemory_IMemoryOwnerOfT_ValidSize(int size, int height, int width { for (int i = 0; i < height; ++i) { - var arrayIndex = width * i; + int arrayIndex = width * i; Span rowSpan = accessor.GetRowSpan(i); ref Rgba32 r0 = ref rowSpan[0]; @@ -490,8 +490,8 @@ public void WrapMemory_IMemoryOwnerOfT_ValidSize(int size, int height, int width [InlineData(65536, 65537, 65536)] public void WrapMemory_IMemoryOwnerOfByte_InvalidSize(int size, int height, int width) { - var array = new byte[size * Unsafe.SizeOf()]; - var memory = new TestMemoryOwner { Memory = array }; + byte[] array = new byte[size * Unsafe.SizeOf()]; + TestMemoryOwner memory = new() { Memory = array }; Assert.Throws(() => Image.WrapMemory(memory, height, width)); } @@ -504,11 +504,11 @@ public void WrapMemory_IMemoryOwnerOfByte_InvalidSize(int size, int height, int [InlineData(2048, 32, 32)] public void WrapMemory_IMemoryOwnerOfByte_ValidSize(int size, int height, int width) { - var pixelSize = Unsafe.SizeOf(); - var array = new byte[size * pixelSize]; - var memory = new TestMemoryOwner { Memory = array }; + int pixelSize = Unsafe.SizeOf(); + byte[] array = new byte[size * pixelSize]; + TestMemoryOwner memory = new() { Memory = array }; - using (var img = Image.WrapMemory(memory, width, height)) + using (Image img = Image.WrapMemory(memory, width, height)) { Assert.Equal(width, img.Width); Assert.Equal(height, img.Height); @@ -517,7 +517,7 @@ public void WrapMemory_IMemoryOwnerOfByte_ValidSize(int size, int height, int wi { for (int i = 0; i < height; ++i) { - var arrayIndex = pixelSize * width * i; + int arrayIndex = pixelSize * width * i; Span rowSpan = acccessor.GetRowSpan(i); ref Rgba32 r0 = ref rowSpan[0]; @@ -538,8 +538,8 @@ public void WrapMemory_IMemoryOwnerOfByte_ValidSize(int size, int height, int wi [InlineData(65536, 65537, 65536)] public void WrapMemory_MemoryOfByte_InvalidSize(int size, int height, int width) { - var array = new byte[size * Unsafe.SizeOf()]; - var memory = new Memory(array); + byte[] array = new byte[size * Unsafe.SizeOf()]; + Memory memory = new(array); Assert.Throws(() => Image.WrapMemory(memory, height, width)); } @@ -552,8 +552,8 @@ public void WrapMemory_MemoryOfByte_InvalidSize(int size, int height, int width) [InlineData(2048, 32, 32)] public void WrapMemory_MemoryOfByte_ValidSize(int size, int height, int width) { - var array = new byte[size * Unsafe.SizeOf()]; - var memory = new Memory(array); + byte[] array = new byte[size * Unsafe.SizeOf()]; + Memory memory = new(array); Image.WrapMemory(memory, height, width); } diff --git a/tests/ImageSharp.Tests/Image/LargeImageIntegrationTests.cs b/tests/ImageSharp.Tests/Image/LargeImageIntegrationTests.cs index 12caa6e7a9..8d1b54658f 100644 --- a/tests/ImageSharp.Tests/Image/LargeImageIntegrationTests.cs +++ b/tests/ImageSharp.Tests/Image/LargeImageIntegrationTests.cs @@ -31,7 +31,7 @@ static void RunTest() Configuration configuration = Configuration.Default.Clone(); configuration.PreferContiguousImageBuffers = true; - using var image = new Image(configuration, 2048, 2048); + using Image image = new(configuration, 2048, 2048); Assert.True(image.DangerousTryGetSinglePixelMemory(out Memory mem)); Assert.Equal(2048 * 2048, mem.Length); } @@ -69,7 +69,7 @@ static void RunTest(string formatInner) Configuration = configuration }; - using var image = Image.Load(options, path); + using Image image = Image.Load(options, path); File.Delete(path); Assert.Equal(1, image.GetPixelMemoryGroup().Count); } diff --git a/tests/ImageSharp.Tests/Image/ProcessPixelRowsTestBase.cs b/tests/ImageSharp.Tests/Image/ProcessPixelRowsTestBase.cs index 27cbe1a7ea..1a6d563c88 100644 --- a/tests/ImageSharp.Tests/Image/ProcessPixelRowsTestBase.cs +++ b/tests/ImageSharp.Tests/Image/ProcessPixelRowsTestBase.cs @@ -32,7 +32,7 @@ protected abstract void ProcessPixelRowsImpl( [Fact] public void PixelAccessorDimensionsAreCorrect() { - using var image = new Image(123, 456); + using Image image = new(123, 456); this.ProcessPixelRowsImpl(image, accessor => { Assert.Equal(123, accessor.Width); @@ -43,7 +43,7 @@ public void PixelAccessorDimensionsAreCorrect() [Fact] public void WriteImagePixels_SingleImage() { - using var image = new Image(256, 256); + using Image image = new(256, 256); this.ProcessPixelRowsImpl(image, accessor => { for (int y = 0; y < accessor.Height; y++) @@ -51,7 +51,7 @@ public void WriteImagePixels_SingleImage() Span row = accessor.GetRowSpan(y); for (int x = 0; x < row.Length; x++) { - row[x] = new L16((ushort)(x * y)); + row[x] = new((ushort)(x * y)); } } }); @@ -71,18 +71,18 @@ public void WriteImagePixels_SingleImage() [Fact] public void WriteImagePixels_MultiImage2() { - using var img1 = new Image(256, 256); + using Image img1 = new(256, 256); Buffer2D buffer = img1.Frames.RootFrame.PixelBuffer; for (int y = 0; y < 256; y++) { Span row = buffer.DangerousGetRowSpan(y); for (int x = 0; x < 256; x++) { - row[x] = new L16((ushort)(x * y)); + row[x] = new((ushort)(x * y)); } } - using var img2 = new Image(256, 256); + using Image img2 = new(256, 256); this.ProcessPixelRowsImpl(img1, img2, (accessor1, accessor2) => { @@ -109,19 +109,19 @@ public void WriteImagePixels_MultiImage2() [Fact] public void WriteImagePixels_MultiImage3() { - using var img1 = new Image(256, 256); + using Image img1 = new(256, 256); Buffer2D buffer2 = img1.Frames.RootFrame.PixelBuffer; for (int y = 0; y < 256; y++) { Span row = buffer2.DangerousGetRowSpan(y); for (int x = 0; x < 256; x++) { - row[x] = new L16((ushort)(x * y)); + row[x] = new((ushort)(x * y)); } } - using var img2 = new Image(256, 256); - using var img3 = new Image(256, 256); + using Image img2 = new(256, 256); + using Image img3 = new(256, 256); this.ProcessPixelRowsImpl(img1, img2, img3, (accessor1, accessor2, accessor3) => { @@ -154,8 +154,8 @@ public void WriteImagePixels_MultiImage3() [Fact] public void Disposed_ThrowsObjectDisposedException() { - using var nonDisposed = new Image(1, 1); - var disposed = new Image(1, 1); + using Image nonDisposed = new(1, 1); + Image disposed = new(1, 1); disposed.Dispose(); Assert.Throws(() => this.ProcessPixelRowsImpl(disposed, _ => { })); @@ -178,11 +178,11 @@ public void RetainsUnmangedBuffers1(bool throwException) static void RunTest(string testTypeName, string throwExceptionStr) { bool throwExceptionInner = bool.Parse(throwExceptionStr); - var buffer = UnmanagedBuffer.Allocate(100); - var allocator = new MockUnmanagedMemoryAllocator(buffer); + UnmanagedBuffer buffer = UnmanagedBuffer.Allocate(100); + MockUnmanagedMemoryAllocator allocator = new(buffer); Configuration.Default.MemoryAllocator = allocator; - var image = new Image(10, 10); + Image image = new(10, 10); Assert.Equal(1, UnmanagedMemoryHandle.TotalOutstandingHandles); try @@ -215,13 +215,13 @@ public void RetainsUnmangedBuffers2(bool throwException) static void RunTest(string testTypeName, string throwExceptionStr) { bool throwExceptionInner = bool.Parse(throwExceptionStr); - var buffer1 = UnmanagedBuffer.Allocate(100); - var buffer2 = UnmanagedBuffer.Allocate(100); - var allocator = new MockUnmanagedMemoryAllocator(buffer1, buffer2); + UnmanagedBuffer buffer1 = UnmanagedBuffer.Allocate(100); + UnmanagedBuffer buffer2 = UnmanagedBuffer.Allocate(100); + MockUnmanagedMemoryAllocator allocator = new(buffer1, buffer2); Configuration.Default.MemoryAllocator = allocator; - var image1 = new Image(10, 10); - var image2 = new Image(10, 10); + Image image1 = new(10, 10); + Image image2 = new(10, 10); Assert.Equal(2, UnmanagedMemoryHandle.TotalOutstandingHandles); try @@ -255,15 +255,15 @@ public void RetainsUnmangedBuffers3(bool throwException) static void RunTest(string testTypeName, string throwExceptionStr) { bool throwExceptionInner = bool.Parse(throwExceptionStr); - var buffer1 = UnmanagedBuffer.Allocate(100); - var buffer2 = UnmanagedBuffer.Allocate(100); - var buffer3 = UnmanagedBuffer.Allocate(100); - var allocator = new MockUnmanagedMemoryAllocator(buffer1, buffer2, buffer3); + UnmanagedBuffer buffer1 = UnmanagedBuffer.Allocate(100); + UnmanagedBuffer buffer2 = UnmanagedBuffer.Allocate(100); + UnmanagedBuffer buffer3 = UnmanagedBuffer.Allocate(100); + MockUnmanagedMemoryAllocator allocator = new(buffer1, buffer2, buffer3); Configuration.Default.MemoryAllocator = allocator; - var image1 = new Image(10, 10); - var image2 = new Image(10, 10); - var image3 = new Image(10, 10); + Image image1 = new(10, 10); + Image image2 = new(10, 10); + Image image3 = new(10, 10); Assert.Equal(3, UnmanagedMemoryHandle.TotalOutstandingHandles); try diff --git a/tests/ImageSharp.Tests/Memory/Allocators/BufferTestSuite.cs b/tests/ImageSharp.Tests/Memory/Allocators/BufferTestSuite.cs index 33950c4697..c4cef5d93e 100644 --- a/tests/ImageSharp.Tests/Memory/Allocators/BufferTestSuite.cs +++ b/tests/ImageSharp.Tests/Memory/Allocators/BufferTestSuite.cs @@ -58,7 +58,7 @@ public override int GetHashCode() } } - public static readonly TheoryData LengthValues = new TheoryData { 0, 1, 7, 1023, 1024 }; + public static readonly TheoryData LengthValues = new() { 0, 1, 7, 1023, 1024 }; [Theory] [MemberData(nameof(LengthValues))] @@ -172,7 +172,7 @@ private void TestWriteAndReadElements(int desiredLength, Func getExpe { using (IMemoryOwner buffer = this.MemoryAllocator.Allocate(desiredLength)) { - var expectedVals = new T[buffer.Length()]; + T[] expectedVals = new T[buffer.Length()]; for (int i = 0; i < buffer.Length(); i++) { @@ -213,7 +213,7 @@ public void IndexingSpan_WhenOutOfRange_Throws_CustomStruct(int desiredLength) private T TestIndexOutOfRangeShouldThrow(int desiredLength) where T : struct, IEquatable { - var dummy = default(T); + T dummy = default(T); using (IMemoryOwner buffer = this.MemoryAllocator.Allocate(desiredLength)) { diff --git a/tests/ImageSharp.Tests/Memory/Allocators/RefCountedLifetimeGuardTests.cs b/tests/ImageSharp.Tests/Memory/Allocators/RefCountedLifetimeGuardTests.cs index 517eda7076..8eb364828e 100644 --- a/tests/ImageSharp.Tests/Memory/Allocators/RefCountedLifetimeGuardTests.cs +++ b/tests/ImageSharp.Tests/Memory/Allocators/RefCountedLifetimeGuardTests.cs @@ -14,7 +14,7 @@ public class RefCountedLifetimeGuardTests [InlineData(3)] public void Dispose_ResultsInSingleRelease(int disposeCount) { - var guard = new MockLifetimeGuard(); + MockLifetimeGuard guard = new(); Assert.Equal(0, guard.ReleaseInvocationCount); for (int i = 0; i < disposeCount; i++) @@ -45,7 +45,7 @@ static void RunTest() [InlineData(3)] public void AddRef_PreventsReleaseOnDispose(int addRefCount) { - var guard = new MockLifetimeGuard(); + MockLifetimeGuard guard = new(); for (int i = 0; i < addRefCount; i++) { @@ -80,7 +80,7 @@ static void RunTest() [Fact] public void AddRefReleaseRefMisuse_DoesntLeadToMultipleReleases() { - var guard = new MockLifetimeGuard(); + MockLifetimeGuard guard = new(); guard.Dispose(); guard.AddRef(); guard.ReleaseRef(); @@ -91,8 +91,8 @@ public void AddRefReleaseRefMisuse_DoesntLeadToMultipleReleases() [Fact] public void UnmanagedBufferLifetimeGuard_Handle_IsReturnedByRef() { - var h = UnmanagedMemoryHandle.Allocate(10); - using var guard = new UnmanagedBufferLifetimeGuard.FreeHandle(h); + UnmanagedMemoryHandle h = UnmanagedMemoryHandle.Allocate(10); + using UnmanagedBufferLifetimeGuard.FreeHandle guard = new(h); Assert.True(guard.Handle.IsValid); guard.Handle.Free(); Assert.False(guard.Handle.IsValid); @@ -101,7 +101,7 @@ public void UnmanagedBufferLifetimeGuard_Handle_IsReturnedByRef() [MethodImpl(MethodImplOptions.NoInlining)] private static void LeakGuard(bool addRef) { - var guard = new MockLifetimeGuard(); + MockLifetimeGuard guard = new(); if (addRef) { guard.AddRef(); diff --git a/tests/ImageSharp.Tests/Memory/Allocators/SharedArrayPoolBufferTests.cs b/tests/ImageSharp.Tests/Memory/Allocators/SharedArrayPoolBufferTests.cs index a956190cd2..72b90c2387 100644 --- a/tests/ImageSharp.Tests/Memory/Allocators/SharedArrayPoolBufferTests.cs +++ b/tests/ImageSharp.Tests/Memory/Allocators/SharedArrayPoolBufferTests.cs @@ -16,7 +16,7 @@ public void AllocatesArrayPoolArray() static void RunTest() { - using (var buffer = new SharedArrayPoolBuffer(900)) + using (SharedArrayPoolBuffer buffer = new(900)) { Assert.Equal(900, buffer.GetSpan().Length); buffer.GetSpan().Fill(42); @@ -36,7 +36,7 @@ public void OutstandingReferences_RetainArrays() static void RunTest() { - var buffer = new SharedArrayPoolBuffer(900); + SharedArrayPoolBuffer buffer = new(900); Span span = buffer.GetSpan(); buffer.AddRef(); diff --git a/tests/ImageSharp.Tests/Memory/Allocators/SimpleGcMemoryAllocatorTests.cs b/tests/ImageSharp.Tests/Memory/Allocators/SimpleGcMemoryAllocatorTests.cs index 665f34a342..0e791c5d97 100644 --- a/tests/ImageSharp.Tests/Memory/Allocators/SimpleGcMemoryAllocatorTests.cs +++ b/tests/ImageSharp.Tests/Memory/Allocators/SimpleGcMemoryAllocatorTests.cs @@ -17,7 +17,7 @@ public BufferTests() } } - protected SimpleGcMemoryAllocator MemoryAllocator { get; } = new SimpleGcMemoryAllocator(); + protected SimpleGcMemoryAllocator MemoryAllocator { get; } = new(); public static TheoryData InvalidLengths { get; set; } = new() { diff --git a/tests/ImageSharp.Tests/Memory/Allocators/UniformUnmanagedMemoryPoolTests.Trim.cs b/tests/ImageSharp.Tests/Memory/Allocators/UniformUnmanagedMemoryPoolTests.Trim.cs index fd8b6af591..fd9760f48f 100644 --- a/tests/ImageSharp.Tests/Memory/Allocators/UniformUnmanagedMemoryPoolTests.Trim.cs +++ b/tests/ImageSharp.Tests/Memory/Allocators/UniformUnmanagedMemoryPoolTests.Trim.cs @@ -24,8 +24,8 @@ public void TrimPeriodElapsed_TrimsHalfOfUnusedArrays() RemoteExecutor.Invoke(RunTest).Dispose(); static void RunTest() { - var trimSettings = new UniformUnmanagedMemoryPool.TrimSettings { TrimPeriodMilliseconds = 5_000 }; - var pool = new UniformUnmanagedMemoryPool(128, 256, trimSettings); + UniformUnmanagedMemoryPool.TrimSettings trimSettings = new() { TrimPeriodMilliseconds = 5_000 }; + UniformUnmanagedMemoryPool pool = new(128, 256, trimSettings); UnmanagedMemoryHandle[] a = pool.Rent(64); UnmanagedMemoryHandle[] b = pool.Rent(64); @@ -77,11 +77,11 @@ public void MultiplePoolInstances_TrimPeriodElapsed_AllAreTrimmed() static void RunTest() { - var trimSettings1 = new UniformUnmanagedMemoryPool.TrimSettings { TrimPeriodMilliseconds = 6_000 }; - var pool1 = new UniformUnmanagedMemoryPool(128, 256, trimSettings1); + UniformUnmanagedMemoryPool.TrimSettings trimSettings1 = new() { TrimPeriodMilliseconds = 6_000 }; + UniformUnmanagedMemoryPool pool1 = new(128, 256, trimSettings1); Thread.Sleep(8_000); // Let some callbacks fire already - var trimSettings2 = new UniformUnmanagedMemoryPool.TrimSettings { TrimPeriodMilliseconds = 3_000 }; - var pool2 = new UniformUnmanagedMemoryPool(128, 256, trimSettings2); + UniformUnmanagedMemoryPool.TrimSettings trimSettings2 = new() { TrimPeriodMilliseconds = 3_000 }; + UniformUnmanagedMemoryPool pool2 = new(128, 256, trimSettings2); pool1.Return(pool1.Rent(64)); pool2.Return(pool2.Rent(64)); @@ -104,14 +104,14 @@ static void RunTest() [MethodImpl(MethodImplOptions.NoInlining)] static void LeakPoolInstance() { - var trimSettings = new UniformUnmanagedMemoryPool.TrimSettings { TrimPeriodMilliseconds = 4_000 }; + UniformUnmanagedMemoryPool.TrimSettings trimSettings = new() { TrimPeriodMilliseconds = 4_000 }; _ = new UniformUnmanagedMemoryPool(128, 256, trimSettings); } } } public static readonly bool Is32BitProcess = !Environment.Is64BitProcess; - private static readonly List PressureArrays = new(); + private static readonly List PressureArrays = []; [Fact] public static void GC_Collect_OnHighLoad_TrimsEntirePool() @@ -129,13 +129,13 @@ static void RunTest() Assert.False(Environment.Is64BitProcess); const int oneMb = 1 << 20; - var trimSettings = new UniformUnmanagedMemoryPool.TrimSettings { HighPressureThresholdRate = 0.2f }; + UniformUnmanagedMemoryPool.TrimSettings trimSettings = new() { HighPressureThresholdRate = 0.2f }; GCMemoryInfo memInfo = GC.GetGCMemoryInfo(); int highLoadThreshold = (int)(memInfo.HighMemoryLoadThresholdBytes / oneMb); highLoadThreshold = (int)(trimSettings.HighPressureThresholdRate * highLoadThreshold); - var pool = new UniformUnmanagedMemoryPool(oneMb, 16, trimSettings); + UniformUnmanagedMemoryPool pool = new(oneMb, 16, trimSettings); pool.Return(pool.Rent(16)); Assert.Equal(16, UnmanagedMemoryHandle.TotalOutstandingHandles); diff --git a/tests/ImageSharp.Tests/Memory/Allocators/UniformUnmanagedMemoryPoolTests.cs b/tests/ImageSharp.Tests/Memory/Allocators/UniformUnmanagedMemoryPoolTests.cs index 69fc1a5f7d..7d1baaaf23 100644 --- a/tests/ImageSharp.Tests/Memory/Allocators/UniformUnmanagedMemoryPoolTests.cs +++ b/tests/ImageSharp.Tests/Memory/Allocators/UniformUnmanagedMemoryPoolTests.cs @@ -18,8 +18,8 @@ public partial class UniformUnmanagedMemoryPoolTests private class CleanupUtil : IDisposable { private readonly UniformUnmanagedMemoryPool pool; - private readonly List handlesToDestroy = new(); - private readonly List ptrsToDestroy = new(); + private readonly List handlesToDestroy = []; + private readonly List ptrsToDestroy = []; public CleanupUtil(UniformUnmanagedMemoryPool pool) { @@ -55,7 +55,7 @@ public void Dispose() [InlineData(7, 4)] public void Constructor_InitializesProperties(int arrayLength, int capacity) { - var pool = new UniformUnmanagedMemoryPool(arrayLength, capacity); + UniformUnmanagedMemoryPool pool = new(arrayLength, capacity); Assert.Equal(arrayLength, pool.BufferLength); Assert.Equal(capacity, pool.Capacity); } @@ -65,8 +65,8 @@ public void Constructor_InitializesProperties(int arrayLength, int capacity) [InlineData(8, 10)] public void Rent_SingleBuffer_ReturnsCorrectBuffer(int length, int capacity) { - var pool = new UniformUnmanagedMemoryPool(length, capacity); - using var cleanup = new CleanupUtil(pool); + UniformUnmanagedMemoryPool pool = new(length, capacity); + using CleanupUtil cleanup = new(pool); for (int i = 0; i < capacity; i++) { @@ -83,7 +83,7 @@ public void Return_DoesNotDeallocateMemory() static void RunTest() { - var pool = new UniformUnmanagedMemoryPool(16, 16); + UniformUnmanagedMemoryPool pool = new(16, 16); UnmanagedMemoryHandle a = pool.Rent(); UnmanagedMemoryHandle[] b = pool.Rent(2); @@ -105,7 +105,7 @@ private static void CheckBuffer(int length, UniformUnmanagedMemoryPool pool, Unm Assert.True(span.SequenceEqual(expected)); } - private static unsafe Span GetSpan(UnmanagedMemoryHandle h, int length) => new Span(h.Pointer, length); + private static unsafe Span GetSpan(UnmanagedMemoryHandle h, int length) => new(h.Pointer, length); [Theory] [InlineData(1, 1)] @@ -114,8 +114,8 @@ private static void CheckBuffer(int length, UniformUnmanagedMemoryPool pool, Unm [InlineData(5, 10)] public void Rent_MultiBuffer_ReturnsCorrectBuffers(int length, int bufferCount) { - var pool = new UniformUnmanagedMemoryPool(length, 10); - using var cleanup = new CleanupUtil(pool); + UniformUnmanagedMemoryPool pool = new(length, 10); + using CleanupUtil cleanup = new(pool); UnmanagedMemoryHandle[] handles = pool.Rent(bufferCount); cleanup.Register(handles); @@ -131,8 +131,8 @@ public void Rent_MultiBuffer_ReturnsCorrectBuffers(int length, int bufferCount) [Fact] public void Rent_MultipleTimesWithoutReturn_ReturnsDifferentHandles() { - var pool = new UniformUnmanagedMemoryPool(128, 10); - using var cleanup = new CleanupUtil(pool); + UniformUnmanagedMemoryPool pool = new(128, 10); + using CleanupUtil cleanup = new(pool); UnmanagedMemoryHandle[] a = pool.Rent(2); cleanup.Register(a); UnmanagedMemoryHandle b = pool.Rent(); @@ -149,10 +149,10 @@ public void Rent_MultipleTimesWithoutReturn_ReturnsDifferentHandles() [InlineData(12, 4, 12)] public void RentReturnRent_SameBuffers(int totalCount, int rentUnit, int capacity) { - var pool = new UniformUnmanagedMemoryPool(128, capacity); - using var cleanup = new CleanupUtil(pool); - var allHandles = new HashSet(); - var handleUnits = new List(); + UniformUnmanagedMemoryPool pool = new(128, capacity); + using CleanupUtil cleanup = new(pool); + HashSet allHandles = []; + List handleUnits = []; UnmanagedMemoryHandle[] handles; for (int i = 0; i < totalCount; i += rentUnit) @@ -197,8 +197,8 @@ public void RentReturnRent_SameBuffers(int totalCount, int rentUnit, int capacit [Fact] public void Rent_SingleBuffer_OverCapacity_ReturnsInvalidBuffer() { - var pool = new UniformUnmanagedMemoryPool(7, 1000); - using var cleanup = new CleanupUtil(pool); + UniformUnmanagedMemoryPool pool = new(7, 1000); + using CleanupUtil cleanup = new(pool); UnmanagedMemoryHandle[] initial = pool.Rent(1000); Assert.NotNull(initial); cleanup.Register(initial); @@ -212,8 +212,8 @@ public void Rent_SingleBuffer_OverCapacity_ReturnsInvalidBuffer() [InlineData(4, 7, 10)] public void Rent_MultiBuffer_OverCapacity_ReturnsNull(int initialRent, int attempt, int capacity) { - var pool = new UniformUnmanagedMemoryPool(128, capacity); - using var cleanup = new CleanupUtil(pool); + UniformUnmanagedMemoryPool pool = new(128, capacity); + using CleanupUtil cleanup = new(pool); UnmanagedMemoryHandle[] initial = pool.Rent(initialRent); Assert.NotNull(initial); cleanup.Register(initial); @@ -228,8 +228,8 @@ public void Rent_MultiBuffer_OverCapacity_ReturnsNull(int initialRent, int attem [InlineData(3, 3, 7)] public void Rent_MultiBuff_BelowCapacity_Succeeds(int initialRent, int attempt, int capacity) { - var pool = new UniformUnmanagedMemoryPool(128, capacity); - using var cleanup = new CleanupUtil(pool); + UniformUnmanagedMemoryPool pool = new(128, capacity); + using CleanupUtil cleanup = new(pool); UnmanagedMemoryHandle[] b0 = pool.Rent(initialRent); Assert.NotNull(b0); cleanup.Register(b0); @@ -250,8 +250,8 @@ public void RentReturnRelease_SubsequentRentReturnsDifferentHandles(bool multipl static void RunTest(string multipleInner) { - var pool = new UniformUnmanagedMemoryPool(16, 16); - using var cleanup = new CleanupUtil(pool); + UniformUnmanagedMemoryPool pool = new(16, 16); + using CleanupUtil cleanup = new(pool); UnmanagedMemoryHandle b0 = pool.Rent(); IntPtr h0 = b0.Handle; UnmanagedMemoryHandle b1 = pool.Rent(); @@ -290,7 +290,7 @@ public void Release_ShouldFreeRetainedMemory() static void RunTest() { - var pool = new UniformUnmanagedMemoryPool(16, 16); + UniformUnmanagedMemoryPool pool = new(16, 16); UnmanagedMemoryHandle a = pool.Rent(); UnmanagedMemoryHandle[] b = pool.Rent(2); pool.Return(a); @@ -306,13 +306,13 @@ static void RunTest() public void RentReturn_IsThreadSafe() { int count = Environment.ProcessorCount * 200; - var pool = new UniformUnmanagedMemoryPool(8, count); - using var cleanup = new CleanupUtil(pool); - var rnd = new Random(0); + UniformUnmanagedMemoryPool pool = new(8, count); + using CleanupUtil cleanup = new(pool); + Random rnd = new(0); Parallel.For(0, Environment.ProcessorCount, (int i) => { - var allHandles = new List(); + List allHandles = []; int pauseAt = rnd.Next(100); for (int j = 0; j < 100; j++) { @@ -359,7 +359,7 @@ static void RunTest(string withGuardedBuffersInner) [MethodImpl(MethodImplOptions.NoInlining)] static void LeakPoolInstance(bool withGuardedBuffers) { - var pool = new UniformUnmanagedMemoryPool(16, 128); + UniformUnmanagedMemoryPool pool = new(16, 128); if (withGuardedBuffers) { UnmanagedMemoryHandle h = pool.Rent(); diff --git a/tests/ImageSharp.Tests/Memory/Allocators/UniformUnmanagedPoolMemoryAllocatorTests.cs b/tests/ImageSharp.Tests/Memory/Allocators/UniformUnmanagedPoolMemoryAllocatorTests.cs index aa34a5c108..e48a0b45d7 100644 --- a/tests/ImageSharp.Tests/Memory/Allocators/UniformUnmanagedPoolMemoryAllocatorTests.cs +++ b/tests/ImageSharp.Tests/Memory/Allocators/UniformUnmanagedPoolMemoryAllocatorTests.cs @@ -44,7 +44,7 @@ public BufferTests2() } public static TheoryData AllocateData = - new TheoryData() + new() { { default(S4), 16, 256, 256, 1024, 64, 64, 1, -1, 64 }, { default(S4), 16, 256, 256, 1024, 256, 256, 1, -1, 256 }, @@ -69,7 +69,7 @@ public void AllocateGroup_BufferSizesAreCorrect( int expectedSizeOfLastBuffer) where T : struct { - var allocator = new UniformUnmanagedMemoryPoolMemoryAllocator( + UniformUnmanagedMemoryPoolMemoryAllocator allocator = new( sharedArrayPoolThresholdInBytes, maxContiguousPoolBufferInBytes, maxPoolSizeInBytes, @@ -86,13 +86,13 @@ public void AllocateGroup_BufferSizesAreCorrect( [Fact] public void AllocateGroup_MultipleTimes_ExceedPoolLimit() { - var allocator = new UniformUnmanagedMemoryPoolMemoryAllocator( + UniformUnmanagedMemoryPoolMemoryAllocator allocator = new( 64, 128, 1024, 1024); - var groups = new List>(); + List> groups = []; for (int i = 0; i < 16; i++) { int lengthInElements = 128 / Unsafe.SizeOf(); @@ -110,7 +110,7 @@ public void AllocateGroup_MultipleTimes_ExceedPoolLimit() [Fact] public void AllocateGroup_SizeInBytesOverLongMaxValue_ThrowsInvalidMemoryOperationException() { - var allocator = new UniformUnmanagedMemoryPoolMemoryAllocator(null); + UniformUnmanagedMemoryPoolMemoryAllocator allocator = new(null); Assert.Throws(() => allocator.AllocateGroup(int.MaxValue * (long)int.MaxValue, int.MaxValue)); } @@ -128,7 +128,7 @@ public void Allocate_IncorrectAmount_ThrowsCorrect_InvalidMemoryOperationExcepti [Fact] public unsafe void Allocate_MemoryIsPinnableMultipleTimes() { - var allocator = new UniformUnmanagedMemoryPoolMemoryAllocator(null); + UniformUnmanagedMemoryPoolMemoryAllocator allocator = new(null); using IMemoryOwner memoryOwner = allocator.Allocate(100); using (MemoryHandle pin = memoryOwner.Memory.Pin()) @@ -149,7 +149,7 @@ public void MemoryAllocator_Create_WithoutSettings_AllocatesDiscontiguousMemory( static void RunTest() { - var allocator = MemoryAllocator.Create(); + MemoryAllocator allocator = MemoryAllocator.Create(); long sixteenMegabytes = 16 * (1 << 20); // Should allocate 4 times 4MB discontiguos blocks: @@ -165,7 +165,7 @@ public void MemoryAllocator_Create_LimitPoolSize() static void RunTest() { - var allocator = MemoryAllocator.Create(new MemoryAllocatorOptions() + MemoryAllocator allocator = MemoryAllocator.Create(new() { MaximumPoolSizeMegabytes = 8 }); @@ -205,7 +205,7 @@ public void BufferDisposal_ReturnsToPool(bool shared) static void RunTest(string sharedStr) { - var allocator = new UniformUnmanagedMemoryPoolMemoryAllocator(512, 1024, 16 * 1024, 1024); + UniformUnmanagedMemoryPoolMemoryAllocator allocator = new(512, 1024, 16 * 1024, 1024); IMemoryOwner buffer0 = allocator.Allocate(bool.Parse(sharedStr) ? 300 : 600); buffer0.GetSpan()[0] = 42; buffer0.Dispose(); @@ -223,7 +223,7 @@ public void MemoryGroupDisposal_ReturnsToPool(bool shared) static void RunTest(string sharedStr) { - var allocator = new UniformUnmanagedMemoryPoolMemoryAllocator(512, 1024, 16 * 1024, 1024); + UniformUnmanagedMemoryPoolMemoryAllocator allocator = new(512, 1024, 16 * 1024, 1024); MemoryGroup g0 = allocator.AllocateGroup(bool.Parse(sharedStr) ? 300 : 600, 100); g0.Single().Span[0] = 42; g0.Dispose(); @@ -238,7 +238,7 @@ public void ReleaseRetainedResources_ShouldFreePooledMemory() RemoteExecutor.Invoke(RunTest).Dispose(); static void RunTest() { - var allocator = new UniformUnmanagedMemoryPoolMemoryAllocator(128, 512, 16 * 512, 1024); + UniformUnmanagedMemoryPoolMemoryAllocator allocator = new(128, 512, 16 * 512, 1024); MemoryGroup g = allocator.AllocateGroup(2048, 128); g.Dispose(); Assert.Equal(4, UnmanagedMemoryHandle.TotalOutstandingHandles); @@ -253,7 +253,7 @@ public void ReleaseRetainedResources_DoesNotFreeOutstandingBuffers() RemoteExecutor.Invoke(RunTest).Dispose(); static void RunTest() { - var allocator = new UniformUnmanagedMemoryPoolMemoryAllocator(128, 512, 16 * 512, 1024); + UniformUnmanagedMemoryPoolMemoryAllocator allocator = new(128, 512, 16 * 512, 1024); IMemoryOwner b = allocator.Allocate(256); MemoryGroup g = allocator.AllocateGroup(2048, 128); Assert.Equal(5, UnmanagedMemoryHandle.TotalOutstandingHandles); @@ -297,7 +297,7 @@ public void AllocateMemoryGroup_Finalization_ReturnsToPool(int length) static void RunTest(string lengthStr) { - var allocator = new UniformUnmanagedMemoryPoolMemoryAllocator(512, 1024, 16 * 1024, 1024); + UniformUnmanagedMemoryPoolMemoryAllocator allocator = new(512, 1024, 16 * 1024, 1024); int lengthInner = int.Parse(lengthStr); AllocateGroupAndForget(allocator, lengthInner); @@ -365,7 +365,7 @@ public void AllocateSingleMemoryOwner_Finalization_ReturnsToPool(int length) static void RunTest(string lengthStr) { - var allocator = new UniformUnmanagedMemoryPoolMemoryAllocator(512, 1024, 16 * 1024, 1024); + UniformUnmanagedMemoryPoolMemoryAllocator allocator = new(512, 1024, 16 * 1024, 1024); int lengthInner = int.Parse(lengthStr); AllocateSingleAndForget(allocator, lengthInner); @@ -422,7 +422,7 @@ static void RunTest() [Fact] public void Allocate_OverLimit_ThrowsInvalidMemoryOperationException() { - MemoryAllocator allocator = MemoryAllocator.Create(new MemoryAllocatorOptions() + MemoryAllocator allocator = MemoryAllocator.Create(new() { AllocationLimitMegabytes = 4 }); @@ -434,7 +434,7 @@ public void Allocate_OverLimit_ThrowsInvalidMemoryOperationException() [Fact] public void AllocateGroup_OverLimit_ThrowsInvalidMemoryOperationException() { - MemoryAllocator allocator = MemoryAllocator.Create(new MemoryAllocatorOptions() + MemoryAllocator allocator = MemoryAllocator.Create(new() { AllocationLimitMegabytes = 4 }); @@ -450,7 +450,7 @@ public void MemoryAllocator_Create_SetHighLimit() static void RunTest() { const long threeGB = 3L * (1 << 30); - MemoryAllocator allocator = MemoryAllocator.Create(new MemoryAllocatorOptions() + MemoryAllocator allocator = MemoryAllocator.Create(new() { AllocationLimitMegabytes = (int)(threeGB / 1024) }); diff --git a/tests/ImageSharp.Tests/Memory/Allocators/UnmanagedBufferTests.cs b/tests/ImageSharp.Tests/Memory/Allocators/UnmanagedBufferTests.cs index d0a5cfa9a7..1fe33c3467 100644 --- a/tests/ImageSharp.Tests/Memory/Allocators/UnmanagedBufferTests.cs +++ b/tests/ImageSharp.Tests/Memory/Allocators/UnmanagedBufferTests.cs @@ -21,7 +21,7 @@ public AllocatorBufferTests() [Fact] public void Allocate_CreatesValidBuffer() { - using var buffer = UnmanagedBuffer.Allocate(10); + using UnmanagedBuffer buffer = UnmanagedBuffer.Allocate(10); Span span = buffer.GetSpan(); Assert.Equal(10, span.Length); span[9] = 123; @@ -35,7 +35,7 @@ public unsafe void Dispose_DoesNotReleaseOutstandingReferences() static void RunTest() { - var buffer = UnmanagedBuffer.Allocate(10); + UnmanagedBuffer buffer = UnmanagedBuffer.Allocate(10); Assert.Equal(1, UnmanagedMemoryHandle.TotalOutstandingHandles); Span span = buffer.GetSpan(); @@ -76,10 +76,10 @@ static void RunTest(string countStr) static List> FillList(int countInner) { - var l = new List>(); + List> l = []; for (int i = 0; i < countInner; i++) { - var h = UnmanagedBuffer.Allocate(42); + UnmanagedBuffer h = UnmanagedBuffer.Allocate(42); l.Add(h); } diff --git a/tests/ImageSharp.Tests/Memory/Allocators/UnmanagedMemoryHandleTests.cs b/tests/ImageSharp.Tests/Memory/Allocators/UnmanagedMemoryHandleTests.cs index 7a0736b545..8818597a94 100644 --- a/tests/ImageSharp.Tests/Memory/Allocators/UnmanagedMemoryHandleTests.cs +++ b/tests/ImageSharp.Tests/Memory/Allocators/UnmanagedMemoryHandleTests.cs @@ -11,7 +11,7 @@ public class UnmanagedMemoryHandleTests [Fact] public unsafe void Allocate_AllocatesReadWriteMemory() { - var h = UnmanagedMemoryHandle.Allocate(128); + UnmanagedMemoryHandle h = UnmanagedMemoryHandle.Allocate(128); Assert.False(h.IsInvalid); Assert.True(h.IsValid); byte* ptr = (byte*)h.Handle; @@ -31,7 +31,7 @@ public unsafe void Allocate_AllocatesReadWriteMemory() [Fact] public void Free_ClosesHandle() { - var h = UnmanagedMemoryHandle.Allocate(128); + UnmanagedMemoryHandle h = UnmanagedMemoryHandle.Allocate(128); h.Free(); Assert.True(h.IsInvalid); Assert.Equal(IntPtr.Zero, h.Handle); @@ -47,11 +47,11 @@ public void Create_Free_AllocationsAreTracked(int count) static void RunTest(string countStr) { int countInner = int.Parse(countStr); - var l = new List(); + List l = []; for (int i = 0; i < countInner; i++) { Assert.Equal(i, UnmanagedMemoryHandle.TotalOutstandingHandles); - var h = UnmanagedMemoryHandle.Allocate(42); + UnmanagedMemoryHandle h = UnmanagedMemoryHandle.Allocate(42); Assert.Equal(i + 1, UnmanagedMemoryHandle.TotalOutstandingHandles); l.Add(h); } @@ -68,7 +68,7 @@ static void RunTest(string countStr) [Fact] public void Equality_WhenTrue() { - var h1 = UnmanagedMemoryHandle.Allocate(10); + UnmanagedMemoryHandle h1 = UnmanagedMemoryHandle.Allocate(10); UnmanagedMemoryHandle h2 = h1; Assert.True(h1.Equals(h2)); @@ -82,8 +82,8 @@ public void Equality_WhenTrue() [Fact] public void Equality_WhenFalse() { - var h1 = UnmanagedMemoryHandle.Allocate(10); - var h2 = UnmanagedMemoryHandle.Allocate(10); + UnmanagedMemoryHandle h1 = UnmanagedMemoryHandle.Allocate(10); + UnmanagedMemoryHandle h2 = UnmanagedMemoryHandle.Allocate(10); Assert.False(h1.Equals(h2)); Assert.False(h2.Equals(h1)); diff --git a/tests/ImageSharp.Tests/Memory/Buffer2DTests.SwapOrCopyContent.cs b/tests/ImageSharp.Tests/Memory/Buffer2DTests.SwapOrCopyContent.cs index 88c05fdd0e..578ffc4806 100644 --- a/tests/ImageSharp.Tests/Memory/Buffer2DTests.SwapOrCopyContent.cs +++ b/tests/ImageSharp.Tests/Memory/Buffer2DTests.SwapOrCopyContent.cs @@ -10,7 +10,7 @@ public partial class Buffer2DTests { public class SwapOrCopyContent { - private readonly TestMemoryAllocator memoryAllocator = new TestMemoryAllocator(); + private readonly TestMemoryAllocator memoryAllocator = new(); [Fact] public void SwapOrCopyContent_WhenBothAllocated() @@ -29,8 +29,8 @@ public void SwapOrCopyContent_WhenBothAllocated() Assert.Equal(bb, a.FastMemoryGroup.Single()); Assert.Equal(aa, b.FastMemoryGroup.Single()); - Assert.Equal(new Size(3, 7), a.Size()); - Assert.Equal(new Size(10, 5), b.Size()); + Assert.Equal(new(3, 7), a.Size()); + Assert.Equal(new(10, 5), b.Size()); Assert.Equal(666, b[1, 3]); Assert.Equal(444, a[1, 3]); @@ -40,8 +40,8 @@ public void SwapOrCopyContent_WhenBothAllocated() [Fact] public void SwapOrCopyContent_WhenDestinationIsOwned_ShouldNotSwapInDisposedSourceBuffer() { - using var destData = MemoryGroup.Wrap(new int[100]); - using var dest = new Buffer2D(destData, 10, 10); + using MemoryGroup destData = MemoryGroup.Wrap(new int[100]); + using Buffer2D dest = new(destData, 10, 10); using (Buffer2D source = this.memoryAllocator.Allocate2D(10, 10, AllocationOptions.Clean)) { @@ -112,11 +112,11 @@ public void WhenBothAreMemoryOwners_ShouldReplaceViews() [InlineData(true)] public void WhenDestIsNotAllocated_SameSize_ShouldCopy(bool sourceIsAllocated) { - var data = new Rgba32[21]; - var color = new Rgba32(1, 2, 3, 4); + Rgba32[] data = new Rgba32[21]; + Rgba32 color = new(1, 2, 3, 4); - using var destOwner = new TestMemoryManager(data); - using var dest = new Buffer2D(MemoryGroup.Wrap(destOwner.Memory), 21, 1); + using TestMemoryManager destOwner = new(data); + using Buffer2D dest = new(MemoryGroup.Wrap(destOwner.Memory), 21, 1); using Buffer2D source = this.memoryAllocator.Allocate2D(21, 1); @@ -136,11 +136,11 @@ public void WhenDestIsNotAllocated_SameSize_ShouldCopy(bool sourceIsAllocated) [InlineData(true)] public void WhenDestIsNotMemoryOwner_DifferentSize_Throws(bool sourceIsOwner) { - var data = new Rgba32[21]; - var color = new Rgba32(1, 2, 3, 4); + Rgba32[] data = new Rgba32[21]; + Rgba32 color = new(1, 2, 3, 4); - using var destOwner = new TestMemoryManager(data); - using var dest = new Buffer2D(MemoryGroup.Wrap(destOwner.Memory), 21, 1); + using TestMemoryManager destOwner = new(data); + using Buffer2D dest = new(MemoryGroup.Wrap(destOwner.Memory), 21, 1); using Buffer2D source = this.memoryAllocator.Allocate2D(22, 1); diff --git a/tests/ImageSharp.Tests/Memory/Buffer2DTests.cs b/tests/ImageSharp.Tests/Memory/Buffer2DTests.cs index 8ba3bf70a2..e17073b745 100644 --- a/tests/ImageSharp.Tests/Memory/Buffer2DTests.cs +++ b/tests/ImageSharp.Tests/Memory/Buffer2DTests.cs @@ -24,7 +24,7 @@ public static void SpanPointsTo(Span span, Memory buffer, int bufferOff } } - private TestMemoryAllocator MemoryAllocator { get; } = new TestMemoryAllocator(); + private TestMemoryAllocator MemoryAllocator { get; } = new(); private const int Big = 99999; @@ -72,7 +72,7 @@ public void Construct_PreferContiguousImageBuffers_AllocatesContiguousRegardless using Buffer2D buffer = useSizeOverload ? this.MemoryAllocator.Allocate2D( - new Size(200, 200), + new(200, 200), preferContiguosImageBuffers: true) : this.MemoryAllocator.Allocate2D( 200, @@ -147,7 +147,7 @@ public unsafe void DangerousGetRowSpan_UnmanagedAllocator(int width, int height) const int unpooledBufferSize = 8_000; int elementSize = sizeof(TestStructs.Foo); - var allocator = new UniformUnmanagedMemoryPoolMemoryAllocator( + UniformUnmanagedMemoryPoolMemoryAllocator allocator = new( sharedPoolThreshold * elementSize, poolBufferSize * elementSize, maxPoolSize * elementSize, @@ -155,7 +155,7 @@ public unsafe void DangerousGetRowSpan_UnmanagedAllocator(int width, int height) using Buffer2D buffer = allocator.Allocate2D(width, height); - var rnd = new Random(42); + Random rnd = new(42); for (int y = 0; y < buffer.Height; y++) { @@ -169,7 +169,7 @@ public unsafe void DangerousGetRowSpan_UnmanagedAllocator(int width, int height) } // Re-seed - rnd = new Random(42); + rnd = new(42); for (int y = 0; y < buffer.Height; y++) { Span span = buffer.GetSafeRowMemory(y).Span; @@ -208,7 +208,7 @@ public void TryGetPaddedRowSpanY(int bufferCapacity, int y, int padding, int exp } } - public static TheoryData GetRowSpanY_OutOfRange_Data = new TheoryData() + public static TheoryData GetRowSpanY_OutOfRange_Data = new() { { Big, 10, 8, -1 }, { Big, 10, 8, 8 }, @@ -227,7 +227,7 @@ public void GetRowSpan_OutOfRange(int bufferCapacity, int width, int height, int Assert.True(ex is ArgumentOutOfRangeException || ex is IndexOutOfRangeException); } - public static TheoryData Indexer_OutOfRange_Data = new TheoryData() + public static TheoryData Indexer_OutOfRange_Data = new() { { Big, 10, 8, 1, -1 }, { Big, 10, 8, 1, 8 }, @@ -284,7 +284,7 @@ public unsafe void Indexer(int bufferCapacity, int width, int height, int x, int [InlineData(5, 1, 1, 3, 2)] public void CopyColumns(int width, int height, int startIndex, int destIndex, int columnCount) { - var rnd = new Random(123); + Random rnd = new(123); using (Buffer2D b = this.MemoryAllocator.Allocate2D(width, height)) { rnd.RandomFill(b.DangerousGetSingleSpan(), 0, 1); @@ -306,7 +306,7 @@ public void CopyColumns(int width, int height, int startIndex, int destIndex, in [Fact] public void CopyColumns_InvokeMultipleTimes() { - var rnd = new Random(123); + Random rnd = new(123); using (Buffer2D b = this.MemoryAllocator.Allocate2D(100, 100)) { rnd.RandomFill(b.DangerousGetSingleSpan(), 0, 1); @@ -339,12 +339,12 @@ public void PublicMemoryGroup_IsMemoryGroupView() Assert.NotSame(mgBefore, buffer1.MemoryGroup); } - public static TheoryData InvalidLengths { get; set; } = new() - { - { new(-1, -1) }, - { new(32768, 32769) }, - { new(32769, 32768) } - }; + public static TheoryData InvalidLengths { get; set; } = + [ + new(-1, -1), + new(32768, 32769), + new(32769, 32768) + ]; [Theory] [MemberData(nameof(InvalidLengths))] @@ -354,7 +354,7 @@ public void Allocate_IncorrectAmount_ThrowsCorrect_InvalidMemoryOperationExcepti [Theory] [MemberData(nameof(InvalidLengths))] public void Allocate_IncorrectAmount_ThrowsCorrect_InvalidMemoryOperationException_Size(Size size) - => Assert.Throws(() => this.MemoryAllocator.Allocate2D(new Size(size))); + => Assert.Throws(() => this.MemoryAllocator.Allocate2D(new(size))); [Theory] [MemberData(nameof(InvalidLengths))] diff --git a/tests/ImageSharp.Tests/Memory/BufferAreaTests.cs b/tests/ImageSharp.Tests/Memory/BufferAreaTests.cs index 46907b9c0e..be7edbacca 100644 --- a/tests/ImageSharp.Tests/Memory/BufferAreaTests.cs +++ b/tests/ImageSharp.Tests/Memory/BufferAreaTests.cs @@ -7,14 +7,14 @@ namespace SixLabors.ImageSharp.Tests.Memory; public class BufferAreaTests { - private readonly TestMemoryAllocator memoryAllocator = new TestMemoryAllocator(); + private readonly TestMemoryAllocator memoryAllocator = new(); [Fact] public void Construct() { using Buffer2D buffer = this.memoryAllocator.Allocate2D(10, 20); - var rectangle = new Rectangle(3, 2, 5, 6); - var area = new Buffer2DRegion(buffer, rectangle); + Rectangle rectangle = new(3, 2, 5, 6); + Buffer2DRegion area = new(buffer, rectangle); Assert.Equal(buffer, area.Buffer); Assert.Equal(rectangle, area.Rectangle); @@ -43,7 +43,7 @@ public void Indexer(int bufferCapacity, int rx, int ry, int x, int y) { this.memoryAllocator.BufferCapacityInBytes = sizeof(int) * bufferCapacity; using Buffer2D buffer = this.CreateTestBuffer(20, 30); - var r = new Rectangle(rx, ry, 5, 6); + Rectangle r = new(rx, ry, 5, 6); Buffer2DRegion region = buffer.GetRegion(r); @@ -62,7 +62,7 @@ public void GetRowSpan(int bufferCapacity, int rx, int ry, int y, int w, int h) this.memoryAllocator.BufferCapacityInBytes = sizeof(int) * bufferCapacity; using Buffer2D buffer = this.CreateTestBuffer(20, 30); - var r = new Rectangle(rx, ry, w, h); + Rectangle r = new(rx, ry, w, h); Buffer2DRegion region = buffer.GetRegion(r); @@ -87,7 +87,7 @@ public void GetSubArea() Buffer2DRegion area1 = area0.GetSubRegion(4, 4, 5, 5); - var expectedRect = new Rectangle(10, 12, 5, 5); + Rectangle expectedRect = new(10, 12, 5, 5); Assert.Equal(buffer, area1.Buffer); Assert.Equal(expectedRect, area1.Rectangle); @@ -120,7 +120,7 @@ public void Clear_FullArea(int bufferCapacity) this.memoryAllocator.BufferCapacityInBytes = sizeof(int) * bufferCapacity; using Buffer2D buffer = this.CreateTestBuffer(22, 13); - var emptyRow = new int[22]; + int[] emptyRow = new int[22]; buffer.GetRegion().Clear(); for (int y = 0; y < 13; y++) diff --git a/tests/ImageSharp.Tests/Memory/DiscontiguousBuffers/MemoryGroupIndex.cs b/tests/ImageSharp.Tests/Memory/DiscontiguousBuffers/MemoryGroupIndex.cs index 878084674a..ea98357cbf 100644 --- a/tests/ImageSharp.Tests/Memory/DiscontiguousBuffers/MemoryGroupIndex.cs +++ b/tests/ImageSharp.Tests/Memory/DiscontiguousBuffers/MemoryGroupIndex.cs @@ -27,7 +27,7 @@ public MemoryGroupIndex(int bufferLength, int bufferIndex, int elementIndex) public static MemoryGroupIndex operator +(MemoryGroupIndex idx, int val) { int nextElementIndex = idx.ElementIndex + val; - return new MemoryGroupIndex( + return new( idx.BufferLength, idx.BufferIndex + (nextElementIndex / idx.BufferLength), nextElementIndex % idx.BufferLength); @@ -105,14 +105,14 @@ public static void SetElementAt(this IMemoryGroup group, MemoryGroupIndex public static MemoryGroupIndex MinIndex(this IMemoryGroup group) where T : struct { - return new MemoryGroupIndex(group.BufferLength, 0, 0); + return new(group.BufferLength, 0, 0); } public static MemoryGroupIndex MaxIndex(this IMemoryGroup group) where T : struct { return group.Count == 0 - ? new MemoryGroupIndex(group.BufferLength, 0, 0) + ? new(group.BufferLength, 0, 0) : new MemoryGroupIndex(group.BufferLength, group.Count - 1, group[group.Count - 1].Length); } } diff --git a/tests/ImageSharp.Tests/Memory/DiscontiguousBuffers/MemoryGroupIndexTests.cs b/tests/ImageSharp.Tests/Memory/DiscontiguousBuffers/MemoryGroupIndexTests.cs index a49ab77781..9c7915e221 100644 --- a/tests/ImageSharp.Tests/Memory/DiscontiguousBuffers/MemoryGroupIndexTests.cs +++ b/tests/ImageSharp.Tests/Memory/DiscontiguousBuffers/MemoryGroupIndexTests.cs @@ -8,8 +8,8 @@ public class MemoryGroupIndexTests [Fact] public void Equal() { - var a = new MemoryGroupIndex(10, 1, 3); - var b = new MemoryGroupIndex(10, 1, 3); + MemoryGroupIndex a = new(10, 1, 3); + MemoryGroupIndex b = new(10, 1, 3); Assert.True(a.Equals(b)); Assert.True(a == b); @@ -21,8 +21,8 @@ public void Equal() [Fact] public void SmallerBufferIndex() { - var a = new MemoryGroupIndex(10, 3, 3); - var b = new MemoryGroupIndex(10, 5, 3); + MemoryGroupIndex a = new(10, 3, 3); + MemoryGroupIndex b = new(10, 5, 3); Assert.False(a == b); Assert.True(a != b); @@ -33,8 +33,8 @@ public void SmallerBufferIndex() [Fact] public void SmallerElementIndex() { - var a = new MemoryGroupIndex(10, 3, 3); - var b = new MemoryGroupIndex(10, 3, 9); + MemoryGroupIndex a = new(10, 3, 3); + MemoryGroupIndex b = new(10, 3, 9); Assert.False(a == b); Assert.True(a != b); @@ -45,20 +45,20 @@ public void SmallerElementIndex() [Fact] public void Increment() { - var a = new MemoryGroupIndex(10, 3, 3); + MemoryGroupIndex a = new(10, 3, 3); a += 1; - Assert.Equal(new MemoryGroupIndex(10, 3, 4), a); + Assert.Equal(new(10, 3, 4), a); } [Fact] public void Increment_OverflowBuffer() { - var a = new MemoryGroupIndex(10, 5, 3); - var b = new MemoryGroupIndex(10, 5, 9); + MemoryGroupIndex a = new(10, 5, 3); + MemoryGroupIndex b = new(10, 5, 9); a += 8; b += 1; - Assert.Equal(new MemoryGroupIndex(10, 6, 1), a); - Assert.Equal(new MemoryGroupIndex(10, 6, 0), b); + Assert.Equal(new(10, 6, 1), a); + Assert.Equal(new(10, 6, 0), b); } } diff --git a/tests/ImageSharp.Tests/Memory/DiscontiguousBuffers/MemoryGroupTests.Allocate.cs b/tests/ImageSharp.Tests/Memory/DiscontiguousBuffers/MemoryGroupTests.Allocate.cs index 4c7de5412c..678a089a85 100644 --- a/tests/ImageSharp.Tests/Memory/DiscontiguousBuffers/MemoryGroupTests.Allocate.cs +++ b/tests/ImageSharp.Tests/Memory/DiscontiguousBuffers/MemoryGroupTests.Allocate.cs @@ -59,7 +59,7 @@ public void Allocate_FromMemoryAllocator_BufferSizesAreCorrect( this.MemoryAllocator.BufferCapacityInBytes = bufferCapacity; // Act: - using var g = MemoryGroup.Allocate(this.MemoryAllocator, totalLength, bufferAlignment); + using MemoryGroup g = MemoryGroup.Allocate(this.MemoryAllocator, totalLength, bufferAlignment); // Assert: ValidateAllocateMemoryGroup(expectedNumberOfBuffers, expectedBufferSize, expectedSizeOfLastBuffer, g); @@ -83,7 +83,7 @@ public void Allocate_FromPool_BufferSizesAreCorrect( return; } - var pool = new UniformUnmanagedMemoryPool(bufferCapacity, expectedNumberOfBuffers); + UniformUnmanagedMemoryPool pool = new(bufferCapacity, expectedNumberOfBuffers); // Act: Assert.True(MemoryGroup.TryAllocate(pool, totalLength, bufferAlignment, AllocationOptions.None, out MemoryGroup g)); @@ -98,7 +98,7 @@ public void Allocate_FromPool_BufferSizesAreCorrect( [InlineData(AllocationOptions.Clean)] public unsafe void Allocate_FromPool_AllocationOptionsAreApplied(AllocationOptions options) { - var pool = new UniformUnmanagedMemoryPool(10, 5); + UniformUnmanagedMemoryPool pool = new(10, 5); UnmanagedMemoryHandle[] buffers = pool.Rent(5); foreach (UnmanagedMemoryHandle b in buffers) { @@ -128,7 +128,7 @@ public void Allocate_FromPool_AroundLimit( int requestBytes, bool shouldSucceed) { - var pool = new UniformUnmanagedMemoryPool(bufferCapacityBytes, poolCapacity); + UniformUnmanagedMemoryPool pool = new(bufferCapacityBytes, poolCapacity); int alignmentElements = alignmentBytes / Unsafe.SizeOf(); int requestElements = requestBytes / Unsafe.SizeOf(); @@ -194,7 +194,7 @@ public void MemoryAllocatorIsUtilizedCorrectly(AllocationOptions allocationOptio HashSet bufferHashes; int expectedBlockCount = 5; - using (var g = MemoryGroup.Allocate(this.MemoryAllocator, 500, 100, allocationOptions)) + using (MemoryGroup g = MemoryGroup.Allocate(this.MemoryAllocator, 500, 100, allocationOptions)) { IReadOnlyList allocationLog = this.MemoryAllocator.AllocationLog; Assert.Equal(expectedBlockCount, allocationLog.Count); diff --git a/tests/ImageSharp.Tests/Memory/DiscontiguousBuffers/MemoryGroupTests.CopyTo.cs b/tests/ImageSharp.Tests/Memory/DiscontiguousBuffers/MemoryGroupTests.CopyTo.cs index 23aaf3c559..c140571fcc 100644 --- a/tests/ImageSharp.Tests/Memory/DiscontiguousBuffers/MemoryGroupTests.CopyTo.cs +++ b/tests/ImageSharp.Tests/Memory/DiscontiguousBuffers/MemoryGroupTests.CopyTo.cs @@ -50,7 +50,7 @@ public void WhenTargetBufferTooShort_Throws() public void GroupToSpan_Success(long totalLength, int bufferLength, int spanLength) { using MemoryGroup src = this.CreateTestGroup(totalLength, bufferLength, true); - var trg = new int[spanLength]; + int[] trg = new int[spanLength]; src.CopyTo(trg); int expected = 1; @@ -67,7 +67,7 @@ public void GroupToSpan_Success(long totalLength, int bufferLength, int spanLeng public void GroupToSpan_OutOfRange(long totalLength, int bufferLength, int spanLength) { using MemoryGroup src = this.CreateTestGroup(totalLength, bufferLength, true); - var trg = new int[spanLength]; + int[] trg = new int[spanLength]; Assert.ThrowsAny(() => src.CopyTo(trg)); } @@ -78,7 +78,7 @@ public void GroupToSpan_OutOfRange(long totalLength, int bufferLength, int spanL [InlineData(0, 3, 0)] public void SpanToGroup_Success(long totalLength, int bufferLength, int spanLength) { - var src = new int[spanLength]; + int[] src = new int[spanLength]; for (int i = 0; i < src.Length; i++) { src[i] = i + 1; @@ -100,7 +100,7 @@ public void SpanToGroup_Success(long totalLength, int bufferLength, int spanLeng [InlineData(0, 3, 1)] public void SpanToGroup_OutOfRange(long totalLength, int bufferLength, int spanLength) { - var src = new int[spanLength]; + int[] src = new int[spanLength]; using MemoryGroup trg = this.CreateTestGroup(totalLength, bufferLength, true); Assert.ThrowsAny(() => src.AsSpan().CopyTo(trg)); } diff --git a/tests/ImageSharp.Tests/Memory/DiscontiguousBuffers/MemoryGroupTests.cs b/tests/ImageSharp.Tests/Memory/DiscontiguousBuffers/MemoryGroupTests.cs index 316150c305..d5dc014c55 100644 --- a/tests/ImageSharp.Tests/Memory/DiscontiguousBuffers/MemoryGroupTests.cs +++ b/tests/ImageSharp.Tests/Memory/DiscontiguousBuffers/MemoryGroupTests.cs @@ -12,7 +12,7 @@ public partial class MemoryGroupTests : MemoryGroupTestsBase [Fact] public void IsValid_TrueAfterCreation() { - using var g = MemoryGroup.Allocate(this.MemoryAllocator, 10, 100); + using MemoryGroup g = MemoryGroup.Allocate(this.MemoryAllocator, 10, 100); Assert.True(g.IsValid); } @@ -20,7 +20,7 @@ public void IsValid_TrueAfterCreation() [Fact] public void IsValid_FalseAfterDisposal() { - using var g = MemoryGroup.Allocate(this.MemoryAllocator, 10, 100); + using MemoryGroup g = MemoryGroup.Allocate(this.MemoryAllocator, 10, 100); g.Dispose(); Assert.False(g.IsValid); @@ -28,7 +28,7 @@ public void IsValid_FalseAfterDisposal() #pragma warning disable SA1509 private static readonly TheoryData CopyAndTransformData = - new TheoryData() + new() { { 20, 10, 20, 10 }, { 20, 5, 20, 4 }, @@ -99,13 +99,13 @@ public void TransformInplace(int totalLength, int bufferLength) [Fact] public void Wrap() { - int[] data0 = { 1, 2, 3, 4 }; - int[] data1 = { 5, 6, 7, 8 }; - int[] data2 = { 9, 10 }; - using var mgr0 = new TestMemoryManager(data0); - using var mgr1 = new TestMemoryManager(data1); + int[] data0 = [1, 2, 3, 4]; + int[] data1 = [5, 6, 7, 8]; + int[] data2 = [9, 10]; + using TestMemoryManager mgr0 = new(data0); + using TestMemoryManager mgr1 = new(data1); - using var group = MemoryGroup.Wrap(mgr0.Memory, mgr1.Memory, data2); + using MemoryGroup group = MemoryGroup.Wrap(mgr0.Memory, mgr1.Memory, data2); Assert.Equal(3, group.Count); Assert.Equal(4, group.BufferLength); @@ -116,7 +116,7 @@ public void Wrap() Assert.True(group[2].Span.SequenceEqual(data2)); int cnt = 0; - int[][] allData = { data0, data1, data2 }; + int[][] allData = [data0, data1, data2]; foreach (Memory memory in group) { Assert.True(memory.Span.SequenceEqual(allData[cnt])); @@ -124,7 +124,7 @@ public void Wrap() } } - public static TheoryData GetBoundedSlice_SuccessData = new TheoryData() + public static TheoryData GetBoundedSlice_SuccessData = new() { { 300, 100, 110, 80 }, { 300, 100, 100, 100 }, @@ -153,7 +153,7 @@ public void GetBoundedSlice_WhenArgsAreCorrect(long totalLength, int bufferLengt } } - public static TheoryData GetBoundedSlice_ErrorData = new TheoryData() + public static TheoryData GetBoundedSlice_ErrorData = new() { { 300, 100, -1, 91 }, { 300, 100, 110, 91 }, @@ -217,7 +217,7 @@ public void Clear() using MemoryGroup group = this.CreateTestGroup(100, 10, true); group.Clear(); - var expectedRow = new int[10]; + int[] expectedRow = new int[10]; foreach (Memory memory in group) { Assert.True(memory.Span.SequenceEqual(expectedRow)); diff --git a/tests/ImageSharp.Tests/Memory/DiscontiguousBuffers/MemoryGroupTestsBase.cs b/tests/ImageSharp.Tests/Memory/DiscontiguousBuffers/MemoryGroupTestsBase.cs index 8fe6ef3ddb..0eaebbfef5 100644 --- a/tests/ImageSharp.Tests/Memory/DiscontiguousBuffers/MemoryGroupTestsBase.cs +++ b/tests/ImageSharp.Tests/Memory/DiscontiguousBuffers/MemoryGroupTestsBase.cs @@ -7,7 +7,7 @@ namespace SixLabors.ImageSharp.Tests.Memory.DiscontiguousBuffers; public abstract class MemoryGroupTestsBase { - internal readonly TestMemoryAllocator MemoryAllocator = new TestMemoryAllocator(); + internal readonly TestMemoryAllocator MemoryAllocator = new(); /// /// Create a group, either uninitialized or filled with incrementing numbers starting with 1. @@ -15,7 +15,7 @@ public abstract class MemoryGroupTestsBase internal MemoryGroup CreateTestGroup(long totalLength, int bufferLength, bool fillSequence = false) { this.MemoryAllocator.BufferCapacityInBytes = bufferLength * sizeof(int); - var g = MemoryGroup.Allocate(this.MemoryAllocator, totalLength, bufferLength); + MemoryGroup g = MemoryGroup.Allocate(this.MemoryAllocator, totalLength, bufferLength); if (!fillSequence) { diff --git a/tests/ImageSharp.Tests/Memory/TestStructs.cs b/tests/ImageSharp.Tests/Memory/TestStructs.cs index ccbee5bd51..0fd823ee50 100644 --- a/tests/ImageSharp.Tests/Memory/TestStructs.cs +++ b/tests/ImageSharp.Tests/Memory/TestStructs.cs @@ -19,10 +19,10 @@ public Foo(int a, double b) internal static Foo[] CreateArray(int size) { - var result = new Foo[size]; + Foo[] result = new Foo[size]; for (int i = 0; i < size; i++) { - result[i] = new Foo(i + 1, i + 1); + result[i] = new(i + 1, i + 1); } return result; @@ -70,10 +70,10 @@ public AlignedFoo(int a, int b) internal static AlignedFoo[] CreateArray(int size) { - var result = new AlignedFoo[size]; + AlignedFoo[] result = new AlignedFoo[size]; for (int i = 0; i < size; i++) { - result[i] = new AlignedFoo(i + 1, i + 1); + result[i] = new(i + 1, i + 1); } return result; diff --git a/tests/ImageSharp.Tests/MemoryAllocatorValidator.cs b/tests/ImageSharp.Tests/MemoryAllocatorValidator.cs index 252784a7c5..395dfd455f 100644 --- a/tests/ImageSharp.Tests/MemoryAllocatorValidator.cs +++ b/tests/ImageSharp.Tests/MemoryAllocatorValidator.cs @@ -38,7 +38,7 @@ private static void MemoryDiagnostics_MemoryAllocated() public static TestMemoryDiagnostics MonitorAllocations() { - var diag = new TestMemoryDiagnostics(); + TestMemoryDiagnostics diag = new(); LocalInstance.Value = diag; return diag; } diff --git a/tests/ImageSharp.Tests/Metadata/ImageFrameMetadataTests.cs b/tests/ImageSharp.Tests/Metadata/ImageFrameMetadataTests.cs index cdd6f0cc4f..07a8a9fa7d 100644 --- a/tests/ImageSharp.Tests/Metadata/ImageFrameMetadataTests.cs +++ b/tests/ImageSharp.Tests/Metadata/ImageFrameMetadataTests.cs @@ -45,10 +45,10 @@ public void CloneIsDeep() ExifProfile exifProfile = new(); exifProfile.SetValue(ExifTag.Software, "UnitTest"); exifProfile.SetValue(ExifTag.Artist, "UnitTest"); - XmpProfile xmpProfile = new(Array.Empty()); + XmpProfile xmpProfile = new([]); IccProfile iccProfile = new() { - Header = new IccProfileHeader() + Header = new() { CmmType = "Unittest" } diff --git a/tests/ImageSharp.Tests/Metadata/ImageMetadataTests.cs b/tests/ImageSharp.Tests/Metadata/ImageMetadataTests.cs index ae02c3d57b..78290db639 100644 --- a/tests/ImageSharp.Tests/Metadata/ImageMetadataTests.cs +++ b/tests/ImageSharp.Tests/Metadata/ImageMetadataTests.cs @@ -36,7 +36,7 @@ public void CloneIsDeep() { ImageMetadata metaData = new() { - ExifProfile = new ExifProfile(), + ExifProfile = new(), HorizontalResolution = 4, VerticalResolution = 2 }; @@ -86,8 +86,8 @@ public void VerticalResolution() public void SyncProfiles() { ExifProfile exifProfile = new(); - exifProfile.SetValue(ExifTag.XResolution, new Rational(200)); - exifProfile.SetValue(ExifTag.YResolution, new Rational(300)); + exifProfile.SetValue(ExifTag.XResolution, new(200)); + exifProfile.SetValue(ExifTag.YResolution, new(300)); using Image image = new(1, 1); image.Metadata.ExifProfile = exifProfile; diff --git a/tests/ImageSharp.Tests/Metadata/Profiles/CICP/CicpProfileTests.cs b/tests/ImageSharp.Tests/Metadata/Profiles/CICP/CicpProfileTests.cs index 76e2d35c45..ff8b034c56 100644 --- a/tests/ImageSharp.Tests/Metadata/Profiles/CICP/CicpProfileTests.cs +++ b/tests/ImageSharp.Tests/Metadata/Profiles/CICP/CicpProfileTests.cs @@ -25,10 +25,10 @@ public async Task ReadCicpMetadata_FromPng_Works(TestImageProvider(1, 1); - var original = CreateCicpProfile(); + using Image image = new(1, 1); + CicpProfile original = CreateCicpProfile(); image.Metadata.CicpProfile = original; - var encoder = new PngEncoder(); + PngEncoder encoder = new(); // act using Image reloadedImage = WriteAndRead(image, encoder); @@ -49,7 +49,7 @@ private static void CicpProfileContainsExpectedValues(CicpProfile cicp) private static CicpProfile CreateCicpProfile() { - var profile = new CicpProfile() + CicpProfile profile = new() { ColorPrimaries = CicpColorPrimaries.ItuRBt2020_2, TransferCharacteristics = CicpTransferCharacteristics.SmpteSt2084, @@ -70,7 +70,7 @@ private static void CicpProfileIsValidAndEqual(CicpProfile actual, CicpProfile o private static Image WriteAndRead(Image image, IImageEncoder encoder) { - using (var memStream = new MemoryStream()) + using (MemoryStream memStream = new()) { image.Save(memStream, encoder); image.Dispose(); diff --git a/tests/ImageSharp.Tests/Metadata/Profiles/Exif/ExifProfileTests.cs b/tests/ImageSharp.Tests/Metadata/Profiles/Exif/ExifProfileTests.cs index 8072bebd77..18fdae8393 100644 --- a/tests/ImageSharp.Tests/Metadata/Profiles/Exif/ExifProfileTests.cs +++ b/tests/ImageSharp.Tests/Metadata/Profiles/Exif/ExifProfileTests.cs @@ -63,7 +63,7 @@ public void Constructor(TestImageWriteFormat imageFormat) Assert.Null(image.Metadata.ExifProfile); const string expected = "Dirk Lemstra"; - image.Metadata.ExifProfile = new ExifProfile(); + image.Metadata.ExifProfile = new(); image.Metadata.ExifProfile.SetValue(ExifTag.Copyright, expected); image = WriteAndRead(image, imageFormat); @@ -82,13 +82,13 @@ public void Constructor(TestImageWriteFormat imageFormat) public void ConstructorEmpty() { new ExifProfile(null); - new ExifProfile(Array.Empty()); + new ExifProfile([]); } [Fact] public void EmptyWriter() { - var profile = new ExifProfile() { Parts = ExifParts.GpsTags }; + ExifProfile profile = new() { Parts = ExifParts.GpsTags }; profile.SetValue(ExifTag.Copyright, "Copyright text"); byte[] bytes = profile.ToByteArray(); @@ -120,14 +120,14 @@ public void ConstructorCopy() [InlineData(TestImageWriteFormat.WebpLossy)] public void WriteFraction(TestImageWriteFormat imageFormat) { - using var memStream = new MemoryStream(); + using MemoryStream memStream = new(); double exposureTime = 1.0 / 1600; ExifProfile profile = GetExifProfile(); - profile.SetValue(ExifTag.ExposureTime, new Rational(exposureTime)); + profile.SetValue(ExifTag.ExposureTime, new(exposureTime)); - var image = new Image(1, 1); + Image image = new(1, 1); image.Metadata.ExifProfile = profile; image = WriteAndRead(image, imageFormat); @@ -142,7 +142,7 @@ public void WriteFraction(TestImageWriteFormat imageFormat) memStream.Position = 0; profile = GetExifProfile(); - profile.SetValue(ExifTag.ExposureTime, new Rational(exposureTime, true)); + profile.SetValue(ExifTag.ExposureTime, new(exposureTime, true)); image.Metadata.ExifProfile = profile; image = WriteAndRead(image, imageFormat); @@ -164,26 +164,26 @@ public void WriteFraction(TestImageWriteFormat imageFormat) public void ReadWriteInfinity(TestImageWriteFormat imageFormat) { Image image = TestFile.Create(TestImages.Jpeg.Baseline.Floorplan).CreateRgba32Image(); - image.Metadata.ExifProfile.SetValue(ExifTag.ExposureBiasValue, new SignedRational(double.PositiveInfinity)); + image.Metadata.ExifProfile.SetValue(ExifTag.ExposureBiasValue, new(double.PositiveInfinity)); image = WriteAndReadJpeg(image); IExifValue value = image.Metadata.ExifProfile.GetValue(ExifTag.ExposureBiasValue); Assert.NotNull(value); - Assert.Equal(new SignedRational(double.PositiveInfinity), value.Value); + Assert.Equal(new(double.PositiveInfinity), value.Value); - image.Metadata.ExifProfile.SetValue(ExifTag.ExposureBiasValue, new SignedRational(double.NegativeInfinity)); + image.Metadata.ExifProfile.SetValue(ExifTag.ExposureBiasValue, new(double.NegativeInfinity)); image = WriteAndRead(image, imageFormat); value = image.Metadata.ExifProfile.GetValue(ExifTag.ExposureBiasValue); Assert.NotNull(value); - Assert.Equal(new SignedRational(double.NegativeInfinity), value.Value); + Assert.Equal(new(double.NegativeInfinity), value.Value); - image.Metadata.ExifProfile.SetValue(ExifTag.FlashEnergy, new Rational(double.NegativeInfinity)); + image.Metadata.ExifProfile.SetValue(ExifTag.FlashEnergy, new(double.NegativeInfinity)); image = WriteAndRead(image, imageFormat); IExifValue value2 = image.Metadata.ExifProfile.GetValue(ExifTag.FlashEnergy); Assert.NotNull(value2); - Assert.Equal(new Rational(double.PositiveInfinity), value2.Value); + Assert.Equal(new(double.PositiveInfinity), value2.Value); image.Dispose(); } @@ -209,20 +209,20 @@ public void SetValue(TestImageWriteFormat imageFormat, int expectedProfileValueC Assert.True(software.TrySetValue(15)); Assert.False(software.TrySetValue(15F)); - image.Metadata.ExifProfile.SetValue(ExifTag.ShutterSpeedValue, new SignedRational(75.55)); + image.Metadata.ExifProfile.SetValue(ExifTag.ShutterSpeedValue, new(75.55)); IExifValue shutterSpeed = image.Metadata.ExifProfile.GetValue(ExifTag.ShutterSpeedValue); - Assert.Equal(new SignedRational(7555, 100), shutterSpeed.Value); + Assert.Equal(new(7555, 100), shutterSpeed.Value); Assert.False(shutterSpeed.TrySetValue(75)); - image.Metadata.ExifProfile.SetValue(ExifTag.XResolution, new Rational(150.0)); + image.Metadata.ExifProfile.SetValue(ExifTag.XResolution, new(150.0)); // We also need to change this value because this overrides XResolution when the image is written. image.Metadata.HorizontalResolution = 150.0; IExifValue xResolution = image.Metadata.ExifProfile.GetValue(ExifTag.XResolution); - Assert.Equal(new Rational(150, 1), xResolution.Value); + Assert.Equal(new(150, 1), xResolution.Value); Assert.False(xResolution.TrySetValue("ImageSharp")); @@ -231,7 +231,7 @@ public void SetValue(TestImageWriteFormat imageFormat, int expectedProfileValueC IExifValue referenceBlackWhite = image.Metadata.ExifProfile.GetValue(ExifTag.ReferenceBlackWhite); Assert.Null(referenceBlackWhite.Value); - var expectedLatitude = new Rational[] { new Rational(12.3), new Rational(4.56), new Rational(789.0) }; + Rational[] expectedLatitude = [new(12.3), new(4.56), new(789.0)]; image.Metadata.ExifProfile.SetValue(ExifTag.GPSLatitude, expectedLatitude); IExifValue latitude = image.Metadata.ExifProfile.GetValue(ExifTag.GPSLatitude); @@ -251,10 +251,10 @@ public void SetValue(TestImageWriteFormat imageFormat, int expectedProfileValueC Assert.Equal("15", software.Value); shutterSpeed = image.Metadata.ExifProfile.GetValue(ExifTag.ShutterSpeedValue); - Assert.Equal(new SignedRational(75.55), shutterSpeed.Value); + Assert.Equal(new(75.55), shutterSpeed.Value); xResolution = image.Metadata.ExifProfile.GetValue(ExifTag.XResolution); - Assert.Equal(new Rational(150.0), xResolution.Value); + Assert.Equal(new(150.0), xResolution.Value); referenceBlackWhite = image.Metadata.ExifProfile.GetValue(ExifTag.ReferenceBlackWhite, false); Assert.Null(referenceBlackWhite); @@ -308,11 +308,11 @@ public void RemoveEntry_Works() [Fact] public void Syncs() { - var exifProfile = new ExifProfile(); - exifProfile.SetValue(ExifTag.XResolution, new Rational(200)); - exifProfile.SetValue(ExifTag.YResolution, new Rational(300)); + ExifProfile exifProfile = new(); + exifProfile.SetValue(ExifTag.XResolution, new(200)); + exifProfile.SetValue(ExifTag.YResolution, new(300)); - var metaData = new ImageMetadata + ImageMetadata metaData = new() { ExifProfile = exifProfile, HorizontalResolution = 200, @@ -362,19 +362,19 @@ public void Values() [Fact] public void ReadWriteLargeProfileJpg() { - ExifTag[] tags = { ExifTag.Software, ExifTag.Copyright, ExifTag.Model, ExifTag.ImageDescription }; + ExifTag[] tags = [ExifTag.Software, ExifTag.Copyright, ExifTag.Model, ExifTag.ImageDescription]; foreach (ExifTag tag in tags) { // Arrange - var junk = new StringBuilder(); + StringBuilder junk = new(); for (int i = 0; i < 65600; i++) { junk.Append('a'); } - var image = new Image(100, 100); + Image image = new(100, 100); ExifProfile expectedProfile = CreateExifProfile(); - var expectedProfileTags = expectedProfile.Values.Select(x => x.Tag).ToList(); + List expectedProfileTags = expectedProfile.Values.Select(x => x.Tag).ToList(); expectedProfile.SetValue(tag, junk.ToString()); image.Metadata.ExifProfile = expectedProfile; @@ -437,7 +437,7 @@ public void TestArrayValueWithUnspecifiedSize() byte[] bytes = profile.ToByteArray(); Assert.Equal(531, bytes.Length); - var profile2 = new ExifProfile(bytes); + ExifProfile profile2 = new(bytes); Assert.Equal(25, profile2.Values.Count); } @@ -449,7 +449,7 @@ public void TestArrayValueWithUnspecifiedSize() public void WritingImagePreservesExifProfile(TestImageWriteFormat imageFormat) { // Arrange - var image = new Image(1, 1); + Image image = new(1, 1); image.Metadata.ExifProfile = CreateExifProfile(); // Act @@ -472,11 +472,11 @@ public void ProfileToByteArray() // Arrange byte[] exifBytesWithoutExifCode = ExifConstants.LittleEndianByteOrderMarker.ToArray(); ExifProfile expectedProfile = CreateExifProfile(); - var expectedProfileTags = expectedProfile.Values.Select(x => x.Tag).ToList(); + List expectedProfileTags = expectedProfile.Values.Select(x => x.Tag).ToList(); // Act byte[] actualBytes = expectedProfile.ToByteArray(); - var actualProfile = new ExifProfile(actualBytes); + ExifProfile actualProfile = new(actualBytes); // Assert Assert.NotNull(actualBytes); @@ -492,7 +492,7 @@ public void ProfileToByteArray() private static ExifProfile CreateExifProfile() { - var profile = new ExifProfile(); + ExifProfile profile = new(); foreach (KeyValuePair exifProfileValue in TestProfileValues) { @@ -505,7 +505,7 @@ private static ExifProfile CreateExifProfile() [Fact] public void IfdStructure() { - var exif = new ExifProfile(); + ExifProfile exif = new(); exif.SetValue(ExifTag.XPAuthor, "Dan Petitt"); Span actualBytes = exif.ToByteArray(); @@ -547,7 +547,7 @@ private static Image WriteAndRead(Image image, TestImageWriteFor private static Image WriteAndReadJpeg(Image image) { - using var memStream = new MemoryStream(); + using MemoryStream memStream = new(); image.SaveAsJpeg(memStream); image.Dispose(); @@ -557,7 +557,7 @@ private static Image WriteAndReadJpeg(Image image) private static Image WriteAndReadPng(Image image) { - using var memStream = new MemoryStream(); + using MemoryStream memStream = new(); image.SaveAsPng(memStream); image.Dispose(); @@ -567,8 +567,8 @@ private static Image WriteAndReadPng(Image image) private static Image WriteAndReadWebp(Image image, WebpFileFormatType fileFormat) { - using var memStream = new MemoryStream(); - image.SaveAsWebp(memStream, new WebpEncoder() { FileFormat = fileFormat }); + using MemoryStream memStream = new(); + image.SaveAsWebp(memStream, new() { FileFormat = fileFormat }); image.Dispose(); memStream.Position = 0; @@ -593,7 +593,7 @@ private static void TestProfile(ExifProfile profile) Assert.Equal("Windows Photo Editor 10.0.10011.16384", software.Value); IExifValue xResolution = profile.GetValue(ExifTag.XResolution); - Assert.Equal(new Rational(300.0), xResolution.Value); + Assert.Equal(new(300.0), xResolution.Value); IExifValue xDimension = profile.GetValue(ExifTag.PixelXDimension); Assert.Equal(2338U, xDimension.Value); diff --git a/tests/ImageSharp.Tests/Metadata/Profiles/Exif/ExifReaderTests.cs b/tests/ImageSharp.Tests/Metadata/Profiles/Exif/ExifReaderTests.cs index 8fe19b37de..bcd884ffa1 100644 --- a/tests/ImageSharp.Tests/Metadata/Profiles/Exif/ExifReaderTests.cs +++ b/tests/ImageSharp.Tests/Metadata/Profiles/Exif/ExifReaderTests.cs @@ -11,7 +11,7 @@ public class ExifReaderTests [Fact] public void Read_DataIsEmpty_ReturnsEmptyCollection() { - var reader = new ExifReader(Array.Empty()); + ExifReader reader = new([]); IList result = reader.ReadValues(); @@ -21,7 +21,7 @@ public void Read_DataIsEmpty_ReturnsEmptyCollection() [Fact] public void Read_DataIsMinimal_ReturnsEmptyCollection() { - var reader = new ExifReader(new byte[] { 69, 120, 105, 102, 0, 0 }); + ExifReader reader = new([69, 120, 105, 102, 0, 0]); IList result = reader.ReadValues(); diff --git a/tests/ImageSharp.Tests/Metadata/Profiles/Exif/ExifTagDescriptionAttributeTests.cs b/tests/ImageSharp.Tests/Metadata/Profiles/Exif/ExifTagDescriptionAttributeTests.cs index 1154b3439c..3f13afa6fc 100644 --- a/tests/ImageSharp.Tests/Metadata/Profiles/Exif/ExifTagDescriptionAttributeTests.cs +++ b/tests/ImageSharp.Tests/Metadata/Profiles/Exif/ExifTagDescriptionAttributeTests.cs @@ -12,7 +12,7 @@ public class ExifTagDescriptionAttributeTests [Fact] public void TestExifTag() { - var exifProfile = new ExifProfile(); + ExifProfile exifProfile = new(); exifProfile.SetValue(ExifTag.ResolutionUnit, (ushort)1); IExifValue value = exifProfile.GetValue(ExifTag.ResolutionUnit); diff --git a/tests/ImageSharp.Tests/Metadata/Profiles/Exif/Values/ExifValuesTests.cs b/tests/ImageSharp.Tests/Metadata/Profiles/Exif/Values/ExifValuesTests.cs index 99cafa8960..4d733a8ebf 100644 --- a/tests/ImageSharp.Tests/Metadata/Profiles/Exif/Values/ExifValuesTests.cs +++ b/tests/ImageSharp.Tests/Metadata/Profiles/Exif/Values/ExifValuesTests.cs @@ -9,14 +9,14 @@ namespace SixLabors.ImageSharp.Tests.Metadata.Profiles.Exif.Values; [Trait("Profile", "Exif")] public class ExifValuesTests { - public static TheoryData ByteTags => new TheoryData + public static TheoryData ByteTags => new() { { ExifTag.FaxProfile }, { ExifTag.ModeNumber }, { ExifTag.GPSAltitudeRef } }; - public static TheoryData ByteArrayTags => new TheoryData + public static TheoryData ByteArrayTags => new() { { ExifTag.ClipPath }, { ExifTag.VersionYear }, @@ -26,7 +26,7 @@ public class ExifValuesTests { ExifTag.GPSVersionID }, }; - public static TheoryData DoubleArrayTags => new TheoryData + public static TheoryData DoubleArrayTags => new() { { ExifTag.PixelScale }, { ExifTag.IntergraphMatrix }, @@ -34,7 +34,7 @@ public class ExifValuesTests { ExifTag.ModelTransform } }; - public static TheoryData LongTags => new TheoryData + public static TheoryData LongTags => new() { { ExifTag.SubfileType }, { ExifTag.SubIFDOffset }, @@ -59,7 +59,7 @@ public class ExifValuesTests { ExifTag.ImageNumber }, }; - public static TheoryData LongArrayTags => new TheoryData + public static TheoryData LongArrayTags => new() { { ExifTag.FreeOffsets }, { ExifTag.FreeByteCounts }, @@ -73,7 +73,7 @@ public class ExifValuesTests { ExifTag.IntergraphRegisters } }; - public static TheoryData NumberTags => new TheoryData + public static TheoryData NumberTags => new() { { ExifTag.ImageWidth }, { ExifTag.ImageLength }, @@ -85,7 +85,7 @@ public class ExifValuesTests { ExifTag.PixelYDimension } }; - public static TheoryData NumberArrayTags => new TheoryData + public static TheoryData NumberArrayTags => new() { { ExifTag.StripOffsets }, { ExifTag.StripByteCounts }, @@ -94,7 +94,7 @@ public class ExifValuesTests { ExifTag.ImageLayer } }; - public static TheoryData RationalTags => new TheoryData + public static TheoryData RationalTags => new() { { ExifTag.XPosition }, { ExifTag.YPosition }, @@ -131,7 +131,7 @@ public class ExifValuesTests { ExifTag.GPSHPositioningError }, }; - public static TheoryData RationalArrayTags => new TheoryData + public static TheoryData RationalArrayTags => new() { { ExifTag.WhitePoint }, { ExifTag.PrimaryChromaticities }, @@ -145,7 +145,7 @@ public class ExifValuesTests { ExifTag.LensSpecification } }; - public static TheoryData ShortTags => new TheoryData + public static TheoryData ShortTags => new() { { ExifTag.OldSubfileType }, { ExifTag.Compression }, @@ -196,7 +196,7 @@ public class ExifValuesTests { ExifTag.GPSDifferential } }; - public static TheoryData ShortArrayTags => new TheoryData + public static TheoryData ShortArrayTags => new() { { ExifTag.BitsPerSample }, { ExifTag.MinSampleValue }, @@ -220,7 +220,7 @@ public class ExifValuesTests { ExifTag.SubjectLocation } }; - public static TheoryData SignedRationalTags => new TheoryData + public static TheoryData SignedRationalTags => new() { { ExifTag.ShutterSpeedValue }, { ExifTag.BrightnessValue }, @@ -230,17 +230,17 @@ public class ExifValuesTests { ExifTag.CameraElevationAngle } }; - public static TheoryData SignedRationalArrayTags => new TheoryData + public static TheoryData SignedRationalArrayTags => new() { { ExifTag.Decode } }; - public static TheoryData SignedShortArrayTags => new TheoryData + public static TheoryData SignedShortArrayTags => new() { { ExifTag.TimeZoneOffset } }; - public static TheoryData StringTags => new TheoryData + public static TheoryData StringTags => new() { { ExifTag.ImageDescription }, { ExifTag.Make }, @@ -298,13 +298,13 @@ public class ExifValuesTests { ExifTag.GPSDateStamp }, }; - public static TheoryData UndefinedTags => new TheoryData + public static TheoryData UndefinedTags => new() { { ExifTag.FileSource }, { ExifTag.SceneType } }; - public static TheoryData UndefinedArrayTags => new TheoryData + public static TheoryData UndefinedArrayTags => new() { { ExifTag.JPEGTables }, { ExifTag.OECF }, @@ -320,14 +320,14 @@ public class ExifValuesTests { ExifTag.ImageSourceData }, }; - public static TheoryData EncodedStringTags => new TheoryData + public static TheoryData EncodedStringTags => new() { { ExifTag.UserComment }, { ExifTag.GPSProcessingMethod }, { ExifTag.GPSAreaInformation } }; - public static TheoryData Ucs2StringTags => new TheoryData + public static TheoryData Ucs2StringTags => new() { { ExifTag.XPTitle }, { ExifTag.XPComment }, @@ -347,7 +347,7 @@ public void ExifByteTests(ExifTag tag) Assert.True(value.TrySetValue((int)expected)); Assert.True(value.TrySetValue(expected)); - var typed = (ExifByte)value; + ExifByte typed = (ExifByte)value; Assert.Equal(expected, typed.Value); } @@ -355,13 +355,13 @@ public void ExifByteTests(ExifTag tag) [MemberData(nameof(ByteArrayTags))] public void ExifByteArrayTests(ExifTag tag) { - byte[] expected = new[] { byte.MaxValue }; + byte[] expected = [byte.MaxValue]; ExifValue value = ExifValues.Create(tag); Assert.False(value.TrySetValue(expected.ToString())); Assert.True(value.TrySetValue(expected)); - var typed = (ExifByteArray)value; + ExifByteArray typed = (ExifByteArray)value; Assert.Equal(expected, typed.Value); } @@ -369,13 +369,13 @@ public void ExifByteArrayTests(ExifTag tag) [MemberData(nameof(DoubleArrayTags))] public void ExifDoubleArrayTests(ExifTag tag) { - double[] expected = new[] { double.MaxValue }; + double[] expected = [double.MaxValue]; ExifValue value = ExifValues.Create(tag); Assert.False(value.TrySetValue(expected.ToString())); Assert.True(value.TrySetValue(expected)); - var typed = (ExifDoubleArray)value; + ExifDoubleArray typed = (ExifDoubleArray)value; Assert.Equal(expected, typed.Value); } @@ -389,7 +389,7 @@ public void ExifLongTests(ExifTag tag) Assert.False(value.TrySetValue(expected.ToString())); Assert.True(value.TrySetValue(expected)); - var typed = (ExifLong)value; + ExifLong typed = (ExifLong)value; Assert.Equal(expected, typed.Value); } @@ -397,13 +397,13 @@ public void ExifLongTests(ExifTag tag) [MemberData(nameof(LongArrayTags))] public void ExifLongArrayTests(ExifTag tag) { - uint[] expected = new[] { uint.MaxValue }; + uint[] expected = [uint.MaxValue]; ExifValue value = ExifValues.Create(tag); Assert.False(value.TrySetValue(expected.ToString())); Assert.True(value.TrySetValue(expected)); - var typed = (ExifLongArray)value; + ExifLongArray typed = (ExifLongArray)value; Assert.Equal(expected, typed.Value); } @@ -447,7 +447,7 @@ public void ExifNumberTests(ExifTag tag) Assert.True(value.TrySetValue((int)expected)); Assert.True(value.TrySetValue(expected)); - var typed = (ExifNumber)value; + ExifNumber typed = (ExifNumber)value; Assert.Equal(expected, typed.Value); typed.Value = ushort.MaxValue + 1; @@ -458,13 +458,13 @@ public void ExifNumberTests(ExifTag tag) [MemberData(nameof(NumberArrayTags))] public void ExifNumberArrayTests(ExifTag tag) { - Number[] expected = new[] { new Number(uint.MaxValue) }; + Number[] expected = [new(uint.MaxValue)]; ExifValue value = ExifValues.Create(tag); Assert.False(value.TrySetValue(expected.ToString())); Assert.True(value.TrySetValue(expected)); - var typed = (ExifNumberArray)value; + ExifNumberArray typed = (ExifNumberArray)value; Assert.Equal(expected, typed.Value); Assert.True(value.TrySetValue(int.MaxValue)); @@ -481,14 +481,14 @@ public void ExifNumberArrayTests(ExifTag tag) [MemberData(nameof(RationalTags))] public void ExifRationalTests(ExifTag tag) { - var expected = new Rational(21, 42); + Rational expected = new(21, 42); ExifValue value = ExifValues.Create(tag); Assert.False(value.TrySetValue(expected.ToString())); Assert.True(value.TrySetValue(new SignedRational(expected.ToDouble()))); Assert.True(value.TrySetValue(expected)); - var typed = (ExifRational)value; + ExifRational typed = (ExifRational)value; Assert.Equal(expected, typed.Value); } @@ -496,13 +496,13 @@ public void ExifRationalTests(ExifTag tag) [MemberData(nameof(RationalArrayTags))] public void ExifRationalArrayTests(ExifTag tag) { - Rational[] expected = new[] { new Rational(21, 42) }; + Rational[] expected = [new(21, 42)]; ExifValue value = ExifValues.Create(tag); Assert.False(value.TrySetValue(expected.ToString())); Assert.True(value.TrySetValue(expected)); - var typed = (ExifRationalArray)value; + ExifRationalArray typed = (ExifRationalArray)value; Assert.Equal(expected, typed.Value); } @@ -518,7 +518,7 @@ public void ExifShortTests(ExifTag tag) Assert.True(value.TrySetValue((short)expected)); Assert.True(value.TrySetValue(expected)); - var typed = (ExifShort)value; + ExifShort typed = (ExifShort)value; Assert.Equal(expected, typed.Value); } @@ -526,13 +526,13 @@ public void ExifShortTests(ExifTag tag) [MemberData(nameof(ShortArrayTags))] public void ExifShortArrayTests(ExifTag tag) { - ushort[] expected = new[] { ushort.MaxValue }; + ushort[] expected = [ushort.MaxValue]; ExifValue value = ExifValues.Create(tag); Assert.False(value.TrySetValue(expected.ToString())); Assert.True(value.TrySetValue(expected)); - var typed = (ExifShortArray)value; + ExifShortArray typed = (ExifShortArray)value; Assert.Equal(expected, typed.Value); } @@ -540,13 +540,13 @@ public void ExifShortArrayTests(ExifTag tag) [MemberData(nameof(SignedRationalTags))] public void ExifSignedRationalTests(ExifTag tag) { - var expected = new SignedRational(21, 42); + SignedRational expected = new(21, 42); ExifValue value = ExifValues.Create(tag); Assert.False(value.TrySetValue(expected.ToString())); Assert.True(value.TrySetValue(expected)); - var typed = (ExifSignedRational)value; + ExifSignedRational typed = (ExifSignedRational)value; Assert.Equal(expected, typed.Value); } @@ -554,13 +554,13 @@ public void ExifSignedRationalTests(ExifTag tag) [MemberData(nameof(SignedRationalArrayTags))] public void ExifSignedRationalArrayTests(ExifTag tag) { - SignedRational[] expected = new[] { new SignedRational(21, 42) }; + SignedRational[] expected = [new(21, 42)]; ExifValue value = ExifValues.Create(tag); Assert.False(value.TrySetValue(expected.ToString())); Assert.True(value.TrySetValue(expected)); - var typed = (ExifSignedRationalArray)value; + ExifSignedRationalArray typed = (ExifSignedRationalArray)value; Assert.Equal(expected, typed.Value); } @@ -569,13 +569,13 @@ public void ExifSignedRationalArrayTests(ExifTag tag) [MemberData(nameof(SignedShortArrayTags))] public void ExifSignedShortArrayTests(ExifTag tag) { - short[] expected = new short[] { 21, 42 }; + short[] expected = [21, 42]; ExifValue value = ExifValues.Create(tag); Assert.False(value.TrySetValue(expected.ToString())); Assert.True(value.TrySetValue(expected)); - var typed = (ExifSignedShortArray)value; + ExifSignedShortArray typed = (ExifSignedShortArray)value; Assert.Equal(expected, typed.Value); } @@ -589,7 +589,7 @@ public void ExifStringTests(ExifTag tag) Assert.False(value.TrySetValue(0M)); Assert.True(value.TrySetValue(expected)); - var typed = (ExifString)value; + ExifString typed = (ExifString)value; Assert.Equal(expected, typed.Value); } @@ -604,7 +604,7 @@ public void ExifUndefinedTests(ExifTag tag) Assert.True(value.TrySetValue((int)expected)); Assert.True(value.TrySetValue(expected)); - var typed = (ExifByte)value; + ExifByte typed = (ExifByte)value; Assert.Equal(expected, typed.Value); } @@ -612,13 +612,13 @@ public void ExifUndefinedTests(ExifTag tag) [MemberData(nameof(UndefinedArrayTags))] public void ExifUndefinedArrayTests(ExifTag tag) { - byte[] expected = new[] { byte.MaxValue }; + byte[] expected = [byte.MaxValue]; ExifValue value = ExifValues.Create(tag); Assert.False(value.TrySetValue(expected.ToString())); Assert.True(value.TrySetValue(expected)); - var typed = (ExifByteArray)value; + ExifByteArray typed = (ExifByteArray)value; Assert.Equal(expected, typed.Value); } @@ -628,18 +628,18 @@ public void ExifEncodedStringTests(ExifTag tag) { foreach (object code in Enum.GetValues(typeof(EncodedString.CharacterCode))) { - var charCode = (EncodedString.CharacterCode)code; + EncodedString.CharacterCode charCode = (EncodedString.CharacterCode)code; Assert.Equal(ExifEncodedStringHelpers.CharacterCodeBytesLength, ExifEncodedStringHelpers.GetCodeBytes(charCode).Length); const string expectedText = "test string"; - var expected = new EncodedString(charCode, expectedText); + EncodedString expected = new(charCode, expectedText); ExifValue value = ExifValues.Create(tag); Assert.False(value.TrySetValue(123)); Assert.True(value.TrySetValue(expected)); - var typed = (ExifEncodedString)value; + ExifEncodedString typed = (ExifEncodedString)value; Assert.Equal(expected, typed.Value); Assert.Equal(expectedText, (string)typed.Value); Assert.Equal(charCode, typed.Value.Code); @@ -656,7 +656,7 @@ public void ExifUcs2StringTests(ExifTag tag) Assert.False(value.TrySetValue(123)); Assert.True(value.TrySetValue(expected)); - var typed = (ExifUcs2String)value; + ExifUcs2String typed = (ExifUcs2String)value; Assert.Equal(expected, typed.Value); Assert.True(value.TrySetValue(Encoding.GetEncoding("UCS-2").GetBytes(expected))); diff --git a/tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataReader/IccDataReaderCurvesTests.cs b/tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataReader/IccDataReaderCurvesTests.cs index 73ae46c2c9..c88a3d5ace 100644 --- a/tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataReader/IccDataReaderCurvesTests.cs +++ b/tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataReader/IccDataReaderCurvesTests.cs @@ -76,6 +76,6 @@ internal void ReadSampledCurveElement(byte[] data, IccSampledCurveElement expect private static IccDataReader CreateReader(byte[] data) { - return new IccDataReader(data); + return new(data); } } diff --git a/tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataReader/IccDataReaderLutTests.cs b/tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataReader/IccDataReaderLutTests.cs index 63585a3bd4..78555a7a26 100644 --- a/tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataReader/IccDataReaderLutTests.cs +++ b/tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataReader/IccDataReaderLutTests.cs @@ -76,6 +76,6 @@ internal void ReadLut16(byte[] data, IccLut expected, int count) private static IccDataReader CreateReader(byte[] data) { - return new IccDataReader(data); + return new(data); } } diff --git a/tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataReader/IccDataReaderMatrixTests.cs b/tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataReader/IccDataReaderMatrixTests.cs index b81395bb2e..b5abc59f72 100644 --- a/tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataReader/IccDataReaderMatrixTests.cs +++ b/tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataReader/IccDataReaderMatrixTests.cs @@ -32,6 +32,6 @@ public void ReadMatrix1D(byte[] data, int yCount, bool isSingle, float[] expecte private static IccDataReader CreateReader(byte[] data) { - return new IccDataReader(data); + return new(data); } } diff --git a/tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataReader/IccDataReaderMultiProcessElementTests.cs b/tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataReader/IccDataReaderMultiProcessElementTests.cs index 9023b1b723..6f924374e1 100644 --- a/tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataReader/IccDataReaderMultiProcessElementTests.cs +++ b/tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataReader/IccDataReaderMultiProcessElementTests.cs @@ -54,6 +54,6 @@ internal void ReadClutProcessElement(byte[] data, IccClutProcessElement expected private static IccDataReader CreateReader(byte[] data) { - return new IccDataReader(data); + return new(data); } } diff --git a/tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataReader/IccDataReaderNonPrimitivesTests.cs b/tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataReader/IccDataReaderNonPrimitivesTests.cs index 91294a3dab..8bc6324eaf 100644 --- a/tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataReader/IccDataReaderNonPrimitivesTests.cs +++ b/tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataReader/IccDataReaderNonPrimitivesTests.cs @@ -121,6 +121,6 @@ internal void ReadScreeningChannel(byte[] data, IccScreeningChannel expected) private static IccDataReader CreateReader(byte[] data) { - return new IccDataReader(data); + return new(data); } } diff --git a/tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataReader/IccDataReaderPrimitivesTests.cs b/tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataReader/IccDataReaderPrimitivesTests.cs index b6135cd197..ca095e6eb0 100644 --- a/tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataReader/IccDataReaderPrimitivesTests.cs +++ b/tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataReader/IccDataReaderPrimitivesTests.cs @@ -81,6 +81,6 @@ public void ReadUFix8(byte[] data, float expected) private static IccDataReader CreateReader(byte[] data) { - return new IccDataReader(data); + return new(data); } } diff --git a/tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataReader/IccDataReaderTagDataEntryTests.cs b/tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataReader/IccDataReaderTagDataEntryTests.cs index d41707b7ce..b0fe526221 100644 --- a/tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataReader/IccDataReaderTagDataEntryTests.cs +++ b/tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataReader/IccDataReaderTagDataEntryTests.cs @@ -441,6 +441,6 @@ internal void ReadUcrBgTagDataEntry(byte[] data, IccUcrBgTagDataEntry expected, private static IccDataReader CreateReader(byte[] data) { - return new IccDataReader(data); + return new(data); } } diff --git a/tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataWriter/IccDataWriterCurvesTests.cs b/tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataWriter/IccDataWriterCurvesTests.cs index 1a23c8d002..23ccb4b067 100644 --- a/tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataWriter/IccDataWriterCurvesTests.cs +++ b/tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataWriter/IccDataWriterCurvesTests.cs @@ -82,6 +82,6 @@ internal void WriteSampledCurveElement(byte[] expected, IccSampledCurveElement d private static IccDataWriter CreateWriter() { - return new IccDataWriter(); + return new(); } } diff --git a/tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataWriter/IccDataWriterLutTests.cs b/tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataWriter/IccDataWriterLutTests.cs index 4a3dc48bcb..485e4069f7 100644 --- a/tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataWriter/IccDataWriterLutTests.cs +++ b/tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataWriter/IccDataWriterLutTests.cs @@ -82,6 +82,6 @@ internal void WriteLut16(byte[] expected, IccLut data, int count) private static IccDataWriter CreateWriter() { - return new IccDataWriter(); + return new(); } } diff --git a/tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataWriter/IccDataWriterLutTests1.cs b/tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataWriter/IccDataWriterLutTests1.cs index 1973d94b89..9d4f8f3b3d 100644 --- a/tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataWriter/IccDataWriterLutTests1.cs +++ b/tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataWriter/IccDataWriterLutTests1.cs @@ -82,6 +82,6 @@ internal void WriteLut16(byte[] expected, IccLut data, int count) private static IccDataWriter CreateWriter() { - return new IccDataWriter(); + return new(); } } diff --git a/tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataWriter/IccDataWriterLutTests2.cs b/tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataWriter/IccDataWriterLutTests2.cs index 4ffc9e0c36..3ecc871278 100644 --- a/tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataWriter/IccDataWriterLutTests2.cs +++ b/tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataWriter/IccDataWriterLutTests2.cs @@ -82,6 +82,6 @@ internal void WriteLut16(byte[] expected, IccLut data, int count) private static IccDataWriter CreateWriter() { - return new IccDataWriter(); + return new(); } } diff --git a/tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataWriter/IccDataWriterMatrixTests.cs b/tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataWriter/IccDataWriterMatrixTests.cs index 7d046aa49b..68ed2a70d4 100644 --- a/tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataWriter/IccDataWriterMatrixTests.cs +++ b/tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataWriter/IccDataWriterMatrixTests.cs @@ -71,6 +71,6 @@ public void WriteMatrix1D_Vector3(byte[] expected, int yCount, bool isSingle, Ve private static IccDataWriter CreateWriter() { - return new IccDataWriter(); + return new(); } } diff --git a/tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataWriter/IccDataWriterMultiProcessElementTests.cs b/tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataWriter/IccDataWriterMultiProcessElementTests.cs index ba2add5eb9..34b0674559 100644 --- a/tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataWriter/IccDataWriterMultiProcessElementTests.cs +++ b/tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataWriter/IccDataWriterMultiProcessElementTests.cs @@ -58,6 +58,6 @@ internal void WriteClutProcessElement(byte[] expected, IccClutProcessElement dat private static IccDataWriter CreateWriter() { - return new IccDataWriter(); + return new(); } } diff --git a/tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataWriter/IccDataWriterNonPrimitivesTests.cs b/tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataWriter/IccDataWriterNonPrimitivesTests.cs index b17ed44419..048c17f7be 100644 --- a/tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataWriter/IccDataWriterNonPrimitivesTests.cs +++ b/tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataWriter/IccDataWriterNonPrimitivesTests.cs @@ -119,6 +119,6 @@ internal void WriteScreeningChannel(byte[] expected, IccScreeningChannel data) private static IccDataWriter CreateWriter() { - return new IccDataWriter(); + return new(); } } diff --git a/tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataWriter/IccDataWriterPrimitivesTests.cs b/tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataWriter/IccDataWriterPrimitivesTests.cs index fbe8fe1ced..69ab80ab16 100644 --- a/tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataWriter/IccDataWriterPrimitivesTests.cs +++ b/tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataWriter/IccDataWriterPrimitivesTests.cs @@ -41,7 +41,7 @@ public void WriteAsciiStringWithNullWritesEmpty() byte[] output = writer.GetData(); Assert.Equal(0, count); - Assert.Equal(Array.Empty(), output); + Assert.Equal([], output); } [Fact] @@ -61,7 +61,7 @@ public void WriteUnicodeStringWithNullWritesEmpty() byte[] output = writer.GetData(); Assert.Equal(0, count); - Assert.Equal(Array.Empty(), output); + Assert.Equal([], output); } [Theory] @@ -114,6 +114,6 @@ public void WriteUFix8(byte[] expected, float data) private static IccDataWriter CreateWriter() { - return new IccDataWriter(); + return new(); } } diff --git a/tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataWriter/IccDataWriterTagDataEntryTests.cs b/tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataWriter/IccDataWriterTagDataEntryTests.cs index 7eda24c8cf..315b79dd27 100644 --- a/tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataWriter/IccDataWriterTagDataEntryTests.cs +++ b/tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataWriter/IccDataWriterTagDataEntryTests.cs @@ -406,6 +406,6 @@ internal void WriteUcrBgTagDataEntry(byte[] expected, IccUcrBgTagDataEntry data, private static IccDataWriter CreateWriter() { - return new IccDataWriter(); + return new(); } } diff --git a/tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataWriter/IccDataWriterTests.cs b/tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataWriter/IccDataWriterTests.cs index 205941fcec..3ca3c6bdbd 100644 --- a/tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataWriter/IccDataWriterTests.cs +++ b/tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataWriter/IccDataWriterTests.cs @@ -107,6 +107,6 @@ public void WriteArrayUInt64(byte[] expected, ulong[] data) private static IccDataWriter CreateWriter() { - return new IccDataWriter(); + return new(); } } diff --git a/tests/ImageSharp.Tests/Metadata/Profiles/ICC/IccProfileTests.cs b/tests/ImageSharp.Tests/Metadata/Profiles/ICC/IccProfileTests.cs index fbbea97fb3..c50afb2c4e 100644 --- a/tests/ImageSharp.Tests/Metadata/Profiles/ICC/IccProfileTests.cs +++ b/tests/ImageSharp.Tests/Metadata/Profiles/ICC/IccProfileTests.cs @@ -21,7 +21,7 @@ public void CalculateHash_WithByteArray_CalculatesProfileHash(byte[] data, IccPr public void CalculateHash_WithByteArray_DoesNotModifyData() { byte[] data = IccTestDataProfiles.Profile_Random_Array; - var copy = new byte[data.Length]; + byte[] copy = new byte[data.Length]; Buffer.BlockCopy(data, 0, copy, 0, data.Length); IccProfile.CalculateHash(data); @@ -33,7 +33,7 @@ public void CalculateHash_WithByteArray_DoesNotModifyData() [MemberData(nameof(IccTestDataProfiles.ProfileValidityTestData), MemberType = typeof(IccTestDataProfiles))] public void CheckIsValid_WithProfiles_ReturnsValidity(byte[] data, bool expected) { - var profile = new IccProfile(data); + IccProfile profile = new(data); bool result = profile.CheckIsValid(); diff --git a/tests/ImageSharp.Tests/Metadata/Profiles/ICC/IccReaderTests.cs b/tests/ImageSharp.Tests/Metadata/Profiles/ICC/IccReaderTests.cs index 9b2ca2a275..9965f1495e 100644 --- a/tests/ImageSharp.Tests/Metadata/Profiles/ICC/IccReaderTests.cs +++ b/tests/ImageSharp.Tests/Metadata/Profiles/ICC/IccReaderTests.cs @@ -52,6 +52,6 @@ public void ReadProfile_DuplicateEntry() private IccReader CreateReader() { - return new IccReader(); + return new(); } } diff --git a/tests/ImageSharp.Tests/Metadata/Profiles/ICC/IccWriterTests.cs b/tests/ImageSharp.Tests/Metadata/Profiles/ICC/IccWriterTests.cs index 89b63b7dcc..6763609976 100644 --- a/tests/ImageSharp.Tests/Metadata/Profiles/ICC/IccWriterTests.cs +++ b/tests/ImageSharp.Tests/Metadata/Profiles/ICC/IccWriterTests.cs @@ -13,7 +13,7 @@ public void WriteProfile_NoEntries() { IccWriter writer = this.CreateWriter(); - var profile = new IccProfile + IccProfile profile = new() { Header = IccTestDataProfiles.Header_Random_Write }; @@ -34,6 +34,6 @@ public void WriteProfile_DuplicateEntry() private IccWriter CreateWriter() { - return new IccWriter(); + return new(); } } diff --git a/tests/ImageSharp.Tests/Metadata/Profiles/ICC/Various/IccProfileIdTests.cs b/tests/ImageSharp.Tests/Metadata/Profiles/ICC/Various/IccProfileIdTests.cs index 968fa86c4e..5af672c210 100644 --- a/tests/ImageSharp.Tests/Metadata/Profiles/ICC/Various/IccProfileIdTests.cs +++ b/tests/ImageSharp.Tests/Metadata/Profiles/ICC/Various/IccProfileIdTests.cs @@ -19,7 +19,7 @@ public void ZeroIsEqualToDefault() [Fact] public void SetIsTrueWhenNonDefaultValue() { - var id = new IccProfileId(1, 2, 3, 4); + IccProfileId id = new(1, 2, 3, 4); Assert.True(id.IsSet); diff --git a/tests/ImageSharp.Tests/Metadata/Profiles/IPTC/IptcProfileTests.cs b/tests/ImageSharp.Tests/Metadata/Profiles/IPTC/IptcProfileTests.cs index 1a52ade629..9965acb24a 100644 --- a/tests/ImageSharp.Tests/Metadata/Profiles/IPTC/IptcProfileTests.cs +++ b/tests/ImageSharp.Tests/Metadata/Profiles/IPTC/IptcProfileTests.cs @@ -14,7 +14,7 @@ public static IEnumerable AllIptcTags() { foreach (object tag in Enum.GetValues(typeof(IptcTag))) { - yield return new object[] { tag }; + yield return [tag]; } } @@ -22,10 +22,10 @@ public static IEnumerable AllIptcTags() public void IptcProfile_WithUtf8Data_WritesEnvelopeRecord_Works() { // arrange - var profile = new IptcProfile(); + IptcProfile profile = new(); profile.SetValue(IptcTag.City, "ESPAÑA"); profile.UpdateData(); - byte[] expectedEnvelopeData = { 28, 1, 90, 0, 3, 27, 37, 71 }; + byte[] expectedEnvelopeData = [28, 1, 90, 0, 3, 27, 37, 71]; // act byte[] profileBytes = profile.Data; @@ -39,7 +39,7 @@ public void IptcProfile_WithUtf8Data_WritesEnvelopeRecord_Works() public void IptcProfile_SetValue_WithStrictEnabled_Works(IptcTag tag) { // arrange - var profile = new IptcProfile(); + IptcProfile profile = new(); string value = new('s', tag.MaxLength() + 1); int expectedLength = tag.MaxLength(); @@ -56,7 +56,7 @@ public void IptcProfile_SetValue_WithStrictEnabled_Works(IptcTag tag) public void IptcProfile_SetValue_WithStrictDisabled_Works(IptcTag tag) { // arrange - var profile = new IptcProfile(); + IptcProfile profile = new(); string value = new('s', tag.MaxLength() + 1); int expectedLength = value.Length; @@ -77,8 +77,8 @@ public void IptcProfile_SetValue_WithStrictDisabled_Works(IptcTag tag) public void IptcProfile_SetDateValue_Works(IptcTag tag) { // arrange - var profile = new IptcProfile(); - var datetime = new DateTimeOffset(new DateTime(1994, 3, 17)); + IptcProfile profile = new(); + DateTimeOffset datetime = new(new(1994, 3, 17)); // act profile.SetDateTimeValue(tag, datetime); @@ -96,8 +96,8 @@ public void IptcProfile_SetDateValue_Works(IptcTag tag) public void IptcProfile_SetTimeValue_Works(IptcTag tag) { // arrange - var profile = new IptcProfile(); - var dateTimeUtc = new DateTime(1994, 3, 17, 14, 15, 16, DateTimeKind.Utc); + IptcProfile profile = new(); + DateTime dateTimeUtc = new(1994, 3, 17, 14, 15, 16, DateTimeKind.Utc); DateTimeOffset dateTimeOffset = new DateTimeOffset(dateTimeUtc).ToOffset(TimeSpan.FromHours(2)); // act @@ -116,7 +116,7 @@ public void ReadIptcMetadata_FromJpg_Works(TestImageProvider pro using (Image image = provider.GetImage(JpegDecoder.Instance)) { Assert.NotNull(image.Metadata.IptcProfile); - var iptcValues = image.Metadata.IptcProfile.Values.ToList(); + List iptcValues = image.Metadata.IptcProfile.Values.ToList(); IptcProfileContainsExpectedValues(iptcValues); } } @@ -130,7 +130,7 @@ public void ReadIptcMetadata_FromTiff_Works(TestImageProvider pr { IptcProfile iptc = image.Frames.RootFrame.Metadata.IptcProfile; Assert.NotNull(iptc); - var iptcValues = iptc.Values.ToList(); + List iptcValues = iptc.Values.ToList(); IptcProfileContainsExpectedValues(iptcValues); } } @@ -170,7 +170,7 @@ public void ReadApp13_WithEmptyIptc_Works(TestImageProvider prov public void IptcProfile_ToAndFromByteArray_Works() { // arrange - var profile = new IptcProfile(); + IptcProfile profile = new(); const string expectedCaptionWriter = "unittest"; const string expectedCaption = "test"; profile.SetValue(IptcTag.CaptionWriter, expectedCaptionWriter); @@ -179,10 +179,10 @@ public void IptcProfile_ToAndFromByteArray_Works() // act profile.UpdateData(); byte[] profileBytes = profile.Data; - var profileFromBytes = new IptcProfile(profileBytes); + IptcProfile profileFromBytes = new(profileBytes); // assert - var iptcValues = profileFromBytes.Values.ToList(); + List iptcValues = profileFromBytes.Values.ToList(); ContainsIptcValue(iptcValues, IptcTag.CaptionWriter, expectedCaptionWriter); ContainsIptcValue(iptcValues, IptcTag.Caption, expectedCaption); } @@ -191,7 +191,7 @@ public void IptcProfile_ToAndFromByteArray_Works() public void IptcProfile_CloneIsDeep() { // arrange - var profile = new IptcProfile(); + IptcProfile profile = new(); const string captionWriter = "unittest"; const string caption = "test"; profile.SetValue(IptcTag.CaptionWriter, captionWriter); @@ -203,7 +203,7 @@ public void IptcProfile_CloneIsDeep() // assert Assert.Equal(2, clone.Values.Count()); - var cloneValues = clone.Values.ToList(); + List cloneValues = clone.Values.ToList(); ContainsIptcValue(cloneValues, IptcTag.CaptionWriter, captionWriter); ContainsIptcValue(cloneValues, IptcTag.Caption, "changed"); ContainsIptcValue(profile.Values.ToList(), IptcTag.Caption, caption); @@ -213,7 +213,7 @@ public void IptcProfile_CloneIsDeep() public void IptcValue_CloneIsDeep() { // arrange - var iptcValue = new IptcValue(IptcTag.Caption, System.Text.Encoding.UTF8, "test", true); + IptcValue iptcValue = new(IptcTag.Caption, System.Text.Encoding.UTF8, "test", true); // act IptcValue clone = iptcValue.DeepClone(); @@ -228,7 +228,7 @@ public void WritingImage_PreservesIptcProfile() { // arrange using Image image = new(1, 1); - image.Metadata.IptcProfile = new IptcProfile(); + image.Metadata.IptcProfile = new(); const string expectedCaptionWriter = "unittest"; const string expectedCaption = "test"; image.Metadata.IptcProfile.SetValue(IptcTag.CaptionWriter, expectedCaptionWriter); @@ -240,7 +240,7 @@ public void WritingImage_PreservesIptcProfile() // assert IptcProfile actual = reloadedImage.Metadata.IptcProfile; Assert.NotNull(actual); - var iptcValues = actual.Values.ToList(); + List iptcValues = actual.Values.ToList(); ContainsIptcValue(iptcValues, IptcTag.CaptionWriter, expectedCaptionWriter); ContainsIptcValue(iptcValues, IptcTag.Caption, expectedCaption); } @@ -263,7 +263,7 @@ public void WritingImage_PreservesIptcProfile() public void IptcProfile_AddRepeatable_Works(IptcTag tag) { // arrange - var profile = new IptcProfile(); + IptcProfile profile = new(); const string expectedValue1 = "test"; const string expectedValue2 = "another one"; profile.SetValue(tag, expectedValue1, false); @@ -272,7 +272,7 @@ public void IptcProfile_AddRepeatable_Works(IptcTag tag) profile.SetValue(tag, expectedValue2, false); // assert - var values = profile.Values.ToList(); + List values = profile.Values.ToList(); Assert.Equal(2, values.Count); ContainsIptcValue(values, tag, expectedValue1); ContainsIptcValue(values, tag, expectedValue2); @@ -315,7 +315,7 @@ public void IptcProfile_AddRepeatable_Works(IptcTag tag) public void IptcProfile_AddNoneRepeatable_DoesOverrideOldValue(IptcTag tag) { // arrange - var profile = new IptcProfile(); + IptcProfile profile = new(); const string expectedValue = "another one"; profile.SetValue(tag, "test", false); @@ -323,7 +323,7 @@ public void IptcProfile_AddNoneRepeatable_DoesOverrideOldValue(IptcTag tag) profile.SetValue(tag, expectedValue, false); // assert - var values = profile.Values.ToList(); + List values = profile.Values.ToList(); Assert.Equal(1, values.Count); ContainsIptcValue(values, tag, expectedValue); } @@ -332,7 +332,7 @@ public void IptcProfile_AddNoneRepeatable_DoesOverrideOldValue(IptcTag tag) public void IptcProfile_RemoveByTag_RemovesAllEntrys() { // arrange - var profile = new IptcProfile(); + IptcProfile profile = new(); profile.SetValue(IptcTag.Byline, "test"); profile.SetValue(IptcTag.Byline, "test2"); @@ -348,7 +348,7 @@ public void IptcProfile_RemoveByTag_RemovesAllEntrys() public void IptcProfile_RemoveByTagAndValue_Works() { // arrange - var profile = new IptcProfile(); + IptcProfile profile = new(); profile.SetValue(IptcTag.Byline, "test"); profile.SetValue(IptcTag.Byline, "test2"); @@ -364,7 +364,7 @@ public void IptcProfile_RemoveByTagAndValue_Works() public void IptcProfile_GetValue_RetrievesAllEntries() { // arrange - var profile = new IptcProfile(); + IptcProfile profile = new(); profile.SetValue(IptcTag.Byline, "test"); profile.SetValue(IptcTag.Byline, "test2"); profile.SetValue(IptcTag.Caption, "test"); @@ -380,12 +380,12 @@ public void IptcProfile_GetValue_RetrievesAllEntries() private static void ContainsIptcValue(List values, IptcTag tag, string value) { Assert.True(values.Any(val => val.Tag == tag), $"Missing iptc tag {tag}"); - Assert.True(values.Contains(new IptcValue(tag, System.Text.Encoding.UTF8.GetBytes(value), false)), $"expected iptc value '{value}' was not found for tag '{tag}'"); + Assert.True(values.Contains(new(tag, System.Text.Encoding.UTF8.GetBytes(value), false)), $"expected iptc value '{value}' was not found for tag '{tag}'"); } private static Image WriteAndReadJpeg(Image image) { - using (var memStream = new MemoryStream()) + using (MemoryStream memStream = new()) { image.SaveAsJpeg(memStream); image.Dispose(); diff --git a/tests/ImageSharp.Tests/Metadata/Profiles/XMP/XmpProfileTests.cs b/tests/ImageSharp.Tests/Metadata/Profiles/XMP/XmpProfileTests.cs index 5dc6ac6db7..e121d24f91 100644 --- a/tests/ImageSharp.Tests/Metadata/Profiles/XMP/XmpProfileTests.cs +++ b/tests/ImageSharp.Tests/Metadata/Profiles/XMP/XmpProfileTests.cs @@ -111,10 +111,10 @@ public void XmpProfile_CloneIsDeep() public void WritingGif_PreservesXmpProfile() { // arrange - using var image = new Image(1, 1); + using Image image = new(1, 1); XmpProfile original = CreateMinimalXmlProfile(); image.Metadata.XmpProfile = original; - var encoder = new GifEncoder(); + GifEncoder encoder = new(); // act using Image reloadedImage = WriteAndRead(image, encoder); @@ -129,10 +129,10 @@ public void WritingGif_PreservesXmpProfile() public void WritingJpeg_PreservesXmpProfile() { // arrange - using var image = new Image(1, 1); + using Image image = new(1, 1); XmpProfile original = CreateMinimalXmlProfile(); image.Metadata.XmpProfile = original; - var encoder = new JpegEncoder(); + JpegEncoder encoder = new(); // act using Image reloadedImage = WriteAndRead(image, encoder); @@ -147,10 +147,10 @@ public void WritingJpeg_PreservesXmpProfile() public async Task WritingJpeg_PreservesExtendedXmpProfile() { // arrange - var provider = TestImageProvider.File(TestImages.Jpeg.Baseline.ExtendedXmp); + TestImageProvider provider = TestImageProvider.File(TestImages.Jpeg.Baseline.ExtendedXmp); using Image image = await provider.GetImageAsync(JpegDecoder.Instance); XmpProfile original = image.Metadata.XmpProfile; - var encoder = new JpegEncoder(); + JpegEncoder encoder = new(); // act using Image reloadedImage = WriteAndRead(image, encoder); @@ -165,10 +165,10 @@ public async Task WritingJpeg_PreservesExtendedXmpProfile() public void WritingPng_PreservesXmpProfile() { // arrange - using var image = new Image(1, 1); + using Image image = new(1, 1); XmpProfile original = CreateMinimalXmlProfile(); image.Metadata.XmpProfile = original; - var encoder = new PngEncoder(); + PngEncoder encoder = new(); // act using Image reloadedImage = WriteAndRead(image, encoder); @@ -183,10 +183,10 @@ public void WritingPng_PreservesXmpProfile() public void WritingTiff_PreservesXmpProfile() { // arrange - using var image = new Image(1, 1); + using Image image = new(1, 1); XmpProfile original = CreateMinimalXmlProfile(); image.Frames.RootFrame.Metadata.XmpProfile = original; - var encoder = new TiffEncoder(); + TiffEncoder encoder = new(); // act using Image reloadedImage = WriteAndRead(image, encoder); @@ -201,10 +201,10 @@ public void WritingTiff_PreservesXmpProfile() public void WritingWebp_PreservesXmpProfile() { // arrange - using var image = new Image(1, 1); + using Image image = new(1, 1); XmpProfile original = CreateMinimalXmlProfile(); image.Metadata.XmpProfile = original; - var encoder = new WebpEncoder(); + WebpEncoder encoder = new(); // act using Image reloadedImage = WriteAndRead(image, encoder); @@ -228,13 +228,13 @@ private static XmpProfile CreateMinimalXmlProfile() { string content = $" "; byte[] data = Encoding.UTF8.GetBytes(content); - var profile = new XmpProfile(data); + XmpProfile profile = new(data); return profile; } private static Image WriteAndRead(Image image, IImageEncoder encoder) { - using (var memStream = new MemoryStream()) + using (MemoryStream memStream = new()) { image.Save(memStream, encoder); image.Dispose(); diff --git a/tests/ImageSharp.Tests/Numerics/RationalTests.cs b/tests/ImageSharp.Tests/Numerics/RationalTests.cs index f9cefaddda..9e7e3b7a09 100644 --- a/tests/ImageSharp.Tests/Numerics/RationalTests.cs +++ b/tests/ImageSharp.Tests/Numerics/RationalTests.cs @@ -70,19 +70,19 @@ public void ConstructorAssignsProperties() Assert.Equal(7U, rational.Numerator); Assert.Equal(55U, rational.Denominator); - rational = new Rational(755, 100); + rational = new(755, 100); Assert.Equal(151U, rational.Numerator); Assert.Equal(20U, rational.Denominator); - rational = new Rational(755, 100, false); + rational = new(755, 100, false); Assert.Equal(755U, rational.Numerator); Assert.Equal(100U, rational.Denominator); - rational = new Rational(-7.55); + rational = new(-7.55); Assert.Equal(151U, rational.Numerator); Assert.Equal(20U, rational.Denominator); - rational = new Rational(7); + rational = new(7); Assert.Equal(7U, rational.Numerator); Assert.Equal(1U, rational.Denominator); } @@ -101,7 +101,7 @@ public void ToDouble() Rational rational = new(0, 0); Assert.Equal(double.NaN, rational.ToDouble()); - rational = new Rational(2, 0); + rational = new(2, 0); Assert.Equal(double.PositiveInfinity, rational.ToDouble()); } @@ -111,19 +111,19 @@ public void ToStringRepresentation() Rational rational = new(0, 0); Assert.Equal("[ Indeterminate ]", rational.ToString()); - rational = new Rational(double.PositiveInfinity); + rational = new(double.PositiveInfinity); Assert.Equal("[ PositiveInfinity ]", rational.ToString()); - rational = new Rational(double.NegativeInfinity); + rational = new(double.NegativeInfinity); Assert.Equal("[ PositiveInfinity ]", rational.ToString()); - rational = new Rational(0, 1); + rational = new(0, 1); Assert.Equal("0", rational.ToString()); - rational = new Rational(2, 1); + rational = new(2, 1); Assert.Equal("2", rational.ToString()); - rational = new Rational(1, 2); + rational = new(1, 2); Assert.Equal("1/2", rational.ToString()); } } diff --git a/tests/ImageSharp.Tests/Numerics/SignedRationalTests.cs b/tests/ImageSharp.Tests/Numerics/SignedRationalTests.cs index 04183571b5..275ba4d5f5 100644 --- a/tests/ImageSharp.Tests/Numerics/SignedRationalTests.cs +++ b/tests/ImageSharp.Tests/Numerics/SignedRationalTests.cs @@ -14,15 +14,15 @@ public class SignedRationalTests [Fact] public void AreEqual() { - var r1 = new SignedRational(3, 2); - var r2 = new SignedRational(3, 2); + SignedRational r1 = new(3, 2); + SignedRational r2 = new(3, 2); Assert.Equal(r1, r2); Assert.True(r1 == r2); - var r3 = new SignedRational(7.55); - var r4 = new SignedRational(755, 100); - var r5 = new SignedRational(151, 20); + SignedRational r3 = new(7.55); + SignedRational r4 = new(755, 100); + SignedRational r5 = new(151, 20); Assert.Equal(r3, r4); Assert.Equal(r4, r5); @@ -34,8 +34,8 @@ public void AreEqual() [Fact] public void AreNotEqual() { - var first = new SignedRational(0, 100); - var second = new SignedRational(100, 100); + SignedRational first = new(0, 100); + SignedRational second = new(100, 100); Assert.NotEqual(first, second); Assert.True(first != second); @@ -47,27 +47,27 @@ public void AreNotEqual() [Fact] public void ConstructorAssignsProperties() { - var rational = new SignedRational(7, -55); + SignedRational rational = new(7, -55); Assert.Equal(7, rational.Numerator); Assert.Equal(-55, rational.Denominator); - rational = new SignedRational(-755, 100); + rational = new(-755, 100); Assert.Equal(-151, rational.Numerator); Assert.Equal(20, rational.Denominator); - rational = new SignedRational(-755, -100, false); + rational = new(-755, -100, false); Assert.Equal(-755, rational.Numerator); Assert.Equal(-100, rational.Denominator); - rational = new SignedRational(-151, -20); + rational = new(-151, -20); Assert.Equal(-151, rational.Numerator); Assert.Equal(-20, rational.Denominator); - rational = new SignedRational(-7.55); + rational = new(-7.55); Assert.Equal(-151, rational.Numerator); Assert.Equal(20, rational.Denominator); - rational = new SignedRational(7); + rational = new(7); Assert.Equal(7, rational.Numerator); Assert.Equal(1, rational.Denominator); } @@ -75,43 +75,43 @@ public void ConstructorAssignsProperties() [Fact] public void Fraction() { - var first = new SignedRational(1.0 / 1600); - var second = new SignedRational(1.0 / 1600, true); + SignedRational first = new(1.0 / 1600); + SignedRational second = new(1.0 / 1600, true); Assert.False(first.Equals(second)); } [Fact] public void ToDouble() { - var rational = new SignedRational(0, 0); + SignedRational rational = new(0, 0); Assert.Equal(double.NaN, rational.ToDouble()); - rational = new SignedRational(2, 0); + rational = new(2, 0); Assert.Equal(double.PositiveInfinity, rational.ToDouble()); - rational = new SignedRational(-2, 0); + rational = new(-2, 0); Assert.Equal(double.NegativeInfinity, rational.ToDouble()); } [Fact] public void ToStringRepresentation() { - var rational = new SignedRational(0, 0); + SignedRational rational = new(0, 0); Assert.Equal("[ Indeterminate ]", rational.ToString()); - rational = new SignedRational(double.PositiveInfinity); + rational = new(double.PositiveInfinity); Assert.Equal("[ PositiveInfinity ]", rational.ToString()); - rational = new SignedRational(double.NegativeInfinity); + rational = new(double.NegativeInfinity); Assert.Equal("[ NegativeInfinity ]", rational.ToString()); - rational = new SignedRational(0, 1); + rational = new(0, 1); Assert.Equal("0", rational.ToString()); - rational = new SignedRational(2, 1); + rational = new(2, 1); Assert.Equal("2", rational.ToString()); - rational = new SignedRational(1, 2); + rational = new(1, 2); Assert.Equal("1/2", rational.ToString()); } } diff --git a/tests/ImageSharp.Tests/PixelFormats/A8Tests.cs b/tests/ImageSharp.Tests/PixelFormats/A8Tests.cs index 4b4e84b4b3..4b348b88f8 100644 --- a/tests/ImageSharp.Tests/PixelFormats/A8Tests.cs +++ b/tests/ImageSharp.Tests/PixelFormats/A8Tests.cs @@ -101,7 +101,7 @@ public void A8_FromBgra5551() const byte expected = byte.MaxValue; // act - A8 alpha = A8.FromBgra5551(new Bgra5551(0.0f, 0.0f, 0.0f, 1.0f)); + A8 alpha = A8.FromBgra5551(new(0.0f, 0.0f, 0.0f, 1.0f)); // assert Assert.Equal(expected, alpha.PackedValue); diff --git a/tests/ImageSharp.Tests/PixelFormats/Abgr32Tests.cs b/tests/ImageSharp.Tests/PixelFormats/Abgr32Tests.cs index 98fdce5dbd..4156503210 100644 --- a/tests/ImageSharp.Tests/PixelFormats/Abgr32Tests.cs +++ b/tests/ImageSharp.Tests/PixelFormats/Abgr32Tests.cs @@ -96,7 +96,7 @@ public void Equality_WhenFalse(byte b1, byte g1, byte r1, byte a1, byte b2, byte [Fact] public void FromRgba32() { - Abgr32 abgr = Abgr32.FromRgba32(new Rgba32(1, 2, 3, 4)); + Abgr32 abgr = Abgr32.FromRgba32(new(1, 2, 3, 4)); Assert.Equal(1, abgr.R); Assert.Equal(2, abgr.G); @@ -136,7 +136,7 @@ public void Abgr32_FromBgra5551() const uint expected = uint.MaxValue; // act - Abgr32 abgr = Abgr32.FromBgra5551(new Bgra5551(1f, 1f, 1f, 1f)); + Abgr32 abgr = Abgr32.FromBgra5551(new(1f, 1f, 1f, 1f)); // assert Assert.Equal(expected, abgr.PackedValue); diff --git a/tests/ImageSharp.Tests/PixelFormats/Argb32Tests.cs b/tests/ImageSharp.Tests/PixelFormats/Argb32Tests.cs index bcaf9265a3..8e05c5ca0f 100644 --- a/tests/ImageSharp.Tests/PixelFormats/Argb32Tests.cs +++ b/tests/ImageSharp.Tests/PixelFormats/Argb32Tests.cs @@ -128,7 +128,7 @@ public void Argb32_FromBgra5551() const uint expected = uint.MaxValue; // act - Argb32 argb = Argb32.FromBgra5551(new Bgra5551(1f, 1f, 1f, 1f)); + Argb32 argb = Argb32.FromBgra5551(new(1f, 1f, 1f, 1f)); // assert Assert.Equal(expected, argb.PackedValue); diff --git a/tests/ImageSharp.Tests/PixelFormats/Bgr24Tests.cs b/tests/ImageSharp.Tests/PixelFormats/Bgr24Tests.cs index 362e20bbae..a7e4a08f0d 100644 --- a/tests/ImageSharp.Tests/PixelFormats/Bgr24Tests.cs +++ b/tests/ImageSharp.Tests/PixelFormats/Bgr24Tests.cs @@ -80,7 +80,7 @@ public void Equals_WhenFalse(byte r1, byte g1, byte b1, byte r2, byte g2, byte b [Fact] public void FromRgba32() { - Bgr24 rgb = Bgr24.FromRgba32(new Rgba32(1, 2, 3, 4)); + Bgr24 rgb = Bgr24.FromRgba32(new(1, 2, 3, 4)); Assert.Equal(1, rgb.R); Assert.Equal(2, rgb.G); @@ -115,7 +115,7 @@ public void ToVector4() public void Bgr24_FromBgra5551() { // act - Bgr24 bgr = Bgr24.FromBgra5551(new Bgra5551(1f, 1f, 1f, 1f)); + Bgr24 bgr = Bgr24.FromBgra5551(new(1f, 1f, 1f, 1f)); // assert Assert.Equal(255, bgr.R); diff --git a/tests/ImageSharp.Tests/PixelFormats/Bgr565Tests.cs b/tests/ImageSharp.Tests/PixelFormats/Bgr565Tests.cs index 3c4a104233..f74660731c 100644 --- a/tests/ImageSharp.Tests/PixelFormats/Bgr565Tests.cs +++ b/tests/ImageSharp.Tests/PixelFormats/Bgr565Tests.cs @@ -17,8 +17,8 @@ public class Bgr565Tests public void AreEqual() { Bgr565 color1 = new(0.0f, 0.0f, 0.0f); - Bgr565 color2 = new(new Vector3(0.0f)); - Bgr565 color3 = new(new Vector3(1.0f, 0.0f, 1.0f)); + Bgr565 color2 = new(new(0.0f)); + Bgr565 color3 = new(new(1.0f, 0.0f, 1.0f)); Bgr565 color4 = new(1.0f, 0.0f, 1.0f); Assert.Equal(color1, color2); @@ -32,8 +32,8 @@ public void AreEqual() public void AreNotEqual() { Bgr565 color1 = new(0.0f, 0.0f, 0.0f); - Bgr565 color2 = new(new Vector3(1.0f)); - Bgr565 color3 = new(new Vector3(1.0f, 0.0f, 0.0f)); + Bgr565 color2 = new(new(1.0f)); + Bgr565 color3 = new(new(1.0f, 0.0f, 0.0f)); Bgr565 color4 = new(1.0f, 1.0f, 0.0f); Assert.NotEqual(color1, color2); @@ -101,7 +101,7 @@ public void Bgr565_FromBgra5551() const ushort expected = ushort.MaxValue; // act - Bgr565 bgr = Bgr565.FromBgra5551(new Bgra5551(1.0f, 1.0f, 1.0f, 1.0f)); + Bgr565 bgr = Bgr565.FromBgra5551(new(1.0f, 1.0f, 1.0f, 1.0f)); // assert Assert.Equal(expected, bgr.PackedValue); @@ -115,8 +115,8 @@ public void Bgr565_FromArgb32() const ushort expected2 = ushort.MaxValue; // act - Bgr565 bgr1 = Bgr565.FromArgb32(new Argb32(1.0f, 1.0f, 1.0f, 1.0f)); - Bgr565 bgr2 = Bgr565.FromArgb32(new Argb32(1.0f, 1.0f, 1.0f, 0.0f)); + Bgr565 bgr1 = Bgr565.FromArgb32(new(1.0f, 1.0f, 1.0f, 1.0f)); + Bgr565 bgr2 = Bgr565.FromArgb32(new(1.0f, 1.0f, 1.0f, 0.0f)); // assert Assert.Equal(expected1, bgr1.PackedValue); @@ -131,8 +131,8 @@ public void Bgr565_FromRgba32() const ushort expected2 = ushort.MaxValue; // act - Bgr565 bgr1 = Bgr565.FromRgba32(new Rgba32(1.0f, 1.0f, 1.0f, 1.0f)); - Bgr565 bgr2 = Bgr565.FromRgba32(new Rgba32(1.0f, 1.0f, 1.0f, 0.0f)); + Bgr565 bgr1 = Bgr565.FromRgba32(new(1.0f, 1.0f, 1.0f, 1.0f)); + Bgr565 bgr2 = Bgr565.FromRgba32(new(1.0f, 1.0f, 1.0f, 0.0f)); // assert Assert.Equal(expected1, bgr1.PackedValue); @@ -159,7 +159,7 @@ public void Bgra565_FromRgb48() const ushort expectedPackedValue = ushort.MaxValue; // act - Bgr565 bgr = Bgr565.FromRgb48(new Rgb48(ushort.MaxValue, ushort.MaxValue, ushort.MaxValue)); + Bgr565 bgr = Bgr565.FromRgb48(new(ushort.MaxValue, ushort.MaxValue, ushort.MaxValue)); // assert Assert.Equal(expectedPackedValue, bgr.PackedValue); @@ -172,7 +172,7 @@ public void Bgra565_FromRgba64() const ushort expectedPackedValue = ushort.MaxValue; // act - Bgr565 bgr = Bgr565.FromRgba64(new Rgba64(ushort.MaxValue, ushort.MaxValue, ushort.MaxValue, ushort.MaxValue)); + Bgr565 bgr = Bgr565.FromRgba64(new(ushort.MaxValue, ushort.MaxValue, ushort.MaxValue, ushort.MaxValue)); // assert Assert.Equal(expectedPackedValue, bgr.PackedValue); @@ -185,7 +185,7 @@ public void Bgr565_FromBgr24() const ushort expected = ushort.MaxValue; // act - Bgr565 bgr = Bgr565.FromBgr24(new Bgr24(byte.MaxValue, byte.MaxValue, byte.MaxValue)); + Bgr565 bgr = Bgr565.FromBgr24(new(byte.MaxValue, byte.MaxValue, byte.MaxValue)); // assert Assert.Equal(expected, bgr.PackedValue); @@ -198,7 +198,7 @@ public void Bgr565_FromRgb24() const ushort expected = ushort.MaxValue; // act - Bgr565 bgr = Bgr565.FromRgb24(new Rgb24(byte.MaxValue, byte.MaxValue, byte.MaxValue)); + Bgr565 bgr = Bgr565.FromRgb24(new(byte.MaxValue, byte.MaxValue, byte.MaxValue)); // assert Assert.Equal(expected, bgr.PackedValue); @@ -211,7 +211,7 @@ public void Bgr565_FromGrey8() const ushort expected = ushort.MaxValue; // act - Bgr565 bgr = Bgr565.FromL8(new L8(byte.MaxValue)); + Bgr565 bgr = Bgr565.FromL8(new(byte.MaxValue)); // assert Assert.Equal(expected, bgr.PackedValue); @@ -224,7 +224,7 @@ public void Bgr565_FromGrey16() const ushort expected = ushort.MaxValue; // act - Bgr565 bgr = Bgr565.FromL16(new L16(ushort.MaxValue)); + Bgr565 bgr = Bgr565.FromL16(new(ushort.MaxValue)); // assert Assert.Equal(expected, bgr.PackedValue); diff --git a/tests/ImageSharp.Tests/PixelFormats/Bgra32Tests.cs b/tests/ImageSharp.Tests/PixelFormats/Bgra32Tests.cs index 277975896e..d0150c808b 100644 --- a/tests/ImageSharp.Tests/PixelFormats/Bgra32Tests.cs +++ b/tests/ImageSharp.Tests/PixelFormats/Bgra32Tests.cs @@ -96,7 +96,7 @@ public void Equality_WhenFalse(byte b1, byte g1, byte r1, byte a1, byte b2, byte [Fact] public void FromRgba32() { - Bgra32 bgra = Bgra32.FromRgba32(new Rgba32(1, 2, 3, 4)); + Bgra32 bgra = Bgra32.FromRgba32(new(1, 2, 3, 4)); Assert.Equal(1, bgra.R); Assert.Equal(2, bgra.G); @@ -136,7 +136,7 @@ public void Bgra32_FromBgra5551() const uint expected = uint.MaxValue; // act - Bgra32 bgra = Bgra32.FromBgra5551(new Bgra5551(1.0f, 1.0f, 1.0f, 1.0f)); + Bgra32 bgra = Bgra32.FromBgra5551(new(1.0f, 1.0f, 1.0f, 1.0f)); // assert Assert.Equal(expected, bgra.PackedValue); diff --git a/tests/ImageSharp.Tests/PixelFormats/Bgra4444Tests.cs b/tests/ImageSharp.Tests/PixelFormats/Bgra4444Tests.cs index 5d20b5cf12..166a069402 100644 --- a/tests/ImageSharp.Tests/PixelFormats/Bgra4444Tests.cs +++ b/tests/ImageSharp.Tests/PixelFormats/Bgra4444Tests.cs @@ -17,8 +17,8 @@ public class Bgra4444Tests public void AreEqual() { Bgra4444 color1 = new(0.0f, 0.0f, 0.0f, 0.0f); - Bgra4444 color2 = new(new Vector4(0.0f)); - Bgra4444 color3 = new(new Vector4(1.0f, 0.0f, 1.0f, 1.0f)); + Bgra4444 color2 = new(new(0.0f)); + Bgra4444 color3 = new(new(1.0f, 0.0f, 1.0f, 1.0f)); Bgra4444 color4 = new(1.0f, 0.0f, 1.0f, 1.0f); Assert.Equal(color1, color2); @@ -32,8 +32,8 @@ public void AreEqual() public void AreNotEqual() { Bgra4444 color1 = new(0.0f, 0.0f, 0.0f, 0.0f); - Bgra4444 color2 = new(new Vector4(1.0f)); - Bgra4444 color3 = new(new Vector4(1.0f, 0.0f, 0.0f, 1.0f)); + Bgra4444 color2 = new(new(1.0f)); + Bgra4444 color3 = new(new(1.0f, 0.0f, 0.0f, 1.0f)); Bgra4444 color4 = new(1.0f, 1.0f, 0.0f, 1.0f); Assert.NotEqual(color1, color2); @@ -114,7 +114,7 @@ public void Bgra4444_FromBgra5551() const ushort expected = ushort.MaxValue; // act - Bgra4444 pixel = Bgra4444.FromBgra5551(new Bgra5551(1.0f, 1.0f, 1.0f, 1.0f)); + Bgra4444 pixel = Bgra4444.FromBgra5551(new(1.0f, 1.0f, 1.0f, 1.0f)); // assert Assert.Equal(expected, pixel.PackedValue); @@ -127,7 +127,7 @@ public void Bgra4444_FromArgb32() const ushort expectedPackedValue = ushort.MaxValue; // act - Bgra4444 pixel = Bgra4444.FromArgb32(new Argb32(255, 255, 255, 255)); + Bgra4444 pixel = Bgra4444.FromArgb32(new(255, 255, 255, 255)); // assert Assert.Equal(expectedPackedValue, pixel.PackedValue); @@ -141,8 +141,8 @@ public void Bgra4444_FromRgba32() const ushort expectedPackedValue2 = 0xFF0F; // act - Bgra4444 bgra1 = Bgra4444.FromRgba32(new Rgba32(255, 255, 255, 255)); - Bgra4444 bgra2 = Bgra4444.FromRgba32(new Rgba32(255, 0, 255, 255)); + Bgra4444 bgra1 = Bgra4444.FromRgba32(new(255, 255, 255, 255)); + Bgra4444 bgra2 = Bgra4444.FromRgba32(new(255, 0, 255, 255)); // assert Assert.Equal(expectedPackedValue1, bgra1.PackedValue); @@ -156,7 +156,7 @@ public void Bgra4444_FromRgb48() const ushort expectedPackedValue = ushort.MaxValue; // act - Bgra4444 pixel = Bgra4444.FromRgb48(new Rgb48(ushort.MaxValue, ushort.MaxValue, ushort.MaxValue)); + Bgra4444 pixel = Bgra4444.FromRgb48(new(ushort.MaxValue, ushort.MaxValue, ushort.MaxValue)); // assert Assert.Equal(expectedPackedValue, pixel.PackedValue); @@ -169,7 +169,7 @@ public void Bgra4444_FromRgba64() const ushort expectedPackedValue = ushort.MaxValue; // act - Bgra4444 pixel = Bgra4444.FromRgba64(new Rgba64(ushort.MaxValue, ushort.MaxValue, ushort.MaxValue, ushort.MaxValue)); + Bgra4444 pixel = Bgra4444.FromRgba64(new(ushort.MaxValue, ushort.MaxValue, ushort.MaxValue, ushort.MaxValue)); // assert Assert.Equal(expectedPackedValue, pixel.PackedValue); @@ -182,7 +182,7 @@ public void Bgra4444_FromGrey16() const ushort expectedPackedValue = ushort.MaxValue; // act - Bgra4444 pixel = Bgra4444.FromL16(new L16(ushort.MaxValue)); + Bgra4444 pixel = Bgra4444.FromL16(new(ushort.MaxValue)); // assert Assert.Equal(expectedPackedValue, pixel.PackedValue); @@ -195,7 +195,7 @@ public void Bgra4444_FromGrey8() const ushort expectedPackedValue = ushort.MaxValue; // act - Bgra4444 pixel = Bgra4444.FromL8(new L8(byte.MaxValue)); + Bgra4444 pixel = Bgra4444.FromL8(new(byte.MaxValue)); // assert Assert.Equal(expectedPackedValue, pixel.PackedValue); @@ -208,7 +208,7 @@ public void Bgra4444_FromBgr24() const ushort expectedPackedValue = ushort.MaxValue; // act - Bgra4444 pixel = Bgra4444.FromBgr24(new Bgr24(byte.MaxValue, byte.MaxValue, byte.MaxValue)); + Bgra4444 pixel = Bgra4444.FromBgr24(new(byte.MaxValue, byte.MaxValue, byte.MaxValue)); // assert Assert.Equal(expectedPackedValue, pixel.PackedValue); @@ -221,7 +221,7 @@ public void Bgra4444_FromRgb24() const ushort expectedPackedValue = ushort.MaxValue; // act - Bgra4444 pixel = Bgra4444.FromRgb24(new Rgb24(byte.MaxValue, byte.MaxValue, byte.MaxValue)); + Bgra4444 pixel = Bgra4444.FromRgb24(new(byte.MaxValue, byte.MaxValue, byte.MaxValue)); // assert Assert.Equal(expectedPackedValue, pixel.PackedValue); diff --git a/tests/ImageSharp.Tests/PixelFormats/Bgra5551Tests.cs b/tests/ImageSharp.Tests/PixelFormats/Bgra5551Tests.cs index 38f809e49f..a19f0e9a19 100644 --- a/tests/ImageSharp.Tests/PixelFormats/Bgra5551Tests.cs +++ b/tests/ImageSharp.Tests/PixelFormats/Bgra5551Tests.cs @@ -17,8 +17,8 @@ public class Bgra5551Tests public void AreEqual() { Bgra5551 color1 = new(0.0f, 0.0f, 0.0f, 0.0f); - Bgra5551 color2 = new(new Vector4(0.0f)); - Bgra5551 color3 = new(new Vector4(1f, 0.0f, 0.0f, 1f)); + Bgra5551 color2 = new(new(0.0f)); + Bgra5551 color3 = new(new(1f, 0.0f, 0.0f, 1f)); Bgra5551 color4 = new(1f, 0.0f, 0.0f, 1f); Assert.Equal(color1, color2); @@ -32,8 +32,8 @@ public void AreEqual() public void AreNotEqual() { Bgra5551 color1 = new(0.0f, 0.0f, 0.0f, 0.0f); - Bgra5551 color2 = new(new Vector4(1f)); - Bgra5551 color3 = new(new Vector4(1f, 0.0f, 0.0f, 1f)); + Bgra5551 color2 = new(new(1f)); + Bgra5551 color3 = new(new(1f, 0.0f, 0.0f, 1f)); Bgra5551 color4 = new(1f, 1f, 0.0f, 1f); Assert.NotEqual(color1, color2); @@ -134,8 +134,8 @@ public void Bgra5551_FromRgba32() const ushort expectedPackedValue2 = 0xFC1F; // act - Bgra5551 bgra1 = Bgra5551.FromRgba32(new Rgba32(255, 255, 255, 255)); - Bgra5551 bgra2 = Bgra5551.FromRgba32(new Rgba32(255, 0, 255, 255)); + Bgra5551 bgra1 = Bgra5551.FromRgba32(new(255, 255, 255, 255)); + Bgra5551 bgra2 = Bgra5551.FromRgba32(new(255, 0, 255, 255)); // assert Assert.Equal(expectedPackedValue1, bgra1.PackedValue); @@ -150,8 +150,8 @@ public void Bgra5551_FromBgra32() const ushort expectedPackedValue2 = 0xFC1F; // act - Bgra5551 bgra1 = Bgra5551.FromBgra32(new Bgra32(255, 255, 255, 255)); - Bgra5551 bgra2 = Bgra5551.FromBgra32(new Bgra32(255, 0, 255, 255)); + Bgra5551 bgra1 = Bgra5551.FromBgra32(new(255, 255, 255, 255)); + Bgra5551 bgra2 = Bgra5551.FromBgra32(new(255, 0, 255, 255)); // assert Assert.Equal(expectedPackedValue1, bgra1.PackedValue); @@ -165,7 +165,7 @@ public void Bgra5551_FromArgb32() const ushort expectedPackedValue = ushort.MaxValue; // act - Bgra5551 pixel = Bgra5551.FromArgb32(new Argb32(255, 255, 255, 255)); + Bgra5551 pixel = Bgra5551.FromArgb32(new(255, 255, 255, 255)); // assert Assert.Equal(expectedPackedValue, pixel.PackedValue); @@ -178,7 +178,7 @@ public void Bgra5551_FromRgb48() const ushort expectedPackedValue = ushort.MaxValue; // act - Bgra5551 pixel = Bgra5551.FromRgb48(new Rgb48(ushort.MaxValue, ushort.MaxValue, ushort.MaxValue)); + Bgra5551 pixel = Bgra5551.FromRgb48(new(ushort.MaxValue, ushort.MaxValue, ushort.MaxValue)); // assert Assert.Equal(expectedPackedValue, pixel.PackedValue); @@ -191,7 +191,7 @@ public void Bgra5551_FromRgba64() const ushort expectedPackedValue = ushort.MaxValue; // act - Bgra5551 pixel = Bgra5551.FromRgba64(new Rgba64(ushort.MaxValue, ushort.MaxValue, ushort.MaxValue, ushort.MaxValue)); + Bgra5551 pixel = Bgra5551.FromRgba64(new(ushort.MaxValue, ushort.MaxValue, ushort.MaxValue, ushort.MaxValue)); // assert Assert.Equal(expectedPackedValue, pixel.PackedValue); @@ -204,7 +204,7 @@ public void Bgra5551_FromGrey16() const ushort expectedPackedValue = ushort.MaxValue; // act - Bgra5551 pixel = Bgra5551.FromL16(new L16(ushort.MaxValue)); + Bgra5551 pixel = Bgra5551.FromL16(new(ushort.MaxValue)); // assert Assert.Equal(expectedPackedValue, pixel.PackedValue); @@ -217,7 +217,7 @@ public void Bgra5551_FromGrey8() const ushort expectedPackedValue = ushort.MaxValue; // act - Bgra5551 pixel = Bgra5551.FromL8(new L8(byte.MaxValue)); + Bgra5551 pixel = Bgra5551.FromL8(new(byte.MaxValue)); // assert Assert.Equal(expectedPackedValue, pixel.PackedValue); @@ -230,7 +230,7 @@ public void Bgra5551_FromBgr24() const ushort expectedPackedValue = ushort.MaxValue; // act - Bgra5551 pixel = Bgra5551.FromBgr24(new Bgr24(byte.MaxValue, byte.MaxValue, byte.MaxValue)); + Bgra5551 pixel = Bgra5551.FromBgr24(new(byte.MaxValue, byte.MaxValue, byte.MaxValue)); // assert Assert.Equal(expectedPackedValue, pixel.PackedValue); @@ -243,7 +243,7 @@ public void Bgra5551_FromRgb24() const ushort expectedPackedValue = ushort.MaxValue; // act - Bgra5551 pixel = Bgra5551.FromRgb24(new Rgb24(byte.MaxValue, byte.MaxValue, byte.MaxValue)); + Bgra5551 pixel = Bgra5551.FromRgb24(new(byte.MaxValue, byte.MaxValue, byte.MaxValue)); // assert Assert.Equal(expectedPackedValue, pixel.PackedValue); diff --git a/tests/ImageSharp.Tests/PixelFormats/Byte4Tests.cs b/tests/ImageSharp.Tests/PixelFormats/Byte4Tests.cs index e73d646408..51c7ec4dbb 100644 --- a/tests/ImageSharp.Tests/PixelFormats/Byte4Tests.cs +++ b/tests/ImageSharp.Tests/PixelFormats/Byte4Tests.cs @@ -17,8 +17,8 @@ public class Byte4Tests public void AreEqual() { Byte4 color1 = new(0f, 0f, 0f, 0f); - Byte4 color2 = new(new Vector4(0f)); - Byte4 color3 = new(new Vector4(1f, 0f, 1f, 1f)); + Byte4 color2 = new(new(0f)); + Byte4 color3 = new(new(1f, 0f, 1f, 1f)); Byte4 color4 = new(1f, 0f, 1f, 1f); Assert.Equal(color1, color2); @@ -32,8 +32,8 @@ public void AreEqual() public void AreNotEqual() { Byte4 color1 = new(0f, 0f, 0f, 0f); - Byte4 color2 = new(new Vector4(1f)); - Byte4 color3 = new(new Vector4(1f, 0f, 0f, 1f)); + Byte4 color2 = new(new(1f)); + Byte4 color3 = new(new(1f, 0f, 0f, 1f)); Byte4 color4 = new(1f, 1f, 0f, 1f); Assert.NotEqual(color1, color2); @@ -111,7 +111,7 @@ public void Byte4_FromArgb32() const uint expectedPackedValue = uint.MaxValue; // act - Byte4 pixel = Byte4.FromArgb32(new Argb32(255, 255, 255, 255)); + Byte4 pixel = Byte4.FromArgb32(new(255, 255, 255, 255)); // assert Assert.Equal(expectedPackedValue, pixel.PackedValue); @@ -124,7 +124,7 @@ public void Byte4_FromBgr24() const uint expectedPackedValue = uint.MaxValue; // act - Byte4 pixel = Byte4.FromBgr24(new Bgr24(byte.MaxValue, byte.MaxValue, byte.MaxValue)); + Byte4 pixel = Byte4.FromBgr24(new(byte.MaxValue, byte.MaxValue, byte.MaxValue)); // assert Assert.Equal(expectedPackedValue, pixel.PackedValue); @@ -137,7 +137,7 @@ public void Byte4_FromGrey8() const uint expectedPackedValue = uint.MaxValue; // act - Byte4 pixel = Byte4.FromL8(new L8(byte.MaxValue)); + Byte4 pixel = Byte4.FromL8(new(byte.MaxValue)); // assert Assert.Equal(expectedPackedValue, pixel.PackedValue); @@ -150,7 +150,7 @@ public void Byte4_FromGrey16() const uint expectedPackedValue = uint.MaxValue; // act - Byte4 pixel = Byte4.FromL16(new L16(ushort.MaxValue)); + Byte4 pixel = Byte4.FromL16(new(ushort.MaxValue)); // assert Assert.Equal(expectedPackedValue, pixel.PackedValue); @@ -163,7 +163,7 @@ public void Byte4_FromRgb24() const uint expectedPackedValue = uint.MaxValue; // act - Byte4 pixel = Byte4.FromRgb24(new Rgb24(byte.MaxValue, byte.MaxValue, byte.MaxValue)); + Byte4 pixel = Byte4.FromRgb24(new(byte.MaxValue, byte.MaxValue, byte.MaxValue)); // assert Assert.Equal(expectedPackedValue, pixel.PackedValue); @@ -176,7 +176,7 @@ public void Byte4_FromBgra5551() const uint expected = 0xFFFFFFFF; // act - Byte4 pixel = Byte4.FromBgra5551(new Bgra5551(1f, 1f, 1f, 1f)); + Byte4 pixel = Byte4.FromBgra5551(new(1f, 1f, 1f, 1f)); // assert Assert.Equal(expected, pixel.PackedValue); @@ -189,7 +189,7 @@ public void Byte4_FromRgba32() const uint expectedPackedValue1 = uint.MaxValue; // act - Byte4 pixel = Byte4.FromRgba32(new Rgba32(255, 255, 255, 255)); + Byte4 pixel = Byte4.FromRgba32(new(255, 255, 255, 255)); // assert Assert.Equal(expectedPackedValue1, pixel.PackedValue); @@ -202,7 +202,7 @@ public void Byte4_FromRgb48() const uint expectedPackedValue = uint.MaxValue; // act - Byte4 pixel = Byte4.FromRgb48(new Rgb48(ushort.MaxValue, ushort.MaxValue, ushort.MaxValue)); + Byte4 pixel = Byte4.FromRgb48(new(ushort.MaxValue, ushort.MaxValue, ushort.MaxValue)); // assert Assert.Equal(expectedPackedValue, pixel.PackedValue); @@ -215,7 +215,7 @@ public void Byte4_FromRgba64() const uint expectedPackedValue = uint.MaxValue; // act - Byte4 pixel = Byte4.FromRgba64(new Rgba64(ushort.MaxValue, ushort.MaxValue, ushort.MaxValue, ushort.MaxValue)); + Byte4 pixel = Byte4.FromRgba64(new(ushort.MaxValue, ushort.MaxValue, ushort.MaxValue, ushort.MaxValue)); // assert Assert.Equal(expectedPackedValue, pixel.PackedValue); diff --git a/tests/ImageSharp.Tests/PixelFormats/HalfVector2Tests.cs b/tests/ImageSharp.Tests/PixelFormats/HalfVector2Tests.cs index c5a89df1e9..d723aac47a 100644 --- a/tests/ImageSharp.Tests/PixelFormats/HalfVector2Tests.cs +++ b/tests/ImageSharp.Tests/PixelFormats/HalfVector2Tests.cs @@ -76,7 +76,7 @@ public void HalfVector2_ToVector4() public void HalfVector2_FromBgra5551() { // act - HalfVector2 pixel = HalfVector2.FromBgra5551(new Bgra5551(1f, 1f, 1f, 1f)); + HalfVector2 pixel = HalfVector2.FromBgra5551(new(1f, 1f, 1f, 1f)); // assert Vector4 actual = pixel.ToScaledVector4(); diff --git a/tests/ImageSharp.Tests/PixelFormats/HalfVector4Tests.cs b/tests/ImageSharp.Tests/PixelFormats/HalfVector4Tests.cs index 16c78a23d3..5717118009 100644 --- a/tests/ImageSharp.Tests/PixelFormats/HalfVector4Tests.cs +++ b/tests/ImageSharp.Tests/PixelFormats/HalfVector4Tests.cs @@ -73,7 +73,7 @@ public void HalfVector4_FromBgra5551() Vector4 expected = Vector4.One; // act - HalfVector4 pixel = HalfVector4.FromBgra5551(new Bgra5551(1.0f, 1.0f, 1.0f, 1.0f)); + HalfVector4 pixel = HalfVector4.FromBgra5551(new(1.0f, 1.0f, 1.0f, 1.0f)); // assert Assert.Equal(expected, pixel.ToScaledVector4()); diff --git a/tests/ImageSharp.Tests/PixelFormats/L16Tests.cs b/tests/ImageSharp.Tests/PixelFormats/L16Tests.cs index 7f0a4217c1..5631bbc7e0 100644 --- a/tests/ImageSharp.Tests/PixelFormats/L16Tests.cs +++ b/tests/ImageSharp.Tests/PixelFormats/L16Tests.cs @@ -115,7 +115,7 @@ public void L16_FromRgba32() ushort expected = ColorNumerics.Get16BitBT709Luminance(scaledRgb, scaledRgb, scaledRgb); // Act - L16 pixel = L16.FromRgba32(new Rgba32(rgb, rgb, rgb)); + L16 pixel = L16.FromRgba32(new(rgb, rgb, rgb)); ushort actual = pixel.PackedValue; // Assert @@ -149,7 +149,7 @@ public void L16_FromBgra5551() const ushort expected = ushort.MaxValue; // act - L16 pixel = L16.FromBgra5551(new Bgra5551(1.0f, 1.0f, 1.0f, 1.0f)); + L16 pixel = L16.FromBgra5551(new(1.0f, 1.0f, 1.0f, 1.0f)); // assert Assert.Equal(expected, pixel.PackedValue); diff --git a/tests/ImageSharp.Tests/PixelFormats/L8Tests.cs b/tests/ImageSharp.Tests/PixelFormats/L8Tests.cs index 1ca865ef41..b1c94c754b 100644 --- a/tests/ImageSharp.Tests/PixelFormats/L8Tests.cs +++ b/tests/ImageSharp.Tests/PixelFormats/L8Tests.cs @@ -114,7 +114,7 @@ public void L8_FromRgba32(byte rgb) byte expected = ColorNumerics.Get8BitBT709Luminance(rgb, rgb, rgb); // Act - L8 pixel = L8.FromRgba32(new Rgba32(rgb, rgb, rgb)); + L8 pixel = L8.FromRgba32(new(rgb, rgb, rgb)); byte actual = pixel.PackedValue; // Assert @@ -145,7 +145,7 @@ public void L8_FromBgra5551() const byte expected = byte.MaxValue; // act - L8 grey = L8.FromBgra5551(new Bgra5551(1f, 1f, 1f, 1f)); + L8 grey = L8.FromBgra5551(new(1f, 1f, 1f, 1f)); // assert Assert.Equal(expected, grey.PackedValue); diff --git a/tests/ImageSharp.Tests/PixelFormats/La16Tests.cs b/tests/ImageSharp.Tests/PixelFormats/La16Tests.cs index f6cbfc4426..d82afdff1e 100644 --- a/tests/ImageSharp.Tests/PixelFormats/La16Tests.cs +++ b/tests/ImageSharp.Tests/PixelFormats/La16Tests.cs @@ -116,7 +116,7 @@ public void La16_FromRgba32(byte rgb) byte expected = ColorNumerics.Get8BitBT709Luminance(rgb, rgb, rgb); // Act - La16 gray = La16.FromRgba32(new Rgba32(rgb, rgb, rgb)); + La16 gray = La16.FromRgba32(new(rgb, rgb, rgb)); byte actual = gray.L; // Assert @@ -148,7 +148,7 @@ public void La16_FromBgra5551() const byte expected = byte.MaxValue; // act - La16 grey = La16.FromBgra5551(new Bgra5551(1.0f, 1.0f, 1.0f, 1.0f)); + La16 grey = La16.FromBgra5551(new(1.0f, 1.0f, 1.0f, 1.0f)); // assert Assert.Equal(expected, grey.L); diff --git a/tests/ImageSharp.Tests/PixelFormats/La32Tests.cs b/tests/ImageSharp.Tests/PixelFormats/La32Tests.cs index fd5556d3bc..571aa3fd03 100644 --- a/tests/ImageSharp.Tests/PixelFormats/La32Tests.cs +++ b/tests/ImageSharp.Tests/PixelFormats/La32Tests.cs @@ -119,7 +119,7 @@ public void La32_FromRgba32() ushort expected = ColorNumerics.Get16BitBT709Luminance(scaledRgb, scaledRgb, scaledRgb); // Act - La32 pixel = La32.FromRgba32(new Rgba32(rgb, rgb, rgb)); + La32 pixel = La32.FromRgba32(new(rgb, rgb, rgb)); ushort actual = pixel.L; // Assert @@ -154,7 +154,7 @@ public void La32_FromBgra5551() const ushort expected = ushort.MaxValue; // act - La32 pixel = La32.FromBgra5551(new Bgra5551(1f, 1f, 1f, 1f)); + La32 pixel = La32.FromBgra5551(new(1f, 1f, 1f, 1f)); // assert Assert.Equal(expected, pixel.L); diff --git a/tests/ImageSharp.Tests/PixelFormats/NormalizedByte2Tests.cs b/tests/ImageSharp.Tests/PixelFormats/NormalizedByte2Tests.cs index ffbddb1398..c6a14518a7 100644 --- a/tests/ImageSharp.Tests/PixelFormats/NormalizedByte2Tests.cs +++ b/tests/ImageSharp.Tests/PixelFormats/NormalizedByte2Tests.cs @@ -32,8 +32,8 @@ public void NormalizedByte2_ToVector2() [Fact] public void NormalizedByte2_ToVector4() { - Assert.Equal(new Vector4(1, 1, 0, 1), new NormalizedByte2(Vector2.One).ToVector4()); - Assert.Equal(new Vector4(0, 0, 0, 1), new NormalizedByte2(Vector2.Zero).ToVector4()); + Assert.Equal(new(1, 1, 0, 1), new NormalizedByte2(Vector2.One).ToVector4()); + Assert.Equal(new(0, 0, 0, 1), new NormalizedByte2(Vector2.Zero).ToVector4()); } [Fact] @@ -74,7 +74,7 @@ public void NormalizedByte2_FromBgra5551() Vector4 expected = new(1, 1, 0, 1); // act - NormalizedByte2 pixel = NormalizedByte2.FromBgra5551(new Bgra5551(1f, 1f, 1f, 1f)); + NormalizedByte2 pixel = NormalizedByte2.FromBgra5551(new(1f, 1f, 1f, 1f)); // assert Assert.Equal(expected, pixel.ToVector4()); diff --git a/tests/ImageSharp.Tests/PixelFormats/NormalizedByte4Tests.cs b/tests/ImageSharp.Tests/PixelFormats/NormalizedByte4Tests.cs index 5a025f6c4e..40d81cad66 100644 --- a/tests/ImageSharp.Tests/PixelFormats/NormalizedByte4Tests.cs +++ b/tests/ImageSharp.Tests/PixelFormats/NormalizedByte4Tests.cs @@ -17,8 +17,8 @@ public class NormalizedByte4Tests public void AreEqual() { NormalizedByte4 color1 = new(0.0f, 0.0f, 0.0f, 0.0f); - NormalizedByte4 color2 = new(new Vector4(0.0f)); - NormalizedByte4 color3 = new(new Vector4(1f, 0.0f, 1f, 1f)); + NormalizedByte4 color2 = new(new(0.0f)); + NormalizedByte4 color3 = new(new(1f, 0.0f, 1f, 1f)); NormalizedByte4 color4 = new(1f, 0.0f, 1f, 1f); Assert.Equal(color1, color2); @@ -32,8 +32,8 @@ public void AreEqual() public void AreNotEqual() { NormalizedByte4 color1 = new(0.0f, 0.0f, 0.0f, 0.0f); - NormalizedByte4 color2 = new(new Vector4(1f)); - NormalizedByte4 color3 = new(new Vector4(1f, 0.0f, 0.0f, 1f)); + NormalizedByte4 color2 = new(new(1f)); + NormalizedByte4 color3 = new(new(1f, 0.0f, 0.0f, 1f)); NormalizedByte4 color4 = new(1f, 1f, 0.0f, 1f); Assert.NotEqual(color1, color2); @@ -98,7 +98,7 @@ public void NormalizedByte4_FromArgb32() Vector4 expected = Vector4.One; // act - NormalizedByte4 pixel = NormalizedByte4.FromArgb32(new Argb32(255, 255, 255, 255)); + NormalizedByte4 pixel = NormalizedByte4.FromArgb32(new(255, 255, 255, 255)); // assert Assert.Equal(expected, pixel.ToScaledVector4()); @@ -111,7 +111,7 @@ public void NormalizedByte4_FromBgr24() Vector4 expected = Vector4.One; // act - NormalizedByte4 pixel = NormalizedByte4.FromBgr24(new Bgr24(byte.MaxValue, byte.MaxValue, byte.MaxValue)); + NormalizedByte4 pixel = NormalizedByte4.FromBgr24(new(byte.MaxValue, byte.MaxValue, byte.MaxValue)); // assert Assert.Equal(expected, pixel.ToScaledVector4()); @@ -124,7 +124,7 @@ public void NormalizedByte4_FromGrey8() Vector4 expected = Vector4.One; // act - NormalizedByte4 pixel = NormalizedByte4.FromL8(new L8(byte.MaxValue)); + NormalizedByte4 pixel = NormalizedByte4.FromL8(new(byte.MaxValue)); // assert Assert.Equal(expected, pixel.ToScaledVector4()); @@ -137,7 +137,7 @@ public void NormalizedByte4_FromGrey16() Vector4 expected = Vector4.One; // act - NormalizedByte4 pixel = NormalizedByte4.FromL16(new L16(ushort.MaxValue)); + NormalizedByte4 pixel = NormalizedByte4.FromL16(new(ushort.MaxValue)); // assert Assert.Equal(expected, pixel.ToScaledVector4()); @@ -150,7 +150,7 @@ public void NormalizedByte4_FromRgb24() Vector4 expected = Vector4.One; // act - NormalizedByte4 pixel = NormalizedByte4.FromRgb24(new Rgb24(byte.MaxValue, byte.MaxValue, byte.MaxValue)); + NormalizedByte4 pixel = NormalizedByte4.FromRgb24(new(byte.MaxValue, byte.MaxValue, byte.MaxValue)); // assert Assert.Equal(expected, pixel.ToScaledVector4()); @@ -163,7 +163,7 @@ public void NormalizedByte4_FromRgba32() Vector4 expected = Vector4.One; // act - NormalizedByte4 pixel = NormalizedByte4.FromRgba32(new Rgba32(255, 255, 255, 255)); + NormalizedByte4 pixel = NormalizedByte4.FromRgba32(new(255, 255, 255, 255)); // assert Assert.Equal(expected, pixel.ToScaledVector4()); @@ -176,7 +176,7 @@ public void NormalizedByte4_FromBgra5551() Vector4 expected = Vector4.One; // act - NormalizedByte4 pixel = NormalizedByte4.FromBgra5551(new Bgra5551(1f, 1f, 1f, 1f)); + NormalizedByte4 pixel = NormalizedByte4.FromBgra5551(new(1f, 1f, 1f, 1f)); // assert Assert.Equal(expected, pixel.ToVector4()); @@ -189,7 +189,7 @@ public void NormalizedByte4_FromRgb48() Vector4 expected = Vector4.One; // act - NormalizedByte4 pixel = NormalizedByte4.FromRgb48(new Rgb48(ushort.MaxValue, ushort.MaxValue, ushort.MaxValue)); + NormalizedByte4 pixel = NormalizedByte4.FromRgb48(new(ushort.MaxValue, ushort.MaxValue, ushort.MaxValue)); // assert Assert.Equal(expected, pixel.ToScaledVector4()); @@ -202,7 +202,7 @@ public void NormalizedByte4_FromRgba64() Vector4 expected = Vector4.One; // act - NormalizedByte4 pixel = NormalizedByte4.FromRgba64(new Rgba64(ushort.MaxValue, ushort.MaxValue, ushort.MaxValue, ushort.MaxValue)); + NormalizedByte4 pixel = NormalizedByte4.FromRgba64(new(ushort.MaxValue, ushort.MaxValue, ushort.MaxValue, ushort.MaxValue)); // assert Assert.Equal(expected, pixel.ToScaledVector4()); diff --git a/tests/ImageSharp.Tests/PixelFormats/NormalizedShort2Tests.cs b/tests/ImageSharp.Tests/PixelFormats/NormalizedShort2Tests.cs index be7b390527..f153f6aea2 100644 --- a/tests/ImageSharp.Tests/PixelFormats/NormalizedShort2Tests.cs +++ b/tests/ImageSharp.Tests/PixelFormats/NormalizedShort2Tests.cs @@ -36,8 +36,8 @@ public void NormalizedShort2_ToVector2() [Fact] public void NormalizedShort2_ToVector4() { - Assert.Equal(new Vector4(1, 1, 0, 1), new NormalizedShort2(Vector2.One).ToVector4()); - Assert.Equal(new Vector4(0, 0, 0, 1), new NormalizedShort2(Vector2.Zero).ToVector4()); + Assert.Equal(new(1, 1, 0, 1), new NormalizedShort2(Vector2.One).ToVector4()); + Assert.Equal(new(0, 0, 0, 1), new NormalizedShort2(Vector2.Zero).ToVector4()); } [Fact] @@ -78,7 +78,7 @@ public void NormalizedShort2_FromBgra5551() Vector4 expected = new(1, 1, 0, 1); // act - NormalizedShort2 normalizedShort2 = NormalizedShort2.FromBgra5551(new Bgra5551(1f, 1f, 1f, 1f)); + NormalizedShort2 normalizedShort2 = NormalizedShort2.FromBgra5551(new(1f, 1f, 1f, 1f)); // assert Assert.Equal(expected, normalizedShort2.ToVector4()); diff --git a/tests/ImageSharp.Tests/PixelFormats/NormalizedShort4Tests.cs b/tests/ImageSharp.Tests/PixelFormats/NormalizedShort4Tests.cs index 281ae7ee52..cf0c3e8195 100644 --- a/tests/ImageSharp.Tests/PixelFormats/NormalizedShort4Tests.cs +++ b/tests/ImageSharp.Tests/PixelFormats/NormalizedShort4Tests.cs @@ -17,8 +17,8 @@ public class NormalizedShort4Tests public void AreEqual() { NormalizedShort4 color1 = new(0.0f, 0.0f, 0.0f, 0.0f); - NormalizedShort4 color2 = new(new Vector4(0.0f)); - NormalizedShort4 color3 = new(new Vector4(1f, 0.0f, 1f, 1f)); + NormalizedShort4 color2 = new(new(0.0f)); + NormalizedShort4 color3 = new(new(1f, 0.0f, 1f, 1f)); NormalizedShort4 color4 = new(1f, 0.0f, 1f, 1f); Assert.Equal(color1, color2); @@ -32,8 +32,8 @@ public void AreEqual() public void AreNotEqual() { NormalizedShort4 color1 = new(0.0f, 0.0f, 0.0f, 0.0f); - NormalizedShort4 color2 = new(new Vector4(1f)); - NormalizedShort4 color3 = new(new Vector4(1f, 0.0f, 0.0f, 1f)); + NormalizedShort4 color2 = new(new(1f)); + NormalizedShort4 color3 = new(new(1f, 0.0f, 0.0f, 1f)); NormalizedShort4 color4 = new(1f, 1f, 0.0f, 1f); Assert.NotEqual(color1, color2); @@ -99,7 +99,7 @@ public void NormalizedShort4_FromArgb32() Vector4 expected = Vector4.One; // act - NormalizedShort4 pixel = NormalizedShort4.FromArgb32(new Argb32(255, 255, 255, 255)); + NormalizedShort4 pixel = NormalizedShort4.FromArgb32(new(255, 255, 255, 255)); // assert Assert.Equal(expected, pixel.ToScaledVector4()); @@ -112,7 +112,7 @@ public void NormalizedShort4_FromBgr24() Vector4 expected = Vector4.One; // act - NormalizedShort4 pixel = NormalizedShort4.FromBgr24(new Bgr24(byte.MaxValue, byte.MaxValue, byte.MaxValue)); + NormalizedShort4 pixel = NormalizedShort4.FromBgr24(new(byte.MaxValue, byte.MaxValue, byte.MaxValue)); // assert Assert.Equal(expected, pixel.ToScaledVector4()); @@ -125,7 +125,7 @@ public void NormalizedShort4_FromGrey8() Vector4 expected = Vector4.One; // act - NormalizedShort4 pixel = NormalizedShort4.FromL8(new L8(byte.MaxValue)); + NormalizedShort4 pixel = NormalizedShort4.FromL8(new(byte.MaxValue)); // assert Assert.Equal(expected, pixel.ToScaledVector4()); @@ -138,7 +138,7 @@ public void NormalizedShort4_FromGrey16() Vector4 expected = Vector4.One; // act - NormalizedShort4 pixel = NormalizedShort4.FromL16(new L16(ushort.MaxValue)); + NormalizedShort4 pixel = NormalizedShort4.FromL16(new(ushort.MaxValue)); // assert Assert.Equal(expected, pixel.ToScaledVector4()); @@ -151,7 +151,7 @@ public void NormalizedShort4_FromRgb24() Vector4 expected = Vector4.One; // act - NormalizedShort4 pixel = NormalizedShort4.FromRgb24(new Rgb24(byte.MaxValue, byte.MaxValue, byte.MaxValue)); + NormalizedShort4 pixel = NormalizedShort4.FromRgb24(new(byte.MaxValue, byte.MaxValue, byte.MaxValue)); // assert Assert.Equal(expected, pixel.ToScaledVector4()); @@ -164,7 +164,7 @@ public void NormalizedShort4_FromRgba32() Vector4 expected = Vector4.One; // act - NormalizedShort4 pixel = NormalizedShort4.FromRgba32(new Rgba32(255, 255, 255, 255)); + NormalizedShort4 pixel = NormalizedShort4.FromRgba32(new(255, 255, 255, 255)); // assert Assert.Equal(expected, pixel.ToScaledVector4()); @@ -177,7 +177,7 @@ public void NormalizedShort4_FromRgb48() Vector4 expected = Vector4.One; // act - NormalizedShort4 pixel = NormalizedShort4.FromRgb48(new Rgb48(ushort.MaxValue, ushort.MaxValue, ushort.MaxValue)); + NormalizedShort4 pixel = NormalizedShort4.FromRgb48(new(ushort.MaxValue, ushort.MaxValue, ushort.MaxValue)); // assert Assert.Equal(expected, pixel.ToScaledVector4()); @@ -190,7 +190,7 @@ public void NormalizedShort4_FromRgba64() Vector4 expected = Vector4.One; // act - NormalizedShort4 pixel = NormalizedShort4.FromRgba64(new Rgba64(ushort.MaxValue, ushort.MaxValue, ushort.MaxValue, ushort.MaxValue)); + NormalizedShort4 pixel = NormalizedShort4.FromRgba64(new(ushort.MaxValue, ushort.MaxValue, ushort.MaxValue, ushort.MaxValue)); // assert Assert.Equal(expected, pixel.ToScaledVector4()); @@ -216,7 +216,7 @@ public void NormalizedShort4_FromBgra5551() Vector4 expected = Vector4.One; // act - NormalizedShort4 normalizedShort4 = NormalizedShort4.FromBgra5551(new Bgra5551(1f, 1f, 1f, 1f)); + NormalizedShort4 normalizedShort4 = NormalizedShort4.FromBgra5551(new(1f, 1f, 1f, 1f)); // assert Assert.Equal(expected, normalizedShort4.ToVector4()); diff --git a/tests/ImageSharp.Tests/PixelFormats/PixelBlenderTests.cs b/tests/ImageSharp.Tests/PixelFormats/PixelBlenderTests.cs index 924e94d929..2e66115b0d 100644 --- a/tests/ImageSharp.Tests/PixelFormats/PixelBlenderTests.cs +++ b/tests/ImageSharp.Tests/PixelFormats/PixelBlenderTests.cs @@ -44,14 +44,14 @@ public void ReturnsCorrectBlender(TestPixel pixel, Type type, Pi public static TheoryData ColorBlendingExpectedResults = new() { { Color.MistyRose.ToPixel(), Color.MidnightBlue.ToPixel(), 1, PixelColorBlendingMode.Normal, Color.MidnightBlue.ToPixel() }, - { Color.MistyRose.ToPixel(), Color.MidnightBlue.ToPixel(), 1, PixelColorBlendingMode.Screen, new Rgba32(0xFFEEE7FF) }, - { Color.MistyRose.ToPixel(), Color.MidnightBlue.ToPixel(), 1, PixelColorBlendingMode.HardLight, new Rgba32(0xFFC62D32) }, - { Color.MistyRose.ToPixel(), Color.MidnightBlue.ToPixel(), 1, PixelColorBlendingMode.Overlay, new Rgba32(0xFFDDCEFF) }, - { Color.MistyRose.ToPixel(), Color.MidnightBlue.ToPixel(), 1, PixelColorBlendingMode.Darken, new Rgba32(0xFF701919) }, - { Color.MistyRose.ToPixel(), Color.MidnightBlue.ToPixel(), 1, PixelColorBlendingMode.Lighten, new Rgba32(0xFFE1E4FF) }, - { Color.MistyRose.ToPixel(), Color.MidnightBlue.ToPixel(), 1, PixelColorBlendingMode.Add, new Rgba32(0xFFFFFDFF) }, - { Color.MistyRose.ToPixel(), Color.MidnightBlue.ToPixel(), 1, PixelColorBlendingMode.Subtract, new Rgba32(0xFF71CBE6) }, - { Color.MistyRose.ToPixel(), Color.MidnightBlue.ToPixel(), 1, PixelColorBlendingMode.Multiply, new Rgba32(0xFF631619) }, + { Color.MistyRose.ToPixel(), Color.MidnightBlue.ToPixel(), 1, PixelColorBlendingMode.Screen, new(0xFFEEE7FF) }, + { Color.MistyRose.ToPixel(), Color.MidnightBlue.ToPixel(), 1, PixelColorBlendingMode.HardLight, new(0xFFC62D32) }, + { Color.MistyRose.ToPixel(), Color.MidnightBlue.ToPixel(), 1, PixelColorBlendingMode.Overlay, new(0xFFDDCEFF) }, + { Color.MistyRose.ToPixel(), Color.MidnightBlue.ToPixel(), 1, PixelColorBlendingMode.Darken, new(0xFF701919) }, + { Color.MistyRose.ToPixel(), Color.MidnightBlue.ToPixel(), 1, PixelColorBlendingMode.Lighten, new(0xFFE1E4FF) }, + { Color.MistyRose.ToPixel(), Color.MidnightBlue.ToPixel(), 1, PixelColorBlendingMode.Add, new(0xFFFFFDFF) }, + { Color.MistyRose.ToPixel(), Color.MidnightBlue.ToPixel(), 1, PixelColorBlendingMode.Subtract, new(0xFF71CBE6) }, + { Color.MistyRose.ToPixel(), Color.MidnightBlue.ToPixel(), 1, PixelColorBlendingMode.Multiply, new(0xFF631619) }, }; [Theory] @@ -67,17 +67,17 @@ public void TestColorBlendingModes(Rgba32 backdrop, Rgba32 source, float opacity public static TheoryData AlphaCompositionExpectedResults = new() { - { Color.MistyRose.ToPixel(), Color.MidnightBlue.ToPixel(), 1, PixelAlphaCompositionMode.Clear, new Rgba32(0) }, - { Color.MistyRose.ToPixel(), Color.MidnightBlue.ToPixel(), 1, PixelAlphaCompositionMode.Xor, new Rgba32(0) }, + { Color.MistyRose.ToPixel(), Color.MidnightBlue.ToPixel(), 1, PixelAlphaCompositionMode.Clear, new(0) }, + { Color.MistyRose.ToPixel(), Color.MidnightBlue.ToPixel(), 1, PixelAlphaCompositionMode.Xor, new(0) }, { Color.MistyRose.ToPixel(), Color.MidnightBlue.ToPixel(), 1, PixelAlphaCompositionMode.Dest, Color.MistyRose.ToPixel() }, { Color.MistyRose.ToPixel(), Color.MidnightBlue.ToPixel(), 1, PixelAlphaCompositionMode.DestAtop, Color.MistyRose.ToPixel() }, { Color.MistyRose.ToPixel(), Color.MidnightBlue.ToPixel(), 1, PixelAlphaCompositionMode.DestIn, Color.MistyRose.ToPixel() }, - { Color.MistyRose.ToPixel(), Color.MidnightBlue.ToPixel(), 1, PixelAlphaCompositionMode.DestOut, new Rgba32(0) }, + { Color.MistyRose.ToPixel(), Color.MidnightBlue.ToPixel(), 1, PixelAlphaCompositionMode.DestOut, new(0) }, { Color.MistyRose.ToPixel(), Color.MidnightBlue.ToPixel(), 1, PixelAlphaCompositionMode.DestOver, Color.MistyRose.ToPixel() }, { Color.MistyRose.ToPixel(), Color.MidnightBlue.ToPixel(), 1, PixelAlphaCompositionMode.Src, Color.MidnightBlue.ToPixel() }, { Color.MistyRose.ToPixel(), Color.MidnightBlue.ToPixel(), 1, PixelAlphaCompositionMode.SrcAtop, Color.MidnightBlue.ToPixel() }, { Color.MistyRose.ToPixel(), Color.MidnightBlue.ToPixel(), 1, PixelAlphaCompositionMode.SrcIn, Color.MidnightBlue.ToPixel() }, - { Color.MistyRose.ToPixel(), Color.MidnightBlue.ToPixel(), 1, PixelAlphaCompositionMode.SrcOut, new Rgba32(0) }, + { Color.MistyRose.ToPixel(), Color.MidnightBlue.ToPixel(), 1, PixelAlphaCompositionMode.SrcOut, new(0) }, { Color.MistyRose.ToPixel(), Color.MidnightBlue.ToPixel(), 1, PixelAlphaCompositionMode.SrcOver, Color.MidnightBlue.ToPixel() }, }; diff --git a/tests/ImageSharp.Tests/PixelFormats/PixelBlenders/PorterDuffFunctionsTests.cs b/tests/ImageSharp.Tests/PixelFormats/PixelBlenders/PorterDuffFunctionsTests.cs index 976a272ebf..908625e17a 100644 --- a/tests/ImageSharp.Tests/PixelFormats/PixelBlenders/PorterDuffFunctionsTests.cs +++ b/tests/ImageSharp.Tests/PixelFormats/PixelBlenders/PorterDuffFunctionsTests.cs @@ -16,8 +16,8 @@ public class PorterDuffFunctionsTests public static TheoryData NormalBlendFunctionData { get; } = new() { - { new TestVector4(1, 1, 1, 1), new TestVector4(1, 1, 1, 1), 1, new TestVector4(1, 1, 1, 1) }, - { new TestVector4(1, 1, 1, 1), new TestVector4(0, 0, 0, .8f), .5f, new TestVector4(0.6f, 0.6f, 0.6f, 1) } + { new(1, 1, 1, 1), new(1, 1, 1, 1), 1, new(1, 1, 1, 1) }, + { new(1, 1, 1, 1), new(0, 0, 0, .8f), .5f, new(0.6f, 0.6f, 0.6f, 1) } }; [Theory] @@ -47,9 +47,9 @@ public void NormalBlendFunction256(TestVector4 back, TestVector4 source, float a public static TheoryData MultiplyFunctionData { get; } = new() { - { new TestVector4(1, 1, 1, 1), new TestVector4(1, 1, 1, 1), 1, new TestVector4(1, 1, 1, 1) }, - { new TestVector4(1, 1, 1, 1), new TestVector4(0, 0, 0, .8f), .5f, new TestVector4(0.6f, 0.6f, 0.6f, 1) }, - { new TestVector4(0.9f, 0.9f, 0.9f, 0.9f), new TestVector4(0.4f, 0.4f, 0.4f, 0.4f), .5f, new TestVector4(0.7834783f, 0.7834783f, 0.7834783f, 0.92f) } + { new(1, 1, 1, 1), new(1, 1, 1, 1), 1, new(1, 1, 1, 1) }, + { new(1, 1, 1, 1), new(0, 0, 0, .8f), .5f, new(0.6f, 0.6f, 0.6f, 1) }, + { new(0.9f, 0.9f, 0.9f, 0.9f), new(0.4f, 0.4f, 0.4f, 0.4f), .5f, new(0.7834783f, 0.7834783f, 0.7834783f, 0.92f) } }; [Theory] @@ -79,9 +79,9 @@ public void MultiplyFunction256(TestVector4 back, TestVector4 source, float amou public static TheoryData AddFunctionData { get; } = new() { - { new TestVector4(1, 1, 1, 1), new TestVector4(1, 1, 1, 1), 1, new TestVector4(1, 1, 1, 1) }, - { new TestVector4(1, 1, 1, 1), new TestVector4(0, 0, 0, .8f), .5f, new TestVector4(1, 1, 1, 1) }, - { new TestVector4(0.2f, 0.2f, 0.2f, 0.3f), new TestVector4(0.3f, 0.3f, 0.3f, 0.2f), .5f, new TestVector4(0.24324325f, 0.24324325f, 0.24324325f, .37f) } + { new(1, 1, 1, 1), new(1, 1, 1, 1), 1, new(1, 1, 1, 1) }, + { new(1, 1, 1, 1), new(0, 0, 0, .8f), .5f, new(1, 1, 1, 1) }, + { new(0.2f, 0.2f, 0.2f, 0.3f), new(0.3f, 0.3f, 0.3f, 0.2f), .5f, new(0.24324325f, 0.24324325f, 0.24324325f, .37f) } }; [Theory] @@ -111,9 +111,9 @@ public void AddFunction256(TestVector4 back, TestVector4 source, float amount, T public static TheoryData SubtractFunctionData { get; } = new() { - { new TestVector4(1, 1, 1, 1), new TestVector4(1, 1, 1, 1), 1, new TestVector4(0, 0, 0, 1) }, - { new TestVector4(1, 1, 1, 1), new TestVector4(0, 0, 0, .8f), .5f, new TestVector4(1, 1, 1, 1f) }, - { new TestVector4(0.2f, 0.2f, 0.2f, 0.3f), new TestVector4(0.3f, 0.3f, 0.3f, 0.2f), .5f, new TestVector4(.2027027f, .2027027f, .2027027f, .37f) } + { new(1, 1, 1, 1), new(1, 1, 1, 1), 1, new(0, 0, 0, 1) }, + { new(1, 1, 1, 1), new(0, 0, 0, .8f), .5f, new(1, 1, 1, 1f) }, + { new(0.2f, 0.2f, 0.2f, 0.3f), new(0.3f, 0.3f, 0.3f, 0.2f), .5f, new(.2027027f, .2027027f, .2027027f, .37f) } }; [Theory] @@ -143,9 +143,9 @@ public void SubtractFunction256(TestVector4 back, TestVector4 source, float amou public static TheoryData ScreenFunctionData { get; } = new() { - { new TestVector4(1, 1, 1, 1), new TestVector4(1, 1, 1, 1), 1, new TestVector4(1, 1, 1, 1) }, - { new TestVector4(1, 1, 1, 1), new TestVector4(0, 0, 0, .8f), .5f, new TestVector4(1, 1, 1, 1f) }, - { new TestVector4(0.2f, 0.2f, 0.2f, 0.3f), new TestVector4(0.3f, 0.3f, 0.3f, 0.2f), .5f, new TestVector4(.2383784f, .2383784f, .2383784f, .37f) } + { new(1, 1, 1, 1), new(1, 1, 1, 1), 1, new(1, 1, 1, 1) }, + { new(1, 1, 1, 1), new(0, 0, 0, .8f), .5f, new(1, 1, 1, 1f) }, + { new(0.2f, 0.2f, 0.2f, 0.3f), new(0.3f, 0.3f, 0.3f, 0.2f), .5f, new(.2383784f, .2383784f, .2383784f, .37f) } }; [Theory] @@ -175,9 +175,9 @@ public void ScreenFunction256(TestVector4 back, TestVector4 source, float amount public static TheoryData DarkenFunctionData { get; } = new() { - { new TestVector4(1, 1, 1, 1), new TestVector4(1, 1, 1, 1), 1, new TestVector4(1, 1, 1, 1) }, - { new TestVector4(1, 1, 1, 1), new TestVector4(0, 0, 0, .8f), .5f, new TestVector4(.6f, .6f, .6f, 1f) }, - { new TestVector4(0.2f, 0.2f, 0.2f, 0.3f), new TestVector4(0.3f, 0.3f, 0.3f, 0.2f), .5f, new TestVector4(.2189189f, .2189189f, .2189189f, .37f) } + { new(1, 1, 1, 1), new(1, 1, 1, 1), 1, new(1, 1, 1, 1) }, + { new(1, 1, 1, 1), new(0, 0, 0, .8f), .5f, new(.6f, .6f, .6f, 1f) }, + { new(0.2f, 0.2f, 0.2f, 0.3f), new(0.3f, 0.3f, 0.3f, 0.2f), .5f, new(.2189189f, .2189189f, .2189189f, .37f) } }; [Theory] @@ -207,9 +207,9 @@ public void DarkenFunction256(TestVector4 back, TestVector4 source, float amount public static TheoryData LightenFunctionData { get; } = new() { - { new TestVector4(1, 1, 1, 1), new TestVector4(1, 1, 1, 1), 1, new TestVector4(1, 1, 1, 1) }, - { new TestVector4(1, 1, 1, 1), new TestVector4(0, 0, 0, .8f), .5f, new TestVector4(1, 1, 1, 1f) }, - { new TestVector4(0.2f, 0.2f, 0.2f, 0.3f), new TestVector4(0.3f, 0.3f, 0.3f, 0.2f), .5f, new TestVector4(.227027f, .227027f, .227027f, .37f) }, + { new(1, 1, 1, 1), new(1, 1, 1, 1), 1, new(1, 1, 1, 1) }, + { new(1, 1, 1, 1), new(0, 0, 0, .8f), .5f, new(1, 1, 1, 1f) }, + { new(0.2f, 0.2f, 0.2f, 0.3f), new(0.3f, 0.3f, 0.3f, 0.2f), .5f, new(.227027f, .227027f, .227027f, .37f) }, }; [Theory] @@ -239,9 +239,9 @@ public void LightenFunction256(TestVector4 back, TestVector4 source, float amoun public static TheoryData OverlayFunctionData { get; } = new() { - { new TestVector4(1, 1, 1, 1), new TestVector4(1, 1, 1, 1), 1, new TestVector4(1, 1, 1, 1) }, - { new TestVector4(1, 1, 1, 1), new TestVector4(0, 0, 0, .8f), .5f, new TestVector4(1, 1, 1, 1f) }, - { new TestVector4(0.2f, 0.2f, 0.2f, 0.3f), new TestVector4(0.3f, 0.3f, 0.3f, 0.2f), .5f, new TestVector4(.2124324f, .2124324f, .2124324f, .37f) }, + { new(1, 1, 1, 1), new(1, 1, 1, 1), 1, new(1, 1, 1, 1) }, + { new(1, 1, 1, 1), new(0, 0, 0, .8f), .5f, new(1, 1, 1, 1f) }, + { new(0.2f, 0.2f, 0.2f, 0.3f), new(0.3f, 0.3f, 0.3f, 0.2f), .5f, new(.2124324f, .2124324f, .2124324f, .37f) }, }; [Theory] @@ -271,9 +271,9 @@ public void OverlayFunction256(TestVector4 back, TestVector4 source, float amoun public static TheoryData HardLightFunctionData { get; } = new() { - { new TestVector4(1, 1, 1, 1), new TestVector4(1, 1, 1, 1), 1, new TestVector4(1, 1, 1, 1) }, - { new TestVector4(1, 1, 1, 1), new TestVector4(0, 0, 0, .8f), .5f, new TestVector4(0.6f, 0.6f, 0.6f, 1f) }, - { new TestVector4(0.2f, 0.2f, 0.2f, 0.3f), new TestVector4(0.3f, 0.3f, 0.3f, 0.2f), .5f, new TestVector4(.2124324f, .2124324f, .2124324f, .37f) }, + { new(1, 1, 1, 1), new(1, 1, 1, 1), 1, new(1, 1, 1, 1) }, + { new(1, 1, 1, 1), new(0, 0, 0, .8f), .5f, new(0.6f, 0.6f, 0.6f, 1f) }, + { new(0.2f, 0.2f, 0.2f, 0.3f), new(0.3f, 0.3f, 0.3f, 0.2f), .5f, new(.2124324f, .2124324f, .2124324f, .37f) }, }; [Theory] diff --git a/tests/ImageSharp.Tests/PixelFormats/PixelBlenders/PorterDuffFunctionsTestsTPixel.cs b/tests/ImageSharp.Tests/PixelFormats/PixelBlenders/PorterDuffFunctionsTestsTPixel.cs index d375a74c67..f11cc43d56 100644 --- a/tests/ImageSharp.Tests/PixelFormats/PixelBlenders/PorterDuffFunctionsTestsTPixel.cs +++ b/tests/ImageSharp.Tests/PixelFormats/PixelBlenders/PorterDuffFunctionsTestsTPixel.cs @@ -12,10 +12,10 @@ public class PorterDuffFunctionsTestsTPixel private static Span AsSpan(T value) where T : struct { - return new Span(new[] { value }); + return new([value]); } - public static TheoryData NormalBlendFunctionData = new TheoryData + public static TheoryData NormalBlendFunctionData = new() { { new TestPixel(1, 1, 1, 1), new TestPixel(1, 1, 1, 1), 1, new TestPixel(1, 1, 1, 1) }, { new TestPixel(1, 1, 1, 1), new TestPixel(0, 0, 0, .8f), .5f, new TestPixel(0.6f, 0.6f, 0.6f, 1) } @@ -46,12 +46,12 @@ public void NormalBlendFunctionBlender(TestPixel back, TestPixel public void NormalBlendFunctionBlenderBulk(TestPixel back, TestPixel source, float amount, TestPixel expected) where TPixel : unmanaged, IPixel { - var dest = new Span(new TPixel[1]); + Span dest = new(new TPixel[1]); new DefaultPixelBlenders.NormalSrcOver().Blend(this.Configuration, dest, back.AsSpan(), source.AsSpan(), AsSpan(amount)); VectorAssert.Equal(expected.AsPixel(), dest[0], 2); } - public static TheoryData MultiplyFunctionData = new TheoryData + public static TheoryData MultiplyFunctionData = new() { { new TestPixel(1, 1, 1, 1), new TestPixel(1, 1, 1, 1), 1, new TestPixel(1, 1, 1, 1) }, { new TestPixel(1, 1, 1, 1), new TestPixel(0, 0, 0, .8f), .5f, new TestPixel(0.6f, 0.6f, 0.6f, 1) }, @@ -86,12 +86,12 @@ public void MultiplyFunctionBlender(TestPixel back, TestPixel(TestPixel back, TestPixel source, float amount, TestPixel expected) where TPixel : unmanaged, IPixel { - var dest = new Span(new TPixel[1]); + Span dest = new(new TPixel[1]); new DefaultPixelBlenders.MultiplySrcOver().Blend(this.Configuration, dest, back.AsSpan(), source.AsSpan(), AsSpan(amount)); VectorAssert.Equal(expected.AsPixel(), dest[0], 2); } - public static TheoryData AddFunctionData = new TheoryData + public static TheoryData AddFunctionData = new() { { new TestPixel(1, 1, 1, 1), @@ -136,12 +136,12 @@ public void AddFunctionBlender(TestPixel back, TestPixel public void AddFunctionBlenderBulk(TestPixel back, TestPixel source, float amount, TestPixel expected) where TPixel : unmanaged, IPixel { - var dest = new Span(new TPixel[1]); + Span dest = new(new TPixel[1]); new DefaultPixelBlenders.AddSrcOver().Blend(this.Configuration, dest, back.AsSpan(), source.AsSpan(), AsSpan(amount)); VectorAssert.Equal(expected.AsPixel(), dest[0], 2); } - public static TheoryData SubtractFunctionData = new TheoryData + public static TheoryData SubtractFunctionData = new() { { new TestPixel(1, 1, 1, 1), new TestPixel(1, 1, 1, 1), 1, new TestPixel(0, 0, 0, 1) }, { new TestPixel(1, 1, 1, 1), new TestPixel(0, 0, 0, .8f), .5f, new TestPixel(1, 1, 1, 1f) }, @@ -176,12 +176,12 @@ public void SubtractFunctionBlender(TestPixel back, TestPixel(TestPixel back, TestPixel source, float amount, TestPixel expected) where TPixel : unmanaged, IPixel { - var dest = new Span(new TPixel[1]); + Span dest = new(new TPixel[1]); new DefaultPixelBlenders.SubtractSrcOver().Blend(this.Configuration, dest, back.AsSpan(), source.AsSpan(), AsSpan(amount)); VectorAssert.Equal(expected.AsPixel(), dest[0], 2); } - public static TheoryData ScreenFunctionData = new TheoryData + public static TheoryData ScreenFunctionData = new() { { new TestPixel(1, 1, 1, 1), new TestPixel(1, 1, 1, 1), 1, new TestPixel(1, 1, 1, 1) }, { new TestPixel(1, 1, 1, 1), new TestPixel(0, 0, 0, .8f), .5f, new TestPixel(1, 1, 1, 1f) }, @@ -216,12 +216,12 @@ public void ScreenFunctionBlender(TestPixel back, TestPixel(TestPixel back, TestPixel source, float amount, TestPixel expected) where TPixel : unmanaged, IPixel { - var dest = new Span(new TPixel[1]); + Span dest = new(new TPixel[1]); new DefaultPixelBlenders.ScreenSrcOver().Blend(this.Configuration, dest, back.AsSpan(), source.AsSpan(), AsSpan(amount)); VectorAssert.Equal(expected.AsPixel(), dest[0], 2); } - public static TheoryData DarkenFunctionData = new TheoryData + public static TheoryData DarkenFunctionData = new() { { new TestPixel(1, 1, 1, 1), new TestPixel(1, 1, 1, 1), 1, new TestPixel(1, 1, 1, 1) }, { new TestPixel(1, 1, 1, 1), new TestPixel(0, 0, 0, .8f), .5f, new TestPixel(.6f, .6f, .6f, 1f) }, @@ -256,12 +256,12 @@ public void DarkenFunctionBlender(TestPixel back, TestPixel(TestPixel back, TestPixel source, float amount, TestPixel expected) where TPixel : unmanaged, IPixel { - var dest = new Span(new TPixel[1]); + Span dest = new(new TPixel[1]); new DefaultPixelBlenders.DarkenSrcOver().Blend(this.Configuration, dest, back.AsSpan(), source.AsSpan(), AsSpan(amount)); VectorAssert.Equal(expected.AsPixel(), dest[0], 2); } - public static TheoryData LightenFunctionData = new TheoryData + public static TheoryData LightenFunctionData = new() { { new TestPixel(1, 1, 1, 1), new TestPixel(1, 1, 1, 1), 1, new TestPixel(1, 1, 1, 1) }, { new TestPixel(1, 1, 1, 1), new TestPixel(0, 0, 0, .8f), .5f, new TestPixel(1, 1, 1, 1f) }, @@ -296,12 +296,12 @@ public void LightenFunctionBlender(TestPixel back, TestPixel(TestPixel back, TestPixel source, float amount, TestPixel expected) where TPixel : unmanaged, IPixel { - var dest = new Span(new TPixel[1]); + Span dest = new(new TPixel[1]); new DefaultPixelBlenders.LightenSrcOver().Blend(this.Configuration, dest, back.AsSpan(), source.AsSpan(), AsSpan(amount)); VectorAssert.Equal(expected.AsPixel(), dest[0], 2); } - public static TheoryData OverlayFunctionData = new TheoryData + public static TheoryData OverlayFunctionData = new() { { new TestPixel(1, 1, 1, 1), new TestPixel(1, 1, 1, 1), 1, new TestPixel(1, 1, 1, 1) }, { new TestPixel(1, 1, 1, 1), new TestPixel(0, 0, 0, .8f), .5f, new TestPixel(1, 1, 1, 1f) }, @@ -336,12 +336,12 @@ public void OverlayFunctionBlender(TestPixel back, TestPixel(TestPixel back, TestPixel source, float amount, TestPixel expected) where TPixel : unmanaged, IPixel { - var dest = new Span(new TPixel[1]); + Span dest = new(new TPixel[1]); new DefaultPixelBlenders.OverlaySrcOver().Blend(this.Configuration, dest, back.AsSpan(), source.AsSpan(), AsSpan(amount)); VectorAssert.Equal(expected.AsPixel(), dest[0], 2); } - public static TheoryData HardLightFunctionData = new TheoryData + public static TheoryData HardLightFunctionData = new() { { new TestPixel(1, 1, 1, 1), new TestPixel(1, 1, 1, 1), 1, new TestPixel(1, 1, 1, 1) }, { new TestPixel(1, 1, 1, 1), new TestPixel(0, 0, 0, .8f), .5f, new TestPixel(0.6f, 0.6f, 0.6f, 1f) }, @@ -376,7 +376,7 @@ public void HardLightFunctionBlender(TestPixel back, TestPixel(TestPixel back, TestPixel source, float amount, TestPixel expected) where TPixel : unmanaged, IPixel { - var dest = new Span(new TPixel[1]); + Span dest = new(new TPixel[1]); new DefaultPixelBlenders.HardLightSrcOver().Blend(this.Configuration, dest, back.AsSpan(), source.AsSpan(), AsSpan(amount)); VectorAssert.Equal(expected.AsPixel(), dest[0], 2); } diff --git a/tests/ImageSharp.Tests/PixelFormats/PixelOperations/PixelOperationsTests.cs b/tests/ImageSharp.Tests/PixelFormats/PixelOperations/PixelOperationsTests.cs index 32b62fc03d..6d5013cde0 100644 --- a/tests/ImageSharp.Tests/PixelFormats/PixelOperations/PixelOperationsTests.cs +++ b/tests/ImageSharp.Tests/PixelFormats/PixelOperations/PixelOperationsTests.cs @@ -117,7 +117,7 @@ public void PixelAlphaRepresentation_DefinesPresenceOfAlphaChannel() const byte alpha = byte.MinValue; const byte noAlpha = byte.MaxValue; - TPixel pixel = TPixel.FromRgba32(new Rgba32(0, 0, 0, alpha)); + TPixel pixel = TPixel.FromRgba32(new(0, 0, 0, alpha)); Rgba32 dest = pixel.ToRgba32(); @@ -480,7 +480,7 @@ public void FromArgb32Bytes(int count) { int i4 = i * 4; - expected[i] = TPixel.FromArgb32(new Argb32(source[i4 + 1], source[i4 + 2], source[i4 + 3], source[i4 + 0])); + expected[i] = TPixel.FromArgb32(new(source[i4 + 1], source[i4 + 2], source[i4 + 3], source[i4 + 0])); } TestOperation( @@ -524,7 +524,7 @@ public void FromBgr24Bytes(int count) { int i3 = i * 3; - expected[i] = TPixel.FromBgr24(new Bgr24(source[i3 + 2], source[i3 + 1], source[i3])); + expected[i] = TPixel.FromBgr24(new(source[i3 + 2], source[i3 + 1], source[i3])); } TestOperation( @@ -566,7 +566,7 @@ public void FromBgra32Bytes(int count) { int i4 = i * 4; - expected[i] = TPixel.FromBgra32(new Bgra32(source[i4 + 2], source[i4 + 1], source[i4 + 0], source[i4 + 3])); + expected[i] = TPixel.FromBgra32(new(source[i4 + 2], source[i4 + 1], source[i4 + 0], source[i4 + 3])); } TestOperation( @@ -609,7 +609,7 @@ public void FromAbgr32Bytes(int count) { int i4 = i * 4; - expected[i] = TPixel.FromAbgr32(new Abgr32(source[i4 + 3], source[i4 + 2], source[i4 + 1], source[i4 + 0])); + expected[i] = TPixel.FromAbgr32(new(source[i4 + 3], source[i4 + 2], source[i4 + 1], source[i4 + 0])); } TestOperation( @@ -863,7 +863,7 @@ public void FromRgb24Bytes(int count) { int i3 = i * 3; - expected[i] = TPixel.FromRgb24(new Rgb24(source[i3 + 0], source[i3 + 1], source[i3 + 2])); + expected[i] = TPixel.FromRgb24(new(source[i3 + 0], source[i3 + 1], source[i3 + 2])); } TestOperation( @@ -905,7 +905,7 @@ public void FromRgba32Bytes(int count) { int i4 = i * 4; - expected[i] = TPixel.FromRgba32(new Rgba32(source[i4 + 0], source[i4 + 1], source[i4 + 2], source[i4 + 3])); + expected[i] = TPixel.FromRgba32(new(source[i4 + 0], source[i4 + 1], source[i4 + 2], source[i4 + 3])); } TestOperation( diff --git a/tests/ImageSharp.Tests/PixelFormats/Rg32Tests.cs b/tests/ImageSharp.Tests/PixelFormats/Rg32Tests.cs index b2790469a1..c4e2fc7a2e 100644 --- a/tests/ImageSharp.Tests/PixelFormats/Rg32Tests.cs +++ b/tests/ImageSharp.Tests/PixelFormats/Rg32Tests.cs @@ -69,7 +69,7 @@ public void Rg32_FromBgra5551() const uint expected = 0xFFFFFFFF; // act - Rg32 rg32 = Rg32.FromBgra5551(new Bgra5551(1f, 1f, 1f, 1f)); + Rg32 rg32 = Rg32.FromBgra5551(new(1f, 1f, 1f, 1f)); // assert Assert.Equal(expected, rg32.PackedValue); diff --git a/tests/ImageSharp.Tests/PixelFormats/Rgb24Tests.cs b/tests/ImageSharp.Tests/PixelFormats/Rgb24Tests.cs index 6364378c15..22c977dcca 100644 --- a/tests/ImageSharp.Tests/PixelFormats/Rgb24Tests.cs +++ b/tests/ImageSharp.Tests/PixelFormats/Rgb24Tests.cs @@ -68,7 +68,7 @@ public void Equals_WhenFalse(byte r1, byte g1, byte b1, byte r2, byte g2, byte b [Fact] public void FromRgba32() { - Rgb24 rgb = Rgb24.FromRgba32(new Rgba32(1, 2, 3, 4)); + Rgb24 rgb = Rgb24.FromRgba32(new(1, 2, 3, 4)); Assert.Equal(1, rgb.R); Assert.Equal(2, rgb.G); @@ -117,7 +117,7 @@ public void ToRgba32() public void Rgb24_FromBgra5551() { // act - Rgb24 rgb = Rgb24.FromBgra5551(new Bgra5551(1.0f, 1.0f, 1.0f, 1.0f)); + Rgb24 rgb = Rgb24.FromBgra5551(new(1.0f, 1.0f, 1.0f, 1.0f)); // assert Assert.Equal(255, rgb.R); diff --git a/tests/ImageSharp.Tests/PixelFormats/Rgb48Tests.cs b/tests/ImageSharp.Tests/PixelFormats/Rgb48Tests.cs index 764627ee34..cf8e2e7e90 100644 --- a/tests/ImageSharp.Tests/PixelFormats/Rgb48Tests.cs +++ b/tests/ImageSharp.Tests/PixelFormats/Rgb48Tests.cs @@ -65,7 +65,7 @@ public void Rgb48_FromBgra5551() const ushort expected = ushort.MaxValue; // act - Rgb48 rgb = Rgb48.FromBgra5551(new Bgra5551(1f, 1f, 1f, 1f)); + Rgb48 rgb = Rgb48.FromBgra5551(new(1f, 1f, 1f, 1f)); // assert Assert.Equal(expected, rgb.R); diff --git a/tests/ImageSharp.Tests/PixelFormats/Rgba1010102Tests.cs b/tests/ImageSharp.Tests/PixelFormats/Rgba1010102Tests.cs index 79a1aefc9c..c342d0aa3f 100644 --- a/tests/ImageSharp.Tests/PixelFormats/Rgba1010102Tests.cs +++ b/tests/ImageSharp.Tests/PixelFormats/Rgba1010102Tests.cs @@ -17,8 +17,8 @@ public class Rgba1010102Tests public void AreEqual() { Rgba1010102 color1 = new(0.0f, 0.0f, 0.0f, 0.0f); - Rgba1010102 color2 = new(new Vector4(0.0f)); - Rgba1010102 color3 = new(new Vector4(1f, 0.0f, 1f, 1f)); + Rgba1010102 color2 = new(new(0.0f)); + Rgba1010102 color3 = new(new(1f, 0.0f, 1f, 1f)); Rgba1010102 color4 = new(1f, 0.0f, 1f, 1f); Assert.Equal(color1, color2); @@ -32,8 +32,8 @@ public void AreEqual() public void AreNotEqual() { Rgba1010102 color1 = new(0.0f, 0.0f, 0.0f, 0.0f); - Rgba1010102 color2 = new(new Vector4(1f)); - Rgba1010102 color3 = new(new Vector4(1f, 0.0f, 0.0f, 1f)); + Rgba1010102 color2 = new(new(1f)); + Rgba1010102 color3 = new(new(1f, 0.0f, 0.0f, 1f)); Rgba1010102 color4 = new(1f, 1f, 0.0f, 1f); Assert.NotEqual(color1, color2); @@ -101,7 +101,7 @@ public void Rgba1010102_FromBgra5551() const uint expected = 0xFFFFFFFF; // act - Rgba1010102 rgba = Rgba1010102.FromBgra5551(new Bgra5551(1f, 1f, 1f, 1f)); + Rgba1010102 rgba = Rgba1010102.FromBgra5551(new(1f, 1f, 1f, 1f)); // assert Assert.Equal(expected, rgba.PackedValue); @@ -114,7 +114,7 @@ public void Rgba1010102_FromArgb32() const uint expectedPackedValue = uint.MaxValue; // act - Rgba1010102 rgba = Rgba1010102.FromArgb32(new Argb32(255, 255, 255, 255)); + Rgba1010102 rgba = Rgba1010102.FromArgb32(new(255, 255, 255, 255)); // assert Assert.Equal(expectedPackedValue, rgba.PackedValue); @@ -128,8 +128,8 @@ public void Rgba1010102_FromRgba32() const uint expectedPackedValue2 = 0xFFF003FF; // act - Rgba1010102 rgba1 = Rgba1010102.FromRgba32(new Rgba32(255, 255, 255, 255)); - Rgba1010102 rgba2 = Rgba1010102.FromRgba32(new Rgba32(255, 0, 255, 255)); + Rgba1010102 rgba1 = Rgba1010102.FromRgba32(new(255, 255, 255, 255)); + Rgba1010102 rgba2 = Rgba1010102.FromRgba32(new(255, 0, 255, 255)); // assert Assert.Equal(expectedPackedValue1, rgba1.PackedValue); @@ -143,7 +143,7 @@ public void Rgba1010102_FromBgr24() const uint expectedPackedValue = uint.MaxValue; // act - Rgba1010102 rgba = Rgba1010102.FromBgr24(new Bgr24(byte.MaxValue, byte.MaxValue, byte.MaxValue)); + Rgba1010102 rgba = Rgba1010102.FromBgr24(new(byte.MaxValue, byte.MaxValue, byte.MaxValue)); // assert Assert.Equal(expectedPackedValue, rgba.PackedValue); @@ -156,7 +156,7 @@ public void Rgba1010102_FromGrey8() const uint expectedPackedValue = uint.MaxValue; // act - Rgba1010102 rgba = Rgba1010102.FromL8(new L8(byte.MaxValue)); + Rgba1010102 rgba = Rgba1010102.FromL8(new(byte.MaxValue)); // assert Assert.Equal(expectedPackedValue, rgba.PackedValue); @@ -169,7 +169,7 @@ public void Rgba1010102_FromGrey16() const uint expectedPackedValue = uint.MaxValue; // act - Rgba1010102 rgba = Rgba1010102.FromL16(new L16(ushort.MaxValue)); + Rgba1010102 rgba = Rgba1010102.FromL16(new(ushort.MaxValue)); // assert Assert.Equal(expectedPackedValue, rgba.PackedValue); @@ -182,7 +182,7 @@ public void Rgba1010102_FromRgb24() const uint expectedPackedValue = uint.MaxValue; // act - Rgba1010102 rgba = Rgba1010102.FromRgb24(new Rgb24(byte.MaxValue, byte.MaxValue, byte.MaxValue)); + Rgba1010102 rgba = Rgba1010102.FromRgb24(new(byte.MaxValue, byte.MaxValue, byte.MaxValue)); // assert Assert.Equal(expectedPackedValue, rgba.PackedValue); @@ -195,7 +195,7 @@ public void Rgba1010102_FromRgb48() const uint expectedPackedValue = uint.MaxValue; // act - Rgba1010102 rgba = Rgba1010102.FromRgb48(new Rgb48(ushort.MaxValue, ushort.MaxValue, ushort.MaxValue)); + Rgba1010102 rgba = Rgba1010102.FromRgb48(new(ushort.MaxValue, ushort.MaxValue, ushort.MaxValue)); // assert Assert.Equal(expectedPackedValue, rgba.PackedValue); @@ -208,7 +208,7 @@ public void Rgba1010102_FromRgba64() const uint expectedPackedValue = uint.MaxValue; // act - Rgba1010102 rgba = Rgba1010102.FromRgba64(new Rgba64(ushort.MaxValue, ushort.MaxValue, ushort.MaxValue, ushort.MaxValue)); + Rgba1010102 rgba = Rgba1010102.FromRgba64(new(ushort.MaxValue, ushort.MaxValue, ushort.MaxValue, ushort.MaxValue)); // assert Assert.Equal(expectedPackedValue, rgba.PackedValue); diff --git a/tests/ImageSharp.Tests/PixelFormats/Rgba32Tests.cs b/tests/ImageSharp.Tests/PixelFormats/Rgba32Tests.cs index 6d56185ecf..fafee5d3cb 100644 --- a/tests/ImageSharp.Tests/PixelFormats/Rgba32Tests.cs +++ b/tests/ImageSharp.Tests/PixelFormats/Rgba32Tests.cs @@ -286,7 +286,7 @@ public void Rgba32_FromBgra5551() const uint expected = 0xFFFFFFFF; // act - Rgba32 rgb = Rgba32.FromBgra5551(new Bgra5551(1f, 1f, 1f, 1f)); + Rgba32 rgb = Rgba32.FromBgra5551(new(1f, 1f, 1f, 1f)); // assert Assert.Equal(expected, rgb.PackedValue); diff --git a/tests/ImageSharp.Tests/PixelFormats/Rgba64Tests.cs b/tests/ImageSharp.Tests/PixelFormats/Rgba64Tests.cs index 694d0ace10..e962b41feb 100644 --- a/tests/ImageSharp.Tests/PixelFormats/Rgba64Tests.cs +++ b/tests/ImageSharp.Tests/PixelFormats/Rgba64Tests.cs @@ -106,7 +106,7 @@ public void Rgba64_FromBgra5551() const ushort expected = ushort.MaxValue; // act - Rgba64 rgba = Rgba64.FromBgra5551(new Bgra5551(1.0f, 1.0f, 1.0f, 1.0f)); + Rgba64 rgba = Rgba64.FromBgra5551(new(1.0f, 1.0f, 1.0f, 1.0f)); // assert Assert.Equal(expected, rgba.R); diff --git a/tests/ImageSharp.Tests/PixelFormats/RgbaVectorTests.cs b/tests/ImageSharp.Tests/PixelFormats/RgbaVectorTests.cs index 5273482efb..daafabaa34 100644 --- a/tests/ImageSharp.Tests/PixelFormats/RgbaVectorTests.cs +++ b/tests/ImageSharp.Tests/PixelFormats/RgbaVectorTests.cs @@ -150,7 +150,7 @@ public void RgbaVector_FromBgra5551() Vector4 expected = Vector4.One; // act - RgbaVector rgb = RgbaVector.FromBgra5551(new Bgra5551(1.0f, 1.0f, 1.0f, 1.0f)); + RgbaVector rgb = RgbaVector.FromBgra5551(new(1.0f, 1.0f, 1.0f, 1.0f)); // assert Assert.Equal(expected, rgb.ToScaledVector4()); @@ -163,7 +163,7 @@ public void RgbaVector_FromGrey16() Vector4 expected = Vector4.One; // act - RgbaVector rgba = RgbaVector.FromL16(new L16(ushort.MaxValue)); + RgbaVector rgba = RgbaVector.FromL16(new(ushort.MaxValue)); // assert Assert.Equal(expected, rgba.ToScaledVector4()); @@ -176,7 +176,7 @@ public void RgbaVector_FromGrey8() Vector4 expected = Vector4.One; // act - RgbaVector rgba = RgbaVector.FromL8(new L8(byte.MaxValue)); + RgbaVector rgba = RgbaVector.FromL8(new(byte.MaxValue)); // assert Assert.Equal(expected, rgba.ToScaledVector4()); diff --git a/tests/ImageSharp.Tests/PixelFormats/Short2Tests.cs b/tests/ImageSharp.Tests/PixelFormats/Short2Tests.cs index f23da0c7a6..a9942220c7 100644 --- a/tests/ImageSharp.Tests/PixelFormats/Short2Tests.cs +++ b/tests/ImageSharp.Tests/PixelFormats/Short2Tests.cs @@ -36,9 +36,9 @@ public void Short2_ToVector2() [Fact] public void Short2_ToVector4() { - Assert.Equal(new Vector4(0x7FFF, 0x7FFF, 0, 1), new Short2(Vector2.One * 0x7FFF).ToVector4()); - Assert.Equal(new Vector4(0, 0, 0, 1), new Short2(Vector2.Zero).ToVector4()); - Assert.Equal(new Vector4(-0x8000, -0x8000, 0, 1), new Short2(Vector2.One * -0x8000).ToVector4()); + Assert.Equal(new(0x7FFF, 0x7FFF, 0, 1), new Short2(Vector2.One * 0x7FFF).ToVector4()); + Assert.Equal(new(0, 0, 0, 1), new Short2(Vector2.Zero).ToVector4()); + Assert.Equal(new(-0x8000, -0x8000, 0, 1), new Short2(Vector2.One * -0x8000).ToVector4()); } [Fact] @@ -140,7 +140,7 @@ public void Short2_FromRgba64() public void Short2_FromBgra5551() { // act - Short2 short2 = Short2.FromBgra5551(new Bgra5551(1.0f, 1.0f, 1.0f, 1.0f)); + Short2 short2 = Short2.FromBgra5551(new(1.0f, 1.0f, 1.0f, 1.0f)); // assert Vector4 actual = short2.ToScaledVector4(); diff --git a/tests/ImageSharp.Tests/PixelFormats/Short4Tests.cs b/tests/ImageSharp.Tests/PixelFormats/Short4Tests.cs index 819ff0e1e5..fd25f50866 100644 --- a/tests/ImageSharp.Tests/PixelFormats/Short4Tests.cs +++ b/tests/ImageSharp.Tests/PixelFormats/Short4Tests.cs @@ -190,7 +190,7 @@ public void Short4_FromBgra5551() Vector4 expected = Vector4.One; // act - Short4 short4 = Short4.FromBgra5551(new Bgra5551(1.0f, 1.0f, 1.0f, 1.0f)); + Short4 short4 = Short4.FromBgra5551(new(1.0f, 1.0f, 1.0f, 1.0f)); // assert Assert.Equal(expected, short4.ToScaledVector4()); diff --git a/tests/ImageSharp.Tests/Primitives/ColorMatrixTests.cs b/tests/ImageSharp.Tests/Primitives/ColorMatrixTests.cs index 9c0e83a7fe..0ea429a771 100644 --- a/tests/ImageSharp.Tests/Primitives/ColorMatrixTests.cs +++ b/tests/ImageSharp.Tests/Primitives/ColorMatrixTests.cs @@ -49,7 +49,7 @@ public void ColorMatrixMultiply() ColorMatrix value1 = CreateAllTwos(); ColorMatrix value2 = CreateAllThrees(); - var m = default(ColorMatrix); + ColorMatrix m = default(ColorMatrix); // First row m.M11 = (value1.M11 * value2.M11) + (value1.M12 * value2.M21) + (value1.M13 * value2.M31) + (value1.M14 * value2.M41); diff --git a/tests/ImageSharp.Tests/Primitives/DenseMatrixTests.cs b/tests/ImageSharp.Tests/Primitives/DenseMatrixTests.cs index ecc5923264..e5162e23d4 100644 --- a/tests/ImageSharp.Tests/Primitives/DenseMatrixTests.cs +++ b/tests/ImageSharp.Tests/Primitives/DenseMatrixTests.cs @@ -38,12 +38,12 @@ public void DenseMatrixThrowsOnEmptyInitializer() [Fact] public void DenseMatrixReturnsCorrectDimensions() { - var dense = new DenseMatrix(FloydSteinbergMatrix); + DenseMatrix dense = new(FloydSteinbergMatrix); Assert.True(dense.Columns == FloydSteinbergMatrix.GetLength(1)); Assert.True(dense.Rows == FloydSteinbergMatrix.GetLength(0)); Assert.Equal(3, dense.Columns); Assert.Equal(2, dense.Rows); - Assert.Equal(new Size(3, 2), dense.Size); + Assert.Equal(new(3, 2), dense.Size); } [Fact] @@ -63,7 +63,7 @@ public void DenseMatrixGetReturnsCorrectResults() [Fact] public void DenseMatrixGetSetReturnsCorrectResults() { - var dense = new DenseMatrix(4, 4); + DenseMatrix dense = new(4, 4); const int Val = 5; dense[3, 3] = Val; @@ -74,7 +74,7 @@ public void DenseMatrixGetSetReturnsCorrectResults() [Fact] public void DenseMatrixCanFillAndClear() { - var dense = new DenseMatrix(9); + DenseMatrix dense = new(9); dense.Fill(4); for (int i = 0; i < dense.Data.Length; i++) @@ -100,7 +100,7 @@ public void DenseMatrixCorrectlyCasts() [Fact] public void DenseMatrixCanTranspose() { - var dense = new DenseMatrix(3, 1); + DenseMatrix dense = new(3, 1); dense[0, 0] = 1; dense[0, 1] = 2; dense[0, 2] = 3; @@ -117,9 +117,9 @@ public void DenseMatrixCanTranspose() [Fact] public void DenseMatrixEquality() { - var dense = new DenseMatrix(3, 1); - var dense2 = new DenseMatrix(3, 1); - var dense3 = new DenseMatrix(1, 3); + DenseMatrix dense = new(3, 1); + DenseMatrix dense2 = new(3, 1); + DenseMatrix dense3 = new(1, 3); Assert.True(dense == dense2); Assert.False(dense != dense2); diff --git a/tests/ImageSharp.Tests/Primitives/PointFTests.cs b/tests/ImageSharp.Tests/Primitives/PointFTests.cs index c3d9e8176b..772d8bd2d0 100644 --- a/tests/ImageSharp.Tests/Primitives/PointFTests.cs +++ b/tests/ImageSharp.Tests/Primitives/PointFTests.cs @@ -9,13 +9,12 @@ namespace SixLabors.ImageSharp.Tests; public class PointFTests { - private static readonly ApproximateFloatComparer ApproximateFloatComparer = - new ApproximateFloatComparer(1e-6f); + private static readonly ApproximateFloatComparer ApproximateFloatComparer = new(1e-6f); [Fact] public void CanReinterpretCastFromVector2() { - var vector = new Vector2(1, 2); + Vector2 vector = new(1, 2); PointF point = Unsafe.As(ref vector); @@ -37,7 +36,7 @@ public void DefaultConstructorTest() [InlineData(0.0, 0.0)] public void NonDefaultConstructorTest(float x, float y) { - var p1 = new PointF(x, y); + PointF p1 = new(x, y); Assert.Equal(x, p1.X); Assert.Equal(y, p1.Y); @@ -67,7 +66,7 @@ public void IsEmptyRandomTest(float x, float y) [InlineData(0, 0)] public void CoordinatesTest(float x, float y) { - var p = new PointF(x, y); + PointF p = new(x, y); Assert.Equal(x, p.X); Assert.Equal(y, p.Y); @@ -84,11 +83,11 @@ public void CoordinatesTest(float x, float y) [InlineData(0, 0, 0, 0)] public void ArithmeticTestWithSize(float x, float y, int x1, int y1) { - var p = new PointF(x, y); - var s = new Size(x1, y1); + PointF p = new(x, y); + Size s = new(x1, y1); - var addExpected = new PointF(x + x1, y + y1); - var subExpected = new PointF(x - x1, y - y1); + PointF addExpected = new(x + x1, y + y1); + PointF subExpected = new(x - x1, y - y1); Assert.Equal(addExpected, p + s); Assert.Equal(subExpected, p - s); Assert.Equal(addExpected, PointF.Add(p, s)); @@ -101,11 +100,11 @@ public void ArithmeticTestWithSize(float x, float y, int x1, int y1) [InlineData(0, 0)] public void ArithmeticTestWithSizeF(float x, float y) { - var p = new PointF(x, y); - var s = new SizeF(y, x); + PointF p = new(x, y); + SizeF s = new(y, x); - var addExpected = new PointF(x + y, y + x); - var subExpected = new PointF(x - y, y - x); + PointF addExpected = new(x + y, y + x); + PointF subExpected = new(x - y, y - x); Assert.Equal(addExpected, p + s); Assert.Equal(subExpected, p - s); Assert.Equal(addExpected, PointF.Add(p, s)); @@ -115,10 +114,10 @@ public void ArithmeticTestWithSizeF(float x, float y) [Fact] public void RotateTest() { - var p = new PointF(13, 17); + PointF p = new(13, 17); Matrix3x2 matrix = Matrix3x2Extensions.CreateRotationDegrees(45, PointF.Empty); - var pout = PointF.Transform(p, matrix); + PointF pout = PointF.Transform(p, matrix); Assert.Equal(-2.82842732F, pout.X, ApproximateFloatComparer); Assert.Equal(21.2132034F, pout.Y, ApproximateFloatComparer); @@ -127,11 +126,11 @@ public void RotateTest() [Fact] public void SkewTest() { - var p = new PointF(13, 17); + PointF p = new(13, 17); Matrix3x2 matrix = Matrix3x2Extensions.CreateSkewDegrees(45, 45, PointF.Empty); - var pout = PointF.Transform(p, matrix); - Assert.Equal(new PointF(30, 30), pout); + PointF pout = PointF.Transform(p, matrix); + Assert.Equal(new(30, 30), pout); } [Theory] @@ -142,8 +141,8 @@ public void SkewTest() [InlineData(0, 0)] public void EqualityTest(float x, float y) { - var pLeft = new PointF(x, y); - var pRight = new PointF(y, x); + PointF pLeft = new(x, y); + PointF pRight = new(y, x); if (x == y) { @@ -164,7 +163,7 @@ public void EqualityTest(float x, float y) [Fact] public void EqualityTest_NotPointF() { - var point = new PointF(0, 0); + PointF point = new(0, 0); Assert.False(point.Equals(null)); Assert.False(point.Equals(0)); @@ -180,7 +179,7 @@ public void EqualityTest_NotPointF() [Fact] public void GetHashCodeTest() { - var point = new PointF(10, 10); + PointF point = new(10, 10); Assert.Equal(point.GetHashCode(), new PointF(10, 10).GetHashCode()); Assert.NotEqual(point.GetHashCode(), new PointF(20, 10).GetHashCode()); Assert.NotEqual(point.GetHashCode(), new PointF(10, 20).GetHashCode()); @@ -189,7 +188,7 @@ public void GetHashCodeTest() [Fact] public void ToStringTest() { - var p = new PointF(5.1F, -5.123F); + PointF p = new(5.1F, -5.123F); Assert.Equal(string.Format(CultureInfo.CurrentCulture, "PointF [ X={0}, Y={1} ]", p.X, p.Y), p.ToString()); } @@ -200,7 +199,7 @@ public void ToStringTest() [InlineData(0, 0)] public void DeconstructTest(float x, float y) { - PointF p = new PointF(x, y); + PointF p = new(x, y); (float deconstructedX, float deconstructedY) = p; diff --git a/tests/ImageSharp.Tests/Primitives/PointTests.cs b/tests/ImageSharp.Tests/Primitives/PointTests.cs index f5c64abf52..8ade95eb14 100644 --- a/tests/ImageSharp.Tests/Primitives/PointTests.cs +++ b/tests/ImageSharp.Tests/Primitives/PointTests.cs @@ -21,8 +21,8 @@ public void DefaultConstructorTest() [InlineData(0, 0)] public void NonDefaultConstructorTest(int x, int y) { - var p1 = new Point(x, y); - var p2 = new Point(new Size(x, y)); + Point p1 = new(x, y); + Point p2 = new(new Size(x, y)); Assert.Equal(p1, p2); } @@ -33,8 +33,8 @@ public void NonDefaultConstructorTest(int x, int y) [InlineData(0)] public void SingleIntConstructorTest(int x) { - var p1 = new Point(x); - var p2 = new Point(unchecked((short)(x & 0xFFFF)), unchecked((short)((x >> 16) & 0xFFFF))); + Point p1 = new(x); + Point p2 = new(unchecked((short)(x & 0xFFFF)), unchecked((short)((x >> 16) & 0xFFFF))); Assert.Equal(p1, p2); } @@ -63,7 +63,7 @@ public void IsEmptyRandomTest(int x, int y) [InlineData(0, 0)] public void CoordinatesTest(int x, int y) { - var p = new Point(x, y); + Point p = new(x, y); Assert.Equal(x, p.X); Assert.Equal(y, p.Y); } @@ -76,7 +76,7 @@ public void CoordinatesTest(int x, int y) public void PointFConversionTest(int x, int y) { PointF p = new Point(x, y); - Assert.Equal(new PointF(x, y), p); + Assert.Equal(new(x, y), p); } [Theory] @@ -86,8 +86,8 @@ public void PointFConversionTest(int x, int y) [InlineData(0, 0)] public void SizeConversionTest(int x, int y) { - var sz = (Size)new Point(x, y); - Assert.Equal(new Size(x, y), sz); + Size sz = (Size)new Point(x, y); + Assert.Equal(new(x, y), sz); } [Theory] @@ -97,13 +97,13 @@ public void SizeConversionTest(int x, int y) [InlineData(0, 0)] public void ArithmeticTest(int x, int y) { - Point addExpected, subExpected, p = new Point(x, y); - var s = new Size(y, x); + Point addExpected, subExpected, p = new(x, y); + Size s = new(y, x); unchecked { - addExpected = new Point(x + y, y + x); - subExpected = new Point(x - y, y - x); + addExpected = new(x + y, y + x); + subExpected = new(x - y, y - x); } Assert.Equal(addExpected, p + s); @@ -119,14 +119,14 @@ public void ArithmeticTest(int x, int y) [InlineData(0, 0)] public void PointFMathematicalTest(float x, float y) { - var pf = new PointF(x, y); + PointF pf = new(x, y); Point pCeiling, pTruncate, pRound; unchecked { - pCeiling = new Point((int)MathF.Ceiling(x), (int)MathF.Ceiling(y)); - pTruncate = new Point((int)x, (int)y); - pRound = new Point((int)MathF.Round(x), (int)MathF.Round(y)); + pCeiling = new((int)MathF.Ceiling(x), (int)MathF.Ceiling(y)); + pTruncate = new((int)x, (int)y); + pRound = new((int)MathF.Round(x), (int)MathF.Round(y)); } Assert.Equal(pCeiling, Point.Ceiling(pf)); @@ -141,8 +141,8 @@ public void PointFMathematicalTest(float x, float y) [InlineData(0, 0)] public void OffsetTest(int x, int y) { - var p1 = new Point(x, y); - var p2 = new Point(y, x); + Point p1 = new(x, y); + Point p2 = new(y, x); p1.Offset(p2); @@ -156,22 +156,22 @@ public void OffsetTest(int x, int y) [Fact] public void RotateTest() { - var p = new Point(13, 17); + Point p = new(13, 17); Matrix3x2 matrix = Matrix3x2Extensions.CreateRotationDegrees(45, Point.Empty); - var pout = Point.Transform(p, matrix); + Point pout = Point.Transform(p, matrix); - Assert.Equal(new Point(-3, 21), pout); + Assert.Equal(new(-3, 21), pout); } [Fact] public void SkewTest() { - var p = new Point(13, 17); + Point p = new(13, 17); Matrix3x2 matrix = Matrix3x2Extensions.CreateSkewDegrees(45, 45, Point.Empty); - var pout = Point.Transform(p, matrix); - Assert.Equal(new Point(30, 30), pout); + Point pout = Point.Transform(p, matrix); + Assert.Equal(new(30, 30), pout); } [Theory] @@ -181,9 +181,9 @@ public void SkewTest() [InlineData(0, 0)] public void EqualityTest(int x, int y) { - var p1 = new Point(x, y); - var p2 = new Point((x / 2) - 1, (y / 2) - 1); - var p3 = new Point(x, y); + Point p1 = new(x, y); + Point p2 = new((x / 2) - 1, (y / 2) - 1); + Point p3 = new(x, y); Assert.True(p1 == p3); Assert.True(p1 != p2); @@ -203,7 +203,7 @@ public void EqualityTest(int x, int y) [Fact] public void EqualityTest_NotPoint() { - var point = new Point(0, 0); + Point point = new(0, 0); Assert.False(point.Equals(null)); Assert.False(point.Equals(0)); Assert.False(point.Equals(new PointF(0, 0))); @@ -212,7 +212,7 @@ public void EqualityTest_NotPoint() [Fact] public void GetHashCodeTest() { - var point = new Point(10, 10); + Point point = new(10, 10); Assert.Equal(point.GetHashCode(), new Point(10, 10).GetHashCode()); Assert.NotEqual(point.GetHashCode(), new Point(20, 10).GetHashCode()); Assert.NotEqual(point.GetHashCode(), new Point(10, 20).GetHashCode()); @@ -223,7 +223,7 @@ public void GetHashCodeTest() [InlineData(1, -2, 3, -4)] public void ConversionTest(int x, int y, int width, int height) { - var rect = new Rectangle(x, y, width, height); + Rectangle rect = new(x, y, width, height); RectangleF rectF = rect; Assert.Equal(x, rectF.X); Assert.Equal(y, rectF.Y); @@ -234,7 +234,7 @@ public void ConversionTest(int x, int y, int width, int height) [Fact] public void ToStringTest() { - var p = new Point(5, -5); + Point p = new(5, -5); Assert.Equal(string.Format(CultureInfo.CurrentCulture, "Point [ X={0}, Y={1} ]", p.X, p.Y), p.ToString()); } @@ -245,7 +245,7 @@ public void ToStringTest() [InlineData(0, 0)] public void DeconstructTest(int x, int y) { - Point p = new Point(x, y); + Point p = new(x, y); (int deconstructedX, int deconstructedY) = p; diff --git a/tests/ImageSharp.Tests/Primitives/RectangleFTests.cs b/tests/ImageSharp.Tests/Primitives/RectangleFTests.cs index a9b3251ca3..4122daaa52 100644 --- a/tests/ImageSharp.Tests/Primitives/RectangleFTests.cs +++ b/tests/ImageSharp.Tests/Primitives/RectangleFTests.cs @@ -23,10 +23,10 @@ public void DefaultConstructorTest() [InlineData(0, float.MinValue, float.MaxValue, 0)] public void NonDefaultConstructorTest(float x, float y, float width, float height) { - var rect1 = new RectangleF(x, y, width, height); - var p = new PointF(x, y); - var s = new SizeF(width, height); - var rect2 = new RectangleF(p, s); + RectangleF rect1 = new(x, y, width, height); + PointF p = new(x, y); + SizeF s = new(width, height); + RectangleF rect2 = new(p, s); Assert.Equal(rect1, rect2); } @@ -38,8 +38,8 @@ public void NonDefaultConstructorTest(float x, float y, float width, float heigh [InlineData(0, float.MinValue, float.MaxValue, 0)] public void FromLTRBTest(float left, float top, float right, float bottom) { - var expected = new RectangleF(left, top, right - left, bottom - top); - var actual = RectangleF.FromLTRB(left, top, right, bottom); + RectangleF expected = new(left, top, right - left, bottom - top); + RectangleF actual = RectangleF.FromLTRB(left, top, right, bottom); Assert.Equal(expected, actual); } @@ -51,9 +51,9 @@ public void FromLTRBTest(float left, float top, float right, float bottom) [InlineData(0, float.MinValue, float.MaxValue, 0)] public void DimensionsTest(float x, float y, float width, float height) { - var rect = new RectangleF(x, y, width, height); - var p = new PointF(x, y); - var s = new SizeF(width, height); + RectangleF rect = new(x, y, width, height); + PointF p = new(x, y); + SizeF s = new(width, height); Assert.Equal(p, rect.Location); Assert.Equal(s, rect.Size); @@ -84,8 +84,8 @@ public void IsEmptyTest() [InlineData(float.MaxValue, float.MinValue)] public void LocationSetTest(float x, float y) { - var point = new PointF(x, y); - var rect = new RectangleF(10, 10, 10, 10) { Location = point }; + PointF point = new(x, y); + RectangleF rect = new(10, 10, 10, 10) { Location = point }; Assert.Equal(point, rect.Location); Assert.Equal(point.X, rect.X); Assert.Equal(point.Y, rect.Y); @@ -96,8 +96,8 @@ public void LocationSetTest(float x, float y) [InlineData(float.MaxValue, float.MinValue)] public void SizeSetTest(float x, float y) { - var size = new SizeF(x, y); - var rect = new RectangleF(10, 10, 10, 10) { Size = size }; + SizeF size = new(x, y); + RectangleF rect = new(10, 10, 10, 10) { Size = size }; Assert.Equal(size, rect.Size); Assert.Equal(size.Width, rect.Width); Assert.Equal(size.Height, rect.Height); @@ -109,8 +109,8 @@ public void SizeSetTest(float x, float y) [InlineData(0, float.MinValue, float.MaxValue, 0)] public void EqualityTest(float x, float y, float width, float height) { - var rect1 = new RectangleF(x, y, width, height); - var rect2 = new RectangleF(width, height, x, y); + RectangleF rect1 = new(x, y, width, height); + RectangleF rect2 = new(width, height, x, y); Assert.True(rect1 != rect2); Assert.False(rect1 == rect2); @@ -121,7 +121,7 @@ public void EqualityTest(float x, float y, float width, float height) [Fact] public void EqualityTestNotRectangleF() { - var rectangle = new RectangleF(0, 0, 0, 0); + RectangleF rectangle = new(0, 0, 0, 0); Assert.False(rectangle.Equals(null)); Assert.False(rectangle.Equals(0)); @@ -137,8 +137,8 @@ public void EqualityTestNotRectangleF() [Fact] public void GetHashCodeTest() { - var rect1 = new RectangleF(10, 10, 10, 10); - var rect2 = new RectangleF(10, 10, 10, 10); + RectangleF rect1 = new(10, 10, 10, 10); + RectangleF rect2 = new(10, 10, 10, 10); Assert.Equal(rect1.GetHashCode(), rect2.GetHashCode()); Assert.NotEqual(rect1.GetHashCode(), new RectangleF(20, 10, 10, 10).GetHashCode()); Assert.NotEqual(rect1.GetHashCode(), new RectangleF(10, 20, 10, 10).GetHashCode()); @@ -151,11 +151,11 @@ public void GetHashCodeTest() [InlineData(0, float.MinValue, float.MaxValue, 0)] public void ContainsTest(float x, float y, float width, float height) { - var rect = new RectangleF(x, y, width, height); + RectangleF rect = new(x, y, width, height); float x1 = (x + width) / 2; float y1 = (y + height) / 2; - var p = new PointF(x1, y1); - var r = new RectangleF(x1, y1, width / 2, height / 2); + PointF p = new(x1, y1); + RectangleF r = new(x1, y1, width / 2, height / 2); Assert.False(rect.Contains(x1, y1)); Assert.False(rect.Contains(p)); @@ -168,13 +168,13 @@ public void ContainsTest(float x, float y, float width, float height) [InlineData(0, float.MinValue, float.MaxValue, 0)] public void InflateTest(float x, float y, float width, float height) { - var rect = new RectangleF(x, y, width, height); - var inflatedRect = new RectangleF(x - width, y - height, width + (2 * width), height + (2 * height)); + RectangleF rect = new(x, y, width, height); + RectangleF inflatedRect = new(x - width, y - height, width + (2 * width), height + (2 * height)); rect.Inflate(width, height); Assert.Equal(inflatedRect, rect); - var s = new SizeF(x, y); + SizeF s = new(x, y); inflatedRect = RectangleF.Inflate(rect, x, y); rect.Inflate(s); @@ -186,9 +186,9 @@ public void InflateTest(float x, float y, float width, float height) [InlineData(0, float.MinValue, float.MaxValue, 0)] public void IntersectTest(float x, float y, float width, float height) { - var rect1 = new RectangleF(x, y, width, height); - var rect2 = new RectangleF(y, x, width, height); - var expectedRect = RectangleF.Intersect(rect1, rect2); + RectangleF rect1 = new(x, y, width, height); + RectangleF rect2 = new(y, x, width, height); + RectangleF expectedRect = RectangleF.Intersect(rect1, rect2); rect1.Intersect(rect2); Assert.Equal(expectedRect, rect1); Assert.False(rect1.IntersectsWith(expectedRect)); @@ -197,9 +197,9 @@ public void IntersectTest(float x, float y, float width, float height) [Fact] public void IntersectIntersectingRectsTest() { - var rect1 = new RectangleF(0, 0, 5, 5); - var rect2 = new RectangleF(1, 1, 3, 3); - var expected = new RectangleF(1, 1, 3, 3); + RectangleF rect1 = new(0, 0, 5, 5); + RectangleF rect2 = new(1, 1, 3, 3); + RectangleF expected = new(1, 1, 3, 3); Assert.Equal(expected, RectangleF.Intersect(rect1, rect2)); } @@ -211,15 +211,15 @@ public void IntersectIntersectingRectsTest() [InlineData(0, float.MinValue, float.MaxValue, 0)] public void UnionTest(float x, float y, float width, float height) { - var a = new RectangleF(x, y, width, height); - var b = new RectangleF(width, height, x, y); + RectangleF a = new(x, y, width, height); + RectangleF b = new(width, height, x, y); float x1 = Math.Min(a.X, b.X); float x2 = Math.Max(a.X + a.Width, b.X + b.Width); float y1 = Math.Min(a.Y, b.Y); float y2 = Math.Max(a.Y + a.Height, b.Y + b.Height); - var expectedRectangle = new RectangleF(x1, y1, x2 - x1, y2 - y1); + RectangleF expectedRectangle = new(x1, y1, x2 - x1, y2 - y1); Assert.Equal(expectedRectangle, RectangleF.Union(a, b)); } @@ -231,9 +231,9 @@ public void UnionTest(float x, float y, float width, float height) [InlineData(0, float.MinValue, float.MaxValue, 0)] public void OffsetTest(float x, float y, float width, float height) { - var r1 = new RectangleF(x, y, width, height); - var expectedRect = new RectangleF(x + width, y + height, width, height); - var p = new PointF(width, height); + RectangleF r1 = new(x, y, width, height); + RectangleF expectedRect = new(x + width, y + height, width, height); + PointF p = new(width, height); r1.Offset(p); Assert.Equal(expectedRect, r1); @@ -246,7 +246,7 @@ public void OffsetTest(float x, float y, float width, float height) [Fact] public void ToStringTest() { - var r = new RectangleF(5, 5.1F, 1.3F, 1); + RectangleF r = new(5, 5.1F, 1.3F, 1); Assert.Equal(string.Format(CultureInfo.CurrentCulture, "RectangleF [ X={0}, Y={1}, Width={2}, Height={3} ]", r.X, r.Y, r.Width, r.Height), r.ToString()); } @@ -270,7 +270,7 @@ public void ToStringTest() [InlineData(0, 0, 0, 0)] public void DeconstructTest(float x, float y, float width, float height) { - RectangleF r = new RectangleF(x, y, width, height); + RectangleF r = new(x, y, width, height); (float dx, float dy, float dw, float dh) = r; diff --git a/tests/ImageSharp.Tests/Primitives/RectangleTests.cs b/tests/ImageSharp.Tests/Primitives/RectangleTests.cs index 2ba3a77315..2a4d64147e 100644 --- a/tests/ImageSharp.Tests/Primitives/RectangleTests.cs +++ b/tests/ImageSharp.Tests/Primitives/RectangleTests.cs @@ -23,8 +23,8 @@ public void DefaultConstructorTest() [InlineData(0, int.MinValue, 0, int.MaxValue)] public void NonDefaultConstructorTest(int x, int y, int width, int height) { - var rect1 = new Rectangle(x, y, width, height); - var rect2 = new Rectangle(new Point(x, y), new Size(width, height)); + Rectangle rect1 = new(x, y, width, height); + Rectangle rect2 = new(new(x, y), new(width, height)); Assert.Equal(rect1, rect2); } @@ -36,8 +36,8 @@ public void NonDefaultConstructorTest(int x, int y, int width, int height) [InlineData(0, int.MinValue, 0, int.MaxValue)] public void FromLTRBTest(int left, int top, int right, int bottom) { - var rect1 = new Rectangle(left, top, unchecked(right - left), unchecked(bottom - top)); - var rect2 = Rectangle.FromLTRB(left, top, right, bottom); + Rectangle rect1 = new(left, top, unchecked(right - left), unchecked(bottom - top)); + Rectangle rect2 = Rectangle.FromLTRB(left, top, right, bottom); Assert.Equal(rect1, rect2); } @@ -68,9 +68,9 @@ public void NonEmptyTest(int x, int y, int width, int height) [InlineData(int.MinValue, int.MaxValue, int.MinValue, int.MaxValue)] public void DimensionsTest(int x, int y, int width, int height) { - var rect = new Rectangle(x, y, width, height); - Assert.Equal(new Point(x, y), rect.Location); - Assert.Equal(new Size(width, height), rect.Size); + Rectangle rect = new(x, y, width, height); + Assert.Equal(new(x, y), rect.Location); + Assert.Equal(new(width, height), rect.Size); Assert.Equal(x, rect.X); Assert.Equal(y, rect.Y); @@ -81,8 +81,8 @@ public void DimensionsTest(int x, int y, int width, int height) Assert.Equal(unchecked(x + width), rect.Right); Assert.Equal(unchecked(y + height), rect.Bottom); - var p = new Point(width, height); - var s = new Size(x, y); + Point p = new(width, height); + Size s = new(x, y); rect.Location = p; rect.Size = s; @@ -104,8 +104,8 @@ public void DimensionsTest(int x, int y, int width, int height) [InlineData(int.MaxValue, int.MinValue)] public void LocationSetTest(int x, int y) { - var point = new Point(x, y); - var rect = new Rectangle(10, 10, 10, 10) { Location = point }; + Point point = new(x, y); + Rectangle rect = new(10, 10, 10, 10) { Location = point }; Assert.Equal(point, rect.Location); Assert.Equal(point.X, rect.X); Assert.Equal(point.Y, rect.Y); @@ -116,8 +116,8 @@ public void LocationSetTest(int x, int y) [InlineData(int.MaxValue, int.MinValue)] public void SizeSetTest(int x, int y) { - var size = new Size(x, y); - var rect = new Rectangle(10, 10, 10, 10) { Size = size }; + Size size = new(x, y); + Rectangle rect = new(10, 10, 10, 10) { Size = size }; Assert.Equal(size, rect.Size); Assert.Equal(size.Width, rect.Width); Assert.Equal(size.Height, rect.Height); @@ -130,8 +130,8 @@ public void SizeSetTest(int x, int y) [InlineData(int.MinValue, int.MaxValue, int.MinValue, int.MaxValue)] public void EqualityTest(int x, int y, int width, int height) { - var rect1 = new Rectangle(x, y, width, height); - var rect2 = new Rectangle(width / 2, height / 2, x, y); + Rectangle rect1 = new(x, y, width, height); + Rectangle rect2 = new(width / 2, height / 2, x, y); Assert.True(rect1 != rect2); Assert.False(rect1 == rect2); @@ -142,7 +142,7 @@ public void EqualityTest(int x, int y, int width, int height) [Fact] public void EqualityTestNotRectangle() { - var rectangle = new Rectangle(0, 0, 0, 0); + Rectangle rectangle = new(0, 0, 0, 0); Assert.False(rectangle.Equals(null)); Assert.False(rectangle.Equals(0)); Assert.False(rectangle.Equals(new RectangleF(0, 0, 0, 0))); @@ -151,8 +151,8 @@ public void EqualityTestNotRectangle() [Fact] public void GetHashCodeTest() { - var rect1 = new Rectangle(10, 10, 10, 10); - var rect2 = new Rectangle(10, 10, 10, 10); + Rectangle rect1 = new(10, 10, 10, 10); + Rectangle rect2 = new(10, 10, 10, 10); Assert.Equal(rect1.GetHashCode(), rect2.GetHashCode()); Assert.NotEqual(rect1.GetHashCode(), new Rectangle(20, 10, 10, 10).GetHashCode()); Assert.NotEqual(rect1.GetHashCode(), new Rectangle(10, 20, 10, 10).GetHashCode()); @@ -166,20 +166,20 @@ public void GetHashCodeTest() [InlineData(0, 0, 0, 0)] public void RectangleFConversionTest(float x, float y, float width, float height) { - var rect = new RectangleF(x, y, width, height); + RectangleF rect = new(x, y, width, height); Rectangle rCeiling, rTruncate, rRound; unchecked { - rCeiling = new Rectangle( + rCeiling = new( (int)Math.Ceiling(x), (int)Math.Ceiling(y), (int)Math.Ceiling(width), (int)Math.Ceiling(height)); - rTruncate = new Rectangle((int)x, (int)y, (int)width, (int)height); + rTruncate = new((int)x, (int)y, (int)width, (int)height); - rRound = new Rectangle( + rRound = new( (int)Math.Round(x), (int)Math.Round(y), (int)Math.Round(width), @@ -196,9 +196,9 @@ public void RectangleFConversionTest(float x, float y, float width, float height [InlineData(0, int.MinValue, int.MaxValue, 0)] public void ContainsTest(int x, int y, int width, int height) { - var rect = new Rectangle(unchecked((2 * x) - width), unchecked((2 * y) - height), width, height); - var p = new Point(x, y); - var r = new Rectangle(x, y, width / 2, height / 2); + Rectangle rect = new(unchecked((2 * x) - width), unchecked((2 * y) - height), width, height); + Point p = new(x, y); + Rectangle r = new(x, y, width / 2, height / 2); Assert.False(rect.Contains(x, y)); Assert.False(rect.Contains(p)); @@ -211,10 +211,10 @@ public void ContainsTest(int x, int y, int width, int height) [InlineData(0, int.MinValue, int.MaxValue, 0)] public void InflateTest(int x, int y, int width, int height) { - Rectangle inflatedRect, rect = new Rectangle(x, y, width, height); + Rectangle inflatedRect, rect = new(x, y, width, height); unchecked { - inflatedRect = new Rectangle(x - width, y - height, width + (2 * width), height + (2 * height)); + inflatedRect = new(x - width, y - height, width + (2 * width), height + (2 * height)); } Assert.Equal(inflatedRect, Rectangle.Inflate(rect, width, height)); @@ -222,10 +222,10 @@ public void InflateTest(int x, int y, int width, int height) rect.Inflate(width, height); Assert.Equal(inflatedRect, rect); - var s = new Size(x, y); + Size s = new(x, y); unchecked { - inflatedRect = new Rectangle(rect.X - x, rect.Y - y, rect.Width + (2 * x), rect.Height + (2 * y)); + inflatedRect = new(rect.X - x, rect.Y - y, rect.Width + (2 * x), rect.Height + (2 * y)); } rect.Inflate(s); @@ -238,8 +238,8 @@ public void InflateTest(int x, int y, int width, int height) [InlineData(0, int.MinValue, int.MaxValue, 0)] public void IntersectTest(int x, int y, int width, int height) { - var rect = new Rectangle(x, y, width, height); - var expectedRect = Rectangle.Intersect(rect, rect); + Rectangle rect = new(x, y, width, height); + Rectangle expectedRect = Rectangle.Intersect(rect, rect); rect.Intersect(rect); Assert.Equal(expectedRect, rect); Assert.False(rect.IntersectsWith(expectedRect)); @@ -248,9 +248,9 @@ public void IntersectTest(int x, int y, int width, int height) [Fact] public void IntersectIntersectingRectsTest() { - var rect1 = new Rectangle(0, 0, 5, 5); - var rect2 = new Rectangle(1, 1, 3, 3); - var expected = new Rectangle(1, 1, 3, 3); + Rectangle rect1 = new(0, 0, 5, 5); + Rectangle rect2 = new(1, 1, 3, 3); + Rectangle expected = new(1, 1, 3, 3); Assert.Equal(expected, Rectangle.Intersect(rect1, rect2)); } @@ -262,15 +262,15 @@ public void IntersectIntersectingRectsTest() [InlineData(0, int.MinValue, int.MaxValue, 0)] public void UnionTest(int x, int y, int width, int height) { - var a = new Rectangle(x, y, width, height); - var b = new Rectangle(width, height, x, y); + Rectangle a = new(x, y, width, height); + Rectangle b = new(width, height, x, y); int x1 = Math.Min(a.X, b.X); int x2 = Math.Max(a.X + a.Width, b.X + b.Width); int y1 = Math.Min(a.Y, b.Y); int y2 = Math.Max(a.Y + a.Height, b.Y + b.Height); - var expectedRectangle = new Rectangle(x1, y1, x2 - x1, y2 - y1); + Rectangle expectedRectangle = new(x1, y1, x2 - x1, y2 - y1); Assert.Equal(expectedRectangle, Rectangle.Union(a, b)); } @@ -282,9 +282,9 @@ public void UnionTest(int x, int y, int width, int height) [InlineData(0, int.MinValue, int.MaxValue, 0)] public void OffsetTest(int x, int y, int width, int height) { - var r1 = new Rectangle(x, y, width, height); - var expectedRect = new Rectangle(x + width, y + height, width, height); - var p = new Point(width, height); + Rectangle r1 = new(x, y, width, height); + Rectangle expectedRect = new(x + width, y + height, width, height); + Point p = new(width, height); r1.Offset(p); Assert.Equal(expectedRect, r1); @@ -297,7 +297,7 @@ public void OffsetTest(int x, int y, int width, int height) [Fact] public void ToStringTest() { - var r = new Rectangle(5, -5, 0, 1); + Rectangle r = new(5, -5, 0, 1); Assert.Equal(string.Format(CultureInfo.CurrentCulture, "Rectangle [ X={0}, Y={1}, Width={2}, Height={3} ]", r.X, r.Y, r.Width, r.Height), r.ToString()); } @@ -321,7 +321,7 @@ public void ToStringTest() [InlineData(0, 0, 0, 0)] public void DeconstructTest(int x, int y, int width, int height) { - var r = new Rectangle(x, y, width, height); + Rectangle r = new(x, y, width, height); (int dx, int dy, int dw, int dh) = r; diff --git a/tests/ImageSharp.Tests/Primitives/SizeFTests.cs b/tests/ImageSharp.Tests/Primitives/SizeFTests.cs index 1a36b4921a..246f21b1ee 100644 --- a/tests/ImageSharp.Tests/Primitives/SizeFTests.cs +++ b/tests/ImageSharp.Tests/Primitives/SizeFTests.cs @@ -20,13 +20,13 @@ public void DefaultConstructorTest() [InlineData(0, 0)] public void NonDefaultConstructorAndDimensionsTest(float width, float height) { - var s1 = new SizeF(width, height); - var p1 = new PointF(width, height); - var s2 = new SizeF(s1); + SizeF s1 = new(width, height); + PointF p1 = new(width, height); + SizeF s2 = new(s1); Assert.Equal(s1, s2); - Assert.Equal(s1, new SizeF(p1)); - Assert.Equal(s2, new SizeF(p1)); + Assert.Equal(s1, new(p1)); + Assert.Equal(s2, new(p1)); Assert.Equal(width, s1.Width); Assert.Equal(height, s1.Height); @@ -62,10 +62,10 @@ public void IsEmptyRandomTest(float width, float height) [InlineData(0, 0)] public void ArithmeticTest(float width, float height) { - var s1 = new SizeF(width, height); - var s2 = new SizeF(height, width); - var addExpected = new SizeF(width + height, width + height); - var subExpected = new SizeF(width - height, height - width); + SizeF s1 = new(width, height); + SizeF s2 = new(height, width); + SizeF addExpected = new(width + height, width + height); + SizeF subExpected = new(width - height, height - width); Assert.Equal(addExpected, s1 + s2); Assert.Equal(addExpected, SizeF.Add(s1, s2)); @@ -81,8 +81,8 @@ public void ArithmeticTest(float width, float height) [InlineData(0, 0)] public void EqualityTest(float width, float height) { - var sLeft = new SizeF(width, height); - var sRight = new SizeF(height, width); + SizeF sLeft = new(width, height); + SizeF sRight = new(height, width); if (width == height) { @@ -103,7 +103,7 @@ public void EqualityTest(float width, float height) [Fact] public void EqualityTest_NotSizeF() { - var size = new SizeF(0, 0); + SizeF size = new(0, 0); Assert.False(size.Equals(null)); Assert.False(size.Equals(0)); @@ -119,7 +119,7 @@ public void EqualityTest_NotSizeF() [Fact] public void GetHashCodeTest() { - var size = new SizeF(10, 10); + SizeF size = new(10, 10); Assert.Equal(size.GetHashCode(), new SizeF(10, 10).GetHashCode()); Assert.NotEqual(size.GetHashCode(), new SizeF(20, 10).GetHashCode()); Assert.NotEqual(size.GetHashCode(), new SizeF(10, 20).GetHashCode()); @@ -132,11 +132,11 @@ public void GetHashCodeTest() [InlineData(0, 0)] public void ConversionTest(float width, float height) { - var s1 = new SizeF(width, height); - var p1 = (PointF)s1; - var s2 = new Size(unchecked((int)width), unchecked((int)height)); + SizeF s1 = new(width, height); + PointF p1 = (PointF)s1; + Size s2 = new(unchecked((int)width), unchecked((int)height)); - Assert.Equal(new PointF(width, height), p1); + Assert.Equal(new(width, height), p1); Assert.Equal(p1, (PointF)s1); Assert.Equal(s2, (Size)s1); } @@ -144,7 +144,7 @@ public void ConversionTest(float width, float height) [Fact] public void ToStringTest() { - var sz = new SizeF(10, 5); + SizeF sz = new(10, 5); Assert.Equal(string.Format(CultureInfo.CurrentCulture, "SizeF [ Width={0}, Height={1} ]", sz.Width, sz.Height), sz.ToString()); } @@ -172,10 +172,10 @@ public void ToStringTest() [InlineData(float.MinValue, float.MinValue)] public void MultiplicationTest(float dimension, float multiplier) { - SizeF sz1 = new SizeF(dimension, dimension); + SizeF sz1 = new(dimension, dimension); SizeF mulExpected; - mulExpected = new SizeF(dimension * multiplier, dimension * multiplier); + mulExpected = new(dimension * multiplier, dimension * multiplier); Assert.Equal(mulExpected, sz1 * multiplier); Assert.Equal(mulExpected, multiplier * sz1); @@ -185,10 +185,10 @@ public void MultiplicationTest(float dimension, float multiplier) [InlineData(1111.1111f, 2222.2222f, 3333.3333f)] public void MultiplicationTestWidthHeightMultiplier(float width, float height, float multiplier) { - SizeF sz1 = new SizeF(width, height); + SizeF sz1 = new(width, height); SizeF mulExpected; - mulExpected = new SizeF(width * multiplier, height * multiplier); + mulExpected = new(width * multiplier, height * multiplier); Assert.Equal(mulExpected, sz1 * multiplier); Assert.Equal(mulExpected, multiplier * sz1); @@ -215,8 +215,8 @@ public void MultiplicationTestWidthHeightMultiplier(float width, float height, f [InlineData(-1.0f, float.MaxValue)] public void DivideTestSizeFloat(float dimension, float divisor) { - SizeF size = new SizeF(dimension, dimension); - SizeF expected = new SizeF(dimension / divisor, dimension / divisor); + SizeF size = new(dimension, dimension); + SizeF expected = new(dimension / divisor, dimension / divisor); Assert.Equal(expected, size / divisor); } @@ -224,8 +224,8 @@ public void DivideTestSizeFloat(float dimension, float divisor) [InlineData(-111.111f, 222.222f, 333.333f)] public void DivideTestSizeFloatWidthHeightDivisor(float width, float height, float divisor) { - SizeF size = new SizeF(width, height); - SizeF expected = new SizeF(width / divisor, height / divisor); + SizeF size = new(width, height); + SizeF expected = new(width / divisor, height / divisor); Assert.Equal(expected, size / divisor); } @@ -236,7 +236,7 @@ public void DivideTestSizeFloatWidthHeightDivisor(float width, float height, flo [InlineData(0, 0)] public void DeconstructTest(float width, float height) { - SizeF s = new SizeF(width, height); + SizeF s = new(width, height); (float deconstructedWidth, float deconstructedHeight) = s; diff --git a/tests/ImageSharp.Tests/Primitives/SizeTests.cs b/tests/ImageSharp.Tests/Primitives/SizeTests.cs index eec1fb63b0..6b366e183f 100644 --- a/tests/ImageSharp.Tests/Primitives/SizeTests.cs +++ b/tests/ImageSharp.Tests/Primitives/SizeTests.cs @@ -23,8 +23,8 @@ public void DefaultConstructorTest() [InlineData(0, 0)] public void NonDefaultConstructorTest(int width, int height) { - var s1 = new Size(width, height); - var s2 = new Size(new Point(width, height)); + Size s1 = new(width, height); + Size s2 = new(new Point(width, height)); Assert.Equal(s1, s2); @@ -59,7 +59,7 @@ public void IsEmptyRandomTest(int width, int height) [InlineData(0, 0)] public void DimensionsTest(int width, int height) { - var p = new Size(width, height); + Size p = new(width, height); Assert.Equal(width, p.Width); Assert.Equal(height, p.Height); } @@ -72,7 +72,7 @@ public void DimensionsTest(int width, int height) public void PointFConversionTest(int width, int height) { SizeF sz = new Size(width, height); - Assert.Equal(new SizeF(width, height), sz); + Assert.Equal(new(width, height), sz); } [Theory] @@ -82,8 +82,8 @@ public void PointFConversionTest(int width, int height) [InlineData(0, 0)] public void SizeConversionTest(int width, int height) { - var sz = (Point)new Size(width, height); - Assert.Equal(new Point(width, height), sz); + Point sz = (Point)new Size(width, height); + Assert.Equal(new(width, height), sz); } [Theory] @@ -93,14 +93,14 @@ public void SizeConversionTest(int width, int height) [InlineData(0, 0)] public void ArithmeticTest(int width, int height) { - var sz1 = new Size(width, height); - var sz2 = new Size(height, width); + Size sz1 = new(width, height); + Size sz2 = new(height, width); Size addExpected, subExpected; unchecked { - addExpected = new Size(width + height, height + width); - subExpected = new Size(width - height, height - width); + addExpected = new(width + height, height + width); + subExpected = new(width - height, height - width); } Assert.Equal(addExpected, sz1 + sz2); @@ -116,14 +116,14 @@ public void ArithmeticTest(int width, int height) [InlineData(0, 0)] public void PointFMathematicalTest(float width, float height) { - var szF = new SizeF(width, height); + SizeF szF = new(width, height); Size pCeiling, pTruncate, pRound; unchecked { - pCeiling = new Size((int)MathF.Ceiling(width), (int)MathF.Ceiling(height)); - pTruncate = new Size((int)width, (int)height); - pRound = new Size((int)MathF.Round(width), (int)MathF.Round(height)); + pCeiling = new((int)MathF.Ceiling(width), (int)MathF.Ceiling(height)); + pTruncate = new((int)width, (int)height); + pRound = new((int)MathF.Round(width), (int)MathF.Round(height)); } Assert.Equal(pCeiling, Size.Ceiling(szF)); @@ -138,9 +138,9 @@ public void PointFMathematicalTest(float width, float height) [InlineData(0, 0)] public void EqualityTest(int width, int height) { - var p1 = new Size(width, height); - var p2 = new Size(unchecked(width - 1), unchecked(height - 1)); - var p3 = new Size(width, height); + Size p1 = new(width, height); + Size p2 = new(unchecked(width - 1), unchecked(height - 1)); + Size p3 = new(width, height); Assert.True(p1 == p3); Assert.True(p1 != p2); @@ -160,7 +160,7 @@ public void EqualityTest(int width, int height) [Fact] public void EqualityTest_NotSize() { - var size = new Size(0, 0); + Size size = new(0, 0); Assert.False(size.Equals(null)); Assert.False(size.Equals(0)); Assert.False(size.Equals(new SizeF(0, 0))); @@ -169,7 +169,7 @@ public void EqualityTest_NotSize() [Fact] public void GetHashCodeTest() { - var size = new Size(10, 10); + Size size = new(10, 10); Assert.Equal(size.GetHashCode(), new Size(10, 10).GetHashCode()); Assert.NotEqual(size.GetHashCode(), new Size(20, 10).GetHashCode()); Assert.NotEqual(size.GetHashCode(), new Size(10, 20).GetHashCode()); @@ -178,7 +178,7 @@ public void GetHashCodeTest() [Fact] public void ToStringTest() { - var sz = new Size(10, 5); + Size sz = new(10, 5); Assert.Equal(string.Format(CultureInfo.CurrentCulture, "Size [ Width={0}, Height={1} ]", sz.Width, sz.Height), sz.ToString()); } @@ -206,12 +206,12 @@ public void ToStringTest() [InlineData(int.MinValue, int.MinValue)] public void MultiplicationTestSizeInt(int dimension, int multiplier) { - Size sz1 = new Size(dimension, dimension); + Size sz1 = new(dimension, dimension); Size mulExpected; unchecked { - mulExpected = new Size(dimension * multiplier, dimension * multiplier); + mulExpected = new(dimension * multiplier, dimension * multiplier); } Assert.Equal(mulExpected, sz1 * multiplier); @@ -222,12 +222,12 @@ public void MultiplicationTestSizeInt(int dimension, int multiplier) [InlineData(1000, 2000, 3000)] public void MultiplicationTestSizeIntWidthHeightMultiplier(int width, int height, int multiplier) { - Size sz1 = new Size(width, height); + Size sz1 = new(width, height); Size mulExpected; unchecked { - mulExpected = new Size(width * multiplier, height * multiplier); + mulExpected = new(width * multiplier, height * multiplier); } Assert.Equal(mulExpected, sz1 * multiplier); @@ -258,10 +258,10 @@ public void MultiplicationTestSizeIntWidthHeightMultiplier(int width, int height [InlineData(int.MinValue, float.MinValue)] public void MultiplicationTestSizeFloat(int dimension, float multiplier) { - Size sz1 = new Size(dimension, dimension); + Size sz1 = new(dimension, dimension); SizeF mulExpected; - mulExpected = new SizeF(dimension * multiplier, dimension * multiplier); + mulExpected = new(dimension * multiplier, dimension * multiplier); Assert.Equal(mulExpected, sz1 * multiplier); Assert.Equal(mulExpected, multiplier * sz1); @@ -271,10 +271,10 @@ public void MultiplicationTestSizeFloat(int dimension, float multiplier) [InlineData(1000, 2000, 30.33f)] public void MultiplicationTestSizeFloatWidthHeightMultiplier(int width, int height, float multiplier) { - Size sz1 = new Size(width, height); + Size sz1 = new(width, height); SizeF mulExpected; - mulExpected = new SizeF(width * multiplier, height * multiplier); + mulExpected = new(width * multiplier, height * multiplier); Assert.Equal(mulExpected, sz1 * multiplier); Assert.Equal(mulExpected, multiplier * sz1); @@ -283,10 +283,10 @@ public void MultiplicationTestSizeFloatWidthHeightMultiplier(int width, int heig [Fact] public void DivideByZeroChecks() { - Size size = new Size(100, 100); + Size size = new(100, 100); Assert.Throws(() => size / 0); - SizeF expectedSizeF = new SizeF(float.PositiveInfinity, float.PositiveInfinity); + SizeF expectedSizeF = new(float.PositiveInfinity, float.PositiveInfinity); Assert.Equal(expectedSizeF, size / 0.0f); } @@ -305,10 +305,10 @@ public void DivideByZeroChecks() [InlineData(int.MaxValue, -1)] public void DivideTestSizeInt(int dimension, int divisor) { - Size size = new Size(dimension, dimension); + Size size = new(dimension, dimension); Size expected; - expected = new Size(dimension / divisor, dimension / divisor); + expected = new(dimension / divisor, dimension / divisor); Assert.Equal(expected, size / divisor); } @@ -317,10 +317,10 @@ public void DivideTestSizeInt(int dimension, int divisor) [InlineData(1111, 2222, 3333)] public void DivideTestSizeIntWidthHeightDivisor(int width, int height, int divisor) { - Size size = new Size(width, height); + Size size = new(width, height); Size expected; - expected = new Size(width / divisor, height / divisor); + expected = new(width / divisor, height / divisor); Assert.Equal(expected, size / divisor); } @@ -341,10 +341,10 @@ public void DivideTestSizeIntWidthHeightDivisor(int width, int height, int divis [InlineData(int.MinValue, -1.0f)] public void DivideTestSizeFloat(int dimension, float divisor) { - SizeF size = new SizeF(dimension, dimension); + SizeF size = new(dimension, dimension); SizeF expected; - expected = new SizeF(dimension / divisor, dimension / divisor); + expected = new(dimension / divisor, dimension / divisor); Assert.Equal(expected, size / divisor); } @@ -352,10 +352,10 @@ public void DivideTestSizeFloat(int dimension, float divisor) [InlineData(1111, 2222, -333.33f)] public void DivideTestSizeFloatWidthHeightDivisor(int width, int height, float divisor) { - SizeF size = new SizeF(width, height); + SizeF size = new(width, height); SizeF expected; - expected = new SizeF(width / divisor, height / divisor); + expected = new(width / divisor, height / divisor); Assert.Equal(expected, size / divisor); } @@ -366,7 +366,7 @@ public void DivideTestSizeFloatWidthHeightDivisor(int width, int height, float d [InlineData(0, 0)] public void DeconstructTest(int width, int height) { - Size s = new Size(width, height); + Size s = new(width, height); (int deconstructedWidth, int deconstructedHeight) = s; diff --git a/tests/ImageSharp.Tests/Processing/BaseImageOperationsExtensionTest.cs b/tests/ImageSharp.Tests/Processing/BaseImageOperationsExtensionTest.cs index 403865e662..1ff67e5e55 100644 --- a/tests/ImageSharp.Tests/Processing/BaseImageOperationsExtensionTest.cs +++ b/tests/ImageSharp.Tests/Processing/BaseImageOperationsExtensionTest.cs @@ -19,10 +19,10 @@ public abstract class BaseImageOperationsExtensionTest : IDisposable public BaseImageOperationsExtensionTest() { - this.options = new GraphicsOptions { Antialias = false }; - this.source = new Image(91 + 324, 123 + 56); - this.rect = new Rectangle(91, 123, 324, 56); // make this random? - this.internalOperations = new FakeImageOperationsProvider.FakeImageOperations(this.source.Configuration, this.source, false); + this.options = new() { Antialias = false }; + this.source = new(91 + 324, 123 + 56); + this.rect = new(91, 123, 324, 56); // make this random? + this.internalOperations = new(this.source.Configuration, this.source, false); this.internalOperations.SetGraphicsOptions(this.options); this.operations = this.internalOperations; } diff --git a/tests/ImageSharp.Tests/Processing/Binarization/OrderedDitherFactoryTests.cs b/tests/ImageSharp.Tests/Processing/Binarization/OrderedDitherFactoryTests.cs index c7eb959535..32b8bf276a 100644 --- a/tests/ImageSharp.Tests/Processing/Binarization/OrderedDitherFactoryTests.cs +++ b/tests/ImageSharp.Tests/Processing/Binarization/OrderedDitherFactoryTests.cs @@ -10,14 +10,14 @@ public class OrderedDitherFactoryTests { #pragma warning disable SA1025 // Code should not contain multiple whitespace in a row - private static readonly DenseMatrix Expected2x2Matrix = new DenseMatrix( + private static readonly DenseMatrix Expected2x2Matrix = new( new uint[2, 2] { { 0, 2 }, { 3, 1 } }); - private static readonly DenseMatrix Expected3x3Matrix = new DenseMatrix( + private static readonly DenseMatrix Expected3x3Matrix = new( new uint[3, 3] { { 0, 5, 2 }, @@ -25,7 +25,7 @@ public class OrderedDitherFactoryTests { 3, 6, 1 } }); - private static readonly DenseMatrix Expected4x4Matrix = new DenseMatrix( + private static readonly DenseMatrix Expected4x4Matrix = new( new uint[4, 4] { { 0, 8, 2, 10 }, @@ -34,7 +34,7 @@ public class OrderedDitherFactoryTests { 15, 7, 13, 5 } }); - private static readonly DenseMatrix Expected8x8Matrix = new DenseMatrix( + private static readonly DenseMatrix Expected8x8Matrix = new( new uint[8, 8] { { 0, 32, 8, 40, 2, 34, 10, 42 }, diff --git a/tests/ImageSharp.Tests/Processing/Convolution/BoxBlurTest.cs b/tests/ImageSharp.Tests/Processing/Convolution/BoxBlurTest.cs index da2bc465f6..2337e4567d 100644 --- a/tests/ImageSharp.Tests/Processing/Convolution/BoxBlurTest.cs +++ b/tests/ImageSharp.Tests/Processing/Convolution/BoxBlurTest.cs @@ -13,7 +13,7 @@ public class BoxBlurTest : BaseImageOperationsExtensionTest public void BoxBlur_BoxBlurProcessorDefaultsSet() { this.operations.BoxBlur(); - var processor = this.Verify(); + BoxBlurProcessor processor = this.Verify(); Assert.Equal(7, processor.Radius); } @@ -22,7 +22,7 @@ public void BoxBlur_BoxBlurProcessorDefaultsSet() public void BoxBlur_amount_BoxBlurProcessorDefaultsSet() { this.operations.BoxBlur(34); - var processor = this.Verify(); + BoxBlurProcessor processor = this.Verify(); Assert.Equal(34, processor.Radius); } @@ -31,7 +31,7 @@ public void BoxBlur_amount_BoxBlurProcessorDefaultsSet() public void BoxBlur_amount_rect_BoxBlurProcessorDefaultsSet() { this.operations.BoxBlur(5, this.rect); - var processor = this.Verify(this.rect); + BoxBlurProcessor processor = this.Verify(this.rect); Assert.Equal(5, processor.Radius); } diff --git a/tests/ImageSharp.Tests/Processing/Convolution/GaussianBlurTest.cs b/tests/ImageSharp.Tests/Processing/Convolution/GaussianBlurTest.cs index 5142791603..77706869a2 100644 --- a/tests/ImageSharp.Tests/Processing/Convolution/GaussianBlurTest.cs +++ b/tests/ImageSharp.Tests/Processing/Convolution/GaussianBlurTest.cs @@ -13,7 +13,7 @@ public class GaussianBlurTest : BaseImageOperationsExtensionTest public void GaussianBlur_GaussianBlurProcessorDefaultsSet() { this.operations.GaussianBlur(); - var processor = this.Verify(); + GaussianBlurProcessor processor = this.Verify(); Assert.Equal(3f, processor.Sigma); } @@ -22,7 +22,7 @@ public void GaussianBlur_GaussianBlurProcessorDefaultsSet() public void GaussianBlur_amount_GaussianBlurProcessorDefaultsSet() { this.operations.GaussianBlur(0.2f); - var processor = this.Verify(); + GaussianBlurProcessor processor = this.Verify(); Assert.Equal(.2f, processor.Sigma); } @@ -31,7 +31,7 @@ public void GaussianBlur_amount_GaussianBlurProcessorDefaultsSet() public void GaussianBlur_amount_rect_GaussianBlurProcessorDefaultsSet() { this.operations.GaussianBlur(0.6f, this.rect); - var processor = this.Verify(this.rect); + GaussianBlurProcessor processor = this.Verify(this.rect); Assert.Equal(.6f, processor.Sigma); } diff --git a/tests/ImageSharp.Tests/Processing/Convolution/GaussianSharpenTest.cs b/tests/ImageSharp.Tests/Processing/Convolution/GaussianSharpenTest.cs index b48ebac0dc..5d0f0e4df4 100644 --- a/tests/ImageSharp.Tests/Processing/Convolution/GaussianSharpenTest.cs +++ b/tests/ImageSharp.Tests/Processing/Convolution/GaussianSharpenTest.cs @@ -13,7 +13,7 @@ public class GaussianSharpenTest : BaseImageOperationsExtensionTest public void GaussianSharpen_GaussianSharpenProcessorDefaultsSet() { this.operations.GaussianSharpen(); - var processor = this.Verify(); + GaussianSharpenProcessor processor = this.Verify(); Assert.Equal(3f, processor.Sigma); } @@ -22,7 +22,7 @@ public void GaussianSharpen_GaussianSharpenProcessorDefaultsSet() public void GaussianSharpen_amount_GaussianSharpenProcessorDefaultsSet() { this.operations.GaussianSharpen(0.2f); - var processor = this.Verify(); + GaussianSharpenProcessor processor = this.Verify(); Assert.Equal(.2f, processor.Sigma); } @@ -31,7 +31,7 @@ public void GaussianSharpen_amount_GaussianSharpenProcessorDefaultsSet() public void GaussianSharpen_amount_rect_GaussianSharpenProcessorDefaultsSet() { this.operations.GaussianSharpen(0.6f, this.rect); - var processor = this.Verify(this.rect); + GaussianSharpenProcessor processor = this.Verify(this.rect); Assert.Equal(.6f, processor.Sigma); } diff --git a/tests/ImageSharp.Tests/Processing/Convolution/KernelSamplingMapTest.cs b/tests/ImageSharp.Tests/Processing/Convolution/KernelSamplingMapTest.cs index 476e5b0a90..eb1d3031a4 100644 --- a/tests/ImageSharp.Tests/Processing/Convolution/KernelSamplingMapTest.cs +++ b/tests/ImageSharp.Tests/Processing/Convolution/KernelSamplingMapTest.cs @@ -11,87 +11,87 @@ public class KernelSamplingMapTest [Fact] public void KernalSamplingMap_Kernel5Image7x7RepeatBorder() { - var kernelSize = new Size(5, 5); - var bounds = new Rectangle(0, 0, 7, 7); - var mode = BorderWrappingMode.Repeat; + Size kernelSize = new(5, 5); + Rectangle bounds = new(0, 0, 7, 7); + BorderWrappingMode mode = BorderWrappingMode.Repeat; int[] expected = - { + [ 0, 0, 0, 1, 2, 0, 0, 1, 2, 3, 0, 1, 2, 3, 4, 1, 2, 3, 4, 5, 2, 3, 4, 5, 6, 3, 4, 5, 6, 6, - 4, 5, 6, 6, 6, - }; + 4, 5, 6, 6, 6 + ]; this.AssertOffsets(kernelSize, bounds, mode, mode, expected, expected); } [Fact] public void KernalSamplingMap_Kernel5Image7x7BounceBorder() { - var kernelSize = new Size(5, 5); - var bounds = new Rectangle(0, 0, 7, 7); - var mode = BorderWrappingMode.Bounce; + Size kernelSize = new(5, 5); + Rectangle bounds = new(0, 0, 7, 7); + BorderWrappingMode mode = BorderWrappingMode.Bounce; int[] expected = - { + [ 2, 1, 0, 1, 2, 1, 0, 1, 2, 3, 0, 1, 2, 3, 4, 1, 2, 3, 4, 5, 2, 3, 4, 5, 6, 3, 4, 5, 6, 5, - 4, 5, 6, 5, 4, - }; + 4, 5, 6, 5, 4 + ]; this.AssertOffsets(kernelSize, bounds, mode, mode, expected, expected); } [Fact] public void KernalSamplingMap_Kernel5Image7x7MirrorBorder() { - var kernelSize = new Size(5, 5); - var bounds = new Rectangle(0, 0, 7, 7); - var mode = BorderWrappingMode.Mirror; + Size kernelSize = new(5, 5); + Rectangle bounds = new(0, 0, 7, 7); + BorderWrappingMode mode = BorderWrappingMode.Mirror; int[] expected = - { + [ 1, 0, 0, 1, 2, 0, 0, 1, 2, 3, 0, 1, 2, 3, 4, 1, 2, 3, 4, 5, 2, 3, 4, 5, 6, 3, 4, 5, 6, 6, - 4, 5, 6, 6, 5, - }; + 4, 5, 6, 6, 5 + ]; this.AssertOffsets(kernelSize, bounds, mode, mode, expected, expected); } [Fact] public void KernalSamplingMap_Kernel5Image7x7WrapBorder() { - var kernelSize = new Size(5, 5); - var bounds = new Rectangle(0, 0, 7, 7); - var mode = BorderWrappingMode.Wrap; + Size kernelSize = new(5, 5); + Rectangle bounds = new(0, 0, 7, 7); + BorderWrappingMode mode = BorderWrappingMode.Wrap; int[] expected = - { + [ 5, 6, 0, 1, 2, 6, 0, 1, 2, 3, 0, 1, 2, 3, 4, 1, 2, 3, 4, 5, 2, 3, 4, 5, 6, 3, 4, 5, 6, 0, - 4, 5, 6, 0, 1, - }; + 4, 5, 6, 0, 1 + ]; this.AssertOffsets(kernelSize, bounds, mode, mode, expected, expected); } [Fact] public void KernalSamplingMap_Kernel5Image9x9BounceBorder() { - var kernelSize = new Size(5, 5); - var bounds = new Rectangle(1, 1, 9, 9); - var mode = BorderWrappingMode.Bounce; + Size kernelSize = new(5, 5); + Rectangle bounds = new(1, 1, 9, 9); + BorderWrappingMode mode = BorderWrappingMode.Bounce; int[] expected = - { + [ 3, 2, 1, 2, 3, 2, 1, 2, 3, 4, 1, 2, 3, 4, 5, @@ -100,19 +100,19 @@ public void KernalSamplingMap_Kernel5Image9x9BounceBorder() 4, 5, 6, 7, 8, 5, 6, 7, 8, 9, 6, 7, 8, 9, 8, - 7, 8, 9, 8, 7, - }; + 7, 8, 9, 8, 7 + ]; this.AssertOffsets(kernelSize, bounds, mode, mode, expected, expected); } [Fact] public void KernalSamplingMap_Kernel5Image9x9MirrorBorder() { - var kernelSize = new Size(5, 5); - var bounds = new Rectangle(1, 1, 9, 9); - var mode = BorderWrappingMode.Mirror; + Size kernelSize = new(5, 5); + Rectangle bounds = new(1, 1, 9, 9); + BorderWrappingMode mode = BorderWrappingMode.Mirror; int[] expected = - { + [ 2, 1, 1, 2, 3, 1, 1, 2, 3, 4, 1, 2, 3, 4, 5, @@ -121,19 +121,19 @@ public void KernalSamplingMap_Kernel5Image9x9MirrorBorder() 4, 5, 6, 7, 8, 5, 6, 7, 8, 9, 6, 7, 8, 9, 9, - 7, 8, 9, 9, 8, - }; + 7, 8, 9, 9, 8 + ]; this.AssertOffsets(kernelSize, bounds, mode, mode, expected, expected); } [Fact] public void KernalSamplingMap_Kernel5Image9x9WrapBorder() { - var kernelSize = new Size(5, 5); - var bounds = new Rectangle(1, 1, 9, 9); - var mode = BorderWrappingMode.Wrap; + Size kernelSize = new(5, 5); + Rectangle bounds = new(1, 1, 9, 9); + BorderWrappingMode mode = BorderWrappingMode.Wrap; int[] expected = - { + [ 8, 9, 1, 2, 3, 9, 1, 2, 3, 4, 1, 2, 3, 4, 5, @@ -142,278 +142,278 @@ public void KernalSamplingMap_Kernel5Image9x9WrapBorder() 4, 5, 6, 7, 8, 5, 6, 7, 8, 9, 6, 7, 8, 9, 1, - 7, 8, 9, 1, 2, - }; + 7, 8, 9, 1, 2 + ]; this.AssertOffsets(kernelSize, bounds, mode, mode, expected, expected); } [Fact] public void KernalSamplingMap_Kernel5Image7x7RepeatBorderTile() { - var kernelSize = new Size(5, 5); - var bounds = new Rectangle(2, 2, 7, 7); - var mode = BorderWrappingMode.Repeat; + Size kernelSize = new(5, 5); + Rectangle bounds = new(2, 2, 7, 7); + BorderWrappingMode mode = BorderWrappingMode.Repeat; int[] expected = - { + [ 2, 2, 2, 3, 4, 2, 2, 3, 4, 5, 2, 3, 4, 5, 6, 3, 4, 5, 6, 7, 4, 5, 6, 7, 8, 5, 6, 7, 8, 8, - 6, 7, 8, 8, 8, - }; + 6, 7, 8, 8, 8 + ]; this.AssertOffsets(kernelSize, bounds, mode, mode, expected, expected); } [Fact] public void KernalSamplingMap_Kernel5Image7x7BounceBorderTile() { - var kernelSize = new Size(5, 5); - var bounds = new Rectangle(2, 2, 7, 7); - var mode = BorderWrappingMode.Bounce; + Size kernelSize = new(5, 5); + Rectangle bounds = new(2, 2, 7, 7); + BorderWrappingMode mode = BorderWrappingMode.Bounce; int[] expected = - { + [ 4, 3, 2, 3, 4, 3, 2, 3, 4, 5, 2, 3, 4, 5, 6, 3, 4, 5, 6, 7, 4, 5, 6, 7, 8, 5, 6, 7, 8, 7, - 6, 7, 8, 7, 6, - }; + 6, 7, 8, 7, 6 + ]; this.AssertOffsets(kernelSize, bounds, mode, mode, expected, expected); } [Fact] public void KernalSamplingMap_Kernel5Image7x7MirrorBorderTile() { - var kernelSize = new Size(5, 5); - var bounds = new Rectangle(2, 2, 7, 7); - var mode = BorderWrappingMode.Mirror; + Size kernelSize = new(5, 5); + Rectangle bounds = new(2, 2, 7, 7); + BorderWrappingMode mode = BorderWrappingMode.Mirror; int[] expected = - { + [ 3, 2, 2, 3, 4, 2, 2, 3, 4, 5, 2, 3, 4, 5, 6, 3, 4, 5, 6, 7, 4, 5, 6, 7, 8, 5, 6, 7, 8, 8, - 6, 7, 8, 8, 7, - }; + 6, 7, 8, 8, 7 + ]; this.AssertOffsets(kernelSize, bounds, mode, mode, expected, expected); } [Fact] public void KernalSamplingMap_Kernel5Image7x7WrapBorderTile() { - var kernelSize = new Size(5, 5); - var bounds = new Rectangle(2, 2, 7, 7); - var mode = BorderWrappingMode.Wrap; + Size kernelSize = new(5, 5); + Rectangle bounds = new(2, 2, 7, 7); + BorderWrappingMode mode = BorderWrappingMode.Wrap; int[] expected = - { + [ 7, 8, 2, 3, 4, 8, 2, 3, 4, 5, 2, 3, 4, 5, 6, 3, 4, 5, 6, 7, 4, 5, 6, 7, 8, 5, 6, 7, 8, 2, - 6, 7, 8, 2, 3, - }; + 6, 7, 8, 2, 3 + ]; this.AssertOffsets(kernelSize, bounds, mode, mode, expected, expected); } [Fact] public void KernalSamplingMap_Kernel3Image7x7RepeatBorder() { - var kernelSize = new Size(3, 3); - var bounds = new Rectangle(0, 0, 7, 7); - var mode = BorderWrappingMode.Repeat; + Size kernelSize = new(3, 3); + Rectangle bounds = new(0, 0, 7, 7); + BorderWrappingMode mode = BorderWrappingMode.Repeat; int[] expected = - { + [ 0, 0, 1, 0, 1, 2, 1, 2, 3, 2, 3, 4, 3, 4, 5, 4, 5, 6, - 5, 6, 6, - }; + 5, 6, 6 + ]; this.AssertOffsets(kernelSize, bounds, mode, mode, expected, expected); } [Fact] public void KernalSamplingMap_Kernel3Image7x7BounceBorder() { - var kernelSize = new Size(3, 3); - var bounds = new Rectangle(0, 0, 7, 7); - var mode = BorderWrappingMode.Bounce; + Size kernelSize = new(3, 3); + Rectangle bounds = new(0, 0, 7, 7); + BorderWrappingMode mode = BorderWrappingMode.Bounce; int[] expected = - { + [ 1, 0, 1, 0, 1, 2, 1, 2, 3, 2, 3, 4, 3, 4, 5, 4, 5, 6, - 5, 6, 5, - }; + 5, 6, 5 + ]; this.AssertOffsets(kernelSize, bounds, mode, mode, expected, expected); } [Fact] public void KernalSamplingMap_Kernel3Image7x7MirrorBorder() { - var kernelSize = new Size(3, 3); - var bounds = new Rectangle(0, 0, 7, 7); - var mode = BorderWrappingMode.Mirror; + Size kernelSize = new(3, 3); + Rectangle bounds = new(0, 0, 7, 7); + BorderWrappingMode mode = BorderWrappingMode.Mirror; int[] expected = - { + [ 0, 0, 1, 0, 1, 2, 1, 2, 3, 2, 3, 4, 3, 4, 5, 4, 5, 6, - 5, 6, 6, - }; + 5, 6, 6 + ]; this.AssertOffsets(kernelSize, bounds, mode, mode, expected, expected); } [Fact] public void KernalSamplingMap_Kernel3Image7x7WrapBorder() { - var kernelSize = new Size(3, 3); - var bounds = new Rectangle(0, 0, 7, 7); - var mode = BorderWrappingMode.Wrap; + Size kernelSize = new(3, 3); + Rectangle bounds = new(0, 0, 7, 7); + BorderWrappingMode mode = BorderWrappingMode.Wrap; int[] expected = - { + [ 6, 0, 1, 0, 1, 2, 1, 2, 3, 2, 3, 4, 3, 4, 5, 4, 5, 6, - 5, 6, 0, - }; + 5, 6, 0 + ]; this.AssertOffsets(kernelSize, bounds, mode, mode, expected, expected); } [Fact] public void KernalSamplingMap_Kernel3Image7x7RepeatBorderTile() { - var kernelSize = new Size(3, 3); - var bounds = new Rectangle(2, 2, 7, 7); - var mode = BorderWrappingMode.Repeat; + Size kernelSize = new(3, 3); + Rectangle bounds = new(2, 2, 7, 7); + BorderWrappingMode mode = BorderWrappingMode.Repeat; int[] expected = - { + [ 2, 2, 3, 2, 3, 4, 3, 4, 5, 4, 5, 6, 5, 6, 7, 6, 7, 8, - 7, 8, 8, - }; + 7, 8, 8 + ]; this.AssertOffsets(kernelSize, bounds, mode, mode, expected, expected); } [Fact] public void KernalSamplingMap_Kernel3Image7BounceBorderTile() { - var kernelSize = new Size(3, 3); - var bounds = new Rectangle(2, 2, 7, 7); - var mode = BorderWrappingMode.Bounce; + Size kernelSize = new(3, 3); + Rectangle bounds = new(2, 2, 7, 7); + BorderWrappingMode mode = BorderWrappingMode.Bounce; int[] expected = - { + [ 3, 2, 3, 2, 3, 4, 3, 4, 5, 4, 5, 6, 5, 6, 7, 6, 7, 8, - 7, 8, 7, - }; + 7, 8, 7 + ]; this.AssertOffsets(kernelSize, bounds, mode, mode, expected, expected); } [Fact] public void KernalSamplingMap_Kernel3Image7MirrorBorderTile() { - var kernelSize = new Size(3, 3); - var bounds = new Rectangle(2, 2, 7, 7); - var mode = BorderWrappingMode.Mirror; + Size kernelSize = new(3, 3); + Rectangle bounds = new(2, 2, 7, 7); + BorderWrappingMode mode = BorderWrappingMode.Mirror; int[] expected = - { + [ 2, 2, 3, 2, 3, 4, 3, 4, 5, 4, 5, 6, 5, 6, 7, 6, 7, 8, - 7, 8, 8, - }; + 7, 8, 8 + ]; this.AssertOffsets(kernelSize, bounds, mode, mode, expected, expected); } [Fact] public void KernalSamplingMap_Kernel3Image7x7WrapBorderTile() { - var kernelSize = new Size(3, 3); - var bounds = new Rectangle(2, 2, 7, 7); - var mode = BorderWrappingMode.Wrap; + Size kernelSize = new(3, 3); + Rectangle bounds = new(2, 2, 7, 7); + BorderWrappingMode mode = BorderWrappingMode.Wrap; int[] expected = - { + [ 8, 2, 3, 2, 3, 4, 3, 4, 5, 4, 5, 6, 5, 6, 7, 6, 7, 8, - 7, 8, 2, - }; + 7, 8, 2 + ]; this.AssertOffsets(kernelSize, bounds, mode, mode, expected, expected); } [Fact] public void KernalSamplingMap_Kernel3Image7x5WrapBorderTile() { - var kernelSize = new Size(3, 3); - var bounds = new Rectangle(2, 2, 7, 5); - var mode = BorderWrappingMode.Wrap; + Size kernelSize = new(3, 3); + Rectangle bounds = new(2, 2, 7, 5); + BorderWrappingMode mode = BorderWrappingMode.Wrap; int[] xExpected = - { + [ 8, 2, 3, 2, 3, 4, 3, 4, 5, 4, 5, 6, 5, 6, 7, 6, 7, 8, - 7, 8, 2, - }; + 7, 8, 2 + ]; int[] yExpected = - { + [ 6, 2, 3, 2, 3, 4, 3, 4, 5, 4, 5, 6, - 5, 6, 2, - }; + 5, 6, 2 + ]; this.AssertOffsets(kernelSize, bounds, mode, mode, xExpected, yExpected); } private void AssertOffsets(Size kernelSize, Rectangle bounds, BorderWrappingMode xBorderMode, BorderWrappingMode yBorderMode, int[] xExpected, int[] yExpected) { // Arrange - var map = new KernelSamplingMap(Configuration.Default.MemoryAllocator); + KernelSamplingMap map = new(Configuration.Default.MemoryAllocator); // Act map.BuildSamplingOffsetMap(kernelSize.Height, kernelSize.Width, bounds, xBorderMode, yBorderMode); // Assert - var xOffsets = map.GetColumnOffsetSpan().ToArray(); + int[] xOffsets = map.GetColumnOffsetSpan().ToArray(); Assert.Equal(xExpected, xOffsets); - var yOffsets = map.GetRowOffsetSpan().ToArray(); + int[] yOffsets = map.GetRowOffsetSpan().ToArray(); Assert.Equal(yExpected, yOffsets); } } diff --git a/tests/ImageSharp.Tests/Processing/Convolution/MedianBlurTest.cs b/tests/ImageSharp.Tests/Processing/Convolution/MedianBlurTest.cs index dc497628fb..bff78a75ed 100644 --- a/tests/ImageSharp.Tests/Processing/Convolution/MedianBlurTest.cs +++ b/tests/ImageSharp.Tests/Processing/Convolution/MedianBlurTest.cs @@ -13,7 +13,7 @@ public class MedianBlurTest : BaseImageOperationsExtensionTest public void Median_radius_MedianProcessorDefaultsSet() { this.operations.MedianBlur(3, true); - var processor = this.Verify(); + MedianBlurProcessor processor = this.Verify(); Assert.Equal(3, processor.Radius); Assert.True(processor.PreserveAlpha); @@ -23,7 +23,7 @@ public void Median_radius_MedianProcessorDefaultsSet() public void Median_radius_rect_MedianProcessorDefaultsSet() { this.operations.MedianBlur(5, false, this.rect); - var processor = this.Verify(this.rect); + MedianBlurProcessor processor = this.Verify(this.rect); Assert.Equal(5, processor.Radius); Assert.False(processor.PreserveAlpha); diff --git a/tests/ImageSharp.Tests/Processing/Convolution/Processors/LaplacianKernelFactoryTests.cs b/tests/ImageSharp.Tests/Processing/Convolution/Processors/LaplacianKernelFactoryTests.cs index 800cb06ac1..6c6fa6b2be 100644 --- a/tests/ImageSharp.Tests/Processing/Convolution/Processors/LaplacianKernelFactoryTests.cs +++ b/tests/ImageSharp.Tests/Processing/Convolution/Processors/LaplacianKernelFactoryTests.cs @@ -7,9 +7,9 @@ namespace SixLabors.ImageSharp.Tests.Processing.Convolution.Processors; public class LaplacianKernelFactoryTests { - private static readonly ApproximateFloatComparer ApproximateComparer = new ApproximateFloatComparer(0.0001F); + private static readonly ApproximateFloatComparer ApproximateComparer = new(0.0001F); - private static readonly DenseMatrix Expected3x3Matrix = new DenseMatrix( + private static readonly DenseMatrix Expected3x3Matrix = new( new float[,] { { -1, -1, -1 }, @@ -17,7 +17,7 @@ public class LaplacianKernelFactoryTests { -1, -1, -1 } }); - private static readonly DenseMatrix Expected5x5Matrix = new DenseMatrix( + private static readonly DenseMatrix Expected5x5Matrix = new( new float[,] { { -1, -1, -1, -1, -1 }, diff --git a/tests/ImageSharp.Tests/Processing/Dithering/DitherTest.cs b/tests/ImageSharp.Tests/Processing/Dithering/DitherTest.cs index 1b3d1bd9ac..43785da6e7 100644 --- a/tests/ImageSharp.Tests/Processing/Dithering/DitherTest.cs +++ b/tests/ImageSharp.Tests/Processing/Dithering/DitherTest.cs @@ -20,11 +20,11 @@ public static void Equal(ReadOnlySpan a, ReadOnlySpan b) private readonly IDither orderedDither; private readonly IDither errorDiffuser; private readonly Color[] testPalette = - { + [ Color.Red, Color.Green, Color.Blue - }; + ]; public DitherTest() { diff --git a/tests/ImageSharp.Tests/Processing/Effects/OilPaintTest.cs b/tests/ImageSharp.Tests/Processing/Effects/OilPaintTest.cs index 6d5973dbbb..b24ab6c817 100644 --- a/tests/ImageSharp.Tests/Processing/Effects/OilPaintTest.cs +++ b/tests/ImageSharp.Tests/Processing/Effects/OilPaintTest.cs @@ -13,7 +13,7 @@ public class OilPaintTest : BaseImageOperationsExtensionTest public void OilPaint_OilPaintingProcessorDefaultsSet() { this.operations.OilPaint(); - var processor = this.Verify(); + OilPaintingProcessor processor = this.Verify(); Assert.Equal(10, processor.Levels); Assert.Equal(15, processor.BrushSize); @@ -23,7 +23,7 @@ public void OilPaint_OilPaintingProcessorDefaultsSet() public void OilPaint_rect_OilPaintingProcessorDefaultsSet() { this.operations.OilPaint(this.rect); - var processor = this.Verify(this.rect); + OilPaintingProcessor processor = this.Verify(this.rect); Assert.Equal(10, processor.Levels); Assert.Equal(15, processor.BrushSize); @@ -33,7 +33,7 @@ public void OilPaint_rect_OilPaintingProcessorDefaultsSet() public void OilPaint_Levels_Brush_OilPaintingProcessorDefaultsSet() { this.operations.OilPaint(34, 65); - var processor = this.Verify(); + OilPaintingProcessor processor = this.Verify(); Assert.Equal(34, processor.Levels); Assert.Equal(65, processor.BrushSize); @@ -43,7 +43,7 @@ public void OilPaint_Levels_Brush_OilPaintingProcessorDefaultsSet() public void OilPaint_Levels_Brush_rect_OilPaintingProcessorDefaultsSet() { this.operations.OilPaint(54, 43, this.rect); - var processor = this.Verify(this.rect); + OilPaintingProcessor processor = this.Verify(this.rect); Assert.Equal(54, processor.Levels); Assert.Equal(43, processor.BrushSize); diff --git a/tests/ImageSharp.Tests/Processing/Effects/PixelateTest.cs b/tests/ImageSharp.Tests/Processing/Effects/PixelateTest.cs index 6531f7b442..f557183d6e 100644 --- a/tests/ImageSharp.Tests/Processing/Effects/PixelateTest.cs +++ b/tests/ImageSharp.Tests/Processing/Effects/PixelateTest.cs @@ -13,7 +13,7 @@ public class PixelateTest : BaseImageOperationsExtensionTest public void Pixelate_PixelateProcessorDefaultsSet() { this.operations.Pixelate(); - var processor = this.Verify(); + PixelateProcessor processor = this.Verify(); Assert.Equal(4, processor.Size); } @@ -22,7 +22,7 @@ public void Pixelate_PixelateProcessorDefaultsSet() public void Pixelate_Size_PixelateProcessorDefaultsSet() { this.operations.Pixelate(12); - var processor = this.Verify(); + PixelateProcessor processor = this.Verify(); Assert.Equal(12, processor.Size); } @@ -31,7 +31,7 @@ public void Pixelate_Size_PixelateProcessorDefaultsSet() public void Pixelate_Size_rect_PixelateProcessorDefaultsSet() { this.operations.Pixelate(23, this.rect); - var processor = this.Verify(this.rect); + PixelateProcessor processor = this.Verify(this.rect); Assert.Equal(23, processor.Size); } diff --git a/tests/ImageSharp.Tests/Processing/FakeImageOperationsProvider.cs b/tests/ImageSharp.Tests/Processing/FakeImageOperationsProvider.cs index 17f63384e0..626f17610e 100644 --- a/tests/ImageSharp.Tests/Processing/FakeImageOperationsProvider.cs +++ b/tests/ImageSharp.Tests/Processing/FakeImageOperationsProvider.cs @@ -10,7 +10,7 @@ namespace SixLabors.ImageSharp.Tests.Processing; internal class FakeImageOperationsProvider : IImageProcessingContextFactory { - private readonly List imageOperators = new List(); + private readonly List imageOperators = []; public bool HasCreated(Image source) where TPixel : unmanaged, IPixel @@ -35,7 +35,7 @@ public IEnumerable> Created(Image so public IInternalImageProcessingContext CreateImageProcessingContext(Configuration configuration, Image source, bool mutate) where TPixel : unmanaged, IPixel { - var op = new FakeImageOperations(configuration, source, mutate); + FakeImageOperations op = new(configuration, source, mutate); this.imageOperators.Add(op); return op; } @@ -51,7 +51,7 @@ public FakeImageOperations(Configuration configuration, Image source, bo public Image Source { get; } - public List Applied { get; } = new List(); + public List Applied { get; } = []; public Configuration Configuration { get; } @@ -69,7 +69,7 @@ public Size GetCurrentSize() public IImageProcessingContext ApplyProcessor(IImageProcessor processor, Rectangle rectangle) { - this.Applied.Add(new AppliedOperation + this.Applied.Add(new() { Rectangle = rectangle, NonGenericProcessor = processor @@ -79,7 +79,7 @@ public IImageProcessingContext ApplyProcessor(IImageProcessor processor, Rectang public IImageProcessingContext ApplyProcessor(IImageProcessor processor) { - this.Applied.Add(new AppliedOperation + this.Applied.Add(new() { NonGenericProcessor = processor }); diff --git a/tests/ImageSharp.Tests/Processing/Filters/BrightnessTest.cs b/tests/ImageSharp.Tests/Processing/Filters/BrightnessTest.cs index 87436e4a35..9cfc3a3f09 100644 --- a/tests/ImageSharp.Tests/Processing/Filters/BrightnessTest.cs +++ b/tests/ImageSharp.Tests/Processing/Filters/BrightnessTest.cs @@ -31,28 +31,28 @@ public void Brightness_amount_rect_BrightnessProcessorDefaultsSet() [Fact] public void Brightness_scaled_vector() { - var rgbImage = new Image(Configuration.Default, 100, 100, new Rgb24(0, 0, 0)); + Image rgbImage = new(Configuration.Default, 100, 100, new Rgb24(0, 0, 0)); rgbImage.Mutate(x => x.ApplyProcessor(new BrightnessProcessor(2))); - Assert.Equal(new Rgb24(0, 0, 0), rgbImage[0, 0]); + Assert.Equal(new(0, 0, 0), rgbImage[0, 0]); - rgbImage = new Image(Configuration.Default, 100, 100, new Rgb24(10, 10, 10)); + rgbImage = new(Configuration.Default, 100, 100, new Rgb24(10, 10, 10)); rgbImage.Mutate(x => x.ApplyProcessor(new BrightnessProcessor(2))); - Assert.Equal(new Rgb24(20, 20, 20), rgbImage[0, 0]); + Assert.Equal(new(20, 20, 20), rgbImage[0, 0]); - var halfSingleImage = new Image(Configuration.Default, 100, 100, new HalfSingle(-1)); + Image halfSingleImage = new(Configuration.Default, 100, 100, new HalfSingle(-1)); halfSingleImage.Mutate(x => x.ApplyProcessor(new BrightnessProcessor(2))); - Assert.Equal(new HalfSingle(-1), halfSingleImage[0, 0]); + Assert.Equal(new(-1), halfSingleImage[0, 0]); - halfSingleImage = new Image(Configuration.Default, 100, 100, new HalfSingle(-0.5f)); + halfSingleImage = new(Configuration.Default, 100, 100, new HalfSingle(-0.5f)); halfSingleImage.Mutate(x => x.ApplyProcessor(new BrightnessProcessor(2))); - Assert.Equal(new HalfSingle(0), halfSingleImage[0, 0]); + Assert.Equal(new(0), halfSingleImage[0, 0]); } } diff --git a/tests/ImageSharp.Tests/Processing/Filters/ColorBlindnessTest.cs b/tests/ImageSharp.Tests/Processing/Filters/ColorBlindnessTest.cs index 7fb93bba54..f00087e1c0 100644 --- a/tests/ImageSharp.Tests/Processing/Filters/ColorBlindnessTest.cs +++ b/tests/ImageSharp.Tests/Processing/Filters/ColorBlindnessTest.cs @@ -11,17 +11,17 @@ namespace SixLabors.ImageSharp.Tests.Processing.Filters; [Trait("Category", "Processors")] public class ColorBlindnessTest : BaseImageOperationsExtensionTest { - public static IEnumerable TheoryData = new[] - { - new object[] { new TestType(), ColorBlindnessMode.Achromatomaly }, - new object[] { new TestType(), ColorBlindnessMode.Achromatopsia }, - new object[] { new TestType(), ColorBlindnessMode.Deuteranomaly }, - new object[] { new TestType(), ColorBlindnessMode.Deuteranopia }, - new object[] { new TestType(), ColorBlindnessMode.Protanomaly }, - new object[] { new TestType(), ColorBlindnessMode.Protanopia }, - new object[] { new TestType(), ColorBlindnessMode.Tritanomaly }, - new object[] { new TestType(), ColorBlindnessMode.Tritanopia } - }; + public static IEnumerable TheoryData = + [ + [new TestType(), ColorBlindnessMode.Achromatomaly], + [new TestType(), ColorBlindnessMode.Achromatopsia], + [new TestType(), ColorBlindnessMode.Deuteranomaly], + [new TestType(), ColorBlindnessMode.Deuteranopia], + [new TestType(), ColorBlindnessMode.Protanomaly], + [new TestType(), ColorBlindnessMode.Protanopia], + [new TestType(), ColorBlindnessMode.Tritanomaly], + [new TestType(), ColorBlindnessMode.Tritanopia] + ]; [Theory] [MemberData(nameof(TheoryData))] diff --git a/tests/ImageSharp.Tests/Processing/Filters/GrayscaleTest.cs b/tests/ImageSharp.Tests/Processing/Filters/GrayscaleTest.cs index 36edc10e5d..6f0f06535f 100644 --- a/tests/ImageSharp.Tests/Processing/Filters/GrayscaleTest.cs +++ b/tests/ImageSharp.Tests/Processing/Filters/GrayscaleTest.cs @@ -11,10 +11,10 @@ namespace SixLabors.ImageSharp.Tests.Processing.Filters; [Trait("Category", "Processors")] public class GrayscaleTest : BaseImageOperationsExtensionTest { - public static IEnumerable ModeTheoryData = new[] - { - new object[] { new TestType(), GrayscaleMode.Bt709 } - }; + public static IEnumerable ModeTheoryData = + [ + [new TestType(), GrayscaleMode.Bt709] + ]; [Theory] [MemberData(nameof(ModeTheoryData))] diff --git a/tests/ImageSharp.Tests/Processing/Filters/HueTest.cs b/tests/ImageSharp.Tests/Processing/Filters/HueTest.cs index 0c197a96f7..33deb715ba 100644 --- a/tests/ImageSharp.Tests/Processing/Filters/HueTest.cs +++ b/tests/ImageSharp.Tests/Processing/Filters/HueTest.cs @@ -13,7 +13,7 @@ public class HueTest : BaseImageOperationsExtensionTest public void Hue_amount_HueProcessorDefaultsSet() { this.operations.Hue(34f); - var processor = this.Verify(); + HueProcessor processor = this.Verify(); Assert.Equal(34f, processor.Degrees); } @@ -22,7 +22,7 @@ public void Hue_amount_HueProcessorDefaultsSet() public void Hue_amount_rect_HueProcessorDefaultsSet() { this.operations.Hue(5f, this.rect); - var processor = this.Verify(this.rect); + HueProcessor processor = this.Verify(this.rect); Assert.Equal(5f, processor.Degrees); } diff --git a/tests/ImageSharp.Tests/Processing/Filters/LomographTest.cs b/tests/ImageSharp.Tests/Processing/Filters/LomographTest.cs index e84bd243e4..f68ecef08f 100644 --- a/tests/ImageSharp.Tests/Processing/Filters/LomographTest.cs +++ b/tests/ImageSharp.Tests/Processing/Filters/LomographTest.cs @@ -13,7 +13,7 @@ public class LomographTest : BaseImageOperationsExtensionTest public void Lomograph_amount_LomographProcessorDefaultsSet() { this.operations.Lomograph(); - var processor = this.Verify(); + LomographProcessor processor = this.Verify(); Assert.Equal(processor.GraphicsOptions, this.options); } @@ -21,7 +21,7 @@ public void Lomograph_amount_LomographProcessorDefaultsSet() public void Lomograph_amount_rect_LomographProcessorDefaultsSet() { this.operations.Lomograph(this.rect); - var processor = this.Verify(this.rect); + LomographProcessor processor = this.Verify(this.rect); Assert.Equal(processor.GraphicsOptions, this.options); } } diff --git a/tests/ImageSharp.Tests/Processing/Filters/PolaroidTest.cs b/tests/ImageSharp.Tests/Processing/Filters/PolaroidTest.cs index 7d3e0aed0f..89d8d47bcf 100644 --- a/tests/ImageSharp.Tests/Processing/Filters/PolaroidTest.cs +++ b/tests/ImageSharp.Tests/Processing/Filters/PolaroidTest.cs @@ -13,7 +13,7 @@ public class PolaroidTest : BaseImageOperationsExtensionTest public void Polaroid_amount_PolaroidProcessorDefaultsSet() { this.operations.Polaroid(); - var processor = this.Verify(); + PolaroidProcessor processor = this.Verify(); Assert.Equal(processor.GraphicsOptions, this.options); } @@ -21,7 +21,7 @@ public void Polaroid_amount_PolaroidProcessorDefaultsSet() public void Polaroid_amount_rect_PolaroidProcessorDefaultsSet() { this.operations.Polaroid(this.rect); - var processor = this.Verify(this.rect); + PolaroidProcessor processor = this.Verify(this.rect); Assert.Equal(processor.GraphicsOptions, this.options); } } diff --git a/tests/ImageSharp.Tests/Processing/ImageOperationTests.cs b/tests/ImageSharp.Tests/Processing/ImageOperationTests.cs index 744e26d8f7..d53dc74b9a 100644 --- a/tests/ImageSharp.Tests/Processing/ImageOperationTests.cs +++ b/tests/ImageSharp.Tests/Processing/ImageOperationTests.cs @@ -22,13 +22,13 @@ public class ImageOperationTests : IDisposable public ImageOperationTests() { - this.provider = new FakeImageOperationsProvider(); + this.provider = new(); - var processorMock = new Mock(); + Mock processorMock = new(); this.processorDefinition = processorMock.Object; - this.image = new Image( - new Configuration + this.image = new( + new() { ImageOperationsProvider = this.provider }, @@ -103,7 +103,7 @@ public void CloneCallsImageOperationsProvider_ListOfProcessors_NotOnOriginal() [Fact] public void ApplyProcessors_ListOfProcessors_AppliesAllProcessorsToOperation() { - var operations = new FakeImageOperationsProvider.FakeImageOperations(Configuration.Default, null, false); + FakeImageOperationsProvider.FakeImageOperations operations = new(Configuration.Default, null, false); operations.ApplyProcessors(this.processorDefinition); Assert.Contains(this.processorDefinition, operations.Applied.Select(x => x.NonGenericProcessor)); } @@ -152,7 +152,7 @@ private static string GetExpectedExceptionText() { try { - var img = new Image(1, 1); + Image img = new(1, 1); img.Dispose(); img.EnsureNotDisposed(); } diff --git a/tests/ImageSharp.Tests/Processing/ImageProcessingContextTests.cs b/tests/ImageSharp.Tests/Processing/ImageProcessingContextTests.cs index 88707c60ff..06eb90005a 100644 --- a/tests/ImageSharp.Tests/Processing/ImageProcessingContextTests.cs +++ b/tests/ImageSharp.Tests/Processing/ImageProcessingContextTests.cs @@ -23,18 +23,18 @@ public class ImageProcessingContextTests : IDisposable private readonly Mock> cloningProcessorImpl; - private static readonly Rectangle Bounds = new Rectangle(3, 3, 5, 5); + private static readonly Rectangle Bounds = new(3, 3, 5, 5); public ImageProcessingContextTests() { - this.processorDefinition = new Mock(); - this.cloningProcessorDefinition = new Mock(); - this.regularProcessorImpl = new Mock>(); - this.cloningProcessorImpl = new Mock>(); + this.processorDefinition = new(); + this.cloningProcessorDefinition = new(); + this.regularProcessorImpl = new(); + this.cloningProcessorImpl = new(); } // bool throwException, bool useBounds - public static readonly TheoryData ProcessorTestData = new TheoryData() + public static readonly TheoryData ProcessorTestData = new() { { false, false }, { false, true }, diff --git a/tests/ImageSharp.Tests/Processing/Normalization/HistogramEqualizationTests.cs b/tests/ImageSharp.Tests/Processing/Normalization/HistogramEqualizationTests.cs index 60e33835af..284bf321d2 100644 --- a/tests/ImageSharp.Tests/Processing/Normalization/HistogramEqualizationTests.cs +++ b/tests/ImageSharp.Tests/Processing/Normalization/HistogramEqualizationTests.cs @@ -21,7 +21,7 @@ public void GlobalHistogramEqualization_WithDifferentLuminanceLevels(int luminan { // Arrange byte[] pixels = - { + [ 52, 55, 61, 59, 70, 61, 76, 61, 62, 59, 55, 104, 94, 85, 59, 71, 63, 65, 66, 113, 144, 104, 63, 72, @@ -30,21 +30,21 @@ public void GlobalHistogramEqualization_WithDifferentLuminanceLevels(int luminan 68, 79, 60, 79, 77, 66, 58, 75, 69, 85, 64, 58, 55, 61, 65, 83, 70, 87, 69, 68, 65, 73, 78, 90 - }; + ]; - using (var image = new Image(8, 8)) + using (Image image = new(8, 8)) { for (int y = 0; y < 8; y++) { for (int x = 0; x < 8; x++) { byte luminance = pixels[(y * 8) + x]; - image[x, y] = new Rgba32(luminance, luminance, luminance); + image[x, y] = new(luminance, luminance, luminance); } } byte[] expected = - { + [ 0, 12, 53, 32, 146, 53, 174, 53, 57, 32, 12, 227, 219, 202, 32, 154, 65, 85, 93, 239, 251, 227, 65, 158, @@ -53,10 +53,10 @@ public void GlobalHistogramEqualization_WithDifferentLuminanceLevels(int luminan 117, 190, 36, 190, 178, 93, 20, 170, 130, 202, 73, 20, 12, 53, 85, 194, 146, 206, 130, 117, 85, 166, 182, 215 - }; + ]; // Act - image.Mutate(x => x.HistogramEqualization(new HistogramEqualizationOptions + image.Mutate(x => x.HistogramEqualization(new() { LuminanceLevels = luminanceLevels, Method = HistogramEqualizationMethod.Global @@ -83,7 +83,7 @@ public void GlobalHistogramEqualization_CompareToReferenceOutput(TestIma { using (Image image = provider.GetImage()) { - var options = new HistogramEqualizationOptions + HistogramEqualizationOptions options = new() { Method = HistogramEqualizationMethod.Global, LuminanceLevels = 256, @@ -101,7 +101,7 @@ public void Adaptive_SlidingWindow_15Tiles_WithClipping(TestImageProvide { using (Image image = provider.GetImage()) { - var options = new HistogramEqualizationOptions + HistogramEqualizationOptions options = new() { Method = HistogramEqualizationMethod.AdaptiveSlidingWindow, LuminanceLevels = 256, @@ -121,7 +121,7 @@ public void Adaptive_TileInterpolation_10Tiles_WithClipping(TestImagePro { using (Image image = provider.GetImage()) { - var options = new HistogramEqualizationOptions + HistogramEqualizationOptions options = new() { Method = HistogramEqualizationMethod.AdaptiveTileInterpolation, LuminanceLevels = 256, @@ -141,7 +141,7 @@ public void AutoLevel_SeparateChannels_CompareToReferenceOutput(TestImag { using (Image image = provider.GetImage()) { - var options = new HistogramEqualizationOptions + HistogramEqualizationOptions options = new() { Method = HistogramEqualizationMethod.AutoLevel, LuminanceLevels = 256, @@ -160,7 +160,7 @@ public void AutoLevel_SynchronizedChannels_CompareToReferenceOutput(Test { using (Image image = provider.GetImage()) { - var options = new HistogramEqualizationOptions + HistogramEqualizationOptions options = new() { Method = HistogramEqualizationMethod.AutoLevel, LuminanceLevels = 256, @@ -187,7 +187,7 @@ public void Issue984(TestImageProvider provider) { using (Image image = provider.GetImage()) { - var options = new HistogramEqualizationOptions() + HistogramEqualizationOptions options = new() { Method = HistogramEqualizationMethod.AdaptiveTileInterpolation, LuminanceLevels = 256, @@ -214,7 +214,7 @@ public unsafe void Issue1640(TestImageProvider provider) // https://github.com/SixLabors/ImageSharp/discussions/1640 // Test using isolated memory to ensure clean buffers for reference provider.Configuration = Configuration.CreateDefaultInstance(); - var options = new HistogramEqualizationOptions + HistogramEqualizationOptions options = new() { Method = HistogramEqualizationMethod.AdaptiveTileInterpolation, LuminanceLevels = 4096, diff --git a/tests/ImageSharp.Tests/Processing/Normalization/MagickCompareTests.cs b/tests/ImageSharp.Tests/Processing/Normalization/MagickCompareTests.cs index 5fb0a4e934..0fcb3611c5 100644 --- a/tests/ImageSharp.Tests/Processing/Normalization/MagickCompareTests.cs +++ b/tests/ImageSharp.Tests/Processing/Normalization/MagickCompareTests.cs @@ -22,7 +22,7 @@ public void AutoLevel_CompareToMagick(TestImageProvider provider Image imageFromMagick; using (Stream stream = LoadAsStream(provider)) { - var magickImage = new MagickImage(stream); + MagickImage magickImage = new(stream); // Apply Auto Level using the Grey (BT.709) channel. magickImage.AutoLevel(Channels.Gray); @@ -31,7 +31,7 @@ public void AutoLevel_CompareToMagick(TestImageProvider provider using (Image image = provider.GetImage()) { - var options = new HistogramEqualizationOptions + HistogramEqualizationOptions options = new() { Method = HistogramEqualizationMethod.AutoLevel, LuminanceLevels = 256, @@ -52,7 +52,7 @@ private Stream LoadAsStream(TestImageProvider provider) throw new InvalidOperationException("CompareToMagick() works only with file providers!"); } - var testFile = TestFile.Create(path); + TestFile testFile = TestFile.Create(path); return new FileStream(testFile.FullPath, FileMode.Open); } @@ -61,7 +61,7 @@ private Image ConvertImageFromMagick(MagickImage magickImage) { Configuration configuration = Configuration.Default.Clone(); configuration.PreferContiguousImageBuffers = true; - var result = new Image(configuration, magickImage.Width, magickImage.Height); + Image result = new(configuration, magickImage.Width, magickImage.Height); Assert.True(result.DangerousTryGetSinglePixelMemory(out Memory resultPixels)); diff --git a/tests/ImageSharp.Tests/Processing/Overlays/GlowTest.cs b/tests/ImageSharp.Tests/Processing/Overlays/GlowTest.cs index 7eec6eb0c1..c7881597ab 100644 --- a/tests/ImageSharp.Tests/Processing/Overlays/GlowTest.cs +++ b/tests/ImageSharp.Tests/Processing/Overlays/GlowTest.cs @@ -45,7 +45,7 @@ public void Glow_Radux_GlowProcessorWithDefaultValues() [Fact] public void Glow_Rect_GlowProcessorWithDefaultValues() { - var rect = new Rectangle(12, 123, 43, 65); + Rectangle rect = new(12, 123, 43, 65); this.operations.Glow(rect); GlowProcessor p = this.Verify(rect); diff --git a/tests/ImageSharp.Tests/Processing/Overlays/VignetteTest.cs b/tests/ImageSharp.Tests/Processing/Overlays/VignetteTest.cs index 1602b5c7a2..e222c566ff 100644 --- a/tests/ImageSharp.Tests/Processing/Overlays/VignetteTest.cs +++ b/tests/ImageSharp.Tests/Processing/Overlays/VignetteTest.cs @@ -48,7 +48,7 @@ public void Vignette_Radux_VignetteProcessorWithDefaultValues() [Fact] public void Vignette_Rect_VignetteProcessorWithDefaultValues() { - var rect = new Rectangle(12, 123, 43, 65); + Rectangle rect = new(12, 123, 43, 65); this.operations.Vignette(rect); VignetteProcessor p = this.Verify(rect); diff --git a/tests/ImageSharp.Tests/Processing/Processors/Binarization/BinaryDitherTests.cs b/tests/ImageSharp.Tests/Processing/Processors/Binarization/BinaryDitherTests.cs index 9694aeb222..62682e837c 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Binarization/BinaryDitherTests.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Binarization/BinaryDitherTests.cs @@ -13,11 +13,11 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Binarization; public class BinaryDitherTests { public static readonly string[] CommonTestImages = - { - TestImages.Png.CalliphoraPartial, TestImages.Png.Bike - }; + [ + TestImages.Png.CalliphoraPartial, TestImages.Png.Bike + ]; - public static readonly TheoryData OrderedDitherers = new TheoryData + public static readonly TheoryData OrderedDitherers = new() { { "Bayer8x8", KnownDitherings.Bayer8x8 }, { "Bayer4x4", KnownDitherings.Bayer4x4 }, @@ -25,7 +25,7 @@ public class BinaryDitherTests { "Bayer2x2", KnownDitherings.Bayer2x2 } }; - public static readonly TheoryData ErrorDiffusers = new TheoryData + public static readonly TheoryData ErrorDiffusers = new() { { "Atkinson", KnownDitherings.Atkinson }, { "Burks", KnownDitherings.Burks }, @@ -102,7 +102,7 @@ public void ApplyDitherFilterInBox(TestImageProvider provider) using (Image source = provider.GetImage()) using (Image image = source.Clone()) { - var bounds = new Rectangle(10, 10, image.Width / 2, image.Height / 2); + Rectangle bounds = new(10, 10, image.Width / 2, image.Height / 2); image.Mutate(x => x.BinaryDither(DefaultDitherer, bounds)); image.DebugSave(provider); @@ -119,7 +119,7 @@ public void ApplyDiffusionFilterInBox(TestImageProvider provider using (Image source = provider.GetImage()) using (Image image = source.Clone()) { - var bounds = new Rectangle(10, 10, image.Width / 2, image.Height / 2); + Rectangle bounds = new(10, 10, image.Width / 2, image.Height / 2); image.Mutate(x => x.BinaryDither(DefaultErrorDiffuser, bounds)); image.DebugSave(provider); diff --git a/tests/ImageSharp.Tests/Processing/Processors/Binarization/BinaryThresholdTest.cs b/tests/ImageSharp.Tests/Processing/Processors/Binarization/BinaryThresholdTest.cs index ecbbb21abd..c9d3f69143 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Binarization/BinaryThresholdTest.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Binarization/BinaryThresholdTest.cs @@ -12,17 +12,17 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Binarization; public class BinaryThresholdTest { public static readonly TheoryData BinaryThresholdValues - = new TheoryData - { + = new() + { .25F, .75F }; public static readonly string[] CommonTestImages = - { + [ TestImages.Png.Rgb48Bpp, - TestImages.Png.ColorsSaturationLightness, - }; + TestImages.Png.ColorsSaturationLightness + ]; public const PixelTypes TestPixelTypes = PixelTypes.Rgba32 | PixelTypes.Bgra32 | PixelTypes.Rgb24; @@ -46,7 +46,7 @@ public void ImageShouldApplyBinaryThresholdInBox(TestImageProvider source = provider.GetImage()) using (Image image = source.Clone()) { - var bounds = new Rectangle(image.Width / 8, image.Height / 8, 6 * image.Width / 8, 6 * image.Width / 8); + Rectangle bounds = new(image.Width / 8, image.Height / 8, 6 * image.Width / 8, 6 * image.Width / 8); image.Mutate(x => x.BinaryThreshold(value, bounds)); image.DebugSave(provider, value); @@ -76,7 +76,7 @@ public void ImageShouldApplyBinarySaturationThresholdInBox(TestImageProv using (Image source = provider.GetImage()) using (Image image = source.Clone()) { - var bounds = new Rectangle(image.Width / 8, image.Height / 8, 6 * image.Width / 8, 6 * image.Width / 8); + Rectangle bounds = new(image.Width / 8, image.Height / 8, 6 * image.Width / 8, 6 * image.Width / 8); image.Mutate(x => x.BinaryThreshold(value, BinaryThresholdMode.Saturation, bounds)); image.DebugSave(provider, value); @@ -96,7 +96,7 @@ public void ImageShouldApplyBinaryMaxChromaThresholdFilter(TestImageProv if (!TestEnvironment.Is64BitProcess && TestEnvironment.IsFramework) { - var comparer = ImageComparer.TolerantPercentage(0.0004F); + ImageComparer comparer = ImageComparer.TolerantPercentage(0.0004F); image.CompareToReferenceOutput(comparer, provider, value.ToString("0.00", NumberFormatInfo.InvariantInfo)); } else @@ -114,14 +114,14 @@ public void ImageShouldApplyBinaryMaxChromaThresholdInBox(TestImageProvi using (Image source = provider.GetImage()) using (Image image = source.Clone()) { - var bounds = new Rectangle(image.Width / 8, image.Height / 8, 6 * image.Width / 8, 6 * image.Width / 8); + Rectangle bounds = new(image.Width / 8, image.Height / 8, 6 * image.Width / 8, 6 * image.Width / 8); image.Mutate(x => x.BinaryThreshold(value, BinaryThresholdMode.MaxChroma, bounds)); image.DebugSave(provider, value); if (!TestEnvironment.Is64BitProcess && TestEnvironment.IsFramework) { - var comparer = ImageComparer.TolerantPercentage(0.0004F); + ImageComparer comparer = ImageComparer.TolerantPercentage(0.0004F); image.CompareToReferenceOutput(comparer, provider, value.ToString("0.00", NumberFormatInfo.InvariantInfo)); } else diff --git a/tests/ImageSharp.Tests/Processing/Processors/Convolution/Basic1ParameterConvolutionTests.cs b/tests/ImageSharp.Tests/Processing/Processors/Convolution/Basic1ParameterConvolutionTests.cs index 13ddf85c1e..1eec353689 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Convolution/Basic1ParameterConvolutionTests.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Convolution/Basic1ParameterConvolutionTests.cs @@ -12,14 +12,14 @@ public abstract class Basic1ParameterConvolutionTests { private static readonly ImageComparer ValidatorComparer = ImageComparer.TolerantPercentage(0.05F); - public static readonly TheoryData Values = new TheoryData { 3, 5 }; + public static readonly TheoryData Values = new() { 3, 5 }; public static readonly string[] InputImages = - { + [ TestImages.Bmp.Car, TestImages.Png.CalliphoraPartial, TestImages.Png.Blur - }; + ]; [Theory] [WithFileCollection(nameof(InputImages), nameof(Values), PixelTypes.Rgba32)] diff --git a/tests/ImageSharp.Tests/Processing/Processors/Convolution/BokehBlurTest.cs b/tests/ImageSharp.Tests/Processing/Processors/Convolution/BokehBlurTest.cs index c94983ecd5..d6694d0ab1 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Convolution/BokehBlurTest.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Convolution/BokehBlurTest.cs @@ -48,10 +48,10 @@ public void VerifyBokehBlurProcessorArguments_Fail(int radius, int components, f public void VerifyComplexComponents() { // Get the saved components - List components = new(); + List components = []; foreach (Match match in Regex.Matches(Components10x2, @"\[\[(.*?)\]\]", RegexOptions.Singleline)) { - string[] values = match.Groups[1].Value.Trim().Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); + string[] values = match.Groups[1].Value.Trim().Split([' '], StringSplitOptions.RemoveEmptyEntries); Complex64[] component = values.Select( value => { @@ -107,20 +107,20 @@ public void Serialize(IXunitSerializationInfo info) public override string ToString() => $"R{this.Radius}_C{this.Components}_G{this.Gamma}"; } - public static readonly TheoryData BokehBlurValues = new() - { - new BokehBlurInfo { Radius = 8, Components = 1, Gamma = 1 }, - new BokehBlurInfo { Radius = 16, Components = 1, Gamma = 3 }, - new BokehBlurInfo { Radius = 16, Components = 2, Gamma = 3 } - }; + public static readonly TheoryData BokehBlurValues = + [ + new() { Radius = 8, Components = 1, Gamma = 1 }, + new() { Radius = 16, Components = 1, Gamma = 3 }, + new() { Radius = 16, Components = 2, Gamma = 3 } + ]; public static readonly string[] TestFiles = - { - TestImages.Png.CalliphoraPartial, + [ + TestImages.Png.CalliphoraPartial, TestImages.Png.Bike, TestImages.Png.BikeGrayscale, - TestImages.Png.Cross, - }; + TestImages.Png.Cross + ]; [Theory] [WithFileCollection(nameof(TestFiles), nameof(BokehBlurValues), PixelTypes.Rgba32)] diff --git a/tests/ImageSharp.Tests/Processing/Processors/Convolution/DetectEdgesTest.cs b/tests/ImageSharp.Tests/Processing/Processors/Convolution/DetectEdgesTest.cs index d51012f9ec..be3fc1e500 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Convolution/DetectEdgesTest.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Convolution/DetectEdgesTest.cs @@ -17,21 +17,21 @@ public class DetectEdgesTest private static readonly ImageComparer TransparentComparer = ImageComparer.TolerantPercentage(0.5F); - public static readonly string[] TestImages = { Tests.TestImages.Png.Bike }; + public static readonly string[] TestImages = [Tests.TestImages.Png.Bike]; public const PixelTypes CommonNonDefaultPixelTypes = PixelTypes.Rgba32 | PixelTypes.Bgra32 | PixelTypes.RgbaVector; public static readonly TheoryData DetectEdgesFilters - = new TheoryData - { + = new() + { { KnownEdgeDetectorKernels.Laplacian3x3, nameof(KnownEdgeDetectorKernels.Laplacian3x3) }, { KnownEdgeDetectorKernels.Laplacian5x5, nameof(KnownEdgeDetectorKernels.Laplacian5x5) }, { KnownEdgeDetectorKernels.LaplacianOfGaussian, nameof(KnownEdgeDetectorKernels.LaplacianOfGaussian) }, }; public static readonly TheoryData DetectEdges2DFilters - = new TheoryData - { + = new() + { { KnownEdgeDetectorKernels.Kayyali, nameof(KnownEdgeDetectorKernels.Kayyali) }, { KnownEdgeDetectorKernels.Prewitt, nameof(KnownEdgeDetectorKernels.Prewitt) }, { KnownEdgeDetectorKernels.RobertsCross, nameof(KnownEdgeDetectorKernels.RobertsCross) }, @@ -40,8 +40,8 @@ public static readonly TheoryData DetectEdges2DFil }; public static readonly TheoryData DetectEdgesCompassFilters - = new TheoryData - { + = new() + { { KnownEdgeDetectorKernels.Kirsch, nameof(KnownEdgeDetectorKernels.Kirsch) }, { KnownEdgeDetectorKernels.Robinson, nameof(KnownEdgeDetectorKernels.Robinson) }, }; @@ -55,7 +55,7 @@ public void DetectEdges_WorksOnWrappedMemoryImage(TestImageProvider { Size size = ctx.GetCurrentSize(); - var bounds = new Rectangle(10, 10, size.Width / 2, size.Height / 2); + Rectangle bounds = new(10, 10, size.Width / 2, size.Height / 2); ctx.DetectEdges(bounds); }, comparer: OpaqueComparer, @@ -158,7 +158,7 @@ public void DetectEdges_InBox(TestImageProvider provider) { using (Image image = provider.GetImage()) { - var bounds = new Rectangle(10, 10, image.Width / 2, image.Height / 2); + Rectangle bounds = new(10, 10, image.Width / 2, image.Height / 2); image.Mutate(x => x.DetectEdges(bounds)); image.DebugSave(provider); diff --git a/tests/ImageSharp.Tests/Processing/Processors/Dithering/DitherTests.cs b/tests/ImageSharp.Tests/Processing/Processors/Dithering/DitherTests.cs index b8e968f73a..25acd3aa67 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Dithering/DitherTests.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Dithering/DitherTests.cs @@ -14,10 +14,10 @@ public class DitherTests public const PixelTypes CommonNonDefaultPixelTypes = PixelTypes.Rgba32 | PixelTypes.Bgra32 | PixelTypes.Rgb24 | PixelTypes.RgbaVector; - public static readonly string[] CommonTestImages = { TestImages.Png.CalliphoraPartial, TestImages.Png.Bike }; + public static readonly string[] CommonTestImages = [TestImages.Png.CalliphoraPartial, TestImages.Png.Bike]; public static readonly TheoryData ErrorDiffusers - = new TheoryData + = new() { { KnownDitherings.Atkinson, nameof(KnownDitherings.Atkinson) }, { KnownDitherings.Burks, nameof(KnownDitherings.Burks) }, @@ -31,7 +31,7 @@ public static readonly TheoryData ErrorDiffusers }; public static readonly TheoryData OrderedDitherers - = new TheoryData + = new() { { KnownDitherings.Bayer2x2, nameof(KnownDitherings.Bayer2x2) }, { KnownDitherings.Bayer4x4, nameof(KnownDitherings.Bayer4x4) }, @@ -41,7 +41,7 @@ public static readonly TheoryData OrderedDitherers }; public static readonly TheoryData DefaultInstanceDitherers - = new TheoryData + = new() { default(ErrorDither), default(OrderedDither) @@ -101,7 +101,7 @@ public void DiffusionFilter_ShouldNotDependOnSinglePixelType(TestImagePr } // Increased tolerance because of compatibility issues on .NET 4.6.2: - var comparer = ImageComparer.TolerantPercentage(1f); + ImageComparer comparer = ImageComparer.TolerantPercentage(1f); provider.RunValidatingProcessorTest(x => x.Dither(DefaultErrorDiffuser), comparer: comparer); } @@ -186,7 +186,7 @@ public void ShouldThrowForDefaultDitherInstance(IDither dither) { void Command() { - using var image = new Image(10, 10); + using Image image = new(10, 10); image.Mutate(x => x.Dither(dither)); } diff --git a/tests/ImageSharp.Tests/Processing/Processors/Effects/BackgroundColorTest.cs b/tests/ImageSharp.Tests/Processing/Processors/Effects/BackgroundColorTest.cs index ed3be0f677..ab379ad7ca 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Effects/BackgroundColorTest.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Effects/BackgroundColorTest.cs @@ -11,10 +11,10 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Effects; public class BackgroundColorTest { public static readonly string[] InputImages = - { - TestImages.Png.Splash, + [ + TestImages.Png.Splash, TestImages.Png.Ducky - }; + ]; [Theory] [WithFileCollection(nameof(InputImages), PixelTypes.Rgba32)] diff --git a/tests/ImageSharp.Tests/Processing/Processors/Effects/OilPaintTest.cs b/tests/ImageSharp.Tests/Processing/Processors/Effects/OilPaintTest.cs index 10811a559e..8d720adf60 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Effects/OilPaintTest.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Effects/OilPaintTest.cs @@ -11,17 +11,17 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Effects; [GroupOutput("Effects")] public class OilPaintTest { - public static readonly TheoryData OilPaintValues = new TheoryData - { + public static readonly TheoryData OilPaintValues = new() + { { 15, 10 }, { 6, 5 } }; public static readonly string[] InputImages = - { - TestImages.Png.CalliphoraPartial, + [ + TestImages.Png.CalliphoraPartial, TestImages.Bmp.Car - }; + ]; [Theory] [WithFileCollection(nameof(InputImages), nameof(OilPaintValues), PixelTypes.Rgba32)] @@ -49,7 +49,7 @@ public void InBox(TestImageProvider provider, int levels, int br [Fact] public void Issue2518_PixelComponentOutsideOfRange_ThrowsImageProcessingException() { - using Image image = new(10, 10, new RgbaVector(1, 1, 100)); + using Image image = new(10, 10, new(1, 1, 100)); Assert.Throws(() => image.Mutate(ctx => ctx.OilPaint())); } } diff --git a/tests/ImageSharp.Tests/Processing/Processors/Effects/PixelShaderTest.cs b/tests/ImageSharp.Tests/Processing/Processors/Effects/PixelShaderTest.cs index fd732f570f..963394e7d5 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Effects/PixelShaderTest.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Effects/PixelShaderTest.cs @@ -24,7 +24,7 @@ public void FullImage(TestImageProvider provider) { Vector4 v4 = span[i]; float avg = (v4.X + v4.Y + v4.Z) / 3f; - span[i] = new Vector4(avg); + span[i] = new(avg); } }), appendPixelTypeToFileName: false); @@ -43,7 +43,7 @@ public void InBox(TestImageProvider provider) { Vector4 v4 = span[i]; float avg = (v4.X + v4.Y + v4.Z) / 3f; - span[i] = new Vector4(avg); + span[i] = new(avg); } }, rect)); @@ -71,7 +71,7 @@ public void PositionAwareFullImage(TestImageProvider provider) Vector4 v4 = span[i]; float avg = (v4.X + v4.Y + v4.Z) / 3f; - var gray = new Vector4(avg, avg, avg, a); + Vector4 gray = new(avg, avg, avg, a); span[i] = Vector4.Clamp(gray, Vector4.Zero, Vector4.One); } @@ -101,7 +101,7 @@ public void PositionAwareInBox(TestImageProvider provider) Vector4 v4 = span[i]; float avg = (v4.X + v4.Y + v4.Z) / 3f; - var gray = new Vector4(avg, avg, avg, a); + Vector4 gray = new(avg, avg, avg, a); span[i] = Vector4.Clamp(gray, Vector4.Zero, Vector4.One); } diff --git a/tests/ImageSharp.Tests/Processing/Processors/Effects/PixelateTest.cs b/tests/ImageSharp.Tests/Processing/Processors/Effects/PixelateTest.cs index 29b9524030..fff7ba0182 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Effects/PixelateTest.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Effects/PixelateTest.cs @@ -10,7 +10,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Effects; [GroupOutput("Effects")] public class PixelateTest { - public static readonly TheoryData PixelateValues = new TheoryData { 4, 8 }; + public static readonly TheoryData PixelateValues = new() { 4, 8 }; [Theory] [WithFile(TestImages.Png.Ducky, nameof(PixelateValues), PixelTypes.Rgba32)] diff --git a/tests/ImageSharp.Tests/Processing/Processors/Filters/BrightnessTest.cs b/tests/ImageSharp.Tests/Processing/Processors/Filters/BrightnessTest.cs index 7da96d13dd..4663aa868d 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Filters/BrightnessTest.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Filters/BrightnessTest.cs @@ -14,7 +14,7 @@ public class BrightnessTest private readonly ImageComparer imageComparer = ImageComparer.Tolerant(0.007F); public static readonly TheoryData BrightnessValues - = new TheoryData + = new() { .5F, 1.5F diff --git a/tests/ImageSharp.Tests/Processing/Processors/Filters/ColorBlindnessTest.cs b/tests/ImageSharp.Tests/Processing/Processors/Filters/ColorBlindnessTest.cs index 0727a5b979..1f2afb97f5 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Filters/ColorBlindnessTest.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Filters/ColorBlindnessTest.cs @@ -14,7 +14,7 @@ public class ColorBlindnessTest private readonly ImageComparer imageComparer = ImageComparer.Tolerant(0.03F); public static readonly TheoryData ColorBlindnessFilters - = new TheoryData + = new() { ColorBlindnessMode.Achromatomaly, ColorBlindnessMode.Achromatopsia, diff --git a/tests/ImageSharp.Tests/Processing/Processors/Filters/ContrastTest.cs b/tests/ImageSharp.Tests/Processing/Processors/Filters/ContrastTest.cs index 5e2a7f55d1..6ff10bbd8e 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Filters/ContrastTest.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Filters/ContrastTest.cs @@ -11,7 +11,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Filters; public class ContrastTest { public static readonly TheoryData ContrastValues - = new TheoryData + = new() { .5F, 1.5F diff --git a/tests/ImageSharp.Tests/Processing/Processors/Filters/GrayscaleTest.cs b/tests/ImageSharp.Tests/Processing/Processors/Filters/GrayscaleTest.cs index 50a2621524..15ef7f7c37 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Filters/GrayscaleTest.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Filters/GrayscaleTest.cs @@ -11,7 +11,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Filters; public class GrayscaleTest { public static readonly TheoryData GrayscaleModeTypes - = new TheoryData + = new() { GrayscaleMode.Bt601, GrayscaleMode.Bt709 diff --git a/tests/ImageSharp.Tests/Processing/Processors/Filters/HueTest.cs b/tests/ImageSharp.Tests/Processing/Processors/Filters/HueTest.cs index 65ac4245d7..1838cc33db 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Filters/HueTest.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Filters/HueTest.cs @@ -11,7 +11,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Filters; public class HueTest { public static readonly TheoryData HueValues - = new TheoryData + = new() { 180, -180 diff --git a/tests/ImageSharp.Tests/Processing/Processors/Filters/LightnessTest.cs b/tests/ImageSharp.Tests/Processing/Processors/Filters/LightnessTest.cs index 39e69aa4a5..49e2c85467 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Filters/LightnessTest.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Filters/LightnessTest.cs @@ -14,7 +14,7 @@ public class LightnessTest private readonly ImageComparer imageComparer = ImageComparer.Tolerant(0.007F); public static readonly TheoryData LightnessValues - = new TheoryData + = new() { .5F, 1.5F diff --git a/tests/ImageSharp.Tests/Processing/Processors/Filters/OpacityTest.cs b/tests/ImageSharp.Tests/Processing/Processors/Filters/OpacityTest.cs index 10ddf3a47d..8a1bbfe3f9 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Filters/OpacityTest.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Filters/OpacityTest.cs @@ -11,7 +11,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Filters; public class OpacityTest { public static readonly TheoryData AlphaValues - = new TheoryData + = new() { 20 / 100F, 80 / 100F diff --git a/tests/ImageSharp.Tests/Processing/Processors/Filters/SaturateTest.cs b/tests/ImageSharp.Tests/Processing/Processors/Filters/SaturateTest.cs index 8632d46259..642c798196 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Filters/SaturateTest.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Filters/SaturateTest.cs @@ -11,7 +11,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Filters; public class SaturateTest { public static readonly TheoryData SaturationValues - = new TheoryData + = new() { .5F, 1.5F, diff --git a/tests/ImageSharp.Tests/Processing/Processors/Overlays/OverlayTestBase.cs b/tests/ImageSharp.Tests/Processing/Processors/Overlays/OverlayTestBase.cs index cf2b7d4dad..3005867ca8 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Overlays/OverlayTestBase.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Overlays/OverlayTestBase.cs @@ -11,9 +11,9 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Overlays; [GroupOutput("Overlays")] public abstract class OverlayTestBase { - public static string[] ColorNames = { "Blue", "White" }; + public static string[] ColorNames = ["Blue", "White"]; - public static string[] InputImages = { TestImages.Png.Ducky, TestImages.Png.Splash }; + public static string[] InputImages = [TestImages.Png.Ducky, TestImages.Png.Splash]; private static readonly ImageComparer ValidatorComparer = ImageComparer.TolerantPercentage(0.05f); diff --git a/tests/ImageSharp.Tests/Processing/Processors/Quantization/OctreeQuantizerTests.cs b/tests/ImageSharp.Tests/Processing/Processors/Quantization/OctreeQuantizerTests.cs index c6880d3a81..cabfe30598 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Quantization/OctreeQuantizerTests.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Quantization/OctreeQuantizerTests.cs @@ -13,24 +13,24 @@ public class OctreeQuantizerTests [Fact] public void OctreeQuantizerConstructor() { - var expected = new QuantizerOptions { MaxColors = 128 }; - var quantizer = new OctreeQuantizer(expected); + QuantizerOptions expected = new() { MaxColors = 128 }; + OctreeQuantizer quantizer = new(expected); Assert.Equal(expected.MaxColors, quantizer.Options.MaxColors); Assert.Equal(QuantizerConstants.DefaultDither, quantizer.Options.Dither); - expected = new QuantizerOptions { Dither = null }; - quantizer = new OctreeQuantizer(expected); + expected = new() { Dither = null }; + quantizer = new(expected); Assert.Equal(QuantizerConstants.MaxColors, quantizer.Options.MaxColors); Assert.Null(quantizer.Options.Dither); - expected = new QuantizerOptions { Dither = KnownDitherings.Atkinson }; - quantizer = new OctreeQuantizer(expected); + expected = new() { Dither = KnownDitherings.Atkinson }; + quantizer = new(expected); Assert.Equal(QuantizerConstants.MaxColors, quantizer.Options.MaxColors); Assert.Equal(KnownDitherings.Atkinson, quantizer.Options.Dither); - expected = new QuantizerOptions { Dither = KnownDitherings.Atkinson, MaxColors = 0 }; - quantizer = new OctreeQuantizer(expected); + expected = new() { Dither = KnownDitherings.Atkinson, MaxColors = 0 }; + quantizer = new(expected); Assert.Equal(QuantizerConstants.MinColors, quantizer.Options.MaxColors); Assert.Equal(KnownDitherings.Atkinson, quantizer.Options.Dither); } @@ -38,7 +38,7 @@ public void OctreeQuantizerConstructor() [Fact] public void OctreeQuantizerCanCreateFrameQuantizer() { - var quantizer = new OctreeQuantizer(); + OctreeQuantizer quantizer = new(); IQuantizer frameQuantizer = quantizer.CreatePixelSpecificQuantizer(Configuration.Default); Assert.NotNull(frameQuantizer); @@ -46,14 +46,14 @@ public void OctreeQuantizerCanCreateFrameQuantizer() Assert.Equal(QuantizerConstants.DefaultDither, frameQuantizer.Options.Dither); frameQuantizer.Dispose(); - quantizer = new OctreeQuantizer(new QuantizerOptions { Dither = null }); + quantizer = new(new() { Dither = null }); frameQuantizer = quantizer.CreatePixelSpecificQuantizer(Configuration.Default); Assert.NotNull(frameQuantizer); Assert.Null(frameQuantizer.Options.Dither); frameQuantizer.Dispose(); - quantizer = new OctreeQuantizer(new QuantizerOptions { Dither = KnownDitherings.Atkinson }); + quantizer = new(new() { Dither = KnownDitherings.Atkinson }); frameQuantizer = quantizer.CreatePixelSpecificQuantizer(Configuration.Default); Assert.NotNull(frameQuantizer); Assert.Equal(KnownDitherings.Atkinson, frameQuantizer.Options.Dither); diff --git a/tests/ImageSharp.Tests/Processing/Processors/Quantization/PaletteQuantizerTests.cs b/tests/ImageSharp.Tests/Processing/Processors/Quantization/PaletteQuantizerTests.cs index 91cf90bc46..c2ceb4a69c 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Quantization/PaletteQuantizerTests.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Quantization/PaletteQuantizerTests.cs @@ -10,29 +10,29 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Quantization; [Trait("Category", "Processors")] public class PaletteQuantizerTests { - private static readonly Color[] Palette = { Color.Red, Color.Green, Color.Blue }; + private static readonly Color[] Palette = [Color.Red, Color.Green, Color.Blue]; [Fact] public void PaletteQuantizerConstructor() { - var expected = new QuantizerOptions { MaxColors = 128 }; - var quantizer = new PaletteQuantizer(Palette, expected); + QuantizerOptions expected = new() { MaxColors = 128 }; + PaletteQuantizer quantizer = new(Palette, expected); Assert.Equal(expected.MaxColors, quantizer.Options.MaxColors); Assert.Equal(QuantizerConstants.DefaultDither, quantizer.Options.Dither); - expected = new QuantizerOptions { Dither = null }; - quantizer = new PaletteQuantizer(Palette, expected); + expected = new() { Dither = null }; + quantizer = new(Palette, expected); Assert.Equal(QuantizerConstants.MaxColors, quantizer.Options.MaxColors); Assert.Null(quantizer.Options.Dither); - expected = new QuantizerOptions { Dither = KnownDitherings.Atkinson }; - quantizer = new PaletteQuantizer(Palette, expected); + expected = new() { Dither = KnownDitherings.Atkinson }; + quantizer = new(Palette, expected); Assert.Equal(QuantizerConstants.MaxColors, quantizer.Options.MaxColors); Assert.Equal(KnownDitherings.Atkinson, quantizer.Options.Dither); - expected = new QuantizerOptions { Dither = KnownDitherings.Atkinson, MaxColors = 0 }; - quantizer = new PaletteQuantizer(Palette, expected); + expected = new() { Dither = KnownDitherings.Atkinson, MaxColors = 0 }; + quantizer = new(Palette, expected); Assert.Equal(QuantizerConstants.MinColors, quantizer.Options.MaxColors); Assert.Equal(KnownDitherings.Atkinson, quantizer.Options.Dither); } @@ -40,7 +40,7 @@ public void PaletteQuantizerConstructor() [Fact] public void PaletteQuantizerCanCreateFrameQuantizer() { - var quantizer = new PaletteQuantizer(Palette); + PaletteQuantizer quantizer = new(Palette); IQuantizer frameQuantizer = quantizer.CreatePixelSpecificQuantizer(Configuration.Default); Assert.NotNull(frameQuantizer); @@ -48,14 +48,14 @@ public void PaletteQuantizerCanCreateFrameQuantizer() Assert.Equal(QuantizerConstants.DefaultDither, frameQuantizer.Options.Dither); frameQuantizer.Dispose(); - quantizer = new PaletteQuantizer(Palette, new QuantizerOptions { Dither = null }); + quantizer = new(Palette, new() { Dither = null }); frameQuantizer = quantizer.CreatePixelSpecificQuantizer(Configuration.Default); Assert.NotNull(frameQuantizer); Assert.Null(frameQuantizer.Options.Dither); frameQuantizer.Dispose(); - quantizer = new PaletteQuantizer(Palette, new QuantizerOptions { Dither = KnownDitherings.Atkinson }); + quantizer = new(Palette, new() { Dither = KnownDitherings.Atkinson }); frameQuantizer = quantizer.CreatePixelSpecificQuantizer(Configuration.Default); Assert.NotNull(frameQuantizer); Assert.Equal(KnownDitherings.Atkinson, frameQuantizer.Options.Dither); diff --git a/tests/ImageSharp.Tests/Processing/Processors/Quantization/QuantizerTests.cs b/tests/ImageSharp.Tests/Processing/Processors/Quantization/QuantizerTests.cs index b8b4615b94..2ba757c117 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Quantization/QuantizerTests.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Quantization/QuantizerTests.cs @@ -13,10 +13,10 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Quantization; public class QuantizerTests { public static readonly string[] CommonTestImages = - { + [ TestImages.Png.CalliphoraPartial, TestImages.Png.Bike - }; + ]; private static readonly QuantizerOptions NoDitherOptions = new() { Dither = null }; private static readonly QuantizerOptions DiffuserDitherOptions = new() { Dither = KnownDitherings.FloydSteinberg }; diff --git a/tests/ImageSharp.Tests/Processing/Processors/Quantization/WuQuantizerTests.cs b/tests/ImageSharp.Tests/Processing/Processors/Quantization/WuQuantizerTests.cs index ab4304d898..6e43fe2525 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Quantization/WuQuantizerTests.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Quantization/WuQuantizerTests.cs @@ -13,24 +13,24 @@ public class WuQuantizerTests [Fact] public void WuQuantizerConstructor() { - var expected = new QuantizerOptions { MaxColors = 128 }; - var quantizer = new WuQuantizer(expected); + QuantizerOptions expected = new() { MaxColors = 128 }; + WuQuantizer quantizer = new(expected); Assert.Equal(expected.MaxColors, quantizer.Options.MaxColors); Assert.Equal(QuantizerConstants.DefaultDither, quantizer.Options.Dither); - expected = new QuantizerOptions { Dither = null }; - quantizer = new WuQuantizer(expected); + expected = new() { Dither = null }; + quantizer = new(expected); Assert.Equal(QuantizerConstants.MaxColors, quantizer.Options.MaxColors); Assert.Null(quantizer.Options.Dither); - expected = new QuantizerOptions { Dither = KnownDitherings.Atkinson }; - quantizer = new WuQuantizer(expected); + expected = new() { Dither = KnownDitherings.Atkinson }; + quantizer = new(expected); Assert.Equal(QuantizerConstants.MaxColors, quantizer.Options.MaxColors); Assert.Equal(KnownDitherings.Atkinson, quantizer.Options.Dither); - expected = new QuantizerOptions { Dither = KnownDitherings.Atkinson, MaxColors = 0 }; - quantizer = new WuQuantizer(expected); + expected = new() { Dither = KnownDitherings.Atkinson, MaxColors = 0 }; + quantizer = new(expected); Assert.Equal(QuantizerConstants.MinColors, quantizer.Options.MaxColors); Assert.Equal(KnownDitherings.Atkinson, quantizer.Options.Dither); } @@ -38,7 +38,7 @@ public void WuQuantizerConstructor() [Fact] public void WuQuantizerCanCreateFrameQuantizer() { - var quantizer = new WuQuantizer(); + WuQuantizer quantizer = new(); IQuantizer frameQuantizer = quantizer.CreatePixelSpecificQuantizer(Configuration.Default); Assert.NotNull(frameQuantizer); @@ -46,14 +46,14 @@ public void WuQuantizerCanCreateFrameQuantizer() Assert.Equal(QuantizerConstants.DefaultDither, frameQuantizer.Options.Dither); frameQuantizer.Dispose(); - quantizer = new WuQuantizer(new QuantizerOptions { Dither = null }); + quantizer = new(new() { Dither = null }); frameQuantizer = quantizer.CreatePixelSpecificQuantizer(Configuration.Default); Assert.NotNull(frameQuantizer); Assert.Null(frameQuantizer.Options.Dither); frameQuantizer.Dispose(); - quantizer = new WuQuantizer(new QuantizerOptions { Dither = KnownDitherings.Atkinson }); + quantizer = new(new() { Dither = KnownDitherings.Atkinson }); frameQuantizer = quantizer.CreatePixelSpecificQuantizer(Configuration.Default); Assert.NotNull(frameQuantizer); Assert.Equal(KnownDitherings.Atkinson, frameQuantizer.Options.Dither); diff --git a/tests/ImageSharp.Tests/Processing/Processors/Transforms/AffineTransformTests.cs b/tests/ImageSharp.Tests/Processing/Processors/Transforms/AffineTransformTests.cs index a7855e23aa..34a8b1e587 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Transforms/AffineTransformTests.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Transforms/AffineTransformTests.cs @@ -213,7 +213,7 @@ public void WorksWithDiscoBuffers(TestImageProvider provider, in public void Issue1911() { using Image image = new(100, 100); - image.Mutate(x => x = x.Transform(new Rectangle(0, 0, 99, 100), Matrix3x2.Identity, new Size(99, 100), KnownResamplers.Lanczos2)); + image.Mutate(x => x = x.Transform(new(0, 0, 99, 100), Matrix3x2.Identity, new(99, 100), KnownResamplers.Lanczos2)); Assert.Equal(99, image.Width); Assert.Equal(100, image.Height); @@ -227,7 +227,7 @@ public void Issue2753(TestImageProvider provider) using Image image = provider.GetImage(); AffineTransformBuilder builder = - new AffineTransformBuilder().AppendRotationDegrees(270, new Vector2(3.5f, 3.5f)); + new AffineTransformBuilder().AppendRotationDegrees(270, new(3.5f, 3.5f)); image.Mutate(x => x.BackgroundColor(Color.Red)); image.Mutate(x => x = x.Transform(builder)); @@ -246,7 +246,7 @@ public void Identity(TestImageProvider provider) Matrix3x2 m = Matrix3x2.Identity; Rectangle r = new(25, 25, 50, 50); - image.Mutate(x => x.Transform(r, m, new Size(100, 100), KnownResamplers.Bicubic)); + image.Mutate(x => x.Transform(r, m, new(100, 100), KnownResamplers.Bicubic)); image.DebugSave(provider); image.CompareToReferenceOutput(ValidatorComparer, provider); } @@ -260,9 +260,9 @@ public void Transform_With_Custom_Dimensions(TestImageProvider p { using Image image = provider.GetImage(); - Matrix3x2 m = Matrix3x2.CreateRotation(radians, new Vector2(50, 50)); + Matrix3x2 m = Matrix3x2.CreateRotation(radians, new(50, 50)); Rectangle r = new(25, 25, 50, 50); - image.Mutate(x => x.Transform(r, m, new Size(100, 100), KnownResamplers.Bicubic)); + image.Mutate(x => x.Transform(r, m, new(100, 100), KnownResamplers.Bicubic)); image.DebugSave(provider, testOutputDetails: radians); image.CompareToReferenceOutput(ValidatorComparer, provider, testOutputDetails: radians); } diff --git a/tests/ImageSharp.Tests/Processing/Processors/Transforms/AutoOrientTests.cs b/tests/ImageSharp.Tests/Processing/Processors/Transforms/AutoOrientTests.cs index 6a61538ea1..73ce79ea09 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Transforms/AutoOrientTests.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Transforms/AutoOrientTests.cs @@ -17,8 +17,8 @@ public class AutoOrientTests public static readonly TheoryData InvalidOrientationValues = new() { - { ExifDataType.Byte, new byte[] { 1 } }, - { ExifDataType.SignedByte, new byte[] { 2 } }, + { ExifDataType.Byte, [1] }, + { ExifDataType.SignedByte, [2] }, { ExifDataType.SignedShort, BitConverter.GetBytes((short)3) }, { ExifDataType.Long, BitConverter.GetBytes(4U) }, { ExifDataType.SignedLong, BitConverter.GetBytes(5) } @@ -44,7 +44,7 @@ public void AutoOrient_WorksForAllExifOrientations(TestImageProvider { using Image image = provider.GetImage(); - image.Metadata.ExifProfile = new ExifProfile(); + image.Metadata.ExifProfile = new(); image.Metadata.ExifProfile.SetValue(ExifTag.Orientation, orientation); image.Mutate(x => x.AutoOrient()); @@ -57,7 +57,7 @@ public void AutoOrient_WorksForAllExifOrientations(TestImageProvider(TestImageProvider provider, ExifDataType dataType, byte[] orientation) where TPixel : unmanaged, IPixel { - var profile = new ExifProfile(); + ExifProfile profile = new(); profile.SetValue(ExifTag.JPEGTables, orientation); byte[] bytes = profile.ToByteArray(); @@ -79,7 +79,7 @@ public void AutoOrient_WorksWithCorruptExifData(TestImageProvider image = provider.GetImage(); using Image reference = image.Clone(); - image.Metadata.ExifProfile = new ExifProfile(bytes); + image.Metadata.ExifProfile = new(bytes); image.Mutate(x => x.AutoOrient()); image.DebugSave(provider, $"{dataType}-{orientationCode}", appendPixelTypeToFileName: false); ImageComparer.Exact.VerifySimilarity(image, reference); diff --git a/tests/ImageSharp.Tests/Processing/Processors/Transforms/CropTest.cs b/tests/ImageSharp.Tests/Processing/Processors/Transforms/CropTest.cs index 18a7a9bd09..f4a0aeb0cc 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Transforms/CropTest.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Transforms/CropTest.cs @@ -17,7 +17,7 @@ public class CropTest public void Crop(TestImageProvider provider, int x, int y, int w, int h) where TPixel : unmanaged, IPixel { - var rect = new Rectangle(x, y, w, h); + Rectangle rect = new(x, y, w, h); FormattableString info = $"X{x}Y{y}.W{w}H{h}"; provider.RunValidatingProcessorTest( ctx => ctx.Crop(rect), diff --git a/tests/ImageSharp.Tests/Processing/Processors/Transforms/EntropyCropTest.cs b/tests/ImageSharp.Tests/Processing/Processors/Transforms/EntropyCropTest.cs index ca4b00d8aa..ffa9be6ea7 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Transforms/EntropyCropTest.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Transforms/EntropyCropTest.cs @@ -10,14 +10,14 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Transforms; [GroupOutput("Transforms")] public class EntropyCropTest { - public static readonly TheoryData EntropyCropValues = new TheoryData { .25F, .75F }; + public static readonly TheoryData EntropyCropValues = new() { .25F, .75F }; public static readonly string[] InputImages = - { - TestImages.Png.Ducky, + [ + TestImages.Png.Ducky, TestImages.Jpeg.Baseline.Jpeg400, TestImages.Jpeg.Baseline.MultiScanBaselineCMYK - }; + ]; [Theory] [WithFileCollection(nameof(InputImages), nameof(EntropyCropValues), PixelTypes.Rgba32)] @@ -35,8 +35,8 @@ public void Entropy_WillNotCropWhiteImage(TestImageProvider prov { // arrange using Image image = provider.GetImage(); - var expectedHeight = image.Height; - var expectedWidth = image.Width; + int expectedHeight = image.Height; + int expectedWidth = image.Width; // act image.Mutate(img => img.EntropyCrop()); diff --git a/tests/ImageSharp.Tests/Processing/Processors/Transforms/FlipTests.cs b/tests/ImageSharp.Tests/Processing/Processors/Transforms/FlipTests.cs index 717582274f..5c545147e1 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Transforms/FlipTests.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Transforms/FlipTests.cs @@ -12,8 +12,8 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Transforms; public class FlipTests { public static readonly TheoryData FlipValues = - new TheoryData - { + new() + { FlipMode.None, FlipMode.Vertical, FlipMode.Horizontal, diff --git a/tests/ImageSharp.Tests/Processing/Processors/Transforms/PadTest.cs b/tests/ImageSharp.Tests/Processing/Processors/Transforms/PadTest.cs index 8949049fbc..0b6f5702f3 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Transforms/PadTest.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Transforms/PadTest.cs @@ -10,9 +10,9 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Transforms; public class PadTest { public static readonly string[] CommonTestImages = - { + [ TestImages.Png.CalliphoraPartial, TestImages.Png.Bike - }; + ]; [Theory] [WithFileCollection(nameof(CommonTestImages), PixelTypes.Rgba32)] diff --git a/tests/ImageSharp.Tests/Processing/Processors/Transforms/ResizeHelperTests.cs b/tests/ImageSharp.Tests/Processing/Processors/Transforms/ResizeHelperTests.cs index 84d834cc50..96e7702d8e 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Transforms/ResizeHelperTests.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Transforms/ResizeHelperTests.cs @@ -34,33 +34,33 @@ public void CalculateResizeWorkerHeightInWindowBands( [Fact] public void CalculateMinRectangleWhenSourceIsSmallerThanTarget() { - var sourceSize = new Size(200, 100); - var target = new Size(400, 200); + Size sourceSize = new(200, 100); + Size target = new(400, 200); (Size size, Rectangle rectangle) = ResizeHelper.CalculateTargetLocationAndBounds( sourceSize, - new ResizeOptions + new() { Mode = ResizeMode.Min, Size = target }); Assert.Equal(sourceSize, size); - Assert.Equal(new Rectangle(0, 0, sourceSize.Width, sourceSize.Height), rectangle); + Assert.Equal(new(0, 0, sourceSize.Width, sourceSize.Height), rectangle); } [Fact] public void MaxSizeAndRectangleAreCorrect() { - var sourceSize = new Size(5072, 6761); - var target = new Size(0, 450); + Size sourceSize = new(5072, 6761); + Size target = new(0, 450); - var expectedSize = new Size(338, 450); - var expectedRectangle = new Rectangle(Point.Empty, expectedSize); + Size expectedSize = new(338, 450); + Rectangle expectedRectangle = new(Point.Empty, expectedSize); (Size size, Rectangle rectangle) = ResizeHelper.CalculateTargetLocationAndBounds( sourceSize, - new ResizeOptions + new() { Mode = ResizeMode.Max, Size = target @@ -73,15 +73,15 @@ public void MaxSizeAndRectangleAreCorrect() [Fact] public void CropSizeAndRectangleAreCorrect() { - var sourceSize = new Size(100, 100); - var target = new Size(25, 50); + Size sourceSize = new(100, 100); + Size target = new(25, 50); - var expectedSize = new Size(25, 50); - var expectedRectangle = new Rectangle(-12, 0, 50, 50); + Size expectedSize = new(25, 50); + Rectangle expectedRectangle = new(-12, 0, 50, 50); (Size size, Rectangle rectangle) = ResizeHelper.CalculateTargetLocationAndBounds( sourceSize, - new ResizeOptions + new() { Mode = ResizeMode.Crop, Size = target @@ -94,15 +94,15 @@ public void CropSizeAndRectangleAreCorrect() [Fact] public void BoxPadSizeAndRectangleAreCorrect() { - var sourceSize = new Size(100, 100); - var target = new Size(120, 110); + Size sourceSize = new(100, 100); + Size target = new(120, 110); - var expectedSize = new Size(120, 110); - var expectedRectangle = new Rectangle(10, 5, 100, 100); + Size expectedSize = new(120, 110); + Rectangle expectedRectangle = new(10, 5, 100, 100); (Size size, Rectangle rectangle) = ResizeHelper.CalculateTargetLocationAndBounds( sourceSize, - new ResizeOptions + new() { Mode = ResizeMode.BoxPad, Size = target @@ -115,15 +115,15 @@ public void BoxPadSizeAndRectangleAreCorrect() [Fact] public void PadSizeAndRectangleAreCorrect() { - var sourceSize = new Size(100, 100); - var target = new Size(120, 110); + Size sourceSize = new(100, 100); + Size target = new(120, 110); - var expectedSize = new Size(120, 110); - var expectedRectangle = new Rectangle(5, 0, 110, 110); + Size expectedSize = new(120, 110); + Rectangle expectedRectangle = new(5, 0, 110, 110); (Size size, Rectangle rectangle) = ResizeHelper.CalculateTargetLocationAndBounds( sourceSize, - new ResizeOptions + new() { Mode = ResizeMode.Pad, Size = target @@ -136,15 +136,15 @@ public void PadSizeAndRectangleAreCorrect() [Fact] public void StretchSizeAndRectangleAreCorrect() { - var sourceSize = new Size(100, 100); - var target = new Size(57, 32); + Size sourceSize = new(100, 100); + Size target = new(57, 32); - var expectedSize = new Size(57, 32); - var expectedRectangle = new Rectangle(Point.Empty, expectedSize); + Size expectedSize = new(57, 32); + Rectangle expectedRectangle = new(Point.Empty, expectedSize); (Size size, Rectangle rectangle) = ResizeHelper.CalculateTargetLocationAndBounds( sourceSize, - new ResizeOptions + new() { Mode = ResizeMode.Stretch, Size = target diff --git a/tests/ImageSharp.Tests/Processing/Processors/Transforms/ResizeKernelMapTests.ReferenceKernelMap.cs b/tests/ImageSharp.Tests/Processing/Processors/Transforms/ResizeKernelMapTests.ReferenceKernelMap.cs index 290a3b37ac..a40a8d5b2b 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Transforms/ResizeKernelMapTests.ReferenceKernelMap.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Transforms/ResizeKernelMapTests.ReferenceKernelMap.cs @@ -39,7 +39,7 @@ public static ReferenceKernelMap Calculate(in TResampler sampler, in double radius = tolerantMath.Ceiling(scale * sampler.Radius); - var result = new List(); + List result = []; for (int i = 0; i < destinationSize; i++) { @@ -80,10 +80,10 @@ public static ReferenceKernelMap Calculate(in TResampler sampler, in float[] floatVals = values.Select(v => (float)v).ToArray(); - result.Add(new ReferenceKernel(left, floatVals)); + result.Add(new(left, floatVals)); } - return new ReferenceKernelMap(result.ToArray()); + return new(result.ToArray()); } } @@ -103,7 +103,7 @@ public ReferenceKernel(int left, float[] values) public static implicit operator ReferenceKernel(ResizeKernel orig) { - return new ReferenceKernel(orig.StartIndex, orig.Values.ToArray()); + return new(orig.StartIndex, orig.Values.ToArray()); } } } diff --git a/tests/ImageSharp.Tests/Processing/Processors/Transforms/ResizeKernelMapTests.cs b/tests/ImageSharp.Tests/Processing/Processors/Transforms/ResizeKernelMapTests.cs index c6da46ee2f..0357dda046 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Transforms/ResizeKernelMapTests.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Transforms/ResizeKernelMapTests.cs @@ -22,8 +22,8 @@ public ResizeKernelMapTests(ITestOutputHelper output) /// resamplerName, srcSize, destSize /// public static readonly TheoryData KernelMapData - = new TheoryData - { + = new() + { { KnownResamplers.Bicubic, 15, 10 }, { KnownResamplers.Bicubic, 10, 15 }, { KnownResamplers.Bicubic, 20, 20 }, @@ -88,7 +88,7 @@ public static readonly TheoryData KernelMapData public void PrintNonNormalizedKernelMap(TResampler resampler, int srcSize, int destSize) where TResampler : struct, IResampler { - var kernelMap = ReferenceKernelMap.Calculate(in resampler, destSize, srcSize, false); + ReferenceKernelMap kernelMap = ReferenceKernelMap.Calculate(in resampler, destSize, srcSize, false); this.Output.WriteLine($"Actual KernelMap:\n{PrintKernelMap(kernelMap)}\n"); } @@ -116,15 +116,15 @@ public void KernelMapContentIsCorrect_ExtendedGeneratedValues(string resamplerNa private void VerifyKernelMapContentIsCorrect(TResampler resampler, int srcSize, int destSize) where TResampler : struct, IResampler { - var referenceMap = ReferenceKernelMap.Calculate(in resampler, destSize, srcSize); - var kernelMap = ResizeKernelMap.Calculate(in resampler, destSize, srcSize, Configuration.Default.MemoryAllocator); + ReferenceKernelMap referenceMap = ReferenceKernelMap.Calculate(in resampler, destSize, srcSize); + ResizeKernelMap kernelMap = ResizeKernelMap.Calculate(in resampler, destSize, srcSize, Configuration.Default.MemoryAllocator); #if DEBUG this.Output.WriteLine(kernelMap.Info); this.Output.WriteLine($"Expected KernelMap:\n{PrintKernelMap(referenceMap)}\n"); this.Output.WriteLine($"Actual KernelMap:\n{PrintKernelMap(kernelMap)}\n"); #endif - var comparer = new ApproximateFloatComparer(1e-6f); + ApproximateFloatComparer comparer = new(1e-6f); for (int i = 0; i < kernelMap.DestinationLength; i++) { @@ -163,7 +163,7 @@ private static string PrintKernelMap( Func getDestinationSize, Func getKernel) { - var bld = new StringBuilder(); + StringBuilder bld = new(); if (kernelMap is ResizeKernelMap actualMap) { @@ -193,19 +193,19 @@ private static string PrintKernelMap( private static TheoryData GenerateImageResizeData() { - var result = new TheoryData(); + TheoryData result = new(); string[] resamplerNames = TestUtils.GetAllResamplerNames(false); int[] dimensionVals = - { - // Arbitrary, small dimensions: + [ + // Arbitrary, small dimensions: 9, 10, 11, 13, 49, 50, 53, 99, 100, 199, 200, 201, 299, 300, 301, // Typical image sizes: 640, 480, 800, 600, 1024, 768, 1280, 960, 1536, 1180, 1600, 1200, 2048, 1536, 2240, 1680, 2560, 1920, 3032, 2008, 3072, 2304, 3264, 2448 - }; + ]; IOrderedEnumerable<(int S, int D)> source2Dest = dimensionVals .SelectMany(s => dimensionVals.Select(d => (s, d))) diff --git a/tests/ImageSharp.Tests/Processing/Processors/Transforms/ResizeTests.cs b/tests/ImageSharp.Tests/Processing/Processors/Transforms/ResizeTests.cs index d1b005ee4e..8771559c2b 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Transforms/ResizeTests.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Transforms/ResizeTests.cs @@ -20,15 +20,15 @@ public class ResizeTests public static readonly string[] AllResamplerNames = TestUtils.GetAllResamplerNames(); - public static readonly string[] CommonTestImages = { TestImages.Png.CalliphoraPartial }; + public static readonly string[] CommonTestImages = [TestImages.Png.CalliphoraPartial]; public static readonly string[] SmokeTestResamplerNames = - { - nameof(KnownResamplers.NearestNeighbor), + [ + nameof(KnownResamplers.NearestNeighbor), nameof(KnownResamplers.Bicubic), nameof(KnownResamplers.Box), - nameof(KnownResamplers.Lanczos5), - }; + nameof(KnownResamplers.Lanczos5) + ]; private static readonly ImageComparer ValidatorComparer = ImageComparer.TolerantPercentage(0.07F); @@ -78,7 +78,7 @@ public void Resize_BasicSmall(TestImageProvider provider, int wN // resizing: (15, 12) -> (10, 6) // kernel dimensions: (3, 4) using Image image = provider.GetImage(); - Size destSize = new Size(image.Width * wN / wD, image.Height * hN / hD); + Size destSize = new(image.Width * wN / wD, image.Height * hN / hD); image.Mutate(x => x.Resize(destSize, KnownResamplers.Bicubic, false)); FormattableString outputInfo = $"({wN}÷{wD},{hN}÷{hD})"; image.DebugSave(provider, outputInfo, appendPixelTypeToFileName: false); @@ -106,7 +106,7 @@ public void WorkingBufferSizeHintInBytes_IsAppliedCorrectly( Configuration configuration = Configuration.CreateDefaultInstance(); int workingBufferSizeHintInBytes = workingBufferLimitInRows * destSize.Width * SizeOfVector4; - TestMemoryAllocator allocator = new TestMemoryAllocator(); + TestMemoryAllocator allocator = new(); allocator.EnableNonThreadSafeLogging(); configuration.MemoryAllocator = allocator; configuration.WorkingBufferSizeHintInBytes = workingBufferSizeHintInBytes; @@ -211,7 +211,7 @@ public void Resize_PremultiplyAlpha(TestImageProvider provider, provider.RunValidatingProcessorTest( x => { - ResizeOptions resizeOptions = new ResizeOptions() + ResizeOptions resizeOptions = new() { Size = x.GetCurrentSize() / 2, Mode = ResizeMode.Crop, @@ -346,7 +346,7 @@ public void Resize_WorksWithAllResamplers( "invalid dimensional input for Resize_WorksWithAllResamplers!"); } - newSize = new SizeF(specificDestWidth.Value, specificDestHeight.Value); + newSize = new(specificDestWidth.Value, specificDestHeight.Value); destSizeInfo = $"{newSize.Width}x{newSize.Height}"; } @@ -365,12 +365,12 @@ public void ResizeFromSourceRectangle(TestImageProvider provider where TPixel : unmanaged, IPixel { using Image image = provider.GetImage(); - Rectangle sourceRectangle = new Rectangle( + Rectangle sourceRectangle = new( image.Width / 8, image.Height / 8, image.Width / 4, image.Height / 4); - Rectangle destRectangle = new Rectangle(image.Width / 4, image.Height / 4, image.Width / 2, image.Height / 2); + Rectangle destRectangle = new(image.Width / 4, image.Height / 4, image.Width / 2, image.Height / 2); image.Mutate( x => x.Resize( @@ -437,9 +437,9 @@ public void ResizeWithBoxPadMode(TestImageProvider provider) where TPixel : unmanaged, IPixel { using Image image = provider.GetImage(); - ResizeOptions options = new ResizeOptions + ResizeOptions options = new() { - Size = new Size(image.Width + 200, image.Height + 200), + Size = new(image.Width + 200, image.Height + 200), Mode = ResizeMode.BoxPad, PadColor = Color.HotPink }; @@ -456,7 +456,7 @@ public void ResizeWithCropHeightMode(TestImageProvider provider) where TPixel : unmanaged, IPixel { using Image image = provider.GetImage(); - ResizeOptions options = new ResizeOptions { Size = new Size(image.Width, image.Height / 2) }; + ResizeOptions options = new() { Size = new(image.Width, image.Height / 2) }; image.Mutate(x => x.Resize(options)); @@ -470,7 +470,7 @@ public void ResizeWithCropWidthMode(TestImageProvider provider) where TPixel : unmanaged, IPixel { using Image image = provider.GetImage(); - ResizeOptions options = new ResizeOptions { Size = new Size(image.Width / 2, image.Height) }; + ResizeOptions options = new() { Size = new(image.Width / 2, image.Height) }; image.Mutate(x => x.Resize(options)); @@ -484,9 +484,9 @@ public void CanResizeLargeImageWithCropMode(TestImageProvider pr where TPixel : unmanaged, IPixel { using Image image = provider.GetImage(); - ResizeOptions options = new ResizeOptions + ResizeOptions options = new() { - Size = new Size(480, 600), + Size = new(480, 600), Mode = ResizeMode.Crop }; @@ -502,7 +502,7 @@ public void ResizeWithMaxMode(TestImageProvider provider) where TPixel : unmanaged, IPixel { using Image image = provider.GetImage(); - ResizeOptions options = new ResizeOptions { Size = new Size(300, 300), Mode = ResizeMode.Max }; + ResizeOptions options = new() { Size = new(300, 300), Mode = ResizeMode.Max }; image.Mutate(x => x.Resize(options)); @@ -516,9 +516,9 @@ public void ResizeWithMinMode(TestImageProvider provider) where TPixel : unmanaged, IPixel { using Image image = provider.GetImage(); - ResizeOptions options = new ResizeOptions + ResizeOptions options = new() { - Size = new Size((int)Math.Round(image.Width * .75F), (int)Math.Round(image.Height * .95F)), + Size = new((int)Math.Round(image.Width * .75F), (int)Math.Round(image.Height * .95F)), Mode = ResizeMode.Min }; @@ -534,9 +534,9 @@ public void ResizeWithPadMode(TestImageProvider provider) where TPixel : unmanaged, IPixel { using Image image = provider.GetImage(); - ResizeOptions options = new ResizeOptions + ResizeOptions options = new() { - Size = new Size(image.Width + 200, image.Height), + Size = new(image.Width + 200, image.Height), Mode = ResizeMode.Pad, PadColor = Color.Lavender }; @@ -553,9 +553,9 @@ public void ResizeWithStretchMode(TestImageProvider provider) where TPixel : unmanaged, IPixel { using Image image = provider.GetImage(); - ResizeOptions options = new ResizeOptions + ResizeOptions options = new() { - Size = new Size(image.Width / 2, image.Height), + Size = new(image.Width / 2, image.Height), Mode = ResizeMode.Stretch }; @@ -586,8 +586,8 @@ public void CanResizeExifIssueImages(TestImageProvider provider) [Fact] public void Issue1195() { - using Image image = new Image(2, 300); - Size size = new Size(50, 50); + using Image image = new(2, 300); + Size size = new(50, 50); image.Mutate(x => x .Resize( new ResizeOptions @@ -605,8 +605,8 @@ public void Issue1195() [InlineData(3, 7)] public void Issue1342(int width, int height) { - using Image image = new Image(1, 1); - Size size = new Size(width, height); + using Image image = new(1, 1); + Size size = new(width, height); image.Mutate(x => x .Resize( new ResizeOptions diff --git a/tests/ImageSharp.Tests/Processing/Processors/Transforms/RotateFlipTests.cs b/tests/ImageSharp.Tests/Processing/Processors/Transforms/RotateFlipTests.cs index 55d26974aa..523fd2bdd1 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Transforms/RotateFlipTests.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Transforms/RotateFlipTests.cs @@ -9,11 +9,11 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Transforms; [Trait("Category", "Processors")] public class RotateFlipTests { - public static readonly string[] FlipFiles = { TestImages.Bmp.F }; + public static readonly string[] FlipFiles = [TestImages.Bmp.F]; public static readonly TheoryData RotateFlipValues - = new TheoryData - { + = new() + { { RotateMode.None, FlipMode.Vertical }, { RotateMode.None, FlipMode.Horizontal }, { RotateMode.Rotate90, FlipMode.None }, diff --git a/tests/ImageSharp.Tests/Processing/Processors/Transforms/RotateTests.cs b/tests/ImageSharp.Tests/Processing/Processors/Transforms/RotateTests.cs index b150da1d8e..7c3a97a444 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Transforms/RotateTests.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Transforms/RotateTests.cs @@ -11,14 +11,14 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Transforms; public class RotateTests { public static readonly TheoryData RotateAngles - = new TheoryData - { + = new() + { 50, -50, 170, -170 }; public static readonly TheoryData RotateEnumValues - = new TheoryData - { + = new() + { RotateMode.None, RotateMode.Rotate90, RotateMode.Rotate180, diff --git a/tests/ImageSharp.Tests/Processing/Processors/Transforms/SkewTests.cs b/tests/ImageSharp.Tests/Processing/Processors/Transforms/SkewTests.cs index 1e217ae24a..84401e8468 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Transforms/SkewTests.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Transforms/SkewTests.cs @@ -14,9 +14,9 @@ public class SkewTests { private const PixelTypes CommonPixelTypes = PixelTypes.Bgra32 | PixelTypes.Rgb24; - public static readonly string[] ResamplerNames = new[] - { - nameof(KnownResamplers.Bicubic), + public static readonly string[] ResamplerNames = + [ + nameof(KnownResamplers.Bicubic), nameof(KnownResamplers.Box), nameof(KnownResamplers.CatmullRom), nameof(KnownResamplers.Hermite), @@ -30,11 +30,11 @@ public class SkewTests nameof(KnownResamplers.RobidouxSharp), nameof(KnownResamplers.Spline), nameof(KnownResamplers.Triangle), - nameof(KnownResamplers.Welch), - }; + nameof(KnownResamplers.Welch) + ]; - public static readonly TheoryData SkewValues = new TheoryData - { + public static readonly TheoryData SkewValues = new() + { { 20, 10 }, { -20, -10 } }; diff --git a/tests/ImageSharp.Tests/Processing/Processors/Transforms/SwizzleTests.cs b/tests/ImageSharp.Tests/Processing/Processors/Transforms/SwizzleTests.cs index de02502e2b..b831b0a6c1 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Transforms/SwizzleTests.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Transforms/SwizzleTests.cs @@ -16,13 +16,12 @@ private struct InvertXAndYSwizzler : ISwizzler { public InvertXAndYSwizzler(Size sourceSize) { - this.DestinationSize = new Size(sourceSize.Height, sourceSize.Width); + this.DestinationSize = new(sourceSize.Height, sourceSize.Width); } public Size DestinationSize { get; } - public Point Transform(Point point) - => new Point(point.Y, point.X); + public Point Transform(Point point) => new(point.Y, point.X); } [Theory] @@ -35,7 +34,7 @@ public void InvertXAndYSwizzle(TestImageProvider provider) using Image expectedImage = provider.GetImage(); using Image image = provider.GetImage(); - image.Mutate(ctx => ctx.Swizzle(new InvertXAndYSwizzler(new Size(image.Width, image.Height)))); + image.Mutate(ctx => ctx.Swizzle(new InvertXAndYSwizzler(new(image.Width, image.Height)))); image.DebugSave( provider, @@ -43,7 +42,7 @@ public void InvertXAndYSwizzle(TestImageProvider provider) appendPixelTypeToFileName: false, appendSourceFileOrDescription: true); - image.Mutate(ctx => ctx.Swizzle(new InvertXAndYSwizzler(new Size(image.Width, image.Height)))); + image.Mutate(ctx => ctx.Swizzle(new InvertXAndYSwizzler(new(image.Width, image.Height)))); image.DebugSave( provider, diff --git a/tests/ImageSharp.Tests/Processing/Transforms/AffineTransformBuilderTests.cs b/tests/ImageSharp.Tests/Processing/Transforms/AffineTransformBuilderTests.cs index 4b1ca92dd6..232571d4d0 100644 --- a/tests/ImageSharp.Tests/Processing/Transforms/AffineTransformBuilderTests.cs +++ b/tests/ImageSharp.Tests/Processing/Transforms/AffineTransformBuilderTests.cs @@ -8,8 +8,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Transforms; public class AffineTransformBuilderTests : TransformBuilderTestBase { - protected override AffineTransformBuilder CreateBuilder() - => new AffineTransformBuilder(); + protected override AffineTransformBuilder CreateBuilder() => new(); protected override void AppendRotationDegrees(AffineTransformBuilder builder, float degrees) => builder.AppendRotationDegrees(degrees); diff --git a/tests/ImageSharp.Tests/Processing/Transforms/CropTest.cs b/tests/ImageSharp.Tests/Processing/Transforms/CropTest.cs index 30c89ec339..6e35fca290 100644 --- a/tests/ImageSharp.Tests/Processing/Transforms/CropTest.cs +++ b/tests/ImageSharp.Tests/Processing/Transforms/CropTest.cs @@ -17,7 +17,7 @@ public void CropWidthHeightCropProcessorWithRectangleSet(int width, int height) this.operations.Crop(width, height); CropProcessor processor = this.Verify(); - Assert.Equal(new Rectangle(0, 0, width, height), processor.CropRectangle); + Assert.Equal(new(0, 0, width, height), processor.CropRectangle); } [Theory] @@ -25,7 +25,7 @@ public void CropWidthHeightCropProcessorWithRectangleSet(int width, int height) [InlineData(12, 123, 6, 2)] public void CropRectangleCropProcessorWithRectangleSet(int x, int y, int width, int height) { - var cropRectangle = new Rectangle(x, y, width, height); + Rectangle cropRectangle = new(x, y, width, height); this.operations.Crop(cropRectangle); CropProcessor processor = this.Verify(); @@ -35,7 +35,7 @@ public void CropRectangleCropProcessorWithRectangleSet(int x, int y, int width, [Fact] public void CropRectangleWithInvalidBoundsThrowsException() { - var cropRectangle = Rectangle.Inflate(this.SourceBounds(), 5, 5); + Rectangle cropRectangle = Rectangle.Inflate(this.SourceBounds(), 5, 5); Assert.Throws(() => this.operations.Crop(cropRectangle)); } } diff --git a/tests/ImageSharp.Tests/Processing/Transforms/ProjectiveTransformBuilderTests.cs b/tests/ImageSharp.Tests/Processing/Transforms/ProjectiveTransformBuilderTests.cs index 7d0c0dc58f..a0380033fd 100644 --- a/tests/ImageSharp.Tests/Processing/Transforms/ProjectiveTransformBuilderTests.cs +++ b/tests/ImageSharp.Tests/Processing/Transforms/ProjectiveTransformBuilderTests.cs @@ -9,8 +9,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Transforms; [Trait("Category", "Processors")] public class ProjectiveTransformBuilderTests : TransformBuilderTestBase { - protected override ProjectiveTransformBuilder CreateBuilder() - => new ProjectiveTransformBuilder(); + protected override ProjectiveTransformBuilder CreateBuilder() => new(); protected override void AppendRotationDegrees(ProjectiveTransformBuilder builder, float degrees) => builder.AppendRotationDegrees(degrees); diff --git a/tests/ImageSharp.Tests/Processing/Transforms/ProjectiveTransformTests.cs b/tests/ImageSharp.Tests/Processing/Transforms/ProjectiveTransformTests.cs index 38ac9c18c6..8ba6782879 100644 --- a/tests/ImageSharp.Tests/Processing/Transforms/ProjectiveTransformTests.cs +++ b/tests/ImageSharp.Tests/Processing/Transforms/ProjectiveTransformTests.cs @@ -20,7 +20,7 @@ public class ProjectiveTransformTests private ITestOutputHelper Output { get; } - public static readonly TheoryData ResamplerNames = new TheoryData + public static readonly TheoryData ResamplerNames = new() { nameof(KnownResamplers.Bicubic), nameof(KnownResamplers.Box), @@ -39,7 +39,7 @@ public class ProjectiveTransformTests nameof(KnownResamplers.Welch), }; - public static readonly TheoryData TaperMatrixData = new TheoryData + public static readonly TheoryData TaperMatrixData = new() { { TaperSide.Bottom, TaperCorner.Both }, { TaperSide.Bottom, TaperCorner.LeftOrTop }, @@ -148,8 +148,8 @@ public void PerspectiveTransformMatchesCSS(TestImageProvider pro [Fact] public void Issue1911() { - using var image = new Image(100, 100); - image.Mutate(x => x = x.Transform(new Rectangle(0, 0, 99, 100), Matrix4x4.Identity, new Size(99, 100), KnownResamplers.Lanczos2)); + using Image image = new(100, 100); + image.Mutate(x => x = x.Transform(new(0, 0, 99, 100), Matrix4x4.Identity, new(99, 100), KnownResamplers.Lanczos2)); Assert.Equal(99, image.Width); Assert.Equal(100, image.Height); @@ -164,7 +164,7 @@ public void Identity(TestImageProvider provider) Matrix4x4 m = Matrix4x4.Identity; Rectangle r = new(25, 25, 50, 50); - image.Mutate(x => x.Transform(r, m, new Size(100, 100), KnownResamplers.Bicubic)); + image.Mutate(x => x.Transform(r, m, new(100, 100), KnownResamplers.Bicubic)); image.DebugSave(provider); image.CompareToReferenceOutput(ValidatorComparer, provider); } @@ -178,9 +178,9 @@ public void Transform_With_Custom_Dimensions(TestImageProvider p { using Image image = provider.GetImage(); - Matrix4x4 m = Matrix4x4.CreateRotationX(radians, new Vector3(50, 50, 1F)) * Matrix4x4.CreateRotationY(radians, new Vector3(50, 50, 1F)); + Matrix4x4 m = Matrix4x4.CreateRotationX(radians, new(50, 50, 1F)) * Matrix4x4.CreateRotationY(radians, new(50, 50, 1F)); Rectangle r = new(25, 25, 50, 50); - image.Mutate(x => x.Transform(r, m, new Size(100, 100), KnownResamplers.Bicubic)); + image.Mutate(x => x.Transform(r, m, new(100, 100), KnownResamplers.Bicubic)); image.DebugSave(provider, testOutputDetails: radians); image.CompareToReferenceOutput(ValidatorComparer, provider, testOutputDetails: radians); } @@ -220,7 +220,7 @@ private static IResampler GetResampler(string name) if (property is null) { - throw new Exception($"No resampler named {name}"); + throw new($"No resampler named {name}"); } return (IResampler)property.GetValue(null); diff --git a/tests/ImageSharp.Tests/Processing/Transforms/ResizeTests.cs b/tests/ImageSharp.Tests/Processing/Transforms/ResizeTests.cs index f6c93ffd0e..d38658bbdb 100644 --- a/tests/ImageSharp.Tests/Processing/Transforms/ResizeTests.cs +++ b/tests/ImageSharp.Tests/Processing/Transforms/ResizeTests.cs @@ -64,9 +64,9 @@ public void ResizeWithOptions() bool compand = true; ResizeMode mode = ResizeMode.Stretch; - var resizeOptions = new ResizeOptions + ResizeOptions resizeOptions = new() { - Size = new Size(width, height), + Size = new(width, height), Sampler = sampler, Compand = compand, Mode = mode @@ -93,7 +93,7 @@ public void HwIntrinsics_Resize() { static void RunTest() { - using var image = new Image(50, 50); + using Image image = new(50, 50); image.Mutate(img => img.Resize(25, 25)); Assert.Equal(25, image.Width); diff --git a/tests/ImageSharp.Tests/Processing/Transforms/SwizzleTests.cs b/tests/ImageSharp.Tests/Processing/Transforms/SwizzleTests.cs index 432bb5cacb..a4f4f152bb 100644 --- a/tests/ImageSharp.Tests/Processing/Transforms/SwizzleTests.cs +++ b/tests/ImageSharp.Tests/Processing/Transforms/SwizzleTests.cs @@ -13,13 +13,12 @@ private struct InvertXAndYSwizzler : ISwizzler { public InvertXAndYSwizzler(Size sourceSize) { - this.DestinationSize = new Size(sourceSize.Height, sourceSize.Width); + this.DestinationSize = new(sourceSize.Height, sourceSize.Width); } public Size DestinationSize { get; } - public Point Transform(Point point) - => new Point(point.Y, point.X); + public Point Transform(Point point) => new(point.Y, point.X); } [Fact] @@ -28,7 +27,7 @@ public void InvertXAndYSwizzlerSetsCorrectSizes() int width = 5; int height = 10; - this.operations.Swizzle(new InvertXAndYSwizzler(new Size(width, height))); + this.operations.Swizzle(new InvertXAndYSwizzler(new(width, height))); SwizzleProcessor processor = this.Verify>(); Assert.Equal(processor.Swizzler.DestinationSize.Width, height); diff --git a/tests/ImageSharp.Tests/Processing/Transforms/TransformBuilderTestBase.cs b/tests/ImageSharp.Tests/Processing/Transforms/TransformBuilderTestBase.cs index f046c2503c..cdc49e2a3f 100644 --- a/tests/ImageSharp.Tests/Processing/Transforms/TransformBuilderTestBase.cs +++ b/tests/ImageSharp.Tests/Processing/Transforms/TransformBuilderTestBase.cs @@ -10,16 +10,16 @@ namespace SixLabors.ImageSharp.Tests.Processing.Transforms; [Trait("Category", "Processors")] public abstract class TransformBuilderTestBase { - private static readonly ApproximateFloatComparer Comparer = new ApproximateFloatComparer(1e-6f); + private static readonly ApproximateFloatComparer Comparer = new(1e-6f); public static readonly TheoryData ScaleTranslate_Data = - new TheoryData - { + new() + { // scale, translate, source, expectedDest { Vector2.One, Vector2.Zero, Vector2.Zero, Vector2.Zero }, - { Vector2.One, Vector2.Zero, new Vector2(10, 20), new Vector2(10, 20) }, - { Vector2.One, new Vector2(3, 1), new Vector2(10, 20), new Vector2(13, 21) }, - { new Vector2(2, 0.5f), new Vector2(3, 1), new Vector2(10, 20), new Vector2(23, 11) }, + { Vector2.One, Vector2.Zero, new(10, 20), new(10, 20) }, + { Vector2.One, new(3, 1), new(10, 20), new(13, 21) }, + { new(2, 0.5f), new(3, 1), new(10, 20), new(23, 11) }, }; [Theory] @@ -29,23 +29,23 @@ public void _1Scale_2Translate(Vector2 scale, Vector2 translate, Vector2 source, #pragma warning restore SA1300 // Element should begin with upper-case letter { // These operations should be size-agnostic: - var size = new Size(123, 321); + Size size = new(123, 321); TBuilder builder = this.CreateBuilder(); - this.AppendScale(builder, new SizeF(scale)); + this.AppendScale(builder, new(scale)); this.AppendTranslation(builder, translate); - Vector2 actualDest = this.Execute(builder, new Rectangle(Point.Empty, size), source); + Vector2 actualDest = this.Execute(builder, new(Point.Empty, size), source); Assert.True(Comparer.Equals(expectedDest, actualDest)); } public static readonly TheoryData TranslateScale_Data = - new TheoryData - { + new() + { // translate, scale, source, expectedDest { Vector2.Zero, Vector2.One, Vector2.Zero, Vector2.Zero }, - { Vector2.Zero, Vector2.One, new Vector2(10, 20), new Vector2(10, 20) }, - { new Vector2(3, 1), new Vector2(2, 0.5f), new Vector2(10, 20), new Vector2(26, 10.5f) }, + { Vector2.Zero, Vector2.One, new(10, 20), new(10, 20) }, + { new(3, 1), new(2, 0.5f), new(10, 20), new(26, 10.5f) }, }; [Theory] @@ -55,13 +55,13 @@ public void _1Translate_2Scale(Vector2 translate, Vector2 scale, Vector2 source, #pragma warning restore SA1300 // Element should begin with upper-case letter { // Translate ans scale are size-agnostic: - var size = new Size(456, 432); + Size size = new(456, 432); TBuilder builder = this.CreateBuilder(); this.AppendTranslation(builder, translate); - this.AppendScale(builder, new SizeF(scale)); + this.AppendScale(builder, new(scale)); - Vector2 actualDest = this.Execute(builder, new Rectangle(Point.Empty, size), source); + Vector2 actualDest = this.Execute(builder, new(Point.Empty, size), source); Assert.Equal(expectedDest, actualDest, Comparer); } @@ -70,10 +70,10 @@ public void _1Translate_2Scale(Vector2 translate, Vector2 scale, Vector2 source, [InlineData(-20, 10)] public void LocationOffsetIsPrepended(int locationX, int locationY) { - var rectangle = new Rectangle(locationX, locationY, 10, 10); + Rectangle rectangle = new(locationX, locationY, 10, 10); TBuilder builder = this.CreateBuilder(); - this.AppendScale(builder, new SizeF(2, 2)); + this.AppendScale(builder, new(2, 2)); Vector2 actual = this.Execute(builder, rectangle, Vector2.One); Vector2 expected = new Vector2(-locationX + 1, -locationY + 1) * 2; @@ -92,7 +92,7 @@ public void AppendRotationDegrees_WithoutSpecificRotationCenter_RotationIsCenter float x, float y) { - var size = new Size(width, height); + Size size = new(width, height); TBuilder builder = this.CreateBuilder(); this.AppendRotationDegrees(builder, degrees); @@ -100,9 +100,9 @@ public void AppendRotationDegrees_WithoutSpecificRotationCenter_RotationIsCenter // TODO: We should also test CreateRotationMatrixDegrees() (and all TransformUtils stuff!) for correctness Matrix3x2 matrix = TransformUtils.CreateRotationTransformMatrixDegrees(degrees, size, TransformSpace.Pixel); - var position = new Vector2(x, y); - var expected = Vector2.Transform(position, matrix); - Vector2 actual = this.Execute(builder, new Rectangle(Point.Empty, size), position); + Vector2 position = new(x, y); + Vector2 expected = Vector2.Transform(position, matrix); + Vector2 actual = this.Execute(builder, new(Point.Empty, size), position); Assert.Equal(actual, expected, Comparer); } @@ -120,17 +120,17 @@ public void AppendRotationDegrees_WithRotationCenter( float x, float y) { - var size = new Size(width, height); + Size size = new(width, height); TBuilder builder = this.CreateBuilder(); - var centerPoint = new Vector2(cx, cy); + Vector2 centerPoint = new(cx, cy); this.AppendRotationDegrees(builder, degrees, centerPoint); - var matrix = Matrix3x2.CreateRotation(GeometryUtilities.DegreeToRadian(degrees), centerPoint); + Matrix3x2 matrix = Matrix3x2.CreateRotation(GeometryUtilities.DegreeToRadian(degrees), centerPoint); - var position = new Vector2(x, y); - var expected = Vector2.Transform(position, matrix); - Vector2 actual = this.Execute(builder, new Rectangle(Point.Empty, size), position); + Vector2 position = new(x, y); + Vector2 expected = Vector2.Transform(position, matrix); + Vector2 actual = this.Execute(builder, new(Point.Empty, size), position); Assert.Equal(actual, expected, Comparer); } @@ -147,16 +147,16 @@ public void AppendSkewDegrees_WithoutSpecificSkewCenter_SkewIsCenteredAroundImag float x, float y) { - var size = new Size(width, height); + Size size = new(width, height); TBuilder builder = this.CreateBuilder(); this.AppendSkewDegrees(builder, degreesX, degreesY); Matrix3x2 matrix = TransformUtils.CreateSkewTransformMatrixDegrees(degreesX, degreesY, size, TransformSpace.Pixel); - var position = new Vector2(x, y); - var expected = Vector2.Transform(position, matrix); - Vector2 actual = this.Execute(builder, new Rectangle(Point.Empty, size), position); + Vector2 position = new(x, y); + Vector2 expected = Vector2.Transform(position, matrix); + Vector2 actual = this.Execute(builder, new(Point.Empty, size), position); Assert.Equal(actual, expected, Comparer); } @@ -174,17 +174,17 @@ public void AppendSkewDegrees_WithSkewCenter( float x, float y) { - var size = new Size(width, height); + Size size = new(width, height); TBuilder builder = this.CreateBuilder(); - var centerPoint = new Vector2(cx, cy); + Vector2 centerPoint = new(cx, cy); this.AppendSkewDegrees(builder, degreesX, degreesY, centerPoint); - var matrix = Matrix3x2.CreateSkew(GeometryUtilities.DegreeToRadian(degreesX), GeometryUtilities.DegreeToRadian(degreesY), centerPoint); + Matrix3x2 matrix = Matrix3x2.CreateSkew(GeometryUtilities.DegreeToRadian(degreesX), GeometryUtilities.DegreeToRadian(degreesY), centerPoint); - var position = new Vector2(x, y); - var expected = Vector2.Transform(position, matrix); - Vector2 actual = this.Execute(builder, new Rectangle(Point.Empty, size), position); + Vector2 position = new(x, y); + Vector2 expected = Vector2.Transform(position, matrix); + Vector2 actual = this.Execute(builder, new(Point.Empty, size), position); Assert.Equal(actual, expected, Comparer); } @@ -192,7 +192,7 @@ public void AppendSkewDegrees_WithSkewCenter( [Fact] public void AppendPrependOpposite() { - var rectangle = new Rectangle(-1, -1, 3, 3); + Rectangle rectangle = new(-1, -1, 3, 3); TBuilder b1 = this.CreateBuilder(); TBuilder b2 = this.CreateBuilder(); @@ -201,21 +201,21 @@ public void AppendPrependOpposite() // Forwards this.AppendRotationRadians(b1, pi); this.AppendSkewRadians(b1, pi, pi); - this.AppendScale(b1, new SizeF(2, 0.5f)); - this.AppendRotationRadians(b1, pi / 2, new Vector2(-0.5f, -0.1f)); - this.AppendSkewRadians(b1, pi, pi / 2, new Vector2(-0.5f, -0.1f)); - this.AppendTranslation(b1, new PointF(123, 321)); + this.AppendScale(b1, new(2, 0.5f)); + this.AppendRotationRadians(b1, pi / 2, new(-0.5f, -0.1f)); + this.AppendSkewRadians(b1, pi, pi / 2, new(-0.5f, -0.1f)); + this.AppendTranslation(b1, new(123, 321)); // Backwards - this.PrependTranslation(b2, new PointF(123, 321)); - this.PrependSkewRadians(b2, pi, pi / 2, new Vector2(-0.5f, -0.1f)); - this.PrependRotationRadians(b2, pi / 2, new Vector2(-0.5f, -0.1f)); - this.PrependScale(b2, new SizeF(2, 0.5f)); + this.PrependTranslation(b2, new(123, 321)); + this.PrependSkewRadians(b2, pi, pi / 2, new(-0.5f, -0.1f)); + this.PrependRotationRadians(b2, pi / 2, new(-0.5f, -0.1f)); + this.PrependScale(b2, new(2, 0.5f)); this.PrependSkewRadians(b2, pi, pi); this.PrependRotationRadians(b2, pi); - Vector2 p1 = this.Execute(b1, rectangle, new Vector2(32, 65)); - Vector2 p2 = this.Execute(b2, rectangle, new Vector2(32, 65)); + Vector2 p1 = this.Execute(b1, rectangle, new(32, 65)); + Vector2 p2 = this.Execute(b2, rectangle, new(32, 65)); Assert.Equal(p1, p2, Comparer); } @@ -226,13 +226,13 @@ public void AppendPrependOpposite() [InlineData(-1, 0)] public void ThrowsForInvalidSizes(int width, int height) { - var size = new Size(width, height); + Size size = new(width, height); Assert.ThrowsAny( () => { TBuilder builder = this.CreateBuilder(); - this.Execute(builder, new Rectangle(Point.Empty, size), Vector2.Zero); + this.Execute(builder, new(Point.Empty, size), Vector2.Zero); }); } @@ -244,7 +244,7 @@ public void ThrowsForInvalidMatrix() { TBuilder builder = this.CreateBuilder(); this.AppendSkewDegrees(builder, 45, 45); - this.Execute(builder, new Rectangle(0, 0, 150, 150), Vector2.Zero); + this.Execute(builder, new(0, 0, 150, 150), Vector2.Zero); }); } diff --git a/tests/ImageSharp.Tests/ProfilingBenchmarks/LoadResizeSaveProfilingBenchmarks.cs b/tests/ImageSharp.Tests/ProfilingBenchmarks/LoadResizeSaveProfilingBenchmarks.cs index a1d7e358b6..209dd361ec 100644 --- a/tests/ImageSharp.Tests/ProfilingBenchmarks/LoadResizeSaveProfilingBenchmarks.cs +++ b/tests/ImageSharp.Tests/ProfilingBenchmarks/LoadResizeSaveProfilingBenchmarks.cs @@ -18,7 +18,7 @@ public LoadResizeSaveProfilingBenchmarks(ITestOutputHelper output) [InlineData(TestImages.Jpeg.Baseline.Jpeg420Exif)] public void LoadResizeSave(string imagePath) { - var configuration = Configuration.CreateDefaultInstance(); + Configuration configuration = Configuration.CreateDefaultInstance(); configuration.MaxDegreeOfParallelism = 1; DecoderOptions options = new() @@ -28,12 +28,12 @@ public void LoadResizeSave(string imagePath) byte[] imageBytes = TestFile.Create(imagePath).Bytes; - using var ms = new MemoryStream(); + using MemoryStream ms = new(); this.Measure( 30, () => { - using (var image = Image.Load(options, imageBytes)) + using (Image image = Image.Load(options, imageBytes)) { image.Mutate(x => x.Resize(image.Size / 4)); image.SaveAsJpeg(ms); diff --git a/tests/ImageSharp.Tests/ProfilingBenchmarks/ResizeProfilingBenchmarks.cs b/tests/ImageSharp.Tests/ProfilingBenchmarks/ResizeProfilingBenchmarks.cs index f20ca8ce18..bab11b0f9d 100644 --- a/tests/ImageSharp.Tests/ProfilingBenchmarks/ResizeProfilingBenchmarks.cs +++ b/tests/ImageSharp.Tests/ProfilingBenchmarks/ResizeProfilingBenchmarks.cs @@ -28,7 +28,7 @@ public void ResizeBicubic(int width, int height) this.ExecutionCount, () => { - using (var image = new Image(this.configuration, width, height)) + using (Image image = new(this.configuration, width, height)) { image.Mutate(x => x.Resize(width / 5, height / 5)); } diff --git a/tests/ImageSharp.Tests/Quantization/QuantizedImageTests.cs b/tests/ImageSharp.Tests/Quantization/QuantizedImageTests.cs index 59a0ad4274..812f822f62 100644 --- a/tests/ImageSharp.Tests/Quantization/QuantizedImageTests.cs +++ b/tests/ImageSharp.Tests/Quantization/QuantizedImageTests.cs @@ -13,10 +13,10 @@ public class QuantizedImageTests [Fact] public void QuantizersDitherByDefault() { - var werner = new WernerPaletteQuantizer(); - var webSafe = new WebSafePaletteQuantizer(); - var octree = new OctreeQuantizer(); - var wu = new WuQuantizer(); + WernerPaletteQuantizer werner = new(); + WebSafePaletteQuantizer webSafe = new(); + OctreeQuantizer octree = new(); + WuQuantizer wu = new(); Assert.NotNull(werner.Options.Dither); Assert.NotNull(webSafe.Options.Dither); @@ -56,13 +56,13 @@ public void OctreeQuantizerYieldsCorrectTransparentPixel( { Assert.True(image[0, 0].Equals(default)); - var options = new QuantizerOptions(); + QuantizerOptions options = new(); if (!dither) { options.Dither = null; } - var quantizer = new OctreeQuantizer(options); + OctreeQuantizer quantizer = new(options); foreach (ImageFrame frame in image.Frames) { @@ -86,13 +86,13 @@ public void WuQuantizerYieldsCorrectTransparentPixel(TestImageProvider frame in image.Frames) { @@ -114,8 +114,8 @@ public void Issue1505(TestImageProvider provider) { using (Image image = provider.GetImage()) { - var octreeQuantizer = new OctreeQuantizer(); - IQuantizer quantizer = octreeQuantizer.CreatePixelSpecificQuantizer(Configuration.Default, new QuantizerOptions() { MaxColors = 128 }); + OctreeQuantizer octreeQuantizer = new(); + IQuantizer quantizer = octreeQuantizer.CreatePixelSpecificQuantizer(Configuration.Default, new() { MaxColors = 128 }); ImageFrame frame = image.Frames[0]; quantizer.BuildPaletteAndQuantizeFrame(frame, frame.Bounds()); } diff --git a/tests/ImageSharp.Tests/Quantization/WuQuantizerTests.cs b/tests/ImageSharp.Tests/Quantization/WuQuantizerTests.cs index ccb79debda..725e16efca 100644 --- a/tests/ImageSharp.Tests/Quantization/WuQuantizerTests.cs +++ b/tests/ImageSharp.Tests/Quantization/WuQuantizerTests.cs @@ -12,9 +12,9 @@ public class WuQuantizerTests public void SinglePixelOpaque() { Configuration config = Configuration.Default; - var quantizer = new WuQuantizer(new QuantizerOptions { Dither = null }); + WuQuantizer quantizer = new(new() { Dither = null }); - using var image = new Image(config, 1, 1, Color.Black.ToPixel()); + using Image image = new(config, 1, 1, Color.Black.ToPixel()); ImageFrame frame = image.Frames.RootFrame; using IQuantizer frameQuantizer = quantizer.CreatePixelSpecificQuantizer(config); @@ -32,9 +32,9 @@ public void SinglePixelOpaque() public void SinglePixelTransparent() { Configuration config = Configuration.Default; - var quantizer = new WuQuantizer(new QuantizerOptions { Dither = null }); + WuQuantizer quantizer = new(new() { Dither = null }); - using var image = new Image(config, 1, 1, default(Rgba32)); + using Image image = new(config, 1, 1, default(Rgba32)); ImageFrame frame = image.Frames.RootFrame; using IQuantizer frameQuantizer = quantizer.CreatePixelSpecificQuantizer(config); @@ -49,24 +49,24 @@ public void SinglePixelTransparent() } [Fact] - public void GrayScale() => TestScale(c => new Rgba32(c, c, c, 128)); + public void GrayScale() => TestScale(c => new(c, c, c, 128)); [Fact] - public void RedScale() => TestScale(c => new Rgba32(c, 0, 0, 128)); + public void RedScale() => TestScale(c => new(c, 0, 0, 128)); [Fact] - public void GreenScale() => TestScale(c => new Rgba32(0, c, 0, 128)); + public void GreenScale() => TestScale(c => new(0, c, 0, 128)); [Fact] - public void BlueScale() => TestScale(c => new Rgba32(0, 0, c, 128)); + public void BlueScale() => TestScale(c => new(0, 0, c, 128)); [Fact] - public void AlphaScale() => TestScale(c => new Rgba32(0, 0, 0, c)); + public void AlphaScale() => TestScale(c => new(0, 0, 0, c)); [Fact] public void Palette256() { - using var image = new Image(1, 256); + using Image image = new(1, 256); for (int i = 0; i < 256; i++) { @@ -75,11 +75,11 @@ public void Palette256() byte b = (byte)(((i / 16) % 4) * 85); byte a = (byte)((i / 64) * 85); - image[0, i] = new Rgba32(r, g, b, a); + image[0, i] = new(r, g, b, a); } Configuration config = Configuration.Default; - var quantizer = new WuQuantizer(new QuantizerOptions { Dither = null }); + WuQuantizer quantizer = new(new() { Dither = null }); ImageFrame frame = image.Frames.RootFrame; @@ -90,7 +90,7 @@ public void Palette256() Assert.Equal(1, result.Width); Assert.Equal(256, result.Height); - using var actualImage = new Image(1, 256); + using Image actualImage = new(1, 256); actualImage.ProcessPixelRows(accessor => { @@ -126,7 +126,7 @@ public void LowVariance(TestImageProvider provider) using (Image image = provider.GetImage()) { Configuration config = Configuration.Default; - var quantizer = new WuQuantizer(new QuantizerOptions { Dither = null }); + WuQuantizer quantizer = new(new() { Dither = null }); ImageFrame frame = image.Frames.RootFrame; using IQuantizer frameQuantizer = quantizer.CreatePixelSpecificQuantizer(config); @@ -138,9 +138,9 @@ public void LowVariance(TestImageProvider provider) private static void TestScale(Func pixelBuilder) { - using (var image = new Image(1, 256)) - using (var expectedImage = new Image(1, 256)) - using (var actualImage = new Image(1, 256)) + using (Image image = new(1, 256)) + using (Image expectedImage = new(1, 256)) + using (Image actualImage = new(1, 256)) { for (int i = 0; i < 256; i++) { @@ -155,7 +155,7 @@ private static void TestScale(Func pixelBuilder) } Configuration config = Configuration.Default; - var quantizer = new WuQuantizer(new QuantizerOptions { Dither = null }); + WuQuantizer quantizer = new(new() { Dither = null }); ImageFrame frame = image.Frames.RootFrame; using (IQuantizer frameQuantizer = quantizer.CreatePixelSpecificQuantizer(config)) diff --git a/tests/ImageSharp.Tests/TestDataIcc/IccTestDataArray.cs b/tests/ImageSharp.Tests/TestDataIcc/IccTestDataArray.cs index 8288a294dd..40483b79b7 100644 --- a/tests/ImageSharp.Tests/TestDataIcc/IccTestDataArray.cs +++ b/tests/ImageSharp.Tests/TestDataIcc/IccTestDataArray.cs @@ -5,14 +5,14 @@ namespace SixLabors.ImageSharp.Tests; internal static class IccTestDataArray { - public static readonly byte[] UInt8 = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }; + public static readonly byte[] UInt8 = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]; public static readonly object[][] UInt8TestData = - { - new object[] { UInt8, UInt8 } - }; + [ + [UInt8, UInt8] + ]; - public static readonly ushort[] UInt16_Val = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }; + public static readonly ushort[] UInt16_Val = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]; public static readonly byte[] UInt16_Arr = ArrayHelper.Concat( IccTestDataPrimitives.UInt16_0, @@ -27,11 +27,11 @@ internal static class IccTestDataArray IccTestDataPrimitives.UInt16_9); public static readonly object[][] UInt16TestData = - { - new object[] { UInt16_Arr, UInt16_Val } - }; + [ + [UInt16_Arr, UInt16_Val] + ]; - public static readonly short[] Int16_Val = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }; + public static readonly short[] Int16_Val = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]; public static readonly byte[] Int16_Arr = ArrayHelper.Concat( IccTestDataPrimitives.Int16_0, @@ -46,11 +46,11 @@ internal static class IccTestDataArray IccTestDataPrimitives.Int16_9); public static readonly object[][] Int16TestData = - { - new object[] { Int16_Arr, Int16_Val } - }; + [ + [Int16_Arr, Int16_Val] + ]; - public static readonly uint[] UInt32_Val = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }; + public static readonly uint[] UInt32_Val = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]; public static readonly byte[] UInt32_Arr = ArrayHelper.Concat( IccTestDataPrimitives.UInt32_0, @@ -65,11 +65,11 @@ internal static class IccTestDataArray IccTestDataPrimitives.UInt32_9); public static readonly object[][] UInt32TestData = - { - new object[] { UInt32_Arr, UInt32_Val } - }; + [ + [UInt32_Arr, UInt32_Val] + ]; - public static readonly int[] Int32_Val = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }; + public static readonly int[] Int32_Val = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]; public static readonly byte[] Int32_Arr = ArrayHelper.Concat( IccTestDataPrimitives.Int32_0, @@ -84,11 +84,11 @@ internal static class IccTestDataArray IccTestDataPrimitives.Int32_9); public static readonly object[][] Int32TestData = - { - new object[] { Int32_Arr, Int32_Val } - }; + [ + [Int32_Arr, Int32_Val] + ]; - public static readonly ulong[] UInt64_Val = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }; + public static readonly ulong[] UInt64_Val = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]; public static readonly byte[] UInt64_Arr = ArrayHelper.Concat( IccTestDataPrimitives.UInt64_0, @@ -103,7 +103,7 @@ internal static class IccTestDataArray IccTestDataPrimitives.UInt64_9); public static readonly object[][] UInt64TestData = - { - new object[] { UInt64_Arr, UInt64_Val } - }; + [ + [UInt64_Arr, UInt64_Val] + ]; } diff --git a/tests/ImageSharp.Tests/TestDataIcc/IccTestDataCurves.cs b/tests/ImageSharp.Tests/TestDataIcc/IccTestDataCurves.cs index f76d2ba036..df0e1859a1 100644 --- a/tests/ImageSharp.Tests/TestDataIcc/IccTestDataCurves.cs +++ b/tests/ImageSharp.Tests/TestDataIcc/IccTestDataCurves.cs @@ -10,19 +10,18 @@ internal static class IccTestDataCurves /// /// Channels: 3 /// - public static readonly IccResponseCurve Response_ValGrad = new IccResponseCurve( + public static readonly IccResponseCurve Response_ValGrad = new( IccCurveMeasurementEncodings.StatusA, - new[] - { + [ IccTestDataNonPrimitives.XyzNumber_ValVar1, IccTestDataNonPrimitives.XyzNumber_ValVar2, IccTestDataNonPrimitives.XyzNumber_ValVar3 - }, + ], new IccResponseNumber[][] { - new IccResponseNumber[] { IccTestDataNonPrimitives.ResponseNumber_Val1, IccTestDataNonPrimitives.ResponseNumber_Val2 }, - new IccResponseNumber[] { IccTestDataNonPrimitives.ResponseNumber_Val3, IccTestDataNonPrimitives.ResponseNumber_Val4 }, - new IccResponseNumber[] { IccTestDataNonPrimitives.ResponseNumber_Val5, IccTestDataNonPrimitives.ResponseNumber_Val6 }, + [IccTestDataNonPrimitives.ResponseNumber_Val1, IccTestDataNonPrimitives.ResponseNumber_Val2], + [IccTestDataNonPrimitives.ResponseNumber_Val3, IccTestDataNonPrimitives.ResponseNumber_Val4], + [IccTestDataNonPrimitives.ResponseNumber_Val5, IccTestDataNonPrimitives.ResponseNumber_Val6], }); /// @@ -44,15 +43,15 @@ internal static class IccTestDataCurves IccTestDataNonPrimitives.ResponseNumber_6); public static readonly object[][] ResponseCurveTestData = - { - new object[] { Response_Grad, Response_ValGrad, 3 }, - }; + [ + [Response_Grad, Response_ValGrad, 3] + ]; - public static readonly IccParametricCurve Parametric_ValVar1 = new IccParametricCurve(1); - public static readonly IccParametricCurve Parametric_ValVar2 = new IccParametricCurve(1, 2, 3); - public static readonly IccParametricCurve Parametric_ValVar3 = new IccParametricCurve(1, 2, 3, 4); - public static readonly IccParametricCurve Parametric_ValVar4 = new IccParametricCurve(1, 2, 3, 4, 5); - public static readonly IccParametricCurve Parametric_ValVar5 = new IccParametricCurve(1, 2, 3, 4, 5, 6, 7); + public static readonly IccParametricCurve Parametric_ValVar1 = new(1); + public static readonly IccParametricCurve Parametric_ValVar2 = new(1, 2, 3); + public static readonly IccParametricCurve Parametric_ValVar3 = new(1, 2, 3, 4); + public static readonly IccParametricCurve Parametric_ValVar4 = new(1, 2, 3, 4, 5); + public static readonly IccParametricCurve Parametric_ValVar5 = new(1, 2, 3, 4, 5, 6, 7); public static readonly byte[] Parametric_Var1 = ArrayHelper.Concat( new byte[] @@ -110,18 +109,18 @@ internal static class IccTestDataCurves IccTestDataPrimitives.Fix16_7); public static readonly object[][] ParametricCurveTestData = - { - new object[] { Parametric_Var1, Parametric_ValVar1 }, - new object[] { Parametric_Var2, Parametric_ValVar2 }, - new object[] { Parametric_Var3, Parametric_ValVar3 }, - new object[] { Parametric_Var4, Parametric_ValVar4 }, - new object[] { Parametric_Var5, Parametric_ValVar5 }, - }; + [ + [Parametric_Var1, Parametric_ValVar1], + [Parametric_Var2, Parametric_ValVar2], + [Parametric_Var3, Parametric_ValVar3], + [Parametric_Var4, Parametric_ValVar4], + [Parametric_Var5, Parametric_ValVar5] + ]; // Formula Segment - public static readonly IccFormulaCurveElement Formula_ValVar1 = new IccFormulaCurveElement(IccFormulaCurveType.Type1, 1, 2, 3, 4, 0, 0); - public static readonly IccFormulaCurveElement Formula_ValVar2 = new IccFormulaCurveElement(IccFormulaCurveType.Type2, 1, 2, 3, 4, 5, 0); - public static readonly IccFormulaCurveElement Formula_ValVar3 = new IccFormulaCurveElement(IccFormulaCurveType.Type3, 0, 2, 3, 4, 5, 6); + public static readonly IccFormulaCurveElement Formula_ValVar1 = new(IccFormulaCurveType.Type1, 1, 2, 3, 4, 0, 0); + public static readonly IccFormulaCurveElement Formula_ValVar2 = new(IccFormulaCurveType.Type2, 1, 2, 3, 4, 5, 0); + public static readonly IccFormulaCurveElement Formula_ValVar3 = new(IccFormulaCurveType.Type3, 0, 2, 3, 4, 5, 6); public static readonly byte[] Formula_Var1 = ArrayHelper.Concat( new byte[] @@ -159,15 +158,15 @@ internal static class IccTestDataCurves IccTestDataPrimitives.Single_6); public static readonly object[][] FormulaCurveSegmentTestData = - { - new object[] { Formula_Var1, Formula_ValVar1 }, - new object[] { Formula_Var2, Formula_ValVar2 }, - new object[] { Formula_Var3, Formula_ValVar3 }, - }; + [ + [Formula_Var1, Formula_ValVar1], + [Formula_Var2, Formula_ValVar2], + [Formula_Var3, Formula_ValVar3] + ]; // Sampled Segment - public static readonly IccSampledCurveElement Sampled_ValGrad1 = new IccSampledCurveElement(new float[] { 1, 2, 3, 4, 5, 6, 7, 8, 9 }); - public static readonly IccSampledCurveElement Sampled_ValGrad2 = new IccSampledCurveElement(new float[] { 9, 8, 7, 6, 5, 4, 3, 2, 1 }); + public static readonly IccSampledCurveElement Sampled_ValGrad1 = new([1, 2, 3, 4, 5, 6, 7, 8, 9]); + public static readonly IccSampledCurveElement Sampled_ValGrad2 = new([9, 8, 7, 6, 5, 4, 3, 2, 1]); public static readonly byte[] Sampled_Grad1 = ArrayHelper.Concat( IccTestDataPrimitives.UInt32_9, @@ -194,10 +193,10 @@ internal static class IccTestDataCurves IccTestDataPrimitives.Single_1); public static readonly object[][] SampledCurveSegmentTestData = - { - new object[] { Sampled_Grad1, Sampled_ValGrad1 }, - new object[] { Sampled_Grad2, Sampled_ValGrad2 }, - }; + [ + [Sampled_Grad1, Sampled_ValGrad1], + [Sampled_Grad2, Sampled_ValGrad2] + ]; public static readonly IccCurveSegment Segment_ValFormula1 = Formula_ValVar1; public static readonly IccCurveSegment Segment_ValFormula2 = Formula_ValVar2; @@ -246,25 +245,25 @@ internal static class IccTestDataCurves Sampled_Grad2); public static readonly object[][] CurveSegmentTestData = - { - new object[] { Segment_Formula1, Segment_ValFormula1 }, - new object[] { Segment_Formula2, Segment_ValFormula2 }, - new object[] { Segment_Formula3, Segment_ValFormula3 }, - new object[] { Segment_Sampled1, Segment_ValSampled1 }, - new object[] { Segment_Sampled2, Segment_ValSampled2 }, - }; - - public static readonly IccOneDimensionalCurve OneDimensional_ValFormula1 = new IccOneDimensionalCurve( - new float[] { 0, 1 }, - new IccCurveSegment[] { Segment_ValFormula1, Segment_ValFormula2, Segment_ValFormula3 }); - - public static readonly IccOneDimensionalCurve OneDimensional_ValFormula2 = new IccOneDimensionalCurve( - new float[] { 0, 1 }, - new IccCurveSegment[] { Segment_ValFormula3, Segment_ValFormula2, Segment_ValFormula1 }); - - public static readonly IccOneDimensionalCurve OneDimensional_ValSampled = new IccOneDimensionalCurve( - new float[] { 0, 1 }, - new IccCurveSegment[] { Segment_ValSampled1, Segment_ValSampled2, Segment_ValSampled1 }); + [ + [Segment_Formula1, Segment_ValFormula1], + [Segment_Formula2, Segment_ValFormula2], + [Segment_Formula3, Segment_ValFormula3], + [Segment_Sampled1, Segment_ValSampled1], + [Segment_Sampled2, Segment_ValSampled2] + ]; + + public static readonly IccOneDimensionalCurve OneDimensional_ValFormula1 = new( + [0, 1], + [Segment_ValFormula1, Segment_ValFormula2, Segment_ValFormula3]); + + public static readonly IccOneDimensionalCurve OneDimensional_ValFormula2 = new( + [0, 1], + [Segment_ValFormula3, Segment_ValFormula2, Segment_ValFormula1]); + + public static readonly IccOneDimensionalCurve OneDimensional_ValSampled = new( + [0, 1], + [Segment_ValSampled1, Segment_ValSampled2, Segment_ValSampled1]); public static readonly byte[] OneDimensional_Formula1 = ArrayHelper.Concat( new byte[] @@ -303,9 +302,9 @@ internal static class IccTestDataCurves Segment_Sampled1); public static readonly object[][] OneDimensionalCurveTestData = - { - new object[] { OneDimensional_Formula1, OneDimensional_ValFormula1 }, - new object[] { OneDimensional_Formula2, OneDimensional_ValFormula2 }, - new object[] { OneDimensional_Sampled, OneDimensional_ValSampled }, - }; + [ + [OneDimensional_Formula1, OneDimensional_ValFormula1], + [OneDimensional_Formula2, OneDimensional_ValFormula2], + [OneDimensional_Sampled, OneDimensional_ValSampled] + ]; } diff --git a/tests/ImageSharp.Tests/TestDataIcc/IccTestDataLut.cs b/tests/ImageSharp.Tests/TestDataIcc/IccTestDataLut.cs index 7a778f269b..c43d9012ea 100644 --- a/tests/ImageSharp.Tests/TestDataIcc/IccTestDataLut.cs +++ b/tests/ImageSharp.Tests/TestDataIcc/IccTestDataLut.cs @@ -18,7 +18,7 @@ private static IccLut CreateLUT8Val() result[i] = i / 255f; } - return new IccLut(result); + return new(result); } private static byte[] CreateLUT8() @@ -33,12 +33,11 @@ private static byte[] CreateLUT8() } public static readonly object[][] Lut8TestData = - { - new object[] { LUT8_Grad, LUT8_ValGrad }, - }; + [ + [LUT8_Grad, LUT8_ValGrad] + ]; - public static readonly IccLut LUT16_ValGrad = new IccLut(new float[] - { + public static readonly IccLut LUT16_ValGrad = new([ 1f / ushort.MaxValue, 2f / ushort.MaxValue, 3f / ushort.MaxValue, @@ -50,7 +49,7 @@ private static byte[] CreateLUT8() 9f / ushort.MaxValue, 32768f / ushort.MaxValue, 1f - }); + ]); public static readonly byte[] LUT16_Grad = ArrayHelper.Concat( IccTestDataPrimitives.UInt16_1, @@ -66,26 +65,24 @@ private static byte[] CreateLUT8() IccTestDataPrimitives.UInt16_Max); public static readonly object[][] Lut16TestData = - { - new object[] { LUT16_Grad, LUT16_ValGrad, 11 }, - }; + [ + [LUT16_Grad, LUT16_ValGrad, 11] + ]; - public static readonly IccClut CLUT8_ValGrad = new IccClut( + public static readonly IccClut CLUT8_ValGrad = new( new float[][] { - new float[] { 1f / byte.MaxValue, 2f / byte.MaxValue, 3f / byte.MaxValue }, - new float[] { 4f / byte.MaxValue, 5f / byte.MaxValue, 6f / byte.MaxValue }, - new float[] { 7f / byte.MaxValue, 8f / byte.MaxValue, 9f / byte.MaxValue }, - - new float[] { 10f / byte.MaxValue, 11f / byte.MaxValue, 12f / byte.MaxValue }, - new float[] { 13f / byte.MaxValue, 14f / byte.MaxValue, 15f / byte.MaxValue }, - new float[] { 16f / byte.MaxValue, 17f / byte.MaxValue, 18f / byte.MaxValue }, - - new float[] { 19f / byte.MaxValue, 20f / byte.MaxValue, 21f / byte.MaxValue }, - new float[] { 22f / byte.MaxValue, 23f / byte.MaxValue, 24f / byte.MaxValue }, - new float[] { 25f / byte.MaxValue, 26f / byte.MaxValue, 27f / byte.MaxValue }, + [1f / byte.MaxValue, 2f / byte.MaxValue, 3f / byte.MaxValue], [4f / byte.MaxValue, 5f / byte.MaxValue, 6f / byte.MaxValue + ], + [7f / byte.MaxValue, 8f / byte.MaxValue, 9f / byte.MaxValue], [10f / byte.MaxValue, 11f / byte.MaxValue, 12f / byte.MaxValue + ], + [13f / byte.MaxValue, 14f / byte.MaxValue, 15f / byte.MaxValue], [16f / byte.MaxValue, 17f / byte.MaxValue, 18f / byte.MaxValue + ], + [19f / byte.MaxValue, 20f / byte.MaxValue, 21f / byte.MaxValue], [22f / byte.MaxValue, 23f / byte.MaxValue, 24f / byte.MaxValue + ], + [25f / byte.MaxValue, 26f / byte.MaxValue, 27f / byte.MaxValue], }, - new byte[] { 3, 3 }, + [3, 3], IccClutDataType.UInt8); /// @@ -94,7 +91,7 @@ private static byte[] CreateLUT8() /// Grid-point Count: { 3, 3 } /// public static readonly byte[] CLUT8_Grad = - { + [ 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, @@ -105,30 +102,28 @@ private static byte[] CreateLUT8() 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, - 0x19, 0x1A, 0x1B, - }; + 0x19, 0x1A, 0x1B + ]; public static readonly object[][] Clut8TestData = - { - new object[] { CLUT8_Grad, CLUT8_ValGrad, 2, 3, new byte[] { 3, 3 } }, - }; + [ + [CLUT8_Grad, CLUT8_ValGrad, 2, 3, new byte[] { 3, 3 }] + ]; - public static readonly IccClut CLUT16_ValGrad = new IccClut( + public static readonly IccClut CLUT16_ValGrad = new( new float[][] { - new float[] { 1f / ushort.MaxValue, 2f / ushort.MaxValue, 3f / ushort.MaxValue }, - new float[] { 4f / ushort.MaxValue, 5f / ushort.MaxValue, 6f / ushort.MaxValue }, - new float[] { 7f / ushort.MaxValue, 8f / ushort.MaxValue, 9f / ushort.MaxValue }, - - new float[] { 10f / ushort.MaxValue, 11f / ushort.MaxValue, 12f / ushort.MaxValue }, - new float[] { 13f / ushort.MaxValue, 14f / ushort.MaxValue, 15f / ushort.MaxValue }, - new float[] { 16f / ushort.MaxValue, 17f / ushort.MaxValue, 18f / ushort.MaxValue }, - - new float[] { 19f / ushort.MaxValue, 20f / ushort.MaxValue, 21f / ushort.MaxValue }, - new float[] { 22f / ushort.MaxValue, 23f / ushort.MaxValue, 24f / ushort.MaxValue }, - new float[] { 25f / ushort.MaxValue, 26f / ushort.MaxValue, 27f / ushort.MaxValue }, + [1f / ushort.MaxValue, 2f / ushort.MaxValue, 3f / ushort.MaxValue], [4f / ushort.MaxValue, 5f / ushort.MaxValue, 6f / ushort.MaxValue + ], + [7f / ushort.MaxValue, 8f / ushort.MaxValue, 9f / ushort.MaxValue], [10f / ushort.MaxValue, 11f / ushort.MaxValue, 12f / ushort.MaxValue + ], + [13f / ushort.MaxValue, 14f / ushort.MaxValue, 15f / ushort.MaxValue], [16f / ushort.MaxValue, 17f / ushort.MaxValue, 18f / ushort.MaxValue + ], + [19f / ushort.MaxValue, 20f / ushort.MaxValue, 21f / ushort.MaxValue], [22f / ushort.MaxValue, 23f / ushort.MaxValue, 24f / ushort.MaxValue + ], + [25f / ushort.MaxValue, 26f / ushort.MaxValue, 27f / ushort.MaxValue], }, - new byte[] { 3, 3 }, + [3, 3], IccClutDataType.UInt16); /// @@ -137,7 +132,7 @@ private static byte[] CreateLUT8() /// Grid-point Count: { 3, 3 } /// public static readonly byte[] CLUT16_Grad = - { + [ 0x00, 0x01, 0x00, 0x02, 0x00, 0x03, 0x00, 0x04, 0x00, 0x05, 0x00, 0x06, 0x00, 0x07, 0x00, 0x08, 0x00, 0x09, @@ -148,30 +143,22 @@ private static byte[] CreateLUT8() 0x00, 0x13, 0x00, 0x14, 0x00, 0x15, 0x00, 0x16, 0x00, 0x17, 0x00, 0x18, - 0x00, 0x19, 0x00, 0x1A, 0x00, 0x1B, - }; + 0x00, 0x19, 0x00, 0x1A, 0x00, 0x1B + ]; public static readonly object[][] Clut16TestData = - { - new object[] { CLUT16_Grad, CLUT16_ValGrad, 2, 3, new byte[] { 3, 3 } }, - }; + [ + [CLUT16_Grad, CLUT16_ValGrad, 2, 3, new byte[] { 3, 3 }] + ]; - public static readonly IccClut CLUTf32_ValGrad = new IccClut( + public static readonly IccClut CLUTf32_ValGrad = new( new float[][] { - new float[] { 1f, 2f, 3f }, - new float[] { 4f, 5f, 6f }, - new float[] { 7f, 8f, 9f }, - - new float[] { 1f, 2f, 3f }, - new float[] { 4f, 5f, 6f }, - new float[] { 7f, 8f, 9f }, - - new float[] { 1f, 2f, 3f }, - new float[] { 4f, 5f, 6f }, - new float[] { 7f, 8f, 9f }, + [1f, 2f, 3f], [4f, 5f, 6f], [7f, 8f, 9f], [1f, 2f, 3f], [4f, 5f, 6f], [7f, 8f, 9f], [1f, 2f, 3f], [4f, 5f, 6f + ], + [7f, 8f, 9f], }, - new byte[] { 3, 3 }, + [3, 3], IccClutDataType.Float); /// @@ -209,9 +196,9 @@ private static byte[] CreateLUT8() IccTestDataPrimitives.Single_9); public static readonly object[][] ClutF32TestData = - { - new object[] { CLUTf32_Grad, CLUTf32_ValGrad, 2, 3, new byte[] { 3, 3 } }, - }; + [ + [CLUTf32_Grad, CLUTf32_ValGrad, 2, 3, new byte[] { 3, 3 }] + ]; public static readonly IccClut CLUT_Val8 = CLUT8_ValGrad; public static readonly IccClut CLUT_Val16 = CLUT16_ValGrad; @@ -232,9 +219,9 @@ private static byte[] CreateLUT8() CLUTf32_Grad); public static readonly object[][] ClutTestData = - { - new object[] { CLUT_8, CLUT_Val8, 2, 3, false }, - new object[] { CLUT_16, CLUT_Val16, 2, 3, false }, - new object[] { CLUT_f32, CLUT_Valf32, 2, 3, true }, - }; + [ + [CLUT_8, CLUT_Val8, 2, 3, false], + [CLUT_16, CLUT_Val16, 2, 3, false], + [CLUT_f32, CLUT_Valf32, 2, 3, true] + ]; } diff --git a/tests/ImageSharp.Tests/TestDataIcc/IccTestDataMatrix.cs b/tests/ImageSharp.Tests/TestDataIcc/IccTestDataMatrix.cs index 94df8d69a6..f13ac94e30 100644 --- a/tests/ImageSharp.Tests/TestDataIcc/IccTestDataMatrix.cs +++ b/tests/ImageSharp.Tests/TestDataIcc/IccTestDataMatrix.cs @@ -32,7 +32,7 @@ internal static class IccTestDataMatrix /// /// 3x3 Matrix /// - public static readonly Matrix4x4 Single_Matrix4x4_ValGrad = new Matrix4x4(1, 2, 3, 0, 4, 5, 6, 0, 7, 8, 9, 0, 0, 0, 0, 1); + public static readonly Matrix4x4 Single_Matrix4x4_ValGrad = new(1, 2, 3, 0, 4, 5, 6, 0, 7, 8, 9, 0, 0, 0, 0, 1); /// /// 3x3 Matrix @@ -42,12 +42,12 @@ internal static class IccTestDataMatrix /// /// 3x3 Matrix /// - public static readonly DenseMatrix Single_DenseMatrix_ValGrad = new DenseMatrix(Single_2DArray_ValGrad); + public static readonly DenseMatrix Single_DenseMatrix_ValGrad = new(Single_2DArray_ValGrad); /// /// 3x3 Matrix /// - public static readonly DenseMatrix Single_DenseMatrix_ValIdentity = new DenseMatrix(Single_2DArray_ValIdentity); + public static readonly DenseMatrix Single_DenseMatrix_ValIdentity = new(Single_2DArray_ValIdentity); /// /// 3x3 Matrix @@ -92,35 +92,35 @@ internal static class IccTestDataMatrix IccTestDataPrimitives.Single_9); public static readonly object[][] Matrix2D_FloatArrayTestData = - { - new object[] { Fix16_2D_Grad, 3, 3, false, Single_2DArray_ValGrad }, - new object[] { Fix16_2D_Identity, 3, 3, false, Single_2DArray_ValIdentity }, - new object[] { Single_2D_Grad, 3, 3, true, Single_2DArray_ValGrad }, - }; + [ + [Fix16_2D_Grad, 3, 3, false, Single_2DArray_ValGrad], + [Fix16_2D_Identity, 3, 3, false, Single_2DArray_ValIdentity], + [Single_2D_Grad, 3, 3, true, Single_2DArray_ValGrad] + ]; public static readonly object[][] Matrix2D_DenseMatrixTestData = - { - new object[] { Fix16_2D_Grad, 3, 3, false, Single_DenseMatrix_ValGrad }, - new object[] { Fix16_2D_Identity, 3, 3, false, Single_DenseMatrix_ValIdentity }, - new object[] { Single_2D_Grad, 3, 3, true, Single_DenseMatrix_ValGrad }, - }; + [ + [Fix16_2D_Grad, 3, 3, false, Single_DenseMatrix_ValGrad], + [Fix16_2D_Identity, 3, 3, false, Single_DenseMatrix_ValIdentity], + [Single_2D_Grad, 3, 3, true, Single_DenseMatrix_ValGrad] + ]; public static readonly object[][] Matrix2D_Matrix4x4TestData = - { - new object[] { Fix16_2D_Grad, 3, 3, false, Single_Matrix4x4_ValGrad }, - new object[] { Fix16_2D_Identity, 3, 3, false, Single_Matrix4x4_ValIdentity }, - new object[] { Single_2D_Grad, 3, 3, true, Single_Matrix4x4_ValGrad }, - }; + [ + [Fix16_2D_Grad, 3, 3, false, Single_Matrix4x4_ValGrad], + [Fix16_2D_Identity, 3, 3, false, Single_Matrix4x4_ValIdentity], + [Single_2D_Grad, 3, 3, true, Single_Matrix4x4_ValGrad] + ]; /// /// 3x1 Matrix /// - public static readonly float[] Single_1DArray_ValGrad = { 1, 4, 7 }; + public static readonly float[] Single_1DArray_ValGrad = [1, 4, 7]; /// /// 3x1 Matrix /// - public static readonly Vector3 Single_Vector3_ValGrad = new Vector3(1, 4, 7); + public static readonly Vector3 Single_Vector3_ValGrad = new(1, 4, 7); /// /// 3x1 Matrix @@ -139,14 +139,14 @@ internal static class IccTestDataMatrix IccTestDataPrimitives.Single_7); public static readonly object[][] Matrix1D_ArrayTestData = - { - new object[] { Fix16_1D_Grad, 3, false, Single_1DArray_ValGrad }, - new object[] { Single_1D_Grad, 3, true, Single_1DArray_ValGrad }, - }; + [ + [Fix16_1D_Grad, 3, false, Single_1DArray_ValGrad], + [Single_1D_Grad, 3, true, Single_1DArray_ValGrad] + ]; public static readonly object[][] Matrix1D_Vector3TestData = - { - new object[] { Fix16_1D_Grad, 3, false, Single_Vector3_ValGrad }, - new object[] { Single_1D_Grad, 3, true, Single_Vector3_ValGrad }, - }; + [ + [Fix16_1D_Grad, 3, false, Single_Vector3_ValGrad], + [Single_1D_Grad, 3, true, Single_Vector3_ValGrad] + ]; } diff --git a/tests/ImageSharp.Tests/TestDataIcc/IccTestDataMultiProcessElements.cs b/tests/ImageSharp.Tests/TestDataIcc/IccTestDataMultiProcessElements.cs index 2c5c432710..e1cf6d63a7 100644 --- a/tests/ImageSharp.Tests/TestDataIcc/IccTestDataMultiProcessElements.cs +++ b/tests/ImageSharp.Tests/TestDataIcc/IccTestDataMultiProcessElements.cs @@ -11,12 +11,11 @@ internal static class IccTestDataMultiProcessElements /// Input Channel Count: 3 /// Output Channel Count: 3 /// - public static readonly IccCurveSetProcessElement CurvePE_ValGrad = new IccCurveSetProcessElement(new IccOneDimensionalCurve[] - { + public static readonly IccCurveSetProcessElement CurvePE_ValGrad = new([ IccTestDataCurves.OneDimensional_ValFormula1, IccTestDataCurves.OneDimensional_ValFormula2, IccTestDataCurves.OneDimensional_ValFormula1 - }); + ]); /// /// Input Channel Count: 3 @@ -28,15 +27,15 @@ internal static class IccTestDataMultiProcessElements IccTestDataCurves.OneDimensional_Formula1); public static readonly object[][] CurveSetTestData = - { - new object[] { CurvePE_Grad, CurvePE_ValGrad, 3, 3 }, - }; + [ + [CurvePE_Grad, CurvePE_ValGrad, 3, 3] + ]; /// /// Input Channel Count: 3 /// Output Channel Count: 3 /// - public static readonly IccMatrixProcessElement MatrixPE_ValGrad = new IccMatrixProcessElement( + public static readonly IccMatrixProcessElement MatrixPE_ValGrad = new( IccTestDataMatrix.Single_2DArray_ValGrad, IccTestDataMatrix.Single_1DArray_ValGrad); @@ -49,15 +48,15 @@ internal static class IccTestDataMultiProcessElements IccTestDataMatrix.Single_1D_Grad); public static readonly object[][] MatrixTestData = - { - new object[] { MatrixPE_Grad, MatrixPE_ValGrad, 3, 3 }, - }; + [ + [MatrixPE_Grad, MatrixPE_ValGrad, 3, 3] + ]; /// /// Input Channel Count: 2 /// Output Channel Count: 3 /// - public static readonly IccClutProcessElement CLUTPE_ValGrad = new IccClutProcessElement(IccTestDataLut.CLUT_Valf32); + public static readonly IccClutProcessElement CLUTPE_ValGrad = new(IccTestDataLut.CLUT_Valf32); /// /// Input Channel Count: 2 @@ -66,9 +65,9 @@ internal static class IccTestDataMultiProcessElements public static readonly byte[] CLUTPE_Grad = IccTestDataLut.CLUT_f32; public static readonly object[][] ClutTestData = - { - new object[] { CLUTPE_Grad, CLUTPE_ValGrad, 2, 3 }, - }; + [ + [CLUTPE_Grad, CLUTPE_ValGrad, 2, 3] + ]; public static readonly IccMultiProcessElement MPE_ValMatrix = MatrixPE_ValGrad; public static readonly IccMultiProcessElement MPE_ValCLUT = CLUTPE_ValGrad; @@ -104,27 +103,27 @@ internal static class IccTestDataMultiProcessElements CurvePE_Grad); public static readonly byte[] MPE_bACS = - { + [ 0x62, 0x41, 0x43, 0x53, 0x00, 0x03, 0x00, 0x03, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - }; + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 + ]; public static readonly byte[] MPE_eACS = - { + [ 0x65, 0x41, 0x43, 0x53, 0x00, 0x03, 0x00, 0x03, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - }; + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 + ]; public static readonly object[][] MultiProcessElementTestData = - { - new object[] { MPE_Matrix, MPE_ValMatrix }, - new object[] { MPE_CLUT, MPE_ValCLUT }, - new object[] { MPE_Curve, MPE_ValCurve }, - new object[] { MPE_bACS, MPE_ValbACS }, - new object[] { MPE_eACS, MPE_ValeACS }, - }; + [ + [MPE_Matrix, MPE_ValMatrix], + [MPE_CLUT, MPE_ValCLUT], + [MPE_Curve, MPE_ValCurve], + [MPE_bACS, MPE_ValbACS], + [MPE_eACS, MPE_ValeACS] + ]; } diff --git a/tests/ImageSharp.Tests/TestDataIcc/IccTestDataNonPrimitives.cs b/tests/ImageSharp.Tests/TestDataIcc/IccTestDataNonPrimitives.cs index c476f2e6c7..9c9e697fe6 100644 --- a/tests/ImageSharp.Tests/TestDataIcc/IccTestDataNonPrimitives.cs +++ b/tests/ImageSharp.Tests/TestDataIcc/IccTestDataNonPrimitives.cs @@ -9,82 +9,82 @@ namespace SixLabors.ImageSharp.Tests; internal static class IccTestDataNonPrimitives { - public static readonly DateTime DateTime_ValMin = new DateTime(1, 1, 1, 0, 0, 0, DateTimeKind.Utc); - public static readonly DateTime DateTime_ValMax = new DateTime(9999, 12, 31, 23, 59, 59, DateTimeKind.Utc); - public static readonly DateTime DateTime_ValRand1 = new DateTime(1990, 11, 26, 3, 19, 47, DateTimeKind.Utc); + public static readonly DateTime DateTime_ValMin = new(1, 1, 1, 0, 0, 0, DateTimeKind.Utc); + public static readonly DateTime DateTime_ValMax = new(9999, 12, 31, 23, 59, 59, DateTimeKind.Utc); + public static readonly DateTime DateTime_ValRand1 = new(1990, 11, 26, 3, 19, 47, DateTimeKind.Utc); public static readonly byte[] DateTime_Min = - { + [ 0x00, 0x01, // Year 1 0x00, 0x01, // Month 1 0x00, 0x01, // Day 1 0x00, 0x00, // Hour 0 0x00, 0x00, // Minute 0 - 0x00, 0x00, // Second 0 - }; + 0x00, 0x00 // Second 0 + ]; public static readonly byte[] DateTime_Max = - { - 0x27, 0x0F, // Year 9999 + [ + 0x27, 0x0F, // Year 9999 0x00, 0x0C, // Month 12 0x00, 0x1F, // Day 31 0x00, 0x17, // Hour 23 0x00, 0x3B, // Minute 59 - 0x00, 0x3B, // Second 59 - }; + 0x00, 0x3B // Second 59 + ]; public static readonly byte[] DateTime_Invalid = - { - 0xFF, 0xFF, // Year 65535 + [ + 0xFF, 0xFF, // Year 65535 0x00, 0x0E, // Month 14 0x00, 0x21, // Day 33 0x00, 0x19, // Hour 25 0x00, 0x3D, // Minute 61 - 0x00, 0x3D, // Second 61 - }; + 0x00, 0x3D // Second 61 + ]; public static readonly byte[] DateTime_Rand1 = - { - 0x07, 0xC6, // Year 1990 + [ + 0x07, 0xC6, // Year 1990 0x00, 0x0B, // Month 11 0x00, 0x1A, // Day 26 0x00, 0x03, // Hour 3 0x00, 0x13, // Minute 19 - 0x00, 0x2F, // Second 47 - }; + 0x00, 0x2F // Second 47 + ]; public static readonly object[][] DateTimeTestData = - { - new object[] { DateTime_Min, DateTime_ValMin }, - new object[] { DateTime_Max, DateTime_ValMax }, - new object[] { DateTime_Rand1, DateTime_ValRand1 }, - }; - - public static readonly IccVersion VersionNumber_ValMin = new IccVersion(0, 0, 0); - public static readonly IccVersion VersionNumber_Val211 = new IccVersion(2, 1, 1); - public static readonly IccVersion VersionNumber_Val430 = new IccVersion(4, 3, 0); - public static readonly IccVersion VersionNumber_ValMax = new IccVersion(255, 15, 15); - - public static readonly byte[] VersionNumber_Min = { 0x00, 0x00, 0x00, 0x00 }; - public static readonly byte[] VersionNumber_211 = { 0x02, 0x11, 0x00, 0x00 }; - public static readonly byte[] VersionNumber_430 = { 0x04, 0x30, 0x00, 0x00 }; - public static readonly byte[] VersionNumber_Max = { 0xFF, 0xFF, 0x00, 0x00 }; + [ + [DateTime_Min, DateTime_ValMin], + [DateTime_Max, DateTime_ValMax], + [DateTime_Rand1, DateTime_ValRand1] + ]; + + public static readonly IccVersion VersionNumber_ValMin = new(0, 0, 0); + public static readonly IccVersion VersionNumber_Val211 = new(2, 1, 1); + public static readonly IccVersion VersionNumber_Val430 = new(4, 3, 0); + public static readonly IccVersion VersionNumber_ValMax = new(255, 15, 15); + + public static readonly byte[] VersionNumber_Min = [0x00, 0x00, 0x00, 0x00]; + public static readonly byte[] VersionNumber_211 = [0x02, 0x11, 0x00, 0x00]; + public static readonly byte[] VersionNumber_430 = [0x04, 0x30, 0x00, 0x00]; + public static readonly byte[] VersionNumber_Max = [0xFF, 0xFF, 0x00, 0x00]; public static readonly object[][] VersionNumberTestData = - { - new object[] { VersionNumber_Min, VersionNumber_ValMin }, - new object[] { VersionNumber_211, VersionNumber_Val211 }, - new object[] { VersionNumber_430, VersionNumber_Val430 }, - new object[] { VersionNumber_Max, VersionNumber_ValMax }, - }; - - public static readonly Vector3 XyzNumber_ValMin = new Vector3(IccTestDataPrimitives.Fix16_ValMin, IccTestDataPrimitives.Fix16_ValMin, IccTestDataPrimitives.Fix16_ValMin); - public static readonly Vector3 XyzNumber_Val0 = new Vector3(0, 0, 0); - public static readonly Vector3 XyzNumber_Val1 = new Vector3(1, 1, 1); - public static readonly Vector3 XyzNumber_ValVar1 = new Vector3(1, 2, 3); - public static readonly Vector3 XyzNumber_ValVar2 = new Vector3(4, 5, 6); - public static readonly Vector3 XyzNumber_ValVar3 = new Vector3(7, 8, 9); - public static readonly Vector3 XyzNumber_ValMax = new Vector3(IccTestDataPrimitives.Fix16_ValMax, IccTestDataPrimitives.Fix16_ValMax, IccTestDataPrimitives.Fix16_ValMax); + [ + [VersionNumber_Min, VersionNumber_ValMin], + [VersionNumber_211, VersionNumber_Val211], + [VersionNumber_430, VersionNumber_Val430], + [VersionNumber_Max, VersionNumber_ValMax] + ]; + + public static readonly Vector3 XyzNumber_ValMin = new(IccTestDataPrimitives.Fix16_ValMin, IccTestDataPrimitives.Fix16_ValMin, IccTestDataPrimitives.Fix16_ValMin); + public static readonly Vector3 XyzNumber_Val0 = new(0, 0, 0); + public static readonly Vector3 XyzNumber_Val1 = new(1, 1, 1); + public static readonly Vector3 XyzNumber_ValVar1 = new(1, 2, 3); + public static readonly Vector3 XyzNumber_ValVar2 = new(4, 5, 6); + public static readonly Vector3 XyzNumber_ValVar3 = new(7, 8, 9); + public static readonly Vector3 XyzNumber_ValMax = new(IccTestDataPrimitives.Fix16_ValMax, IccTestDataPrimitives.Fix16_ValMax, IccTestDataPrimitives.Fix16_ValMax); public static readonly byte[] XyzNumber_Min = ArrayHelper.Concat(IccTestDataPrimitives.Fix16_Min, IccTestDataPrimitives.Fix16_Min, IccTestDataPrimitives.Fix16_Min); public static readonly byte[] XyzNumber_0 = ArrayHelper.Concat(IccTestDataPrimitives.Fix16_0, IccTestDataPrimitives.Fix16_0, IccTestDataPrimitives.Fix16_0); @@ -95,54 +95,54 @@ internal static class IccTestDataNonPrimitives public static readonly byte[] XyzNumber_Max = ArrayHelper.Concat(IccTestDataPrimitives.Fix16_Max, IccTestDataPrimitives.Fix16_Max, IccTestDataPrimitives.Fix16_Max); public static readonly object[][] XyzNumberTestData = - { - new object[] { XyzNumber_Min, XyzNumber_ValMin }, - new object[] { XyzNumber_0, XyzNumber_Val0 }, - new object[] { XyzNumber_Var1, XyzNumber_ValVar1 }, - new object[] { XyzNumber_Max, XyzNumber_ValMax }, - }; + [ + [XyzNumber_Min, XyzNumber_ValMin], + [XyzNumber_0, XyzNumber_Val0], + [XyzNumber_Var1, XyzNumber_ValVar1], + [XyzNumber_Max, XyzNumber_ValMax] + ]; - public static readonly IccProfileId ProfileId_ValMin = new IccProfileId(0, 0, 0, 0); - public static readonly IccProfileId ProfileId_ValRand = new IccProfileId(IccTestDataPrimitives.UInt32_ValRand1, IccTestDataPrimitives.UInt32_ValRand2, IccTestDataPrimitives.UInt32_ValRand3, IccTestDataPrimitives.UInt32_ValRand4); - public static readonly IccProfileId ProfileId_ValMax = new IccProfileId(uint.MaxValue, uint.MaxValue, uint.MaxValue, uint.MaxValue); + public static readonly IccProfileId ProfileId_ValMin = new(0, 0, 0, 0); + public static readonly IccProfileId ProfileId_ValRand = new(IccTestDataPrimitives.UInt32_ValRand1, IccTestDataPrimitives.UInt32_ValRand2, IccTestDataPrimitives.UInt32_ValRand3, IccTestDataPrimitives.UInt32_ValRand4); + public static readonly IccProfileId ProfileId_ValMax = new(uint.MaxValue, uint.MaxValue, uint.MaxValue, uint.MaxValue); public static readonly byte[] ProfileId_Min = ArrayHelper.Concat(IccTestDataPrimitives.UInt32_0, IccTestDataPrimitives.UInt32_0, IccTestDataPrimitives.UInt32_0, IccTestDataPrimitives.UInt32_0); public static readonly byte[] ProfileId_Rand = ArrayHelper.Concat(IccTestDataPrimitives.UInt32_Rand1, IccTestDataPrimitives.UInt32_Rand2, IccTestDataPrimitives.UInt32_Rand3, IccTestDataPrimitives.UInt32_Rand4); public static readonly byte[] ProfileId_Max = ArrayHelper.Concat(IccTestDataPrimitives.UInt32_Max, IccTestDataPrimitives.UInt32_Max, IccTestDataPrimitives.UInt32_Max, IccTestDataPrimitives.UInt32_Max); public static readonly object[][] ProfileIdTestData = - { - new object[] { ProfileId_Min, ProfileId_ValMin }, - new object[] { ProfileId_Rand, ProfileId_ValRand }, - new object[] { ProfileId_Max, ProfileId_ValMax }, - }; + [ + [ProfileId_Min, ProfileId_ValMin], + [ProfileId_Rand, ProfileId_ValRand], + [ProfileId_Max, ProfileId_ValMax] + ]; - public static readonly IccPositionNumber PositionNumber_ValMin = new IccPositionNumber(0, 0); - public static readonly IccPositionNumber PositionNumber_ValRand = new IccPositionNumber(IccTestDataPrimitives.UInt32_ValRand1, IccTestDataPrimitives.UInt32_ValRand2); - public static readonly IccPositionNumber PositionNumber_ValMax = new IccPositionNumber(uint.MaxValue, uint.MaxValue); + public static readonly IccPositionNumber PositionNumber_ValMin = new(0, 0); + public static readonly IccPositionNumber PositionNumber_ValRand = new(IccTestDataPrimitives.UInt32_ValRand1, IccTestDataPrimitives.UInt32_ValRand2); + public static readonly IccPositionNumber PositionNumber_ValMax = new(uint.MaxValue, uint.MaxValue); public static readonly byte[] PositionNumber_Min = ArrayHelper.Concat(IccTestDataPrimitives.UInt32_0, IccTestDataPrimitives.UInt32_0); public static readonly byte[] PositionNumber_Rand = ArrayHelper.Concat(IccTestDataPrimitives.UInt32_Rand1, IccTestDataPrimitives.UInt32_Rand2); public static readonly byte[] PositionNumber_Max = ArrayHelper.Concat(IccTestDataPrimitives.UInt32_Max, IccTestDataPrimitives.UInt32_Max); public static readonly object[][] PositionNumberTestData = - { - new object[] { PositionNumber_Min, PositionNumber_ValMin }, - new object[] { PositionNumber_Rand, PositionNumber_ValRand }, - new object[] { PositionNumber_Max, PositionNumber_ValMax }, - }; - - public static readonly IccResponseNumber ResponseNumber_ValMin = new IccResponseNumber(0, IccTestDataPrimitives.Fix16_ValMin); - public static readonly IccResponseNumber ResponseNumber_Val1 = new IccResponseNumber(1, 1); - public static readonly IccResponseNumber ResponseNumber_Val2 = new IccResponseNumber(2, 2); - public static readonly IccResponseNumber ResponseNumber_Val3 = new IccResponseNumber(3, 3); - public static readonly IccResponseNumber ResponseNumber_Val4 = new IccResponseNumber(4, 4); - public static readonly IccResponseNumber ResponseNumber_Val5 = new IccResponseNumber(5, 5); - public static readonly IccResponseNumber ResponseNumber_Val6 = new IccResponseNumber(6, 6); - public static readonly IccResponseNumber ResponseNumber_Val7 = new IccResponseNumber(7, 7); - public static readonly IccResponseNumber ResponseNumber_Val8 = new IccResponseNumber(8, 8); - public static readonly IccResponseNumber ResponseNumber_Val9 = new IccResponseNumber(9, 9); - public static readonly IccResponseNumber ResponseNumber_ValMax = new IccResponseNumber(ushort.MaxValue, IccTestDataPrimitives.Fix16_ValMax); + [ + [PositionNumber_Min, PositionNumber_ValMin], + [PositionNumber_Rand, PositionNumber_ValRand], + [PositionNumber_Max, PositionNumber_ValMax] + ]; + + public static readonly IccResponseNumber ResponseNumber_ValMin = new(0, IccTestDataPrimitives.Fix16_ValMin); + public static readonly IccResponseNumber ResponseNumber_Val1 = new(1, 1); + public static readonly IccResponseNumber ResponseNumber_Val2 = new(2, 2); + public static readonly IccResponseNumber ResponseNumber_Val3 = new(3, 3); + public static readonly IccResponseNumber ResponseNumber_Val4 = new(4, 4); + public static readonly IccResponseNumber ResponseNumber_Val5 = new(5, 5); + public static readonly IccResponseNumber ResponseNumber_Val6 = new(6, 6); + public static readonly IccResponseNumber ResponseNumber_Val7 = new(7, 7); + public static readonly IccResponseNumber ResponseNumber_Val8 = new(8, 8); + public static readonly IccResponseNumber ResponseNumber_Val9 = new(9, 9); + public static readonly IccResponseNumber ResponseNumber_ValMax = new(ushort.MaxValue, IccTestDataPrimitives.Fix16_ValMax); public static readonly byte[] ResponseNumber_Min = ArrayHelper.Concat(IccTestDataPrimitives.UInt16_0, IccTestDataPrimitives.Fix16_Min); public static readonly byte[] ResponseNumber_1 = ArrayHelper.Concat(IccTestDataPrimitives.UInt16_1, IccTestDataPrimitives.Fix16_1); @@ -157,27 +157,27 @@ internal static class IccTestDataNonPrimitives public static readonly byte[] ResponseNumber_Max = ArrayHelper.Concat(IccTestDataPrimitives.UInt16_Max, IccTestDataPrimitives.Fix16_Max); public static readonly object[][] ResponseNumberTestData = - { - new object[] { ResponseNumber_Min, ResponseNumber_ValMin }, - new object[] { ResponseNumber_1, ResponseNumber_Val1 }, - new object[] { ResponseNumber_4, ResponseNumber_Val4 }, - new object[] { ResponseNumber_Max, ResponseNumber_ValMax }, - }; - - public static readonly IccNamedColor NamedColor_ValMin = new IccNamedColor( + [ + [ResponseNumber_Min, ResponseNumber_ValMin], + [ResponseNumber_1, ResponseNumber_Val1], + [ResponseNumber_4, ResponseNumber_Val4], + [ResponseNumber_Max, ResponseNumber_ValMax] + ]; + + public static readonly IccNamedColor NamedColor_ValMin = new( ArrayHelper.Fill('A', 31), - new ushort[] { 0, 0, 0 }, - new ushort[] { 0, 0, 0 }); + [0, 0, 0], + [0, 0, 0]); - public static readonly IccNamedColor NamedColor_ValRand = new IccNamedColor( + public static readonly IccNamedColor NamedColor_ValRand = new( ArrayHelper.Fill('5', 31), - new ushort[] { 10794, 10794, 10794 }, - new ushort[] { 17219, 17219, 17219, 17219, 17219 }); + [10794, 10794, 10794], + [17219, 17219, 17219, 17219, 17219]); - public static readonly IccNamedColor NamedColor_ValMax = new IccNamedColor( + public static readonly IccNamedColor NamedColor_ValMax = new( ArrayHelper.Fill('4', 31), - new ushort[] { ushort.MaxValue, ushort.MaxValue, ushort.MaxValue }, - new ushort[] { ushort.MaxValue, ushort.MaxValue, ushort.MaxValue, ushort.MaxValue }); + [ushort.MaxValue, ushort.MaxValue, ushort.MaxValue], + [ushort.MaxValue, ushort.MaxValue, ushort.MaxValue, ushort.MaxValue]); public static readonly byte[] NamedColor_Min = CreateNamedColor(3, 0x41, 0x00, 0x00); public static readonly byte[] NamedColor_Rand = CreateNamedColor(5, 0x35, 42, 67); @@ -210,38 +210,38 @@ private static byte[] CreateNamedColor(int devCoordCount, byte name, byte pCS, b } public static readonly object[][] NamedColorTestData = - { - new object[] { NamedColor_Min, NamedColor_ValMin, 3u }, - new object[] { NamedColor_Rand, NamedColor_ValRand, 5u }, - new object[] { NamedColor_Max, NamedColor_ValMax, 4u }, - }; + [ + [NamedColor_Min, NamedColor_ValMin, 3u], + [NamedColor_Rand, NamedColor_ValRand, 5u], + [NamedColor_Max, NamedColor_ValMax, 4u] + ]; - private static readonly CultureInfo CultureEnUs = new CultureInfo("en-US"); - private static readonly CultureInfo CultureDeAT = new CultureInfo("de-AT"); + private static readonly CultureInfo CultureEnUs = new("en-US"); + private static readonly CultureInfo CultureDeAT = new("de-AT"); - private static readonly IccLocalizedString LocalizedString_Rand1 = new IccLocalizedString(CultureEnUs, IccTestDataPrimitives.Unicode_ValRand2); - private static readonly IccLocalizedString LocalizedString_Rand2 = new IccLocalizedString(CultureDeAT, IccTestDataPrimitives.Unicode_ValRand3); + private static readonly IccLocalizedString LocalizedString_Rand1 = new(CultureEnUs, IccTestDataPrimitives.Unicode_ValRand2); + private static readonly IccLocalizedString LocalizedString_Rand2 = new(CultureDeAT, IccTestDataPrimitives.Unicode_ValRand3); - private static readonly IccLocalizedString[] LocalizedString_RandArr1 = new IccLocalizedString[] - { + private static readonly IccLocalizedString[] LocalizedString_RandArr1 = + [ LocalizedString_Rand1, - LocalizedString_Rand2, - }; + LocalizedString_Rand2 + ]; - private static readonly IccMultiLocalizedUnicodeTagDataEntry MultiLocalizedUnicode_Val = new IccMultiLocalizedUnicodeTagDataEntry(LocalizedString_RandArr1); + private static readonly IccMultiLocalizedUnicodeTagDataEntry MultiLocalizedUnicode_Val = new(LocalizedString_RandArr1); private static readonly byte[] MultiLocalizedUnicode_Arr = ArrayHelper.Concat( IccTestDataPrimitives.UInt32_2, new byte[] { 0x00, 0x00, 0x00, 0x0C }, // 12 - new byte[] { (byte)'e', (byte)'n', (byte)'U', (byte)'S' }, + [(byte)'e', (byte)'n', (byte)'U', (byte)'S'], new byte[] { 0x00, 0x00, 0x00, 0x0C }, // 12 new byte[] { 0x00, 0x00, 0x00, 0x28 }, // 40 - new byte[] { (byte)'d', (byte)'e', (byte)'A', (byte)'T' }, + [(byte)'d', (byte)'e', (byte)'A', (byte)'T'], new byte[] { 0x00, 0x00, 0x00, 0x0E }, // 14 new byte[] { 0x00, 0x00, 0x00, 0x34 }, // 52 IccTestDataPrimitives.Unicode_Rand2, IccTestDataPrimitives.Unicode_Rand3); - public static readonly IccTextDescriptionTagDataEntry TextDescription_Val1 = new IccTextDescriptionTagDataEntry( + public static readonly IccTextDescriptionTagDataEntry TextDescription_Val1 = new( IccTestDataPrimitives.Ascii_ValRand, IccTestDataPrimitives.Unicode_ValRand1, ArrayHelper.Fill('A', 66), @@ -252,7 +252,7 @@ private static byte[] CreateNamedColor(int devCoordCount, byte name, byte pCS, b new byte[] { 0x00, 0x00, 0x00, 0x0B }, // 11 IccTestDataPrimitives.Ascii_Rand, new byte[] { 0x00 }, // Null terminator - new byte[] { (byte)'e', (byte)'n', (byte)'U', (byte)'S' }, + [(byte)'e', (byte)'n', (byte)'U', (byte)'S'], new byte[] { 0x00, 0x00, 0x00, 0x07 }, // 7 IccTestDataPrimitives.Unicode_Rand2, new byte[] { 0x00, 0x00 }, // Null terminator @@ -260,7 +260,7 @@ private static byte[] CreateNamedColor(int devCoordCount, byte name, byte pCS, b ArrayHelper.Fill((byte)0x41, 66), new byte[] { 0x00 }); // Null terminator - public static readonly IccProfileDescription ProfileDescription_ValRand1 = new IccProfileDescription( + public static readonly IccProfileDescription ProfileDescription_ValRand1 = new( 1, 2, IccDeviceAttribute.ChromaBlackWhite | IccDeviceAttribute.ReflectivityMatte, @@ -268,13 +268,13 @@ private static byte[] CreateNamedColor(int devCoordCount, byte name, byte pCS, b MultiLocalizedUnicode_Val.Texts, MultiLocalizedUnicode_Val.Texts); - public static readonly IccProfileDescription ProfileDescription_ValRand2 = new IccProfileDescription( + public static readonly IccProfileDescription ProfileDescription_ValRand2 = new( 1, 2, IccDeviceAttribute.ChromaBlackWhite | IccDeviceAttribute.ReflectivityMatte, IccProfileTag.ProfileDescription, - new IccLocalizedString[] { LocalizedString_Rand1 }, - new IccLocalizedString[] { LocalizedString_Rand1 }); + [LocalizedString_Rand1], + [LocalizedString_Rand1]); public static readonly byte[] ProfileDescription_Rand1 = ArrayHelper.Concat( IccTestDataPrimitives.UInt32_1, @@ -301,18 +301,18 @@ private static byte[] CreateNamedColor(int devCoordCount, byte name, byte pCS, b TextDescription_Arr1); public static readonly object[][] ProfileDescriptionReadTestData = - { - new object[] { ProfileDescription_Rand1, ProfileDescription_ValRand1 }, - new object[] { ProfileDescription_Rand2, ProfileDescription_ValRand2 }, - }; + [ + [ProfileDescription_Rand1, ProfileDescription_ValRand1], + [ProfileDescription_Rand2, ProfileDescription_ValRand2] + ]; public static readonly object[][] ProfileDescriptionWriteTestData = - { - new object[] { ProfileDescription_Rand1, ProfileDescription_ValRand1 }, - }; + [ + [ProfileDescription_Rand1, ProfileDescription_ValRand1] + ]; - public static readonly IccColorantTableEntry ColorantTableEntry_ValRand1 = new IccColorantTableEntry(ArrayHelper.Fill('A', 31), 1, 2, 3); - public static readonly IccColorantTableEntry ColorantTableEntry_ValRand2 = new IccColorantTableEntry(ArrayHelper.Fill('4', 31), 4, 5, 6); + public static readonly IccColorantTableEntry ColorantTableEntry_ValRand1 = new(ArrayHelper.Fill('A', 31), 1, 2, 3); + public static readonly IccColorantTableEntry ColorantTableEntry_ValRand2 = new(ArrayHelper.Fill('4', 31), 4, 5, 6); public static readonly byte[] ColorantTableEntry_Rand1 = ArrayHelper.Concat( ArrayHelper.Fill((byte)0x41, 31), @@ -329,13 +329,13 @@ private static byte[] CreateNamedColor(int devCoordCount, byte name, byte pCS, b IccTestDataPrimitives.UInt16_6); public static readonly object[][] ColorantTableEntryTestData = - { - new object[] { ColorantTableEntry_Rand1, ColorantTableEntry_ValRand1 }, - new object[] { ColorantTableEntry_Rand2, ColorantTableEntry_ValRand2 }, - }; + [ + [ColorantTableEntry_Rand1, ColorantTableEntry_ValRand1], + [ColorantTableEntry_Rand2, ColorantTableEntry_ValRand2] + ]; - public static readonly IccScreeningChannel ScreeningChannel_ValRand1 = new IccScreeningChannel(4, 6, IccScreeningSpotType.Cross); - public static readonly IccScreeningChannel ScreeningChannel_ValRand2 = new IccScreeningChannel(8, 5, IccScreeningSpotType.Diamond); + public static readonly IccScreeningChannel ScreeningChannel_ValRand1 = new(4, 6, IccScreeningSpotType.Cross); + public static readonly IccScreeningChannel ScreeningChannel_ValRand2 = new(8, 5, IccScreeningSpotType.Diamond); public static readonly byte[] ScreeningChannel_Rand1 = ArrayHelper.Concat( IccTestDataPrimitives.Fix16_4, @@ -348,8 +348,8 @@ private static byte[] CreateNamedColor(int devCoordCount, byte name, byte pCS, b IccTestDataPrimitives.Int32_3); public static readonly object[][] ScreeningChannelTestData = - { - new object[] { ScreeningChannel_Rand1, ScreeningChannel_ValRand1 }, - new object[] { ScreeningChannel_Rand2, ScreeningChannel_ValRand2 }, - }; + [ + [ScreeningChannel_Rand1, ScreeningChannel_ValRand1], + [ScreeningChannel_Rand2, ScreeningChannel_ValRand2] + ]; } diff --git a/tests/ImageSharp.Tests/TestDataIcc/IccTestDataPrimitives.cs b/tests/ImageSharp.Tests/TestDataIcc/IccTestDataPrimitives.cs index f8e8717273..2e10c976c2 100644 --- a/tests/ImageSharp.Tests/TestDataIcc/IccTestDataPrimitives.cs +++ b/tests/ImageSharp.Tests/TestDataIcc/IccTestDataPrimitives.cs @@ -5,191 +5,191 @@ namespace SixLabors.ImageSharp.Tests; internal static class IccTestDataPrimitives { - public static readonly byte[] UInt16_0 = { 0x00, 0x00 }; - public static readonly byte[] UInt16_1 = { 0x00, 0x01 }; - public static readonly byte[] UInt16_2 = { 0x00, 0x02 }; - public static readonly byte[] UInt16_3 = { 0x00, 0x03 }; - public static readonly byte[] UInt16_4 = { 0x00, 0x04 }; - public static readonly byte[] UInt16_5 = { 0x00, 0x05 }; - public static readonly byte[] UInt16_6 = { 0x00, 0x06 }; - public static readonly byte[] UInt16_7 = { 0x00, 0x07 }; - public static readonly byte[] UInt16_8 = { 0x00, 0x08 }; - public static readonly byte[] UInt16_9 = { 0x00, 0x09 }; - public static readonly byte[] UInt16_32768 = { 0x80, 0x00 }; - public static readonly byte[] UInt16_Max = { 0xFF, 0xFF }; - - public static readonly byte[] Int16_Min = { 0x80, 0x00 }; - public static readonly byte[] Int16_0 = { 0x00, 0x00 }; - public static readonly byte[] Int16_1 = { 0x00, 0x01 }; - public static readonly byte[] Int16_2 = { 0x00, 0x02 }; - public static readonly byte[] Int16_3 = { 0x00, 0x03 }; - public static readonly byte[] Int16_4 = { 0x00, 0x04 }; - public static readonly byte[] Int16_5 = { 0x00, 0x05 }; - public static readonly byte[] Int16_6 = { 0x00, 0x06 }; - public static readonly byte[] Int16_7 = { 0x00, 0x07 }; - public static readonly byte[] Int16_8 = { 0x00, 0x08 }; - public static readonly byte[] Int16_9 = { 0x00, 0x09 }; - public static readonly byte[] Int16_Max = { 0x7F, 0xFF }; - - public static readonly byte[] UInt32_0 = { 0x00, 0x00, 0x00, 0x00 }; - public static readonly byte[] UInt32_1 = { 0x00, 0x00, 0x00, 0x01 }; - public static readonly byte[] UInt32_2 = { 0x00, 0x00, 0x00, 0x02 }; - public static readonly byte[] UInt32_3 = { 0x00, 0x00, 0x00, 0x03 }; - public static readonly byte[] UInt32_4 = { 0x00, 0x00, 0x00, 0x04 }; - public static readonly byte[] UInt32_5 = { 0x00, 0x00, 0x00, 0x05 }; - public static readonly byte[] UInt32_6 = { 0x00, 0x00, 0x00, 0x06 }; - public static readonly byte[] UInt32_7 = { 0x00, 0x00, 0x00, 0x07 }; - public static readonly byte[] UInt32_8 = { 0x00, 0x00, 0x00, 0x08 }; - public static readonly byte[] UInt32_9 = { 0x00, 0x00, 0x00, 0x09 }; - public static readonly byte[] UInt32_Max = { 0xFF, 0xFF, 0xFF, 0xFF }; + public static readonly byte[] UInt16_0 = [0x00, 0x00]; + public static readonly byte[] UInt16_1 = [0x00, 0x01]; + public static readonly byte[] UInt16_2 = [0x00, 0x02]; + public static readonly byte[] UInt16_3 = [0x00, 0x03]; + public static readonly byte[] UInt16_4 = [0x00, 0x04]; + public static readonly byte[] UInt16_5 = [0x00, 0x05]; + public static readonly byte[] UInt16_6 = [0x00, 0x06]; + public static readonly byte[] UInt16_7 = [0x00, 0x07]; + public static readonly byte[] UInt16_8 = [0x00, 0x08]; + public static readonly byte[] UInt16_9 = [0x00, 0x09]; + public static readonly byte[] UInt16_32768 = [0x80, 0x00]; + public static readonly byte[] UInt16_Max = [0xFF, 0xFF]; + + public static readonly byte[] Int16_Min = [0x80, 0x00]; + public static readonly byte[] Int16_0 = [0x00, 0x00]; + public static readonly byte[] Int16_1 = [0x00, 0x01]; + public static readonly byte[] Int16_2 = [0x00, 0x02]; + public static readonly byte[] Int16_3 = [0x00, 0x03]; + public static readonly byte[] Int16_4 = [0x00, 0x04]; + public static readonly byte[] Int16_5 = [0x00, 0x05]; + public static readonly byte[] Int16_6 = [0x00, 0x06]; + public static readonly byte[] Int16_7 = [0x00, 0x07]; + public static readonly byte[] Int16_8 = [0x00, 0x08]; + public static readonly byte[] Int16_9 = [0x00, 0x09]; + public static readonly byte[] Int16_Max = [0x7F, 0xFF]; + + public static readonly byte[] UInt32_0 = [0x00, 0x00, 0x00, 0x00]; + public static readonly byte[] UInt32_1 = [0x00, 0x00, 0x00, 0x01]; + public static readonly byte[] UInt32_2 = [0x00, 0x00, 0x00, 0x02]; + public static readonly byte[] UInt32_3 = [0x00, 0x00, 0x00, 0x03]; + public static readonly byte[] UInt32_4 = [0x00, 0x00, 0x00, 0x04]; + public static readonly byte[] UInt32_5 = [0x00, 0x00, 0x00, 0x05]; + public static readonly byte[] UInt32_6 = [0x00, 0x00, 0x00, 0x06]; + public static readonly byte[] UInt32_7 = [0x00, 0x00, 0x00, 0x07]; + public static readonly byte[] UInt32_8 = [0x00, 0x00, 0x00, 0x08]; + public static readonly byte[] UInt32_9 = [0x00, 0x00, 0x00, 0x09]; + public static readonly byte[] UInt32_Max = [0xFF, 0xFF, 0xFF, 0xFF]; public static readonly uint UInt32_ValRand1 = 1749014123; public static readonly uint UInt32_ValRand2 = 3870560989; public static readonly uint UInt32_ValRand3 = 1050090334; public static readonly uint UInt32_ValRand4 = 3550252874; - public static readonly byte[] UInt32_Rand1 = { 0x68, 0x3F, 0xD6, 0x6B }; - public static readonly byte[] UInt32_Rand2 = { 0xE6, 0xB4, 0x12, 0xDD }; - public static readonly byte[] UInt32_Rand3 = { 0x3E, 0x97, 0x1B, 0x5E }; - public static readonly byte[] UInt32_Rand4 = { 0xD3, 0x9C, 0x8F, 0x4A }; - - public static readonly byte[] Int32_Min = { 0x80, 0x00, 0x00, 0x00 }; - public static readonly byte[] Int32_0 = { 0x00, 0x00, 0x00, 0x00 }; - public static readonly byte[] Int32_1 = { 0x00, 0x00, 0x00, 0x01 }; - public static readonly byte[] Int32_2 = { 0x00, 0x00, 0x00, 0x02 }; - public static readonly byte[] Int32_3 = { 0x00, 0x00, 0x00, 0x03 }; - public static readonly byte[] Int32_4 = { 0x00, 0x00, 0x00, 0x04 }; - public static readonly byte[] Int32_5 = { 0x00, 0x00, 0x00, 0x05 }; - public static readonly byte[] Int32_6 = { 0x00, 0x00, 0x00, 0x06 }; - public static readonly byte[] Int32_7 = { 0x00, 0x00, 0x00, 0x07 }; - public static readonly byte[] Int32_8 = { 0x00, 0x00, 0x00, 0x08 }; - public static readonly byte[] Int32_9 = { 0x00, 0x00, 0x00, 0x09 }; - public static readonly byte[] Int32_Max = { 0x7F, 0xFF, 0xFF, 0xFF }; - - public static readonly byte[] UInt64_0 = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; - public static readonly byte[] UInt64_1 = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 }; - public static readonly byte[] UInt64_2 = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02 }; - public static readonly byte[] UInt64_3 = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03 }; - public static readonly byte[] UInt64_4 = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04 }; - public static readonly byte[] UInt64_5 = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05 }; - public static readonly byte[] UInt64_6 = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06 }; - public static readonly byte[] UInt64_7 = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07 }; - public static readonly byte[] UInt64_8 = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08 }; - public static readonly byte[] UInt64_9 = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x09 }; - public static readonly byte[] UInt64_Max = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF }; - - public static readonly byte[] Int64_Min = { 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; - public static readonly byte[] Int64_0 = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; - public static readonly byte[] Int64_1 = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 }; - public static readonly byte[] Int64_2 = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02 }; - public static readonly byte[] Int64_3 = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03 }; - public static readonly byte[] Int64_4 = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04 }; - public static readonly byte[] Int64_5 = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05 }; - public static readonly byte[] Int64_6 = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06 }; - public static readonly byte[] Int64_7 = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07 }; - public static readonly byte[] Int64_8 = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08 }; - public static readonly byte[] Int64_9 = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x09 }; - public static readonly byte[] Int64_Max = { 0x7F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF }; - - public static readonly byte[] Single_Min = { 0xFF, 0x7F, 0xFF, 0xFF }; - public static readonly byte[] Single_0 = { 0x00, 0x00, 0x00, 0x00 }; - public static readonly byte[] Single_1 = { 0x3F, 0x80, 0x00, 0x00 }; - public static readonly byte[] Single_2 = { 0x40, 0x00, 0x00, 0x00 }; - public static readonly byte[] Single_3 = { 0x40, 0x40, 0x00, 0x00 }; - public static readonly byte[] Single_4 = { 0x40, 0x80, 0x00, 0x00 }; - public static readonly byte[] Single_5 = { 0x40, 0xA0, 0x00, 0x00 }; - public static readonly byte[] Single_6 = { 0x40, 0xC0, 0x00, 0x00 }; - public static readonly byte[] Single_7 = { 0x40, 0xE0, 0x00, 0x00 }; - public static readonly byte[] Single_8 = { 0x41, 0x00, 0x00, 0x00 }; - public static readonly byte[] Single_9 = { 0x41, 0x10, 0x00, 0x00 }; - public static readonly byte[] Single_Max = { 0x7F, 0x7F, 0xFF, 0xFF }; - - public static readonly byte[] Double_Min = { 0xFF, 0xEF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF }; - public static readonly byte[] Double_0 = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; - public static readonly byte[] Double_1 = { 0x3F, 0xF0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; - public static readonly byte[] Double_Max = { 0x7F, 0xEF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF }; + public static readonly byte[] UInt32_Rand1 = [0x68, 0x3F, 0xD6, 0x6B]; + public static readonly byte[] UInt32_Rand2 = [0xE6, 0xB4, 0x12, 0xDD]; + public static readonly byte[] UInt32_Rand3 = [0x3E, 0x97, 0x1B, 0x5E]; + public static readonly byte[] UInt32_Rand4 = [0xD3, 0x9C, 0x8F, 0x4A]; + + public static readonly byte[] Int32_Min = [0x80, 0x00, 0x00, 0x00]; + public static readonly byte[] Int32_0 = [0x00, 0x00, 0x00, 0x00]; + public static readonly byte[] Int32_1 = [0x00, 0x00, 0x00, 0x01]; + public static readonly byte[] Int32_2 = [0x00, 0x00, 0x00, 0x02]; + public static readonly byte[] Int32_3 = [0x00, 0x00, 0x00, 0x03]; + public static readonly byte[] Int32_4 = [0x00, 0x00, 0x00, 0x04]; + public static readonly byte[] Int32_5 = [0x00, 0x00, 0x00, 0x05]; + public static readonly byte[] Int32_6 = [0x00, 0x00, 0x00, 0x06]; + public static readonly byte[] Int32_7 = [0x00, 0x00, 0x00, 0x07]; + public static readonly byte[] Int32_8 = [0x00, 0x00, 0x00, 0x08]; + public static readonly byte[] Int32_9 = [0x00, 0x00, 0x00, 0x09]; + public static readonly byte[] Int32_Max = [0x7F, 0xFF, 0xFF, 0xFF]; + + public static readonly byte[] UInt64_0 = [0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00]; + public static readonly byte[] UInt64_1 = [0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01]; + public static readonly byte[] UInt64_2 = [0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02]; + public static readonly byte[] UInt64_3 = [0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03]; + public static readonly byte[] UInt64_4 = [0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04]; + public static readonly byte[] UInt64_5 = [0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05]; + public static readonly byte[] UInt64_6 = [0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06]; + public static readonly byte[] UInt64_7 = [0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07]; + public static readonly byte[] UInt64_8 = [0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08]; + public static readonly byte[] UInt64_9 = [0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x09]; + public static readonly byte[] UInt64_Max = [0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF]; + + public static readonly byte[] Int64_Min = [0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00]; + public static readonly byte[] Int64_0 = [0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00]; + public static readonly byte[] Int64_1 = [0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01]; + public static readonly byte[] Int64_2 = [0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02]; + public static readonly byte[] Int64_3 = [0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03]; + public static readonly byte[] Int64_4 = [0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04]; + public static readonly byte[] Int64_5 = [0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05]; + public static readonly byte[] Int64_6 = [0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06]; + public static readonly byte[] Int64_7 = [0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07]; + public static readonly byte[] Int64_8 = [0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08]; + public static readonly byte[] Int64_9 = [0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x09]; + public static readonly byte[] Int64_Max = [0x7F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF]; + + public static readonly byte[] Single_Min = [0xFF, 0x7F, 0xFF, 0xFF]; + public static readonly byte[] Single_0 = [0x00, 0x00, 0x00, 0x00]; + public static readonly byte[] Single_1 = [0x3F, 0x80, 0x00, 0x00]; + public static readonly byte[] Single_2 = [0x40, 0x00, 0x00, 0x00]; + public static readonly byte[] Single_3 = [0x40, 0x40, 0x00, 0x00]; + public static readonly byte[] Single_4 = [0x40, 0x80, 0x00, 0x00]; + public static readonly byte[] Single_5 = [0x40, 0xA0, 0x00, 0x00]; + public static readonly byte[] Single_6 = [0x40, 0xC0, 0x00, 0x00]; + public static readonly byte[] Single_7 = [0x40, 0xE0, 0x00, 0x00]; + public static readonly byte[] Single_8 = [0x41, 0x00, 0x00, 0x00]; + public static readonly byte[] Single_9 = [0x41, 0x10, 0x00, 0x00]; + public static readonly byte[] Single_Max = [0x7F, 0x7F, 0xFF, 0xFF]; + + public static readonly byte[] Double_Min = [0xFF, 0xEF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF]; + public static readonly byte[] Double_0 = [0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00]; + public static readonly byte[] Double_1 = [0x3F, 0xF0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00]; + public static readonly byte[] Double_Max = [0x7F, 0xEF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF]; public const float Fix16_ValMin = short.MinValue; public const float Fix16_ValMax = short.MaxValue + (65535f / 65536f); - public static readonly byte[] Fix16_Min = { 0x80, 0x00, 0x00, 0x00 }; - public static readonly byte[] Fix16_0 = { 0x00, 0x00, 0x00, 0x00 }; - public static readonly byte[] Fix16_1 = { 0x00, 0x01, 0x00, 0x00 }; - public static readonly byte[] Fix16_2 = { 0x00, 0x02, 0x00, 0x00 }; - public static readonly byte[] Fix16_3 = { 0x00, 0x03, 0x00, 0x00 }; - public static readonly byte[] Fix16_4 = { 0x00, 0x04, 0x00, 0x00 }; - public static readonly byte[] Fix16_5 = { 0x00, 0x05, 0x00, 0x00 }; - public static readonly byte[] Fix16_6 = { 0x00, 0x06, 0x00, 0x00 }; - public static readonly byte[] Fix16_7 = { 0x00, 0x07, 0x00, 0x00 }; - public static readonly byte[] Fix16_8 = { 0x00, 0x08, 0x00, 0x00 }; - public static readonly byte[] Fix16_9 = { 0x00, 0x09, 0x00, 0x00 }; - public static readonly byte[] Fix16_Max = { 0x7F, 0xFF, 0xFF, 0xFF }; + public static readonly byte[] Fix16_Min = [0x80, 0x00, 0x00, 0x00]; + public static readonly byte[] Fix16_0 = [0x00, 0x00, 0x00, 0x00]; + public static readonly byte[] Fix16_1 = [0x00, 0x01, 0x00, 0x00]; + public static readonly byte[] Fix16_2 = [0x00, 0x02, 0x00, 0x00]; + public static readonly byte[] Fix16_3 = [0x00, 0x03, 0x00, 0x00]; + public static readonly byte[] Fix16_4 = [0x00, 0x04, 0x00, 0x00]; + public static readonly byte[] Fix16_5 = [0x00, 0x05, 0x00, 0x00]; + public static readonly byte[] Fix16_6 = [0x00, 0x06, 0x00, 0x00]; + public static readonly byte[] Fix16_7 = [0x00, 0x07, 0x00, 0x00]; + public static readonly byte[] Fix16_8 = [0x00, 0x08, 0x00, 0x00]; + public static readonly byte[] Fix16_9 = [0x00, 0x09, 0x00, 0x00]; + public static readonly byte[] Fix16_Max = [0x7F, 0xFF, 0xFF, 0xFF]; public static readonly object[][] Fix16TestData = - { - new object[] { Fix16_Min, Fix16_ValMin }, - new object[] { Fix16_0, 0 }, - new object[] { Fix16_4, 4 }, - new object[] { Fix16_Max, Fix16_ValMax }, - }; + [ + [Fix16_Min, Fix16_ValMin], + [Fix16_0, 0], + [Fix16_4, 4], + [Fix16_Max, Fix16_ValMax] + ]; public const float UFix16_ValMin = 0; public const float UFix16_ValMax = ushort.MaxValue + (65535f / 65536f); - public static readonly byte[] UFix16_0 = { 0x00, 0x00, 0x00, 0x00 }; - public static readonly byte[] UFix16_1 = { 0x00, 0x01, 0x00, 0x00 }; - public static readonly byte[] UFix16_2 = { 0x00, 0x02, 0x00, 0x00 }; - public static readonly byte[] UFix16_3 = { 0x00, 0x03, 0x00, 0x00 }; - public static readonly byte[] UFix16_4 = { 0x00, 0x04, 0x00, 0x00 }; - public static readonly byte[] UFix16_5 = { 0x00, 0x05, 0x00, 0x00 }; - public static readonly byte[] UFix16_6 = { 0x00, 0x06, 0x00, 0x00 }; - public static readonly byte[] UFix16_7 = { 0x00, 0x07, 0x00, 0x00 }; - public static readonly byte[] UFix16_8 = { 0x00, 0x08, 0x00, 0x00 }; - public static readonly byte[] UFix16_9 = { 0x00, 0x09, 0x00, 0x00 }; - public static readonly byte[] UFix16_Max = { 0xFF, 0xFF, 0xFF, 0xFF }; + public static readonly byte[] UFix16_0 = [0x00, 0x00, 0x00, 0x00]; + public static readonly byte[] UFix16_1 = [0x00, 0x01, 0x00, 0x00]; + public static readonly byte[] UFix16_2 = [0x00, 0x02, 0x00, 0x00]; + public static readonly byte[] UFix16_3 = [0x00, 0x03, 0x00, 0x00]; + public static readonly byte[] UFix16_4 = [0x00, 0x04, 0x00, 0x00]; + public static readonly byte[] UFix16_5 = [0x00, 0x05, 0x00, 0x00]; + public static readonly byte[] UFix16_6 = [0x00, 0x06, 0x00, 0x00]; + public static readonly byte[] UFix16_7 = [0x00, 0x07, 0x00, 0x00]; + public static readonly byte[] UFix16_8 = [0x00, 0x08, 0x00, 0x00]; + public static readonly byte[] UFix16_9 = [0x00, 0x09, 0x00, 0x00]; + public static readonly byte[] UFix16_Max = [0xFF, 0xFF, 0xFF, 0xFF]; public static readonly object[][] UFix16TestData = - { - new object[] { UFix16_0, 0 }, - new object[] { UFix16_4, 4 }, - new object[] { UFix16_Max, UFix16_ValMax }, - }; + [ + [UFix16_0, 0], + [UFix16_4, 4], + [UFix16_Max, UFix16_ValMax] + ]; public const float U1Fix15_ValMin = 0; public const float U1Fix15_ValMax = 1f + (32767f / 32768f); - public static readonly byte[] U1Fix15_0 = { 0x00, 0x00 }; - public static readonly byte[] U1Fix15_1 = { 0x80, 0x00 }; - public static readonly byte[] U1Fix15_Max = { 0xFF, 0xFF }; + public static readonly byte[] U1Fix15_0 = [0x00, 0x00]; + public static readonly byte[] U1Fix15_1 = [0x80, 0x00]; + public static readonly byte[] U1Fix15_Max = [0xFF, 0xFF]; public static readonly object[][] U1Fix15TestData = - { - new object[] { U1Fix15_0, 0 }, - new object[] { U1Fix15_1, 1 }, - new object[] { U1Fix15_Max, U1Fix15_ValMax }, - }; + [ + [U1Fix15_0, 0], + [U1Fix15_1, 1], + [U1Fix15_Max, U1Fix15_ValMax] + ]; public const float UFix8_ValMin = 0; public const float UFix8_ValMax = byte.MaxValue + (255f / 256f); - public static readonly byte[] UFix8_0 = { 0x00, 0x00 }; - public static readonly byte[] UFix8_1 = { 0x01, 0x00 }; - public static readonly byte[] UFix8_2 = { 0x02, 0x00 }; - public static readonly byte[] UFix8_3 = { 0x03, 0x00 }; - public static readonly byte[] UFix8_4 = { 0x04, 0x00 }; - public static readonly byte[] UFix8_5 = { 0x05, 0x00 }; - public static readonly byte[] UFix8_6 = { 0x06, 0x00 }; - public static readonly byte[] UFix8_7 = { 0x07, 0x00 }; - public static readonly byte[] UFix8_8 = { 0x08, 0x00 }; - public static readonly byte[] UFix8_9 = { 0x09, 0x00 }; - public static readonly byte[] UFix8_Max = { 0xFF, 0xFF }; + public static readonly byte[] UFix8_0 = [0x00, 0x00]; + public static readonly byte[] UFix8_1 = [0x01, 0x00]; + public static readonly byte[] UFix8_2 = [0x02, 0x00]; + public static readonly byte[] UFix8_3 = [0x03, 0x00]; + public static readonly byte[] UFix8_4 = [0x04, 0x00]; + public static readonly byte[] UFix8_5 = [0x05, 0x00]; + public static readonly byte[] UFix8_6 = [0x06, 0x00]; + public static readonly byte[] UFix8_7 = [0x07, 0x00]; + public static readonly byte[] UFix8_8 = [0x08, 0x00]; + public static readonly byte[] UFix8_9 = [0x09, 0x00]; + public static readonly byte[] UFix8_Max = [0xFF, 0xFF]; public static readonly object[][] UFix8TestData = - { - new object[] { UFix8_0, 0 }, - new object[] { UFix8_4, 4 }, - new object[] { UFix8_Max, UFix8_ValMax }, - }; + [ + [UFix8_0, 0], + [UFix8_4, 4], + [UFix8_Max, UFix8_ValMax] + ]; public const string Ascii_ValRand = "aBcdEf1234"; public const string Ascii_ValRand1 = "Ecf3a"; @@ -199,14 +199,14 @@ internal static class IccTestDataPrimitives public const string Ascii_ValRandLength4 = "aBcd"; public const string Ascii_ValNullRand = "aBcd\0Ef\0123"; - public static readonly byte[] Ascii_Rand = { 97, 66, 99, 100, 69, 102, 49, 50, 51, 52 }; - public static readonly byte[] Ascii_Rand1 = { 69, 99, 102, 51, 97 }; - public static readonly byte[] Ascii_Rand2 = { 50, 66, 100, 52, 99 }; - public static readonly byte[] Ascii_Rand3 = { 99, 97, 100, 49, 52 }; - public static readonly byte[] Ascii_Rand4 = { 102, 100, 52, 69, 49 }; - public static readonly byte[] Ascii_RandLength4 = { 97, 66, 99, 100 }; - public static readonly byte[] Ascii_PaddedRand = { 97, 66, 99, 100, 69, 102, 49, 50, 51, 52, 0, 0, 0, 0 }; - public static readonly byte[] Ascii_NullRand = { 97, 66, 99, 100, 0, 69, 102, 0, 49, 50, 51 }; + public static readonly byte[] Ascii_Rand = [97, 66, 99, 100, 69, 102, 49, 50, 51, 52]; + public static readonly byte[] Ascii_Rand1 = [69, 99, 102, 51, 97]; + public static readonly byte[] Ascii_Rand2 = [50, 66, 100, 52, 99]; + public static readonly byte[] Ascii_Rand3 = [99, 97, 100, 49, 52]; + public static readonly byte[] Ascii_Rand4 = [102, 100, 52, 69, 49]; + public static readonly byte[] Ascii_RandLength4 = [97, 66, 99, 100]; + public static readonly byte[] Ascii_PaddedRand = [97, 66, 99, 100, 69, 102, 49, 50, 51, 52, 0, 0, 0, 0]; + public static readonly byte[] Ascii_NullRand = [97, 66, 99, 100, 0, 69, 102, 0, 49, 50, 51]; public const int Ascii_Rand_Length = 10; public const int Ascii_PaddedRand_Length = 14; @@ -214,30 +214,30 @@ internal static class IccTestDataPrimitives public const int Ascii_NullRand_LengthNoNull = 4; public static readonly object[][] AsciiTestData = - { - new object[] { Ascii_Rand, Ascii_Rand_Length, Ascii_ValRand }, - new object[] { Ascii_Rand, 4, Ascii_ValRandLength4 }, - new object[] { Ascii_NullRand, Ascii_NullRand_LengthNoNull, Ascii_ValRandLength4 }, - }; + [ + [Ascii_Rand, Ascii_Rand_Length, Ascii_ValRand], + [Ascii_Rand, 4, Ascii_ValRandLength4], + [Ascii_NullRand, Ascii_NullRand_LengthNoNull, Ascii_ValRandLength4] + ]; public static readonly object[][] AsciiWriteTestData = - { - new object[] { Ascii_Rand, Ascii_ValRand }, - new object[] { Ascii_NullRand, Ascii_ValNullRand }, - }; + [ + [Ascii_Rand, Ascii_ValRand], + [Ascii_NullRand, Ascii_ValNullRand] + ]; public static readonly object[][] AsciiPaddingTestData = - { - new object[] { Ascii_PaddedRand, Ascii_PaddedRand_Length, Ascii_ValRand, true }, - new object[] { Ascii_RandLength4, 4, Ascii_ValRand, false }, - }; + [ + [Ascii_PaddedRand, Ascii_PaddedRand_Length, Ascii_ValRand, true], + [Ascii_RandLength4, 4, Ascii_ValRand, false] + ]; public const string Unicode_ValRand1 = ".6Abäñ$€β𐐷𤭢"; public const string Unicode_ValRand2 = ".6Abäñ"; public const string Unicode_ValRand3 = "$€β𐐷𤭢"; public static readonly byte[] Unicode_Rand1 = - { + [ 0x00, 0x2e, // . 0x00, 0x36, // 6 0x00, 0x41, // A @@ -248,25 +248,25 @@ internal static class IccTestDataPrimitives 0x20, 0xAC, // € 0x03, 0xb2, // β 0xD8, 0x01, 0xDC, 0x37, // 𐐷 - 0xD8, 0x52, 0xDF, 0x62, // 𤭢 - }; + 0xD8, 0x52, 0xDF, 0x62 // 𤭢 + ]; public static readonly byte[] Unicode_Rand2 = - { + [ 0x00, 0x2e, // . 0x00, 0x36, // 6 0x00, 0x41, // A 0x00, 0x62, // b 0x00, 0xe4, // ä - 0x00, 0xf1, // ñ - }; + 0x00, 0xf1 // ñ + ]; public static readonly byte[] Unicode_Rand3 = - { + [ 0x00, 0x24, // $ 0x20, 0xAC, // € 0x03, 0xb2, // β 0xD8, 0x01, 0xDC, 0x37, // 𐐷 - 0xD8, 0x52, 0xDF, 0x62, // 𤭢 - }; + 0xD8, 0x52, 0xDF, 0x62 // 𤭢 + ]; } diff --git a/tests/ImageSharp.Tests/TestDataIcc/IccTestDataProfiles.cs b/tests/ImageSharp.Tests/TestDataIcc/IccTestDataProfiles.cs index 8fd6f7e4ae..a6cb9cede5 100644 --- a/tests/ImageSharp.Tests/TestDataIcc/IccTestDataProfiles.cs +++ b/tests/ImageSharp.Tests/TestDataIcc/IccTestDataProfiles.cs @@ -8,22 +8,22 @@ namespace SixLabors.ImageSharp.Tests; internal static class IccTestDataProfiles { - public static readonly IccProfileId Header_Random_Id_Value = new IccProfileId(0x84A8D460, 0xC716B6F3, 0x9B0E4C3D, 0xAB95F838); - public static readonly IccProfileId Profile_Random_Id_Value = new IccProfileId(0x917D6DE6, 0x84C958D1, 0x3BB0F5BB, 0xADD1134F); + public static readonly IccProfileId Header_Random_Id_Value = new(0x84A8D460, 0xC716B6F3, 0x9B0E4C3D, 0xAB95F838); + public static readonly IccProfileId Profile_Random_Id_Value = new(0x917D6DE6, 0x84C958D1, 0x3BB0F5BB, 0xADD1134F); public static readonly byte[] Header_Random_Id_Array = - { - 0x84, 0xA8, 0xD4, 0x60, 0xC7, 0x16, 0xB6, 0xF3, 0x9B, 0x0E, 0x4C, 0x3D, 0xAB, 0x95, 0xF8, 0x38, - }; + [ + 0x84, 0xA8, 0xD4, 0x60, 0xC7, 0x16, 0xB6, 0xF3, 0x9B, 0x0E, 0x4C, 0x3D, 0xAB, 0x95, 0xF8, 0x38 + ]; public static readonly byte[] Profile_Random_Id_Array = - { - 0x91, 0x7D, 0x6D, 0xE6, 0x84, 0xC9, 0x58, 0xD1, 0x3B, 0xB0, 0xF5, 0xBB, 0xAD, 0xD1, 0x13, 0x4F, - }; + [ + 0x91, 0x7D, 0x6D, 0xE6, 0x84, 0xC9, 0x58, 0xD1, 0x3B, 0xB0, 0xF5, 0xBB, 0xAD, 0xD1, 0x13, 0x4F + ]; public static readonly IccProfileHeader Header_Random_Write = CreateHeaderRandomValue( 562, // should be overwritten - new IccProfileId(1, 2, 3, 4), // should be overwritten + new(1, 2, 3, 4), // should be overwritten "ijkl"); // should be overwritten to "acsp" public static readonly IccProfileHeader Header_Random_Read = CreateHeaderRandomValue(132, Header_Random_Id_Value, "acsp"); @@ -32,11 +32,11 @@ internal static class IccTestDataProfiles public static IccProfileHeader CreateHeaderRandomValue(uint size, IccProfileId id, string fileSignature) { - return new IccProfileHeader + return new() { Class = IccProfileClass.DisplayDevice, CmmType = "abcd", - CreationDate = new DateTime(1990, 11, 26, 7, 21, 42), + CreationDate = new(1990, 11, 26, 7, 21, 42), CreatorSignature = "dcba", DataColorSpace = IccColorSpaceType.Rgb, DeviceAttributes = IccDeviceAttribute.ChromaBlackWhite | IccDeviceAttribute.OpacityTransparent, @@ -45,12 +45,12 @@ public static IccProfileHeader CreateHeaderRandomValue(uint size, IccProfileId i FileSignature = "acsp", Flags = IccProfileFlag.Embedded | IccProfileFlag.Independent, Id = id, - PcsIlluminant = new Vector3(4, 5, 6), + PcsIlluminant = new(4, 5, 6), PrimaryPlatformSignature = IccPrimaryPlatformType.MicrosoftCorporation, ProfileConnectionSpace = IccColorSpaceType.CieXyz, RenderingIntent = IccRenderingIntent.AbsoluteColorimetric, Size = size, - Version = new IccVersion(4, 3, 0), + Version = new(4, 3, 0), }; } @@ -107,15 +107,15 @@ public static byte[] CreateHeaderRandomArray(uint size, uint nrOfEntries, byte[] IccTestDataTagDataEntry.TagDataEntryHeader_UnknownArr, IccTestDataTagDataEntry.Unknown_Arr); - public static readonly IccProfile Profile_Random_Val = new IccProfile( + public static readonly IccProfile Profile_Random_Val = new( CreateHeaderRandomValue( 168, Profile_Random_Id_Value, "acsp"), - new IccTagDataEntry[] { IccTestDataTagDataEntry.Unknown_Val, IccTestDataTagDataEntry.Unknown_Val }); + [IccTestDataTagDataEntry.Unknown_Val, IccTestDataTagDataEntry.Unknown_Val]); public static readonly byte[] Header_CorruptDataColorSpace_Array = - { + [ 0x00, 0x00, 0x00, 0x80, // Size 0x61, 0x62, 0x63, 0x64, // CmmType 0x04, 0x30, 0x00, 0x00, // Version @@ -140,11 +140,11 @@ public static byte[] CreateHeaderRandomArray(uint size, uint nrOfEntries, byte[] 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, - }; + 0x00, 0x00, 0x00, 0x00 + ]; public static readonly byte[] Header_CorruptProfileConnectionSpace_Array = - { + [ 0x00, 0x00, 0x00, 0x80, // Size 0x62, 0x63, 0x64, 0x65, // CmmType 0x04, 0x30, 0x00, 0x00, // Version @@ -169,11 +169,11 @@ public static byte[] CreateHeaderRandomArray(uint size, uint nrOfEntries, byte[] 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, - }; + 0x00, 0x00, 0x00, 0x00 + ]; public static readonly byte[] Header_CorruptRenderingIntent_Array = - { + [ 0x00, 0x00, 0x00, 0x80, // Size 0x63, 0x64, 0x65, 0x66, // CmmType 0x04, 0x30, 0x00, 0x00, // Version @@ -198,8 +198,8 @@ public static byte[] CreateHeaderRandomArray(uint size, uint nrOfEntries, byte[] 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, - }; + 0x00, 0x00, 0x00, 0x00 + ]; public static readonly byte[] Header_DataTooSmall_Array = new byte[127]; @@ -210,20 +210,20 @@ public static byte[] CreateHeaderRandomArray(uint size, uint nrOfEntries, byte[] public static readonly byte[] Header_SizeBiggerThanData_Array = CreateHeaderRandomArray(160, 0, Header_Random_Id_Array); public static readonly object[][] ProfileIdTestData = - { - new object[] { Header_Random_Array, Header_Random_Id_Value }, - new object[] { Profile_Random_Array, Profile_Random_Id_Value }, - }; + [ + [Header_Random_Array, Header_Random_Id_Value], + [Profile_Random_Array, Profile_Random_Id_Value] + ]; public static readonly object[][] ProfileValidityTestData = - { - new object[] { Header_CorruptDataColorSpace_Array, false }, - new object[] { Header_CorruptProfileConnectionSpace_Array, false }, - new object[] { Header_CorruptRenderingIntent_Array, false }, - new object[] { Header_DataTooSmall_Array, false }, - new object[] { Header_InvalidSizeSmall_Array, false }, - new object[] { Header_InvalidSizeBig_Array, false }, - new object[] { Header_SizeBiggerThanData_Array, false }, - new object[] { Header_Random_Array, true }, - }; + [ + [Header_CorruptDataColorSpace_Array, false], + [Header_CorruptProfileConnectionSpace_Array, false], + [Header_CorruptRenderingIntent_Array, false], + [Header_DataTooSmall_Array, false], + [Header_InvalidSizeSmall_Array, false], + [Header_InvalidSizeBig_Array, false], + [Header_SizeBiggerThanData_Array, false], + [Header_Random_Array, true] + ]; } diff --git a/tests/ImageSharp.Tests/TestDataIcc/IccTestDataTagDataEntry.cs b/tests/ImageSharp.Tests/TestDataIcc/IccTestDataTagDataEntry.cs index 69d375cedf..e7d18b52f8 100644 --- a/tests/ImageSharp.Tests/TestDataIcc/IccTestDataTagDataEntry.cs +++ b/tests/ImageSharp.Tests/TestDataIcc/IccTestDataTagDataEntry.cs @@ -11,40 +11,40 @@ internal static class IccTestDataTagDataEntry { public static readonly IccTypeSignature TagDataEntryHeader_UnknownVal = IccTypeSignature.Unknown; public static readonly byte[] TagDataEntryHeader_UnknownArr = - { - 0x00, 0x00, 0x00, 0x00, + [ 0x00, 0x00, 0x00, 0x00, - }; + 0x00, 0x00, 0x00, 0x00 + ]; public static readonly IccTypeSignature TagDataEntryHeader_MultiLocalizedUnicodeVal = IccTypeSignature.MultiLocalizedUnicode; public static readonly byte[] TagDataEntryHeader_MultiLocalizedUnicodeArr = - { + [ 0x6D, 0x6C, 0x75, 0x63, - 0x00, 0x00, 0x00, 0x00, - }; + 0x00, 0x00, 0x00, 0x00 + ]; public static readonly IccTypeSignature TagDataEntryHeader_CurveVal = IccTypeSignature.Curve; public static readonly byte[] TagDataEntryHeader_CurveArr = - { + [ 0x63, 0x75, 0x72, 0x76, - 0x00, 0x00, 0x00, 0x00, - }; + 0x00, 0x00, 0x00, 0x00 + ]; public static readonly object[][] TagDataEntryHeaderTestData = - { - new object[] { TagDataEntryHeader_UnknownArr, TagDataEntryHeader_UnknownVal }, - new object[] { TagDataEntryHeader_MultiLocalizedUnicodeArr, TagDataEntryHeader_MultiLocalizedUnicodeVal }, - new object[] { TagDataEntryHeader_CurveArr, TagDataEntryHeader_CurveVal }, - }; + [ + [TagDataEntryHeader_UnknownArr, TagDataEntryHeader_UnknownVal], + [TagDataEntryHeader_MultiLocalizedUnicodeArr, TagDataEntryHeader_MultiLocalizedUnicodeVal], + [TagDataEntryHeader_CurveArr, TagDataEntryHeader_CurveVal] + ]; - public static readonly IccUnknownTagDataEntry Unknown_Val = new(new byte[] { 0x00, 0x01, 0x02, 0x03 }); + public static readonly IccUnknownTagDataEntry Unknown_Val = new([0x00, 0x01, 0x02, 0x03]); - public static readonly byte[] Unknown_Arr = { 0x00, 0x01, 0x02, 0x03 }; + public static readonly byte[] Unknown_Arr = [0x00, 0x01, 0x02, 0x03]; public static readonly object[][] UnknownTagDataEntryTestData = - { - new object[] { Unknown_Arr, Unknown_Val, 12u }, - }; + [ + [Unknown_Arr, Unknown_Val, 12u] + ]; public static readonly IccChromaticityTagDataEntry Chromaticity_Val1 = new(IccColorantEncoding.ItuRBt709_2); public static readonly byte[] Chromaticity_Arr1 = ArrayHelper.Concat( @@ -60,8 +60,7 @@ internal static class IccTestDataTagDataEntry public static readonly IccChromaticityTagDataEntry Chromaticity_Val2 = new( new double[][] { - new double[] { 1, 2 }, - new double[] { 3, 4 }, + [1, 2], [3, 4], }); public static readonly byte[] Chromaticity_Arr2 = ArrayHelper.Concat( @@ -87,25 +86,24 @@ internal static class IccTestDataTagDataEntry IccTestDataPrimitives.UInt16_9); public static readonly object[][] ChromaticityTagDataEntryTestData = - { - new object[] { Chromaticity_Arr1, Chromaticity_Val1 }, - new object[] { Chromaticity_Arr2, Chromaticity_Val2 }, - }; + [ + [Chromaticity_Arr1, Chromaticity_Val1], + [Chromaticity_Arr2, Chromaticity_Val2] + ]; - public static readonly IccColorantOrderTagDataEntry ColorantOrder_Val = new(new byte[] { 0x00, 0x01, 0x02 }); + public static readonly IccColorantOrderTagDataEntry ColorantOrder_Val = new([0x00, 0x01, 0x02]); public static readonly byte[] ColorantOrder_Arr = ArrayHelper.Concat(IccTestDataPrimitives.UInt32_3, new byte[] { 0x00, 0x01, 0x02 }); public static readonly object[][] ColorantOrderTagDataEntryTestData = - { - new object[] { ColorantOrder_Arr, ColorantOrder_Val }, - }; + [ + [ColorantOrder_Arr, ColorantOrder_Val] + ]; public static readonly IccColorantTableTagDataEntry ColorantTable_Val = new( - new IccColorantTableEntry[] - { - IccTestDataNonPrimitives.ColorantTableEntry_ValRand1, + [ + IccTestDataNonPrimitives.ColorantTableEntry_ValRand1, IccTestDataNonPrimitives.ColorantTableEntry_ValRand2 - }); + ]); public static readonly byte[] ColorantTable_Arr = ArrayHelper.Concat( IccTestDataPrimitives.UInt32_2, @@ -113,9 +111,9 @@ internal static class IccTestDataTagDataEntry IccTestDataNonPrimitives.ColorantTableEntry_Rand2); public static readonly object[][] ColorantTableTagDataEntryTestData = - { - new object[] { ColorantTable_Arr, ColorantTable_Val }, - }; + [ + [ColorantTable_Arr, ColorantTable_Val] + ]; public static readonly IccCurveTagDataEntry Curve_Val_0 = new(); public static readonly byte[] Curve_Arr_0 = IccTestDataPrimitives.UInt32_0; @@ -125,7 +123,7 @@ internal static class IccTestDataTagDataEntry IccTestDataPrimitives.UInt32_1, IccTestDataPrimitives.UFix8_1); - public static readonly IccCurveTagDataEntry Curve_Val_2 = new(new float[] { 1 / 65535f, 2 / 65535f, 3 / 65535f }); + public static readonly IccCurveTagDataEntry Curve_Val_2 = new([1 / 65535f, 2 / 65535f, 3 / 65535f]); public static readonly byte[] Curve_Arr_2 = ArrayHelper.Concat( IccTestDataPrimitives.UInt32_3, IccTestDataPrimitives.UInt16_1, @@ -133,50 +131,50 @@ internal static class IccTestDataTagDataEntry IccTestDataPrimitives.UInt16_3); public static readonly object[][] CurveTagDataEntryTestData = - { - new object[] { Curve_Arr_0, Curve_Val_0 }, - new object[] { Curve_Arr_1, Curve_Val_1 }, - new object[] { Curve_Arr_2, Curve_Val_2 }, - }; + [ + [Curve_Arr_0, Curve_Val_0], + [Curve_Arr_1, Curve_Val_1], + [Curve_Arr_2, Curve_Val_2] + ]; public static readonly IccDataTagDataEntry Data_ValNoASCII = new( - new byte[] { 0x01, 0x02, 0x03, 0x04 }, + [0x01, 0x02, 0x03, 0x04], false); public static readonly byte[] Data_ArrNoASCII = - { + [ 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x03, 0x04 - }; + ]; public static readonly IccDataTagDataEntry Data_ValASCII = new( - new byte[] { (byte)'A', (byte)'S', (byte)'C', (byte)'I', (byte)'I' }, + [(byte)'A', (byte)'S', (byte)'C', (byte)'I', (byte)'I'], true); public static readonly byte[] Data_ArrASCII = - { + [ 0x00, 0x00, 0x00, 0x01, (byte)'A', (byte)'S', (byte)'C', (byte)'I', (byte)'I' - }; + ]; public static readonly object[][] DataTagDataEntryTestData = - { - new object[] { Data_ArrNoASCII, Data_ValNoASCII, 16u }, - new object[] { Data_ArrASCII, Data_ValASCII, 17u }, - }; + [ + [Data_ArrNoASCII, Data_ValNoASCII, 16u], + [Data_ArrASCII, Data_ValASCII, 17u] + ]; public static readonly IccDateTimeTagDataEntry DateTime_Val = new(IccTestDataNonPrimitives.DateTime_ValRand1); public static readonly byte[] DateTime_Arr = IccTestDataNonPrimitives.DateTime_Rand1; public static readonly object[][] DateTimeTagDataEntryTestData = - { - new object[] { DateTime_Arr, DateTime_Val }, - }; + [ + [DateTime_Arr, DateTime_Val] + ]; public static readonly IccLut16TagDataEntry Lut16_Val = new( - new IccLut[] { IccTestDataLut.LUT16_ValGrad, IccTestDataLut.LUT16_ValGrad }, + [IccTestDataLut.LUT16_ValGrad, IccTestDataLut.LUT16_ValGrad], IccTestDataLut.CLUT16_ValGrad, - new IccLut[] { IccTestDataLut.LUT16_ValGrad, IccTestDataLut.LUT16_ValGrad, IccTestDataLut.LUT16_ValGrad }); + [IccTestDataLut.LUT16_ValGrad, IccTestDataLut.LUT16_ValGrad, IccTestDataLut.LUT16_ValGrad]); public static readonly byte[] Lut16_Arr = ArrayHelper.Concat( new byte[] { 0x02, 0x03, 0x03, 0x00 }, @@ -190,14 +188,14 @@ internal static class IccTestDataTagDataEntry IccTestDataLut.LUT16_Grad); public static readonly object[][] Lut16TagDataEntryTestData = - { - new object[] { Lut16_Arr, Lut16_Val }, - }; + [ + [Lut16_Arr, Lut16_Val] + ]; public static readonly IccLut8TagDataEntry Lut8_Val = new( - new IccLut[] { IccTestDataLut.LUT8_ValGrad, IccTestDataLut.LUT8_ValGrad }, + [IccTestDataLut.LUT8_ValGrad, IccTestDataLut.LUT8_ValGrad], IccTestDataLut.CLUT8_ValGrad, - new IccLut[] { IccTestDataLut.LUT8_ValGrad, IccTestDataLut.LUT8_ValGrad, IccTestDataLut.LUT8_ValGrad }); + [IccTestDataLut.LUT8_ValGrad, IccTestDataLut.LUT8_ValGrad, IccTestDataLut.LUT8_ValGrad]); public static readonly byte[] Lut8_Arr = ArrayHelper.Concat( new byte[] { 0x02, 0x03, 0x03, 0x00 }, @@ -210,9 +208,9 @@ internal static class IccTestDataTagDataEntry IccTestDataLut.LUT8_Grad); public static readonly object[][] Lut8TagDataEntryTestData = - { - new object[] { Lut8_Arr, Lut8_Val }, - }; + [ + [Lut8_Arr, Lut8_Val] + ]; private static readonly byte[] CurveFull_0 = ArrayHelper.Concat( TagDataEntryHeader_CurveArr, @@ -277,21 +275,20 @@ public static readonly IccLutAToBTagDataEntry LutAToB_Val new byte[] { 0x00, 0x00 }); // Padding public static readonly object[][] LutAToBTagDataEntryTestData = - { - new object[] { LutAToB_Arr, LutAToB_Val }, - }; + [ + [LutAToB_Arr, LutAToB_Val] + ]; public static readonly IccLutBToATagDataEntry LutBToA_Val = new( - new[] - { + [ Curve_Val_0, - Curve_Val_1, - }, + Curve_Val_1 + ], null, null, null, IccTestDataLut.CLUT_Val16, - new[] { Curve_Val_2, Curve_Val_1, Curve_Val_0 }); + [Curve_Val_2, Curve_Val_1, Curve_Val_0]); public static readonly byte[] LutBToA_Arr = ArrayHelper.Concat( new byte[] { 0x02, 0x03, 0x00, 0x00 }, @@ -318,9 +315,9 @@ public static readonly IccLutAToBTagDataEntry LutAToB_Val CurveFull_0); // 12 bytes public static readonly object[][] LutBToATagDataEntryTestData = - { - new object[] { LutBToA_Arr, LutBToA_Val }, - }; + [ + [LutBToA_Arr, LutBToA_Val] + ]; public static readonly IccMeasurementTagDataEntry Measurement_Val = new( IccStandardObserver.Cie1931Observer, @@ -337,9 +334,9 @@ public static readonly IccLutAToBTagDataEntry LutAToB_Val IccTestDataPrimitives.UInt32_1); public static readonly object[][] MeasurementTagDataEntryTestData = - { - new object[] { Measurement_Arr, Measurement_Val }, - }; + [ + [Measurement_Arr, Measurement_Val] + ]; private static readonly IccLocalizedString LocalizedString_Rand_enUS = CreateLocalizedString("en", "US", IccTestDataPrimitives.Unicode_ValRand2); private static readonly IccLocalizedString LocalizedString_Rand_deDE = CreateLocalizedString("de", "DE", IccTestDataPrimitives.Unicode_ValRand3); @@ -356,7 +353,7 @@ private static IccLocalizedString CreateLocalizedString(string language, string { try { - culture = new CultureInfo(language); + culture = new(language); } catch (CultureNotFoundException) { @@ -367,7 +364,7 @@ private static IccLocalizedString CreateLocalizedString(string language, string { try { - culture = new CultureInfo($"{language}-{country}"); + culture = new($"{language}-{country}"); } catch (CultureNotFoundException) { @@ -375,37 +372,37 @@ private static IccLocalizedString CreateLocalizedString(string language, string } } - return new IccLocalizedString(culture, text); + return new(culture, text); } - private static readonly IccLocalizedString[] LocalizedString_RandArr_enUS_deDE = new IccLocalizedString[] - { + private static readonly IccLocalizedString[] LocalizedString_RandArr_enUS_deDE = + [ LocalizedString_Rand_enUS, - LocalizedString_Rand_deDE, - }; + LocalizedString_Rand_deDE + ]; - private static readonly IccLocalizedString[] LocalizedString_RandArr_en_Invariant = new IccLocalizedString[] - { + private static readonly IccLocalizedString[] LocalizedString_RandArr_en_Invariant = + [ LocalizedString_Rand_en, - LocalizedString_Rand_Invariant, - }; + LocalizedString_Rand_Invariant + ]; - private static readonly IccLocalizedString[] LocalizedString_SameArr_enUS_deDE_esXL_xyXL = new IccLocalizedString[] - { + private static readonly IccLocalizedString[] LocalizedString_SameArr_enUS_deDE_esXL_xyXL = + [ LocalizedString_Rand_enUS, LocalizedString_Rand2_deDE, LocalizedString_Rand2_esXL, - LocalizedString_Rand2_xyXL, - }; + LocalizedString_Rand2_xyXL + ]; public static readonly IccMultiLocalizedUnicodeTagDataEntry MultiLocalizedUnicode_Val = new(LocalizedString_RandArr_enUS_deDE); public static readonly byte[] MultiLocalizedUnicode_Arr = ArrayHelper.Concat( IccTestDataPrimitives.UInt32_2, new byte[] { 0x00, 0x00, 0x00, 0x0C }, // 12 - new byte[] { (byte)'e', (byte)'n', (byte)'U', (byte)'S' }, + [(byte)'e', (byte)'n', (byte)'U', (byte)'S'], new byte[] { 0x00, 0x00, 0x00, 0x0C }, // 12 new byte[] { 0x00, 0x00, 0x00, 0x28 }, // 40 - new byte[] { (byte)'d', (byte)'e', (byte)'D', (byte)'E' }, + [(byte)'d', (byte)'e', (byte)'D', (byte)'E'], new byte[] { 0x00, 0x00, 0x00, 0x0E }, // 14 new byte[] { 0x00, 0x00, 0x00, 0x34 }, // 52 IccTestDataPrimitives.Unicode_Rand2, @@ -440,40 +437,39 @@ private static IccLocalizedString CreateLocalizedString(string language, string public static readonly byte[] MultiLocalizedUnicode_Arr3 = ArrayHelper.Concat( IccTestDataPrimitives.UInt32_4, new byte[] { 0x00, 0x00, 0x00, 0x0C }, // 12 - new byte[] { (byte)'e', (byte)'n', (byte)'U', (byte)'S' }, + [(byte)'e', (byte)'n', (byte)'U', (byte)'S'], new byte[] { 0x00, 0x00, 0x00, 0x0C }, // 12 new byte[] { 0x00, 0x00, 0x00, 0x40 }, // 64 - new byte[] { (byte)'d', (byte)'e', (byte)'D', (byte)'E' }, + [(byte)'d', (byte)'e', (byte)'D', (byte)'E'], new byte[] { 0x00, 0x00, 0x00, 0x0C }, // 12 new byte[] { 0x00, 0x00, 0x00, 0x40 }, // 64 - new byte[] { (byte)'e', (byte)'s', (byte)'X', (byte)'L' }, + [(byte)'e', (byte)'s', (byte)'X', (byte)'L'], new byte[] { 0x00, 0x00, 0x00, 0x0C }, // 12 new byte[] { 0x00, 0x00, 0x00, 0x40 }, // 64 - new byte[] { (byte)'x', (byte)'y', (byte)'X', (byte)'L' }, + [(byte)'x', (byte)'y', (byte)'X', (byte)'L'], new byte[] { 0x00, 0x00, 0x00, 0x0C }, // 12 new byte[] { 0x00, 0x00, 0x00, 0x40 }, // 64 IccTestDataPrimitives.Unicode_Rand2); public static readonly object[][] MultiLocalizedUnicodeTagDataEntryTestData_Read = - { - new object[] { MultiLocalizedUnicode_Arr, MultiLocalizedUnicode_Val }, - new object[] { MultiLocalizedUnicode_Arr2_Read, MultiLocalizedUnicode_Val2 }, - new object[] { MultiLocalizedUnicode_Arr3, MultiLocalizedUnicode_Val3 }, - }; + [ + [MultiLocalizedUnicode_Arr, MultiLocalizedUnicode_Val], + [MultiLocalizedUnicode_Arr2_Read, MultiLocalizedUnicode_Val2], + [MultiLocalizedUnicode_Arr3, MultiLocalizedUnicode_Val3] + ]; public static readonly object[][] MultiLocalizedUnicodeTagDataEntryTestData_Write = - { - new object[] { MultiLocalizedUnicode_Arr, MultiLocalizedUnicode_Val }, - new object[] { MultiLocalizedUnicode_Arr2_Write, MultiLocalizedUnicode_Val2 }, - new object[] { MultiLocalizedUnicode_Arr3, MultiLocalizedUnicode_Val3 }, - }; + [ + [MultiLocalizedUnicode_Arr, MultiLocalizedUnicode_Val], + [MultiLocalizedUnicode_Arr2_Write, MultiLocalizedUnicode_Val2], + [MultiLocalizedUnicode_Arr3, MultiLocalizedUnicode_Val3] + ]; public static readonly IccMultiProcessElementsTagDataEntry MultiProcessElements_Val = new( - new IccMultiProcessElement[] - { - IccTestDataMultiProcessElements.MPE_ValCLUT, - IccTestDataMultiProcessElements.MPE_ValCLUT, - }); + [ + IccTestDataMultiProcessElements.MPE_ValCLUT, + IccTestDataMultiProcessElements.MPE_ValCLUT + ]); public static readonly byte[] MultiProcessElements_Arr = ArrayHelper.Concat( IccTestDataPrimitives.UInt16_2, @@ -487,15 +483,15 @@ private static IccLocalizedString CreateLocalizedString(string language, string IccTestDataMultiProcessElements.MPE_CLUT); public static readonly object[][] MultiProcessElementsTagDataEntryTestData = - { - new object[] { MultiProcessElements_Arr, MultiProcessElements_Val }, - }; + [ + [MultiProcessElements_Arr, MultiProcessElements_Val] + ]; public static readonly IccNamedColor2TagDataEntry NamedColor2_Val = new( 16909060, ArrayHelper.Fill('A', 31), ArrayHelper.Fill('4', 31), - new IccNamedColor[] { IccTestDataNonPrimitives.NamedColor_ValMin, IccTestDataNonPrimitives.NamedColor_ValMin }); + [IccTestDataNonPrimitives.NamedColor_ValMin, IccTestDataNonPrimitives.NamedColor_ValMin]); public static readonly byte[] NamedColor2_Arr = ArrayHelper.Concat( new byte[] { 0x01, 0x02, 0x03, 0x04 }, @@ -509,24 +505,23 @@ private static IccLocalizedString CreateLocalizedString(string language, string IccTestDataNonPrimitives.NamedColor_Min); public static readonly object[][] NamedColor2TagDataEntryTestData = - { - new object[] { NamedColor2_Arr, NamedColor2_Val }, - }; + [ + [NamedColor2_Arr, NamedColor2_Val] + ]; public static readonly IccParametricCurveTagDataEntry ParametricCurve_Val = new(IccTestDataCurves.Parametric_ValVar1); public static readonly byte[] ParametricCurve_Arr = IccTestDataCurves.Parametric_Var1; public static readonly object[][] ParametricCurveTagDataEntryTestData = - { - new object[] { ParametricCurve_Arr, ParametricCurve_Val }, - }; + [ + [ParametricCurve_Arr, ParametricCurve_Val] + ]; public static readonly IccProfileSequenceDescTagDataEntry ProfileSequenceDesc_Val = new( - new IccProfileDescription[] - { - IccTestDataNonPrimitives.ProfileDescription_ValRand1, + [ + IccTestDataNonPrimitives.ProfileDescription_ValRand1, IccTestDataNonPrimitives.ProfileDescription_ValRand1 - }); + ]); public static readonly byte[] ProfileSequenceDesc_Arr = ArrayHelper.Concat( IccTestDataPrimitives.UInt32_2, @@ -534,16 +529,15 @@ private static IccLocalizedString CreateLocalizedString(string language, string IccTestDataNonPrimitives.ProfileDescription_Rand1); public static readonly object[][] ProfileSequenceDescTagDataEntryTestData = - { - new object[] { ProfileSequenceDesc_Arr, ProfileSequenceDesc_Val }, - }; + [ + [ProfileSequenceDesc_Arr, ProfileSequenceDesc_Val] + ]; public static readonly IccProfileSequenceIdentifierTagDataEntry ProfileSequenceIdentifier_Val = new( - new IccProfileSequenceIdentifier[] - { - new IccProfileSequenceIdentifier(IccTestDataNonPrimitives.ProfileId_ValRand, LocalizedString_RandArr_enUS_deDE), - new IccProfileSequenceIdentifier(IccTestDataNonPrimitives.ProfileId_ValRand, LocalizedString_RandArr_enUS_deDE), - }); + [ + new(IccTestDataNonPrimitives.ProfileId_ValRand, LocalizedString_RandArr_enUS_deDE), + new(IccTestDataNonPrimitives.ProfileId_ValRand, LocalizedString_RandArr_enUS_deDE) + ]); public static readonly byte[] ProfileSequenceIdentifier_Arr = ArrayHelper.Concat( IccTestDataPrimitives.UInt32_2, @@ -561,16 +555,15 @@ private static IccLocalizedString CreateLocalizedString(string language, string new byte[] { 0x00, 0x00 }); public static readonly object[][] ProfileSequenceIdentifierTagDataEntryTestData = - { - new object[] { ProfileSequenceIdentifier_Arr, ProfileSequenceIdentifier_Val }, - }; + [ + [ProfileSequenceIdentifier_Arr, ProfileSequenceIdentifier_Val] + ]; public static readonly IccResponseCurveSet16TagDataEntry ResponseCurveSet16_Val = new( - new IccResponseCurve[] - { - IccTestDataCurves.Response_ValGrad, - IccTestDataCurves.Response_ValGrad, - }); + [ + IccTestDataCurves.Response_ValGrad, + IccTestDataCurves.Response_ValGrad + ]); public static readonly byte[] ResponseCurveSet16_Arr = ArrayHelper.Concat( IccTestDataPrimitives.UInt16_3, @@ -581,88 +574,88 @@ private static IccLocalizedString CreateLocalizedString(string language, string IccTestDataCurves.Response_Grad); // 88 bytes public static readonly object[][] ResponseCurveSet16TagDataEntryTestData = - { - new object[] { ResponseCurveSet16_Arr, ResponseCurveSet16_Val }, - }; + [ + [ResponseCurveSet16_Arr, ResponseCurveSet16_Val] + ]; - public static readonly IccFix16ArrayTagDataEntry Fix16Array_Val = new(new float[] { 1 / 256f, 2 / 256f, 3 / 256f }); + public static readonly IccFix16ArrayTagDataEntry Fix16Array_Val = new([1 / 256f, 2 / 256f, 3 / 256f]); public static readonly byte[] Fix16Array_Arr = ArrayHelper.Concat( IccTestDataPrimitives.Fix16_1, IccTestDataPrimitives.Fix16_2, IccTestDataPrimitives.Fix16_3); public static readonly object[][] Fix16ArrayTagDataEntryTestData = - { - new object[] { Fix16Array_Arr, Fix16Array_Val, 20u }, - }; + [ + [Fix16Array_Arr, Fix16Array_Val, 20u] + ]; public static readonly IccSignatureTagDataEntry Signature_Val = new("ABCD"); - public static readonly byte[] Signature_Arr = { 0x41, 0x42, 0x43, 0x44, }; + public static readonly byte[] Signature_Arr = [0x41, 0x42, 0x43, 0x44]; public static readonly object[][] SignatureTagDataEntryTestData = - { - new object[] { Signature_Arr, Signature_Val }, - }; + [ + [Signature_Arr, Signature_Val] + ]; public static readonly IccTextTagDataEntry Text_Val = new("ABCD"); - public static readonly byte[] Text_Arr = { 0x41, 0x42, 0x43, 0x44 }; + public static readonly byte[] Text_Arr = [0x41, 0x42, 0x43, 0x44]; public static readonly object[][] TextTagDataEntryTestData = - { - new object[] { Text_Arr, Text_Val, 12u }, - }; + [ + [Text_Arr, Text_Val, 12u] + ]; - public static readonly IccUFix16ArrayTagDataEntry UFix16Array_Val = new(new float[] { 1, 2, 3 }); + public static readonly IccUFix16ArrayTagDataEntry UFix16Array_Val = new([1, 2, 3]); public static readonly byte[] UFix16Array_Arr = ArrayHelper.Concat( IccTestDataPrimitives.UFix16_1, IccTestDataPrimitives.UFix16_2, IccTestDataPrimitives.UFix16_3); public static readonly object[][] UFix16ArrayTagDataEntryTestData = - { - new object[] { UFix16Array_Arr, UFix16Array_Val, 20u }, - }; + [ + [UFix16Array_Arr, UFix16Array_Val, 20u] + ]; - public static readonly IccUInt16ArrayTagDataEntry UInt16Array_Val = new(new ushort[] { 1, 2, 3 }); + public static readonly IccUInt16ArrayTagDataEntry UInt16Array_Val = new([1, 2, 3]); public static readonly byte[] UInt16Array_Arr = ArrayHelper.Concat( IccTestDataPrimitives.UInt16_1, IccTestDataPrimitives.UInt16_2, IccTestDataPrimitives.UInt16_3); public static readonly object[][] UInt16ArrayTagDataEntryTestData = - { - new object[] { UInt16Array_Arr, UInt16Array_Val, 14u }, - }; + [ + [UInt16Array_Arr, UInt16Array_Val, 14u] + ]; - public static readonly IccUInt32ArrayTagDataEntry UInt32Array_Val = new(new uint[] { 1, 2, 3 }); + public static readonly IccUInt32ArrayTagDataEntry UInt32Array_Val = new([1, 2, 3]); public static readonly byte[] UInt32Array_Arr = ArrayHelper.Concat( IccTestDataPrimitives.UInt32_1, IccTestDataPrimitives.UInt32_2, IccTestDataPrimitives.UInt32_3); public static readonly object[][] UInt32ArrayTagDataEntryTestData = - { - new object[] { UInt32Array_Arr, UInt32Array_Val, 20u }, - }; + [ + [UInt32Array_Arr, UInt32Array_Val, 20u] + ]; - public static readonly IccUInt64ArrayTagDataEntry UInt64Array_Val = new(new ulong[] { 1, 2, 3 }); + public static readonly IccUInt64ArrayTagDataEntry UInt64Array_Val = new([1, 2, 3]); public static readonly byte[] UInt64Array_Arr = ArrayHelper.Concat( IccTestDataPrimitives.UInt64_1, IccTestDataPrimitives.UInt64_2, IccTestDataPrimitives.UInt64_3); public static readonly object[][] UInt64ArrayTagDataEntryTestData = - { - new object[] { UInt64Array_Arr, UInt64Array_Val, 32u }, - }; + [ + [UInt64Array_Arr, UInt64Array_Val, 32u] + ]; - public static readonly IccUInt8ArrayTagDataEntry UInt8Array_Val = new(new byte[] { 1, 2, 3 }); - public static readonly byte[] UInt8Array_Arr = { 1, 2, 3 }; + public static readonly IccUInt8ArrayTagDataEntry UInt8Array_Val = new([1, 2, 3]); + public static readonly byte[] UInt8Array_Arr = [1, 2, 3]; public static readonly object[][] UInt8ArrayTagDataEntryTestData = - { - new object[] { UInt8Array_Arr, UInt8Array_Val, 11u }, - }; + [ + [UInt8Array_Arr, UInt8Array_Val, 11u] + ]; public static readonly IccViewingConditionsTagDataEntry ViewingConditions_Val = new( IccTestDataNonPrimitives.XyzNumber_ValVar1, @@ -675,16 +668,15 @@ private static IccLocalizedString CreateLocalizedString(string language, string IccTestDataPrimitives.UInt32_1); public static readonly object[][] ViewingConditionsTagDataEntryTestData = - { - new object[] { ViewingConditions_Arr, ViewingConditions_Val }, - }; + [ + [ViewingConditions_Arr, ViewingConditions_Val] + ]; - public static readonly IccXyzTagDataEntry XYZ_Val = new(new Vector3[] - { + public static readonly IccXyzTagDataEntry XYZ_Val = new([ IccTestDataNonPrimitives.XyzNumber_ValVar1, IccTestDataNonPrimitives.XyzNumber_ValVar2, - IccTestDataNonPrimitives.XyzNumber_ValVar3, - }); + IccTestDataNonPrimitives.XyzNumber_ValVar3 + ]); public static readonly byte[] XYZ_Arr = ArrayHelper.Concat( IccTestDataNonPrimitives.XyzNumber_Var1, @@ -692,9 +684,9 @@ private static IccLocalizedString CreateLocalizedString(string language, string IccTestDataNonPrimitives.XyzNumber_Var3); public static readonly object[][] XYZTagDataEntryTestData = - { - new object[] { XYZ_Arr, XYZ_Val, 44u }, - }; + [ + [XYZ_Arr, XYZ_Val, 44u] + ]; public static readonly IccTextDescriptionTagDataEntry TextDescription_Val1 = new( IccTestDataPrimitives.Ascii_ValRand, @@ -726,10 +718,10 @@ private static IccLocalizedString CreateLocalizedString(string language, string ArrayHelper.Fill((byte)0x00, 67)); public static readonly object[][] TextDescriptionTagDataEntryTestData = - { - new object[] { TextDescription_Arr1, TextDescription_Val1 }, - new object[] { TextDescription_Arr2, TextDescription_Val2 }, - }; + [ + [TextDescription_Arr1, TextDescription_Val1], + [TextDescription_Arr2, TextDescription_Val2] + ]; public static readonly IccCrdInfoTagDataEntry CrdInfo_Val = new( IccTestDataPrimitives.Ascii_ValRand4, @@ -756,13 +748,13 @@ private static IccLocalizedString CreateLocalizedString(string language, string new byte[] { 0 }); public static readonly object[][] CrdInfoTagDataEntryTestData = - { - new object[] { CrdInfo_Arr, CrdInfo_Val }, - }; + [ + [CrdInfo_Arr, CrdInfo_Val] + ]; public static readonly IccScreeningTagDataEntry Screening_Val = new( IccScreeningFlag.DefaultScreens | IccScreeningFlag.UnitLinesPerCm, - new IccScreeningChannel[] { IccTestDataNonPrimitives.ScreeningChannel_ValRand1, IccTestDataNonPrimitives.ScreeningChannel_ValRand2 }); + [IccTestDataNonPrimitives.ScreeningChannel_ValRand1, IccTestDataNonPrimitives.ScreeningChannel_ValRand2]); public static readonly byte[] Screening_Arr = ArrayHelper.Concat( IccTestDataPrimitives.Int32_1, @@ -771,13 +763,13 @@ private static IccLocalizedString CreateLocalizedString(string language, string IccTestDataNonPrimitives.ScreeningChannel_Rand2); public static readonly object[][] ScreeningTagDataEntryTestData = - { - new object[] { Screening_Arr, Screening_Val }, - }; + [ + [Screening_Arr, Screening_Val] + ]; public static readonly IccUcrBgTagDataEntry UcrBg_Val = new( - new ushort[] { 3, 4, 6 }, - new ushort[] { 9, 7, 2, 5 }, + [3, 4, 6], + [9, 7, 2, 5], IccTestDataPrimitives.Ascii_ValRand); public static readonly byte[] UcrBg_Arr = ArrayHelper.Concat( @@ -794,9 +786,9 @@ private static IccLocalizedString CreateLocalizedString(string language, string new byte[] { 0 }); public static readonly object[][] UcrBgTagDataEntryTestData = - { - new object[] { UcrBg_Arr, UcrBg_Val, 41 }, - }; + [ + [UcrBg_Arr, UcrBg_Val, 41] + ]; public static readonly IccTagDataEntry TagDataEntry_CurveVal = Curve_Val_2; public static readonly byte[] TagDataEntry_CurveArr = ArrayHelper.Concat( @@ -818,8 +810,8 @@ private static IccLocalizedString CreateLocalizedString(string language, string public static readonly IccTagTableEntry TagDataEntry_CurveTable = new(IccProfileTag.Unknown, 0, (uint)TagDataEntry_CurveArr.Length - 2); public static readonly object[][] TagDataEntryTestData = - { - new object[] { TagDataEntry_CurveArr, TagDataEntry_CurveVal }, - new object[] { TagDataEntry_MultiLocalizedUnicodeArr, TagDataEntry_MultiLocalizedUnicodeVal }, - }; + [ + [TagDataEntry_CurveArr, TagDataEntry_CurveVal], + [TagDataEntry_MultiLocalizedUnicodeArr, TagDataEntry_MultiLocalizedUnicodeVal] + ]; } diff --git a/tests/ImageSharp.Tests/TestFile.cs b/tests/ImageSharp.Tests/TestFile.cs index a53e508067..01c5fdae3b 100644 --- a/tests/ImageSharp.Tests/TestFile.cs +++ b/tests/ImageSharp.Tests/TestFile.cs @@ -79,7 +79,7 @@ public static string GetInputFileFullPath(string file) /// The . /// public static TestFile Create(string file) - => Cache.GetOrAdd(file, (string fileName) => new TestFile(GetInputFileFullPath(fileName))); + => Cache.GetOrAdd(file, (string fileName) => new(GetInputFileFullPath(fileName))); /// /// Gets the file name. diff --git a/tests/ImageSharp.Tests/TestFontUtilities.cs b/tests/ImageSharp.Tests/TestFontUtilities.cs index 01b1faa45a..6e14274a93 100644 --- a/tests/ImageSharp.Tests/TestFontUtilities.cs +++ b/tests/ImageSharp.Tests/TestFontUtilities.cs @@ -37,13 +37,13 @@ public static string GetPath(string file) /// private static string GetFontsDirectory() { - List directories = new List - { - "TestFonts/", // Here for code coverage tests. - "tests/ImageSharp.Tests/TestFonts/", // from travis/build script - "../../../../../ImageSharp.Tests/TestFonts/", // from Sandbox46 - "../../../../TestFonts/" - }; + List directories = + [ + "TestFonts/", // Here for code coverage tests. + "tests/ImageSharp.Tests/TestFonts/", // from travis/build script + "../../../../../ImageSharp.Tests/TestFonts/", // from Sandbox46 + "../../../../TestFonts/" + ]; directories = directories.SelectMany(x => new[] { @@ -59,7 +59,7 @@ private static string GetFontsDirectory() return directory; } - throw new System.Exception($"Unable to find Fonts directory at any of these locations [{string.Join(", ", directories)}]"); + throw new($"Unable to find Fonts directory at any of these locations [{string.Join(", ", directories)}]"); } /// diff --git a/tests/ImageSharp.Tests/TestFormat.cs b/tests/ImageSharp.Tests/TestFormat.cs index d30ce7846d..8f0ec7ea81 100644 --- a/tests/ImageSharp.Tests/TestFormat.cs +++ b/tests/ImageSharp.Tests/TestFormat.cs @@ -24,11 +24,11 @@ public class TestFormat : IImageFormatConfigurationModule, IImageFormat public TestFormat() { - this.Encoder = new TestEncoder(this); - this.Decoder = new TestDecoder(this); + this.Encoder = new(this); + this.Decoder = new(this); } - public List DecodeCalls { get; } = new(); + public List DecodeCalls { get; } = []; public TestEncoder Encoder { get; } @@ -38,7 +38,7 @@ public TestFormat() public MemoryStream CreateStream(byte[] marker = null) { - var ms = new MemoryStream(); + MemoryStream ms = new(); byte[] data = this.header; ms.Write(data, 0, data.Length); if (marker != null) @@ -54,7 +54,7 @@ public Stream CreateAsyncSemaphoreStream(SemaphoreSlim notifyWaitPositionReached { byte[] buffer = new byte[size]; this.header.CopyTo(buffer, 0); - var semaphoreStream = new SemaphoreReadMemoryStream(buffer, waitAfterPosition, notifyWaitPositionReachedSemaphore, continueSemaphore); + SemaphoreReadMemoryStream semaphoreStream = new(buffer, waitAfterPosition, notifyWaitPositionReachedSemaphore, continueSemaphore); return seeakable ? semaphoreStream : new AsyncStreamWrapper(semaphoreStream, () => false); } @@ -103,7 +103,7 @@ public Image Sample() public string Extension => "test_ext"; - public IEnumerable SupportedExtensions => new[] { "test_ext" }; + public IEnumerable SupportedExtensions => ["test_ext"]; public int HeaderSize => this.header.Length; @@ -111,7 +111,7 @@ public Image Sample() public string DefaultMimeType => this.MimeType; - public IEnumerable MimeTypes => new[] { this.MimeType }; + public IEnumerable MimeTypes => [this.MimeType]; public IEnumerable FileExtensions => this.SupportedExtensions; @@ -193,7 +193,7 @@ public class TestDecoder : SpecializedImageDecoder public TestDecoder(TestFormat testFormat) => this.testFormat = testFormat; - public IEnumerable MimeTypes => new[] { this.testFormat.MimeType }; + public IEnumerable MimeTypes => [this.testFormat.MimeType]; public IEnumerable FileExtensions => this.testFormat.SupportedExtensions; @@ -220,7 +220,7 @@ protected override Image Decode(TestDecoderOptions options, Stre using MemoryStream ms = new(); stream.CopyTo(ms, configuration.StreamProcessingBufferSize); byte[] marker = ms.ToArray().Skip(this.testFormat.header.Length).ToArray(); - this.testFormat.DecodeCalls.Add(new DecodeOperation + this.testFormat.DecodeCalls.Add(new() { Marker = marker, Config = configuration, @@ -246,7 +246,7 @@ public class TestEncoder : IImageEncoder public TestEncoder(TestFormat testFormat) => this.testFormat = testFormat; - public IEnumerable MimeTypes => new[] { this.testFormat.MimeType }; + public IEnumerable MimeTypes => [this.testFormat.MimeType]; public IEnumerable FileExtensions => this.testFormat.SupportedExtensions; diff --git a/tests/ImageSharp.Tests/TestImages.cs b/tests/ImageSharp.Tests/TestImages.cs index 13f72a6345..71d16fb823 100644 --- a/tests/ImageSharp.Tests/TestImages.cs +++ b/tests/ImageSharp.Tests/TestImages.cs @@ -215,7 +215,7 @@ public static class Bad public const string ExifUndefType = "Jpg/progressive/ExifUndefType.jpg"; } - public static readonly string[] All = { Fb, Progress, Festzug }; + public static readonly string[] All = [Fb, Progress, Festzug]; } public static class Baseline @@ -271,12 +271,12 @@ public static class Bad public const string ArithmeticCodingWithRestart = "Jpg/baseline/Calliphora-arithmetic-restart.jpg"; public static readonly string[] All = - { + [ Cmyk, Ycck, Exif, Floorplan, Calliphora, Turtle420, GammaDalaiLamaGray, Hiyamugi, Jpeg400, Jpeg420Exif, Jpeg444, Ratio1x1, Testorig12bit, YcckSubsample1222 - }; + ]; } public static class Issues @@ -453,24 +453,24 @@ public static class Bmp public const string BlackWhitePalletDataMatrix = "Bmp/bit1datamatrix.bmp"; public static readonly string[] BitFields = - { - Rgb32bfdef, + [ + Rgb32bfdef, Rgb32bf, Rgb16565, Rgb16bfdef, Rgb16565pal, - Issue735, - }; + Issue735 + ]; public static readonly string[] Miscellaneous = - { + [ Car, F, NegHeight - }; + ]; public static readonly string[] Benchmark = - { + [ Car, F, NegHeight, @@ -487,7 +487,7 @@ public static class Bmp Bit16, Bit16Inverted, Bit32Rgb - }; + ]; } public static class Gif @@ -539,7 +539,7 @@ public static class Issues } public static readonly string[] Animated = - { + [ M4nb, Giphy, Cheers, @@ -558,7 +558,7 @@ public static class Issues Issues.Issue1530, Bit18RGBCube, Global256NoTrans - }; + ]; } public static class Tga @@ -1073,9 +1073,10 @@ public static class Tiff public const string InvalidIptcData = "Tiff/7324fcaff3aad96f27899da51c1bb5d9.tiff"; public const string IptcData = "Tiff/iptc.tiff"; - public static readonly string[] Multiframes = { MultiframeDeflateWithPreview, MultiframeLzwPredictor /*, MultiFrameDifferentSize, MultiframeDifferentSizeTiled, MultiFrameDifferentVariants,*/ }; + public static readonly string[] Multiframes = [MultiframeDeflateWithPreview, MultiframeLzwPredictor /*, MultiFrameDifferentSize, MultiframeDifferentSizeTiled, MultiFrameDifferentVariants,*/ + ]; - public static readonly string[] Metadata = { SampleMetadata }; + public static readonly string[] Metadata = [SampleMetadata]; } public static class BigTiff diff --git a/tests/ImageSharp.Tests/TestUtilities/ArrayHelper.cs b/tests/ImageSharp.Tests/TestUtilities/ArrayHelper.cs index 8ff2abd90b..90a98d1c81 100644 --- a/tests/ImageSharp.Tests/TestUtilities/ArrayHelper.cs +++ b/tests/ImageSharp.Tests/TestUtilities/ArrayHelper.cs @@ -13,7 +13,7 @@ public static class ArrayHelper /// The concatenated array public static T[] Concat(params T[][] arrays) { - var result = new T[arrays.Sum(t => t.Length)]; + T[] result = new T[arrays.Sum(t => t.Length)]; int offset = 0; for (int i = 0; i < arrays.Length; i++) { @@ -33,7 +33,7 @@ public static T[] Concat(params T[][] arrays) /// The created array filled with the given value public static T[] Fill(T value, int length) { - var result = new T[length]; + T[] result = new T[length]; for (int i = 0; i < length; i++) { result[i] = value; diff --git a/tests/ImageSharp.Tests/TestUtilities/Attributes/ImageDataAttributeBase.cs b/tests/ImageSharp.Tests/TestUtilities/Attributes/ImageDataAttributeBase.cs index 592ebb4ebe..7191f3ba74 100644 --- a/tests/ImageSharp.Tests/TestUtilities/Attributes/ImageDataAttributeBase.cs +++ b/tests/ImageSharp.Tests/TestUtilities/Attributes/ImageDataAttributeBase.cs @@ -70,7 +70,7 @@ public override IEnumerable GetData(MethodInfo testMethod) if (!addedRows.Any()) { - addedRows = new[] { Array.Empty() }; + addedRows = [[]]; } bool firstIsProvider = this.FirstIsProvider(testMethod); diff --git a/tests/ImageSharp.Tests/TestUtilities/Attributes/WithBasicTestPatternImagesAttribute.cs b/tests/ImageSharp.Tests/TestUtilities/Attributes/WithBasicTestPatternImagesAttribute.cs index d82d5cd910..349db60f20 100644 --- a/tests/ImageSharp.Tests/TestUtilities/Attributes/WithBasicTestPatternImagesAttribute.cs +++ b/tests/ImageSharp.Tests/TestUtilities/Attributes/WithBasicTestPatternImagesAttribute.cs @@ -31,5 +31,6 @@ public WithBasicTestPatternImagesAttribute(string memberData, int width, int hei protected override string GetFactoryMethodName(MethodInfo testMethod) => "BasicTestPattern"; - protected override object[] GetFactoryMethodArgs(MethodInfo testMethod, Type factoryType) => new object[] { this.Width, this.Height }; + protected override object[] GetFactoryMethodArgs(MethodInfo testMethod, Type factoryType) => [this.Width, this.Height + ]; } diff --git a/tests/ImageSharp.Tests/TestUtilities/Attributes/WithBlankImagesAttribute.cs b/tests/ImageSharp.Tests/TestUtilities/Attributes/WithBlankImagesAttribute.cs index e9f57a7abe..ec637a7b6b 100644 --- a/tests/ImageSharp.Tests/TestUtilities/Attributes/WithBlankImagesAttribute.cs +++ b/tests/ImageSharp.Tests/TestUtilities/Attributes/WithBlankImagesAttribute.cs @@ -46,5 +46,6 @@ public WithBlankImagesAttribute(string memberData, int width, int height, PixelT protected override string GetFactoryMethodName(MethodInfo testMethod) => "Blank"; - protected override object[] GetFactoryMethodArgs(MethodInfo testMethod, Type factoryType) => new object[] { this.Width, this.Height }; + protected override object[] GetFactoryMethodArgs(MethodInfo testMethod, Type factoryType) => [this.Width, this.Height + ]; } diff --git a/tests/ImageSharp.Tests/TestUtilities/Attributes/WithFileAttribute.cs b/tests/ImageSharp.Tests/TestUtilities/Attributes/WithFileAttribute.cs index cf472699a7..3392d97ab9 100644 --- a/tests/ImageSharp.Tests/TestUtilities/Attributes/WithFileAttribute.cs +++ b/tests/ImageSharp.Tests/TestUtilities/Attributes/WithFileAttribute.cs @@ -39,7 +39,7 @@ public WithFileAttribute(string fileName, string dataMemberName, PixelTypes pixe this.fileName = fileName; } - protected override object[] GetFactoryMethodArgs(MethodInfo testMethod, Type factoryType) => new object[] { this.fileName }; + protected override object[] GetFactoryMethodArgs(MethodInfo testMethod, Type factoryType) => [this.fileName]; protected override string GetFactoryMethodName(MethodInfo testMethod) => "File"; } diff --git a/tests/ImageSharp.Tests/TestUtilities/Attributes/WithFileCollectionAttribute.cs b/tests/ImageSharp.Tests/TestUtilities/Attributes/WithFileCollectionAttribute.cs index 57949e7b11..87f6f0479d 100644 --- a/tests/ImageSharp.Tests/TestUtilities/Attributes/WithFileCollectionAttribute.cs +++ b/tests/ImageSharp.Tests/TestUtilities/Attributes/WithFileCollectionAttribute.cs @@ -58,7 +58,7 @@ protected override IEnumerable GetAllFactoryMethodArgs(MethodInfo test Func accessor = this.GetPropertyAccessor(testMethod.DeclaringType, this.fileEnumeratorMemberName); accessor = accessor ?? this.GetFieldAccessor(testMethod.DeclaringType, this.fileEnumeratorMemberName); - var files = (IEnumerable)accessor(); + IEnumerable files = (IEnumerable)accessor(); return files.Select(f => new object[] { f }); } diff --git a/tests/ImageSharp.Tests/TestUtilities/Attributes/WithMemberFactoryAttribute.cs b/tests/ImageSharp.Tests/TestUtilities/Attributes/WithMemberFactoryAttribute.cs index cd27eaf0ba..59c092b409 100644 --- a/tests/ImageSharp.Tests/TestUtilities/Attributes/WithMemberFactoryAttribute.cs +++ b/tests/ImageSharp.Tests/TestUtilities/Attributes/WithMemberFactoryAttribute.cs @@ -29,7 +29,7 @@ public WithMemberFactoryAttribute(string memberMethodName, PixelTypes pixelTypes protected override object[] GetFactoryMethodArgs(MethodInfo testMethod, Type factoryType) { - return new object[] { testMethod.DeclaringType.FullName, this.memberMethodName }; + return [testMethod.DeclaringType.FullName, this.memberMethodName]; } protected override string GetFactoryMethodName(MethodInfo testMethod) => "Lambda"; diff --git a/tests/ImageSharp.Tests/TestUtilities/Attributes/WithSolidFilledImagesAttribute.cs b/tests/ImageSharp.Tests/TestUtilities/Attributes/WithSolidFilledImagesAttribute.cs index a4149f7356..cc4f6f7f3c 100644 --- a/tests/ImageSharp.Tests/TestUtilities/Attributes/WithSolidFilledImagesAttribute.cs +++ b/tests/ImageSharp.Tests/TestUtilities/Attributes/WithSolidFilledImagesAttribute.cs @@ -160,7 +160,7 @@ public WithSolidFilledImagesAttribute( public byte A { get; } protected override object[] GetFactoryMethodArgs(MethodInfo testMethod, Type factoryType) - => new object[] { this.Width, this.Height, this.R, this.G, this.B, this.A }; + => [this.Width, this.Height, this.R, this.G, this.B, this.A]; protected override string GetFactoryMethodName(MethodInfo testMethod) => "Solid"; } diff --git a/tests/ImageSharp.Tests/TestUtilities/Attributes/WithTestPatternImagesAttribute.cs b/tests/ImageSharp.Tests/TestUtilities/Attributes/WithTestPatternImagesAttribute.cs index 4b016d5eae..2630acea80 100644 --- a/tests/ImageSharp.Tests/TestUtilities/Attributes/WithTestPatternImagesAttribute.cs +++ b/tests/ImageSharp.Tests/TestUtilities/Attributes/WithTestPatternImagesAttribute.cs @@ -50,5 +50,6 @@ public WithTestPatternImagesAttribute(string memberData, int width, int height, protected override string GetFactoryMethodName(MethodInfo testMethod) => "TestPattern"; - protected override object[] GetFactoryMethodArgs(MethodInfo testMethod, Type factoryType) => new object[] { this.Width, this.Height }; + protected override object[] GetFactoryMethodArgs(MethodInfo testMethod, Type factoryType) => [this.Width, this.Height + ]; } diff --git a/tests/ImageSharp.Tests/TestUtilities/ByteArrayUtility.cs b/tests/ImageSharp.Tests/TestUtilities/ByteArrayUtility.cs index 963c3c7835..2fb75444e3 100644 --- a/tests/ImageSharp.Tests/TestUtilities/ByteArrayUtility.cs +++ b/tests/ImageSharp.Tests/TestUtilities/ByteArrayUtility.cs @@ -11,7 +11,7 @@ public static byte[] WithByteOrder(this byte[] bytes, bool isLittleEndian) { if (isLittleEndian != BitConverter.IsLittleEndian) { - var reversedBytes = new byte[bytes.Length]; + byte[] reversedBytes = new byte[bytes.Length]; Array.Copy(bytes, reversedBytes, bytes.Length); Array.Reverse(reversedBytes); return reversedBytes; diff --git a/tests/ImageSharp.Tests/TestUtilities/ByteBuffer.cs b/tests/ImageSharp.Tests/TestUtilities/ByteBuffer.cs index 45e1425c75..ed3b7d2f77 100644 --- a/tests/ImageSharp.Tests/TestUtilities/ByteBuffer.cs +++ b/tests/ImageSharp.Tests/TestUtilities/ByteBuffer.cs @@ -8,7 +8,7 @@ namespace SixLabors.ImageSharp.Tests.TestUtilities; public class ByteBuffer { - private readonly List bytes = new List(); + private readonly List bytes = []; private readonly bool isLittleEndian; public ByteBuffer(bool isLittleEndian) diff --git a/tests/ImageSharp.Tests/TestUtilities/EofHitCounter.cs b/tests/ImageSharp.Tests/TestUtilities/EofHitCounter.cs index c5ffdd6489..45a5ab5f58 100644 --- a/tests/ImageSharp.Tests/TestUtilities/EofHitCounter.cs +++ b/tests/ImageSharp.Tests/TestUtilities/EofHitCounter.cs @@ -31,7 +31,7 @@ public static EofHitCounter RunDecoder(byte[] imageData) { BufferedReadStream stream = new(Configuration.Default, new MemoryStream(imageData)); Image image = Image.Load(stream); - return new EofHitCounter(stream, image); + return new(stream, image); } public static EofHitCounter RunDecoder(byte[] imageData, T decoder, TO options) @@ -40,7 +40,7 @@ public static EofHitCounter RunDecoder(byte[] imageData, T decoder, TO op { BufferedReadStream stream = new(options.GeneralOptions.Configuration, new MemoryStream(imageData)); Image image = decoder.Decode(options, stream); - return new EofHitCounter(stream, image); + return new(stream, image); } public void Dispose() diff --git a/tests/ImageSharp.Tests/TestUtilities/FeatureTesting/FeatureTestRunner.cs b/tests/ImageSharp.Tests/TestUtilities/FeatureTesting/FeatureTestRunner.cs index 07ad5e8f03..82a1ac0f8f 100644 --- a/tests/ImageSharp.Tests/TestUtilities/FeatureTesting/FeatureTestRunner.cs +++ b/tests/ImageSharp.Tests/TestUtilities/FeatureTesting/FeatureTestRunner.cs @@ -67,7 +67,7 @@ public static void RunWithHwIntrinsicsFeature( RemoteExecutor.Invoke( action, - new RemoteInvokeOptions + new() { StartInfo = processStartInfo }) @@ -109,7 +109,7 @@ public static void RunWithHwIntrinsicsFeature( RemoteExecutor.Invoke( action, intrinsic.Key.ToString(), - new RemoteInvokeOptions + new() { StartInfo = processStartInfo }) @@ -153,7 +153,7 @@ public static void RunWithHwIntrinsicsFeature( RemoteExecutor.Invoke( action, BasicSerializer.Serialize(serializable), - new RemoteInvokeOptions + new() { StartInfo = processStartInfo }) @@ -198,7 +198,7 @@ public static void RunWithHwIntrinsicsFeature( action, BasicSerializer.Serialize(serializable), intrinsic.Key.ToString(), - new RemoteInvokeOptions + new() { StartInfo = processStartInfo }) @@ -247,7 +247,7 @@ public static void RunWithHwIntrinsicsFeature( action, BasicSerializer.Serialize(arg1), BasicSerializer.Serialize(arg2), - new RemoteInvokeOptions + new() { StartInfo = processStartInfo }) @@ -294,7 +294,7 @@ public static void RunWithHwIntrinsicsFeature( action, BasicSerializer.Serialize(arg1), arg2, - new RemoteInvokeOptions + new() { StartInfo = processStartInfo }) @@ -338,7 +338,7 @@ public static void RunWithHwIntrinsicsFeature( RemoteExecutor.Invoke( action, serializable.ToString(), - new RemoteInvokeOptions + new() { StartInfo = processStartInfo }) @@ -385,7 +385,7 @@ public static void RunWithHwIntrinsicsFeature( action, arg0.ToString(), arg1.ToString(), - new RemoteInvokeOptions + new() { StartInfo = processStartInfo }) diff --git a/tests/ImageSharp.Tests/TestUtilities/ImageComparison/ExactImageComparer.cs b/tests/ImageSharp.Tests/TestUtilities/ImageComparison/ExactImageComparer.cs index 92fc06eff5..f9b8eedd19 100644 --- a/tests/ImageSharp.Tests/TestUtilities/ImageComparison/ExactImageComparer.cs +++ b/tests/ImageSharp.Tests/TestUtilities/ImageComparison/ExactImageComparer.cs @@ -8,7 +8,7 @@ namespace SixLabors.ImageSharp.Tests.TestUtilities.ImageComparison; public class ExactImageComparer : ImageComparer { - public static ExactImageComparer Instance { get; } = new ExactImageComparer(); + public static ExactImageComparer Instance { get; } = new(); public override ImageSimilarityReport CompareImagesOrFrames( int index, @@ -23,10 +23,10 @@ public override ImageSimilarityReport CompareImagesOrFrames(); + List differences = []; Configuration configuration = expected.Configuration; Buffer2D expectedBuffer = expected.PixelBuffer; Buffer2D actualBuffer = actual.PixelBuffer; @@ -46,12 +46,12 @@ public override ImageSimilarityReport CompareImagesOrFrames(index, expected, actual, differences); + return new(index, expected, actual, differences); } } diff --git a/tests/ImageSharp.Tests/TestUtilities/ImageComparison/ImageComparer.cs b/tests/ImageSharp.Tests/TestUtilities/ImageComparison/ImageComparer.cs index 7153674e6b..39b9f0265f 100644 --- a/tests/ImageSharp.Tests/TestUtilities/ImageComparison/ImageComparer.cs +++ b/tests/ImageSharp.Tests/TestUtilities/ImageComparison/ImageComparer.cs @@ -51,7 +51,7 @@ public static IEnumerable> CompareImages where TPixelA : unmanaged, IPixel where TPixelB : unmanaged, IPixel { - List> result = new(); + List> result = []; int expectedFrameCount = actual.Frames.Count; if (predicate != null) @@ -147,7 +147,7 @@ public static void VerifySimilarityIgnoreRegion( IEnumerable> reports = comparer.CompareImages(expected, actual); if (reports.Any()) { - var cleanedReports = new List>(reports.Count()); + List> cleanedReports = new(reports.Count()); foreach (ImageSimilarityReport r in reports) { IEnumerable outsideChanges = r.Differences.Where( @@ -159,7 +159,7 @@ public static void VerifySimilarityIgnoreRegion( if (outsideChanges.Any()) { - cleanedReports.Add(new ImageSimilarityReport(r.Index, r.ExpectedImage, r.ActualImage, outsideChanges, null)); + cleanedReports.Add(new(r.Index, r.ExpectedImage, r.ActualImage, outsideChanges, null)); } } diff --git a/tests/ImageSharp.Tests/TestUtilities/ImageComparison/ImageComparingUtils.cs b/tests/ImageSharp.Tests/TestUtilities/ImageComparison/ImageComparingUtils.cs index f5c70b0885..1a6b42c6fc 100644 --- a/tests/ImageSharp.Tests/TestUtilities/ImageComparison/ImageComparingUtils.cs +++ b/tests/ImageSharp.Tests/TestUtilities/ImageComparison/ImageComparingUtils.cs @@ -21,8 +21,8 @@ public static void CompareWithReferenceDecoder( throw new InvalidOperationException("CompareToOriginal() works only with file providers!"); } - var testFile = TestFile.Create(path); - using Image magickImage = DecodeWithMagick(new FileInfo(testFile.FullPath)); + TestFile testFile = TestFile.Create(path); + using Image magickImage = DecodeWithMagick(new(testFile.FullPath)); if (useExactComparer) { ImageComparer.Exact.VerifySimilarity(magickImage, image); @@ -38,10 +38,10 @@ public static Image DecodeWithMagick(FileInfo fileInfo) { Configuration configuration = Configuration.Default.Clone(); configuration.PreferContiguousImageBuffers = true; - using (var magickImage = new MagickImage(fileInfo)) + using (MagickImage magickImage = new(fileInfo)) { magickImage.AutoOrient(); - var result = new Image(configuration, magickImage.Width, magickImage.Height); + Image result = new(configuration, magickImage.Width, magickImage.Height); Assert.True(result.DangerousTryGetSinglePixelMemory(out Memory resultPixels)); diff --git a/tests/ImageSharp.Tests/TestUtilities/ImageComparison/ImageSimilarityReport.cs b/tests/ImageSharp.Tests/TestUtilities/ImageComparison/ImageSimilarityReport.cs index c50ae5e219..b75b52ad50 100644 --- a/tests/ImageSharp.Tests/TestUtilities/ImageComparison/ImageSimilarityReport.cs +++ b/tests/ImageSharp.Tests/TestUtilities/ImageComparison/ImageSimilarityReport.cs @@ -61,7 +61,7 @@ public override string ToString() private string PrintDifference() { - var sb = new StringBuilder(); + StringBuilder sb = new(); if (this.TotalNormalizedDifference.HasValue) { sb.AppendLine(); @@ -103,7 +103,7 @@ public ImageSimilarityReport( } public static ImageSimilarityReport Empty => - new ImageSimilarityReport(0, null, null, Enumerable.Empty(), 0f); + new(0, null, null, [], 0f); public new ImageFrame ExpectedImage => (ImageFrame)base.ExpectedImage; diff --git a/tests/ImageSharp.Tests/TestUtilities/ImageComparison/TolerantImageComparer.cs b/tests/ImageSharp.Tests/TestUtilities/ImageComparison/TolerantImageComparer.cs index d057267da7..ec31678072 100644 --- a/tests/ImageSharp.Tests/TestUtilities/ImageComparison/TolerantImageComparer.cs +++ b/tests/ImageSharp.Tests/TestUtilities/ImageComparison/TolerantImageComparer.cs @@ -65,12 +65,12 @@ public override ImageSimilarityReport CompareImagesOrFrames(); + List differences = []; Configuration configuration = expected.Configuration; Buffer2D expectedBuffer = expected.PixelBuffer; Buffer2D actualBuffer = actual.PixelBuffer; @@ -89,7 +89,7 @@ public override ImageSimilarityReport CompareImagesOrFrames this.PerPixelManhattanThreshold) { - var diff = new PixelDifference(new Point(x, y), aBuffer[x], bBuffer[x]); + PixelDifference diff = new(new(x, y), aBuffer[x], bBuffer[x]); differences.Add(diff); totalDifference += d; @@ -102,7 +102,7 @@ public override ImageSimilarityReport CompareImagesOrFrames this.ImageThreshold) { - return new ImageSimilarityReport(index, expected, actual, differences, normalizedDifference); + return new(index, expected, actual, differences, normalizedDifference); } else { diff --git a/tests/ImageSharp.Tests/TestUtilities/ImageProviders/BasicTestPatternProvider.cs b/tests/ImageSharp.Tests/TestUtilities/ImageProviders/BasicTestPatternProvider.cs index 813ed505d8..d861d293b9 100644 --- a/tests/ImageSharp.Tests/TestUtilities/ImageProviders/BasicTestPatternProvider.cs +++ b/tests/ImageSharp.Tests/TestUtilities/ImageProviders/BasicTestPatternProvider.cs @@ -78,6 +78,6 @@ public override TPixel GetExpectedBasicTestPatternPixelAt(int x, int y) return x < midX ? BottomLeftColor : BottomRightColor; } - private static TPixel GetBottomRightColor() => TPixel.FromScaledVector4(new Vector4(1f, 0f, 1f, 0.5f)); + private static TPixel GetBottomRightColor() => TPixel.FromScaledVector4(new(1f, 0f, 1f, 0.5f)); } } diff --git a/tests/ImageSharp.Tests/TestUtilities/ImageProviders/BlankProvider.cs b/tests/ImageSharp.Tests/TestUtilities/ImageProviders/BlankProvider.cs index 5a31707bf9..c8c3e09c34 100644 --- a/tests/ImageSharp.Tests/TestUtilities/ImageProviders/BlankProvider.cs +++ b/tests/ImageSharp.Tests/TestUtilities/ImageProviders/BlankProvider.cs @@ -33,7 +33,7 @@ public BlankProvider() protected int Width { get; private set; } - public override Image GetImage() => new Image(this.Configuration, this.Width, this.Height); + public override Image GetImage() => new(this.Configuration, this.Width, this.Height); public override void Deserialize(IXunitSerializationInfo info) { diff --git a/tests/ImageSharp.Tests/TestUtilities/ImageProviders/FileProvider.cs b/tests/ImageSharp.Tests/TestUtilities/ImageProviders/FileProvider.cs index 3652d77a1e..caa54feae5 100644 --- a/tests/ImageSharp.Tests/TestUtilities/ImageProviders/FileProvider.cs +++ b/tests/ImageSharp.Tests/TestUtilities/ImageProviders/FileProvider.cs @@ -32,7 +32,7 @@ public Key( ISpecializedDecoderOptions specialized) { Type customType = customDecoder?.GetType(); - this.commonValues = new Tuple( + this.commonValues = new( pixelType, filePath, customType); @@ -45,7 +45,7 @@ private static Dictionary GetDecoderParameters( { Type type = options.GetType(); - var data = new Dictionary(); + Dictionary data = new(); while (type != null && type != typeof(object)) { @@ -196,7 +196,7 @@ public override Image GetImage(IImageDecoder decoder, DecoderOptions opt return this.DecodeImage(decoder, options); } - var key = new Key(this.PixelType, this.FilePath, decoder, options, null); + Key key = new(this.PixelType, this.FilePath, decoder, options, null); Image cachedImage = Cache.GetOrAdd(key, _ => this.DecodeImage(decoder, options)); return cachedImage.Clone(this.Configuration); @@ -233,7 +233,7 @@ public override Image GetImage(ISpecializedImageDecoder decoder, T return this.DecodeImage(decoder, options); } - var key = new Key(this.PixelType, this.FilePath, decoder, options.GeneralOptions, options); + Key key = new(this.PixelType, this.FilePath, decoder, options.GeneralOptions, options); Image cachedImage = Cache.GetOrAdd(key, _ => this.DecodeImage(decoder, options)); return cachedImage.Clone(this.Configuration); @@ -270,7 +270,7 @@ private Image DecodeImage(IImageDecoder decoder, DecoderOptions options) { options.SetConfiguration(this.Configuration); - var testFile = TestFile.Create(this.FilePath); + TestFile testFile = TestFile.Create(this.FilePath); using Stream stream = new MemoryStream(testFile.Bytes); return decoder.Decode(options, stream); } @@ -280,7 +280,7 @@ private Image DecodeImage(ISpecializedImageDecoder decoder, T opti { options.GeneralOptions.SetConfiguration(this.Configuration); - var testFile = TestFile.Create(this.FilePath); + TestFile testFile = TestFile.Create(this.FilePath); using Stream stream = new MemoryStream(testFile.Bytes); return decoder.Decode(options, stream); } @@ -288,7 +288,7 @@ private Image DecodeImage(ISpecializedImageDecoder decoder, T opti public static string GetFilePathOrNull(ITestImageProvider provider) { - var fileProvider = provider as FileProvider; + FileProvider fileProvider = provider as FileProvider; return fileProvider?.FilePath; } } diff --git a/tests/ImageSharp.Tests/TestUtilities/ImageProviders/MemberMethodProvider.cs b/tests/ImageSharp.Tests/TestUtilities/ImageProviders/MemberMethodProvider.cs index 390195274f..6da5b75f0d 100644 --- a/tests/ImageSharp.Tests/TestUtilities/ImageProviders/MemberMethodProvider.cs +++ b/tests/ImageSharp.Tests/TestUtilities/ImageProviders/MemberMethodProvider.cs @@ -54,7 +54,7 @@ public override void Deserialize(IXunitSerializationInfo info) private Func> GetFactory() { - var declaringType = Type.GetType(this.declaringTypeName); + Type declaringType = Type.GetType(this.declaringTypeName); MethodInfo m = declaringType.GetMethod(this.methodName); Type pixelType = typeof(TPixel); Type imgType = typeof(Image<>).MakeGenericType(pixelType); diff --git a/tests/ImageSharp.Tests/TestUtilities/ImageProviders/TestImageProvider.cs b/tests/ImageSharp.Tests/TestUtilities/ImageProviders/TestImageProvider.cs index 8f22fb2b29..88ebd6c7f6 100644 --- a/tests/ImageSharp.Tests/TestUtilities/ImageProviders/TestImageProvider.cs +++ b/tests/ImageSharp.Tests/TestUtilities/ImageProviders/TestImageProvider.cs @@ -152,7 +152,7 @@ protected TestImageProvider Init( this.MethodName = methodName; this.OutputSubfolderName = outputSubfolderName; - this.Utility = new ImagingTestCaseUtility + this.Utility = new() { SourceFileOrDescription = this.SourceFileOrDescription, PixelTypeName = this.PixelType.ToString() diff --git a/tests/ImageSharp.Tests/TestUtilities/MeasureFixture.cs b/tests/ImageSharp.Tests/TestUtilities/MeasureFixture.cs index de42ba0ccf..81f16cf6b9 100644 --- a/tests/ImageSharp.Tests/TestUtilities/MeasureFixture.cs +++ b/tests/ImageSharp.Tests/TestUtilities/MeasureFixture.cs @@ -30,7 +30,7 @@ public void Measure(int times, Action action, [CallerMemberName] string operatio this.Output?.WriteLine($"{operationName} X {times} ..."); } - var sw = Stopwatch.StartNew(); + Stopwatch sw = Stopwatch.StartNew(); for (int i = 0; i < times; i++) { @@ -60,7 +60,7 @@ public class MeasureGuard : IDisposable { private readonly string operation; - private readonly Stopwatch stopwatch = new Stopwatch(); + private readonly Stopwatch stopwatch = new(); public MeasureGuard(ITestOutputHelper output, string operation) { diff --git a/tests/ImageSharp.Tests/TestUtilities/PausedMemoryStream.cs b/tests/ImageSharp.Tests/TestUtilities/PausedMemoryStream.cs index ae4af24f14..ac0a6ba775 100644 --- a/tests/ImageSharp.Tests/TestUtilities/PausedMemoryStream.cs +++ b/tests/ImageSharp.Tests/TestUtilities/PausedMemoryStream.cs @@ -91,9 +91,9 @@ public override async Task CopyToAsync(Stream destination, int bufferSize, Cance try { int bytesRead; - while ((bytesRead = await this.ReadAsync(new Memory(buffer), cancellationToken).ConfigureAwait(false)) != 0) + while ((bytesRead = await this.ReadAsync(new(buffer), cancellationToken).ConfigureAwait(false)) != 0) { - await destination.WriteAsync(new ReadOnlyMemory(buffer, 0, bytesRead), cancellationToken).ConfigureAwait(false); + await destination.WriteAsync(new(buffer, 0, bytesRead), cancellationToken).ConfigureAwait(false); } } finally diff --git a/tests/ImageSharp.Tests/TestUtilities/PausedStream.cs b/tests/ImageSharp.Tests/TestUtilities/PausedStream.cs index 3c780f3474..f146d87c6a 100644 --- a/tests/ImageSharp.Tests/TestUtilities/PausedStream.cs +++ b/tests/ImageSharp.Tests/TestUtilities/PausedStream.cs @@ -94,9 +94,9 @@ public override async Task CopyToAsync(Stream destination, int bufferSize, Cance try { int bytesRead; - while ((bytesRead = await this.ReadAsync(new Memory(buffer), cancellationToken).ConfigureAwait(false)) != 0) + while ((bytesRead = await this.ReadAsync(new(buffer), cancellationToken).ConfigureAwait(false)) != 0) { - await destination.WriteAsync(new ReadOnlyMemory(buffer, 0, bytesRead), cancellationToken).ConfigureAwait(false); + await destination.WriteAsync(new(buffer, 0, bytesRead), cancellationToken).ConfigureAwait(false); } } finally diff --git a/tests/ImageSharp.Tests/TestUtilities/ReferenceCodecs/MagickReferenceDecoder.cs b/tests/ImageSharp.Tests/TestUtilities/ReferenceCodecs/MagickReferenceDecoder.cs index f96dc19ee0..34ae65f9f8 100644 --- a/tests/ImageSharp.Tests/TestUtilities/ReferenceCodecs/MagickReferenceDecoder.cs +++ b/tests/ImageSharp.Tests/TestUtilities/ReferenceCodecs/MagickReferenceDecoder.cs @@ -32,15 +32,15 @@ public MagickReferenceDecoder(IImageFormat imageFormat, bool validate) this.validate = validate; } - public static MagickReferenceDecoder Png { get; } = new MagickReferenceDecoder(PngFormat.Instance); + public static MagickReferenceDecoder Png { get; } = new(PngFormat.Instance); - public static MagickReferenceDecoder Bmp { get; } = new MagickReferenceDecoder(BmpFormat.Instance); + public static MagickReferenceDecoder Bmp { get; } = new(BmpFormat.Instance); - public static MagickReferenceDecoder Jpeg { get; } = new MagickReferenceDecoder(JpegFormat.Instance); + public static MagickReferenceDecoder Jpeg { get; } = new(JpegFormat.Instance); - public static MagickReferenceDecoder Tiff { get; } = new MagickReferenceDecoder(TiffFormat.Instance); + public static MagickReferenceDecoder Tiff { get; } = new(TiffFormat.Instance); - public static MagickReferenceDecoder WebP { get; } = new MagickReferenceDecoder(WebpFormat.Instance); + public static MagickReferenceDecoder WebP { get; } = new(WebpFormat.Instance); protected override Image Decode(DecoderOptions options, Stream stream, CancellationToken cancellationToken) { diff --git a/tests/ImageSharp.Tests/TestUtilities/ReferenceCodecs/SystemDrawingBridge.cs b/tests/ImageSharp.Tests/TestUtilities/ReferenceCodecs/SystemDrawingBridge.cs index 04f59979f7..84be9e3a9a 100644 --- a/tests/ImageSharp.Tests/TestUtilities/ReferenceCodecs/SystemDrawingBridge.cs +++ b/tests/ImageSharp.Tests/TestUtilities/ReferenceCodecs/SystemDrawingBridge.cs @@ -27,7 +27,7 @@ internal static unsafe Image From32bppArgbSystemDrawingBitmap(Bi int w = bmp.Width; int h = bmp.Height; - var fullRect = new System.Drawing.Rectangle(0, 0, w, h); + System.Drawing.Rectangle fullRect = new(0, 0, w, h); if (bmp.PixelFormat != PixelFormat.Format32bppArgb) { @@ -37,7 +37,7 @@ internal static unsafe Image From32bppArgbSystemDrawingBitmap(Bi } BitmapData data = bmp.LockBits(fullRect, ImageLockMode.ReadWrite, bmp.PixelFormat); - var image = new Image(w, h); + Image image = new(w, h); try { byte* sourcePtrBase = (byte*)data.Scan0; @@ -86,7 +86,7 @@ internal static unsafe Image From24bppRgbSystemDrawingBitmap(Bit int w = bmp.Width; int h = bmp.Height; - var fullRect = new System.Drawing.Rectangle(0, 0, w, h); + System.Drawing.Rectangle fullRect = new(0, 0, w, h); if (bmp.PixelFormat != PixelFormat.Format24bppRgb) { @@ -96,7 +96,7 @@ internal static unsafe Image From24bppRgbSystemDrawingBitmap(Bit } BitmapData data = bmp.LockBits(fullRect, ImageLockMode.ReadWrite, bmp.PixelFormat); - var image = new Image(w, h); + Image image = new(w, h); try { byte* sourcePtrBase = (byte*)data.Scan0; @@ -138,8 +138,8 @@ internal static unsafe Bitmap To32bppArgbSystemDrawingBitmap(Image this.imageFormat = imageFormat; - public static SystemDrawingReferenceDecoder Png { get; } = new SystemDrawingReferenceDecoder(PngFormat.Instance); + public static SystemDrawingReferenceDecoder Png { get; } = new(PngFormat.Instance); - public static SystemDrawingReferenceDecoder Bmp { get; } = new SystemDrawingReferenceDecoder(BmpFormat.Instance); + public static SystemDrawingReferenceDecoder Bmp { get; } = new(BmpFormat.Instance); protected override ImageInfo Identify(DecoderOptions options, Stream stream, CancellationToken cancellationToken) { diff --git a/tests/ImageSharp.Tests/TestUtilities/ReferenceCodecs/SystemDrawingReferenceEncoder.cs b/tests/ImageSharp.Tests/TestUtilities/ReferenceCodecs/SystemDrawingReferenceEncoder.cs index 0789ab2634..f9769b891e 100644 --- a/tests/ImageSharp.Tests/TestUtilities/ReferenceCodecs/SystemDrawingReferenceEncoder.cs +++ b/tests/ImageSharp.Tests/TestUtilities/ReferenceCodecs/SystemDrawingReferenceEncoder.cs @@ -15,9 +15,9 @@ public class SystemDrawingReferenceEncoder : IImageEncoder public SystemDrawingReferenceEncoder(ImageFormat imageFormat) => this.imageFormat = imageFormat; - public static SystemDrawingReferenceEncoder Png { get; } = new SystemDrawingReferenceEncoder(ImageFormat.Png); + public static SystemDrawingReferenceEncoder Png { get; } = new(ImageFormat.Png); - public static SystemDrawingReferenceEncoder Bmp { get; } = new SystemDrawingReferenceEncoder(ImageFormat.Bmp); + public static SystemDrawingReferenceEncoder Bmp { get; } = new(ImageFormat.Bmp); public bool SkipMetadata { get; init; } diff --git a/tests/ImageSharp.Tests/TestUtilities/SixLaborsXunitTestFramework.cs b/tests/ImageSharp.Tests/TestUtilities/SixLaborsXunitTestFramework.cs index edae08ce16..d8b0ff7856 100644 --- a/tests/ImageSharp.Tests/TestUtilities/SixLaborsXunitTestFramework.cs +++ b/tests/ImageSharp.Tests/TestUtilities/SixLaborsXunitTestFramework.cs @@ -18,7 +18,7 @@ public class SixLaborsXunitTestFramework : XunitTestFramework public SixLaborsXunitTestFramework(IMessageSink messageSink) : base(messageSink) { - var message = new DiagnosticMessage(HostEnvironmentInfo.GetInformation()); + DiagnosticMessage message = new(HostEnvironmentInfo.GetInformation()); messageSink.OnMessage(message); } } diff --git a/tests/ImageSharp.Tests/TestUtilities/TestDataGenerator.cs b/tests/ImageSharp.Tests/TestUtilities/TestDataGenerator.cs index 31de3909e1..53f0f06486 100644 --- a/tests/ImageSharp.Tests/TestUtilities/TestDataGenerator.cs +++ b/tests/ImageSharp.Tests/TestUtilities/TestDataGenerator.cs @@ -20,7 +20,7 @@ internal static class TestDataGenerator /// The . public static float[] GenerateRandomFloatArray(this Random rnd, int length, float minVal, float maxVal) { - var values = new float[length]; + float[] values = new float[length]; RandomFill(rnd, values, minVal, maxVal); @@ -45,7 +45,7 @@ public static void RandomFill(this Random rnd, Span destination, float mi /// The . public static Vector4[] GenerateRandomVectorArray(this Random rnd, int length, float minVal, float maxVal) { - var values = new Vector4[length]; + Vector4[] values = new Vector4[length]; for (int i = 0; i < length; i++) { @@ -69,7 +69,7 @@ public static Vector4[] GenerateRandomVectorArray(this Random rnd, int length, f /// The . public static float[] GenerateRandomRoundedFloatArray(this Random rnd, int length, float minVal, float maxVal) { - var values = new float[length]; + float[] values = new float[length]; for (int i = 0; i < length; i++) { @@ -87,14 +87,14 @@ public static float[] GenerateRandomRoundedFloatArray(this Random rnd, int lengt /// The . public static byte[] GenerateRandomByteArray(this Random rnd, int length) { - var values = new byte[length]; + byte[] values = new byte[length]; rnd.NextBytes(values); return values; } public static short[] GenerateRandomInt16Array(this Random rnd, int length, short minVal, short maxVal) { - var values = new short[length]; + short[] values = new short[length]; for (int i = 0; i < values.Length; i++) { values[i] = (short)rnd.Next(minVal, maxVal); diff --git a/tests/ImageSharp.Tests/TestUtilities/TestEnvironment.cs b/tests/ImageSharp.Tests/TestUtilities/TestEnvironment.cs index 8818830351..3149d68c76 100644 --- a/tests/ImageSharp.Tests/TestUtilities/TestEnvironment.cs +++ b/tests/ImageSharp.Tests/TestUtilities/TestEnvironment.cs @@ -19,9 +19,9 @@ public static partial class TestEnvironment private const string ToolsDirectoryRelativePath = @"tests\Images\External\tools"; - private static readonly Lazy SolutionDirectoryFullPathLazy = new Lazy(GetSolutionDirectoryFullPathImpl); + private static readonly Lazy SolutionDirectoryFullPathLazy = new(GetSolutionDirectoryFullPathImpl); - private static readonly Lazy NetCoreVersionLazy = new Lazy(GetNetCoreVersion); + private static readonly Lazy NetCoreVersionLazy = new(GetNetCoreVersion); static TestEnvironment() => PrepareRemoteExecutor(); @@ -52,8 +52,7 @@ public static partial class TestEnvironment internal static string SolutionDirectoryFullPath => SolutionDirectoryFullPathLazy.Value; - private static readonly FileInfo TestAssemblyFile = - new FileInfo(typeof(TestEnvironment).GetTypeInfo().Assembly.Location); + private static readonly FileInfo TestAssemblyFile = new(typeof(TestEnvironment).GetTypeInfo().Assembly.Location); private static string GetSolutionDirectoryFullPathImpl() { @@ -199,7 +198,7 @@ private static void EnsureRemoteExecutorIs32Bit() "Microsoft SDKs", "Windows"); - FileInfo corFlagsFile = Find(new DirectoryInfo(windowsSdksDir), "CorFlags.exe"); + FileInfo corFlagsFile = Find(new(windowsSdksDir), "CorFlags.exe"); string remoteExecutorPath = Path.Combine(TestAssemblyFile.DirectoryName, "Microsoft.DotNet.RemoteExecutor.exe"); @@ -215,7 +214,7 @@ private static void EnsureRemoteExecutorIs32Bit() string args = $"{remoteExecutorTmpPath} /32Bit+ /Force"; - var si = new ProcessStartInfo() + ProcessStartInfo si = new() { FileName = corFlagsFile.FullName, Arguments = args, @@ -224,14 +223,14 @@ private static void EnsureRemoteExecutorIs32Bit() RedirectStandardError = true }; - using var proc = Process.Start(si); + using Process proc = Process.Start(si); proc.WaitForExit(); string standardOutput = proc.StandardOutput.ReadToEnd(); string standardError = proc.StandardError.ReadToEnd(); if (proc.ExitCode != 0) { - throw new Exception( + throw new( $@"Failed to run {si.FileName} {si.Arguments}:\n STDOUT: {standardOutput}\n STDERR: {standardError}"); } @@ -266,7 +265,7 @@ static FileInfo Find(DirectoryInfo root, string name) private static Version GetNetCoreVersion() { Assembly assembly = typeof(System.Runtime.GCSettings).GetTypeInfo().Assembly; - string[] assemblyPath = assembly.Location.Split(new[] { '/', '\\' }, StringSplitOptions.RemoveEmptyEntries); + string[] assemblyPath = assembly.Location.Split(['/', '\\'], StringSplitOptions.RemoveEmptyEntries); int netCoreAppIndex = Array.IndexOf(assemblyPath, "Microsoft.NETCore.App"); if (netCoreAppIndex > 0 && netCoreAppIndex < assemblyPath.Length - 2) { diff --git a/tests/ImageSharp.Tests/TestUtilities/TestImageExtensions.cs b/tests/ImageSharp.Tests/TestUtilities/TestImageExtensions.cs index 05abedbd8e..09110056fc 100644 --- a/tests/ImageSharp.Tests/TestUtilities/TestImageExtensions.cs +++ b/tests/ImageSharp.Tests/TestUtilities/TestImageExtensions.cs @@ -343,7 +343,7 @@ public static Image GetReferenceOutputImageMultiFrame( appendPixelTypeToFileName, predicate); - List> temporaryFrameImages = new(); + List> temporaryFrameImages = []; IImageDecoder decoder = TestEnvironment.GetReferenceDecoder(frameFiles[0].FileName); @@ -694,7 +694,7 @@ internal static AllocatorBufferCapacityConfigurator LimitAllocatorBufferCapacity { TestMemoryAllocator allocator = new(); provider.Configuration.MemoryAllocator = allocator; - return new AllocatorBufferCapacityConfigurator(allocator, Unsafe.SizeOf()); + return new(allocator, Unsafe.SizeOf()); } private class MakeOpaqueProcessor : IImageProcessor diff --git a/tests/ImageSharp.Tests/TestUtilities/TestMemoryAllocator.cs b/tests/ImageSharp.Tests/TestUtilities/TestMemoryAllocator.cs index fe94cffc43..1ec16c26b4 100644 --- a/tests/ImageSharp.Tests/TestUtilities/TestMemoryAllocator.cs +++ b/tests/ImageSharp.Tests/TestUtilities/TestMemoryAllocator.cs @@ -33,8 +33,8 @@ public TestMemoryAllocator(byte dirtyValue = 42) public void EnableNonThreadSafeLogging() { - this.allocationLog = new List(); - this.returnLog = new List(); + this.allocationLog = []; + this.returnLog = []; } public override IMemoryOwner Allocate(int length, AllocationOptions options = AllocationOptions.None) @@ -46,7 +46,7 @@ public override IMemoryOwner Allocate(int length, AllocationOptions option private T[] AllocateArray(int length, AllocationOptions options) where T : struct { - var array = new T[length + 42]; + T[] array = new T[length + 42]; this.allocationLog?.Add(AllocationRequest.Create(options, length, array)); if (options == AllocationOptions.None) @@ -61,7 +61,7 @@ private T[] AllocateArray(int length, AllocationOptions options) private void Return(BasicArrayBuffer buffer) where T : struct { - this.returnLog?.Add(new ReturnRequest(buffer.Array.GetHashCode())); + this.returnLog?.Add(new(buffer.Array.GetHashCode())); } public struct AllocationRequest @@ -83,7 +83,7 @@ public static AllocationRequest Create(AllocationOptions allocationOptions, i { Type type = typeof(T); int elementSize = Marshal.SizeOf(type); - return new AllocationRequest(type, allocationOptions, length, length * elementSize, buffer.GetHashCode()); + return new(type, allocationOptions, length, length * elementSize, buffer.GetHashCode()); } public Type ElementType { get; } @@ -150,7 +150,7 @@ public override unsafe MemoryHandle Pin(int elementIndex = 0) } void* ptr = (void*)this.pinHandle.AddrOfPinnedObject(); - return new MemoryHandle(ptr, pinnable: this); + return new(ptr, pinnable: this); } public override void Unpin() diff --git a/tests/ImageSharp.Tests/TestUtilities/TestMemoryManager.cs b/tests/ImageSharp.Tests/TestUtilities/TestMemoryManager.cs index 50e086d579..2604aa1de9 100644 --- a/tests/ImageSharp.Tests/TestUtilities/TestMemoryManager.cs +++ b/tests/ImageSharp.Tests/TestUtilities/TestMemoryManager.cs @@ -34,9 +34,9 @@ public override void Unpin() public static TestMemoryManager CreateAsCopyOf(Span copyThisBuffer) { - var pixelArray = new T[copyThisBuffer.Length]; + T[] pixelArray = new T[copyThisBuffer.Length]; copyThisBuffer.CopyTo(pixelArray); - return new TestMemoryManager(pixelArray); + return new(pixelArray); } protected override void Dispose(bool disposing) diff --git a/tests/ImageSharp.Tests/TestUtilities/TestPixel.cs b/tests/ImageSharp.Tests/TestUtilities/TestPixel.cs index f0344e2b9c..42b2b2a256 100644 --- a/tests/ImageSharp.Tests/TestUtilities/TestPixel.cs +++ b/tests/ImageSharp.Tests/TestUtilities/TestPixel.cs @@ -35,7 +35,7 @@ public TestPixel(float red, float green, float blue, float alpha) public float Alpha { get; set; } - public TPixel AsPixel() => TPixel.FromScaledVector4(new Vector4(this.Red, this.Green, this.Blue, this.Alpha)); + public TPixel AsPixel() => TPixel.FromScaledVector4(new(this.Red, this.Green, this.Blue, this.Alpha)); internal Span AsSpan() => new([this.AsPixel()]); diff --git a/tests/ImageSharp.Tests/TestUtilities/TestUtils.cs b/tests/ImageSharp.Tests/TestUtilities/TestUtils.cs index fbdfb9d619..fe45b1abf5 100644 --- a/tests/ImageSharp.Tests/TestUtilities/TestUtils.cs +++ b/tests/ImageSharp.Tests/TestUtilities/TestUtils.cs @@ -26,7 +26,7 @@ public static class TestUtils private static readonly Dictionary PixelTypes2ClrTypes = new(); private static readonly PixelTypes[] AllConcretePixelTypes = GetAllPixelTypes() - .Except(new[] { PixelTypes.Undefined, PixelTypes.All }) + .Except([PixelTypes.Undefined, PixelTypes.All]) .ToArray(); static TestUtils() @@ -69,7 +69,7 @@ internal static byte[] FillImageWithRandomBytes(Image image) Span row = accessor.GetRowSpan(y); for (int x = 0; x < row.Length; x++) { - row[x] = new La16(expected[cnt++], expected[cnt++]); + row[x] = new(expected[cnt++], expected[cnt++]); } } }); @@ -133,7 +133,7 @@ public static IEnumerable> ExpandAllTypes(this Pi { if (pixelTypes == PixelTypes.Undefined) { - return Enumerable.Empty>(); + return []; } else if (pixelTypes == PixelTypes.All) { @@ -393,7 +393,7 @@ public static IDither GetDither(string name) if (property is null) { - throw new Exception($"No dither named '{name}"); + throw new($"No dither named '{name}"); } return (IDither)property.GetValue(null); diff --git a/tests/ImageSharp.Tests/TestUtilities/TestVector4.cs b/tests/ImageSharp.Tests/TestUtilities/TestVector4.cs index 350333965a..4130d89da1 100644 --- a/tests/ImageSharp.Tests/TestUtilities/TestVector4.cs +++ b/tests/ImageSharp.Tests/TestUtilities/TestVector4.cs @@ -35,7 +35,7 @@ public static implicit operator Vector4(TestVector4 d) public Vector4 AsVector() { - return new Vector4(this.X, this.Y, this.Z, this.W); + return new(this.X, this.Y, this.Z, this.W); } public void Deserialize(IXunitSerializationInfo info) diff --git a/tests/ImageSharp.Tests/TestUtilities/Tests/BasicSerializerTests.cs b/tests/ImageSharp.Tests/TestUtilities/Tests/BasicSerializerTests.cs index 52447b6c2c..1b5b43f033 100644 --- a/tests/ImageSharp.Tests/TestUtilities/Tests/BasicSerializerTests.cs +++ b/tests/ImageSharp.Tests/TestUtilities/Tests/BasicSerializerTests.cs @@ -51,7 +51,7 @@ public override void Serialize(IXunitSerializationInfo info) [Fact] public void SerializeDeserialize_ShouldPreserveValues() { - var obj = new DerivedObj() { Length = 123.1, Name = "Lol123!", Lives = 7, Strength = 4.8 }; + DerivedObj obj = new() { Length = 123.1, Name = "Lol123!", Lives = 7, Strength = 4.8 }; string str = BasicSerializer.Serialize(obj); BaseObj mirrorBase = BasicSerializer.Deserialize(str); diff --git a/tests/ImageSharp.Tests/TestUtilities/Tests/FeatureTestRunnerTests.cs b/tests/ImageSharp.Tests/TestUtilities/Tests/FeatureTestRunnerTests.cs index 34337600eb..82b247d9df 100644 --- a/tests/ImageSharp.Tests/TestUtilities/Tests/FeatureTestRunnerTests.cs +++ b/tests/ImageSharp.Tests/TestUtilities/Tests/FeatureTestRunnerTests.cs @@ -14,9 +14,9 @@ public class FeatureTestRunnerTests public static TheoryData Intrinsics => new() { - { HwIntrinsics.DisableAES | HwIntrinsics.AllowAll, new[] { "EnableAES", "AllowAll" } }, - { HwIntrinsics.DisableHWIntrinsic, new[] { "EnableHWIntrinsic" } }, - { HwIntrinsics.DisableSSE42 | HwIntrinsics.DisableAVX, new[] { "EnableSSE42", "EnableAVX" } } + { HwIntrinsics.DisableAES | HwIntrinsics.AllowAll, ["EnableAES", "AllowAll"] }, + { HwIntrinsics.DisableHWIntrinsic, ["EnableHWIntrinsic"] }, + { HwIntrinsics.DisableSSE42 | HwIntrinsics.DisableAVX, ["EnableSSE42", "EnableAVX"] } }; [Theory] diff --git a/tests/ImageSharp.Tests/TestUtilities/Tests/ImageComparerTests.cs b/tests/ImageSharp.Tests/TestUtilities/Tests/ImageComparerTests.cs index 4c1a740e2b..649c626a14 100644 --- a/tests/ImageSharp.Tests/TestUtilities/Tests/ImageComparerTests.cs +++ b/tests/ImageSharp.Tests/TestUtilities/Tests/ImageComparerTests.cs @@ -31,7 +31,7 @@ public void TolerantImageComparer_ApprovesPerfectSimilarity( { using (Image clone = image.Clone()) { - var comparer = ImageComparer.Tolerant(imageThreshold, pixelThreshold); + ImageComparer comparer = ImageComparer.Tolerant(imageThreshold, pixelThreshold); comparer.VerifySimilarity(image, clone); } } @@ -48,7 +48,7 @@ public void TolerantImageComparer_ApprovesSimilarityBelowTolerance(TestI { ImagingTestCaseUtility.ModifyPixel(clone, 0, 0, 1); - var comparer = ImageComparer.Tolerant(); + ImageComparer comparer = ImageComparer.Tolerant(); comparer.VerifySimilarity(image, clone); } } @@ -66,13 +66,13 @@ public void TolerantImageComparer_DoesNotApproveSimilarityAboveTolerance byte perChannelChange = 20; ImagingTestCaseUtility.ModifyPixel(clone, 3, 1, perChannelChange); - var comparer = ImageComparer.Tolerant(); + ImageComparer comparer = ImageComparer.Tolerant(); ImageDifferenceIsOverThresholdException ex = Assert.ThrowsAny( () => comparer.VerifySimilarity(image, clone)); PixelDifference diff = ex.Reports.Single().Differences.Single(); - Assert.Equal(new Point(3, 1), diff.Position); + Assert.Equal(new(3, 1), diff.Position); } } } @@ -90,7 +90,7 @@ public void TolerantImageComparer_TestPerPixelThreshold(TestImageProvide ImagingTestCaseUtility.ModifyPixel(clone, 1, 0, 1); ImagingTestCaseUtility.ModifyPixel(clone, 2, 0, 1); - var comparer = ImageComparer.Tolerant(perPixelManhattanThreshold: 257 * 3); + ImageComparer comparer = ImageComparer.Tolerant(perPixelManhattanThreshold: 257 * 3); comparer.VerifySimilarity(image, clone); } } @@ -131,7 +131,7 @@ public void VerifySimilarity_WhenAnImageFrameIsDifferent_Reports(TestIma IEnumerable reports = ImageComparer.Exact.CompareImages(image, clone); PixelDifference difference = reports.Single().Differences.Single(); - Assert.Equal(new Point(42, 43), difference.Position); + Assert.Equal(new(42, 43), difference.Position); } } } diff --git a/tests/ImageSharp.Tests/TestUtilities/Tests/ReferenceDecoderBenchmarks.cs b/tests/ImageSharp.Tests/TestUtilities/Tests/ReferenceDecoderBenchmarks.cs index 6e1eba28e8..a145e7365e 100644 --- a/tests/ImageSharp.Tests/TestUtilities/Tests/ReferenceDecoderBenchmarks.cs +++ b/tests/ImageSharp.Tests/TestUtilities/Tests/ReferenceDecoderBenchmarks.cs @@ -22,20 +22,20 @@ public class ReferenceDecoderBenchmarks public const int DefaultExecutionCount = 50; public static readonly string[] PngBenchmarkFiles = - { - TestImages.Png.CalliphoraPartial, + [ + TestImages.Png.CalliphoraPartial, TestImages.Png.Kaboom, TestImages.Png.Bike, TestImages.Png.Splash, TestImages.Png.SplashInterlaced - }; + ]; public static readonly string[] BmpBenchmarkFiles = - { - TestImages.Bmp.NegHeight, + [ + TestImages.Bmp.NegHeight, TestImages.Bmp.Car, TestImages.Bmp.V5Header - }; + ]; public ReferenceDecoderBenchmarks(ITestOutputHelper output) { @@ -76,7 +76,7 @@ public void BenchmarkSystemDrawingBmpDecoder(TestImageProvider p private void BenchmarkDecoderImpl(IEnumerable testFiles, IImageDecoder decoder, string info, int times = DefaultExecutionCount) { - var measure = new MeasureFixture(this.Output); + MeasureFixture measure = new(this.Output); measure.Measure( times, () => diff --git a/tests/ImageSharp.Tests/TestUtilities/Tests/SemaphoreReadMemoryStreamTests.cs b/tests/ImageSharp.Tests/TestUtilities/Tests/SemaphoreReadMemoryStreamTests.cs index e080bda9b6..f0a5f4eb42 100644 --- a/tests/ImageSharp.Tests/TestUtilities/Tests/SemaphoreReadMemoryStreamTests.cs +++ b/tests/ImageSharp.Tests/TestUtilities/Tests/SemaphoreReadMemoryStreamTests.cs @@ -5,8 +5,8 @@ namespace SixLabors.ImageSharp.Tests.TestUtilities.Tests; public class SemaphoreReadMemoryStreamTests { - private readonly SemaphoreSlim continueSemaphore = new SemaphoreSlim(0); - private readonly SemaphoreSlim notifyWaitPositionReachedSemaphore = new SemaphoreSlim(0); + private readonly SemaphoreSlim continueSemaphore = new(0); + private readonly SemaphoreSlim notifyWaitPositionReachedSemaphore = new(0); private readonly byte[] buffer = new byte[128]; [Fact] diff --git a/tests/ImageSharp.Tests/TestUtilities/Tests/SystemDrawingReferenceCodecTests.cs b/tests/ImageSharp.Tests/TestUtilities/Tests/SystemDrawingReferenceCodecTests.cs index 4608583791..555041890a 100644 --- a/tests/ImageSharp.Tests/TestUtilities/Tests/SystemDrawingReferenceCodecTests.cs +++ b/tests/ImageSharp.Tests/TestUtilities/Tests/SystemDrawingReferenceCodecTests.cs @@ -1,6 +1,7 @@ // Copyright (c) Six Labors. // Licensed under the Six Labors Split License. +using System.Drawing; using SixLabors.ImageSharp.Formats; using SixLabors.ImageSharp.Formats.Png; using SixLabors.ImageSharp.PixelFormats; @@ -35,7 +36,7 @@ public void From32bppArgbSystemDrawingBitmap(TestImageProvider d { string path = TestFile.GetInputFileFullPath(TestImages.Png.Splash); - using var sdBitmap = new System.Drawing.Bitmap(path); + using Bitmap sdBitmap = new(path); using Image image = SystemDrawingBridge.From32bppArgbSystemDrawingBitmap(sdBitmap); image.DebugSave(dummyProvider); } @@ -49,7 +50,7 @@ private static string SavePng(TestImageProvider provider, PngCol sourceImage.Mutate(c => c.MakeOpaque()); } - var encoder = new PngEncoder { ColorType = pngColorType }; + PngEncoder encoder = new() { ColorType = pngColorType }; return provider.Utility.SaveTestOutputFile(sourceImage, "png", encoder); } @@ -65,7 +66,7 @@ public void From32bppArgbSystemDrawingBitmap2(TestImageProvider string path = SavePng(provider, PngColorType.RgbWithAlpha); - using var sdBitmap = new System.Drawing.Bitmap(path); + using Bitmap sdBitmap = new(path); using Image original = provider.GetImage(); using Image resaved = SystemDrawingBridge.From32bppArgbSystemDrawingBitmap(sdBitmap); ImageComparer comparer = ImageComparer.Exact; @@ -80,7 +81,7 @@ public void From24bppRgbSystemDrawingBitmap(TestImageProvider pr string path = SavePng(provider, PngColorType.Rgb); using Image original = provider.GetImage(); - using var sdBitmap = new System.Drawing.Bitmap(path); + using Bitmap sdBitmap = new(path); using Image resaved = SystemDrawingBridge.From24bppRgbSystemDrawingBitmap(sdBitmap); ImageComparer comparer = ImageComparer.Exact; comparer.VerifySimilarity(original, resaved); diff --git a/tests/ImageSharp.Tests/TestUtilities/Tests/TestUtilityExtensionsTests.cs b/tests/ImageSharp.Tests/TestUtilities/Tests/TestUtilityExtensionsTests.cs index 46fb7159e8..520f40e72a 100644 --- a/tests/ImageSharp.Tests/TestUtilities/Tests/TestUtilityExtensionsTests.cs +++ b/tests/ImageSharp.Tests/TestUtilities/Tests/TestUtilityExtensionsTests.cs @@ -83,7 +83,7 @@ private static void AssertContainsPixelType( PixelTypes pt, IEnumerable> pixelTypesExp) { - Assert.Contains(new KeyValuePair(pt, typeof(T)), pixelTypesExp); + Assert.Contains(new(pt, typeof(T)), pixelTypesExp); } [Fact]