diff --git a/src/ImageSharp/Formats/Bmp/BmpDecoderOptions.cs b/src/ImageSharp/Formats/Bmp/BmpDecoderOptions.cs
index 26c4e7ec58..bfe7f6ca2c 100644
--- a/src/ImageSharp/Formats/Bmp/BmpDecoderOptions.cs
+++ b/src/ImageSharp/Formats/Bmp/BmpDecoderOptions.cs
@@ -9,11 +9,11 @@ namespace SixLabors.ImageSharp.Formats.Bmp;
public sealed class BmpDecoderOptions : ISpecializedDecoderOptions
{
///
- public DecoderOptions GeneralOptions { get; set; } = new();
+ public DecoderOptions GeneralOptions { get; init; } = DecoderOptions.Default;
///
- /// Gets or sets the value indicating how to deal with skipped pixels,
+ /// Gets the value indicating how to deal with skipped pixels,
/// which can occur during decoding run length encoded bitmaps.
///
- public RleSkippedPixelHandling RleSkippedPixelHandling { get; set; }
+ public RleSkippedPixelHandling RleSkippedPixelHandling { get; init; }
}
diff --git a/src/ImageSharp/Formats/DecoderOptions.cs b/src/ImageSharp/Formats/DecoderOptions.cs
index 3e3f1aa50d..9acdae827b 100644
--- a/src/ImageSharp/Formats/DecoderOptions.cs
+++ b/src/ImageSharp/Formats/DecoderOptions.cs
@@ -21,27 +21,27 @@ public sealed class DecoderOptions
internal static DecoderOptions Default { get; } = LazyOptions.Value;
///
- /// Gets or sets a custom Configuration instance to be used by the image processing pipeline.
+ /// Gets a custom configuration instance to be used by the image processing pipeline.
///
- public Configuration Configuration { get; set; } = Configuration.Default;
+ public Configuration Configuration { get; internal set; } = Configuration.Default;
///
- /// Gets or sets the target size to decode the image into.
+ /// Gets the target size to decode the image into.
///
- public Size? TargetSize { get; set; }
+ public Size? TargetSize { get; init; }
///
- /// Gets or sets the sampler to use when resizing during decoding.
+ /// Gets the sampler to use when resizing during decoding.
///
- public IResampler Sampler { get; set; } = KnownResamplers.Box;
+ public IResampler Sampler { get; init; } = KnownResamplers.Box;
///
- /// Gets or sets a value indicating whether to ignore encoded metadata when decoding.
+ /// Gets a value indicating whether to ignore encoded metadata when decoding.
///
- public bool SkipMetadata { get; set; }
+ public bool SkipMetadata { get; init; }
///
- /// Gets or sets the maximum number of image frames to decode, inclusive.
+ /// Gets the maximum number of image frames to decode, inclusive.
///
- public uint MaxFrames { get => this.maxFrames; set => this.maxFrames = Math.Clamp(value, 1, int.MaxValue); }
+ public uint MaxFrames { get => this.maxFrames; init => this.maxFrames = Math.Clamp(value, 1, int.MaxValue); }
}
diff --git a/src/ImageSharp/Formats/ISpecializedDecoderOptions.cs b/src/ImageSharp/Formats/ISpecializedDecoderOptions.cs
index 75f643d0c6..e0a4c9b62c 100644
--- a/src/ImageSharp/Formats/ISpecializedDecoderOptions.cs
+++ b/src/ImageSharp/Formats/ISpecializedDecoderOptions.cs
@@ -9,7 +9,7 @@ namespace SixLabors.ImageSharp.Formats;
public interface ISpecializedDecoderOptions
{
///
- /// Gets or sets the general decoder options.
+ /// Gets the general decoder options.
///
- DecoderOptions GeneralOptions { get; set; }
+ DecoderOptions GeneralOptions { get; init; }
}
diff --git a/src/ImageSharp/Formats/Jpeg/JpegDecoderOptions.cs b/src/ImageSharp/Formats/Jpeg/JpegDecoderOptions.cs
index 193b2d3a8f..633b9f80b8 100644
--- a/src/ImageSharp/Formats/Jpeg/JpegDecoderOptions.cs
+++ b/src/ImageSharp/Formats/Jpeg/JpegDecoderOptions.cs
@@ -8,11 +8,11 @@ namespace SixLabors.ImageSharp.Formats.Jpeg;
///
public sealed class JpegDecoderOptions : ISpecializedDecoderOptions
{
+ ///
+ public DecoderOptions GeneralOptions { get; init; } = DecoderOptions.Default;
+
///
- /// Gets or sets the resize mode.
+ /// Gets the resize mode.
///
- public JpegDecoderResizeMode ResizeMode { get; set; }
-
- ///
- public DecoderOptions GeneralOptions { get; set; } = new();
+ public JpegDecoderResizeMode ResizeMode { get; init; }
}
diff --git a/tests/ImageSharp.Benchmarks/Codecs/Jpeg/DecodeJpegParseStreamOnly.cs b/tests/ImageSharp.Benchmarks/Codecs/Jpeg/DecodeJpegParseStreamOnly.cs
index 3a3c81b52c..aa88242ce4 100644
--- a/tests/ImageSharp.Benchmarks/Codecs/Jpeg/DecodeJpegParseStreamOnly.cs
+++ b/tests/ImageSharp.Benchmarks/Codecs/Jpeg/DecodeJpegParseStreamOnly.cs
@@ -37,8 +37,7 @@ public class DecodeJpegParseStreamOnly
{
using var memoryStream = new MemoryStream(this.jpegBytes);
using var bufferedStream = new BufferedReadStream(Configuration.Default, memoryStream);
- var options = new JpegDecoderOptions();
- options.GeneralOptions.SkipMetadata = true;
+ var options = new JpegDecoderOptions() { GeneralOptions = new() { SkipMetadata = true } };
using var decoder = new JpegDecoderCore(options);
var spectralConverter = new NoopSpectralConverter();
diff --git a/tests/ImageSharp.Tests/TestFormat.cs b/tests/ImageSharp.Tests/TestFormat.cs
index 99b522a4fe..e195bc660d 100644
--- a/tests/ImageSharp.Tests/TestFormat.cs
+++ b/tests/ImageSharp.Tests/TestFormat.cs
@@ -230,7 +230,7 @@ public class TestFormat : IConfigurationModule, IImageFormat
public class TestDecoderOptions : ISpecializedDecoderOptions
{
- public DecoderOptions GeneralOptions { get; set; } = new();
+ public DecoderOptions GeneralOptions { get; init; } = DecoderOptions.Default;
}
public class TestEncoder : ImageEncoder
diff --git a/tests/ImageSharp.Tests/TestUtilities/Tests/TestImageProviderTests.cs b/tests/ImageSharp.Tests/TestUtilities/Tests/TestImageProviderTests.cs
index 2806091dd7..99bba9e816 100644
--- a/tests/ImageSharp.Tests/TestUtilities/Tests/TestImageProviderTests.cs
+++ b/tests/ImageSharp.Tests/TestUtilities/Tests/TestImageProviderTests.cs
@@ -429,15 +429,15 @@ public class TestImageProviderTests
private class TestDecoderOptions : ISpecializedDecoderOptions
{
- public DecoderOptions GeneralOptions { get; set; } = new();
+ public DecoderOptions GeneralOptions { get; init; } = DecoderOptions.Default;
}
private class TestDecoderWithParametersOptions : ISpecializedDecoderOptions
{
- public string Param1 { get; set; }
+ public string Param1 { get; init; }
- public int Param2 { get; set; }
+ public int Param2 { get; init; }
- public DecoderOptions GeneralOptions { get; set; } = new();
+ public DecoderOptions GeneralOptions { get; init; } = DecoderOptions.Default;
}
}