Browse Source

use Explicit Types and Target Type new

pull/2951/head
Stefan Nikolei 11 months ago
parent
commit
57f5966fe7
  1. 8
      .editorconfig
  2. 4
      src/ImageSharp/Advanced/ParallelExecutionSettings.cs
  3. 4
      src/ImageSharp/Advanced/ParallelRowIterator.Wrappers.cs
  4. 28
      src/ImageSharp/Advanced/ParallelRowIterator.cs
  5. 2
      src/ImageSharp/Color/Color.WebSafePalette.cs
  6. 6
      src/ImageSharp/ColorProfiles/CieLab.cs
  7. 10
      src/ImageSharp/ColorProfiles/CieLch.cs
  8. 8
      src/ImageSharp/ColorProfiles/CieLchuv.cs
  9. 4
      src/ImageSharp/ColorProfiles/CieLuv.cs
  10. 8
      src/ImageSharp/ColorProfiles/CieXyy.cs
  11. 8
      src/ImageSharp/ColorProfiles/CieXyz.cs
  12. 6
      src/ImageSharp/ColorProfiles/Cmyk.cs
  13. 16
      src/ImageSharp/ColorProfiles/ColorProfileConverterExtensionsIcc.cs
  14. 8
      src/ImageSharp/ColorProfiles/Hsl.cs
  15. 10
      src/ImageSharp/ColorProfiles/Hsv.cs
  16. 8
      src/ImageSharp/ColorProfiles/HunterLab.cs
  17. 4
      src/ImageSharp/ColorProfiles/Icc/Calculators/ColorTrcCalculator.cs
  18. 2
      src/ImageSharp/ColorProfiles/Icc/Calculators/CurveCalculator.cs
  19. 2
      src/ImageSharp/ColorProfiles/Icc/Calculators/GrayTrcCalculator.cs
  20. 10
      src/ImageSharp/ColorProfiles/Icc/Calculators/LutABCalculator.cs
  21. 4
      src/ImageSharp/ColorProfiles/Icc/Calculators/LutEntryCalculator.cs
  22. 2
      src/ImageSharp/ColorProfiles/Icc/Calculators/MatrixCalculator.cs
  23. 2
      src/ImageSharp/ColorProfiles/Icc/CompactSrgbV4Profile.cs
  24. 4
      src/ImageSharp/ColorProfiles/Icc/IccConverterbase.Conversions.cs
  25. 12
      src/ImageSharp/ColorProfiles/KnownChromaticAdaptationMatrices.cs
  26. 38
      src/ImageSharp/ColorProfiles/KnownRgbWorkingSpaces.cs
  27. 18
      src/ImageSharp/ColorProfiles/KnownYCbCrMatrices.cs
  28. 4
      src/ImageSharp/ColorProfiles/Lms.cs
  29. 6
      src/ImageSharp/ColorProfiles/Rgb.cs
  30. 4
      src/ImageSharp/ColorProfiles/VonKriesChromaticAdaptation.cs
  31. 2
      src/ImageSharp/ColorProfiles/Y.cs
  32. 6
      src/ImageSharp/ColorProfiles/YCbCr.cs
  33. 6
      src/ImageSharp/ColorProfiles/YccK.cs
  34. 2
      src/ImageSharp/Common/Extensions/ConfigurationExtensions.cs
  35. 10
      src/ImageSharp/Common/Helpers/Numerics.cs
  36. 2
      src/ImageSharp/Common/Helpers/SimdUtils.Pack.cs
  37. 2
      src/ImageSharp/Common/Helpers/SimdUtils.cs
  38. 4
      src/ImageSharp/Common/Helpers/UnitConverter.cs
  39. 2
      src/ImageSharp/Compression/Zlib/Deflater.cs
  40. 2
      src/ImageSharp/Compression/Zlib/DeflaterEngine.cs
  41. 8
      src/ImageSharp/Compression/Zlib/DeflaterHuffman.cs
  42. 2
      src/ImageSharp/Compression/Zlib/DeflaterOutputStream.cs
  43. 2
      src/ImageSharp/Compression/Zlib/ZlibDeflateStream.cs
  44. 2
      src/ImageSharp/Compression/Zlib/ZlibInflateStream.cs
  45. 12
      src/ImageSharp/Formats/Bmp/BmpDecoderCore.cs
  46. 6
      src/ImageSharp/Formats/Bmp/BmpEncoderCore.cs
  47. 16
      src/ImageSharp/Formats/Bmp/BmpMetadata.cs
  48. 6
      src/ImageSharp/Formats/Cur/CurFrameMetadata.cs
  49. 4
      src/ImageSharp/Formats/Cur/CurMetadata.cs
  50. 6
      src/ImageSharp/Formats/Gif/GifDecoderCore.cs
  51. 2
      src/ImageSharp/Formats/Gif/GifMetadata.cs
  52. 2
      src/ImageSharp/Formats/Gif/Sections/GifNetscapeLoopingApplicationExtension.cs
  53. 2
      src/ImageSharp/Formats/Gif/Sections/GifXmpApplicationExtension.cs
  54. 6
      src/ImageSharp/Formats/Ico/IcoFrameMetadata.cs
  55. 4
      src/ImageSharp/Formats/Ico/IcoMetadata.cs
  56. 2
      src/ImageSharp/Formats/Jpeg/Components/Block8x8.cs
  57. 8
      src/ImageSharp/Formats/Jpeg/Components/Block8x8F.ScaledCopy.cs
  58. 2
      src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverterBase.cs
  59. 2
      src/ImageSharp/Formats/Jpeg/Components/Decoder/AdobeMarker.cs
  60. 2
      src/ImageSharp/Formats/Jpeg/Components/Decoder/ArithmeticScanDecoder.cs
  61. 4
      src/ImageSharp/Formats/Jpeg/Components/Decoder/HuffmanScanDecoder.cs
  62. 2
      src/ImageSharp/Formats/Jpeg/Components/Decoder/JFifMarker.cs
  63. 4
      src/ImageSharp/Formats/Jpeg/Components/Decoder/JpegComponent.cs
  64. 2
      src/ImageSharp/Formats/Jpeg/Components/Decoder/SpectralConverter.cs
  65. 4
      src/ImageSharp/Formats/Jpeg/Components/Encoder/Component.cs
  66. 2
      src/ImageSharp/Formats/Jpeg/Components/Encoder/ComponentProcessor.cs
  67. 4
      src/ImageSharp/Formats/Jpeg/Components/Encoder/HuffmanScanEncoder.cs
  68. 2
      src/ImageSharp/Formats/Jpeg/Components/Encoder/JpegFrame.cs
  69. 6
      src/ImageSharp/Formats/Jpeg/Components/Encoder/SpectralConverter{TPixel}.cs
  70. 8
      src/ImageSharp/Formats/Jpeg/Components/SizeExtensions.cs
  71. 32
      src/ImageSharp/Formats/Jpeg/JpegDecoderCore.cs
  72. 16
      src/ImageSharp/Formats/Jpeg/JpegEncoderCore.FrameConfig.cs
  73. 4
      src/ImageSharp/Formats/Jpeg/JpegMetadata.cs
  74. 6
      src/ImageSharp/Formats/Pbm/PbmDecoderCore.cs
  75. 4
      src/ImageSharp/Formats/Pbm/PbmMetadata.cs
  76. 8
      src/ImageSharp/Formats/Pbm/PlainDecoder.cs
  77. 4
      src/ImageSharp/Formats/Png/Chunks/PngPhysical.cs
  78. 2
      src/ImageSharp/Formats/Png/PngDecoder.cs
  79. 28
      src/ImageSharp/Formats/Png/PngDecoderCore.cs
  80. 2
      src/ImageSharp/Formats/Png/PngFrameMetadata.cs
  81. 2
      src/ImageSharp/Formats/Png/PngMetadata.cs
  82. 4
      src/ImageSharp/Formats/Qoi/QoiDecoderCore.cs
  83. 6
      src/ImageSharp/Formats/Qoi/QoiMetadata.cs
  84. 10
      src/ImageSharp/Formats/Tga/TgaDecoderCore.cs
  85. 2
      src/ImageSharp/Formats/Tga/TgaImageFormatDetector.cs
  86. 10
      src/ImageSharp/Formats/Tga/TgaMetadata.cs
  87. 2
      src/ImageSharp/Formats/Tiff/Compression/Compressors/DeflateCompressor.cs
  88. 2
      src/ImageSharp/Formats/Tiff/Compression/Compressors/LzwCompressor.cs
  89. 2
      src/ImageSharp/Formats/Tiff/Compression/Compressors/PackBitsWriter.cs
  90. 4
      src/ImageSharp/Formats/Tiff/Compression/Compressors/TiffJpegCompressor.cs
  91. 2
      src/ImageSharp/Formats/Tiff/Compression/Decompressors/DeflateTiffCompression.cs
  92. 6
      src/ImageSharp/Formats/Tiff/Compression/Decompressors/LzwString.cs
  93. 2
      src/ImageSharp/Formats/Tiff/Compression/Decompressors/LzwTiffCompression.cs
  94. 2
      src/ImageSharp/Formats/Tiff/Compression/Decompressors/ModifiedHuffmanTiffCompression.cs
  95. 2
      src/ImageSharp/Formats/Tiff/Compression/Decompressors/T4TiffCompression.cs
  96. 6
      src/ImageSharp/Formats/Tiff/Compression/Decompressors/T6TiffCompression.cs
  97. 2
      src/ImageSharp/Formats/Tiff/Compression/Decompressors/TiffLzwDecoder.cs
  98. 2
      src/ImageSharp/Formats/Tiff/Compression/Decompressors/WebpTiffCompression.cs
  99. 6
      src/ImageSharp/Formats/Tiff/Compression/HorizontalPredictor.cs
  100. 4
      src/ImageSharp/Formats/Tiff/PhotometricInterpretation/BlackIsZero32FloatTiffColor{TPixel}.cs

