From 0e13e6c96c8ef1adc9d7f2290785612447f53eec Mon Sep 17 00:00:00 2001 From: James Jackson-South Date: Mon, 8 Aug 2022 13:45:53 +1000 Subject: [PATCH] Add sampler option, add comment. --- src/ImageSharp/Formats/DecoderOptions.cs | 7 +++++++ src/ImageSharp/Formats/ImageDecoderUtilities.cs | 2 +- src/ImageSharp/Formats/Jpeg/JpegDecoderResizeMode.cs | 4 +++- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/ImageSharp/Formats/DecoderOptions.cs b/src/ImageSharp/Formats/DecoderOptions.cs index a608fcd524..8f16c6ecc7 100644 --- a/src/ImageSharp/Formats/DecoderOptions.cs +++ b/src/ImageSharp/Formats/DecoderOptions.cs @@ -2,6 +2,8 @@ // Licensed under the Six Labors Split License. using System; +using SixLabors.ImageSharp.Processing; +using SixLabors.ImageSharp.Processing.Processors.Transforms; namespace SixLabors.ImageSharp.Formats { @@ -29,6 +31,11 @@ namespace SixLabors.ImageSharp.Formats /// public Size? TargetSize { get; set; } = null; + /// + /// Gets or sets the sampler to use when resizing during decoding. + /// + public IResampler Sampler { get; set; } = KnownResamplers.Box; + /// /// Gets or sets a value indicating whether to ignore encoded metadata when decoding. /// diff --git a/src/ImageSharp/Formats/ImageDecoderUtilities.cs b/src/ImageSharp/Formats/ImageDecoderUtilities.cs index 2c04820341..37a4ebe5fe 100644 --- a/src/ImageSharp/Formats/ImageDecoderUtilities.cs +++ b/src/ImageSharp/Formats/ImageDecoderUtilities.cs @@ -29,7 +29,7 @@ namespace SixLabors.ImageSharp.Formats ResizeOptions resizeOptions = new() { Size = options.TargetSize.Value, - Sampler = KnownResamplers.Box, + Sampler = options.Sampler, Mode = ResizeMode.Max }; diff --git a/src/ImageSharp/Formats/Jpeg/JpegDecoderResizeMode.cs b/src/ImageSharp/Formats/Jpeg/JpegDecoderResizeMode.cs index d99d522c5b..5037c85809 100644 --- a/src/ImageSharp/Formats/Jpeg/JpegDecoderResizeMode.cs +++ b/src/ImageSharp/Formats/Jpeg/JpegDecoderResizeMode.cs @@ -1,6 +1,8 @@ // Copyright (c) Six Labors. // Licensed under the Six Labors Split License. +using SixLabors.ImageSharp.Processing; + namespace SixLabors.ImageSharp.Formats.Jpeg { /// @@ -15,7 +17,7 @@ namespace SixLabors.ImageSharp.Formats.Jpeg Combined, /// - /// IDCT-only to nearest block scale. + /// IDCT-only to nearest block scale. Similar in output to . /// IdctOnly,