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..b76f2948f1 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 RowInterval(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 RowInterval(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..b805d63f97 100644
--- a/src/ImageSharp/Color/Color.WebSafePalette.cs
+++ b/src/ImageSharp/Color/Color.WebSafePalette.cs
@@ -8,7 +8,7 @@ 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.
diff --git a/src/ImageSharp/ColorProfiles/CieLab.cs b/src/ImageSharp/ColorProfiles/CieLab.cs
index ca72dd745a..c1f53c1622 100644
--- a/src/ImageSharp/ColorProfiles/CieLab.cs
+++ b/src/ImageSharp/ColorProfiles/CieLab.cs
@@ -88,7 +88,7 @@ public Vector4 ToScaledVector4()
v3 += this.AsVector3Unsafe();
v3 += new Vector3(0, 128F, 128F);
v3 /= new Vector3(100F, 255F, 255F);
- return new Vector4(v3, 1F);
+ return new(v3, 1F);
}
///
@@ -97,7 +97,7 @@ public static CieLab FromScaledVector4(Vector4 source)
Vector3 v3 = source.AsVector3();
v3 *= new Vector3(100F, 255, 255);
v3 -= new Vector3(0, 128F, 128F);
- return new CieLab(v3);
+ return new(v3);
}
///
@@ -145,7 +145,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 e62aa2ba23..53afc0053b 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))
{
}
@@ -100,7 +100,7 @@ public Vector4 ToScaledVector4()
v3 += this.AsVector3Unsafe();
v3 += new Vector3(0, 200, 0);
v3 /= new Vector3(100, 400, 360);
- return new Vector4(v3, 1F);
+ return new(v3, 1F);
}
///
@@ -109,7 +109,7 @@ public static CieLch FromScaledVector4(Vector4 source)
Vector3 v3 = source.AsVector3();
v3 *= new Vector3(100, 400, 360);
v3 -= new Vector3(0, 200, 0);
- return new CieLch(v3, true);
+ return new(v3, true);
}
///
@@ -155,7 +155,7 @@ public static CieLch FromProfileConnectingSpace(ColorConversionOptions options,
hDegrees += 360;
}
- return new CieLch(l, c, hDegrees);
+ return new(l, c, hDegrees);
}
///
@@ -181,7 +181,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 5478752ddc..c08d6cc40c 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))
{
}
@@ -97,7 +97,7 @@ public Vector4 ToScaledVector4()
v3 += this.AsVector3Unsafe();
v3 += new Vector3(0, 200, 0);
v3 /= new Vector3(100, 400, 360);
- return new Vector4(v3, 1F);
+ return new(v3, 1F);
}
///
@@ -106,7 +106,7 @@ public static CieLchuv FromScaledVector4(Vector4 source)
Vector3 v3 = source.AsVector3();
v3 *= new Vector3(100, 400, 360);
v3 -= new Vector3(0, 200, 0);
- return new CieLchuv(v3, true);
+ return new(v3, true);
}
///
@@ -154,7 +154,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 b17c433313..58ec9048c0 100644
--- a/src/ImageSharp/ColorProfiles/CieLuv.cs
+++ b/src/ImageSharp/ColorProfiles/CieLuv.cs
@@ -134,7 +134,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);
}
///
@@ -188,7 +188,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 744b6195e9..ef45f352df 100644
--- a/src/ImageSharp/ColorProfiles/CieXyy.cs
+++ b/src/ImageSharp/ColorProfiles/CieXyy.cs
@@ -122,10 +122,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);
}
///
@@ -144,14 +144,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/CieXyz.cs b/src/ImageSharp/ColorProfiles/CieXyz.cs
index 94fcfb21bb..b14f014695 100644
--- a/src/ImageSharp/ColorProfiles/CieXyz.cs
+++ b/src/ImageSharp/ColorProfiles/CieXyz.cs
@@ -88,7 +88,7 @@ internal Vector4 ToVector4()
{
Vector3 v3 = default;
v3 += this.AsVector3Unsafe();
- return new Vector4(v3, 1F);
+ return new(v3, 1F);
}
///
@@ -97,13 +97,13 @@ public Vector4 ToScaledVector4()
Vector3 v3 = default;
v3 += this.AsVector3Unsafe();
v3 *= 32768F / 65535;
- return new Vector4(v3, 1F);
+ return new(v3, 1F);
}
internal static CieXyz FromVector4(Vector4 source)
{
Vector3 v3 = source.AsVector3();
- return new CieXyz(v3);
+ return new(v3);
}
///
@@ -111,7 +111,7 @@ public static CieXyz FromScaledVector4(Vector4 source)
{
Vector3 v3 = source.AsVector3();
v3 *= 65535 / 32768F;
- return new CieXyz(v3);
+ return new(v3);
}
///
diff --git a/src/ImageSharp/ColorProfiles/Cmyk.cs b/src/ImageSharp/ColorProfiles/Cmyk.cs
index ee81ff9f7e..3a2ffd6fb6 100644
--- a/src/ImageSharp/ColorProfiles/Cmyk.cs
+++ b/src/ImageSharp/ColorProfiles/Cmyk.cs
@@ -26,7 +26,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))
{
}
@@ -138,12 +138,12 @@ public static Cmyk FromProfileConnectingSpace(ColorConversionOptions options, in
if (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/ColorProfileConverterExtensionsIcc.cs b/src/ImageSharp/ColorProfiles/ColorProfileConverterExtensionsIcc.cs
index c33f40001a..b00ff8200b 100644
--- a/src/ImageSharp/ColorProfiles/ColorProfileConverterExtensionsIcc.cs
+++ b/src/ImageSharp/ColorProfiles/ColorProfileConverterExtensionsIcc.cs
@@ -57,11 +57,11 @@ internal static TTo ConvertUsingIccProfile(this ColorProfileConverte
ConversionParams sourceParams = new(converter.Options.SourceIccProfile, toPcs: true);
ConversionParams targetParams = new(converter.Options.TargetIccProfile, toPcs: false);
- ColorProfileConverter pcsConverter = new(new ColorConversionOptions
+ ColorProfileConverter pcsConverter = new(new()
{
MemoryAllocator = converter.Options.MemoryAllocator,
- SourceWhitePoint = new CieXyz(converter.Options.SourceIccProfile.Header.PcsIlluminant),
- TargetWhitePoint = new CieXyz(converter.Options.TargetIccProfile.Header.PcsIlluminant),
+ SourceWhitePoint = new(converter.Options.SourceIccProfile.Header.PcsIlluminant),
+ TargetWhitePoint = new(converter.Options.TargetIccProfile.Header.PcsIlluminant),
});
// Normalize the source, then convert to the PCS space.
@@ -101,11 +101,11 @@ internal static void ConvertUsingIccProfile(this ColorProfileConvert
ConversionParams sourceParams = new(converter.Options.SourceIccProfile, toPcs: true);
ConversionParams targetParams = new(converter.Options.TargetIccProfile, toPcs: false);
- ColorProfileConverter pcsConverter = new(new ColorConversionOptions
+ ColorProfileConverter pcsConverter = new(new()
{
MemoryAllocator = converter.Options.MemoryAllocator,
- SourceWhitePoint = new CieXyz(converter.Options.SourceIccProfile.Header.PcsIlluminant),
- TargetWhitePoint = new CieXyz(converter.Options.TargetIccProfile.Header.PcsIlluminant),
+ SourceWhitePoint = new(converter.Options.SourceIccProfile.Header.PcsIlluminant),
+ TargetWhitePoint = new(converter.Options.TargetIccProfile.Header.PcsIlluminant),
});
using IMemoryOwner pcsBuffer = converter.Options.MemoryAllocator.Allocate(source.Length);
@@ -355,7 +355,7 @@ private static Vector4 GetTargetPcsWithPerceptualAdjustment(
vector = Vector3.Max(vector, Vector3.Zero);
}
- xyz = new CieXyz(AdjustPcsFromV2BlackPoint(vector));
+ xyz = new(AdjustPcsFromV2BlackPoint(vector));
}
// when converting from PCS to device with v2 perceptual intent
@@ -371,7 +371,7 @@ private static Vector4 GetTargetPcsWithPerceptualAdjustment(
vector = Vector3.Max(vector, Vector3.Zero);
}
- xyz = new CieXyz(vector);
+ xyz = new(vector);
}
switch (targetParams.PcsType)
diff --git a/src/ImageSharp/ColorProfiles/Hsl.cs b/src/ImageSharp/ColorProfiles/Hsl.cs
index 7a9365fb75..2735b55137 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))
{
}
@@ -141,7 +141,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)
@@ -172,7 +172,7 @@ public static Hsl FromProfileConnectingSpace(ColorConversionOptions options, in
s = chroma / (2F - max - min);
}
- return new Hsl(h, s, l);
+ return new(h, s, l);
}
///
@@ -213,7 +213,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 1e013fe1fb..d29b3023e7 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))
{
}
@@ -139,7 +139,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)
@@ -163,7 +163,7 @@ public static Hsv FromProfileConnectingSpace(ColorConversionOptions options, in
s = chroma / v;
- return new Hsv(h, s, v);
+ return new(h, s, v);
}
///
@@ -185,7 +185,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;
@@ -236,7 +236,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 e978c6de22..341360b12e 100644
--- a/src/ImageSharp/ColorProfiles/HunterLab.cs
+++ b/src/ImageSharp/ColorProfiles/HunterLab.cs
@@ -87,7 +87,7 @@ public Vector4 ToScaledVector4()
v3 += this.AsVector3Unsafe();
v3 += new Vector3(0, 128F, 128F);
v3 /= new Vector3(100F, 255F, 255F);
- return new Vector4(v3, 1F);
+ return new(v3, 1F);
}
///
@@ -96,7 +96,7 @@ public static HunterLab FromScaledVector4(Vector4 source)
Vector3 v3 = source.AsVector3();
v3 *= new Vector3(100F, 255, 255);
v3 -= new Vector3(0, 128F, 128F);
- return new HunterLab(v3);
+ return new(v3);
}
///
@@ -151,7 +151,7 @@ public static HunterLab FromProfileConnectingSpace(ColorConversionOptions option
b = 0;
}
- return new HunterLab(l, a, b);
+ return new(l, a, b);
}
///
@@ -184,7 +184,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/Icc/Calculators/ColorTrcCalculator.cs b/src/ImageSharp/ColorProfiles/Icc/Calculators/ColorTrcCalculator.cs
index 3604642c95..e5d95d5134 100644
--- a/src/ImageSharp/ColorProfiles/Icc/Calculators/ColorTrcCalculator.cs
+++ b/src/ImageSharp/ColorProfiles/Icc/Calculators/ColorTrcCalculator.cs
@@ -23,12 +23,12 @@ public ColorTrcCalculator(
bool toPcs)
{
this.toPcs = toPcs;
- this.curveCalculator = new TrcCalculator([redTrc, greenTrc, blueTrc], !toPcs);
+ this.curveCalculator = new([redTrc, greenTrc, blueTrc], !toPcs);
Vector3 mr = redMatrixColumn.Data[0];
Vector3 mg = greenMatrixColumn.Data[0];
Vector3 mb = blueMatrixColumn.Data[0];
- this.matrix = new Matrix4x4(mr.X, mr.Y, mr.Z, 0, mg.X, mg.Y, mg.Z, 0, mb.X, mb.Y, mb.Z, 0, 0, 0, 0, 1);
+ this.matrix = new(mr.X, mr.Y, mr.Z, 0, mg.X, mg.Y, mg.Z, 0, mb.X, mb.Y, mb.Z, 0, 0, 0, 0, 1);
if (!toPcs)
{
diff --git a/src/ImageSharp/ColorProfiles/Icc/Calculators/CurveCalculator.cs b/src/ImageSharp/ColorProfiles/Icc/Calculators/CurveCalculator.cs
index c39eaf958f..9c7a18ae8c 100644
--- a/src/ImageSharp/ColorProfiles/Icc/Calculators/CurveCalculator.cs
+++ b/src/ImageSharp/ColorProfiles/Icc/Calculators/CurveCalculator.cs
@@ -31,7 +31,7 @@ public CurveCalculator(IccCurveTagDataEntry entry, bool inverted)
}
else
{
- this.lutCalculator = new LutCalculator(entry.CurveData, inverted);
+ this.lutCalculator = new(entry.CurveData, inverted);
this.type = CalculationType.Lut;
}
}
diff --git a/src/ImageSharp/ColorProfiles/Icc/Calculators/GrayTrcCalculator.cs b/src/ImageSharp/ColorProfiles/Icc/Calculators/GrayTrcCalculator.cs
index 8d823c1e95..f39f4da52a 100644
--- a/src/ImageSharp/ColorProfiles/Icc/Calculators/GrayTrcCalculator.cs
+++ b/src/ImageSharp/ColorProfiles/Icc/Calculators/GrayTrcCalculator.cs
@@ -12,7 +12,7 @@ internal class GrayTrcCalculator : IVector4Calculator
private readonly TrcCalculator calculator;
public GrayTrcCalculator(IccTagDataEntry grayTrc, bool toPcs)
- => this.calculator = new TrcCalculator(new IccTagDataEntry[] { grayTrc }, !toPcs);
+ => this.calculator = new(new IccTagDataEntry[] { grayTrc }, !toPcs);
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public Vector4 Calculate(Vector4 value) => this.calculator.Calculate(value);
diff --git a/src/ImageSharp/ColorProfiles/Icc/Calculators/LutABCalculator.cs b/src/ImageSharp/ColorProfiles/Icc/Calculators/LutABCalculator.cs
index 172d806394..e0d1ad8d41 100644
--- a/src/ImageSharp/ColorProfiles/Icc/Calculators/LutABCalculator.cs
+++ b/src/ImageSharp/ColorProfiles/Icc/Calculators/LutABCalculator.cs
@@ -109,27 +109,27 @@ private void Init(IccTagDataEntry[] curveA, IccTagDataEntry[] curveB, IccTagData
if (hasACurve)
{
- this.curveACalculator = new TrcCalculator(curveA, false);
+ this.curveACalculator = new(curveA, false);
}
if (hasBCurve)
{
- this.curveBCalculator = new TrcCalculator(curveB, false);
+ this.curveBCalculator = new(curveB, false);
}
if (hasMCurve)
{
- this.curveMCalculator = new TrcCalculator(curveM, false);
+ this.curveMCalculator = new(curveM, false);
}
if (hasMatrix)
{
- this.matrixCalculator = new MatrixCalculator(matrix3x3.Value, matrix3x1.Value);
+ this.matrixCalculator = new(matrix3x3.Value, matrix3x1.Value);
}
if (hasClut)
{
- this.clutCalculator = new ClutCalculator(clut);
+ this.clutCalculator = new(clut);
}
}
}
diff --git a/src/ImageSharp/ColorProfiles/Icc/Calculators/LutEntryCalculator.cs b/src/ImageSharp/ColorProfiles/Icc/Calculators/LutEntryCalculator.cs
index c97578ee3f..fbeae88f8e 100644
--- a/src/ImageSharp/ColorProfiles/Icc/Calculators/LutEntryCalculator.cs
+++ b/src/ImageSharp/ColorProfiles/Icc/Calculators/LutEntryCalculator.cs
@@ -61,7 +61,7 @@ private void Init(IccLut[] inputCurve, IccLut[] outputCurve, IccClut clut, Matri
{
this.inputCurve = InitLut(inputCurve);
this.outputCurve = InitLut(outputCurve);
- this.clutCalculator = new ClutCalculator(clut);
+ this.clutCalculator = new(clut);
this.matrix = matrix;
this.doTransform = !matrix.IsIdentity && inputCurve.Length == 3;
@@ -72,7 +72,7 @@ private static LutCalculator[] InitLut(IccLut[] curves)
LutCalculator[] calculators = new LutCalculator[curves.Length];
for (int i = 0; i < curves.Length; i++)
{
- calculators[i] = new LutCalculator(curves[i].Values, false);
+ calculators[i] = new(curves[i].Values, false);
}
return calculators;
diff --git a/src/ImageSharp/ColorProfiles/Icc/Calculators/MatrixCalculator.cs b/src/ImageSharp/ColorProfiles/Icc/Calculators/MatrixCalculator.cs
index 6be1fdbf95..5eade1fc8e 100644
--- a/src/ImageSharp/ColorProfiles/Icc/Calculators/MatrixCalculator.cs
+++ b/src/ImageSharp/ColorProfiles/Icc/Calculators/MatrixCalculator.cs
@@ -14,7 +14,7 @@ internal class MatrixCalculator : IVector4Calculator
public MatrixCalculator(Matrix4x4 matrix3x3, Vector3 matrix3x1)
{
this.matrix2D = matrix3x3;
- this.matrix1D = new Vector4(matrix3x1, 0);
+ this.matrix1D = new(matrix3x1, 0);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
diff --git a/src/ImageSharp/ColorProfiles/Icc/CompactSrgbV4Profile.cs b/src/ImageSharp/ColorProfiles/Icc/CompactSrgbV4Profile.cs
index 29e30b53e2..f0ee4ba580 100644
--- a/src/ImageSharp/ColorProfiles/Icc/CompactSrgbV4Profile.cs
+++ b/src/ImageSharp/ColorProfiles/Icc/CompactSrgbV4Profile.cs
@@ -37,6 +37,6 @@ private static IccProfile GetIccProfile()
{
byte[] buffer = new byte[Data.Length];
Data.CopyTo(buffer);
- return new IccProfile(buffer);
+ return new(buffer);
}
}
diff --git a/src/ImageSharp/ColorProfiles/Icc/IccConverterbase.Conversions.cs b/src/ImageSharp/ColorProfiles/Icc/IccConverterbase.Conversions.cs
index 20df08e378..917be020b5 100644
--- a/src/ImageSharp/ColorProfiles/Icc/IccConverterbase.Conversions.cs
+++ b/src/ImageSharp/ColorProfiles/Icc/IccConverterbase.Conversions.cs
@@ -91,7 +91,7 @@ private static ColorTrcCalculator InitColorTrc(IccProfile profile, bool toPcs)
throw new InvalidIccProfileException("Missing matrix column or channel.");
}
- return new ColorTrcCalculator(
+ return new(
redMatrixColumn,
greenMatrixColumn,
blueMatrixColumn,
@@ -104,6 +104,6 @@ private static ColorTrcCalculator InitColorTrc(IccProfile profile, bool toPcs)
private static GrayTrcCalculator InitGrayTrc(IccProfile profile, bool toPcs)
{
IccTagDataEntry entry = GetTag(profile, IccProfileTag.GrayTrc);
- return new GrayTrcCalculator(entry, toPcs);
+ return new(entry, toPcs);
}
}
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/KnownYCbCrMatrices.cs b/src/ImageSharp/ColorProfiles/KnownYCbCrMatrices.cs
index d32833a382..b838f9ddc9 100644
--- a/src/ImageSharp/ColorProfiles/KnownYCbCrMatrices.cs
+++ b/src/ImageSharp/ColorProfiles/KnownYCbCrMatrices.cs
@@ -16,47 +16,47 @@ public static class KnownYCbCrMatrices
/// ITU-R BT.601 (SD video standard).
///
public static readonly YCbCrTransform BT601 = new(
- new Matrix4x4(
+ new(
0.299000F, 0.587000F, 0.114000F, 0F,
-0.168736F, -0.331264F, 0.500000F, 0F,
0.500000F, -0.418688F, -0.081312F, 0F,
0F, 0F, 0F, 1F),
- new Matrix4x4(
+ new(
1.000000F, 0.000000F, 1.402000F, 0F,
1.000000F, -0.344136F, -0.714136F, 0F,
1.000000F, 1.772000F, 0.000000F, 0F,
0F, 0F, 0F, 1F),
- new Vector3(0F, 0.5F, 0.5F));
+ new(0F, 0.5F, 0.5F));
///
/// ITU-R BT.709 (HD video, sRGB standard).
///
public static readonly YCbCrTransform BT709 = new(
- new Matrix4x4(
+ new(
0.212600F, 0.715200F, 0.072200F, 0F,
-0.114572F, -0.385428F, 0.500000F, 0F,
0.500000F, -0.454153F, -0.045847F, 0F,
0F, 0F, 0F, 1F),
- new Matrix4x4(
+ new(
1.000000F, 0.000000F, 1.574800F, 0F,
1.000000F, -0.187324F, -0.468124F, 0F,
1.000000F, 1.855600F, 0.000000F, 0F,
0F, 0F, 0F, 1F),
- new Vector3(0F, 0.5F, 0.5F));
+ new(0F, 0.5F, 0.5F));
///
/// ITU-R BT.2020 (UHD/4K video standard).
///
public static readonly YCbCrTransform BT2020 = new(
- new Matrix4x4(
+ new(
0.262700F, 0.678000F, 0.059300F, 0F,
-0.139630F, -0.360370F, 0.500000F, 0F,
0.500000F, -0.459786F, -0.040214F, 0F,
0F, 0F, 0F, 1F),
- new Matrix4x4(
+ new(
1.000000F, 0.000000F, 1.474600F, 0F,
1.000000F, -0.164553F, -0.571353F, 0F,
1.000000F, 1.881400F, 0.000000F, 0F,
0F, 0F, 0F, 1F),
- new Vector3(0F, 0.5F, 0.5F));
+ new(0F, 0.5F, 0.5F));
}
diff --git a/src/ImageSharp/ColorProfiles/Lms.cs b/src/ImageSharp/ColorProfiles/Lms.cs
index 3aa3d72557..86cb7956bf 100644
--- a/src/ImageSharp/ColorProfiles/Lms.cs
+++ b/src/ImageSharp/ColorProfiles/Lms.cs
@@ -89,7 +89,7 @@ public Vector4 ToScaledVector4()
v3 += this.AsVector3Unsafe();
v3 += new Vector3(1F);
v3 /= 2F;
- return new Vector4(v3, 1F);
+ return new(v3, 1F);
}
///
@@ -98,7 +98,7 @@ public static Lms FromScaledVector4(Vector4 source)
Vector3 v3 = source.AsVector3();
v3 *= 2F;
v3 -= new Vector3(1F);
- return new Lms(v3);
+ return new(v3);
}
///
diff --git a/src/ImageSharp/ColorProfiles/Rgb.cs b/src/ImageSharp/ColorProfiles/Rgb.cs
index 42e502592c..4d7788fcfb 100644
--- a/src/ImageSharp/ColorProfiles/Rgb.cs
+++ b/src/ImageSharp/ColorProfiles/Rgb.cs
@@ -154,7 +154,7 @@ public CieXyz ToProfileConnectingSpace(ColorConversionOptions options)
Rgb linear = FromScaledVector4(options.SourceRgbWorkingSpace.Expand(this.ToScaledVector4()));
// Then convert to xyz
- return new CieXyz(Vector3.Transform(linear.AsVector3Unsafe(), GetRgbToCieXyzMatrix(options.SourceRgbWorkingSpace)));
+ return new(Vector3.Transform(linear.AsVector3Unsafe(), GetRgbToCieXyzMatrix(options.SourceRgbWorkingSpace)));
}
///
@@ -171,7 +171,7 @@ public static void ToProfileConnectionSpace(ColorConversionOptions options, Read
Rgb linear = FromScaledVector4(options.SourceRgbWorkingSpace.Expand(rgb.ToScaledVector4()));
// Then convert to xyz
- destination[i] = new CieXyz(Vector3.Transform(linear.AsVector3Unsafe(), matrix));
+ destination[i] = new(Vector3.Transform(linear.AsVector3Unsafe(), matrix));
}
}
@@ -274,7 +274,7 @@ private static Matrix4x4 GetRgbToCieXyzMatrix(RgbWorkingSpace workingSpace)
Vector3 vector = Vector3.Transform(workingSpace.WhitePoint.AsVector3Unsafe(), 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 ec25d0e1c4..6f06ccf27a 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.AsVector3Unsafe(), 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/Y.cs b/src/ImageSharp/ColorProfiles/Y.cs
index 83321a0851..62cef78146 100644
--- a/src/ImageSharp/ColorProfiles/Y.cs
+++ b/src/ImageSharp/ColorProfiles/Y.cs
@@ -92,7 +92,7 @@ public static Y FromProfileConnectingSpace(ColorConversionOptions options, in Rg
{
Matrix4x4 m = options.YCbCrTransform.Forward;
float offset = options.YCbCrTransform.Offset.X;
- return new(Vector3.Dot(source.AsVector3Unsafe(), new Vector3(m.M11, m.M12, m.M13)) + offset);
+ return new(Vector3.Dot(source.AsVector3Unsafe(), new(m.M11, m.M12, m.M13)) + offset);
}
///
diff --git a/src/ImageSharp/ColorProfiles/YCbCr.cs b/src/ImageSharp/ColorProfiles/YCbCr.cs
index 22d629373b..e112ef7992 100644
--- a/src/ImageSharp/ColorProfiles/YCbCr.cs
+++ b/src/ImageSharp/ColorProfiles/YCbCr.cs
@@ -24,7 +24,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))
{
}
@@ -95,7 +95,7 @@ public Vector4 ToScaledVector4()
{
Vector3 v3 = default;
v3 += this.AsVector3Unsafe();
- return new Vector4(v3, 1F);
+ return new(v3, 1F);
}
///
@@ -133,7 +133,7 @@ public static YCbCr FromProfileConnectingSpace(ColorConversionOptions options, i
Matrix4x4 m = options.TransposedYCbCrTransform.Forward;
Vector3 offset = options.TransposedYCbCrTransform.Offset;
- return new YCbCr(Vector3.Transform(rgb, m) + offset, true);
+ return new(Vector3.Transform(rgb, m) + offset, true);
}
///
diff --git a/src/ImageSharp/ColorProfiles/YccK.cs b/src/ImageSharp/ColorProfiles/YccK.cs
index df5eb48947..d0966a6d12 100644
--- a/src/ImageSharp/ColorProfiles/YccK.cs
+++ b/src/ImageSharp/ColorProfiles/YccK.cs
@@ -27,7 +27,7 @@ namespace SixLabors.ImageSharp.ColorProfiles;
/// The keyline black component.
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public YccK(float y, float cb, float cr, float k)
- : this(new Vector4(y, cb, cr, k))
+ : this(new(y, cb, cr, k))
{
}
@@ -149,11 +149,11 @@ public static YccK FromProfileConnectingSpace(ColorConversionOptions options, in
if (k >= 1F - Constants.Epsilon)
{
- return new YccK(new Vector4(0F, 0.5F, 0.5F, 1F), true);
+ return new(new(0F, 0.5F, 0.5F, 1F), true);
}
rgb /= 1F - k;
- return new YccK(new Vector4(Vector3.Transform(rgb, m), k) + new Vector4(offset, 0F));
+ return new(new Vector4(Vector3.Transform(rgb, m), k) + new Vector4(offset, 0F));
}
///
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/Numerics.cs b/src/ImageSharp/Common/Helpers/Numerics.cs
index 5f91dcd998..0aa8e4a418 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 7f98c83754..883e18ae73 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);
}
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/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/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..a05320a09e 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();
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/Formats/Bmp/BmpDecoderCore.cs b/src/ImageSharp/Formats/Bmp/BmpDecoderCore.cs
index b9b32dede7..acf69529aa 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 46da463455..ba9a0dc232 100644
--- a/src/ImageSharp/Formats/Bmp/BmpEncoderCore.cs
+++ b/src/ImageSharp/Formats/Bmp/BmpEncoderCore.cs
@@ -655,7 +655,7 @@ private void Write4BitPixelData(
CancellationToken cancellationToken)
where TPixel : unmanaged, IPixel
{
- using IQuantizer frameQuantizer = this.quantizer.CreatePixelSpecificQuantizer(configuration, new QuantizerOptions()
+ using IQuantizer frameQuantizer = this.quantizer.CreatePixelSpecificQuantizer(configuration, new()
{
MaxColors = 16,
Dither = this.quantizer.Options.Dither,
@@ -712,7 +712,7 @@ private void Write2BitPixelData(
CancellationToken cancellationToken)
where TPixel : unmanaged, IPixel
{
- using IQuantizer frameQuantizer = this.quantizer.CreatePixelSpecificQuantizer(configuration, new QuantizerOptions()
+ using IQuantizer frameQuantizer = this.quantizer.CreatePixelSpecificQuantizer(configuration, new()
{
MaxColors = 4,
Dither = this.quantizer.Options.Dither,
@@ -778,7 +778,7 @@ private void Write1BitPixelData(
CancellationToken cancellationToken)
where TPixel : unmanaged, IPixel
{
- using IQuantizer frameQuantizer = this.quantizer.CreatePixelSpecificQuantizer(configuration, new QuantizerOptions()
+ using IQuantizer frameQuantizer = this.quantizer.CreatePixelSpecificQuantizer(configuration, new()
{
MaxColors = 2,
Dither = this.quantizer.Options.Dither,
diff --git a/src/ImageSharp/Formats/Bmp/BmpMetadata.cs b/src/ImageSharp/Formats/Bmp/BmpMetadata.cs
index 1dac74ba3a..3514a7ed56 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 9854854aad..454f15b862 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
@@ -98,7 +98,7 @@ public static CurFrameMetadata FromFormatConnectingFrameMetadata(FormatConnectin
compression = IconFrameCompression.Png;
}
- return new CurFrameMetadata
+ return new()
{
BmpBitsPerPixel = bbpp,
Compression = compression,
@@ -210,7 +210,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 d8fdb32902..6499c5b422 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
@@ -129,7 +129,7 @@ public PixelTypeInfo GetPixelTypeInfo()
}
}
- return new PixelTypeInfo(bpp)
+ return new(bpp)
{
AlphaRepresentation = alpha,
ComponentInfo = info,
diff --git a/src/ImageSharp/Formats/Gif/GifDecoderCore.cs b/src/ImageSharp/Formats/Gif/GifDecoderCore.cs
index 6a28c3403b..4817edcf7b 100644
--- a/src/ImageSharp/Formats/Gif/GifDecoderCore.cs
+++ b/src/ImageSharp/Formats/Gif/GifDecoderCore.cs
@@ -266,7 +266,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);
@@ -344,7 +344,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
{
@@ -554,7 +554,7 @@ private void ReadFrameColors(
if (previousFrame is null && previousDisposalMode is null)
{
image = transFlag
- ? new Image(this.configuration, imageWidth, imageHeight, this.metadata)
+ ? new(this.configuration, imageWidth, imageHeight, this.metadata)
: new Image(this.configuration, imageWidth, imageHeight, backgroundPixel, 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 77f600633b..d6e9c780bd 100644
--- a/src/ImageSharp/Formats/Gif/GifMetadata.cs
+++ b/src/ImageSharp/Formats/Gif/GifMetadata.cs
@@ -87,7 +87,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/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..b32f91205e 100644
--- a/src/ImageSharp/Formats/Gif/Sections/GifXmpApplicationExtension.cs
+++ b/src/ImageSharp/Formats/Gif/Sections/GifXmpApplicationExtension.cs
@@ -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 31f65133e6..3afb02456a 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
@@ -91,7 +91,7 @@ public static IcoFrameMetadata FromFormatConnectingFrameMetadata(FormatConnectin
compression = IconFrameCompression.Png;
}
- return new IcoFrameMetadata
+ return new()
{
BmpBitsPerPixel = bbpp,
Compression = compression,
@@ -205,7 +205,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 f8c2ff40f2..4436dce855 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
@@ -129,7 +129,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 731ad0f765..754f1f8b49 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 StringBuilder();
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..1c0615ef52 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 Vector4(sLeft.X);
xyLeft.Z = sLeft.Y;
xyLeft.W = sLeft.Y;
- var zwLeft = new Vector4(sLeft.Z);
+ Vector4 zwLeft = new Vector4(sLeft.Z);
zwLeft.Z = sLeft.W;
zwLeft.W = sLeft.W;
- var xyRight = new Vector4(sRight.X);
+ Vector4 xyRight = new Vector4(sRight.X);
xyRight.Z = sRight.Y;
xyRight.W = sRight.Y;
- var zwRight = new Vector4(sRight.Z);
+ Vector4 zwRight = new Vector4(sRight.Z);
zwRight.Z = sRight.W;
zwRight.W = sRight.W;
diff --git a/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverterBase.cs b/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverterBase.cs
index 74227c7a6e..7d236eeae9 100644
--- a/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverterBase.cs
+++ b/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverterBase.cs
@@ -514,7 +514,7 @@ public ComponentValues Slice(int start, int length)
Span c2 = this.Component2.Length > 0 ? this.Component2.Slice(start, length) : [];
Span c3 = this.Component3.Length > 0 ? this.Component3.Slice(start, length) : [];
- 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 6e83f5b2b4..ba6276a5c8 100644
--- a/src/ImageSharp/Formats/Jpeg/Components/Decoder/ArithmeticScanDecoder.cs
+++ b/src/ImageSharp/Formats/Jpeg/Components/Decoder/ArithmeticScanDecoder.cs
@@ -242,7 +242,7 @@ public void ParseEntropyCodedData(int scanComponentCount, IccProfile iccProfile)
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 9ee43a2c83..b43df4d974 100644
--- a/src/ImageSharp/Formats/Jpeg/Components/Decoder/HuffmanScanDecoder.cs
+++ b/src/ImageSharp/Formats/Jpeg/Components/Decoder/HuffmanScanDecoder.cs
@@ -116,7 +116,7 @@ public void ParseEntropyCodedData(int scanComponentCount, IccProfile iccProfile)
this.scanComponentCount = scanComponentCount;
- this.scanBuffer = new JpegBitReader(this.stream);
+ this.scanBuffer = new(this.stream);
this.frame.AllocateComponents();
@@ -784,6 +784,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/SpectralConverter.cs b/src/ImageSharp/Formats/Jpeg/Components/Decoder/SpectralConverter.cs
index 0703e4d9e0..5b77ab1534 100644
--- a/src/ImageSharp/Formats/Jpeg/Components/Decoder/SpectralConverter.cs
+++ b/src/ImageSharp/Formats/Jpeg/Components/Decoder/SpectralConverter.cs
@@ -121,7 +121,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..1704ae1e74 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 Vector(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 90e16f6dff..857f2a1fe5 100644
--- a/src/ImageSharp/Formats/Jpeg/Components/Encoder/HuffmanScanEncoder.cs
+++ b/src/ImageSharp/Formats/Jpeg/Components/Encoder/HuffmanScanEncoder.cs
@@ -134,7 +134,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);
}
///
@@ -409,7 +409,7 @@ private void EncodeScanBaselineInterleaved(JpegFrame frame, SpectralConv
{
this.FlushRemainingBytes();
this.WriteRestart(restarts % 8);
- foreach (var component in frame.Components)
+ foreach (Component component in frame.Components)
{
component.DcPredictor = 0;
}
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 baaa7213ad..e97c57cd95 100644
--- a/src/ImageSharp/Formats/Jpeg/Components/Encoder/SpectralConverter{TPixel}.cs
+++ b/src/ImageSharp/Formats/Jpeg/Components/Encoder/SpectralConverter{TPixel}.cs
@@ -46,12 +46,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,
@@ -119,7 +119,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/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/JpegDecoderCore.cs b/src/ImageSharp/Formats/Jpeg/JpegDecoderCore.cs
index 0b2d3d67ea..c9ac1e6bb1 100644
--- a/src/ImageSharp/Formats/Jpeg/JpegDecoderCore.cs
+++ b/src/ImageSharp/Formats/Jpeg/JpegDecoderCore.cs
@@ -167,7 +167,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.
@@ -179,14 +179,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);
}
}
}
@@ -205,7 +205,7 @@ protected override Image Decode(BufferedReadStream stream, Cance
_ = this.Options.TryGetIccProfileForColorConversion(this.Metadata.IccProfile, out IccProfile profile);
- return new Image(
+ return new(
this.configuration,
spectralConverter.GetPixelBuffer(profile, cancellationToken),
this.Metadata);
@@ -222,7 +222,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);
}
///
@@ -233,7 +233,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)
@@ -256,7 +256,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))
{
@@ -300,7 +300,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);
}
}
@@ -316,7 +316,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];
@@ -529,7 +529,7 @@ private void ProcessComMarker(BufferedReadStream stream, int markerContentByteSi
chars[i] = (char)read;
}
- metadata.Comments.Add(new JpegComData(chars));
+ metadata.Comments.Add(new(chars));
}
///
@@ -661,7 +661,7 @@ private void InitExifProfile()
{
if (this.hasExif)
{
- this.Metadata.ExifProfile = new ExifProfile(this.exifData);
+ this.Metadata.ExifProfile = new(this.exifData);
}
}
@@ -685,7 +685,7 @@ private void SetIccMetadata(IccProfile profile)
if (!this.skipMetadata && profile?.CheckIsValid() == true)
{
this.hasIcc = true;
- this.Metadata ??= new ImageMetadata();
+ this.Metadata ??= new();
this.Metadata.IccProfile = profile;
}
}
@@ -697,7 +697,7 @@ private void InitIptcProfile()
{
if (this.hasIptc)
{
- this.Metadata.IptcProfile = new IptcProfile(this.iptcData);
+ this.Metadata.IptcProfile = new(this.iptcData);
}
}
@@ -708,7 +708,7 @@ private void InitXmpProfile()
{
if (this.hasXmp)
{
- this.Metadata.XmpProfile = new XmpProfile(this.xmpData);
+ this.Metadata.XmpProfile = new(this.xmpData);
}
}
@@ -992,7 +992,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)
{
@@ -1242,7 +1242,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..9a89eced28 100644
--- a/src/ImageSharp/Formats/Jpeg/JpegEncoderCore.FrameConfig.cs
+++ b/src/ImageSharp/Formats/Jpeg/JpegEncoderCore.FrameConfig.cs
@@ -13,15 +13,15 @@ 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 JpegHuffmanTableConfig(@class: 0, destIndex: 0, HuffmanSpec.LuminanceDC);
+ JpegHuffmanTableConfig defaultLuminanceHuffmanAC = new JpegHuffmanTableConfig(@class: 1, destIndex: 0, HuffmanSpec.LuminanceAC);
+ JpegHuffmanTableConfig defaultChrominanceHuffmanDC = new JpegHuffmanTableConfig(@class: 0, destIndex: 1, HuffmanSpec.ChrominanceDC);
+ JpegHuffmanTableConfig defaultChrominanceHuffmanAC = new JpegHuffmanTableConfig(@class: 1, destIndex: 1, HuffmanSpec.ChrominanceAC);
- var defaultLuminanceQuantTable = new JpegQuantizationTableConfig(0, Quantization.LuminanceTable);
- var defaultChrominanceQuantTable = new JpegQuantizationTableConfig(1, Quantization.ChrominanceTable);
+ JpegQuantizationTableConfig defaultLuminanceQuantTable = new JpegQuantizationTableConfig(0, Quantization.LuminanceTable);
+ JpegQuantizationTableConfig defaultChrominanceQuantTable = new JpegQuantizationTableConfig(1, Quantization.ChrominanceTable);
- var yCbCrHuffmanConfigs = new JpegHuffmanTableConfig[]
+ JpegHuffmanTableConfig[] yCbCrHuffmanConfigs = new JpegHuffmanTableConfig[]
{
defaultLuminanceHuffmanDC,
defaultLuminanceHuffmanAC,
@@ -29,7 +29,7 @@ private static JpegFrameConfig[] CreateFrameConfigs()
defaultChrominanceHuffmanAC,
};
- var yCbCrQuantTableConfigs = new JpegQuantizationTableConfig[]
+ JpegQuantizationTableConfig[] yCbCrQuantTableConfigs = new JpegQuantizationTableConfig[]
{
defaultLuminanceQuantTable,
defaultChrominanceQuantTable,
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/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/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/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 0971c3ecfc..577c15272b 100644
--- a/src/ImageSharp/Formats/Png/PngDecoderCore.cs
+++ b/src/ImageSharp/Formats/Png/PngDecoderCore.cs
@@ -297,7 +297,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;
@@ -497,7 +497,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;
@@ -525,7 +525,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
{
@@ -626,7 +626,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);
@@ -1377,7 +1377,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));
}
}
@@ -1418,7 +1418,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));
}
}
@@ -1476,7 +1476,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);
}
///
@@ -1560,7 +1560,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;
}
@@ -1594,7 +1594,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);
}
}
@@ -1750,17 +1750,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.
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/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 59ca3b17a0..fcbb93bf0a 100644
--- a/src/ImageSharp/Formats/Png/PngMetadata.cs
+++ b/src/ImageSharp/Formats/Png/PngMetadata.cs
@@ -209,7 +209,7 @@ public PixelTypeInfo GetPixelTypeInfo()
break;
}
- return new PixelTypeInfo(bpp)
+ return new(bpp)
{
AlphaRepresentation = alpha,
ColorType = colorType,
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/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/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 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..1d7de583f7 100644
--- a/src/ImageSharp/Formats/Tiff/Compression/Compressors/DeflateCompressor.cs
+++ b/src/ImageSharp/Formats/Tiff/Compression/Compressors/DeflateCompressor.cs
@@ -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 ZlibDeflateStream(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/TiffJpegCompressor.cs b/src/ImageSharp/Formats/Tiff/Compression/Compressors/TiffJpegCompressor.cs
index 08faa539a8..a2a83be0a6 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 MemoryStream();
+ 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 64e702f1be..39c3928150 100644
--- a/src/ImageSharp/Formats/Tiff/Compression/Decompressors/DeflateTiffCompression.cs
+++ b/src/ImageSharp/Formats/Tiff/Compression/Decompressors/DeflateTiffCompression.cs
@@ -54,7 +54,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 ZlibInflateStream(
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 2402927186..beb22a2bb6 100644
--- a/src/ImageSharp/Formats/Tiff/Compression/Decompressors/LzwTiffCompression.cs
+++ b/src/ImageSharp/Formats/Tiff/Compression/Decompressors/LzwTiffCompression.cs
@@ -48,7 +48,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 TiffLzwDecoder(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..f0ed12c411 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 ModifiedHuffmanBitReader(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..4d09f7b4e0 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 T4BitReader(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 706e6a38c1..ebf4042e2b 100644
--- a/src/ImageSharp/Formats/Tiff/Compression/HorizontalPredictor.cs
+++ b/src/ImageSharp/Formats/Tiff/Compression/HorizontalPredictor.cs
@@ -222,7 +222,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);
}
}
}
@@ -429,7 +429,7 @@ private static void UndoRgb24BitRow(Span pixelBytes, int width, int y)
r += pixel.R;
g += pixel.G;
b += pixel.B;
- pixel = new Rgb24(r, g, b);
+ pixel = new(r, g, b);
}
}
@@ -462,7 +462,7 @@ private static void UndoRgba32BitRow(Span pixelBytes, int width, int y)
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/CmykTiffColor{TPixel}.cs b/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/CmykTiffColor{TPixel}.cs
index b0580ead39..86e5841935 100644
--- a/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/CmykTiffColor{TPixel}.cs
+++ b/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/CmykTiffColor{TPixel}.cs
@@ -31,7 +31,7 @@ public override void Decode(ReadOnlySpan data, Buffer2D pixels, in
Span pixelRow = pixels.DangerousGetRowSpan(y).Slice(left, width);
for (int x = 0; x < pixelRow.Length; x++)
{
- pixelRow[x] = TPixel.FromVector4(new Vector4(data[offset] * Inv255, data[offset + 1] * Inv255, data[offset + 2] * Inv255, 1.0f));
+ pixelRow[x] = TPixel.FromVector4(new(data[offset] * Inv255, data[offset + 1] * Inv255, data[offset + 2] * Inv255, 1.0f));
offset += 3;
}
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..754cbd0059 100644
--- a/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/YCbCrConverter.cs
+++ b/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/YCbCrConverter.cs
@@ -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 e594ee8121..73f66a062a 100644
--- a/src/ImageSharp/Formats/Tiff/TiffDecoderCore.cs
+++ b/src/ImageSharp/Formats/Tiff/TiffDecoderCore.cs
@@ -191,7 +191,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
{
@@ -228,7 +228,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);
}
///
@@ -285,7 +285,7 @@ private ImageFrame DecodeFrame(ExifProfile tags, Size? size, Can
// We resolve the ICC profile early so that we can use it for color conversion if needed.
if (tags.TryGetValue(ExifTag.IccProfile, out IExifValue iccProfileBytes))
{
- imageFrameMetaData.IccProfile = new IccProfile(iccProfileBytes.Value);
+ imageFrameMetaData.IccProfile = new(iccProfileBytes.Value);
}
}
diff --git a/src/ImageSharp/Formats/Tiff/TiffDecoderMetadataCreator.cs b/src/ImageSharp/Formats/Tiff/TiffDecoderMetadataCreator.cs
index ebf407f9b5..db27854a17 100644
--- a/src/ImageSharp/Formats/Tiff/TiffDecoderMetadataCreator.cs
+++ b/src/ImageSharp/Formats/Tiff/TiffDecoderMetadataCreator.cs
@@ -33,12 +33,12 @@ 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);
}
}
}
diff --git a/src/ImageSharp/Formats/Tiff/TiffDecoderOptionsParser.cs b/src/ImageSharp/Formats/Tiff/TiffDecoderOptionsParser.cs
index 7519871b74..9583994543 100644
--- a/src/ImageSharp/Formats/Tiff/TiffDecoderOptionsParser.cs
+++ b/src/ImageSharp/Formats/Tiff/TiffDecoderOptionsParser.cs
@@ -531,7 +531,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;
@@ -549,7 +549,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;
@@ -557,7 +557,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/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/Webp/AlphaDecoder.cs b/src/ImageSharp/Formats/Webp/AlphaDecoder.cs
index c7ce12fc7b..f374daba4f 100644
--- a/src/ImageSharp/Formats/Webp/AlphaDecoder.cs
+++ b/src/ImageSharp/Formats/Webp/AlphaDecoder.cs
@@ -56,12 +56,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 fd6f508e4a..56587da187 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/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 274d4426f9..bac6d5167c 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.
@@ -281,7 +281,7 @@ private static void BackwardReferencesHashChainDistanceOnly(
if (useColorCache)
{
- colorCache = new ColorCache(cacheBits);
+ colorCache = new(cacheBits);
}
costModel.Build(xSize, cacheBits, refs);
@@ -383,7 +383,7 @@ private static void BackwardReferencesHashChainFollowChosenPath(ReadOnlySpan 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/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..fd5d1dd940 100644
--- a/src/ImageSharp/Formats/Webp/Lossless/HuffmanUtils.cs
+++ b/src/ImageSharp/Formats/Webp/Lossless/HuffmanUtils.cs
@@ -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/PredictorEncoder.cs b/src/ImageSharp/Formats/Webp/Lossless/PredictorEncoder.cs
index 736070a1c9..19dc08fc5b 100644
--- a/src/ImageSharp/Formats/Webp/Lossless/PredictorEncoder.cs
+++ b/src/ImageSharp/Formats/Webp/Lossless/PredictorEncoder.cs
@@ -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++)
@@ -856,7 +856,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/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 b398554eb1..2cbe4bbb61 100644
--- a/src/ImageSharp/Formats/Webp/Lossless/Vp8LEncoder.cs
+++ b/src/ImageSharp/Formats/Webp/Lossless/Vp8LEncoder.cs
@@ -124,16 +124,16 @@ 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);
for (int i = 0; i < this.Refs.Length; i++)
{
- this.Refs[i] = new Vp8LBackwardRefs(memoryAllocator, pixelCount);
+ this.Refs[i] = new(memoryAllocator, pixelCount);
}
}
@@ -549,14 +549,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.
@@ -565,7 +565,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 });
}
}
}
@@ -575,7 +575,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
@@ -712,7 +712,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++)
@@ -858,7 +858,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.
diff --git a/src/ImageSharp/Formats/Webp/Lossless/Vp8LHistogram.cs b/src/ImageSharp/Formats/Webp/Lossless/Vp8LHistogram.cs
index 03bedfe672..5b3ecc7f57 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 6de3ae7497..af26616ccb 100644
--- a/src/ImageSharp/Formats/Webp/Lossless/WebpLosslessDecoder.cs
+++ b/src/ImageSharp/Formats/Webp/Lossless/WebpLosslessDecoder.cs
@@ -108,7 +108,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 +129,7 @@ public IMemoryOwner DecodeImageStream(Vp8LDecoder decoder, int xSize, int
}
else
{
- decoder.Metadata = new Vp8LMetadata();
+ decoder.Metadata = new();
}
// Color cache.
@@ -156,7 +156,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 +416,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/QuantEnc.cs b/src/ImageSharp/Formats/Webp/Lossy/QuantEnc.cs
index e9eb1110b0..31030adb03 100644
--- a/src/ImageSharp/Formats/Webp/Lossy/QuantEnc.cs
+++ b/src/ImageSharp/Formats/Webp/Lossy/QuantEnc.cs
@@ -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 Vp8ModeScore();
+ Vp8Residual res = new Vp8Residual();
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 Vp8ModeScore();
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();
+ Vp8ModeScore rdTmp = new Vp8ModeScore();
+ Vp8Residual res = new Vp8Residual();
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();
+ Vp8ModeScore rdUv = new Vp8ModeScore();
+ Vp8Residual res = new Vp8Residual();
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 3c8bafa1b2..cd9a0dea2a 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..7f57c81f84 100644
--- a/src/ImageSharp/Formats/Webp/Lossy/Vp8EncIterator.cs
+++ b/src/ImageSharp/Formats/Webp/Lossy/Vp8EncIterator.cs
@@ -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 e4ebe14731..608c5391b3 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,
@@ -424,14 +424,14 @@ private bool Encode(
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/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/WebpAnimationDecoder.cs b/src/ImageSharp/Formats/Webp/WebpAnimationDecoder.cs
index 173d9436dd..d19efec3b1 100644
--- a/src/ImageSharp/Formats/Webp/WebpAnimationDecoder.cs
+++ b/src/ImageSharp/Formats/Webp/WebpAnimationDecoder.cs
@@ -93,7 +93,7 @@ public Image Decode(
ImageFrame? previousFrame = null;
WebpFrameData? prevFrameData = null;
- this.metadata = new ImageMetadata();
+ this.metadata = new();
this.webpMetadata = this.metadata.GetWebpMetadata();
this.webpMetadata.RepeatCount = features.AnimationLoopCount;
@@ -204,7 +204,7 @@ private uint ReadFrame(
ImageFrame currentFrame;
if (previousFrame is null)
{
- image = new Image(this.configuration, (int)width, (int)height, backgroundColor, this.metadata);
+ image = new(this.configuration, (int)width, (int)height, backgroundColor, this.metadata);
currentFrame = image.Frames.RootFrame;
SetFrameMetadata(currentFrame.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/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 51379a32ae..dfd80c8380 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/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..aa0590619a 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 GraphicsOptions();
// 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/Image.Decode.cs b/src/ImageSharp/Image.Decode.cs
index d2ee0f9061..7e61e50950 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);
}
///