8
.editorconfig

@ -161,6 +161,9 @@ csharp_style_deconstructed_variable_declaration = true:warning
csharp_style_prefer_index_operator = true:warning
csharp_style_prefer_range_operator = true:warning
csharp_style_implicit_object_creation_when_type_is_apparent = true:error
# Collection expression preferences
# dotnet_style_prefer_collection_expression = true:error
# "Null" checking preferences
csharp_style_throw_expression = true:warning
csharp_style_conditional_delegate_call = true:warning
@ -175,6 +178,11 @@ csharp_prefer_static_local_function = true:warning
# Primary constructor preferences
csharp_style_prefer_primary_constructors = false:none
# ReSharper inspection severities
resharper_arrange_object_creation_when_type_evident_highlighting = error
resharper_arrange_object_creation_when_type_not_evident_highlighting = error
# resharper_use_collection_expression_highlighting = error
##########################################
# Unnecessary Code Rules
# https://docs.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/unnecessary-code-rules

4
src/ImageSharp/Advanced/ParallelExecutionSettings.cs

@ -79,7 +79,7 @@ public readonly struct ParallelExecutionSettings
{
Guard.MustBeGreaterThan(multiplier, 0, nameof(multiplier));
return new ParallelExecutionSettings(
return new(
this.MaxDegreeOfParallelism,
this.MinimumPixelsProcessedPerTask * multiplier,
this.MemoryAllocator);
@ -92,6 +92,6 @@ public readonly struct ParallelExecutionSettings
/// <returns>The <see cref="ParallelExecutionSettings"/>.</returns>
public static ParallelExecutionSettings FromConfiguration(Configuration configuration)
{
return new ParallelExecutionSettings(configuration.MaxDegreeOfParallelism, configuration.MemoryAllocator);
return new(configuration.MaxDegreeOfParallelism, configuration.MemoryAllocator);
}
}

4
src/ImageSharp/Advanced/ParallelRowIterator.Wrappers.cs

@ -139,7 +139,7 @@ public static partial class ParallelRowIterator
}
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 static partial class ParallelRowIterator
}
int yMax = Math.Min(yMin + this.stepY, this.maxY);
var rows = new RowInterval(yMin, yMax);
RowInterval rows = new RowInterval(yMin, yMax);
using IMemoryOwner<TBuffer> buffer = this.allocator.Allocate<TBuffer>(this.bufferLength);

28
src/ImageSharp/Advanced/ParallelRowIterator.cs

@ -26,7 +26,7 @@ public static partial class ParallelRowIterator
public static void IterateRows<T>(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 partial class ParallelRowIterator
}
int verticalStep = DivideCeil(rectangle.Height, numOfSteps);
var parallelOptions = new ParallelOptions { MaxDegreeOfParallelism = numOfSteps };
var wrappingOperation = new RowOperationWrapper<T>(top, bottom, verticalStep, in operation);
ParallelOptions parallelOptions = new() { MaxDegreeOfParallelism = numOfSteps };
RowOperationWrapper<T> wrappingOperation = new(top, bottom, verticalStep, in operation);
Parallel.For(
0,
@ -88,7 +88,7 @@ public static partial class ParallelRowIterator
where T : struct, IRowOperation<TBuffer>
where TBuffer : unmanaged
{
var parallelSettings = ParallelExecutionSettings.FromConfiguration(configuration);
ParallelExecutionSettings parallelSettings = ParallelExecutionSettings.FromConfiguration(configuration);
IterateRows<T, TBuffer>(rectangle, in parallelSettings, in operation);
}
@ -135,8 +135,8 @@ public static partial class ParallelRowIterator
}
int verticalStep = DivideCeil(height, numOfSteps);
var parallelOptions = new ParallelOptions { MaxDegreeOfParallelism = numOfSteps };
var wrappingOperation = new RowOperationWrapper<T, TBuffer>(top, bottom, verticalStep, bufferLength, allocator, in operation);
ParallelOptions parallelOptions = new() { MaxDegreeOfParallelism = numOfSteps };
RowOperationWrapper<T, TBuffer> wrappingOperation = new(top, bottom, verticalStep, bufferLength, allocator, in operation);
Parallel.For(
0,
@ -156,7 +156,7 @@ public static partial class ParallelRowIterator
public static void IterateRowIntervals<T>(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 partial class ParallelRowIterator
// 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<T>(top, bottom, verticalStep, in operation);
ParallelOptions parallelOptions = new() { MaxDegreeOfParallelism = numOfSteps };
RowIntervalOperationWrapper<T> wrappingOperation = new(top, bottom, verticalStep, in operation);
Parallel.For(
0,
@ -215,7 +215,7 @@ public static partial class ParallelRowIterator
where T : struct, IRowIntervalOperation<TBuffer>
where TBuffer : unmanaged
{
var parallelSettings = ParallelExecutionSettings.FromConfiguration(configuration);
ParallelExecutionSettings parallelSettings = ParallelExecutionSettings.FromConfiguration(configuration);
IterateRowIntervals<T, TBuffer>(rectangle, in parallelSettings, in operation);
}
@ -250,7 +250,7 @@ public static partial class ParallelRowIterator
// Avoid TPL overhead in this trivial case:
if (numOfSteps == 1)
{
var rows = new RowInterval(top, bottom);
RowInterval rows = new(top, bottom);
using IMemoryOwner<TBuffer> buffer = allocator.Allocate<TBuffer>(bufferLength);
Unsafe.AsRef(in operation).Invoke(in rows, buffer.Memory.Span);
@ -259,8 +259,8 @@ public static partial class ParallelRowIterator
}
int verticalStep = DivideCeil(height, numOfSteps);
var parallelOptions = new ParallelOptions { MaxDegreeOfParallelism = numOfSteps };
var wrappingOperation = new RowIntervalOperationWrapper<T, TBuffer>(top, bottom, verticalStep, bufferLength, allocator, in operation);
ParallelOptions parallelOptions = new() { MaxDegreeOfParallelism = numOfSteps };
RowIntervalOperationWrapper<T, TBuffer> wrappingOperation = new(top, bottom, verticalStep, bufferLength, allocator, in operation);
Parallel.For(
0,

2
src/ImageSharp/Color/Color.WebSafePalette.cs

@ -8,7 +8,7 @@ namespace SixLabors.ImageSharp;
/// </content>
public partial struct Color
{
private static readonly Lazy<Color[]> WebSafePaletteLazy = new Lazy<Color[]>(CreateWebSafePalette, true);
private static readonly Lazy<Color[]> WebSafePaletteLazy = new(CreateWebSafePalette, true);
/// <summary>
/// Gets a collection of named, web safe colors as defined in the CSS Color Module Level 4.

6
src/ImageSharp/ColorProfiles/CieLab.cs

@ -88,7 +88,7 @@ public readonly struct CieLab : IProfileConnectingSpace<CieLab, CieXyz>
v3 += this.AsVector3Unsafe();
v3 += new Vector3(0, 128F, 128F);
v3 /= new Vector3(100F, 255F, 255F);
return new Vector4(v3, 1F);
return new(v3, 1F);
}
/// <inheritdoc/>
@ -97,7 +97,7 @@ public readonly struct CieLab : IProfileConnectingSpace<CieLab, CieXyz>
Vector3 v3 = source.AsVector3();
v3 *= new Vector3(100F, 255, 255);
v3 -= new Vector3(0, 128F, 128F);
return new CieLab(v3);
return new(v3);
}
/// <inheritdoc/>
@ -145,7 +145,7 @@ public readonly struct CieLab : IProfileConnectingSpace<CieLab, CieXyz>
float a = 500F * (fx - fy);
float b = 200F * (fy - fz);
return new CieLab(l, a, b);
return new(l, a, b);
}
/// <inheritdoc/>

10
src/ImageSharp/ColorProfiles/CieLch.cs

@ -25,7 +25,7 @@ public readonly struct CieLch : IColorProfile<CieLch, CieLab>
/// <param name="h">The hue in degrees.</param>
[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 readonly struct CieLch : IColorProfile<CieLch, CieLab>
v3 += this.AsVector3Unsafe();
v3 += new Vector3(0, 200, 0);
v3 /= new Vector3(100, 400, 360);
return new Vector4(v3, 1F);
return new(v3, 1F);
}
/// <inheritdoc/>
@ -109,7 +109,7 @@ public readonly struct CieLch : IColorProfile<CieLch, CieLab>
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);
}
/// <inheritdoc/>
@ -155,7 +155,7 @@ public readonly struct CieLch : IColorProfile<CieLch, CieLab>
hDegrees += 360;
}
return new CieLch(l, c, hDegrees);
return new(l, c, hDegrees);
}
/// <inheritdoc/>
@ -181,7 +181,7 @@ public readonly struct CieLch : IColorProfile<CieLch, CieLab>
float a = c * MathF.Cos(hRadians);
float b = c * MathF.Sin(hRadians);
return new CieLab(l, a, b);
return new(l, a, b);
}
/// <inheritdoc/>

