|
|
@ -37,27 +37,23 @@ namespace SixLabors.ImageSharp.Tests.Formats.Bmp |
|
|
public void BmpDecoder_CanDecode_MiscellaneousBitmaps<TPixel>(TestImageProvider<TPixel> provider) |
|
|
public void BmpDecoder_CanDecode_MiscellaneousBitmaps<TPixel>(TestImageProvider<TPixel> provider) |
|
|
where TPixel : struct, IPixel<TPixel> |
|
|
where TPixel : struct, IPixel<TPixel> |
|
|
{ |
|
|
{ |
|
|
using (Image<TPixel> image = provider.GetImage(new BmpDecoder())) |
|
|
using Image<TPixel> image = provider.GetImage(new BmpDecoder()); |
|
|
{ |
|
|
|
|
|
image.DebugSave(provider); |
|
|
image.DebugSave(provider); |
|
|
if (TestEnvironment.IsWindows) |
|
|
if (TestEnvironment.IsWindows) |
|
|
{ |
|
|
{ |
|
|
image.CompareToOriginal(provider); |
|
|
image.CompareToOriginal(provider); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
[Theory] |
|
|
[Theory] |
|
|
[WithFileCollection(nameof(BitfieldsBmpFiles), PixelTypes.Rgba32)] |
|
|
[WithFileCollection(nameof(BitfieldsBmpFiles), PixelTypes.Rgba32)] |
|
|
public void BmpDecoder_CanDecodeBitfields<TPixel>(TestImageProvider<TPixel> provider) |
|
|
public void BmpDecoder_CanDecodeBitfields<TPixel>(TestImageProvider<TPixel> provider) |
|
|
where TPixel : struct, IPixel<TPixel> |
|
|
where TPixel : struct, IPixel<TPixel> |
|
|
{ |
|
|
{ |
|
|
using (Image<TPixel> image = provider.GetImage(new BmpDecoder())) |
|
|
using Image<TPixel> image = provider.GetImage(new BmpDecoder()); |
|
|
{ |
|
|
|
|
|
image.DebugSave(provider); |
|
|
image.DebugSave(provider); |
|
|
image.CompareToOriginal(provider); |
|
|
image.CompareToOriginal(provider); |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
[Theory] |
|
|
[Theory] |
|
|
[WithFile(Bit16Inverted, PixelTypes.Rgba32)] |
|
|
[WithFile(Bit16Inverted, PixelTypes.Rgba32)] |
|
|
@ -65,12 +61,10 @@ namespace SixLabors.ImageSharp.Tests.Formats.Bmp |
|
|
public void BmpDecoder_CanDecode_Inverted<TPixel>(TestImageProvider<TPixel> provider) |
|
|
public void BmpDecoder_CanDecode_Inverted<TPixel>(TestImageProvider<TPixel> provider) |
|
|
where TPixel : struct, IPixel<TPixel> |
|
|
where TPixel : struct, IPixel<TPixel> |
|
|
{ |
|
|
{ |
|
|
using (Image<TPixel> image = provider.GetImage(new BmpDecoder())) |
|
|
using Image<TPixel> image = provider.GetImage(new BmpDecoder()); |
|
|
{ |
|
|
|
|
|
image.DebugSave(provider); |
|
|
image.DebugSave(provider); |
|
|
image.CompareToOriginal(provider); |
|
|
image.CompareToOriginal(provider); |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
[Theory] |
|
|
[Theory] |
|
|
[WithFile(Bit1, PixelTypes.Rgba32)] |
|
|
[WithFile(Bit1, PixelTypes.Rgba32)] |
|
|
@ -78,20 +72,17 @@ namespace SixLabors.ImageSharp.Tests.Formats.Bmp |
|
|
public void BmpDecoder_CanDecode_1Bit<TPixel>(TestImageProvider<TPixel> provider) |
|
|
public void BmpDecoder_CanDecode_1Bit<TPixel>(TestImageProvider<TPixel> provider) |
|
|
where TPixel : struct, IPixel<TPixel> |
|
|
where TPixel : struct, IPixel<TPixel> |
|
|
{ |
|
|
{ |
|
|
using (Image<TPixel> image = provider.GetImage(new BmpDecoder())) |
|
|
using Image<TPixel> image = provider.GetImage(new BmpDecoder()); |
|
|
{ |
|
|
|
|
|
image.DebugSave(provider); |
|
|
image.DebugSave(provider); |
|
|
image.CompareToOriginal(provider, new SystemDrawingReferenceDecoder()); |
|
|
image.CompareToOriginal(provider, new SystemDrawingReferenceDecoder()); |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
[Theory] |
|
|
[Theory] |
|
|
[WithFile(Bit4, PixelTypes.Rgba32)] |
|
|
[WithFile(Bit4, PixelTypes.Rgba32)] |
|
|
public void BmpDecoder_CanDecode_4Bit<TPixel>(TestImageProvider<TPixel> provider) |
|
|
public void BmpDecoder_CanDecode_4Bit<TPixel>(TestImageProvider<TPixel> provider) |
|
|
where TPixel : struct, IPixel<TPixel> |
|
|
where TPixel : struct, IPixel<TPixel> |
|
|
{ |
|
|
{ |
|
|
using (Image<TPixel> image = provider.GetImage(new BmpDecoder())) |
|
|
using Image<TPixel> image = provider.GetImage(new BmpDecoder()); |
|
|
{ |
|
|
|
|
|
image.DebugSave(provider); |
|
|
image.DebugSave(provider); |
|
|
|
|
|
|
|
|
// The Magick Reference Decoder can not decode 4-Bit bitmaps, so only execute this on windows.
|
|
|
// The Magick Reference Decoder can not decode 4-Bit bitmaps, so only execute this on windows.
|
|
|
@ -100,55 +91,46 @@ namespace SixLabors.ImageSharp.Tests.Formats.Bmp |
|
|
image.CompareToOriginal(provider); |
|
|
image.CompareToOriginal(provider); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
[Theory] |
|
|
[Theory] |
|
|
[WithFile(Bit8, PixelTypes.Rgba32)] |
|
|
[WithFile(Bit8, PixelTypes.Rgba32)] |
|
|
public void BmpDecoder_CanDecode_8Bit<TPixel>(TestImageProvider<TPixel> provider) |
|
|
public void BmpDecoder_CanDecode_8Bit<TPixel>(TestImageProvider<TPixel> provider) |
|
|
where TPixel : struct, IPixel<TPixel> |
|
|
where TPixel : struct, IPixel<TPixel> |
|
|
{ |
|
|
{ |
|
|
using (Image<TPixel> image = provider.GetImage(new BmpDecoder())) |
|
|
using Image<TPixel> image = provider.GetImage(new BmpDecoder()); |
|
|
{ |
|
|
|
|
|
image.DebugSave(provider); |
|
|
image.DebugSave(provider); |
|
|
image.CompareToOriginal(provider); |
|
|
image.CompareToOriginal(provider); |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
[Theory] |
|
|
[Theory] |
|
|
[WithFile(Bit16, PixelTypes.Rgba32)] |
|
|
[WithFile(Bit16, PixelTypes.Rgba32)] |
|
|
public void BmpDecoder_CanDecode_16Bit<TPixel>(TestImageProvider<TPixel> provider) |
|
|
public void BmpDecoder_CanDecode_16Bit<TPixel>(TestImageProvider<TPixel> provider) |
|
|
where TPixel : struct, IPixel<TPixel> |
|
|
where TPixel : struct, IPixel<TPixel> |
|
|
{ |
|
|
{ |
|
|
using (Image<TPixel> image = provider.GetImage(new BmpDecoder())) |
|
|
using Image<TPixel> image = provider.GetImage(new BmpDecoder()); |
|
|
{ |
|
|
|
|
|
image.DebugSave(provider); |
|
|
image.DebugSave(provider); |
|
|
image.CompareToOriginal(provider); |
|
|
image.CompareToOriginal(provider); |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
[Theory] |
|
|
[Theory] |
|
|
[WithFile(Bit32Rgb, PixelTypes.Rgba32)] |
|
|
[WithFile(Bit32Rgb, PixelTypes.Rgba32)] |
|
|
public void BmpDecoder_CanDecode_32Bit<TPixel>(TestImageProvider<TPixel> provider) |
|
|
public void BmpDecoder_CanDecode_32Bit<TPixel>(TestImageProvider<TPixel> provider) |
|
|
where TPixel : struct, IPixel<TPixel> |
|
|
where TPixel : struct, IPixel<TPixel> |
|
|
{ |
|
|
{ |
|
|
using (Image<TPixel> image = provider.GetImage(new BmpDecoder())) |
|
|
using Image<TPixel> image = provider.GetImage(new BmpDecoder()); |
|
|
{ |
|
|
|
|
|
image.DebugSave(provider); |
|
|
image.DebugSave(provider); |
|
|
image.CompareToOriginal(provider); |
|
|
image.CompareToOriginal(provider); |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
[Theory] |
|
|
[Theory] |
|
|
[WithFile(Rgba32v4, PixelTypes.Rgba32)] |
|
|
[WithFile(Rgba32v4, PixelTypes.Rgba32)] |
|
|
public void BmpDecoder_CanDecode_32BitV4Header_Fast<TPixel>(TestImageProvider<TPixel> provider) |
|
|
public void BmpDecoder_CanDecode_32BitV4Header_Fast<TPixel>(TestImageProvider<TPixel> provider) |
|
|
where TPixel : struct, IPixel<TPixel> |
|
|
where TPixel : struct, IPixel<TPixel> |
|
|
{ |
|
|
{ |
|
|
using (Image<TPixel> image = provider.GetImage(new BmpDecoder())) |
|
|
using Image<TPixel> image = provider.GetImage(new BmpDecoder()); |
|
|
{ |
|
|
|
|
|
image.DebugSave(provider); |
|
|
image.DebugSave(provider); |
|
|
image.CompareToOriginal(provider); |
|
|
image.CompareToOriginal(provider); |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
[Theory] |
|
|
[Theory] |
|
|
[WithFile(RLE4Cut, PixelTypes.Rgba32)] |
|
|
[WithFile(RLE4Cut, PixelTypes.Rgba32)] |
|
|
@ -157,8 +139,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Bmp |
|
|
public void BmpDecoder_CanDecode_RunLengthEncoded_4Bit_WithDelta<TPixel>(TestImageProvider<TPixel> provider) |
|
|
public void BmpDecoder_CanDecode_RunLengthEncoded_4Bit_WithDelta<TPixel>(TestImageProvider<TPixel> provider) |
|
|
where TPixel : struct, IPixel<TPixel> |
|
|
where TPixel : struct, IPixel<TPixel> |
|
|
{ |
|
|
{ |
|
|
using (Image<TPixel> image = provider.GetImage(new BmpDecoder { RleSkippedPixelHandling = RleSkippedPixelHandling.Black })) |
|
|
using Image<TPixel> image = provider.GetImage(new BmpDecoder { RleSkippedPixelHandling = RleSkippedPixelHandling.Black }); |
|
|
{ |
|
|
|
|
|
image.DebugSave(provider); |
|
|
image.DebugSave(provider); |
|
|
|
|
|
|
|
|
// The Magick Reference Decoder can not decode 4-Bit bitmaps, so only execute this on windows.
|
|
|
// The Magick Reference Decoder can not decode 4-Bit bitmaps, so only execute this on windows.
|
|
|
@ -167,15 +148,13 @@ namespace SixLabors.ImageSharp.Tests.Formats.Bmp |
|
|
image.CompareToOriginal(provider); |
|
|
image.CompareToOriginal(provider); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
[Theory] |
|
|
[Theory] |
|
|
[WithFile(RLE4, PixelTypes.Rgba32)] |
|
|
[WithFile(RLE4, PixelTypes.Rgba32)] |
|
|
public void BmpDecoder_CanDecode_RunLengthEncoded_4Bit<TPixel>(TestImageProvider<TPixel> provider) |
|
|
public void BmpDecoder_CanDecode_RunLengthEncoded_4Bit<TPixel>(TestImageProvider<TPixel> provider) |
|
|
where TPixel : struct, IPixel<TPixel> |
|
|
where TPixel : struct, IPixel<TPixel> |
|
|
{ |
|
|
{ |
|
|
using (Image<TPixel> image = provider.GetImage(new BmpDecoder { RleSkippedPixelHandling = RleSkippedPixelHandling.Black })) |
|
|
using Image<TPixel> image = provider.GetImage(new BmpDecoder { RleSkippedPixelHandling = RleSkippedPixelHandling.Black }); |
|
|
{ |
|
|
|
|
|
image.DebugSave(provider); |
|
|
image.DebugSave(provider); |
|
|
|
|
|
|
|
|
// The Magick Reference Decoder can not decode 4-Bit bitmaps, so only execute this on windows.
|
|
|
// The Magick Reference Decoder can not decode 4-Bit bitmaps, so only execute this on windows.
|
|
|
@ -184,7 +163,6 @@ namespace SixLabors.ImageSharp.Tests.Formats.Bmp |
|
|
image.CompareToOriginal(provider); |
|
|
image.CompareToOriginal(provider); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
[Theory] |
|
|
[Theory] |
|
|
[WithFile(RLE8Cut, PixelTypes.Rgba32)] |
|
|
[WithFile(RLE8Cut, PixelTypes.Rgba32)] |
|
|
@ -194,15 +172,13 @@ namespace SixLabors.ImageSharp.Tests.Formats.Bmp |
|
|
public void BmpDecoder_CanDecode_RunLengthEncoded_8Bit_WithDelta_SystemDrawingRefDecoder<TPixel>(TestImageProvider<TPixel> provider) |
|
|
public void BmpDecoder_CanDecode_RunLengthEncoded_8Bit_WithDelta_SystemDrawingRefDecoder<TPixel>(TestImageProvider<TPixel> provider) |
|
|
where TPixel : struct, IPixel<TPixel> |
|
|
where TPixel : struct, IPixel<TPixel> |
|
|
{ |
|
|
{ |
|
|
using (Image<TPixel> image = provider.GetImage(new BmpDecoder { RleSkippedPixelHandling = RleSkippedPixelHandling.Black })) |
|
|
using Image<TPixel> image = provider.GetImage(new BmpDecoder { RleSkippedPixelHandling = RleSkippedPixelHandling.Black }); |
|
|
{ |
|
|
|
|
|
image.DebugSave(provider); |
|
|
image.DebugSave(provider); |
|
|
if (TestEnvironment.IsWindows) |
|
|
if (TestEnvironment.IsWindows) |
|
|
{ |
|
|
{ |
|
|
image.CompareToOriginal(provider, new SystemDrawingReferenceDecoder()); |
|
|
image.CompareToOriginal(provider, new SystemDrawingReferenceDecoder()); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
[Theory] |
|
|
[Theory] |
|
|
[WithFile(RLE8Cut, PixelTypes.Rgba32)] |
|
|
[WithFile(RLE8Cut, PixelTypes.Rgba32)] |
|
|
@ -210,12 +186,10 @@ namespace SixLabors.ImageSharp.Tests.Formats.Bmp |
|
|
public void BmpDecoder_CanDecode_RunLengthEncoded_8Bit_WithDelta_MagickRefDecoder<TPixel>(TestImageProvider<TPixel> provider) |
|
|
public void BmpDecoder_CanDecode_RunLengthEncoded_8Bit_WithDelta_MagickRefDecoder<TPixel>(TestImageProvider<TPixel> provider) |
|
|
where TPixel : struct, IPixel<TPixel> |
|
|
where TPixel : struct, IPixel<TPixel> |
|
|
{ |
|
|
{ |
|
|
using (Image<TPixel> image = provider.GetImage(new BmpDecoder { RleSkippedPixelHandling = RleSkippedPixelHandling.FirstColorOfPalette })) |
|
|
using Image<TPixel> image = provider.GetImage(new BmpDecoder { RleSkippedPixelHandling = RleSkippedPixelHandling.FirstColorOfPalette }); |
|
|
{ |
|
|
|
|
|
image.DebugSave(provider); |
|
|
image.DebugSave(provider); |
|
|
image.CompareToOriginal(provider, new MagickReferenceDecoder()); |
|
|
image.CompareToOriginal(provider, new MagickReferenceDecoder()); |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
[Theory] |
|
|
[Theory] |
|
|
[WithFile(RLE8, PixelTypes.Rgba32)] |
|
|
[WithFile(RLE8, PixelTypes.Rgba32)] |
|
|
@ -223,12 +197,10 @@ namespace SixLabors.ImageSharp.Tests.Formats.Bmp |
|
|
public void BmpDecoder_CanDecode_RunLengthEncoded_8Bit<TPixel>(TestImageProvider<TPixel> provider) |
|
|
public void BmpDecoder_CanDecode_RunLengthEncoded_8Bit<TPixel>(TestImageProvider<TPixel> provider) |
|
|
where TPixel : struct, IPixel<TPixel> |
|
|
where TPixel : struct, IPixel<TPixel> |
|
|
{ |
|
|
{ |
|
|
using (Image<TPixel> image = provider.GetImage(new BmpDecoder { RleSkippedPixelHandling = RleSkippedPixelHandling.FirstColorOfPalette })) |
|
|
using Image<TPixel> image = provider.GetImage(new BmpDecoder { RleSkippedPixelHandling = RleSkippedPixelHandling.FirstColorOfPalette }); |
|
|
{ |
|
|
|
|
|
image.DebugSave(provider); |
|
|
image.DebugSave(provider); |
|
|
image.CompareToOriginal(provider, new MagickReferenceDecoder()); |
|
|
image.CompareToOriginal(provider, new MagickReferenceDecoder()); |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
[Theory] |
|
|
[Theory] |
|
|
[WithFile(RLE24, PixelTypes.Rgba32)] |
|
|
[WithFile(RLE24, PixelTypes.Rgba32)] |
|
|
@ -237,48 +209,41 @@ namespace SixLabors.ImageSharp.Tests.Formats.Bmp |
|
|
public void BmpDecoder_CanDecode_RunLengthEncoded_24Bit<TPixel>(TestImageProvider<TPixel> provider) |
|
|
public void BmpDecoder_CanDecode_RunLengthEncoded_24Bit<TPixel>(TestImageProvider<TPixel> provider) |
|
|
where TPixel : struct, IPixel<TPixel> |
|
|
where TPixel : struct, IPixel<TPixel> |
|
|
{ |
|
|
{ |
|
|
using (Image<TPixel> image = provider.GetImage(new BmpDecoder { RleSkippedPixelHandling = RleSkippedPixelHandling.Black })) |
|
|
using Image<TPixel> image = provider.GetImage(new BmpDecoder { RleSkippedPixelHandling = RleSkippedPixelHandling.Black }); |
|
|
{ |
|
|
|
|
|
image.DebugSave(provider); |
|
|
image.DebugSave(provider); |
|
|
|
|
|
|
|
|
// TODO: Neither System.Drawing nor MagickReferenceDecoder decode this file.
|
|
|
// TODO: Neither System.Drawing nor MagickReferenceDecoder decode this file.
|
|
|
// image.CompareToOriginal(provider);
|
|
|
// image.CompareToOriginal(provider);
|
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
[Theory] |
|
|
[Theory] |
|
|
[WithFile(RgbaAlphaBitfields, PixelTypes.Rgba32)] |
|
|
[WithFile(RgbaAlphaBitfields, PixelTypes.Rgba32)] |
|
|
public void BmpDecoder_CanDecodeAlphaBitfields<TPixel>(TestImageProvider<TPixel> provider) |
|
|
public void BmpDecoder_CanDecodeAlphaBitfields<TPixel>(TestImageProvider<TPixel> provider) |
|
|
where TPixel : struct, IPixel<TPixel> |
|
|
where TPixel : struct, IPixel<TPixel> |
|
|
{ |
|
|
{ |
|
|
using (Image<TPixel> image = provider.GetImage(new BmpDecoder())) |
|
|
using Image<TPixel> image = provider.GetImage(new BmpDecoder()); |
|
|
{ |
|
|
|
|
|
image.DebugSave(provider); |
|
|
image.DebugSave(provider); |
|
|
|
|
|
|
|
|
// TODO: Neither System.Drawing nor MagickReferenceDecoder decode this file.
|
|
|
// TODO: Neither System.Drawing nor MagickReferenceDecoder decode this file.
|
|
|
// image.CompareToOriginal(provider);
|
|
|
// image.CompareToOriginal(provider);
|
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
[Theory] |
|
|
[Theory] |
|
|
[WithFile(Bit32Rgba, PixelTypes.Rgba32)] |
|
|
[WithFile(Bit32Rgba, PixelTypes.Rgba32)] |
|
|
public void BmpDecoder_CanDecodeBitmap_WithAlphaChannel<TPixel>(TestImageProvider<TPixel> provider) |
|
|
public void BmpDecoder_CanDecodeBitmap_WithAlphaChannel<TPixel>(TestImageProvider<TPixel> provider) |
|
|
where TPixel : struct, IPixel<TPixel> |
|
|
where TPixel : struct, IPixel<TPixel> |
|
|
{ |
|
|
{ |
|
|
using (Image<TPixel> image = provider.GetImage(new BmpDecoder())) |
|
|
using Image<TPixel> image = provider.GetImage(new BmpDecoder()); |
|
|
{ |
|
|
|
|
|
image.DebugSave(provider); |
|
|
image.DebugSave(provider); |
|
|
image.CompareToOriginal(provider, new MagickReferenceDecoder()); |
|
|
image.CompareToOriginal(provider, new MagickReferenceDecoder()); |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
[Theory] |
|
|
[Theory] |
|
|
[WithFile(Rgba321010102, PixelTypes.Rgba32)] |
|
|
[WithFile(Rgba321010102, PixelTypes.Rgba32)] |
|
|
public void BmpDecoder_CanDecodeBitfields_WithUnusualBitmasks<TPixel>(TestImageProvider<TPixel> provider) |
|
|
public void BmpDecoder_CanDecodeBitfields_WithUnusualBitmasks<TPixel>(TestImageProvider<TPixel> provider) |
|
|
where TPixel : struct, IPixel<TPixel> |
|
|
where TPixel : struct, IPixel<TPixel> |
|
|
{ |
|
|
{ |
|
|
using (Image<TPixel> image = provider.GetImage(new BmpDecoder())) |
|
|
using Image<TPixel> image = provider.GetImage(new BmpDecoder()); |
|
|
{ |
|
|
|
|
|
image.DebugSave(provider); |
|
|
image.DebugSave(provider); |
|
|
|
|
|
|
|
|
// Choosing large tolerance of 6.1 here, because for some reason with the MagickReferenceDecoder the alpha channel
|
|
|
// Choosing large tolerance of 6.1 here, because for some reason with the MagickReferenceDecoder the alpha channel
|
|
|
@ -288,7 +253,6 @@ namespace SixLabors.ImageSharp.Tests.Formats.Bmp |
|
|
// Exporting the image as PNG with GIMP yields to the same result as the ImageSharp implementation.
|
|
|
// Exporting the image as PNG with GIMP yields to the same result as the ImageSharp implementation.
|
|
|
image.CompareToOriginal(provider, ImageComparer.TolerantPercentage(6.1f), new MagickReferenceDecoder()); |
|
|
image.CompareToOriginal(provider, ImageComparer.TolerantPercentage(6.1f), new MagickReferenceDecoder()); |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
[Theory] |
|
|
[Theory] |
|
|
[WithFile(WinBmpv2, PixelTypes.Rgba32)] |
|
|
[WithFile(WinBmpv2, PixelTypes.Rgba32)] |
|
|
@ -296,36 +260,30 @@ namespace SixLabors.ImageSharp.Tests.Formats.Bmp |
|
|
public void BmpDecoder_CanDecodeBmpv2<TPixel>(TestImageProvider<TPixel> provider) |
|
|
public void BmpDecoder_CanDecodeBmpv2<TPixel>(TestImageProvider<TPixel> provider) |
|
|
where TPixel : struct, IPixel<TPixel> |
|
|
where TPixel : struct, IPixel<TPixel> |
|
|
{ |
|
|
{ |
|
|
using (Image<TPixel> image = provider.GetImage(new BmpDecoder())) |
|
|
using Image<TPixel> image = provider.GetImage(new BmpDecoder()); |
|
|
{ |
|
|
|
|
|
image.DebugSave(provider); |
|
|
image.DebugSave(provider); |
|
|
image.CompareToOriginal(provider); |
|
|
image.CompareToOriginal(provider); |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
[Theory] |
|
|
[Theory] |
|
|
[WithFile(WinBmpv3, PixelTypes.Rgba32)] |
|
|
[WithFile(WinBmpv3, PixelTypes.Rgba32)] |
|
|
public void BmpDecoder_CanDecodeBmpv3<TPixel>(TestImageProvider<TPixel> provider) |
|
|
public void BmpDecoder_CanDecodeBmpv3<TPixel>(TestImageProvider<TPixel> provider) |
|
|
where TPixel : struct, IPixel<TPixel> |
|
|
where TPixel : struct, IPixel<TPixel> |
|
|
{ |
|
|
{ |
|
|
using (Image<TPixel> image = provider.GetImage(new BmpDecoder())) |
|
|
using Image<TPixel> image = provider.GetImage(new BmpDecoder()); |
|
|
{ |
|
|
|
|
|
image.DebugSave(provider); |
|
|
image.DebugSave(provider); |
|
|
image.CompareToOriginal(provider); |
|
|
image.CompareToOriginal(provider); |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
[Theory] |
|
|
[Theory] |
|
|
[WithFile(LessThanFullSizedPalette, PixelTypes.Rgba32)] |
|
|
[WithFile(LessThanFullSizedPalette, PixelTypes.Rgba32)] |
|
|
public void BmpDecoder_CanDecodeLessThanFullPalette<TPixel>(TestImageProvider<TPixel> provider) |
|
|
public void BmpDecoder_CanDecodeLessThanFullPalette<TPixel>(TestImageProvider<TPixel> provider) |
|
|
where TPixel : struct, IPixel<TPixel> |
|
|
where TPixel : struct, IPixel<TPixel> |
|
|
{ |
|
|
{ |
|
|
using (Image<TPixel> image = provider.GetImage(new BmpDecoder())) |
|
|
using Image<TPixel> image = provider.GetImage(new BmpDecoder()); |
|
|
{ |
|
|
|
|
|
image.DebugSave(provider); |
|
|
image.DebugSave(provider); |
|
|
image.CompareToOriginal(provider, new MagickReferenceDecoder()); |
|
|
image.CompareToOriginal(provider, new MagickReferenceDecoder()); |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
[Theory] |
|
|
[Theory] |
|
|
[WithFile(OversizedPalette, PixelTypes.Rgba32)] |
|
|
[WithFile(OversizedPalette, PixelTypes.Rgba32)] |
|
|
@ -333,15 +291,13 @@ namespace SixLabors.ImageSharp.Tests.Formats.Bmp |
|
|
public void BmpDecoder_CanDecodeOversizedPalette<TPixel>(TestImageProvider<TPixel> provider) |
|
|
public void BmpDecoder_CanDecodeOversizedPalette<TPixel>(TestImageProvider<TPixel> provider) |
|
|
where TPixel : struct, IPixel<TPixel> |
|
|
where TPixel : struct, IPixel<TPixel> |
|
|
{ |
|
|
{ |
|
|
using (Image<TPixel> image = provider.GetImage(new BmpDecoder())) |
|
|
using Image<TPixel> image = provider.GetImage(new BmpDecoder()); |
|
|
{ |
|
|
|
|
|
image.DebugSave(provider); |
|
|
image.DebugSave(provider); |
|
|
if (TestEnvironment.IsWindows) |
|
|
if (TestEnvironment.IsWindows) |
|
|
{ |
|
|
{ |
|
|
image.CompareToOriginal(provider); |
|
|
image.CompareToOriginal(provider); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
[Theory] |
|
|
[Theory] |
|
|
[WithFile(InvalidPaletteSize, PixelTypes.Rgba32)] |
|
|
[WithFile(InvalidPaletteSize, PixelTypes.Rgba32)] |
|
|
@ -375,36 +331,30 @@ namespace SixLabors.ImageSharp.Tests.Formats.Bmp |
|
|
public void BmpDecoder_CanDecodeAdobeBmpv3<TPixel>(TestImageProvider<TPixel> provider) |
|
|
public void BmpDecoder_CanDecodeAdobeBmpv3<TPixel>(TestImageProvider<TPixel> provider) |
|
|
where TPixel : struct, IPixel<TPixel> |
|
|
where TPixel : struct, IPixel<TPixel> |
|
|
{ |
|
|
{ |
|
|
using (Image<TPixel> image = provider.GetImage(new BmpDecoder())) |
|
|
using Image<TPixel> image = provider.GetImage(new BmpDecoder()); |
|
|
{ |
|
|
|
|
|
image.DebugSave(provider); |
|
|
image.DebugSave(provider); |
|
|
image.CompareToOriginal(provider, new MagickReferenceDecoder()); |
|
|
image.CompareToOriginal(provider, new MagickReferenceDecoder()); |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
[Theory] |
|
|
[Theory] |
|
|
[WithFile(Rgba32bf56AdobeV3, PixelTypes.Rgba32)] |
|
|
[WithFile(Rgba32bf56AdobeV3, PixelTypes.Rgba32)] |
|
|
public void BmpDecoder_CanDecodeAdobeBmpv3_WithAlpha<TPixel>(TestImageProvider<TPixel> provider) |
|
|
public void BmpDecoder_CanDecodeAdobeBmpv3_WithAlpha<TPixel>(TestImageProvider<TPixel> provider) |
|
|
where TPixel : struct, IPixel<TPixel> |
|
|
where TPixel : struct, IPixel<TPixel> |
|
|
{ |
|
|
{ |
|
|
using (Image<TPixel> image = provider.GetImage(new BmpDecoder())) |
|
|
using Image<TPixel> image = provider.GetImage(new BmpDecoder()); |
|
|
{ |
|
|
|
|
|
image.DebugSave(provider); |
|
|
image.DebugSave(provider); |
|
|
image.CompareToOriginal(provider, new MagickReferenceDecoder()); |
|
|
image.CompareToOriginal(provider, new MagickReferenceDecoder()); |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
[Theory] |
|
|
[Theory] |
|
|
[WithFile(WinBmpv4, PixelTypes.Rgba32)] |
|
|
[WithFile(WinBmpv4, PixelTypes.Rgba32)] |
|
|
public void BmpDecoder_CanDecodeBmpv4<TPixel>(TestImageProvider<TPixel> provider) |
|
|
public void BmpDecoder_CanDecodeBmpv4<TPixel>(TestImageProvider<TPixel> provider) |
|
|
where TPixel : struct, IPixel<TPixel> |
|
|
where TPixel : struct, IPixel<TPixel> |
|
|
{ |
|
|
{ |
|
|
using (Image<TPixel> image = provider.GetImage(new BmpDecoder())) |
|
|
using Image<TPixel> image = provider.GetImage(new BmpDecoder()); |
|
|
{ |
|
|
|
|
|
image.DebugSave(provider); |
|
|
image.DebugSave(provider); |
|
|
image.CompareToOriginal(provider); |
|
|
image.CompareToOriginal(provider); |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
[Theory] |
|
|
[Theory] |
|
|
[WithFile(WinBmpv5, PixelTypes.Rgba32)] |
|
|
[WithFile(WinBmpv5, PixelTypes.Rgba32)] |
|
|
@ -412,48 +362,40 @@ namespace SixLabors.ImageSharp.Tests.Formats.Bmp |
|
|
public void BmpDecoder_CanDecodeBmpv5<TPixel>(TestImageProvider<TPixel> provider) |
|
|
public void BmpDecoder_CanDecodeBmpv5<TPixel>(TestImageProvider<TPixel> provider) |
|
|
where TPixel : struct, IPixel<TPixel> |
|
|
where TPixel : struct, IPixel<TPixel> |
|
|
{ |
|
|
{ |
|
|
using (Image<TPixel> image = provider.GetImage(new BmpDecoder())) |
|
|
using Image<TPixel> image = provider.GetImage(new BmpDecoder()); |
|
|
{ |
|
|
|
|
|
image.DebugSave(provider); |
|
|
image.DebugSave(provider); |
|
|
image.CompareToOriginal(provider); |
|
|
image.CompareToOriginal(provider); |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
[Theory] |
|
|
[Theory] |
|
|
[WithFile(Pal8Offset, PixelTypes.Rgba32)] |
|
|
[WithFile(Pal8Offset, PixelTypes.Rgba32)] |
|
|
public void BmpDecoder_RespectsFileHeaderOffset<TPixel>(TestImageProvider<TPixel> provider) |
|
|
public void BmpDecoder_RespectsFileHeaderOffset<TPixel>(TestImageProvider<TPixel> provider) |
|
|
where TPixel : struct, IPixel<TPixel> |
|
|
where TPixel : struct, IPixel<TPixel> |
|
|
{ |
|
|
{ |
|
|
using (Image<TPixel> image = provider.GetImage(new BmpDecoder())) |
|
|
using Image<TPixel> image = provider.GetImage(new BmpDecoder()); |
|
|
{ |
|
|
|
|
|
image.DebugSave(provider); |
|
|
image.DebugSave(provider); |
|
|
image.CompareToOriginal(provider); |
|
|
image.CompareToOriginal(provider); |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
[Theory] |
|
|
[Theory] |
|
|
[WithFile(F, CommonNonDefaultPixelTypes)] |
|
|
[WithFile(F, CommonNonDefaultPixelTypes)] |
|
|
public void BmpDecoder_IsNotBoundToSinglePixelType<TPixel>(TestImageProvider<TPixel> provider) |
|
|
public void BmpDecoder_IsNotBoundToSinglePixelType<TPixel>(TestImageProvider<TPixel> provider) |
|
|
where TPixel : struct, IPixel<TPixel> |
|
|
where TPixel : struct, IPixel<TPixel> |
|
|
{ |
|
|
{ |
|
|
using (Image<TPixel> image = provider.GetImage(new BmpDecoder())) |
|
|
using Image<TPixel> image = provider.GetImage(new BmpDecoder()); |
|
|
{ |
|
|
|
|
|
image.DebugSave(provider); |
|
|
image.DebugSave(provider); |
|
|
image.CompareToOriginal(provider); |
|
|
image.CompareToOriginal(provider); |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
[Theory] |
|
|
[Theory] |
|
|
[WithFile(Bit8Palette4, PixelTypes.Rgba32)] |
|
|
[WithFile(Bit8Palette4, PixelTypes.Rgba32)] |
|
|
public void BmpDecoder_CanDecode4BytePerEntryPalette<TPixel>(TestImageProvider<TPixel> provider) |
|
|
public void BmpDecoder_CanDecode4BytePerEntryPalette<TPixel>(TestImageProvider<TPixel> provider) |
|
|
where TPixel : struct, IPixel<TPixel> |
|
|
where TPixel : struct, IPixel<TPixel> |
|
|
{ |
|
|
{ |
|
|
using (Image<TPixel> image = provider.GetImage(new BmpDecoder())) |
|
|
using Image<TPixel> image = provider.GetImage(new BmpDecoder()); |
|
|
{ |
|
|
|
|
|
image.DebugSave(provider); |
|
|
image.DebugSave(provider); |
|
|
image.CompareToOriginal(provider); |
|
|
image.CompareToOriginal(provider); |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
[Theory] |
|
|
[Theory] |
|
|
[InlineData(Bit32Rgb, 32)] |
|
|
[InlineData(Bit32Rgb, 32)] |
|
|
@ -471,13 +413,11 @@ namespace SixLabors.ImageSharp.Tests.Formats.Bmp |
|
|
public void Identify_DetectsCorrectPixelType(string imagePath, int expectedPixelSize) |
|
|
public void Identify_DetectsCorrectPixelType(string imagePath, int expectedPixelSize) |
|
|
{ |
|
|
{ |
|
|
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); |
|
|
{ |
|
|
|
|
|
IImageInfo imageInfo = Image.Identify(stream); |
|
|
IImageInfo imageInfo = Image.Identify(stream); |
|
|
Assert.NotNull(imageInfo); |
|
|
Assert.NotNull(imageInfo); |
|
|
Assert.Equal(expectedPixelSize, imageInfo.PixelType?.BitsPerPixel); |
|
|
Assert.Equal(expectedPixelSize, imageInfo.PixelType?.BitsPerPixel); |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
[Theory] |
|
|
[Theory] |
|
|
[InlineData(Bit32Rgb, 127, 64)] |
|
|
[InlineData(Bit32Rgb, 127, 64)] |
|
|
@ -491,54 +431,45 @@ namespace SixLabors.ImageSharp.Tests.Formats.Bmp |
|
|
public void Identify_DetectsCorrectWidthAndHeight(string imagePath, int expectedWidth, int expectedHeight) |
|
|
public void Identify_DetectsCorrectWidthAndHeight(string imagePath, int expectedWidth, int expectedHeight) |
|
|
{ |
|
|
{ |
|
|
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); |
|
|
{ |
|
|
|
|
|
IImageInfo imageInfo = Image.Identify(stream); |
|
|
IImageInfo imageInfo = Image.Identify(stream); |
|
|
Assert.NotNull(imageInfo); |
|
|
Assert.NotNull(imageInfo); |
|
|
Assert.Equal(expectedWidth, imageInfo.Width); |
|
|
Assert.Equal(expectedWidth, imageInfo.Width); |
|
|
Assert.Equal(expectedHeight, imageInfo.Height); |
|
|
Assert.Equal(expectedHeight, imageInfo.Height); |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
[Theory] |
|
|
[Theory] |
|
|
[MemberData(nameof(RatioFiles))] |
|
|
[MemberData(nameof(RatioFiles))] |
|
|
public void Decode_VerifyRatio(string imagePath, int xResolution, int yResolution, PixelResolutionUnit resolutionUnit) |
|
|
public void Decode_VerifyRatio(string imagePath, int xResolution, int yResolution, PixelResolutionUnit resolutionUnit) |
|
|
{ |
|
|
{ |
|
|
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(); |
|
|
using (Image<Rgba32> image = decoder.Decode<Rgba32>(Configuration.Default, stream)) |
|
|
using Image<Rgba32> image = decoder.Decode<Rgba32>(Configuration.Default, stream); |
|
|
{ |
|
|
|
|
|
ImageMetadata meta = image.Metadata; |
|
|
ImageMetadata meta = image.Metadata; |
|
|
Assert.Equal(xResolution, meta.HorizontalResolution); |
|
|
Assert.Equal(xResolution, meta.HorizontalResolution); |
|
|
Assert.Equal(yResolution, meta.VerticalResolution); |
|
|
Assert.Equal(yResolution, meta.VerticalResolution); |
|
|
Assert.Equal(resolutionUnit, meta.ResolutionUnits); |
|
|
Assert.Equal(resolutionUnit, meta.ResolutionUnits); |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
[Theory] |
|
|
[Theory] |
|
|
[WithFile(Os2v2Short, PixelTypes.Rgba32)] |
|
|
[WithFile(Os2v2Short, PixelTypes.Rgba32)] |
|
|
public void BmpDecoder_CanDecode_Os2v2XShortHeader<TPixel>(TestImageProvider<TPixel> provider) |
|
|
public void BmpDecoder_CanDecode_Os2v2XShortHeader<TPixel>(TestImageProvider<TPixel> provider) |
|
|
where TPixel : struct, IPixel<TPixel> |
|
|
where TPixel : struct, IPixel<TPixel> |
|
|
{ |
|
|
{ |
|
|
using (Image<TPixel> image = provider.GetImage(new BmpDecoder())) |
|
|
using Image<TPixel> image = provider.GetImage(new BmpDecoder()); |
|
|
{ |
|
|
|
|
|
image.DebugSave(provider); |
|
|
image.DebugSave(provider); |
|
|
|
|
|
|
|
|
// TODO: Neither System.Drawing or MagickReferenceDecoder can correctly decode this file.
|
|
|
// TODO: Neither System.Drawing or MagickReferenceDecoder can correctly decode this file.
|
|
|
// image.CompareToOriginal(provider);
|
|
|
// image.CompareToOriginal(provider);
|
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
[Theory] |
|
|
[Theory] |
|
|
[WithFile(Os2v2, PixelTypes.Rgba32)] |
|
|
[WithFile(Os2v2, PixelTypes.Rgba32)] |
|
|
public void BmpDecoder_CanDecode_Os2v2Header<TPixel>(TestImageProvider<TPixel> provider) |
|
|
public void BmpDecoder_CanDecode_Os2v2Header<TPixel>(TestImageProvider<TPixel> provider) |
|
|
where TPixel : struct, IPixel<TPixel> |
|
|
where TPixel : struct, IPixel<TPixel> |
|
|
{ |
|
|
{ |
|
|
using (Image<TPixel> image = provider.GetImage(new BmpDecoder())) |
|
|
using Image<TPixel> image = provider.GetImage(new BmpDecoder()); |
|
|
{ |
|
|
|
|
|
image.DebugSave(provider); |
|
|
image.DebugSave(provider); |
|
|
|
|
|
|
|
|
// TODO: System.Drawing can not decode this image. MagickReferenceDecoder can decode it,
|
|
|
// TODO: System.Drawing can not decode this image. MagickReferenceDecoder can decode it,
|
|
|
@ -546,7 +477,6 @@ namespace SixLabors.ImageSharp.Tests.Formats.Bmp |
|
|
// The results are the same as the image sharp implementation.
|
|
|
// The results are the same as the image sharp implementation.
|
|
|
// image.CompareToOriginal(provider, new MagickReferenceDecoder());
|
|
|
// image.CompareToOriginal(provider, new MagickReferenceDecoder());
|
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
[Theory] |
|
|
[Theory] |
|
|
[WithFile(Os2BitmapArray, PixelTypes.Rgba32)] |
|
|
[WithFile(Os2BitmapArray, PixelTypes.Rgba32)] |
|
|
@ -561,8 +491,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Bmp |
|
|
public void BmpDecoder_CanDecode_Os2BitmapArray<TPixel>(TestImageProvider<TPixel> provider) |
|
|
public void BmpDecoder_CanDecode_Os2BitmapArray<TPixel>(TestImageProvider<TPixel> provider) |
|
|
where TPixel : struct, IPixel<TPixel> |
|
|
where TPixel : struct, IPixel<TPixel> |
|
|
{ |
|
|
{ |
|
|
using (Image<TPixel> image = provider.GetImage(new BmpDecoder())) |
|
|
using Image<TPixel> image = provider.GetImage(new BmpDecoder()); |
|
|
{ |
|
|
|
|
|
image.DebugSave(provider); |
|
|
image.DebugSave(provider); |
|
|
|
|
|
|
|
|
// TODO: Neither System.Drawing or MagickReferenceDecoder can correctly decode this file.
|
|
|
// TODO: Neither System.Drawing or MagickReferenceDecoder can correctly decode this file.
|
|
|
@ -570,4 +499,3 @@ namespace SixLabors.ImageSharp.Tests.Formats.Bmp |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|