Browse Source

added unit test for decoding OS2 bitmap with 16 bytes header

af/merge-core
popow 8 years ago
parent
commit
c0a0c6ec95
  1. 30
      tests/ImageSharp.Tests/Formats/Bmp/BmpDecoderTests.cs
  2. 3
      tests/Images/Input/Bmp/pal8os2v2-16.bmp

30
tests/ImageSharp.Tests/Formats/Bmp/BmpDecoderTests.cs

@ -88,19 +88,33 @@ namespace SixLabors.ImageSharp.Tests
} }
} }
[Theory] [Fact]
[MemberData(nameof(RatioFiles))] public void DecodeOs22XShortHeader_VeryfyDimensions()
public void Identify_VerifyRatio(string imagePath, int xResolution, int yResolution, PixelResolutionUnit resolutionUnit)
{ {
string imagePath = @"Bmp/pal8os2v2-16.bmp";
var testFile = TestFile.Create(imagePath); var testFile = TestFile.Create(imagePath);
using (var stream = new MemoryStream(testFile.Bytes, false)) using (var stream = new MemoryStream(testFile.Bytes, false))
{ {
var decoder = new BmpDecoder(); var decoder = new BmpDecoder();
IImageInfo image = decoder.Identify(Configuration.Default, stream); using (Image<Rgba32> image = decoder.Decode<Rgba32>(Configuration.Default, stream))
ImageMetaData meta = image.MetaData; {
Assert.Equal(xResolution, meta.HorizontalResolution); Assert.Equal(127, image.Width);
Assert.Equal(yResolution, meta.VerticalResolution); Assert.Equal(64, image.Height);
Assert.Equal(resolutionUnit, meta.ResolutionUnits); }
}
}
[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);
} }
} }
} }

3
tests/Images/Input/Bmp/pal8os2v2-16.bmp

@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:8085c60533095d9a756009f84c050d01605fc029a980a13d1bdabe943c50de5a
size 9246
Loading…
Cancel
Save