8
src/ImageSharp/ColorProfiles/CieLchuv.cs

@ -25,7 +25,7 @@ public readonly struct CieLchuv : IColorProfile<CieLchuv, CieXyz>
/// <param name="h">The hue in degrees.</param>
[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 readonly struct CieLchuv : IColorProfile<CieLchuv, CieXyz>
v3 += this.AsVector3Unsafe();
v3 += new Vector3(0, 200, 0);
v3 /= new Vector3(100, 400, 360);
return new Vector4(v3, 1F);
return new(v3, 1F);
}
/// <inheritdoc/>
@ -106,7 +106,7 @@ public readonly struct CieLchuv : IColorProfile<CieLchuv, CieXyz>
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);
}
/// <inheritdoc/>
@ -154,7 +154,7 @@ public readonly struct CieLchuv : IColorProfile<CieLchuv, CieXyz>
hDegrees += 360;
}
return new CieLchuv(l, c, hDegrees);
return new(l, c, hDegrees);
}
/// <inheritdoc/>

4
src/ImageSharp/ColorProfiles/CieLuv.cs

@ -134,7 +134,7 @@ public readonly struct CieLuv : IColorProfile<CieLuv, CieXyz>
v = 0;
}
return new CieLuv((float)l, (float)u, (float)v);
return new((float)l, (float)u, (float)v);
}
/// <inheritdoc/>
@ -188,7 +188,7 @@ public readonly struct CieLuv : IColorProfile<CieLuv, CieXyz>
z = 0;
}
return new CieXyz((float)x, (float)y, (float)z);
return new((float)x, (float)y, (float)z);
}
/// <inheritdoc/>

8
src/ImageSharp/ColorProfiles/CieXyy.cs

@ -122,10 +122,10 @@ public readonly struct CieXyy : IColorProfile<CieXyy, CieXyz>
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);
}
/// <inheritdoc/>
@ -144,14 +144,14 @@ public readonly struct CieXyy : IColorProfile<CieXyy, CieXyz>
{
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);
}
/// <inheritdoc/>

8
src/ImageSharp/ColorProfiles/CieXyz.cs

@ -88,7 +88,7 @@ public readonly struct CieXyz : IProfileConnectingSpace<CieXyz, CieXyz>
{
Vector3 v3 = default;
v3 += this.AsVector3Unsafe();
return new Vector4(v3, 1F);
return new(v3, 1F);
}
/// <inheritdoc/>
@ -97,13 +97,13 @@ public readonly struct CieXyz : IProfileConnectingSpace<CieXyz, CieXyz>
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);
}
/// <inheritdoc/>
@ -111,7 +111,7 @@ public readonly struct CieXyz : IProfileConnectingSpace<CieXyz, CieXyz>
{
Vector3 v3 = source.AsVector3();
v3 *= 65535 / 32768F;
return new CieXyz(v3);
return new(v3);
}
/// <inheritdoc/>

6
src/ImageSharp/ColorProfiles/Cmyk.cs

@ -26,7 +26,7 @@ public readonly struct Cmyk : IColorProfile<Cmyk, Rgb>
/// <param name="k">The keyline black component.</param>
[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 readonly struct Cmyk : IColorProfile<Cmyk, Rgb>
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);
}
/// <inheritdoc/>

16
src/ImageSharp/ColorProfiles/ColorProfileConverterExtensionsIcc.cs

@ -57,11 +57,11 @@ internal static class ColorProfileConverterExtensionsIcc
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 class ColorProfileConverterExtensionsIcc
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<Vector4> pcsBuffer = converter.Options.MemoryAllocator.Allocate<Vector4>(source.Length);
@ -355,7 +355,7 @@ internal static class ColorProfileConverterExtensionsIcc
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 @@ internal static class ColorProfileConverterExtensionsIcc
vector = Vector3.Max(vector, Vector3.Zero);
}
xyz = new CieXyz(vector);
xyz = new(vector);
}
switch (targetParams.PcsType)

8
src/ImageSharp/ColorProfiles/Hsl.cs

@ -24,7 +24,7 @@ public readonly struct Hsl : IColorProfile<Hsl, Rgb>
/// <param name="l">The l value (lightness) component.</param>
[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 readonly struct Hsl : IColorProfile<Hsl, Rgb>
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 readonly struct Hsl : IColorProfile<Hsl, Rgb>
s = chroma / (2F - max - min);
}
return new Hsl(h, s, l);
return new(h, s, l);
}
/// <inheritdoc/>
@ -213,7 +213,7 @@ public readonly struct Hsl : IColorProfile<Hsl, Rgb>
}
}
return new Rgb(r, g, b);
return new(r, g, b);
}
/// <inheritdoc/>

10
src/ImageSharp/ColorProfiles/Hsv.cs

@ -24,7 +24,7 @@ public readonly struct Hsv : IColorProfile<Hsv, Rgb>
/// <param name="v">The v value (brightness) component.</param>
[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 readonly struct Hsv : IColorProfile<Hsv, Rgb>
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 readonly struct Hsv : IColorProfile<Hsv, Rgb>
s = chroma / v;
return new Hsv(h, s, v);
return new(h, s, v);
}
/// <inheritdoc/>
@ -185,7 +185,7 @@ public readonly struct Hsv : IColorProfile<Hsv, Rgb>
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 readonly struct Hsv : IColorProfile<Hsv, Rgb>
break;
}
return new Rgb(r, g, b);
return new(r, g, b);
}
/// <inheritdoc/>

8
src/ImageSharp/ColorProfiles/HunterLab.cs

@ -87,7 +87,7 @@ public readonly struct HunterLab : IColorProfile<HunterLab, CieXyz>
v3 += this.AsVector3Unsafe();
v3 += new Vector3(0, 128F, 128F);
v3 /= new Vector3(100F, 255F, 255F);
return new Vector4(v3, 1F);
return new(v3, 1F);
}
/// <inheritdoc/>
@ -96,7 +96,7 @@ public readonly struct HunterLab : IColorProfile<HunterLab, CieXyz>
Vector3 v3 = source.AsVector3();
v3 *= new Vector3(100F, 255, 255);
v3 -= new Vector3(0, 128F, 128F);
return new HunterLab(v3);
return new(v3);
}
/// <inheritdoc/>
@ -151,7 +151,7 @@ public readonly struct HunterLab : IColorProfile<HunterLab, CieXyz>
b = 0;
}
return new HunterLab(l, a, b);
return new(l, a, b);
}
/// <inheritdoc/>
@ -184,7 +184,7 @@ public readonly struct HunterLab : IColorProfile<HunterLab, CieXyz>
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);
}
/// <inheritdoc/>

4
src/ImageSharp/ColorProfiles/Icc/Calculators/ColorTrcCalculator.cs

@ -23,12 +23,12 @@ internal class ColorTrcCalculator : IVector4Calculator
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)
{

2
src/ImageSharp/ColorProfiles/Icc/Calculators/CurveCalculator.cs

@ -31,7 +31,7 @@ internal partial class CurveCalculator : ISingleCalculator
}
else
{
this.lutCalculator = new LutCalculator(entry.CurveData, inverted);
this.lutCalculator = new(entry.CurveData, inverted);
this.type = CalculationType.Lut;
}
}

2
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);

10
src/ImageSharp/ColorProfiles/Icc/Calculators/LutABCalculator.cs

@ -109,27 +109,27 @@ internal partial class LutABCalculator : IVector4Calculator
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);
}
}
}

4
src/ImageSharp/ColorProfiles/Icc/Calculators/LutEntryCalculator.cs

@ -61,7 +61,7 @@ internal class LutEntryCalculator : IVector4Calculator
{
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 @@ internal class LutEntryCalculator : IVector4Calculator
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;

2
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)]

2
src/ImageSharp/ColorProfiles/Icc/CompactSrgbV4Profile.cs

@ -37,6 +37,6 @@ internal static class CompactSrgbV4Profile
{
byte[] buffer = new byte[Data.Length];
Data.CopyTo(buffer);
return new IccProfile(buffer);
return new(buffer);
}
}

4
src/ImageSharp/ColorProfiles/Icc/IccConverterbase.Conversions.cs

