Skip to content

Commit b4ad3c3

Browse files
committed
Added test that shows the issue
1 parent b11f4db commit b4ad3c3

File tree

3 files changed

+29
-0
lines changed

3 files changed

+29
-0
lines changed

tests/ImageSharp.Tests/Formats/Bmp/BmpEncoderTests.cs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -370,6 +370,30 @@ public void Encode_WorksWithDiscontiguousBuffers<TPixel>(TestImageProvider<TPixe
370370
TestBmpEncoderCore(provider, bitsPerPixel);
371371
}
372372

373+
[Theory]
374+
[WithFile(BlackWhitePalletDataMatrix, PixelTypes.Rgb24, BmpBitsPerPixel.Pixel1)]
375+
public void Encode_Issue2467<TPixel>(TestImageProvider<TPixel> provider, BmpBitsPerPixel bitsPerPixel)
376+
where TPixel : unmanaged, IPixel<TPixel>
377+
{
378+
using Image<TPixel> image = provider.GetImage();
379+
380+
using var reencodedStream = new MemoryStream();
381+
var encoder = new BmpEncoder
382+
{
383+
BitsPerPixel = bitsPerPixel,
384+
SupportTransparency = false,
385+
Quantizer = KnownQuantizers.Octree
386+
};
387+
image.SaveAsBmp(reencodedStream, encoder);
388+
reencodedStream.Seek(0, SeekOrigin.Begin);
389+
390+
using Image<TPixel> reencodedImage = Image.Load<TPixel>(reencodedStream);
391+
392+
reencodedImage.DebugSave(provider);
393+
394+
reencodedImage.CompareToOriginal(provider);
395+
}
396+
373397
private static void TestBmpEncoderCore<TPixel>(
374398
TestImageProvider<TPixel> provider,
375399
BmpBitsPerPixel bitsPerPixel,

tests/ImageSharp.Tests/TestImages.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -407,6 +407,8 @@ public static class Bmp
407407
public const string Rgba321010102 = "Bmp/rgba32-1010102.bmp";
408408
public const string RgbaAlphaBitfields = "Bmp/rgba32abf.bmp";
409409

410+
public const string BlackWhitePalletDataMatrix = "Bmp/bit1datamatrix.bmp";
411+
410412
public static readonly string[] BitFields =
411413
{
412414
Rgb32bfdef,
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
version https://git-lfs.github.com/spec/v1
2+
oid sha256:3b2288e2a059b15c7855eb141c05e3ce69431e7c3ddef851033f7fd9ca39a2d4
3+
size 102

0 commit comments

Comments
 (0)