Browse Source

Cleanup

pull/1851/head
Brian Popow 5 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; this.Encoding = PbmEncoding.Plain;
break; break;
case '4': 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.ColorType = PbmColorType.BlackAndWhite;
this.Encoding = PbmEncoding.Binary; this.Encoding = PbmEncoding.Binary;
break; 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 /// 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 family of PNM images.
/// <para> /// <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 /// 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"> /// <list type="bullet">
/// <item> /// <item>
/// <term>PBM</term> /// <term>PBM</term>

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

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

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

@ -11,10 +11,7 @@ namespace SixLabors.ImageSharp.Formats.Pbm
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="PbmMetadata"/> class. /// Initializes a new instance of the <see cref="PbmMetadata"/> class.
/// </summary> /// </summary>
public PbmMetadata() public PbmMetadata() => this.MaxPixelValue = this.ColorType == PbmColorType.BlackAndWhite ? 1 : 255;
{
this.MaxPixelValue = this.ColorType == PbmColorType.BlackAndWhite ? 1 : 255;
}
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="PbmMetadata"/> class. /// 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> /// </summary>
internal class PlainDecoder internal class PlainDecoder
{ {
private static L8 white = new L8(255); private static readonly L8 White = new(255);
private static L8 black = new L8(0); private static readonly L8 Black = new(0);
/// <summary> /// <summary>
/// Decode the specified pixels. /// Decode the specified pixels.
@ -184,7 +184,7 @@ namespace SixLabors.ImageSharp.Formats.Pbm
{ {
int value = stream.ReadDecimal(); int value = stream.ReadDecimal();
stream.SkipWhitespaceAndComments(); stream.SkipWhitespaceAndComments();
rowSpan[x] = value == 0 ? white : black; rowSpan[x] = value == 0 ? White : Black;
} }
Span<TPixel> pixelSpan = pixels.GetRowSpan(y); Span<TPixel> pixelSpan = pixels.GetRowSpan(y);

7
tests/ImageSharp.Tests/Formats/Pbm/PbmEncoderTests.cs

@ -4,7 +4,6 @@
using System.IO; using System.IO;
using SixLabors.ImageSharp.Formats.Pbm; using SixLabors.ImageSharp.Formats.Pbm;
using SixLabors.ImageSharp.PixelFormats; using SixLabors.ImageSharp.PixelFormats;
using SixLabors.ImageSharp.Tests.Formats.Tga;
using SixLabors.ImageSharp.Tests.TestUtilities.ImageComparison; using SixLabors.ImageSharp.Tests.TestUtilities.ImageComparison;
using Xunit; using Xunit;
using static SixLabors.ImageSharp.Tests.TestImages.Pbm; using static SixLabors.ImageSharp.Tests.TestImages.Pbm;
@ -17,7 +16,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Pbm
public class PbmEncoderTests public class PbmEncoderTests
{ {
public static readonly TheoryData<PbmColorType> ColorType = public static readonly TheoryData<PbmColorType> ColorType =
new TheoryData<PbmColorType> new()
{ {
PbmColorType.BlackAndWhite, PbmColorType.BlackAndWhite,
PbmColorType.Grayscale, PbmColorType.Grayscale,
@ -25,7 +24,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Pbm
}; };
public static readonly TheoryData<string, PbmColorType> PbmColorTypeFiles = public static readonly TheoryData<string, PbmColorType> PbmColorTypeFiles =
new TheoryData<string, PbmColorType> new()
{ {
{ BlackAndWhiteBinary, PbmColorType.BlackAndWhite }, { BlackAndWhiteBinary, PbmColorType.BlackAndWhite },
{ BlackAndWhitePlain, PbmColorType.BlackAndWhite }, { BlackAndWhitePlain, PbmColorType.BlackAndWhite },
@ -67,7 +66,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Pbm
Encoding = PbmEncoding.Plain Encoding = PbmEncoding.Plain
}; };
TestFile testFile = TestFile.Create(imagePath); var testFile = TestFile.Create(imagePath);
using (Image<Rgba32> input = testFile.CreateRgba32Image()) using (Image<Rgba32> input = testFile.CreateRgba32Image())
{ {
using (var memStream = new MemoryStream()) using (var memStream = new MemoryStream())

Loading…
Cancel
Save