@ -91,7 +91,7 @@ internal abstract partial class IccConverterBase
throw new InvalidIccProfileException("Missing matrix column or channel.");
}
return new ColorTrcCalculator(
return new(
redMatrixColumn,
greenMatrixColumn,
blueMatrixColumn,
@ -104,6 +104,6 @@ internal abstract partial class IccConverterBase
private static GrayTrcCalculator InitGrayTrc(IccProfile profile, bool toPcs)
{
IccTagDataEntry entry = GetTag(profile, IccProfileTag.GrayTrc);
return new GrayTrcCalculator(entry, toPcs);
return new(entry, toPcs);
}
}

12
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)
/// </summary>
public static readonly Matrix4x4 VonKriesHPEAdjusted
= Matrix4x4.Transpose(new Matrix4x4
= Matrix4x4.Transpose(new()
{
M11 = 0.40024F,
M12 = 0.7076F,
@ -42,7 +42,7 @@ public static class KnownChromaticAdaptationMatrices
/// von Kries chromatic adaptation transform matrix (Hunt-Pointer-Estevez for equal energy)
/// </summary>
public static readonly Matrix4x4 VonKriesHPE
= Matrix4x4.Transpose(new Matrix4x4
= Matrix4x4.Transpose(new()
{
M11 = 0.3897F,
M12 = 0.6890F,
@ -65,7 +65,7 @@ public static class KnownChromaticAdaptationMatrices
/// Bradford chromatic adaptation transform matrix (used in CMCCAT97)
/// </summary>
public static readonly Matrix4x4 Bradford
= Matrix4x4.Transpose(new Matrix4x4
= Matrix4x4.Transpose(new()
{
M11 = 0.8951F,
M12 = 0.2664F,
@ -83,7 +83,7 @@ public static class KnownChromaticAdaptationMatrices
/// Spectral sharpening and the Bradford transform
/// </summary>
public static readonly Matrix4x4 BradfordSharp
= Matrix4x4.Transpose(new Matrix4x4
= Matrix4x4.Transpose(new()
{
M11 = 1.2694F,
M12 = -0.0988F,
@ -101,7 +101,7 @@ public static class KnownChromaticAdaptationMatrices
/// CMCCAT2000 (fitted from all available color data sets)
/// </summary>
public static readonly Matrix4x4 CMCCAT2000
= Matrix4x4.Transpose(new Matrix4x4
= Matrix4x4.Transpose(new()
{
M11 = 0.7982F,
M12 = 0.3389F,
@ -119,7 +119,7 @@ public static class KnownChromaticAdaptationMatrices
/// CAT02 (optimized for minimizing CIELAB differences)
/// </summary>
public static readonly Matrix4x4 CAT02
= Matrix4x4.Transpose(new Matrix4x4
= Matrix4x4.Transpose(new()
{
M11 = 0.7328F,
M12 = 0.4296F,

38
src/ImageSharp/ColorProfiles/KnownRgbWorkingSpaces.cs

@ -18,96 +18,96 @@ public static class KnownRgbWorkingSpaces
/// Uses proper companding function, according to:
/// <see href="http://www.brucelindbloom.com/index.html?Eqn_Rgb_to_XYZ.html"/>
/// </remarks>
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)));
/// <summary>
/// Simplified sRgb working space (uses <see cref="GammaCompanding">gamma companding</see> instead of <see cref="SRgbCompanding"/>).
/// See also <see cref="SRgb"/>.
/// </summary>
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)));
/// <summary>
/// Rec. 709 (ITU-R Recommendation BT.709) working space.
/// </summary>
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)));
/// <summary>
/// Rec. 2020 (ITU-R Recommendation BT.2020F) working space.
/// </summary>
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)));
/// <summary>
/// ECI Rgb v2 working space.
/// </summary>
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)));
/// <summary>
/// Adobe Rgb (1998) working space.
/// </summary>
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)));
/// <summary>
/// Apple sRgb working space.
/// </summary>
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)));
/// <summary>
/// Best Rgb working space.
/// </summary>
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)));
/// <summary>
/// Beta Rgb working space.
/// </summary>
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)));
/// <summary>
/// Bruce Rgb working space.
/// </summary>
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)));
/// <summary>
/// CIE Rgb working space.
/// </summary>
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)));
/// <summary>
/// ColorMatch Rgb working space.
/// </summary>
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)));
/// <summary>
/// Don Rgb 4 working space.
/// </summary>
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)));
/// <summary>
/// Ekta Space PS5 working space.
/// </summary>
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)));
/// <summary>
/// NTSC Rgb working space.
/// </summary>
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)));
/// <summary>
/// PAL/SECAM Rgb working space.
/// </summary>
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)));
/// <summary>
/// ProPhoto Rgb working space.
/// </summary>
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)));
/// <summary>
/// SMPTE-C Rgb working space.
/// </summary>
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)));
/// <summary>
/// Wide Gamut Rgb working space.
/// </summary>
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)));
}

18
src/ImageSharp/ColorProfiles/KnownYCbCrMatrices.cs

@ -16,47 +16,47 @@ public static class KnownYCbCrMatrices
/// ITU-R BT.601 (SD video standard).
/// </summary>
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));
/// <summary>
/// ITU-R BT.709 (HD video, sRGB standard).
/// </summary>
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));
/// <summary>
/// ITU-R BT.2020 (UHD/4K video standard).
/// </summary>
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));
}

4
src/ImageSharp/ColorProfiles/Lms.cs

@ -89,7 +89,7 @@ public readonly struct Lms : IColorProfile<Lms, CieXyz>
v3 += this.AsVector3Unsafe();
v3 += new Vector3(1F);
v3 /= 2F;
return new Vector4(v3, 1F);
return new(v3, 1F);
}
/// <inheritdoc/>
@ -98,7 +98,7 @@ public readonly struct Lms : IColorProfile<Lms, CieXyz>
Vector3 v3 = source.AsVector3();
v3 *= 2F;
v3 -= new Vector3(1F);
return new Lms(v3);
return new(v3);
}
/// <inheritdoc/>

6
src/ImageSharp/ColorProfiles/Rgb.cs

@ -154,7 +154,7 @@ public readonly struct Rgb : IProfileConnectingSpace<Rgb, CieXyz>
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)));
}
/// <inheritdoc/>
@ -171,7 +171,7 @@ public readonly struct Rgb : IProfileConnectingSpace<Rgb, CieXyz>
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 @@ public readonly struct Rgb : IProfileConnectingSpace<Rgb, CieXyz>
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,

4
src/ImageSharp/ColorProfiles/VonKriesChromaticAdaptation.cs

@ -42,7 +42,7 @@ public static class VonKriesChromaticAdaptation
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));
}
/// <summary>
@ -89,7 +89,7 @@ public static class VonKriesChromaticAdaptation
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));
}
}
}

2
src/ImageSharp/ColorProfiles/Y.cs

@ -92,7 +92,7 @@ public readonly struct Y : IColorProfile<Y, Rgb>
{
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);
}
/// <inheritdoc/>

6
src/ImageSharp/ColorProfiles/YCbCr.cs

@ -24,7 +24,7 @@ public readonly struct YCbCr : IColorProfile<YCbCr, Rgb>
/// <param name="cr">The cr chroma component.</param>
[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 readonly struct YCbCr : IColorProfile<YCbCr, Rgb>
{
Vector3 v3 = default;
v3 += this.AsVector3Unsafe();
return new Vector4(v3, 1F);
return new(v3, 1F);
}
/// <inheritdoc/>
@ -133,7 +133,7 @@ public readonly struct YCbCr : IColorProfile<YCbCr, Rgb>
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);
}
/// <inheritdoc/>

6
src/ImageSharp/ColorProfiles/YccK.cs

@ -27,7 +27,7 @@ public readonly struct YccK : IColorProfile<YccK, Rgb>
/// <param name="k">The keyline black component.</param>
[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 readonly struct YccK : IColorProfile<YccK, Rgb>
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));
}
/// <inheritdoc/>

2
src/ImageSharp/Common/Extensions/ConfigurationExtensions.cs

@ -14,6 +14,6 @@ internal static class ConfigurationExtensions
/// </summary>
public static ParallelOptions GetParallelOptions(this Configuration configuration)
{
return new ParallelOptions { MaxDegreeOfParallelism = configuration.MaxDegreeOfParallelism };
return new() { MaxDegreeOfParallelism = configuration.MaxDegreeOfParallelism };
}
}

10
src/ImageSharp/Common/Helpers/Numerics.cs

@ -470,8 +470,8 @@ internal static class Numerics
where T : unmanaged
{
ref T sRef = ref MemoryMarshal.GetReference(span);
var vmin = new Vector<T>(min);
var vmax = new Vector<T>(max);
Vector<T> vmin = new(min);
Vector<T> vmax = new(max);
nint n = (nint)(uint)span.Length / Vector<T>.Count;
nint m = Modulo4(n);
@ -726,12 +726,12 @@ internal static class Numerics
ref Vector128<float> vectors128Ref = ref Unsafe.As<Vector4, Vector128<float>>(ref MemoryMarshal.GetReference(vectors));
ref Vector128<float> vectors128End = ref Unsafe.Add(ref vectors128Ref, (uint)vectors.Length);
var v128_341 = Vector128.Create(341);
Vector128<int> v128_341 = Vector128.Create(341);
Vector128<int> v128_negativeZero = Vector128.Create(-0.0f).AsInt32();
Vector128<int> v128_one = Vector128.Create(1.0f).AsInt32();
var v128_13rd = Vector128.Create(1 / 3f);
var v128_23rds = Vector128.Create(2 / 3f);
Vector128<float> v128_13rd = Vector128.Create(1 / 3f);
Vector128<float> v128_23rds = Vector128.Create(2 / 3f);
while (Unsafe.IsAddressLessThan(ref vectors128Ref, ref vectors128End))
{

2
src/ImageSharp/Common/Helpers/SimdUtils.Pack.cs

@ -134,7 +134,7 @@ internal static partial class SimdUtils
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);

2
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);
}

4
src/ImageSharp/Common/Helpers/UnitConverter.cs

@ -131,9 +131,9 @@ internal static class UnitConverter
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);
}
}

2
src/ImageSharp/Compression/Zlib/Deflater.cs

@ -79,7 +79,7 @@ internal sealed class Deflater : IDisposable
}
// 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();

2
src/ImageSharp/Compression/Zlib/DeflaterEngine.cs

