From f09641c06b1f77de8234883aeb3e6ca4bc84962b Mon Sep 17 00:00:00 2001 From: Brian Popow Date: Sun, 5 Dec 2021 17:46:10 +0100 Subject: [PATCH] Cleanup --- src/ImageSharp/Formats/Pbm/PbmDecoderCore.cs | 2 +- src/ImageSharp/Formats/Pbm/PbmEncoder.cs | 4 ++-- src/ImageSharp/Formats/Pbm/PbmFormat.cs | 2 +- src/ImageSharp/Formats/Pbm/PbmMetadata.cs | 5 +---- src/ImageSharp/Formats/Pbm/PlainDecoder.cs | 6 +++--- tests/ImageSharp.Tests/Formats/Pbm/PbmEncoderTests.cs | 7 +++---- 6 files changed, 11 insertions(+), 15 deletions(-) diff --git a/src/ImageSharp/Formats/Pbm/PbmDecoderCore.cs b/src/ImageSharp/Formats/Pbm/PbmDecoderCore.cs index b2be74ea14..8bac0bfd14 100644 --- a/src/ImageSharp/Formats/Pbm/PbmDecoderCore.cs +++ b/src/ImageSharp/Formats/Pbm/PbmDecoderCore.cs @@ -115,7 +115,7 @@ namespace SixLabors.ImageSharp.Formats.Pbm this.Encoding = PbmEncoding.Plain; break; case '4': - // Binary PBM format: 1 component per pixel, 8 picels per byte. + // Binary PBM format: 1 component per pixel, 8 pixels per byte. this.ColorType = PbmColorType.BlackAndWhite; this.Encoding = PbmEncoding.Binary; break; diff --git a/src/ImageSharp/Formats/Pbm/PbmEncoder.cs b/src/ImageSharp/Formats/Pbm/PbmEncoder.cs index fe0f7f9f16..7984dddacc 100644 --- a/src/ImageSharp/Formats/Pbm/PbmEncoder.cs +++ b/src/ImageSharp/Formats/Pbm/PbmEncoder.cs @@ -13,9 +13,9 @@ namespace SixLabors.ImageSharp.Formats.Pbm /// Image encoder for writing an image to a stream as PGM, PBM or PPM bitmap. These images are from /// the family of PNM images. /// - /// The PNM formats are a faily simple image format. They share a plain text header, consisting of: + /// The PNM formats are a fairly simple image format. They share a plain text header, consisting of: /// signature, width, height and max_pixel_value only. The pixels follow thereafter and can be in - /// plain text decimals seperated by spaces, or binary encoded. + /// plain text decimals separated by spaces, or binary encoded. /// /// /// PBM diff --git a/src/ImageSharp/Formats/Pbm/PbmFormat.cs b/src/ImageSharp/Formats/Pbm/PbmFormat.cs index 35aa9cf8c7..5ffb49652f 100644 --- a/src/ImageSharp/Formats/Pbm/PbmFormat.cs +++ b/src/ImageSharp/Formats/Pbm/PbmFormat.cs @@ -17,7 +17,7 @@ namespace SixLabors.ImageSharp.Formats.Pbm /// /// Gets the current instance. /// - public static PbmFormat Instance { get; } = new PbmFormat(); + public static PbmFormat Instance { get; } = new(); /// public string Name => "PBM"; diff --git a/src/ImageSharp/Formats/Pbm/PbmMetadata.cs b/src/ImageSharp/Formats/Pbm/PbmMetadata.cs index b29cd27c26..869b1b06de 100644 --- a/src/ImageSharp/Formats/Pbm/PbmMetadata.cs +++ b/src/ImageSharp/Formats/Pbm/PbmMetadata.cs @@ -11,10 +11,7 @@ namespace SixLabors.ImageSharp.Formats.Pbm /// /// Initializes a new instance of the class. /// - public PbmMetadata() - { - this.MaxPixelValue = this.ColorType == PbmColorType.BlackAndWhite ? 1 : 255; - } + public PbmMetadata() => this.MaxPixelValue = this.ColorType == PbmColorType.BlackAndWhite ? 1 : 255; /// /// Initializes a new instance of the class. diff --git a/src/ImageSharp/Formats/Pbm/PlainDecoder.cs b/src/ImageSharp/Formats/Pbm/PlainDecoder.cs index dc5350bdd9..4521f9b649 100644 --- a/src/ImageSharp/Formats/Pbm/PlainDecoder.cs +++ b/src/ImageSharp/Formats/Pbm/PlainDecoder.cs @@ -14,8 +14,8 @@ namespace SixLabors.ImageSharp.Formats.Pbm /// internal class PlainDecoder { - private static L8 white = new L8(255); - private static L8 black = new L8(0); + private static readonly L8 White = new(255); + private static readonly L8 Black = new(0); /// /// Decode the specified pixels. @@ -184,7 +184,7 @@ namespace SixLabors.ImageSharp.Formats.Pbm { int value = stream.ReadDecimal(); stream.SkipWhitespaceAndComments(); - rowSpan[x] = value == 0 ? white : black; + rowSpan[x] = value == 0 ? White : Black; } Span pixelSpan = pixels.GetRowSpan(y); diff --git a/tests/ImageSharp.Tests/Formats/Pbm/PbmEncoderTests.cs b/tests/ImageSharp.Tests/Formats/Pbm/PbmEncoderTests.cs index 44fab1617c..2ca49a39de 100644 --- a/tests/ImageSharp.Tests/Formats/Pbm/PbmEncoderTests.cs +++ b/tests/ImageSharp.Tests/Formats/Pbm/PbmEncoderTests.cs @@ -4,7 +4,6 @@ using System.IO; using SixLabors.ImageSharp.Formats.Pbm; using SixLabors.ImageSharp.PixelFormats; -using SixLabors.ImageSharp.Tests.Formats.Tga; using SixLabors.ImageSharp.Tests.TestUtilities.ImageComparison; using Xunit; using static SixLabors.ImageSharp.Tests.TestImages.Pbm; @@ -17,7 +16,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Pbm public class PbmEncoderTests { public static readonly TheoryData ColorType = - new TheoryData + new() { PbmColorType.BlackAndWhite, PbmColorType.Grayscale, @@ -25,7 +24,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Pbm }; public static readonly TheoryData PbmColorTypeFiles = - new TheoryData + new() { { BlackAndWhiteBinary, PbmColorType.BlackAndWhite }, { BlackAndWhitePlain, PbmColorType.BlackAndWhite }, @@ -67,7 +66,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Pbm Encoding = PbmEncoding.Plain }; - TestFile testFile = TestFile.Create(imagePath); + var testFile = TestFile.Create(imagePath); using (Image input = testFile.CreateRgba32Image()) { using (var memStream = new MemoryStream())