From 472bc04f3d6c1de7c6f09319525c9ce657d7a495 Mon Sep 17 00:00:00 2001 From: LuisAlfredo92 <92luisalfredo@protonmail.com> Date: Tue, 4 Jul 2023 20:50:43 -0600 Subject: [PATCH] Fixing extensions, class access and StyleCop --- .../Formats/ImageExtensions.Save.cs | 153 +++++++++--------- .../Formats/ImageExtensions.Save.tt | 3 +- src/ImageSharp/Formats/Qoi/QoiEncoderCore.cs | 3 +- 3 files changed, 81 insertions(+), 78 deletions(-) diff --git a/src/ImageSharp/Formats/ImageExtensions.Save.cs b/src/ImageSharp/Formats/ImageExtensions.Save.cs index 6457b6f500..30f576e5c4 100644 --- a/src/ImageSharp/Formats/ImageExtensions.Save.cs +++ b/src/ImageSharp/Formats/ImageExtensions.Save.cs @@ -11,8 +11,8 @@ using SixLabors.ImageSharp.Formats.Pbm; using SixLabors.ImageSharp.Formats.Png; using SixLabors.ImageSharp.Formats.Qoi; using SixLabors.ImageSharp.Formats.Tga; -using SixLabors.ImageSharp.Formats.Webp; using SixLabors.ImageSharp.Formats.Tiff; +using SixLabors.ImageSharp.Formats.Webp; namespace SixLabors.ImageSharp; @@ -532,47 +532,47 @@ public static partial class ImageExtensions cancellationToken); /// - /// Saves the image to the given stream with the Tga format. + /// Saves the image to the given stream with the Qoi format. /// /// The image this method extends. /// The file path to save the image to. /// Thrown if the path is null. - public static void SaveAsTga(this Image source, string path) => SaveAsTga(source, path, default); + public static void SaveAsQoi(this Image source, string path) => SaveAsQoi(source, path, default); /// - /// Saves the image to the given stream with the Tga format. + /// Saves the image to the given stream with the Qoi format. /// /// The image this method extends. /// The file path to save the image to. /// Thrown if the path is null. /// A representing the asynchronous operation. - public static Task SaveAsTgaAsync(this Image source, string path) => SaveAsTgaAsync(source, path, default); + public static Task SaveAsQoiAsync(this Image source, string path) => SaveAsQoiAsync(source, path, default); /// - /// Saves the image to the given stream with the Tga format. + /// Saves the image to the given stream with the Qoi format. /// /// The image this method extends. /// The file path to save the image to. /// The token to monitor for cancellation requests. /// Thrown if the path is null. /// A representing the asynchronous operation. - public static Task SaveAsTgaAsync(this Image source, string path, CancellationToken cancellationToken) - => SaveAsTgaAsync(source, path, default, cancellationToken); + public static Task SaveAsQoiAsync(this Image source, string path, CancellationToken cancellationToken) + => SaveAsQoiAsync(source, path, default, cancellationToken); /// - /// Saves the image to the given stream with the Tga format. + /// Saves the image to the given stream with the Qoi format. /// /// The image this method extends. /// The file path to save the image to. /// The encoder to save the image with. /// Thrown if the path is null. - public static void SaveAsTga(this Image source, string path, TgaEncoder encoder) => + public static void SaveAsQoi(this Image source, string path, QoiEncoder encoder) => source.Save( path, - encoder ?? source.GetConfiguration().ImageFormatsManager.GetEncoder(TgaFormat.Instance)); + encoder ?? source.GetConfiguration().ImageFormatsManager.GetEncoder(QoiFormat.Instance)); /// - /// Saves the image to the given stream with the Tga format. + /// Saves the image to the given stream with the Qoi format. /// /// The image this method extends. /// The file path to save the image to. @@ -580,46 +580,46 @@ public static partial class ImageExtensions /// The token to monitor for cancellation requests. /// Thrown if the path is null. /// A representing the asynchronous operation. - public static Task SaveAsTgaAsync(this Image source, string path, TgaEncoder encoder, CancellationToken cancellationToken = default) + public static Task SaveAsQoiAsync(this Image source, string path, QoiEncoder encoder, CancellationToken cancellationToken = default) => source.SaveAsync( path, - encoder ?? source.GetConfiguration().ImageFormatsManager.GetEncoder(TgaFormat.Instance), + encoder ?? source.GetConfiguration().ImageFormatsManager.GetEncoder(QoiFormat.Instance), cancellationToken); /// - /// Saves the image to the given stream with the Tga format. + /// Saves the image to the given stream with the Qoi format. /// /// The image this method extends. /// The stream to save the image to. /// Thrown if the stream is null. - public static void SaveAsTga(this Image source, Stream stream) - => SaveAsTga(source, stream, default); + public static void SaveAsQoi(this Image source, Stream stream) + => SaveAsQoi(source, stream, default); /// - /// Saves the image to the given stream with the Tga format. + /// Saves the image to the given stream with the Qoi format. /// /// The image this method extends. /// The stream to save the image to. /// The token to monitor for cancellation requests. /// Thrown if the stream is null. /// A representing the asynchronous operation. - public static Task SaveAsTgaAsync(this Image source, Stream stream, CancellationToken cancellationToken = default) - => SaveAsTgaAsync(source, stream, default, cancellationToken); + public static Task SaveAsQoiAsync(this Image source, Stream stream, CancellationToken cancellationToken = default) + => SaveAsQoiAsync(source, stream, default, cancellationToken); /// - /// Saves the image to the given stream with the Tga format. + /// Saves the image to the given stream with the Qoi format. /// /// The image this method extends. /// The stream to save the image to. /// The encoder to save the image with. /// Thrown if the stream is null. - public static void SaveAsTga(this Image source, Stream stream, TgaEncoder encoder) + public static void SaveAsQoi(this Image source, Stream stream, QoiEncoder encoder) => source.Save( stream, - encoder ?? source.GetConfiguration().ImageFormatsManager.GetEncoder(TgaFormat.Instance)); + encoder ?? source.GetConfiguration().ImageFormatsManager.GetEncoder(QoiFormat.Instance)); /// - /// Saves the image to the given stream with the Tga format. + /// Saves the image to the given stream with the Qoi format. /// /// The image this method extends. /// The stream to save the image to. @@ -627,54 +627,54 @@ public static partial class ImageExtensions /// The token to monitor for cancellation requests. /// Thrown if the stream is null. /// A representing the asynchronous operation. - public static Task SaveAsTgaAsync(this Image source, Stream stream, TgaEncoder encoder, CancellationToken cancellationToken = default) + public static Task SaveAsQoiAsync(this Image source, Stream stream, QoiEncoder encoder, CancellationToken cancellationToken = default) => source.SaveAsync( stream, - encoder ?? source.GetConfiguration().ImageFormatsManager.GetEncoder(TgaFormat.Instance), + encoder ?? source.GetConfiguration().ImageFormatsManager.GetEncoder(QoiFormat.Instance), cancellationToken); /// - /// Saves the image to the given stream with the Webp format. + /// Saves the image to the given stream with the Tga format. /// /// The image this method extends. /// The file path to save the image to. /// Thrown if the path is null. - public static void SaveAsWebp(this Image source, string path) => SaveAsWebp(source, path, default); + public static void SaveAsTga(this Image source, string path) => SaveAsTga(source, path, default); /// - /// Saves the image to the given stream with the Webp format. + /// Saves the image to the given stream with the Tga format. /// /// The image this method extends. /// The file path to save the image to. /// Thrown if the path is null. /// A representing the asynchronous operation. - public static Task SaveAsWebpAsync(this Image source, string path) => SaveAsWebpAsync(source, path, default); + public static Task SaveAsTgaAsync(this Image source, string path) => SaveAsTgaAsync(source, path, default); /// - /// Saves the image to the given stream with the Webp format. + /// Saves the image to the given stream with the Tga format. /// /// The image this method extends. /// The file path to save the image to. /// The token to monitor for cancellation requests. /// Thrown if the path is null. /// A representing the asynchronous operation. - public static Task SaveAsWebpAsync(this Image source, string path, CancellationToken cancellationToken) - => SaveAsWebpAsync(source, path, default, cancellationToken); + public static Task SaveAsTgaAsync(this Image source, string path, CancellationToken cancellationToken) + => SaveAsTgaAsync(source, path, default, cancellationToken); /// - /// Saves the image to the given stream with the Webp format. + /// Saves the image to the given stream with the Tga format. /// /// The image this method extends. /// The file path to save the image to. /// The encoder to save the image with. /// Thrown if the path is null. - public static void SaveAsWebp(this Image source, string path, WebpEncoder encoder) => + public static void SaveAsTga(this Image source, string path, TgaEncoder encoder) => source.Save( path, - encoder ?? source.GetConfiguration().ImageFormatsManager.GetEncoder(WebpFormat.Instance)); + encoder ?? source.GetConfiguration().ImageFormatsManager.GetEncoder(TgaFormat.Instance)); /// - /// Saves the image to the given stream with the Webp format. + /// Saves the image to the given stream with the Tga format. /// /// The image this method extends. /// The file path to save the image to. @@ -682,46 +682,46 @@ public static partial class ImageExtensions /// The token to monitor for cancellation requests. /// Thrown if the path is null. /// A representing the asynchronous operation. - public static Task SaveAsWebpAsync(this Image source, string path, WebpEncoder encoder, CancellationToken cancellationToken = default) + public static Task SaveAsTgaAsync(this Image source, string path, TgaEncoder encoder, CancellationToken cancellationToken = default) => source.SaveAsync( path, - encoder ?? source.GetConfiguration().ImageFormatsManager.GetEncoder(WebpFormat.Instance), + encoder ?? source.GetConfiguration().ImageFormatsManager.GetEncoder(TgaFormat.Instance), cancellationToken); /// - /// Saves the image to the given stream with the Webp format. + /// Saves the image to the given stream with the Tga format. /// /// The image this method extends. /// The stream to save the image to. /// Thrown if the stream is null. - public static void SaveAsWebp(this Image source, Stream stream) - => SaveAsWebp(source, stream, default); + public static void SaveAsTga(this Image source, Stream stream) + => SaveAsTga(source, stream, default); /// - /// Saves the image to the given stream with the Webp format. + /// Saves the image to the given stream with the Tga format. /// /// The image this method extends. /// The stream to save the image to. /// The token to monitor for cancellation requests. /// Thrown if the stream is null. /// A representing the asynchronous operation. - public static Task SaveAsWebpAsync(this Image source, Stream stream, CancellationToken cancellationToken = default) - => SaveAsWebpAsync(source, stream, default, cancellationToken); + public static Task SaveAsTgaAsync(this Image source, Stream stream, CancellationToken cancellationToken = default) + => SaveAsTgaAsync(source, stream, default, cancellationToken); /// - /// Saves the image to the given stream with the Webp format. + /// Saves the image to the given stream with the Tga format. /// /// The image this method extends. /// The stream to save the image to. /// The encoder to save the image with. /// Thrown if the stream is null. - public static void SaveAsWebp(this Image source, Stream stream, WebpEncoder encoder) + public static void SaveAsTga(this Image source, Stream stream, TgaEncoder encoder) => source.Save( stream, - encoder ?? source.GetConfiguration().ImageFormatsManager.GetEncoder(WebpFormat.Instance)); + encoder ?? source.GetConfiguration().ImageFormatsManager.GetEncoder(TgaFormat.Instance)); /// - /// Saves the image to the given stream with the Webp format. + /// Saves the image to the given stream with the Tga format. /// /// The image this method extends. /// The stream to save the image to. @@ -729,10 +729,10 @@ public static partial class ImageExtensions /// The token to monitor for cancellation requests. /// Thrown if the stream is null. /// A representing the asynchronous operation. - public static Task SaveAsWebpAsync(this Image source, Stream stream, WebpEncoder encoder, CancellationToken cancellationToken = default) + public static Task SaveAsTgaAsync(this Image source, Stream stream, TgaEncoder encoder, CancellationToken cancellationToken = default) => source.SaveAsync( stream, - encoder ?? source.GetConfiguration().ImageFormatsManager.GetEncoder(WebpFormat.Instance), + encoder ?? source.GetConfiguration().ImageFormatsManager.GetEncoder(TgaFormat.Instance), cancellationToken); /// @@ -838,47 +838,47 @@ public static partial class ImageExtensions cancellationToken); /// - /// Saves the image to the given stream with the Qoi format. + /// Saves the image to the given stream with the Webp format. /// /// The image this method extends. /// The file path to save the image to. /// Thrown if the path is null. - public static void SaveAsQoi(this Image source, string path) => SaveAsQoi(source, path, default); + public static void SaveAsWebp(this Image source, string path) => SaveAsWebp(source, path, default); /// - /// Saves the image to the given stream with the Qoi format. + /// Saves the image to the given stream with the Webp format. /// /// The image this method extends. /// The file path to save the image to. /// Thrown if the path is null. /// A representing the asynchronous operation. - public static Task SaveAsQoiAsync(this Image source, string path) => SaveAsQoiAsync(source, path, default); + public static Task SaveAsWebpAsync(this Image source, string path) => SaveAsWebpAsync(source, path, default); /// - /// Saves the image to the given stream with the Qoi format. + /// Saves the image to the given stream with the Webp format. /// /// The image this method extends. /// The file path to save the image to. /// The token to monitor for cancellation requests. /// Thrown if the path is null. /// A representing the asynchronous operation. - public static Task SaveAsQoiAsync(this Image source, string path, CancellationToken cancellationToken) - => SaveAsQoiAsync(source, path, default, cancellationToken); + public static Task SaveAsWebpAsync(this Image source, string path, CancellationToken cancellationToken) + => SaveAsWebpAsync(source, path, default, cancellationToken); /// - /// Saves the image to the given stream with the Qoi format. + /// Saves the image to the given stream with the Webp format. /// /// The image this method extends. /// The file path to save the image to. /// The encoder to save the image with. /// Thrown if the path is null. - public static void SaveAsQoi(this Image source, string path, QoiEncoder encoder) => + public static void SaveAsWebp(this Image source, string path, WebpEncoder encoder) => source.Save( path, - encoder ?? source.GetConfiguration().ImageFormatsManager.GetEncoder(QoiFormat.Instance)); + encoder ?? source.GetConfiguration().ImageFormatsManager.GetEncoder(WebpFormat.Instance)); /// - /// Saves the image to the given stream with the Qoi format. + /// Saves the image to the given stream with the Webp format. /// /// The image this method extends. /// The file path to save the image to. @@ -886,46 +886,46 @@ public static partial class ImageExtensions /// The token to monitor for cancellation requests. /// Thrown if the path is null. /// A representing the asynchronous operation. - public static Task SaveAsQoiAsync(this Image source, string path, QoiEncoder encoder, CancellationToken cancellationToken = default) + public static Task SaveAsWebpAsync(this Image source, string path, WebpEncoder encoder, CancellationToken cancellationToken = default) => source.SaveAsync( path, - encoder ?? source.GetConfiguration().ImageFormatsManager.GetEncoder(QoiFormat.Instance), + encoder ?? source.GetConfiguration().ImageFormatsManager.GetEncoder(WebpFormat.Instance), cancellationToken); /// - /// Saves the image to the given stream with the Qoi format. + /// Saves the image to the given stream with the Webp format. /// /// The image this method extends. /// The stream to save the image to. /// Thrown if the stream is null. - public static void SaveAsQoi(this Image source, Stream stream) - => SaveAsQoi(source, stream, default); + public static void SaveAsWebp(this Image source, Stream stream) + => SaveAsWebp(source, stream, default); /// - /// Saves the image to the given stream with the Qoi format. + /// Saves the image to the given stream with the Webp format. /// /// The image this method extends. /// The stream to save the image to. /// The token to monitor for cancellation requests. /// Thrown if the stream is null. /// A representing the asynchronous operation. - public static Task SaveAsQoiAsync(this Image source, Stream stream, CancellationToken cancellationToken = default) - => SaveAsQoiAsync(source, stream, default, cancellationToken); + public static Task SaveAsWebpAsync(this Image source, Stream stream, CancellationToken cancellationToken = default) + => SaveAsWebpAsync(source, stream, default, cancellationToken); /// - /// Saves the image to the given stream with the Qoi format. + /// Saves the image to the given stream with the Webp format. /// /// The image this method extends. /// The stream to save the image to. /// The encoder to save the image with. /// Thrown if the stream is null. - public static void SaveAsQoi(this Image source, Stream stream, QoiEncoder encoder) + public static void SaveAsWebp(this Image source, Stream stream, WebpEncoder encoder) => source.Save( stream, - encoder ?? source.GetConfiguration().ImageFormatsManager.GetEncoder(QoiFormat.Instance)); + encoder ?? source.GetConfiguration().ImageFormatsManager.GetEncoder(WebpFormat.Instance)); /// - /// Saves the image to the given stream with the Qoi format. + /// Saves the image to the given stream with the Webp format. /// /// The image this method extends. /// The stream to save the image to. @@ -933,9 +933,10 @@ public static partial class ImageExtensions /// The token to monitor for cancellation requests. /// Thrown if the stream is null. /// A representing the asynchronous operation. - public static Task SaveAsQoiAsync(this Image source, Stream stream, QoiEncoder encoder, CancellationToken cancellationToken = default) + public static Task SaveAsWebpAsync(this Image source, Stream stream, WebpEncoder encoder, CancellationToken cancellationToken = default) => source.SaveAsync( stream, - encoder ?? source.GetConfiguration().ImageFormatsManager.GetEncoder(QoiFormat.Instance), + encoder ?? source.GetConfiguration().ImageFormatsManager.GetEncoder(WebpFormat.Instance), cancellationToken); + } diff --git a/src/ImageSharp/Formats/ImageExtensions.Save.tt b/src/ImageSharp/Formats/ImageExtensions.Save.tt index 64f3bde9cc..538f62d041 100644 --- a/src/ImageSharp/Formats/ImageExtensions.Save.tt +++ b/src/ImageSharp/Formats/ImageExtensions.Save.tt @@ -14,9 +14,10 @@ using SixLabors.ImageSharp.Advanced; "Jpeg", "Pbm", "Png", + "Qoi", "Tga", - "Webp", "Tiff", + "Webp", }; foreach (string fmt in formats) diff --git a/src/ImageSharp/Formats/Qoi/QoiEncoderCore.cs b/src/ImageSharp/Formats/Qoi/QoiEncoderCore.cs index 251b7436ef..40b246faf2 100644 --- a/src/ImageSharp/Formats/Qoi/QoiEncoderCore.cs +++ b/src/ImageSharp/Formats/Qoi/QoiEncoderCore.cs @@ -12,7 +12,7 @@ namespace SixLabors.ImageSharp.Formats.Qoi; /// /// Image encoder for writing an image to a stream as a QOi image /// -public class QoiEncoderCore : IImageEncoderInternals +internal class QoiEncoderCore : IImageEncoderInternals { /// /// The encoder with options @@ -34,6 +34,7 @@ public class QoiEncoderCore : IImageEncoderInternals /// /// The encoder with options. /// The to use for buffer allocations. + /// The configuration of the Encoder. public QoiEncoderCore(QoiEncoder encoder, MemoryAllocator memoryAllocator, Configuration configuration) { this.encoder = encoder;