@ -147,7 +147,7 @@ internal sealed unsafe class DeflaterEngine : IDisposable
/// <param name="strategy">The deflate strategy to use.</param>
public DeflaterEngine(MemoryAllocator memoryAllocator, DeflateStrategy strategy)
{
this.huffman = new DeflaterHuffman(memoryAllocator);
this.huffman = new(memoryAllocator);
this.Pending = this.huffman.Pending;
this.strategy = strategy;

8
src/ImageSharp/Compression/Zlib/DeflaterHuffman.cs

@ -58,11 +58,11 @@ internal sealed unsafe class DeflaterHuffman : IDisposable
/// <param name="memoryAllocator">The memory allocator to use for buffer allocations.</param>
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<short>(BufferSize);
this.distanceBufferHandle = this.distanceMemoryOwner.Memory.Pin();

2
src/ImageSharp/Compression/Zlib/DeflaterOutputStream.cs

@ -30,7 +30,7 @@ internal sealed class DeflaterOutputStream : Stream
this.rawStream = rawStream;
this.memoryOwner = memoryAllocator.Allocate<byte>(BufferLength);
this.buffer = this.memoryOwner.Memory;
this.deflater = new Deflater(memoryAllocator, compressionLevel);
this.deflater = new(memoryAllocator, compressionLevel);
}
/// <inheritdoc/>

2
src/ImageSharp/Compression/Zlib/ZlibDeflateStream.cs

@ -101,7 +101,7 @@ internal sealed class ZlibDeflateStream : Stream
this.rawStream.WriteByte(Cmf);
this.rawStream.WriteByte((byte)flg);
this.deflateStream = new DeflaterOutputStream(memoryAllocator, this.rawStream, compressionLevel);
this.deflateStream = new(memoryAllocator, this.rawStream, compressionLevel);
}
/// <inheritdoc/>

2
src/ImageSharp/Compression/Zlib/ZlibInflateStream.cs

@ -270,7 +270,7 @@ internal sealed class ZlibInflateStream : Stream
}
// Initialize the deflate BufferedReadStream.
this.CompressedStream = new DeflateStream(this, CompressionMode.Decompress, true);
this.CompressedStream = new(this, CompressionMode.Decompress, true);
return true;
}

12
src/ImageSharp/Formats/Bmp/BmpDecoderCore.cs

@ -132,7 +132,7 @@ internal sealed class BmpDecoderCore : ImageDecoderCore
{
int bytesPerColorMapEntry = this.ReadImageHeaders(stream, out bool inverted, out byte[] palette);
image = new Image<TPixel>(this.configuration, this.infoHeader.Width, this.infoHeader.Height, this.metadata);
image = new(this.configuration, this.infoHeader.Width, this.infoHeader.Height, this.metadata);
Buffer2D<TPixel> pixels = image.GetRootFramePixelBuffer();
@ -220,7 +220,7 @@ internal sealed class BmpDecoderCore : ImageDecoderCore
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);
}
/// <summary>
@ -343,7 +343,7 @@ internal sealed class BmpDecoderCore : ImageDecoderCore
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 @@ internal sealed class BmpDecoderCore : ImageDecoderCore
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 @@ internal sealed class BmpDecoderCore : ImageDecoderCore
long infoHeaderStart = stream.Position;
// Resolution is stored in PPM.
this.metadata = new ImageMetadata
this.metadata = new()
{
ResolutionUnits = PixelResolutionUnit.PixelsPerMeter
};
@ -1426,7 +1426,7 @@ internal sealed class BmpDecoderCore : ImageDecoderCore
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;
}
}

6
src/ImageSharp/Formats/Bmp/BmpEncoderCore.cs

