From c0a0c6ec952d124d104926b17ae51b2a90b5ed7d Mon Sep 17 00:00:00 2001 From: popow Date: Sat, 15 Dec 2018 17:20:48 +0100 Subject: [PATCH] added unit test for decoding OS2 bitmap with 16 bytes header --- .../Formats/Bmp/BmpDecoderTests.cs | 30 ++++++++++++++----- tests/Images/Input/Bmp/pal8os2v2-16.bmp | 3 ++ 2 files changed, 25 insertions(+), 8 deletions(-) create mode 100644 tests/Images/Input/Bmp/pal8os2v2-16.bmp diff --git a/tests/ImageSharp.Tests/Formats/Bmp/BmpDecoderTests.cs b/tests/ImageSharp.Tests/Formats/Bmp/BmpDecoderTests.cs index 5f2de9f51e..dc858f9500 100644 --- a/tests/ImageSharp.Tests/Formats/Bmp/BmpDecoderTests.cs +++ b/tests/ImageSharp.Tests/Formats/Bmp/BmpDecoderTests.cs @@ -88,19 +88,33 @@ namespace SixLabors.ImageSharp.Tests } } - [Theory] - [MemberData(nameof(RatioFiles))] - public void Identify_VerifyRatio(string imagePath, int xResolution, int yResolution, PixelResolutionUnit resolutionUnit) + [Fact] + public void DecodeOs22XShortHeader_VeryfyDimensions() { + string imagePath = @"Bmp/pal8os2v2-16.bmp"; var testFile = TestFile.Create(imagePath); using (var stream = new MemoryStream(testFile.Bytes, false)) { var decoder = new BmpDecoder(); - IImageInfo image = decoder.Identify(Configuration.Default, stream); - ImageMetaData meta = image.MetaData; - Assert.Equal(xResolution, meta.HorizontalResolution); - Assert.Equal(yResolution, meta.VerticalResolution); - Assert.Equal(resolutionUnit, meta.ResolutionUnits); + using (Image image = decoder.Decode(Configuration.Default, stream)) + { + Assert.Equal(127, image.Width); + Assert.Equal(64, image.Height); + } + } + } + + [Fact] + public void IdentifyOs22XShortHeader_VeryfyDimensions() + { + string imagePath = @"Bmp/pal8os2v2-16.bmp"; + var testFile = TestFile.Create(imagePath); + using (var stream = new MemoryStream(testFile.Bytes, false)) + { + IImageInfo imageInfo = Image.Identify(stream); + Assert.Equal(127, imageInfo.Width); + Assert.Equal(64, imageInfo.Height); + Assert.Equal(8, imageInfo.PixelType.BitsPerPixel); } } } diff --git a/tests/Images/Input/Bmp/pal8os2v2-16.bmp b/tests/Images/Input/Bmp/pal8os2v2-16.bmp new file mode 100644 index 0000000000..7cc99c56f7 --- /dev/null +++ b/tests/Images/Input/Bmp/pal8os2v2-16.bmp @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:8085c60533095d9a756009f84c050d01605fc029a980a13d1bdabe943c50de5a +size 9246