From f6301d4b679cc6fa7319858a2a7a2238f45cd6a5 Mon Sep 17 00:00:00 2001 From: Ynse Hoornenborg Date: Wed, 8 Dec 2021 21:45:04 +0100 Subject: [PATCH] Refactor Pbm option enums --- src/ImageSharp/Formats/Pbm/BinaryDecoder.cs | 12 ++--- src/ImageSharp/Formats/Pbm/BinaryEncoder.cs | 8 +-- .../Formats/Pbm/IPbmEncoderOptions.cs | 4 +- .../Formats/Pbm/PbmComponentType.cs | 26 ++++++++++ src/ImageSharp/Formats/Pbm/PbmDecoderCore.cs | 34 +++++++++---- src/ImageSharp/Formats/Pbm/PbmEncoder.cs | 4 +- src/ImageSharp/Formats/Pbm/PbmEncoderCore.cs | 16 +++--- src/ImageSharp/Formats/Pbm/PbmMetadata.cs | 9 ++-- src/ImageSharp/Formats/Pbm/PlainDecoder.cs | 8 +-- src/ImageSharp/Formats/Pbm/PlainEncoder.cs | 8 +-- .../Formats/Pbm/PbmDecoderTests.cs | 50 ++++++++++--------- .../Formats/Pbm/PbmMetadataTests.cs | 20 ++++---- 12 files changed, 123 insertions(+), 76 deletions(-) create mode 100644 src/ImageSharp/Formats/Pbm/PbmComponentType.cs diff --git a/src/ImageSharp/Formats/Pbm/BinaryDecoder.cs b/src/ImageSharp/Formats/Pbm/BinaryDecoder.cs index 2a171456a..a469ced8a 100644 --- a/src/ImageSharp/Formats/Pbm/BinaryDecoder.cs +++ b/src/ImageSharp/Formats/Pbm/BinaryDecoder.cs @@ -14,8 +14,8 @@ namespace SixLabors.ImageSharp.Formats.Pbm /// internal class BinaryDecoder { - private static L8 white = new L8(255); - private static L8 black = new L8(0); + private static L8 white = new(255); + private static L8 black = new(0); /// /// Decode the specified pixels. @@ -25,16 +25,16 @@ namespace SixLabors.ImageSharp.Formats.Pbm /// The pixel array to encode into. /// The stream to read the data from. /// The ColorType to decode. - /// The maximum expected pixel value + /// Data type of the pixles components. /// /// Thrown if an invalid combination of setting is requested. /// - public static void Process(Configuration configuration, Buffer2D pixels, BufferedReadStream stream, PbmColorType colorType, int maxPixelValue) + public static void Process(Configuration configuration, Buffer2D pixels, BufferedReadStream stream, PbmColorType colorType, PbmComponentType componentType) where TPixel : unmanaged, IPixel { if (colorType == PbmColorType.Grayscale) { - if (maxPixelValue < 256) + if (componentType == PbmComponentType.Byte) { ProcessGrayscale(configuration, pixels, stream); } @@ -45,7 +45,7 @@ namespace SixLabors.ImageSharp.Formats.Pbm } else if (colorType == PbmColorType.Rgb) { - if (maxPixelValue < 256) + if (componentType == PbmComponentType.Byte) { ProcessRgb(configuration, pixels, stream); } diff --git a/src/ImageSharp/Formats/Pbm/BinaryEncoder.cs b/src/ImageSharp/Formats/Pbm/BinaryEncoder.cs index 626026726..8b32c18c2 100644 --- a/src/ImageSharp/Formats/Pbm/BinaryEncoder.cs +++ b/src/ImageSharp/Formats/Pbm/BinaryEncoder.cs @@ -22,16 +22,16 @@ namespace SixLabors.ImageSharp.Formats.Pbm /// The bytestream to write to. /// The input image. /// The ColorType to use. - /// The maximum expected pixel value + /// Data type of the pixles components. /// /// Thrown if an invalid combination of setting is requested. /// - public static void WritePixels(Configuration configuration, Stream stream, ImageFrame image, PbmColorType colorType, int maxPixelValue) + public static void WritePixels(Configuration configuration, Stream stream, ImageFrame image, PbmColorType colorType, PbmComponentType componentType) where TPixel : unmanaged, IPixel { if (colorType == PbmColorType.Grayscale) { - if (maxPixelValue < 256) + if (componentType == PbmComponentType.Byte) { WriteGrayscale(configuration, stream, image); } @@ -42,7 +42,7 @@ namespace SixLabors.ImageSharp.Formats.Pbm } else if (colorType == PbmColorType.Rgb) { - if (maxPixelValue < 256) + if (componentType == PbmComponentType.Byte) { WriteRgb(configuration, stream, image); } diff --git a/src/ImageSharp/Formats/Pbm/IPbmEncoderOptions.cs b/src/ImageSharp/Formats/Pbm/IPbmEncoderOptions.cs index c5c409ec8..988d9e560 100644 --- a/src/ImageSharp/Formats/Pbm/IPbmEncoderOptions.cs +++ b/src/ImageSharp/Formats/Pbm/IPbmEncoderOptions.cs @@ -19,8 +19,8 @@ namespace SixLabors.ImageSharp.Formats.Pbm PbmColorType? ColorType { get; } /// - /// Gets the maximum pixel value, per component. + /// Gets the Data Type of the pixel components. /// - int? MaxPixelValue { get; } + PbmComponentType? ComponentType { get; } } } diff --git a/src/ImageSharp/Formats/Pbm/PbmComponentType.cs b/src/ImageSharp/Formats/Pbm/PbmComponentType.cs new file mode 100644 index 000000000..26272021c --- /dev/null +++ b/src/ImageSharp/Formats/Pbm/PbmComponentType.cs @@ -0,0 +1,26 @@ +// Copyright (c) Six Labors. +// Licensed under the Apache License, Version 2.0. + +namespace SixLabors.ImageSharp.Formats.Pbm +{ + /// + /// The data type of the components of the pixels. + /// + public enum PbmComponentType : byte + { + /// + /// Single bit per pixel, exclusively for . + /// + Bit = 0, + + /// + /// 8 bits unsigned integer per component. + /// + Byte = 1, + + /// + /// 16 bits unsigned integer per component. + /// + Short = 2 + } +} diff --git a/src/ImageSharp/Formats/Pbm/PbmDecoderCore.cs b/src/ImageSharp/Formats/Pbm/PbmDecoderCore.cs index 8bac0bfd1..749fc0292 100644 --- a/src/ImageSharp/Formats/Pbm/PbmDecoderCore.cs +++ b/src/ImageSharp/Formats/Pbm/PbmDecoderCore.cs @@ -16,6 +16,8 @@ namespace SixLabors.ImageSharp.Formats.Pbm /// internal sealed class PbmDecoderCore : IImageDecoderInternals { + private int maxPixelValue; + /// /// Initializes a new instance of the class. /// @@ -36,9 +38,9 @@ namespace SixLabors.ImageSharp.Formats.Pbm public Size PixelSize { get; private set; } /// - /// Gets the maximum pixel value + /// Gets the component data type /// - public int MaxPixelValue { get; private set; } + public PbmComponentType ComponentType { get; private set; } /// /// Gets the Encoding of pixels @@ -53,7 +55,7 @@ namespace SixLabors.ImageSharp.Formats.Pbm /// Size IImageDecoderInternals.Dimensions => this.PixelSize; - private bool NeedsUpscaling => this.ColorType != PbmColorType.BlackAndWhite && this.MaxPixelValue is not 255 and not 65535; + private bool NeedsUpscaling => this.ColorType != PbmColorType.BlackAndWhite && this.maxPixelValue is not 255 and not 65535; /// public Image Decode(BufferedReadStream stream, CancellationToken cancellationToken) @@ -79,7 +81,8 @@ namespace SixLabors.ImageSharp.Formats.Pbm { this.ProcessHeader(stream); - int bitsPerPixel = this.MaxPixelValue > 255 ? 16 : 8; + // BlackAndWhite pixels are encoded into a byte. + int bitsPerPixel = this.ComponentType == PbmComponentType.Short ? 16 : 8; return new ImageInfo(new PixelTypeInfo(bitsPerPixel), this.PixelSize.Width, this.PixelSize.Height, this.Metadata); } @@ -143,12 +146,21 @@ namespace SixLabors.ImageSharp.Formats.Pbm stream.SkipWhitespaceAndComments(); if (this.ColorType != PbmColorType.BlackAndWhite) { - this.MaxPixelValue = stream.ReadDecimal(); + this.maxPixelValue = stream.ReadDecimal(); + if (this.maxPixelValue > 255) + { + this.ComponentType = PbmComponentType.Short; + } + else + { + this.ComponentType = PbmComponentType.Byte; + } + stream.SkipWhitespaceAndComments(); } else { - this.MaxPixelValue = 1; + this.ComponentType = PbmComponentType.Bit; } this.PixelSize = new Size(width, height); @@ -156,7 +168,7 @@ namespace SixLabors.ImageSharp.Formats.Pbm PbmMetadata meta = this.Metadata.GetPbmMetadata(); meta.Encoding = this.Encoding; meta.ColorType = this.ColorType; - meta.MaxPixelValue = this.MaxPixelValue; + meta.ComponentType = this.ComponentType; } private void ProcessPixels(BufferedReadStream stream, Buffer2D pixels) @@ -164,19 +176,19 @@ namespace SixLabors.ImageSharp.Formats.Pbm { if (this.Encoding == PbmEncoding.Binary) { - BinaryDecoder.Process(this.Configuration, pixels, stream, this.ColorType, this.MaxPixelValue); + BinaryDecoder.Process(this.Configuration, pixels, stream, this.ColorType, this.ComponentType); } else { - PlainDecoder.Process(this.Configuration, pixels, stream, this.ColorType, this.MaxPixelValue); + PlainDecoder.Process(this.Configuration, pixels, stream, this.ColorType, this.ComponentType); } } private void ProcessUpscaling(Image image) where TPixel : unmanaged, IPixel { - int maxAllocationValue = (this.MaxPixelValue > 255) ? 65535 : 255; - float factor = maxAllocationValue / this.MaxPixelValue; + int maxAllocationValue = this.ComponentType == PbmComponentType.Short ? 65535 : 255; + float factor = maxAllocationValue / this.maxPixelValue; image.Mutate(x => x.Brightness(factor)); } } diff --git a/src/ImageSharp/Formats/Pbm/PbmEncoder.cs b/src/ImageSharp/Formats/Pbm/PbmEncoder.cs index 7984dddac..75d666063 100644 --- a/src/ImageSharp/Formats/Pbm/PbmEncoder.cs +++ b/src/ImageSharp/Formats/Pbm/PbmEncoder.cs @@ -46,9 +46,9 @@ namespace SixLabors.ImageSharp.Formats.Pbm public PbmColorType? ColorType { get; set; } /// - /// Gets or sets the maximum pixel value, per component. + /// Gets or sets the data type of the pixels components. /// - public int? MaxPixelValue { get; set; } + public PbmComponentType? ComponentType { get; set; } /// public void Encode(Image image, Stream stream) diff --git a/src/ImageSharp/Formats/Pbm/PbmEncoderCore.cs b/src/ImageSharp/Formats/Pbm/PbmEncoderCore.cs index 158786e3c..9d1f39edf 100644 --- a/src/ImageSharp/Formats/Pbm/PbmEncoderCore.cs +++ b/src/ImageSharp/Formats/Pbm/PbmEncoderCore.cs @@ -42,7 +42,7 @@ namespace SixLabors.ImageSharp.Formats.Pbm /// /// Gets the maximum pixel value, per component. /// - private int maxPixelValue; + private PbmComponentType componentType; /// /// Initializes a new instance of the class. @@ -87,8 +87,11 @@ namespace SixLabors.ImageSharp.Formats.Pbm this.colorType = this.options.ColorType ?? metadata.ColorType; if (this.colorType != PbmColorType.BlackAndWhite) { - this.maxPixelValue = this.options.MaxPixelValue ?? metadata.MaxPixelValue; - this.maxPixelValue = Math.Max(this.maxPixelValue, PbmConstants.MaxLength); + this.componentType = this.options.ComponentType ?? metadata.ComponentType; + } + else + { + this.componentType = PbmComponentType.Bit; } } @@ -151,7 +154,8 @@ namespace SixLabors.ImageSharp.Formats.Pbm if (this.colorType != PbmColorType.BlackAndWhite) { - Utf8Formatter.TryFormat(this.maxPixelValue, buffer.Slice(written), out bytesWritten); + int maxPixelValue = this.componentType == PbmComponentType.Short ? 65535 : 255; + Utf8Formatter.TryFormat(maxPixelValue, buffer.Slice(written), out bytesWritten); written += bytesWritten; buffer[written++] = NewLine; } @@ -172,11 +176,11 @@ namespace SixLabors.ImageSharp.Formats.Pbm { if (this.encoding == PbmEncoding.Plain) { - PlainEncoder.WritePixels(this.configuration, stream, image, this.colorType, this.maxPixelValue); + PlainEncoder.WritePixels(this.configuration, stream, image, this.colorType, this.componentType); } else { - BinaryEncoder.WritePixels(this.configuration, stream, image, this.colorType, this.maxPixelValue); + BinaryEncoder.WritePixels(this.configuration, stream, image, this.colorType, this.componentType); } } } diff --git a/src/ImageSharp/Formats/Pbm/PbmMetadata.cs b/src/ImageSharp/Formats/Pbm/PbmMetadata.cs index 869b1b06d..a00ae46de 100644 --- a/src/ImageSharp/Formats/Pbm/PbmMetadata.cs +++ b/src/ImageSharp/Formats/Pbm/PbmMetadata.cs @@ -11,7 +11,8 @@ 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.ComponentType = this.ColorType == PbmColorType.BlackAndWhite ? PbmComponentType.Bit : PbmComponentType.Byte; /// /// Initializes a new instance of the class. @@ -21,7 +22,7 @@ namespace SixLabors.ImageSharp.Formats.Pbm { this.Encoding = other.Encoding; this.ColorType = other.ColorType; - this.MaxPixelValue = other.MaxPixelValue; + this.ComponentType = other.ComponentType; } /// @@ -35,9 +36,9 @@ namespace SixLabors.ImageSharp.Formats.Pbm public PbmColorType ColorType { get; set; } = PbmColorType.Grayscale; /// - /// Gets or sets the maximum pixel value. + /// Gets or sets the data type of the pixel components. /// - public int MaxPixelValue { get; set; } + public PbmComponentType ComponentType { get; set; } /// public IDeepCloneable DeepClone() => new PbmMetadata(this); diff --git a/src/ImageSharp/Formats/Pbm/PlainDecoder.cs b/src/ImageSharp/Formats/Pbm/PlainDecoder.cs index 4521f9b64..a9e90d788 100644 --- a/src/ImageSharp/Formats/Pbm/PlainDecoder.cs +++ b/src/ImageSharp/Formats/Pbm/PlainDecoder.cs @@ -25,13 +25,13 @@ namespace SixLabors.ImageSharp.Formats.Pbm /// The pixel array to encode into. /// The stream to read the data from. /// The ColorType to decode. - /// The maximum expected pixel value - public static void Process(Configuration configuration, Buffer2D pixels, BufferedReadStream stream, PbmColorType colorType, int maxPixelValue) + /// Data type of the pixles components. + public static void Process(Configuration configuration, Buffer2D pixels, BufferedReadStream stream, PbmColorType colorType, PbmComponentType componentType) where TPixel : unmanaged, IPixel { if (colorType == PbmColorType.Grayscale) { - if (maxPixelValue < 256) + if (componentType == PbmComponentType.Byte) { ProcessGrayscale(configuration, pixels, stream); } @@ -42,7 +42,7 @@ namespace SixLabors.ImageSharp.Formats.Pbm } else if (colorType == PbmColorType.Rgb) { - if (maxPixelValue < 256) + if (componentType == PbmComponentType.Byte) { ProcessRgb(configuration, pixels, stream); } diff --git a/src/ImageSharp/Formats/Pbm/PlainEncoder.cs b/src/ImageSharp/Formats/Pbm/PlainEncoder.cs index 8d534b7a9..75e6f56e9 100644 --- a/src/ImageSharp/Formats/Pbm/PlainEncoder.cs +++ b/src/ImageSharp/Formats/Pbm/PlainEncoder.cs @@ -36,13 +36,13 @@ namespace SixLabors.ImageSharp.Formats.Pbm /// The bytestream to write to. /// The input image. /// The ColorType to use. - /// The maximum expected pixel value - public static void WritePixels(Configuration configuration, Stream stream, ImageFrame image, PbmColorType colorType, int maxPixelValue) + /// Data type of the pixles components. + public static void WritePixels(Configuration configuration, Stream stream, ImageFrame image, PbmColorType colorType, PbmComponentType componentType) where TPixel : unmanaged, IPixel { if (colorType == PbmColorType.Grayscale) { - if (maxPixelValue < 256) + if (componentType == PbmComponentType.Byte) { WriteGrayscale(configuration, stream, image); } @@ -53,7 +53,7 @@ namespace SixLabors.ImageSharp.Formats.Pbm } else if (colorType == PbmColorType.Rgb) { - if (maxPixelValue < 256) + if (componentType == PbmComponentType.Byte) { WriteRgb(configuration, stream, image); } diff --git a/tests/ImageSharp.Tests/Formats/Pbm/PbmDecoderTests.cs b/tests/ImageSharp.Tests/Formats/Pbm/PbmDecoderTests.cs index 51bf61d23..97237bca5 100644 --- a/tests/ImageSharp.Tests/Formats/Pbm/PbmDecoderTests.cs +++ b/tests/ImageSharp.Tests/Formats/Pbm/PbmDecoderTests.cs @@ -14,16 +14,16 @@ namespace SixLabors.ImageSharp.Tests.Formats.Pbm public class PbmDecoderTests { [Theory] - [InlineData(BlackAndWhitePlain, PbmColorType.BlackAndWhite)] - [InlineData(BlackAndWhiteBinary, PbmColorType.BlackAndWhite)] - [InlineData(GrayscalePlain, PbmColorType.Grayscale)] - [InlineData(GrayscalePlainMagick, PbmColorType.Grayscale)] - [InlineData(GrayscaleBinary, PbmColorType.Grayscale)] - [InlineData(GrayscaleBinaryWide, PbmColorType.Grayscale)] - [InlineData(RgbPlain, PbmColorType.Rgb)] - [InlineData(RgbPlainMagick, PbmColorType.Rgb)] - [InlineData(RgbBinary, PbmColorType.Rgb)] - public void ImageLoadCanDecode(string imagePath, PbmColorType expectedColorType) + [InlineData(BlackAndWhitePlain, PbmColorType.BlackAndWhite, PbmComponentType.Bit)] + [InlineData(BlackAndWhiteBinary, PbmColorType.BlackAndWhite, PbmComponentType.Bit)] + [InlineData(GrayscalePlain, PbmColorType.Grayscale, PbmComponentType.Byte)] + [InlineData(GrayscalePlainMagick, PbmColorType.Grayscale, PbmComponentType.Byte)] + [InlineData(GrayscaleBinary, PbmColorType.Grayscale, PbmComponentType.Byte)] + [InlineData(GrayscaleBinaryWide, PbmColorType.Grayscale, PbmComponentType.Short)] + [InlineData(RgbPlain, PbmColorType.Rgb, PbmComponentType.Byte)] + [InlineData(RgbPlainMagick, PbmColorType.Rgb, PbmComponentType.Byte)] + [InlineData(RgbBinary, PbmColorType.Rgb, PbmComponentType.Byte)] + public void ImageLoadCanDecode(string imagePath, PbmColorType expectedColorType, PbmComponentType expectedComponentType) { // Arrange var testFile = TestFile.Create(imagePath); @@ -34,9 +34,10 @@ namespace SixLabors.ImageSharp.Tests.Formats.Pbm // Assert Assert.NotNull(image); - PbmMetadata bitmapMetadata = image.Metadata.GetPbmMetadata(); - Assert.NotNull(bitmapMetadata); - Assert.Equal(expectedColorType, bitmapMetadata.ColorType); + PbmMetadata metadata = image.Metadata.GetPbmMetadata(); + Assert.NotNull(metadata); + Assert.Equal(expectedColorType, metadata.ColorType); + Assert.Equal(expectedComponentType, metadata.ComponentType); } [Theory] @@ -77,21 +78,22 @@ namespace SixLabors.ImageSharp.Tests.Formats.Pbm } [Theory] - [WithFile(BlackAndWhitePlain, PixelTypes.L8, true)] - [WithFile(BlackAndWhiteBinary, PixelTypes.L8, true)] - [WithFile(GrayscalePlain, PixelTypes.L8, true)] - [WithFile(GrayscalePlainNormalized, PixelTypes.L8, true)] - [WithFile(GrayscaleBinary, PixelTypes.L8, true)] - [WithFile(GrayscaleBinaryWide, PixelTypes.L16, true)] - [WithFile(RgbPlain, PixelTypes.Rgb24, false)] - [WithFile(RgbPlainNormalized, PixelTypes.Rgb24, false)] - [WithFile(RgbBinary, PixelTypes.Rgb24, false)] - public void DecodeReferenceImage(TestImageProvider provider, bool isGrayscale) + [WithFile(BlackAndWhitePlain, PixelTypes.L8, "pbm")] + [WithFile(BlackAndWhiteBinary, PixelTypes.L8, "pbm")] + [WithFile(GrayscalePlain, PixelTypes.L8, "pgm")] + [WithFile(GrayscalePlainNormalized, PixelTypes.L8, "pgm")] + [WithFile(GrayscaleBinary, PixelTypes.L8, "pgm")] + [WithFile(GrayscaleBinaryWide, PixelTypes.L16, "pgm")] + [WithFile(RgbPlain, PixelTypes.Rgb24, "ppm")] + [WithFile(RgbPlainNormalized, PixelTypes.Rgb24, "ppm")] + [WithFile(RgbBinary, PixelTypes.Rgb24, "ppm")] + public void DecodeReferenceImage(TestImageProvider provider, string extension) where TPixel : unmanaged, IPixel { using Image image = provider.GetImage(); - image.DebugSave(provider); + image.DebugSave(provider, extension: extension); + bool isGrayscale = extension is "pgm" or "pbm"; image.CompareToReferenceOutput(provider, grayscale: isGrayscale); } } diff --git a/tests/ImageSharp.Tests/Formats/Pbm/PbmMetadataTests.cs b/tests/ImageSharp.Tests/Formats/Pbm/PbmMetadataTests.cs index 00b4f443d..7915d224a 100644 --- a/tests/ImageSharp.Tests/Formats/Pbm/PbmMetadataTests.cs +++ b/tests/ImageSharp.Tests/Formats/Pbm/PbmMetadataTests.cs @@ -20,8 +20,10 @@ namespace SixLabors.ImageSharp.Tests.Formats.Pbm var clone = (PbmMetadata)meta.DeepClone(); clone.ColorType = PbmColorType.Rgb; + clone.ComponentType = PbmComponentType.Short; Assert.False(meta.ColorType.Equals(clone.ColorType)); + Assert.False(meta.ComponentType.Equals(clone.ComponentType)); } [Theory] @@ -63,14 +65,14 @@ namespace SixLabors.ImageSharp.Tests.Formats.Pbm } [Theory] - [InlineData(BlackAndWhitePlain, 1)] - [InlineData(BlackAndWhiteBinary, 1)] - [InlineData(GrayscaleBinary, 255)] - [InlineData(GrayscaleBinaryWide, 65535)] - [InlineData(GrayscalePlain, 15)] - [InlineData(RgbBinary, 255)] - [InlineData(RgbPlain, 15)] - public void Identify_DetectsCorrectMaxPixelValue(string imagePath, int expectedMaxPixelValue) + [InlineData(BlackAndWhitePlain, PbmComponentType.Bit)] + [InlineData(BlackAndWhiteBinary, PbmComponentType.Bit)] + [InlineData(GrayscaleBinary, PbmComponentType.Byte)] + [InlineData(GrayscaleBinaryWide, PbmComponentType.Short)] + [InlineData(GrayscalePlain, PbmComponentType.Byte)] + [InlineData(RgbBinary, PbmComponentType.Byte)] + [InlineData(RgbPlain, PbmComponentType.Byte)] + public void Identify_DetectsCorrectComponentType(string imagePath, PbmComponentType expectedComponentType) { var testFile = TestFile.Create(imagePath); using var stream = new MemoryStream(testFile.Bytes, false); @@ -78,7 +80,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Pbm Assert.NotNull(imageInfo); PbmMetadata bitmapMetadata = imageInfo.Metadata.GetPbmMetadata(); Assert.NotNull(bitmapMetadata); - Assert.Equal(expectedMaxPixelValue, bitmapMetadata.MaxPixelValue); + Assert.Equal(expectedComponentType, bitmapMetadata.ComponentType); } } }