@ -655,7 +655,7 @@ internal sealed class BmpEncoderCore
CancellationToken cancellationToken)
where TPixel : unmanaged, IPixel<TPixel>
{
using IQuantizer<TPixel> frameQuantizer = this.quantizer.CreatePixelSpecificQuantizer<TPixel>(configuration, new QuantizerOptions()
using IQuantizer<TPixel> frameQuantizer = this.quantizer.CreatePixelSpecificQuantizer<TPixel>(configuration, new()
{
MaxColors = 16,
Dither = this.quantizer.Options.Dither,
@ -712,7 +712,7 @@ internal sealed class BmpEncoderCore
CancellationToken cancellationToken)
where TPixel : unmanaged, IPixel<TPixel>
{
using IQuantizer<TPixel> frameQuantizer = this.quantizer.CreatePixelSpecificQuantizer<TPixel>(configuration, new QuantizerOptions()
using IQuantizer<TPixel> frameQuantizer = this.quantizer.CreatePixelSpecificQuantizer<TPixel>(configuration, new()
{
MaxColors = 4,
Dither = this.quantizer.Options.Dither,
@ -778,7 +778,7 @@ internal sealed class BmpEncoderCore
CancellationToken cancellationToken)
where TPixel : unmanaged, IPixel<TPixel>
{
using IQuantizer<TPixel> frameQuantizer = this.quantizer.CreatePixelSpecificQuantizer<TPixel>(configuration, new QuantizerOptions()
using IQuantizer<TPixel> frameQuantizer = this.quantizer.CreatePixelSpecificQuantizer<TPixel>(configuration, new()
{
MaxColors = 2,
Dither = this.quantizer.Options.Dither,

16
src/ImageSharp/Formats/Bmp/BmpMetadata.cs

@ -54,21 +54,21 @@ public class BmpMetadata : IFormatMetadata<BmpMetadata>
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 @@ public class BmpMetadata : IFormatMetadata<BmpMetadata>
break;
}
return new PixelTypeInfo(bpp)
return new(bpp)
{
AlphaRepresentation = alpha,
ComponentInfo = info,

6
src/ImageSharp/Formats/Cur/CurFrameMetadata.cs

@ -73,7 +73,7 @@ public class CurFrameMetadata : IFormatFrameMetadata<CurFrameMetadata>
{
if (!metadata.PixelTypeInfo.HasValue)
{
return new CurFrameMetadata
return new()
{
BmpBitsPerPixel = BmpBitsPerPixel.Bit32,
Compression = IconFrameCompression.Png
@ -98,7 +98,7 @@ public class CurFrameMetadata : IFormatFrameMetadata<CurFrameMetadata>
compression = IconFrameCompression.Png;
}
return new CurFrameMetadata
return new()
{
BmpBitsPerPixel = bbpp,
Compression = compression,
@ -210,7 +210,7 @@ public class CurFrameMetadata : IFormatFrameMetadata<CurFrameMetadata>
}
}
return new PixelTypeInfo(bpp)
return new(bpp)
{
AlphaRepresentation = alpha,
ComponentInfo = info,

4
src/ImageSharp/Formats/Cur/CurMetadata.cs

@ -68,7 +68,7 @@ public class CurMetadata : IFormatMetadata<CurMetadata>
compression = IconFrameCompression.Png;
}
return new CurMetadata
return new()
{
BmpBitsPerPixel = bbpp,
Compression = compression
@ -129,7 +129,7 @@ public class CurMetadata : IFormatMetadata<CurMetadata>
}
}
return new PixelTypeInfo(bpp)
return new(bpp)
{
AlphaRepresentation = alpha,
ComponentInfo = info,

6
src/ImageSharp/Formats/Gif/GifDecoderCore.cs

@ -266,7 +266,7 @@ internal sealed class GifDecoderCore : ImageDecoderCore
GifThrowHelper.ThrowNoHeader();
}
return new ImageInfo(
return new(
new(this.logicalScreenDescriptor.Width, this.logicalScreenDescriptor.Height),
this.metadata,
framesMetadata);
@ -344,7 +344,7 @@ internal sealed class GifDecoderCore : ImageDecoderCore
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
{
@ -549,7 +549,7 @@ internal sealed class GifDecoderCore : ImageDecoderCore
if (previousFrame is null && previousDisposalMode is null)
{
image = transFlag
? new Image<TPixel>(this.configuration, imageWidth, imageHeight, this.metadata)
? new(this.configuration, imageWidth, imageHeight, this.metadata)
: new Image<TPixel>(this.configuration, imageWidth, imageHeight, backgroundPixel, this.metadata);
this.SetFrameMetadata(image.Frames.RootFrame.Metadata);

2
src/ImageSharp/Formats/Gif/GifMetadata.cs

@ -87,7 +87,7 @@ public class GifMetadata : IFormatMetadata<GifMetadata>
? 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),

2
src/ImageSharp/Formats/Gif/Sections/GifNetscapeLoopingApplicationExtension.cs

@ -22,7 +22,7 @@ internal readonly struct GifNetscapeLoopingApplicationExtension : IGifExtension
public static GifNetscapeLoopingApplicationExtension Parse(ReadOnlySpan<byte> buffer)
{
ushort repeatCount = BinaryPrimitives.ReadUInt16LittleEndian(buffer[..2]);
return new GifNetscapeLoopingApplicationExtension(repeatCount);
return new(repeatCount);
}
public int WriteTo(Span<byte> buffer)

2
src/ImageSharp/Formats/Gif/Sections/GifXmpApplicationExtension.cs

@ -42,7 +42,7 @@ internal readonly struct GifXmpApplicationExtension : IGifExtension
stream.Skip(1); // Skip the terminator.
}
return new GifXmpApplicationExtension(buffer);
return new(buffer);
}
public int WriteTo(Span<byte> buffer)

6
src/ImageSharp/Formats/Ico/IcoFrameMetadata.cs

@ -66,7 +66,7 @@ public class IcoFrameMetadata : IFormatFrameMetadata<IcoFrameMetadata>
{
if (!metadata.PixelTypeInfo.HasValue)
{
return new IcoFrameMetadata
return new()
{
BmpBitsPerPixel = BmpBitsPerPixel.Bit32,
Compression = IconFrameCompression.Png
@ -91,7 +91,7 @@ public class IcoFrameMetadata : IFormatFrameMetadata<IcoFrameMetadata>
compression = IconFrameCompression.Png;
}
return new IcoFrameMetadata
return new()
{
BmpBitsPerPixel = bbpp,
Compression = compression,
@ -205,7 +205,7 @@ public class IcoFrameMetadata : IFormatFrameMetadata<IcoFrameMetadata>
}
}
return new PixelTypeInfo(bpp)
return new(bpp)
{
AlphaRepresentation = alpha,
ComponentInfo = info,

4
src/ImageSharp/Formats/Ico/IcoMetadata.cs

@ -68,7 +68,7 @@ public class IcoMetadata : IFormatMetadata<IcoMetadata>
compression = IconFrameCompression.Png;
}
return new IcoMetadata
return new()
{
BmpBitsPerPixel = bbpp,
Compression = compression
@ -129,7 +129,7 @@ public class IcoMetadata : IFormatMetadata<IcoMetadata>
}
}
return new PixelTypeInfo(bpp)
return new(bpp)
{
AlphaRepresentation = alpha,
ComponentInfo = info,

2
src/ImageSharp/Formats/Jpeg/Components/Block8x8.cs

@ -140,7 +140,7 @@ internal partial struct Block8x8
/// <inheritdoc />
public override string ToString()
{
var sb = new StringBuilder();
StringBuilder sb = new StringBuilder();
sb.Append('[');
for (int i = 0; i < Size; i++)
{

8
src/ImageSharp/Formats/Jpeg/Components/Block8x8F.ScaledCopy.cs

@ -57,19 +57,19 @@ internal partial struct Block8x8F
ref Vector4 dTopLeft = ref Unsafe.As<Vector2, Vector4>(ref Unsafe.Add(ref destBase, offset));
ref Vector4 dBottomLeft = ref Unsafe.As<Vector2, Vector4>(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;

2
src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverterBase.cs

@ -514,7 +514,7 @@ internal abstract partial class JpegColorConverterBase
Span<float> c2 = this.Component2.Length > 0 ? this.Component2.Slice(start, length) : [];
Span<float> 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);
}
}
}

2
src/ImageSharp/Formats/Jpeg/Components/Decoder/AdobeMarker.cs

@ -71,7 +71,7 @@ internal readonly struct AdobeMarker : IEquatable<AdobeMarker>
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;
}

2
src/ImageSharp/Formats/Jpeg/Components/Decoder/ArithmeticScanDecoder.cs

@ -242,7 +242,7 @@ internal class ArithmeticScanDecoder : IJpegScanDecoder
this.scanComponentCount = scanComponentCount;
this.scanBuffer = new JpegBitReader(this.stream);
this.scanBuffer = new(this.stream);
this.frame.AllocateComponents();

4
src/ImageSharp/Formats/Jpeg/Components/Decoder/HuffmanScanDecoder.cs

@ -116,7 +116,7 @@ internal class HuffmanScanDecoder : IJpegScanDecoder
this.scanComponentCount = scanComponentCount;
this.scanBuffer = new JpegBitReader(this.stream);
this.scanBuffer = new(this.stream);
this.frame.AllocateComponents();
@ -784,6 +784,6 @@ internal class HuffmanScanDecoder : IJpegScanDecoder
public void BuildHuffmanTable(int type, int index, ReadOnlySpan<byte> codeLengths, ReadOnlySpan<byte> values, Span<uint> workspace)
{
HuffmanTable[] tables = type == 0 ? this.dcHuffmanTables : this.acHuffmanTables;
tables[index] = new HuffmanTable(codeLengths, values, workspace);
tables[index] = new(codeLengths, values, workspace);
}
}

2
src/ImageSharp/Formats/Jpeg/Components/Decoder/JFifMarker.cs

@ -80,7 +80,7 @@ internal readonly struct JFifMarker : IEquatable<JFifMarker>
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;
}

4
src/ImageSharp/Formats/Jpeg/Components/Decoder/JpegComponent.cs

@ -21,7 +21,7 @@ internal class JpegComponent : IDisposable, IJpegComponent
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 @@ internal class JpegComponent : IDisposable, IJpegComponent
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);

2
src/ImageSharp/Formats/Jpeg/Components/Decoder/SpectralConverter.cs

@ -121,7 +121,7 @@ internal abstract class SpectralConverter
if (scaledWidth >= tSize.Width && scaledHeight >= tSize.Height)
{
blockPixelSize = blockSize;
return new Size(scaledWidth, scaledHeight);
return new(scaledWidth, scaledHeight);
}
}
}

4
src/ImageSharp/Formats/Jpeg/Components/Encoder/Component.cs

@ -19,7 +19,7 @@ internal class Component : IDisposable
this.HorizontalSamplingFactor = horizontalFactor;
this.VerticalSamplingFactor = verticalFactor;
this.SamplingFactors = new Size(horizontalFactor, verticalFactor);
this.SamplingFactors = new(horizontalFactor, verticalFactor);
this.QuantizationTableIndex = quantizationTableIndex;
}
@ -95,7 +95,7 @@ internal class Component : IDisposable
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);

2
src/ImageSharp/Formats/Jpeg/Components/Encoder/ComponentProcessor.cs

@ -241,7 +241,7 @@ internal class ComponentProcessor : IDisposable
ref Vector<float> targetVectorRef = ref Unsafe.As<float, Vector<float>>(ref MemoryMarshal.GetReference(target));
nuint count = target.VectorCount<float>();
var multiplierVector = new Vector<float>(multiplier);
Vector<float> multiplierVector = new Vector<float>(multiplier);
for (nuint i = 0; i < count; i++)
{
Unsafe.Add(ref targetVectorRef, i) *= multiplierVector;

4
src/ImageSharp/Formats/Jpeg/Components/Encoder/HuffmanScanEncoder.cs

@ -134,7 +134,7 @@ internal class HuffmanScanEncoder
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);
}
/// <summary>
@ -409,7 +409,7 @@ internal class HuffmanScanEncoder
{
this.FlushRemainingBytes();
this.WriteRestart(restarts % 8);
foreach (var component in frame.Components)
foreach (Component component in frame.Components)
{
component.DcPredictor = 0;
}

2
src/ImageSharp/Formats/Jpeg/Components/Encoder/JpegFrame.cs

@ -27,7 +27,7 @@ internal sealed class JpegFrame : IDisposable
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,

6
src/ImageSharp/Formats/Jpeg/Components/Encoder/SpectralConverter{TPixel}.cs

@ -46,12 +46,12 @@ internal class SpectralConverter<TPixel> : SpectralConverter, IDisposable
// 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 @@ internal class SpectralConverter<TPixel> : SpectralConverter, IDisposable
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);
}

8
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?
/// </summary>
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);
/// <summary>
/// Divides 'a.Width' with 'b.Width' and 'a.Height' with 'b.Height'.
/// TODO: Shouldn't we expose this as operator in SixLabors.Core?
/// </summary>
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);
/// <summary>
/// Divide Width and Height as real numbers and return the Ceiling.
/// </summary>
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);
}
/// <summary>

32
src/ImageSharp/Formats/Jpeg/JpegDecoderCore.cs

