Browse Source

Fix failing bmp tests

pull/3096/head
Brian Popow 1 month ago
parent
commit
0c3ca3da24
  1. 2
      src/ImageSharp/Formats/Exr/ExrBox2i.cs
  2. 35
      tests/ImageSharp.Tests/Formats/Bmp/BmpDecoderTests.cs
  3. 3
      tests/Images/External/ReferenceOutput/BmpDecoderTests/BmpDecoder_CanDecode_RunLengthEncoded_8Bit_Inverted_Rgba32_RunLengthEncoded-inverted.png
  4. 3
      tests/Images/External/ReferenceOutput/BmpDecoderTests/BmpDecoder_CanDecode_RunLengthEncoded_8Bit_WithDeltaAndEOL_MagickRefDecoder_Rgba32_pal8rlecut.png

2
src/ImageSharp/Formats/Exr/ExrBox2i.cs

@ -6,7 +6,7 @@ using System.Diagnostics;
namespace SixLabors.ImageSharp.Formats.Exr;
[DebuggerDisplay("xMin: {XMin}, yMin: {YMin}, xMax: {XMax}, yMax: {YMax}")]
internal struct ExrBox2i
internal readonly struct ExrBox2i
{
public ExrBox2i(int xMin, int yMin, int xMax, int yMax)
{

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

@ -224,8 +224,8 @@ public class BmpDecoderTests
}
}
// An RLE-compressed image that uses “delta” codes, to skip over some pixels.
[Theory]
[WithFile(RLE8Cut, PixelTypes.Rgba32)]
[WithFile(RLE8Delta, PixelTypes.Rgba32)]
public void BmpDecoder_CanDecode_RunLengthEncoded_8Bit_WithDelta_MagickRefDecoder<TPixel>(TestImageProvider<TPixel> provider)
where TPixel : unmanaged, IPixel<TPixel>
@ -236,11 +236,21 @@ public class BmpDecoderTests
image.CompareToOriginal(provider, MagickReferenceDecoder.Png);
}
// An RLE-compressed image that uses “delta” codes, and early EOL & EOBMP markers, to skip over some pixels.
[Theory]
[WithFile(RLE8Cut, PixelTypes.Rgba32)]
public void BmpDecoder_CanDecode_RunLengthEncoded_8Bit_WithDeltaAndEOL_MagickRefDecoder<TPixel>(TestImageProvider<TPixel> provider)
where TPixel : unmanaged, IPixel<TPixel>
{
BmpDecoderOptions options = new() { RleSkippedPixelHandling = RleSkippedPixelHandling.FirstColorOfPalette };
using Image<TPixel> image = provider.GetImage(BmpDecoder.Instance, options);
image.DebugSave(provider);
image.CompareToReferenceOutput(provider);
}
[Theory]
[WithFile(RLE8, PixelTypes.Rgba32, false)]
[WithFile(RLE8Inverted, PixelTypes.Rgba32, false)]
[WithFile(RLE8, PixelTypes.Rgba32, true)]
[WithFile(RLE8Inverted, PixelTypes.Rgba32, true)]
public void BmpDecoder_CanDecode_RunLengthEncoded_8Bit<TPixel>(TestImageProvider<TPixel> provider, bool enforceDiscontiguousBuffers)
where TPixel : unmanaged, IPixel<TPixel>
{
@ -255,6 +265,25 @@ public class BmpDecoderTests
image.CompareToOriginal(provider, MagickReferenceDecoder.Png);
}
[Theory]
[WithFile(RLE8Inverted, PixelTypes.Rgba32, false)]
[WithFile(RLE8Inverted, PixelTypes.Rgba32, true)]
public void BmpDecoder_CanDecode_RunLengthEncoded_8Bit_Inverted<TPixel>(TestImageProvider<TPixel> provider, bool enforceDiscontiguousBuffers)
where TPixel : unmanaged, IPixel<TPixel>
{
if (enforceDiscontiguousBuffers)
{
provider.LimitAllocatorBufferCapacity().InBytesSqrt(400);
}
BmpDecoderOptions options = new() { RleSkippedPixelHandling = RleSkippedPixelHandling.FirstColorOfPalette };
using Image<TPixel> image = provider.GetImage(BmpDecoder.Instance, options);
image.DebugSave(provider);
// The Reference decoder does not support decoding compressed bmp which are inverted (with negative height).
image.CompareToReferenceOutput(provider);
}
[Theory]
[WithFile(RLE24, PixelTypes.Rgba32, false)]
[WithFile(RLE24Cut, PixelTypes.Rgba32, false)]

3
tests/Images/External/ReferenceOutput/BmpDecoderTests/BmpDecoder_CanDecode_RunLengthEncoded_8Bit_Inverted_Rgba32_RunLengthEncoded-inverted.png

@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:0e774cba4dda2fe9d3cdff141e7a8c1de7f3e9c8014093abf8697a34e6cc7144
size 5379

3
tests/Images/External/ReferenceOutput/BmpDecoderTests/BmpDecoder_CanDecode_RunLengthEncoded_8Bit_WithDeltaAndEOL_MagickRefDecoder_Rgba32_pal8rlecut.png

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