From 7356edd4ea71468d49e4ee933659c95904f805fa Mon Sep 17 00:00:00 2001 From: Brian Popow Date: Wed, 31 Aug 2022 15:38:13 +0200 Subject: [PATCH 1/8] Add option to write 2 bit bitmap's --- src/ImageSharp/Formats/Bmp/BmpBitsPerPixel.cs | 5 + src/ImageSharp/Formats/Bmp/BmpDecoderCore.cs | 2 +- src/ImageSharp/Formats/Bmp/BmpEncoderCore.cs | 125 +++++++++++++----- .../Formats/Bmp/BmpEncoderTests.cs | 52 +++++++- tests/ImageSharp.Tests/TestImages.cs | 2 + .../ImageComparison/ImageComparer.cs | 11 +- tests/Images/Input/Bmp/pal2.bmp | 3 + tests/Images/Input/Bmp/pal2color.bmp | 3 + 8 files changed, 158 insertions(+), 45 deletions(-) create mode 100644 tests/Images/Input/Bmp/pal2.bmp create mode 100644 tests/Images/Input/Bmp/pal2color.bmp diff --git a/src/ImageSharp/Formats/Bmp/BmpBitsPerPixel.cs b/src/ImageSharp/Formats/Bmp/BmpBitsPerPixel.cs index 1b73d8b18..f66883c20 100644 --- a/src/ImageSharp/Formats/Bmp/BmpBitsPerPixel.cs +++ b/src/ImageSharp/Formats/Bmp/BmpBitsPerPixel.cs @@ -13,6 +13,11 @@ namespace SixLabors.ImageSharp.Formats.Bmp /// Pixel1 = 1, + /// + /// 2 bits per pixel. + /// + Pixel2 = 2, + /// /// 4 bits per pixel. /// diff --git a/src/ImageSharp/Formats/Bmp/BmpDecoderCore.cs b/src/ImageSharp/Formats/Bmp/BmpDecoderCore.cs index 3a96c4022..517a3b8cf 100644 --- a/src/ImageSharp/Formats/Bmp/BmpDecoderCore.cs +++ b/src/ImageSharp/Formats/Bmp/BmpDecoderCore.cs @@ -1387,7 +1387,7 @@ namespace SixLabors.ImageSharp.Formats.Bmp int colorMapSizeBytes = -1; if (this.infoHeader.ClrUsed == 0) { - if (this.infoHeader.BitsPerPixel is 1 or 4 or 8) + if (this.infoHeader.BitsPerPixel is 1 or 2 or 4 or 8) { switch (this.fileMarkerType) { diff --git a/src/ImageSharp/Formats/Bmp/BmpEncoderCore.cs b/src/ImageSharp/Formats/Bmp/BmpEncoderCore.cs index f71275b7c..257159bd2 100644 --- a/src/ImageSharp/Formats/Bmp/BmpEncoderCore.cs +++ b/src/ImageSharp/Formats/Bmp/BmpEncoderCore.cs @@ -57,6 +57,11 @@ namespace SixLabors.ImageSharp.Formats.Bmp /// private const int ColorPaletteSize4Bit = 64; + /// + /// The color palette for an 2 bit image will have 4 entry's with 4 bytes for each entry. + /// + private const int ColorPaletteSize2Bit = 16; + /// /// The color palette for an 1 bit image will have 2 entry's with 4 bytes for each entry. /// @@ -125,19 +130,14 @@ namespace SixLabors.ImageSharp.Formats.Bmp int bytesPerLine = 4 * (((image.Width * bpp) + 31) / 32); this.padding = bytesPerLine - (int)(image.Width * (bpp / 8F)); - int colorPaletteSize = 0; - if (this.bitsPerPixel == BmpBitsPerPixel.Pixel8) - { - colorPaletteSize = ColorPaletteSize8Bit; - } - else if (this.bitsPerPixel == BmpBitsPerPixel.Pixel4) - { - colorPaletteSize = ColorPaletteSize4Bit; - } - else if (this.bitsPerPixel == BmpBitsPerPixel.Pixel1) + int colorPaletteSize = this.bitsPerPixel switch { - colorPaletteSize = ColorPaletteSize1Bit; - } + BmpBitsPerPixel.Pixel8 => ColorPaletteSize8Bit, + BmpBitsPerPixel.Pixel4 => ColorPaletteSize4Bit, + BmpBitsPerPixel.Pixel2 => ColorPaletteSize2Bit, + BmpBitsPerPixel.Pixel1 => ColorPaletteSize1Bit, + _ => 0 + }; byte[] iccProfileData = null; int iccProfileSize = 0; @@ -322,27 +322,31 @@ namespace SixLabors.ImageSharp.Formats.Bmp switch (this.bitsPerPixel) { case BmpBitsPerPixel.Pixel32: - this.Write32Bit(stream, pixels); + this.Write32BitPixelData(stream, pixels); break; case BmpBitsPerPixel.Pixel24: - this.Write24Bit(stream, pixels); + this.Write24BitPixelData(stream, pixels); break; case BmpBitsPerPixel.Pixel16: - this.Write16Bit(stream, pixels); + this.Write16BitPixelData(stream, pixels); break; case BmpBitsPerPixel.Pixel8: - this.Write8Bit(stream, image); + this.Write8BitPixelData(stream, image); break; case BmpBitsPerPixel.Pixel4: - this.Write4BitColor(stream, image); + this.Write4BitPixelData(stream, image); + break; + + case BmpBitsPerPixel.Pixel2: + this.Write2BitPixelData(stream, image); break; case BmpBitsPerPixel.Pixel1: - this.Write1BitColor(stream, image); + this.Write1BitPixelData(stream, image); break; } } @@ -351,12 +355,12 @@ namespace SixLabors.ImageSharp.Formats.Bmp => this.memoryAllocator.AllocatePaddedPixelRowBuffer(width, bytesPerPixel, this.padding); /// - /// Writes the 32bit color palette to the stream. + /// Writes 32-bit data with a color palette to the stream. /// /// The pixel format. /// The to write to. /// The containing pixel data. - private void Write32Bit(Stream stream, Buffer2D pixels) + private void Write32BitPixelData(Stream stream, Buffer2D pixels) where TPixel : unmanaged, IPixel { using IMemoryOwner row = this.AllocateRow(pixels.Width, 4); @@ -375,12 +379,12 @@ namespace SixLabors.ImageSharp.Formats.Bmp } /// - /// Writes the 24bit color palette to the stream. + /// Writes 24-bit pixel data with a color palette to the stream. /// /// The pixel format. /// The to write to. /// The containing pixel data. - private void Write24Bit(Stream stream, Buffer2D pixels) + private void Write24BitPixelData(Stream stream, Buffer2D pixels) where TPixel : unmanaged, IPixel { int width = pixels.Width; @@ -401,12 +405,12 @@ namespace SixLabors.ImageSharp.Formats.Bmp } /// - /// Writes the 16bit color palette to the stream. + /// Writes 16-bit pixel data with a color palette to the stream. /// /// The type of the pixel. /// The to write to. /// The containing pixel data. - private void Write16Bit(Stream stream, Buffer2D pixels) + private void Write16BitPixelData(Stream stream, Buffer2D pixels) where TPixel : unmanaged, IPixel { int width = pixels.Width; @@ -429,12 +433,12 @@ namespace SixLabors.ImageSharp.Formats.Bmp } /// - /// Writes an 8 bit image with a color palette. The color palette has 256 entry's with 4 bytes for each entry. + /// Writes 8 bit pixel data with a color palette. The color palette has 256 entry's with 4 bytes for each entry. /// /// The type of the pixel. /// The to write to. /// The containing pixel data. - private void Write8Bit(Stream stream, ImageFrame image) + private void Write8BitPixelData(Stream stream, ImageFrame image) where TPixel : unmanaged, IPixel { bool isL8 = typeof(TPixel) == typeof(L8); @@ -443,7 +447,7 @@ namespace SixLabors.ImageSharp.Formats.Bmp if (isL8) { - this.Write8BitGray(stream, image, colorPalette); + this.Write8BitPixelData(stream, image, colorPalette); } else { @@ -480,13 +484,13 @@ namespace SixLabors.ImageSharp.Formats.Bmp } /// - /// Writes an 8 bit gray image with a color palette. The color palette has 256 entry's with 4 bytes for each entry. + /// Writes 8 bit gray pixel data with a color palette. The color palette has 256 entry's with 4 bytes for each entry. /// /// The type of the pixel. /// The to write to. /// The containing pixel data. /// A byte span of size 1024 for the color palette. - private void Write8BitGray(Stream stream, ImageFrame image, Span colorPalette) + private void Write8BitPixelData(Stream stream, ImageFrame image, Span colorPalette) where TPixel : unmanaged, IPixel { // Create a color palette with 256 different gray values. @@ -518,12 +522,12 @@ namespace SixLabors.ImageSharp.Formats.Bmp } /// - /// Writes an 4 bit color image with a color palette. The color palette has 16 entry's with 4 bytes for each entry. + /// Writes 4 bit pixel data with a color palette. The color palette has 16 entry's with 4 bytes for each entry. /// /// The type of the pixel. /// The to write to. /// The containing pixel data. - private void Write4BitColor(Stream stream, ImageFrame image) + private void Write4BitPixelData(Stream stream, ImageFrame image) where TPixel : unmanaged, IPixel { using IQuantizer frameQuantizer = this.quantizer.CreatePixelSpecificQuantizer(this.configuration, new QuantizerOptions() @@ -562,12 +566,65 @@ namespace SixLabors.ImageSharp.Formats.Bmp } /// - /// Writes a 1 bit image with a color palette. The color palette has 2 entry's with 4 bytes for each entry. + /// Writes 2 bit pixel data with a color palette. The color palette has 4 entry's with 4 bytes for each entry. + /// + /// The type of the pixel. + /// The to write to. + /// The containing pixel data. + private void Write2BitPixelData(Stream stream, ImageFrame image) + where TPixel : unmanaged, IPixel + { + using IQuantizer frameQuantizer = this.quantizer.CreatePixelSpecificQuantizer(this.configuration, new QuantizerOptions() + { + MaxColors = 4 + }); + using IndexedImageFrame quantized = frameQuantizer.BuildPaletteAndQuantizeFrame(image, image.Bounds()); + using IMemoryOwner colorPaletteBuffer = this.memoryAllocator.Allocate(ColorPaletteSize2Bit, AllocationOptions.Clean); + + Span colorPalette = colorPaletteBuffer.GetSpan(); + ReadOnlySpan quantizedColorPalette = quantized.Palette.Span; + this.WriteColorPalette(stream, quantizedColorPalette, colorPalette); + + ReadOnlySpan pixelRowSpan = quantized.DangerousGetRowSpan(0); + int rowPadding = pixelRowSpan.Length % 4 != 0 ? this.padding - 1 : this.padding; + for (int y = image.Height - 1; y >= 0; y--) + { + pixelRowSpan = quantized.DangerousGetRowSpan(y); + + int endIdx = pixelRowSpan.Length % 4 == 0 ? pixelRowSpan.Length : pixelRowSpan.Length - 4; + int i = 0; + for (i = 0; i < endIdx; i += 4) + { + stream.WriteByte((byte)((pixelRowSpan[i] << 6) | (pixelRowSpan[i + 1] << 4) | (pixelRowSpan[i + 2] << 2) | pixelRowSpan[i + 3])); + } + + if (pixelRowSpan.Length % 4 != 0) + { + int shift = 6; + byte pixelData = 0; + for (; i < pixelRowSpan.Length; i++) + { + pixelData = (byte)(pixelData | (pixelRowSpan[i] << shift)); + shift -= 2; + } + + stream.WriteByte(pixelData); + } + + for (i = 0; i < rowPadding; i++) + { + stream.WriteByte(0); + } + } + } + + /// + /// Writes 1 bit pixel data with a color palette. The color palette has 2 entry's with 4 bytes for each entry. /// /// The type of the pixel. /// The to write to. /// The containing pixel data. - private void Write1BitColor(Stream stream, ImageFrame image) + private void Write1BitPixelData(Stream stream, ImageFrame image) where TPixel : unmanaged, IPixel { using IQuantizer frameQuantizer = this.quantizer.CreatePixelSpecificQuantizer(this.configuration, new QuantizerOptions() @@ -622,7 +679,7 @@ namespace SixLabors.ImageSharp.Formats.Bmp Span colorPaletteAsUInt = MemoryMarshal.Cast(colorPalette); for (int i = 0; i < colorPaletteAsUInt.Length; i++) { - colorPaletteAsUInt[i] = colorPaletteAsUInt[i] & 0x00FFFFFF; // Padding byte, always 0. + colorPaletteAsUInt[i] &= 0x00FFFFFF; // Padding byte, always 0. } stream.Write(colorPalette); diff --git a/tests/ImageSharp.Tests/Formats/Bmp/BmpEncoderTests.cs b/tests/ImageSharp.Tests/Formats/Bmp/BmpEncoderTests.cs index dd59fb279..fc9554f6a 100644 --- a/tests/ImageSharp.Tests/Formats/Bmp/BmpEncoderTests.cs +++ b/tests/ImageSharp.Tests/Formats/Bmp/BmpEncoderTests.cs @@ -20,6 +20,8 @@ namespace SixLabors.ImageSharp.Tests.Formats.Bmp [Trait("Format", "Bmp")] public class BmpEncoderTests { + private static BmpDecoder BmpDecoder => new(); + public static readonly TheoryData BitsPerPixel = new() { @@ -39,6 +41,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Bmp new() { { Bit1, BmpBitsPerPixel.Pixel1 }, + { Bit2, BmpBitsPerPixel.Pixel2 }, { Bit4, BmpBitsPerPixel.Pixel4 }, { Bit8, BmpBitsPerPixel.Pixel8 }, { Rgb16, BmpBitsPerPixel.Pixel16 }, @@ -204,6 +207,50 @@ namespace SixLabors.ImageSharp.Tests.Formats.Bmp TestBmpEncoderCore(provider, bitsPerPixel, supportTransparency: true, customComparer: comparer); } + [Theory] + [WithFile(Bit2, PixelTypes.Rgba32, BmpBitsPerPixel.Pixel2)] + public void Encode_2Bit_WithV3Header_Works( + TestImageProvider provider, + BmpBitsPerPixel bitsPerPixel) + where TPixel : unmanaged, IPixel + { + // arrange + var encoder = new BmpEncoder() { BitsPerPixel = bitsPerPixel }; + using var memoryStream = new MemoryStream(); + using Image input = provider.GetImage(BmpDecoder); + + // act + encoder.Encode(input, memoryStream); + memoryStream.Position = 0; + + // assert + using var actual = Image.Load(memoryStream); + ImageSimilarityReport similarityReport = ImageComparer.Exact.CompareImagesOrFrames(input, actual); + Assert.True(similarityReport.IsEmpty, "encoded image does not match reference image"); + } + + [Theory] + [WithFile(Bit2, PixelTypes.Rgba32, BmpBitsPerPixel.Pixel2)] + public void Encode_2Bit_WithV4Header_Works( + TestImageProvider provider, + BmpBitsPerPixel bitsPerPixel) + where TPixel : unmanaged, IPixel + { + // arrange + var encoder = new BmpEncoder() { BitsPerPixel = bitsPerPixel }; + using var memoryStream = new MemoryStream(); + using Image input = provider.GetImage(BmpDecoder); + + // act + encoder.Encode(input, memoryStream); + memoryStream.Position = 0; + + // assert + using var actual = Image.Load(memoryStream); + ImageSimilarityReport similarityReport = ImageComparer.Exact.CompareImagesOrFrames(input, actual); + Assert.True(similarityReport.IsEmpty, "encoded image does not match reference image"); + } + [Theory] [WithFile(Bit1, PixelTypes.Rgba32, BmpBitsPerPixel.Pixel1)] public void Encode_1Bit_WithV3Header_Works( @@ -343,7 +390,8 @@ namespace SixLabors.ImageSharp.Tests.Formats.Bmp BmpBitsPerPixel bitsPerPixel, bool supportTransparency = true, // if set to true, will write a V4 header, otherwise a V3 header. IQuantizer quantizer = null, - ImageComparer customComparer = null) + ImageComparer customComparer = null, + IImageDecoder referenceDecoder = null) where TPixel : unmanaged, IPixel { using (Image image = provider.GetImage()) @@ -362,7 +410,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Bmp }; // Does DebugSave & load reference CompareToReferenceInput(): - image.VerifyEncoder(provider, "bmp", bitsPerPixel, encoder, customComparer); + image.VerifyEncoder(provider, "bmp", bitsPerPixel, encoder, customComparer, referenceDecoder: referenceDecoder); } } } diff --git a/tests/ImageSharp.Tests/TestImages.cs b/tests/ImageSharp.Tests/TestImages.cs index 306a28dae..27df82b5f 100644 --- a/tests/ImageSharp.Tests/TestImages.cs +++ b/tests/ImageSharp.Tests/TestImages.cs @@ -344,6 +344,8 @@ namespace SixLabors.ImageSharp.Tests public const string RLE4Delta = "Bmp/pal4rletrns.bmp"; public const string Rle4Delta320240 = "Bmp/rle4-delta-320x240.bmp"; public const string Bit1 = "Bmp/pal1.bmp"; + public const string Bit2 = "Bmp/pal2.bmp"; + public const string Bit2Color = "Bmp/pal2Color.bmp"; public const string Bit1Pal1 = "Bmp/pal1p1.bmp"; public const string Bit4 = "Bmp/pal4.bmp"; public const string Bit8 = "Bmp/test8.bmp"; diff --git a/tests/ImageSharp.Tests/TestUtilities/ImageComparison/ImageComparer.cs b/tests/ImageSharp.Tests/TestUtilities/ImageComparison/ImageComparer.cs index cea2784b6..d2750c31c 100644 --- a/tests/ImageSharp.Tests/TestUtilities/ImageComparison/ImageComparer.cs +++ b/tests/ImageSharp.Tests/TestUtilities/ImageComparison/ImageComparer.cs @@ -19,10 +19,8 @@ namespace SixLabors.ImageSharp.Tests.TestUtilities.ImageComparison /// A ImageComparer instance. public static ImageComparer Tolerant( float imageThreshold = TolerantImageComparer.DefaultImageThreshold, - int perPixelManhattanThreshold = 0) - { - return new TolerantImageComparer(imageThreshold, perPixelManhattanThreshold); - } + int perPixelManhattanThreshold = 0) => + new TolerantImageComparer(imageThreshold, perPixelManhattanThreshold); /// /// Returns Tolerant(imageThresholdInPercents/100) @@ -45,10 +43,7 @@ namespace SixLabors.ImageSharp.Tests.TestUtilities.ImageComparison Image expected, Image actual) where TPixelA : unmanaged, IPixel - where TPixelB : unmanaged, IPixel - { - return comparer.CompareImagesOrFrames(expected.Frames.RootFrame, actual.Frames.RootFrame); - } + where TPixelB : unmanaged, IPixel => comparer.CompareImagesOrFrames(expected.Frames.RootFrame, actual.Frames.RootFrame); public static IEnumerable> CompareImages( this ImageComparer comparer, diff --git a/tests/Images/Input/Bmp/pal2.bmp b/tests/Images/Input/Bmp/pal2.bmp new file mode 100644 index 000000000..ac351d5fb --- /dev/null +++ b/tests/Images/Input/Bmp/pal2.bmp @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:bac6eec4100831e635fcd34a9e0e34a8a9082abdec132ac327aa1bfc7137d40f +size 2118 diff --git a/tests/Images/Input/Bmp/pal2color.bmp b/tests/Images/Input/Bmp/pal2color.bmp new file mode 100644 index 000000000..dd7c31bf6 --- /dev/null +++ b/tests/Images/Input/Bmp/pal2color.bmp @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:6ac541592afb207524091aa19d59614851c293193600eacb1170b4854d351dae +size 2118 From 26700fe6b0eb250faaed263b9ad4ef339408e5ff Mon Sep 17 00:00:00 2001 From: Brian Popow Date: Wed, 31 Aug 2022 17:07:12 +0200 Subject: [PATCH 2/8] Add decoder tests for 2 bit bitmap's --- .../Formats/Bmp/BmpDecoderTests.cs | 15 +++++++++++++++ .../Formats/Bmp/BmpEncoderTests.cs | 10 ++++------ .../BmpDecoder_CanDecode_2Bit_Rgba32_pal2.png | 3 +++ ...BmpDecoder_CanDecode_2Bit_Rgba32_pal2Color.png | 3 +++ 4 files changed, 25 insertions(+), 6 deletions(-) create mode 100644 tests/Images/External/ReferenceOutput/BmpDecoderTests/BmpDecoder_CanDecode_2Bit_Rgba32_pal2.png create mode 100644 tests/Images/External/ReferenceOutput/BmpDecoderTests/BmpDecoder_CanDecode_2Bit_Rgba32_pal2Color.png diff --git a/tests/ImageSharp.Tests/Formats/Bmp/BmpDecoderTests.cs b/tests/ImageSharp.Tests/Formats/Bmp/BmpDecoderTests.cs index 239e20976..f85219757 100644 --- a/tests/ImageSharp.Tests/Formats/Bmp/BmpDecoderTests.cs +++ b/tests/ImageSharp.Tests/Formats/Bmp/BmpDecoderTests.cs @@ -131,6 +131,21 @@ namespace SixLabors.ImageSharp.Tests.Formats.Bmp } } + [Theory] + [WithFile(Bit2, PixelTypes.Rgba32)] + [WithFile(Bit2Color, PixelTypes.Rgba32)] + public void BmpDecoder_CanDecode_2Bit(TestImageProvider provider) + where TPixel : unmanaged, IPixel + { + using (Image image = provider.GetImage(BmpDecoder)) + { + image.DebugSave(provider); + + // Reference decoder cant decode 2-bit, compare to reference output instead. + image.CompareToReferenceOutput(provider, extension: "png"); + } + } + [Theory] [WithFile(Bit4, PixelTypes.Rgba32)] public void BmpDecoder_CanDecode_4Bit(TestImageProvider provider) diff --git a/tests/ImageSharp.Tests/Formats/Bmp/BmpEncoderTests.cs b/tests/ImageSharp.Tests/Formats/Bmp/BmpEncoderTests.cs index fc9554f6a..665bdd0da 100644 --- a/tests/ImageSharp.Tests/Formats/Bmp/BmpEncoderTests.cs +++ b/tests/ImageSharp.Tests/Formats/Bmp/BmpEncoderTests.cs @@ -22,6 +22,8 @@ namespace SixLabors.ImageSharp.Tests.Formats.Bmp { private static BmpDecoder BmpDecoder => new(); + private static BmpEncoder BmpEncoder => new(); + public static readonly TheoryData BitsPerPixel = new() { @@ -53,14 +55,12 @@ namespace SixLabors.ImageSharp.Tests.Formats.Bmp [MemberData(nameof(RatioFiles))] public void Encode_PreserveRatio(string imagePath, int xResolution, int yResolution, PixelResolutionUnit resolutionUnit) { - var options = new BmpEncoder(); - var testFile = TestFile.Create(imagePath); using (Image input = testFile.CreateRgba32Image()) { using (var memStream = new MemoryStream()) { - input.Save(memStream, options); + input.Save(memStream, BmpEncoder); memStream.Position = 0; using (var output = Image.Load(memStream)) @@ -78,14 +78,12 @@ namespace SixLabors.ImageSharp.Tests.Formats.Bmp [MemberData(nameof(BmpBitsPerPixelFiles))] public void Encode_PreserveBitsPerPixel(string imagePath, BmpBitsPerPixel bmpBitsPerPixel) { - var options = new BmpEncoder(); - var testFile = TestFile.Create(imagePath); using (Image input = testFile.CreateRgba32Image()) { using (var memStream = new MemoryStream()) { - input.Save(memStream, options); + input.Save(memStream, BmpEncoder); memStream.Position = 0; using (var output = Image.Load(memStream)) diff --git a/tests/Images/External/ReferenceOutput/BmpDecoderTests/BmpDecoder_CanDecode_2Bit_Rgba32_pal2.png b/tests/Images/External/ReferenceOutput/BmpDecoderTests/BmpDecoder_CanDecode_2Bit_Rgba32_pal2.png new file mode 100644 index 000000000..4a1ac4088 --- /dev/null +++ b/tests/Images/External/ReferenceOutput/BmpDecoderTests/BmpDecoder_CanDecode_2Bit_Rgba32_pal2.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:2c3e8b87af737c40d7be02e55a2aec93bb0e7bd123cd1f3e3b74482a0c7d18bd +size 2376 diff --git a/tests/Images/External/ReferenceOutput/BmpDecoderTests/BmpDecoder_CanDecode_2Bit_Rgba32_pal2Color.png b/tests/Images/External/ReferenceOutput/BmpDecoderTests/BmpDecoder_CanDecode_2Bit_Rgba32_pal2Color.png new file mode 100644 index 000000000..6f7bd6869 --- /dev/null +++ b/tests/Images/External/ReferenceOutput/BmpDecoderTests/BmpDecoder_CanDecode_2Bit_Rgba32_pal2Color.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:c3da68e15f4edf6ce5da76360f3704d52baff5292ee12efe5415540b5788dda5 +size 2578 From 3db96c989e70aff06f046d17f5703fcaa35fa31e Mon Sep 17 00:00:00 2001 From: Brian Popow Date: Wed, 31 Aug 2022 17:21:40 +0200 Subject: [PATCH 3/8] Compare to reference output, when reference decoder is not an option --- .../Formats/Bmp/BmpDecoderTests.cs | 27 ++++++++++--------- ...nDecodeAlphaBitfields_Rgba32_rgba32abf.png | 3 +++ ...der_CanDecode_Os2BitmapArray_Rgba32_9S.png | 3 +++ ...anDecode_Os2BitmapArray_Rgba32_DIAMOND.png | 3 +++ ...anDecode_Os2BitmapArray_Rgba32_GMARBLE.png | 3 +++ ..._CanDecode_Os2BitmapArray_Rgba32_PINES.png | 3 +++ ...CanDecode_Os2BitmapArray_Rgba32_SKATER.png | 3 +++ ..._CanDecode_Os2BitmapArray_Rgba32_SPADE.png | 3 +++ ...anDecode_Os2BitmapArray_Rgba32_SUNFLOW.png | 3 +++ ..._CanDecode_Os2BitmapArray_Rgba32_WARPD.png | 3 +++ ..._CanDecode_Os2BitmapArray_Rgba32_ba-bm.png | 3 +++ ...CanDecode_Os2v2Header_Rgba32_pal8os2v2.png | 3 +++ ..._Os2v2XShortHeader_Rgba32_pal8os2v2-16.png | 3 +++ ...nLengthEncoded_24Bit_Rgba32_rgb24rle24.png | 3 +++ ...LengthEncoded_24Bit_Rgba32_rle24rlecut.png | 3 +++ 15 files changed, 57 insertions(+), 12 deletions(-) create mode 100644 tests/Images/External/ReferenceOutput/BmpDecoderTests/BmpDecoder_CanDecodeAlphaBitfields_Rgba32_rgba32abf.png create mode 100644 tests/Images/External/ReferenceOutput/BmpDecoderTests/BmpDecoder_CanDecode_Os2BitmapArray_Rgba32_9S.png create mode 100644 tests/Images/External/ReferenceOutput/BmpDecoderTests/BmpDecoder_CanDecode_Os2BitmapArray_Rgba32_DIAMOND.png create mode 100644 tests/Images/External/ReferenceOutput/BmpDecoderTests/BmpDecoder_CanDecode_Os2BitmapArray_Rgba32_GMARBLE.png create mode 100644 tests/Images/External/ReferenceOutput/BmpDecoderTests/BmpDecoder_CanDecode_Os2BitmapArray_Rgba32_PINES.png create mode 100644 tests/Images/External/ReferenceOutput/BmpDecoderTests/BmpDecoder_CanDecode_Os2BitmapArray_Rgba32_SKATER.png create mode 100644 tests/Images/External/ReferenceOutput/BmpDecoderTests/BmpDecoder_CanDecode_Os2BitmapArray_Rgba32_SPADE.png create mode 100644 tests/Images/External/ReferenceOutput/BmpDecoderTests/BmpDecoder_CanDecode_Os2BitmapArray_Rgba32_SUNFLOW.png create mode 100644 tests/Images/External/ReferenceOutput/BmpDecoderTests/BmpDecoder_CanDecode_Os2BitmapArray_Rgba32_WARPD.png create mode 100644 tests/Images/External/ReferenceOutput/BmpDecoderTests/BmpDecoder_CanDecode_Os2BitmapArray_Rgba32_ba-bm.png create mode 100644 tests/Images/External/ReferenceOutput/BmpDecoderTests/BmpDecoder_CanDecode_Os2v2Header_Rgba32_pal8os2v2.png create mode 100644 tests/Images/External/ReferenceOutput/BmpDecoderTests/BmpDecoder_CanDecode_Os2v2XShortHeader_Rgba32_pal8os2v2-16.png create mode 100644 tests/Images/External/ReferenceOutput/BmpDecoderTests/BmpDecoder_CanDecode_RunLengthEncoded_24Bit_Rgba32_rgb24rle24.png create mode 100644 tests/Images/External/ReferenceOutput/BmpDecoderTests/BmpDecoder_CanDecode_RunLengthEncoded_24Bit_Rgba32_rle24rlecut.png diff --git a/tests/ImageSharp.Tests/Formats/Bmp/BmpDecoderTests.cs b/tests/ImageSharp.Tests/Formats/Bmp/BmpDecoderTests.cs index f85219757..23a849790 100644 --- a/tests/ImageSharp.Tests/Formats/Bmp/BmpDecoderTests.cs +++ b/tests/ImageSharp.Tests/Formats/Bmp/BmpDecoderTests.cs @@ -304,8 +304,9 @@ namespace SixLabors.ImageSharp.Tests.Formats.Bmp { image.DebugSave(provider); - // TODO: Neither System.Drawing nor MagickReferenceDecoder decode this file. - // image.CompareToOriginal(provider); + // Neither System.Drawing nor MagickReferenceDecoder decode this file. + // Compare to reference output instead. + image.CompareToReferenceOutput(provider, extension: "png"); } } @@ -318,8 +319,9 @@ namespace SixLabors.ImageSharp.Tests.Formats.Bmp { image.DebugSave(provider); - // TODO: Neither System.Drawing nor MagickReferenceDecoder decode this file. - // image.CompareToOriginal(provider); + // Neither System.Drawing nor MagickReferenceDecoder decode this file. + // Compare to reference output instead. + image.CompareToReferenceOutput(provider, extension: "png"); } } @@ -592,8 +594,9 @@ namespace SixLabors.ImageSharp.Tests.Formats.Bmp { image.DebugSave(provider); - // TODO: Neither System.Drawing or MagickReferenceDecoder can correctly decode this file. - // image.CompareToOriginal(provider); + // Neither System.Drawing or MagickReferenceDecoder can correctly decode this file. + // Compare to reference output instead. + image.CompareToReferenceOutput(provider, extension: "png"); } } @@ -606,10 +609,9 @@ namespace SixLabors.ImageSharp.Tests.Formats.Bmp { image.DebugSave(provider); - // TODO: System.Drawing can not decode this image. MagickReferenceDecoder can decode it, - // but i think incorrectly. I have loaded the image with GIMP and exported as PNG. - // The results are the same as the image sharp implementation. - // image.CompareToOriginal(provider, new MagickReferenceDecoder()); + // System.Drawing can not decode this image. MagickReferenceDecoder can decode it, + // Compare to reference output instead. + image.CompareToReferenceOutput(provider, extension: "png"); } } @@ -630,8 +632,9 @@ namespace SixLabors.ImageSharp.Tests.Formats.Bmp { image.DebugSave(provider); - // TODO: Neither System.Drawing or MagickReferenceDecoder can correctly decode this file. - // image.CompareToOriginal(provider); + // Neither System.Drawing or MagickReferenceDecoder can correctly decode this file. + // Compare to reference output instead. + image.CompareToReferenceOutput(provider, extension: "png"); } } } diff --git a/tests/Images/External/ReferenceOutput/BmpDecoderTests/BmpDecoder_CanDecodeAlphaBitfields_Rgba32_rgba32abf.png b/tests/Images/External/ReferenceOutput/BmpDecoderTests/BmpDecoder_CanDecodeAlphaBitfields_Rgba32_rgba32abf.png new file mode 100644 index 000000000..40613ca7e --- /dev/null +++ b/tests/Images/External/ReferenceOutput/BmpDecoderTests/BmpDecoder_CanDecodeAlphaBitfields_Rgba32_rgba32abf.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:1c7c5d24cf8ba473a22d1c12dcd196f626d2ef056a35bb3ff54b5c84516544bf +size 14547 diff --git a/tests/Images/External/ReferenceOutput/BmpDecoderTests/BmpDecoder_CanDecode_Os2BitmapArray_Rgba32_9S.png b/tests/Images/External/ReferenceOutput/BmpDecoderTests/BmpDecoder_CanDecode_Os2BitmapArray_Rgba32_9S.png new file mode 100644 index 000000000..0319b9718 --- /dev/null +++ b/tests/Images/External/ReferenceOutput/BmpDecoderTests/BmpDecoder_CanDecode_Os2BitmapArray_Rgba32_9S.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:8597af653507fb625a8f387ce01ab900603086892f046b7b92e6fcf60a636295 +size 884 diff --git a/tests/Images/External/ReferenceOutput/BmpDecoderTests/BmpDecoder_CanDecode_Os2BitmapArray_Rgba32_DIAMOND.png b/tests/Images/External/ReferenceOutput/BmpDecoderTests/BmpDecoder_CanDecode_Os2BitmapArray_Rgba32_DIAMOND.png new file mode 100644 index 000000000..630b44ecd --- /dev/null +++ b/tests/Images/External/ReferenceOutput/BmpDecoderTests/BmpDecoder_CanDecode_Os2BitmapArray_Rgba32_DIAMOND.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:0a6989978a0fe36399a774000ee04336d090a4e6a2b63bcbfcd45312ccac4dab +size 648 diff --git a/tests/Images/External/ReferenceOutput/BmpDecoderTests/BmpDecoder_CanDecode_Os2BitmapArray_Rgba32_GMARBLE.png b/tests/Images/External/ReferenceOutput/BmpDecoderTests/BmpDecoder_CanDecode_Os2BitmapArray_Rgba32_GMARBLE.png new file mode 100644 index 000000000..ff484218d --- /dev/null +++ b/tests/Images/External/ReferenceOutput/BmpDecoderTests/BmpDecoder_CanDecode_Os2BitmapArray_Rgba32_GMARBLE.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:951d9d48a5b5df5b70a8c217e2a3d94f4b2c8e8cc63d70cb807627b8e98b8b1d +size 20567 diff --git a/tests/Images/External/ReferenceOutput/BmpDecoderTests/BmpDecoder_CanDecode_Os2BitmapArray_Rgba32_PINES.png b/tests/Images/External/ReferenceOutput/BmpDecoderTests/BmpDecoder_CanDecode_Os2BitmapArray_Rgba32_PINES.png new file mode 100644 index 000000000..78ffbe76c --- /dev/null +++ b/tests/Images/External/ReferenceOutput/BmpDecoderTests/BmpDecoder_CanDecode_Os2BitmapArray_Rgba32_PINES.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:35dc46a1f19f3f0a91948bee9b173f6ce264ade69754c01b688e2a878f1374a9 +size 21406 diff --git a/tests/Images/External/ReferenceOutput/BmpDecoderTests/BmpDecoder_CanDecode_Os2BitmapArray_Rgba32_SKATER.png b/tests/Images/External/ReferenceOutput/BmpDecoderTests/BmpDecoder_CanDecode_Os2BitmapArray_Rgba32_SKATER.png new file mode 100644 index 000000000..7b6ec01dc --- /dev/null +++ b/tests/Images/External/ReferenceOutput/BmpDecoderTests/BmpDecoder_CanDecode_Os2BitmapArray_Rgba32_SKATER.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:3191c0ac33c1749f770f96814c0585715aa1c0b085f02256317cedeabc531c12 +size 636 diff --git a/tests/Images/External/ReferenceOutput/BmpDecoderTests/BmpDecoder_CanDecode_Os2BitmapArray_Rgba32_SPADE.png b/tests/Images/External/ReferenceOutput/BmpDecoderTests/BmpDecoder_CanDecode_Os2BitmapArray_Rgba32_SPADE.png new file mode 100644 index 000000000..89bf24a22 --- /dev/null +++ b/tests/Images/External/ReferenceOutput/BmpDecoderTests/BmpDecoder_CanDecode_Os2BitmapArray_Rgba32_SPADE.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:50c5f1adb8b9f0f9a111fdd4b04df023d4239d409f93e2ab5823352c02761118 +size 802 diff --git a/tests/Images/External/ReferenceOutput/BmpDecoderTests/BmpDecoder_CanDecode_Os2BitmapArray_Rgba32_SUNFLOW.png b/tests/Images/External/ReferenceOutput/BmpDecoderTests/BmpDecoder_CanDecode_Os2BitmapArray_Rgba32_SUNFLOW.png new file mode 100644 index 000000000..5e7a2c071 --- /dev/null +++ b/tests/Images/External/ReferenceOutput/BmpDecoderTests/BmpDecoder_CanDecode_Os2BitmapArray_Rgba32_SUNFLOW.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:8f0f9b6a5f1a36596fbe8ac1416e69af82e24c5892a8012a6b68206b6e467bec +size 14190 diff --git a/tests/Images/External/ReferenceOutput/BmpDecoderTests/BmpDecoder_CanDecode_Os2BitmapArray_Rgba32_WARPD.png b/tests/Images/External/ReferenceOutput/BmpDecoderTests/BmpDecoder_CanDecode_Os2BitmapArray_Rgba32_WARPD.png new file mode 100644 index 000000000..6a62cc9c7 --- /dev/null +++ b/tests/Images/External/ReferenceOutput/BmpDecoderTests/BmpDecoder_CanDecode_Os2BitmapArray_Rgba32_WARPD.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:452e8aeca41c0899f4e7a4f0458f7cf2dd8002e42a752708d7dd308e040641a0 +size 103892 diff --git a/tests/Images/External/ReferenceOutput/BmpDecoderTests/BmpDecoder_CanDecode_Os2BitmapArray_Rgba32_ba-bm.png b/tests/Images/External/ReferenceOutput/BmpDecoderTests/BmpDecoder_CanDecode_Os2BitmapArray_Rgba32_ba-bm.png new file mode 100644 index 000000000..2c9fab29f --- /dev/null +++ b/tests/Images/External/ReferenceOutput/BmpDecoderTests/BmpDecoder_CanDecode_Os2BitmapArray_Rgba32_ba-bm.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:9e1fc90acab9db3469b673036c8cdcf5920ca3d12915a412280f09a86a14ad2e +size 5081 diff --git a/tests/Images/External/ReferenceOutput/BmpDecoderTests/BmpDecoder_CanDecode_Os2v2Header_Rgba32_pal8os2v2.png b/tests/Images/External/ReferenceOutput/BmpDecoderTests/BmpDecoder_CanDecode_Os2v2Header_Rgba32_pal8os2v2.png new file mode 100644 index 000000000..2c9fab29f --- /dev/null +++ b/tests/Images/External/ReferenceOutput/BmpDecoderTests/BmpDecoder_CanDecode_Os2v2Header_Rgba32_pal8os2v2.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:9e1fc90acab9db3469b673036c8cdcf5920ca3d12915a412280f09a86a14ad2e +size 5081 diff --git a/tests/Images/External/ReferenceOutput/BmpDecoderTests/BmpDecoder_CanDecode_Os2v2XShortHeader_Rgba32_pal8os2v2-16.png b/tests/Images/External/ReferenceOutput/BmpDecoderTests/BmpDecoder_CanDecode_Os2v2XShortHeader_Rgba32_pal8os2v2-16.png new file mode 100644 index 000000000..2c9fab29f --- /dev/null +++ b/tests/Images/External/ReferenceOutput/BmpDecoderTests/BmpDecoder_CanDecode_Os2v2XShortHeader_Rgba32_pal8os2v2-16.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:9e1fc90acab9db3469b673036c8cdcf5920ca3d12915a412280f09a86a14ad2e +size 5081 diff --git a/tests/Images/External/ReferenceOutput/BmpDecoderTests/BmpDecoder_CanDecode_RunLengthEncoded_24Bit_Rgba32_rgb24rle24.png b/tests/Images/External/ReferenceOutput/BmpDecoderTests/BmpDecoder_CanDecode_RunLengthEncoded_24Bit_Rgba32_rgb24rle24.png new file mode 100644 index 000000000..2c9fab29f --- /dev/null +++ b/tests/Images/External/ReferenceOutput/BmpDecoderTests/BmpDecoder_CanDecode_RunLengthEncoded_24Bit_Rgba32_rgb24rle24.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:9e1fc90acab9db3469b673036c8cdcf5920ca3d12915a412280f09a86a14ad2e +size 5081 diff --git a/tests/Images/External/ReferenceOutput/BmpDecoderTests/BmpDecoder_CanDecode_RunLengthEncoded_24Bit_Rgba32_rle24rlecut.png b/tests/Images/External/ReferenceOutput/BmpDecoderTests/BmpDecoder_CanDecode_RunLengthEncoded_24Bit_Rgba32_rle24rlecut.png new file mode 100644 index 000000000..8311bc95b --- /dev/null +++ b/tests/Images/External/ReferenceOutput/BmpDecoderTests/BmpDecoder_CanDecode_RunLengthEncoded_24Bit_Rgba32_rle24rlecut.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:13d9b630227069f3fd744ef486d64d3f997ee0a9844824e9986c55d754bf413c +size 4379 From 9aa991884935e69c5acef696d6167ac86dc905d3 Mon Sep 17 00:00:00 2001 From: Brian Popow Date: Wed, 31 Aug 2022 17:30:01 +0200 Subject: [PATCH 4/8] Throw exception, when not enough data could be read --- src/ImageSharp/Formats/Bmp/BmpDecoderCore.cs | 51 ++++++++++++++++---- 1 file changed, 42 insertions(+), 9 deletions(-) diff --git a/src/ImageSharp/Formats/Bmp/BmpDecoderCore.cs b/src/ImageSharp/Formats/Bmp/BmpDecoderCore.cs index 517a3b8cf..74b41bb04 100644 --- a/src/ImageSharp/Formats/Bmp/BmpDecoderCore.cs +++ b/src/ImageSharp/Formats/Bmp/BmpDecoderCore.cs @@ -832,7 +832,11 @@ namespace SixLabors.ImageSharp.Formats.Bmp for (int y = 0; y < height; y++) { int newY = Invert(y, height, inverted); - this.stream.Read(rowSpan); + if (this.stream.Read(rowSpan) == 0) + { + BmpThrowHelper.ThrowInvalidImageContentException("Could not read enough data for a pixel row!"); + } + int offset = 0; Span pixelRow = pixels.DangerousGetRowSpan(newY); @@ -884,7 +888,11 @@ namespace SixLabors.ImageSharp.Formats.Bmp for (int y = 0; y < height; y++) { - this.stream.Read(bufferSpan); + if (this.stream.Read(bufferSpan) == 0) + { + BmpThrowHelper.ThrowInvalidImageContentException("Could not read enough data for a pixel row!"); + } + int newY = Invert(y, height, inverted); Span pixelRow = pixels.DangerousGetRowSpan(newY); @@ -939,7 +947,11 @@ namespace SixLabors.ImageSharp.Formats.Bmp for (int y = 0; y < height; y++) { - this.stream.Read(rowSpan); + if (this.stream.Read(rowSpan) == 0) + { + BmpThrowHelper.ThrowInvalidImageContentException("Could not read enough data for a pixel row!"); + } + int newY = Invert(y, height, inverted); Span pixelSpan = pixels.DangerousGetRowSpan(newY); PixelOperations.Instance.FromBgr24Bytes( @@ -967,7 +979,11 @@ namespace SixLabors.ImageSharp.Formats.Bmp for (int y = 0; y < height; y++) { - this.stream.Read(rowSpan); + if (this.stream.Read(rowSpan) == 0) + { + BmpThrowHelper.ThrowInvalidImageContentException("Could not read enough data for a pixel row!"); + } + int newY = Invert(y, height, inverted); Span pixelSpan = pixels.DangerousGetRowSpan(newY); PixelOperations.Instance.FromBgra32Bytes( @@ -1003,7 +1019,10 @@ namespace SixLabors.ImageSharp.Formats.Bmp // actually a BGRA image, and change tactics accordingly. for (int y = 0; y < height; y++) { - this.stream.Read(rowSpan); + if (this.stream.Read(rowSpan) == 0) + { + BmpThrowHelper.ThrowInvalidImageContentException("Could not read enough data for a pixel row!"); + } PixelOperations.Instance.FromBgra32Bytes( this.Configuration, @@ -1036,7 +1055,10 @@ namespace SixLabors.ImageSharp.Formats.Bmp { for (int y = 0; y < height; y++) { - this.stream.Read(rowSpan); + if (this.stream.Read(rowSpan) == 0) + { + BmpThrowHelper.ThrowInvalidImageContentException("Could not read enough data for a pixel row!"); + } int newY = Invert(y, height, inverted); Span pixelSpan = pixels.DangerousGetRowSpan(newY); @@ -1054,7 +1076,11 @@ namespace SixLabors.ImageSharp.Formats.Bmp // Slow path. We need to set each alpha component value to fully opaque. for (int y = 0; y < height; y++) { - this.stream.Read(rowSpan); + if (this.stream.Read(rowSpan) == 0) + { + BmpThrowHelper.ThrowInvalidImageContentException("Could not read enough data for a pixel row!"); + } + PixelOperations.Instance.FromBgra32Bytes( this.Configuration, rowSpan, @@ -1115,7 +1141,11 @@ namespace SixLabors.ImageSharp.Formats.Bmp for (int y = 0; y < height; y++) { - this.stream.Read(bufferSpan); + if (this.stream.Read(bufferSpan) == 0) + { + BmpThrowHelper.ThrowInvalidImageContentException("Could not read enough data for a pixel row!"); + } + int newY = Invert(y, height, inverted); Span pixelRow = pixels.DangerousGetRowSpan(newY); @@ -1431,7 +1461,10 @@ namespace SixLabors.ImageSharp.Formats.Bmp palette = new byte[colorMapSizeBytes]; - this.stream.Read(palette, 0, colorMapSizeBytes); + if (this.stream.Read(palette, 0, colorMapSizeBytes) == 0) + { + BmpThrowHelper.ThrowInvalidImageContentException("Could not read enough data for the palette!"); + } } this.infoHeader.VerifyDimensions(); From ee62b83ad937614652c613ee0d50b8f3f1edac51 Mon Sep 17 00:00:00 2001 From: Brian Popow Date: Wed, 31 Aug 2022 18:03:17 +0200 Subject: [PATCH 5/8] Fix test file name --- tests/ImageSharp.Tests/TestImages.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/ImageSharp.Tests/TestImages.cs b/tests/ImageSharp.Tests/TestImages.cs index c51ec4acb..0f9479a76 100644 --- a/tests/ImageSharp.Tests/TestImages.cs +++ b/tests/ImageSharp.Tests/TestImages.cs @@ -348,7 +348,7 @@ namespace SixLabors.ImageSharp.Tests public const string Rle4Delta320240 = "Bmp/rle4-delta-320x240.bmp"; public const string Bit1 = "Bmp/pal1.bmp"; public const string Bit2 = "Bmp/pal2.bmp"; - public const string Bit2Color = "Bmp/pal2Color.bmp"; + public const string Bit2Color = "Bmp/pal2color.bmp"; public const string Bit1Pal1 = "Bmp/pal1p1.bmp"; public const string Bit4 = "Bmp/pal4.bmp"; public const string Bit8 = "Bmp/test8.bmp"; From 9d699c34c85e198e01788d3456ba7b6fbd317007 Mon Sep 17 00:00:00 2001 From: Brian Popow Date: Wed, 31 Aug 2022 19:21:35 +0200 Subject: [PATCH 6/8] Rename test file --- ...l2Color.png => BmpDecoder_CanDecode_2Bit_Rgba32_pal2color.png} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename tests/Images/External/ReferenceOutput/BmpDecoderTests/{BmpDecoder_CanDecode_2Bit_Rgba32_pal2Color.png => BmpDecoder_CanDecode_2Bit_Rgba32_pal2color.png} (100%) diff --git a/tests/Images/External/ReferenceOutput/BmpDecoderTests/BmpDecoder_CanDecode_2Bit_Rgba32_pal2Color.png b/tests/Images/External/ReferenceOutput/BmpDecoderTests/BmpDecoder_CanDecode_2Bit_Rgba32_pal2color.png similarity index 100% rename from tests/Images/External/ReferenceOutput/BmpDecoderTests/BmpDecoder_CanDecode_2Bit_Rgba32_pal2Color.png rename to tests/Images/External/ReferenceOutput/BmpDecoderTests/BmpDecoder_CanDecode_2Bit_Rgba32_pal2color.png From 976f2a8eacfc7c811c3bc329deaca0d85362c864 Mon Sep 17 00:00:00 2001 From: James Jackson-South Date: Thu, 1 Sep 2022 13:27:12 +1000 Subject: [PATCH 7/8] Bypass constantly failing NET7 Win tests --- .github/workflows/build-and-test.yml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index 1a57ec1ed..440131362 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -20,19 +20,19 @@ jobs: sdk-preview: true runtime: -x64 codecov: false + - os: macos-latest + framework: net7.0 + sdk: 7.0.x + sdk-preview: true + runtime: -x64 + codecov: false # Temp disabled due to runtime preview issues. - #- os: macos-latest + #- os: windows-latest # framework: net7.0 # sdk: 7.0.x # sdk-preview: true # runtime: -x64 # codecov: false - - os: windows-latest - framework: net7.0 - sdk: 7.0.x - sdk-preview: true - runtime: -x64 - codecov: false - os: ubuntu-latest framework: net6.0 sdk: 6.0.x From af9bfe516eeded3e6a52a7e74cf531af86d00f56 Mon Sep 17 00:00:00 2001 From: James Jackson-South Date: Thu, 1 Sep 2022 13:44:08 +1000 Subject: [PATCH 8/8] Mac fix is not released yet --- .github/workflows/build-and-test.yml | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index 440131362..cd59dca80 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -20,13 +20,14 @@ jobs: sdk-preview: true runtime: -x64 codecov: false - - os: macos-latest - framework: net7.0 - sdk: 7.0.x - sdk-preview: true - runtime: -x64 - codecov: false # Temp disabled due to runtime preview issues. + # https://github.com/SixLabors/ImageSharp/issues/2117 + #- os: macos-latest + # framework: net7.0 + # sdk: 7.0.x + # sdk-preview: true + # runtime: -x64 + # codecov: false #- os: windows-latest # framework: net7.0 # sdk: 7.0.x