@ -167,7 +167,7 @@ internal sealed class JpegDecoderCore : ImageDecoderCore, IRawJpegData
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 @@ internal sealed class JpegDecoderCore : ImageDecoderCore, IRawJpegData
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 @@ internal sealed class JpegDecoderCore : ImageDecoderCore, IRawJpegData
_ = this.Options.TryGetIccProfileForColorConversion(this.Metadata.IccProfile, out IccProfile profile);
return new Image<TPixel>(
return new(
this.configuration,
spectralConverter.GetPixelBuffer(profile, cancellationToken),
this.Metadata);
@ -222,7 +222,7 @@ internal sealed class JpegDecoderCore : ImageDecoderCore, IRawJpegData
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);
}
/// <summary>
@ -233,7 +233,7 @@ internal sealed class JpegDecoderCore : ImageDecoderCore, IRawJpegData
/// <param name="scanDecoder">The scan decoder.</param>
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 @@ internal sealed class JpegDecoderCore : ImageDecoderCore, IRawJpegData
// 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 @@ internal sealed class JpegDecoderCore : ImageDecoderCore, IRawJpegData
JpegThrowHelper.ThrowInvalidImageContentException("Not enough data to read marker");
}
fileMarker = new JpegFileMarker(markerBuffer[1], 0);
fileMarker = new(markerBuffer[1], 0);
}
}
@ -316,7 +316,7 @@ internal sealed class JpegDecoderCore : ImageDecoderCore, IRawJpegData
this.scanDecoder ??= new HuffmanScanDecoder(stream, spectralConverter, cancellationToken);
this.Metadata ??= new ImageMetadata();
this.Metadata ??= new();
Span<byte> markerBuffer = stackalloc byte[2];
@ -529,7 +529,7 @@ internal sealed class JpegDecoderCore : ImageDecoderCore, IRawJpegData
chars[i] = (char)read;
}
metadata.Comments.Add(new JpegComData(chars));
metadata.Comments.Add(new(chars));
}
/// <summary>
@ -661,7 +661,7 @@ internal sealed class JpegDecoderCore : ImageDecoderCore, IRawJpegData
{
if (this.hasExif)
{
this.Metadata.ExifProfile = new ExifProfile(this.exifData);
this.Metadata.ExifProfile = new(this.exifData);
}
}
@ -685,7 +685,7 @@ internal sealed class JpegDecoderCore : ImageDecoderCore, IRawJpegData
if (!this.skipMetadata && profile?.CheckIsValid() == true)
{
this.hasIcc = true;
this.Metadata ??= new ImageMetadata();
this.Metadata ??= new();
this.Metadata.IccProfile = profile;
}
}
@ -697,7 +697,7 @@ internal sealed class JpegDecoderCore : ImageDecoderCore, IRawJpegData
{
if (this.hasIptc)
{
this.Metadata.IptcProfile = new IptcProfile(this.iptcData);
this.Metadata.IptcProfile = new(this.iptcData);
}
}
@ -708,7 +708,7 @@ internal sealed class JpegDecoderCore : ImageDecoderCore, IRawJpegData
{
if (this.hasXmp)
{
this.Metadata.XmpProfile = new XmpProfile(this.xmpData);
this.Metadata.XmpProfile = new(this.xmpData);
}
}
@ -992,7 +992,7 @@ internal sealed class JpegDecoderCore : ImageDecoderCore, IRawJpegData
/// <param name="remaining">The remaining bytes in the segment block.</param>
private void ProcessArithmeticTable(BufferedReadStream stream, int remaining)
{
this.arithmeticDecodingTables ??= new List<ArithmeticDecodingTable>(4);
this.arithmeticDecodingTables ??= new(4);
while (remaining > 0)
{
@ -1242,7 +1242,7 @@ internal sealed class JpegDecoderCore : ImageDecoderCore, IRawJpegData
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;

16
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 @@ internal sealed unsafe partial class JpegEncoderCore
defaultChrominanceHuffmanAC,
};
var yCbCrQuantTableConfigs = new JpegQuantizationTableConfig[]
JpegQuantizationTableConfig[] yCbCrQuantTableConfigs = new JpegQuantizationTableConfig[]
{
defaultLuminanceQuantTable,
defaultChrominanceQuantTable,

4
src/ImageSharp/Formats/Jpeg/JpegMetadata.cs

@ -139,7 +139,7 @@ public class JpegMetadata : IFormatMetadata<JpegMetadata>
break;
}
return new JpegMetadata
return new()
{
ColorType = color,
ChrominanceQuality = metadata.Quality,
@ -182,7 +182,7 @@ public class JpegMetadata : IFormatMetadata<JpegMetadata>
break;
}
return new PixelTypeInfo(bpp)
return new(bpp)
{
AlphaRepresentation = PixelAlphaRepresentation.None,
ColorType = colorType,

6
src/ImageSharp/Formats/Pbm/PbmDecoderCore.cs

@ -79,7 +79,7 @@ internal sealed class PbmDecoderCore : ImageDecoderCore
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 @@ internal sealed class PbmDecoderCore : ImageDecoderCore
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;

4
src/ImageSharp/Formats/Pbm/PbmMetadata.cs

@ -77,7 +77,7 @@ public class PbmMetadata : IFormatMetadata<PbmMetadata>
_ => PbmComponentType.Short
};
return new PbmMetadata
return new()
{
ColorType = color,
ComponentType = componentType
@ -114,7 +114,7 @@ public class PbmMetadata : IFormatMetadata<PbmMetadata>
break;
}
return new PixelTypeInfo(bpp)
return new(bpp)
{
AlphaRepresentation = PixelAlphaRepresentation.None,
ColorType = colorType,

8
src/ImageSharp/Formats/Pbm/PlainDecoder.cs

@ -71,7 +71,7 @@ internal class PlainDecoder
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 @@ internal class PlainDecoder
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 @@ internal class PlainDecoder
stream.ReadDecimal(out int blue);
rowSpan[x] = new Rgb24((byte)red, (byte)green, (byte)blue);
rowSpan[x] = new((byte)red, (byte)green, (byte)blue);
eofReached = !stream.SkipWhitespaceAndComments();
if (eofReached)
{
@ -201,7 +201,7 @@ internal class PlainDecoder
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)
{

4
src/ImageSharp/Formats/Png/Chunks/PngPhysical.cs

@ -50,7 +50,7 @@ internal readonly struct PngPhysical
uint vResolution = BinaryPrimitives.ReadUInt32BigEndian(data.Slice(4, 4));
byte unit = data[8];
return new PngPhysical(hResolution, vResolution, unit);
return new(hResolution, vResolution, unit);
}
/// <summary>
@ -92,7 +92,7 @@ internal readonly struct PngPhysical
break;
}
return new PngPhysical(x, y, unitSpecifier);
return new(x, y, unitSpecifier);
}
/// <summary>

2
src/ImageSharp/Formats/Png/PngDecoder.cs

@ -25,7 +25,7 @@ public sealed class PngDecoder : SpecializedImageDecoder<PngDecoderOptions>
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);
}
/// <inheritdoc/>

28
src/ImageSharp/Formats/Png/PngDecoderCore.cs

@ -297,7 +297,7 @@ internal sealed class PngDecoderCore : ImageDecoderCore
{
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 @@ internal sealed class PngDecoderCore : ImageDecoderCore
{
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 @@ internal sealed class PngDecoderCore : ImageDecoderCore
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 @@ internal sealed class PngDecoderCore : ImageDecoderCore
private void InitializeImage<TPixel>(ImageMetadata metadata, FrameControl frameControl, out Image<TPixel> image)
where TPixel : unmanaged, IPixel<TPixel>
{
image = new Image<TPixel>(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 @@ internal sealed class PngDecoderCore : ImageDecoderCore
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 @@ internal sealed class PngDecoderCore : ImageDecoderCore
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 @@ internal sealed class PngDecoderCore : ImageDecoderCore
fullRange = null;
}
metadata.CicpProfile = new CicpProfile(colorPrimaries, transferFunction, matrixCoefficients, fullRange);
metadata.CicpProfile = new(colorPrimaries, transferFunction, matrixCoefficients, fullRange);
}
/// <summary>
@ -1560,7 +1560,7 @@ internal sealed class PngDecoderCore : ImageDecoderCore
return false;
}
MergeOrSetExifProfile(metadata, new ExifProfile(exifBlob), replaceExistingKeys: false);
MergeOrSetExifProfile(metadata, new(exifBlob), replaceExistingKeys: false);
return true;
}
@ -1594,7 +1594,7 @@ internal sealed class PngDecoderCore : ImageDecoderCore
if (this.TryDecompressZlibData(compressedData, this.maxUncompressedLength, out byte[] iccpProfileBytes))
{
metadata.IccProfile = new IccProfile(iccpProfileBytes);
metadata.IccProfile = new(iccpProfileBytes);
}
}
@ -1750,17 +1750,17 @@ internal sealed class PngDecoderCore : ImageDecoderCore
if (this.TryDecompressTextData(compressedData, PngConstants.TranslatedEncoding, out string? uncompressed))
{
pngMetadata.TextData.Add(new PngTextData(keyword, uncompressed, language, translatedKeyword));
pngMetadata.TextData.Add(new(keyword, uncompressed, language, translatedKeyword));
}
}
else if (IsXmpTextData(keywordBytes))
{
metadata.XmpProfile = new XmpProfile(data[dataStartIdx..].ToArray());
metadata.XmpProfile = new(data[dataStartIdx..].ToArray());
}
else
{
string value = PngConstants.TranslatedEncoding.GetString(data[dataStartIdx..]);
pngMetadata.TextData.Add(new PngTextData(keyword, value, language, translatedKeyword));
pngMetadata.TextData.Add(new(keyword, value, language, translatedKeyword));
}
}
@ -1950,14 +1950,14 @@ internal sealed class PngDecoderCore : ImageDecoderCore
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));

2
src/ImageSharp/Formats/Png/PngFrameMetadata.cs

@ -53,7 +53,7 @@ public class PngFrameMetadata : IFormatFrameMetadata<PngFrameMetadata>
/// <param name="frameControl">The chunk to create an instance from.</param>
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;
}

2
src/ImageSharp/Formats/Png/PngMetadata.cs

@ -209,7 +209,7 @@ public class PngMetadata : IFormatMetadata<PngMetadata>
break;
}
return new PixelTypeInfo(bpp)
return new(bpp)
{
AlphaRepresentation = alpha,
ColorType = colorType,

4
src/ImageSharp/Formats/Qoi/QoiDecoderCore.cs

@ -68,7 +68,7 @@ internal class QoiDecoderCore : ImageDecoderCore
qoiMetadata.Channels = this.header.Channels;
qoiMetadata.ColorSpace = this.header.ColorSpace;
return new ImageInfo(size, metadata);
return new(size, metadata);
}
/// <summary>
@ -124,7 +124,7 @@ internal class QoiDecoderCore : ImageDecoderCore
ThrowInvalidImageContentException();
}
this.header = new QoiHeader(width, height, (QoiChannels)channels, (QoiColorSpace)colorSpace);
this.header = new(width, height, (QoiChannels)channels, (QoiColorSpace)colorSpace);
}
[DoesNotReturn]

6
src/ImageSharp/Formats/Qoi/QoiMetadata.cs

