From d8b188ffc3a492ddd86fa46e3e0a2287b719c4b3 Mon Sep 17 00:00:00 2001 From: Jason Nelson Date: Tue, 27 Mar 2018 10:03:04 -0700 Subject: [PATCH] Make PixelTypeInfo a struct --- src/ImageSharp/Formats/PixelTypeInfo.cs | 4 ++-- tests/ImageSharp.Tests/Formats/Bmp/BmpDecoderTests.cs | 2 +- tests/ImageSharp.Tests/Formats/Gif/GifDecoderTests.cs | 2 +- tests/ImageSharp.Tests/Formats/Jpg/JpegDecoderTests.cs | 4 ++-- tests/ImageSharp.Tests/Formats/Png/PngDecoderTests.cs | 4 ++-- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/ImageSharp/Formats/PixelTypeInfo.cs b/src/ImageSharp/Formats/PixelTypeInfo.cs index ed21b91bfc..c83ce67889 100644 --- a/src/ImageSharp/Formats/PixelTypeInfo.cs +++ b/src/ImageSharp/Formats/PixelTypeInfo.cs @@ -6,10 +6,10 @@ namespace SixLabors.ImageSharp.Formats /// /// Contains information about the pixels that make up an images visual data. /// - public class PixelTypeInfo + public readonly struct PixelTypeInfo { /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the struct. /// /// Color depth, in number of bits per pixel. internal PixelTypeInfo(int bitsPerPixel) diff --git a/tests/ImageSharp.Tests/Formats/Bmp/BmpDecoderTests.cs b/tests/ImageSharp.Tests/Formats/Bmp/BmpDecoderTests.cs index d958278f6e..c15b0c2b08 100644 --- a/tests/ImageSharp.Tests/Formats/Bmp/BmpDecoderTests.cs +++ b/tests/ImageSharp.Tests/Formats/Bmp/BmpDecoderTests.cs @@ -57,7 +57,7 @@ namespace SixLabors.ImageSharp.Tests var testFile = TestFile.Create(imagePath); using (var stream = new MemoryStream(testFile.Bytes, false)) { - Assert.Equal(expectedPixelSize, Image.Identify(stream)?.PixelType?.BitsPerPixel); + Assert.Equal(expectedPixelSize, Image.Identify(stream)?.PixelType.BitsPerPixel); } } } diff --git a/tests/ImageSharp.Tests/Formats/Gif/GifDecoderTests.cs b/tests/ImageSharp.Tests/Formats/Gif/GifDecoderTests.cs index 9cdb9f8b1a..9cd29f460f 100644 --- a/tests/ImageSharp.Tests/Formats/Gif/GifDecoderTests.cs +++ b/tests/ImageSharp.Tests/Formats/Gif/GifDecoderTests.cs @@ -172,7 +172,7 @@ namespace SixLabors.ImageSharp.Tests TestFile testFile = TestFile.Create(imagePath); using (var stream = new MemoryStream(testFile.Bytes, false)) { - Assert.Equal(expectedPixelSize, Image.Identify(stream)?.PixelType?.BitsPerPixel); + Assert.Equal(expectedPixelSize, Image.Identify(stream)?.PixelType.BitsPerPixel); } } diff --git a/tests/ImageSharp.Tests/Formats/Jpg/JpegDecoderTests.cs b/tests/ImageSharp.Tests/Formats/Jpg/JpegDecoderTests.cs index 95ee40e807..c7ac71ed92 100644 --- a/tests/ImageSharp.Tests/Formats/Jpg/JpegDecoderTests.cs +++ b/tests/ImageSharp.Tests/Formats/Jpg/JpegDecoderTests.cs @@ -397,10 +397,10 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg [InlineData(TestImages.Jpeg.Baseline.Snake, 24)] public void DetectPixelSize(string imagePath, int expectedPixelSize) { - TestFile testFile = TestFile.Create(imagePath); + var testFile = TestFile.Create(imagePath); using (var stream = new MemoryStream(testFile.Bytes, false)) { - Assert.Equal(expectedPixelSize, Image.Identify(stream)?.PixelType?.BitsPerPixel); + Assert.Equal(expectedPixelSize, Image.Identify(stream)?.PixelType.BitsPerPixel); } } } diff --git a/tests/ImageSharp.Tests/Formats/Png/PngDecoderTests.cs b/tests/ImageSharp.Tests/Formats/Png/PngDecoderTests.cs index f70e4e3300..8e83f5ffb7 100644 --- a/tests/ImageSharp.Tests/Formats/Png/PngDecoderTests.cs +++ b/tests/ImageSharp.Tests/Formats/Png/PngDecoderTests.cs @@ -228,10 +228,10 @@ namespace SixLabors.ImageSharp.Tests [InlineData(TestImages.Png.Rgb48BppInterlaced, 48)] public void DetectPixelSize(string imagePath, int expectedPixelSize) { - TestFile testFile = TestFile.Create(imagePath); + var testFile = TestFile.Create(imagePath); using (var stream = new MemoryStream(testFile.Bytes, false)) { - Assert.Equal(expectedPixelSize, Image.Identify(stream)?.PixelType?.BitsPerPixel); + Assert.Equal(expectedPixelSize, Image.Identify(stream)?.PixelType.BitsPerPixel); } }