Browse Source

Cleanup

pull/1851/head
Brian Popow 4 years ago
parent
commit
f09641c06b
  1. 2
      src/ImageSharp/Formats/Pbm/PbmDecoderCore.cs
  2. 4
      src/ImageSharp/Formats/Pbm/PbmEncoder.cs
  3. 2
      src/ImageSharp/Formats/Pbm/PbmFormat.cs
  4. 5
      src/ImageSharp/Formats/Pbm/PbmMetadata.cs
  5. 6
      src/ImageSharp/Formats/Pbm/PlainDecoder.cs
  6. 7
      tests/ImageSharp.Tests/Formats/Pbm/PbmEncoderTests.cs

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

4
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.
/// <para>
/// 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.
/// <list type="bullet">
/// <item>
/// <term>PBM</term>

2
src/ImageSharp/Formats/Pbm/PbmFormat.cs

@ -17,7 +17,7 @@ namespace SixLabors.ImageSharp.Formats.Pbm
/// <summary>
/// Gets the current instance.
/// </summary>
public static PbmFormat Instance { get; } = new PbmFormat();
public static PbmFormat Instance { get; } = new();
/// <inheritdoc/>
public string Name => "PBM";

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

@ -11,10 +11,7 @@ namespace SixLabors.ImageSharp.Formats.Pbm
/// <summary>
/// Initializes a new instance of the <see cref="PbmMetadata"/> class.
/// </summary>
public PbmMetadata()
{
this.MaxPixelValue = this.ColorType == PbmColorType.BlackAndWhite ? 1 : 255;
}
public PbmMetadata() => this.MaxPixelValue = this.ColorType == PbmColorType.BlackAndWhite ? 1 : 255;
/// <summary>
/// Initializes a new instance of the <see cref="PbmMetadata"/> class.

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

@ -14,8 +14,8 @@ namespace SixLabors.ImageSharp.Formats.Pbm
/// </summary>
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);
/// <summary>
/// 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<TPixel> pixelSpan = pixels.GetRowSpan(y);

7
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<PbmColorType> ColorType =
new TheoryData<PbmColorType>
new()
{
PbmColorType.BlackAndWhite,
PbmColorType.Grayscale,
@ -25,7 +24,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Pbm
};
public static readonly TheoryData<string, PbmColorType> PbmColorTypeFiles =
new TheoryData<string, PbmColorType>
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<Rgba32> input = testFile.CreateRgba32Image())
{
using (var memStream = new MemoryStream())

Loading…
Cancel
Save