@ -44,10 +44,10 @@ public class QoiMetadata : IFormatMetadata<QoiMetadata>
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 };
}
/// <inheritdoc/>
@ -73,7 +73,7 @@ public class QoiMetadata : IFormatMetadata<QoiMetadata>
break;
}
return new PixelTypeInfo(bpp)
return new(bpp)
{
AlphaRepresentation = alpha,
ColorType = colorType,

10
src/ImageSharp/Formats/Tga/TgaDecoderCore.cs

@ -622,7 +622,7 @@ internal sealed class TgaDecoderCore : ImageDecoderCore
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 @@ internal sealed class TgaDecoderCore : ImageDecoderCore
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 @@ internal sealed class TgaDecoderCore : ImageDecoderCore
Guard.NotNull(this.tgaMetadata);
byte alpha = this.tgaMetadata.AlphaChannelBits == 0 ? byte.MaxValue : scratchBuffer[3];
pixelRow[x] = TPixel.FromBgra32(new Bgra32(scratchBuffer[2], scratchBuffer[1], scratchBuffer[0], alpha));
pixelRow[x] = TPixel.FromBgra32(new(scratchBuffer[2], scratchBuffer[1], scratchBuffer[0], alpha));
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
@ -907,9 +907,9 @@ internal sealed class TgaDecoderCore : ImageDecoderCore
stream.Read(buffer, 0, TgaFileHeader.Size);
this.fileHeader = TgaFileHeader.Parse(buffer);
this.Dimensions = new Size(this.fileHeader.Width, this.fileHeader.Height);
this.Dimensions = new(this.fileHeader.Width, this.fileHeader.Height);
this.metadata = new ImageMetadata();
this.metadata = new();
this.tgaMetadata = this.metadata.GetTgaMetadata();
this.tgaMetadata.BitsPerPixel = (TgaBitsPerPixel)this.fileHeader.PixelDepth;

2
src/ImageSharp/Formats/Tga/TgaImageFormatDetector.cs

@ -34,7 +34,7 @@ public sealed class TgaImageFormatDetector : IImageFormatDetector
}
// The third byte is the image type.
var imageType = (TgaImageType)header[2];
TgaImageType imageType = (TgaImageType)header[2];
if (!imageType.IsValid())
{
return false;

10
src/ImageSharp/Formats/Tga/TgaMetadata.cs

@ -41,10 +41,10 @@ public class TgaMetadata : IFormatMetadata<TgaMetadata>
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 class TgaMetadata : IFormatMetadata<TgaMetadata>
break;
}
return new PixelTypeInfo(bpp)
return new(bpp)
{
AlphaRepresentation = alpha,
ComponentInfo = info,

2
src/ImageSharp/Formats/Tiff/Compression/Compressors/DeflateCompressor.cs

@ -29,7 +29,7 @@ internal sealed class DeflateCompressor : TiffBaseCompressor
public override void CompressStrip(Span<byte> 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)
{

2
src/ImageSharp/Formats/Tiff/Compression/Compressors/LzwCompressor.cs

@ -20,7 +20,7 @@ internal sealed class LzwCompressor : TiffBaseCompressor
public override TiffCompression Method => TiffCompression.Lzw;
/// <inheritdoc/>
public override void Initialize(int rowsPerStrip) => this.lzwEncoder = new TiffLzwEncoder(this.Allocator);
public override void Initialize(int rowsPerStrip) => this.lzwEncoder = new(this.Allocator);
/// <inheritdoc/>
public override void CompressStrip(Span<byte> rows, int height)

2
src/ImageSharp/Formats/Tiff/Compression/Compressors/PackBitsWriter.cs

@ -101,7 +101,7 @@ internal static class PackBitsWriter
private static int FindRunLength(ReadOnlySpan<byte> 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++)
{

4
src/ImageSharp/Formats/Tiff/Compression/Compressors/TiffJpegCompressor.cs

@ -29,8 +29,8 @@ internal class TiffJpegCompressor : TiffBaseCompressor
int pixelCount = rows.Length / 3;
int width = pixelCount / height;
using var memoryStream = new MemoryStream();
var image = Image.LoadPixelData<Rgb24>(rows, width, height);
using MemoryStream memoryStream = new MemoryStream();
Image<Rgb24> image = Image.LoadPixelData<Rgb24>(rows, width, height);
image.Save(memoryStream, new JpegEncoder()
{
ColorType = JpegColorType.Rgb

2
src/ImageSharp/Formats/Tiff/Compression/Decompressors/DeflateTiffCompression.cs

@ -54,7 +54,7 @@ internal sealed class DeflateTiffCompression : TiffBaseDecompressor
protected override void Decompress(BufferedReadStream stream, int byteCount, int stripHeight, Span<byte> buffer, CancellationToken cancellationToken)
{
long pos = stream.Position;
using (var deframeStream = new ZlibInflateStream(
using (ZlibInflateStream deframeStream = new ZlibInflateStream(
stream,
() =>
{

6
src/ImageSharp/Formats/Tiff/Compression/Decompressors/LzwString.cs

@ -9,7 +9,7 @@ namespace SixLabors.ImageSharp.Formats.Tiff.Compression.Decompressors;
/// </summary>
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 class LzwString
{
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);
}
/// <summary>

2
src/ImageSharp/Formats/Tiff/Compression/Decompressors/LzwTiffCompression.cs

@ -48,7 +48,7 @@ internal sealed class LzwTiffCompression : TiffBaseDecompressor
/// <inheritdoc/>
protected override void Decompress(BufferedReadStream stream, int byteCount, int stripHeight, Span<byte> buffer, CancellationToken cancellationToken)
{
var decoder = new TiffLzwDecoder(stream);
TiffLzwDecoder decoder = new TiffLzwDecoder(stream);
decoder.DecodePixels(buffer);
if (this.Predictor == TiffPredictor.Horizontal)

2
src/ImageSharp/Formats/Tiff/Compression/Decompressors/ModifiedHuffmanTiffCompression.cs

@ -41,7 +41,7 @@ internal sealed class ModifiedHuffmanTiffCompression : TiffBaseDecompressor
/// <inheritdoc/>
protected override void Decompress(BufferedReadStream stream, int byteCount, int stripHeight, Span<byte> buffer, CancellationToken cancellationToken)
{
var bitReader = new ModifiedHuffmanBitReader(stream, this.FillOrder, byteCount);
ModifiedHuffmanBitReader bitReader = new ModifiedHuffmanBitReader(stream, this.FillOrder, byteCount);
buffer.Clear();
nint bitsWritten = 0;

2
src/ImageSharp/Formats/Tiff/Compression/Decompressors/T4TiffCompression.cs

@ -60,7 +60,7 @@ internal sealed class T4TiffCompression : TiffBaseDecompressor
}
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;

6
src/ImageSharp/Formats/Tiff/Compression/Decompressors/T6TiffCompression.cs

@ -57,9 +57,9 @@ internal sealed class T6TiffCompression : TiffBaseDecompressor
Span<byte> scanLine = scanLineBuffer.GetSpan()[..this.width];
Span<byte> 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 @@ internal sealed class T6TiffCompression : TiffBaseDecompressor
bitsWritten = this.WriteScanLine(buffer, scanLine, bitsWritten);
scanLine.CopyTo(referenceScanLineSpan);
referenceScanLine = new CcittReferenceScanline(this.isWhiteZero, referenceScanLineSpan);
referenceScanLine = new(this.isWhiteZero, referenceScanLineSpan);
}
}

2
src/ImageSharp/Formats/Tiff/Compression/Decompressors/TiffLzwDecoder.cs

@ -103,7 +103,7 @@ internal sealed class TiffLzwDecoder
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();

2
src/ImageSharp/Formats/Tiff/Compression/Decompressors/WebpTiffCompression.cs

@ -32,7 +32,7 @@ internal class WebpTiffCompression : TiffBaseDecompressor
/// <inheritdoc/>
protected override void Decompress(BufferedReadStream stream, int byteCount, int stripHeight, Span<byte> buffer, CancellationToken cancellationToken)
{
using WebpDecoderCore decoder = new(new WebpDecoderOptions() { GeneralOptions = this.options });
using WebpDecoderCore decoder = new(new() { GeneralOptions = this.options });
using Image<Rgb24> image = decoder.Decode<Rgb24>(this.options.Configuration, stream, cancellationToken);
CopyImageBytesToBuffer(buffer, image.Frames.RootFrame.PixelBuffer);
}

6
src/ImageSharp/Formats/Tiff/Compression/HorizontalPredictor.cs

@ -222,7 +222,7 @@ internal static class HorizontalPredictor
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 @@ internal static class HorizontalPredictor
r += pixel.R;
g += pixel.G;
b += pixel.B;
pixel = new Rgb24(r, g, b);
pixel = new(r, g, b);
}
}
@ -462,7 +462,7 @@ internal static class HorizontalPredictor
g += pixel.G;
b += pixel.B;
a += pixel.A;
pixel = new Rgba32(r, g, b, a);
pixel = new(r, g, b, a);
}
}

4
src/ImageSharp/Formats/Tiff/PhotometricInterpretation/BlackIsZero32FloatTiffColor{TPixel}.cs

@ -40,7 +40,7 @@ internal class BlackIsZero32FloatTiffColor<TPixel> : TiffBaseColorDecoder<TPixel
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 @@ internal class BlackIsZero32FloatTiffColor<TPixel> : TiffBaseColorDecoder<TPixel
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));
}
}
}

Some files were not shown because too many files changed in this diff

Loading…
Cancel
Save