|
|
@ -4,7 +4,7 @@ |
|
|
using System; |
|
|
using System; |
|
|
using System.IO; |
|
|
using System.IO; |
|
|
using Microsoft.DotNet.RemoteExecutor; |
|
|
using Microsoft.DotNet.RemoteExecutor; |
|
|
|
|
|
using SixLabors.ImageSharp.Formats; |
|
|
using SixLabors.ImageSharp.Formats.Bmp; |
|
|
using SixLabors.ImageSharp.Formats.Bmp; |
|
|
using SixLabors.ImageSharp.Memory; |
|
|
using SixLabors.ImageSharp.Memory; |
|
|
using SixLabors.ImageSharp.Metadata; |
|
|
using SixLabors.ImageSharp.Metadata; |
|
|
@ -75,11 +75,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Bmp |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
string providerDump = BasicSerializer.Serialize(provider); |
|
|
string providerDump = BasicSerializer.Serialize(provider); |
|
|
RemoteExecutor.Invoke( |
|
|
RemoteExecutor.Invoke(RunTest, providerDump, "Disco").Dispose(); |
|
|
RunTest, |
|
|
|
|
|
providerDump, |
|
|
|
|
|
"Disco") |
|
|
|
|
|
.Dispose(); |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
[Theory] |
|
|
[Theory] |
|
|
@ -98,12 +94,10 @@ namespace SixLabors.ImageSharp.Tests.Formats.Bmp |
|
|
public void BmpDecoder_CanDecodeBitfields<TPixel>(TestImageProvider<TPixel> provider) |
|
|
public void BmpDecoder_CanDecodeBitfields<TPixel>(TestImageProvider<TPixel> provider) |
|
|
where TPixel : unmanaged, IPixel<TPixel> |
|
|
where TPixel : unmanaged, IPixel<TPixel> |
|
|
{ |
|
|
{ |
|
|
using (Image<TPixel> image = provider.GetImage(BmpDecoder)) |
|
|
using Image<TPixel> image = provider.GetImage(BmpDecoder); |
|
|
{ |
|
|
|
|
|
image.DebugSave(provider); |
|
|
image.DebugSave(provider); |
|
|
image.CompareToOriginal(provider); |
|
|
image.CompareToOriginal(provider); |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
[Theory] |
|
|
[Theory] |
|
|
[WithFile(Bit16Inverted, PixelTypes.Rgba32)] |
|
|
[WithFile(Bit16Inverted, PixelTypes.Rgba32)] |
|
|
@ -111,12 +105,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 : unmanaged, IPixel<TPixel> |
|
|
where TPixel : unmanaged, IPixel<TPixel> |
|
|
{ |
|
|
{ |
|
|
using (Image<TPixel> image = provider.GetImage(BmpDecoder)) |
|
|
using Image<TPixel> image = provider.GetImage(BmpDecoder); |
|
|
{ |
|
|
|
|
|
image.DebugSave(provider); |
|
|
image.DebugSave(provider); |
|
|
image.CompareToOriginal(provider); |
|
|
image.CompareToOriginal(provider); |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
[Theory] |
|
|
[Theory] |
|
|
[WithFile(Bit1, PixelTypes.Rgba32)] |
|
|
[WithFile(Bit1, PixelTypes.Rgba32)] |
|
|
@ -124,72 +116,60 @@ 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 : unmanaged, IPixel<TPixel> |
|
|
where TPixel : unmanaged, IPixel<TPixel> |
|
|
{ |
|
|
{ |
|
|
using (Image<TPixel> image = provider.GetImage(BmpDecoder)) |
|
|
using Image<TPixel> image = provider.GetImage(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 : unmanaged, IPixel<TPixel> |
|
|
where TPixel : unmanaged, IPixel<TPixel> |
|
|
{ |
|
|
{ |
|
|
using (Image<TPixel> image = provider.GetImage(BmpDecoder)) |
|
|
using Image<TPixel> image = provider.GetImage(BmpDecoder); |
|
|
{ |
|
|
|
|
|
image.DebugSave(provider); |
|
|
image.DebugSave(provider); |
|
|
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 : unmanaged, IPixel<TPixel> |
|
|
where TPixel : unmanaged, IPixel<TPixel> |
|
|
{ |
|
|
{ |
|
|
using (Image<TPixel> image = provider.GetImage(BmpDecoder)) |
|
|
using Image<TPixel> image = provider.GetImage(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 : unmanaged, IPixel<TPixel> |
|
|
where TPixel : unmanaged, IPixel<TPixel> |
|
|
{ |
|
|
{ |
|
|
using (Image<TPixel> image = provider.GetImage(BmpDecoder)) |
|
|
using Image<TPixel> image = provider.GetImage(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 : unmanaged, IPixel<TPixel> |
|
|
where TPixel : unmanaged, IPixel<TPixel> |
|
|
{ |
|
|
{ |
|
|
using (Image<TPixel> image = provider.GetImage(BmpDecoder)) |
|
|
using Image<TPixel> image = provider.GetImage(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 : unmanaged, IPixel<TPixel> |
|
|
where TPixel : unmanaged, IPixel<TPixel> |
|
|
{ |
|
|
{ |
|
|
using (Image<TPixel> image = provider.GetImage(BmpDecoder)) |
|
|
using Image<TPixel> image = provider.GetImage(BmpDecoder); |
|
|
{ |
|
|
|
|
|
image.DebugSave(provider); |
|
|
image.DebugSave(provider); |
|
|
image.CompareToOriginal(provider); |
|
|
image.CompareToOriginal(provider); |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
[Theory] |
|
|
[Theory] |
|
|
[WithFile(RLE4Cut, PixelTypes.Rgba32)] |
|
|
[WithFile(RLE4Cut, PixelTypes.Rgba32)] |
|
|
@ -199,12 +179,12 @@ namespace SixLabors.ImageSharp.Tests.Formats.Bmp |
|
|
where TPixel : unmanaged, IPixel<TPixel> |
|
|
where TPixel : unmanaged, IPixel<TPixel> |
|
|
{ |
|
|
{ |
|
|
RleSkippedPixelHandling skippedPixelHandling = TestEnvironment.IsWindows ? RleSkippedPixelHandling.Black : RleSkippedPixelHandling.FirstColorOfPalette; |
|
|
RleSkippedPixelHandling skippedPixelHandling = TestEnvironment.IsWindows ? RleSkippedPixelHandling.Black : RleSkippedPixelHandling.FirstColorOfPalette; |
|
|
using (Image<TPixel> image = provider.GetImage(new BmpDecoder { RleSkippedPixelHandling = skippedPixelHandling })) |
|
|
BmpDecoderOptions options = new() { RleSkippedPixelHandling = skippedPixelHandling }; |
|
|
{ |
|
|
|
|
|
|
|
|
using Image<TPixel> image = provider.GetImage(BmpDecoder, options); |
|
|
image.DebugSave(provider); |
|
|
image.DebugSave(provider); |
|
|
image.CompareToOriginal(provider); |
|
|
image.CompareToOriginal(provider); |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
[Theory] |
|
|
[Theory] |
|
|
[WithFile(RLE4, PixelTypes.Rgba32)] |
|
|
[WithFile(RLE4, PixelTypes.Rgba32)] |
|
|
@ -212,12 +192,12 @@ namespace SixLabors.ImageSharp.Tests.Formats.Bmp |
|
|
where TPixel : unmanaged, IPixel<TPixel> |
|
|
where TPixel : unmanaged, IPixel<TPixel> |
|
|
{ |
|
|
{ |
|
|
RleSkippedPixelHandling skippedPixelHandling = TestEnvironment.IsWindows ? RleSkippedPixelHandling.Black : RleSkippedPixelHandling.FirstColorOfPalette; |
|
|
RleSkippedPixelHandling skippedPixelHandling = TestEnvironment.IsWindows ? RleSkippedPixelHandling.Black : RleSkippedPixelHandling.FirstColorOfPalette; |
|
|
using (Image<TPixel> image = provider.GetImage(new BmpDecoder { RleSkippedPixelHandling = skippedPixelHandling })) |
|
|
BmpDecoderOptions options = new() { RleSkippedPixelHandling = skippedPixelHandling }; |
|
|
{ |
|
|
|
|
|
|
|
|
using Image<TPixel> image = provider.GetImage(BmpDecoder, options); |
|
|
image.DebugSave(provider); |
|
|
image.DebugSave(provider); |
|
|
image.CompareToOriginal(provider); |
|
|
image.CompareToOriginal(provider); |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
[Theory] |
|
|
[Theory] |
|
|
[WithFile(RLE8Cut, PixelTypes.Rgba32)] |
|
|
[WithFile(RLE8Cut, PixelTypes.Rgba32)] |
|
|
@ -227,15 +207,14 @@ 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 : unmanaged, IPixel<TPixel> |
|
|
where TPixel : unmanaged, IPixel<TPixel> |
|
|
{ |
|
|
{ |
|
|
using (Image<TPixel> image = provider.GetImage(new BmpDecoder { RleSkippedPixelHandling = RleSkippedPixelHandling.Black })) |
|
|
BmpDecoderOptions options = new() { RleSkippedPixelHandling = RleSkippedPixelHandling.Black }; |
|
|
{ |
|
|
using Image<TPixel> image = provider.GetImage(BmpDecoder, options); |
|
|
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)] |
|
|
@ -243,12 +222,11 @@ 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 : unmanaged, IPixel<TPixel> |
|
|
where TPixel : unmanaged, IPixel<TPixel> |
|
|
{ |
|
|
{ |
|
|
using (Image<TPixel> image = provider.GetImage(new BmpDecoder { RleSkippedPixelHandling = RleSkippedPixelHandling.FirstColorOfPalette })) |
|
|
BmpDecoderOptions options = new() { RleSkippedPixelHandling = RleSkippedPixelHandling.FirstColorOfPalette }; |
|
|
{ |
|
|
using Image<TPixel> image = provider.GetImage(BmpDecoder, options); |
|
|
image.DebugSave(provider); |
|
|
image.DebugSave(provider); |
|
|
image.CompareToOriginal(provider, new MagickReferenceDecoder()); |
|
|
image.CompareToOriginal(provider, new MagickReferenceDecoder()); |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
[Theory] |
|
|
[Theory] |
|
|
[WithFile(RLE8, PixelTypes.Rgba32, false)] |
|
|
[WithFile(RLE8, PixelTypes.Rgba32, false)] |
|
|
@ -263,12 +241,11 @@ namespace SixLabors.ImageSharp.Tests.Formats.Bmp |
|
|
provider.LimitAllocatorBufferCapacity().InBytesSqrt(400); |
|
|
provider.LimitAllocatorBufferCapacity().InBytesSqrt(400); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
using (Image<TPixel> image = provider.GetImage(new BmpDecoder { RleSkippedPixelHandling = RleSkippedPixelHandling.FirstColorOfPalette })) |
|
|
BmpDecoderOptions options = new() { RleSkippedPixelHandling = RleSkippedPixelHandling.FirstColorOfPalette }; |
|
|
{ |
|
|
using Image<TPixel> image = provider.GetImage(BmpDecoder, options); |
|
|
image.DebugSave(provider); |
|
|
image.DebugSave(provider); |
|
|
image.CompareToOriginal(provider, new MagickReferenceDecoder()); |
|
|
image.CompareToOriginal(provider, new MagickReferenceDecoder()); |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
[Theory] |
|
|
[Theory] |
|
|
[WithFile(RLE24, PixelTypes.Rgba32, false)] |
|
|
[WithFile(RLE24, PixelTypes.Rgba32, false)] |
|
|
@ -285,48 +262,42 @@ namespace SixLabors.ImageSharp.Tests.Formats.Bmp |
|
|
provider.LimitAllocatorBufferCapacity().InBytesSqrt(400); |
|
|
provider.LimitAllocatorBufferCapacity().InBytesSqrt(400); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
using (Image<TPixel> image = provider.GetImage(new BmpDecoder { RleSkippedPixelHandling = RleSkippedPixelHandling.Black })) |
|
|
BmpDecoderOptions options = new() { RleSkippedPixelHandling = RleSkippedPixelHandling.Black }; |
|
|
{ |
|
|
using Image<TPixel> image = provider.GetImage(BmpDecoder, options); |
|
|
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 : unmanaged, IPixel<TPixel> |
|
|
where TPixel : unmanaged, IPixel<TPixel> |
|
|
{ |
|
|
{ |
|
|
using (Image<TPixel> image = provider.GetImage(BmpDecoder)) |
|
|
using Image<TPixel> image = provider.GetImage(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 : unmanaged, IPixel<TPixel> |
|
|
where TPixel : unmanaged, IPixel<TPixel> |
|
|
{ |
|
|
{ |
|
|
using (Image<TPixel> image = provider.GetImage(BmpDecoder)) |
|
|
using Image<TPixel> image = provider.GetImage(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 : unmanaged, IPixel<TPixel> |
|
|
where TPixel : unmanaged, IPixel<TPixel> |
|
|
{ |
|
|
{ |
|
|
using (Image<TPixel> image = provider.GetImage(BmpDecoder)) |
|
|
using Image<TPixel> image = provider.GetImage(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
|
|
|
@ -336,7 +307,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)] |
|
|
@ -344,38 +314,32 @@ namespace SixLabors.ImageSharp.Tests.Formats.Bmp |
|
|
public void BmpDecoder_CanDecodeBmpv2<TPixel>(TestImageProvider<TPixel> provider) |
|
|
public void BmpDecoder_CanDecodeBmpv2<TPixel>(TestImageProvider<TPixel> provider) |
|
|
where TPixel : unmanaged, IPixel<TPixel> |
|
|
where TPixel : unmanaged, IPixel<TPixel> |
|
|
{ |
|
|
{ |
|
|
using (Image<TPixel> image = provider.GetImage(BmpDecoder)) |
|
|
using Image<TPixel> image = provider.GetImage(BmpDecoder); |
|
|
{ |
|
|
|
|
|
image.DebugSave(provider); |
|
|
image.DebugSave(provider); |
|
|
|
|
|
|
|
|
// Do not validate. Reference files will fail validation.
|
|
|
// Do not validate. Reference files will fail validation.
|
|
|
image.CompareToOriginal(provider, new MagickReferenceDecoder(false)); |
|
|
image.CompareToOriginal(provider, new MagickReferenceDecoder(false)); |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
[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 : unmanaged, IPixel<TPixel> |
|
|
where TPixel : unmanaged, IPixel<TPixel> |
|
|
{ |
|
|
{ |
|
|
using (Image<TPixel> image = provider.GetImage(BmpDecoder)) |
|
|
using Image<TPixel> image = provider.GetImage(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 : unmanaged, IPixel<TPixel> |
|
|
where TPixel : unmanaged, IPixel<TPixel> |
|
|
{ |
|
|
{ |
|
|
using (Image<TPixel> image = provider.GetImage(BmpDecoder)) |
|
|
using Image<TPixel> image = provider.GetImage(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)] |
|
|
@ -383,78 +347,66 @@ namespace SixLabors.ImageSharp.Tests.Formats.Bmp |
|
|
public void BmpDecoder_CanDecodeOversizedPalette<TPixel>(TestImageProvider<TPixel> provider) |
|
|
public void BmpDecoder_CanDecodeOversizedPalette<TPixel>(TestImageProvider<TPixel> provider) |
|
|
where TPixel : unmanaged, IPixel<TPixel> |
|
|
where TPixel : unmanaged, IPixel<TPixel> |
|
|
{ |
|
|
{ |
|
|
using (Image<TPixel> image = provider.GetImage(BmpDecoder)) |
|
|
using Image<TPixel> image = provider.GetImage(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)] |
|
|
public void BmpDecoder_ThrowsInvalidImageContentException_OnInvalidPaletteSize<TPixel>(TestImageProvider<TPixel> provider) |
|
|
public void BmpDecoder_ThrowsInvalidImageContentException_OnInvalidPaletteSize<TPixel>(TestImageProvider<TPixel> provider) |
|
|
where TPixel : unmanaged, IPixel<TPixel> |
|
|
where TPixel : unmanaged, IPixel<TPixel> |
|
|
{ |
|
|
=> Assert.Throws<InvalidImageContentException>(() => |
|
|
Assert.Throws<InvalidImageContentException>(() => |
|
|
|
|
|
{ |
|
|
{ |
|
|
using (provider.GetImage(BmpDecoder)) |
|
|
using (provider.GetImage(BmpDecoder)) |
|
|
{ |
|
|
{ |
|
|
} |
|
|
} |
|
|
}); |
|
|
}); |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
[Theory] |
|
|
[Theory] |
|
|
[WithFile(Rgb24jpeg, PixelTypes.Rgba32)] |
|
|
[WithFile(Rgb24jpeg, PixelTypes.Rgba32)] |
|
|
[WithFile(Rgb24png, PixelTypes.Rgba32)] |
|
|
[WithFile(Rgb24png, PixelTypes.Rgba32)] |
|
|
public void BmpDecoder_ThrowsNotSupportedException_OnUnsupportedBitmaps<TPixel>(TestImageProvider<TPixel> provider) |
|
|
public void BmpDecoder_ThrowsNotSupportedException_OnUnsupportedBitmaps<TPixel>(TestImageProvider<TPixel> provider) |
|
|
where TPixel : unmanaged, IPixel<TPixel> |
|
|
where TPixel : unmanaged, IPixel<TPixel> |
|
|
{ |
|
|
=> Assert.Throws<NotSupportedException>(() => |
|
|
Assert.Throws<NotSupportedException>(() => |
|
|
|
|
|
{ |
|
|
{ |
|
|
using (provider.GetImage(BmpDecoder)) |
|
|
using (provider.GetImage(BmpDecoder)) |
|
|
{ |
|
|
{ |
|
|
} |
|
|
} |
|
|
}); |
|
|
}); |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
[Theory] |
|
|
[Theory] |
|
|
[WithFile(Rgb32h52AdobeV3, PixelTypes.Rgba32)] |
|
|
[WithFile(Rgb32h52AdobeV3, PixelTypes.Rgba32)] |
|
|
public void BmpDecoder_CanDecodeAdobeBmpv3<TPixel>(TestImageProvider<TPixel> provider) |
|
|
public void BmpDecoder_CanDecodeAdobeBmpv3<TPixel>(TestImageProvider<TPixel> provider) |
|
|
where TPixel : unmanaged, IPixel<TPixel> |
|
|
where TPixel : unmanaged, IPixel<TPixel> |
|
|
{ |
|
|
{ |
|
|
using (Image<TPixel> image = provider.GetImage(BmpDecoder)) |
|
|
using Image<TPixel> image = provider.GetImage(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 : unmanaged, IPixel<TPixel> |
|
|
where TPixel : unmanaged, IPixel<TPixel> |
|
|
{ |
|
|
{ |
|
|
using (Image<TPixel> image = provider.GetImage(BmpDecoder)) |
|
|
using Image<TPixel> image = provider.GetImage(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 : unmanaged, IPixel<TPixel> |
|
|
where TPixel : unmanaged, IPixel<TPixel> |
|
|
{ |
|
|
{ |
|
|
using (Image<TPixel> image = provider.GetImage(BmpDecoder)) |
|
|
using Image<TPixel> image = provider.GetImage(BmpDecoder); |
|
|
{ |
|
|
|
|
|
image.DebugSave(provider); |
|
|
image.DebugSave(provider); |
|
|
image.CompareToOriginal(provider); |
|
|
image.CompareToOriginal(provider); |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
[Theory] |
|
|
[Theory] |
|
|
[WithFile(WinBmpv5, PixelTypes.Rgba32)] |
|
|
[WithFile(WinBmpv5, PixelTypes.Rgba32)] |
|
|
@ -462,48 +414,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 : unmanaged, IPixel<TPixel> |
|
|
where TPixel : unmanaged, IPixel<TPixel> |
|
|
{ |
|
|
{ |
|
|
using (Image<TPixel> image = provider.GetImage(BmpDecoder)) |
|
|
using Image<TPixel> image = provider.GetImage(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 : unmanaged, IPixel<TPixel> |
|
|
where TPixel : unmanaged, IPixel<TPixel> |
|
|
{ |
|
|
{ |
|
|
using (Image<TPixel> image = provider.GetImage(BmpDecoder)) |
|
|
using Image<TPixel> image = provider.GetImage(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 : unmanaged, IPixel<TPixel> |
|
|
where TPixel : unmanaged, IPixel<TPixel> |
|
|
{ |
|
|
{ |
|
|
using (Image<TPixel> image = provider.GetImage(BmpDecoder)) |
|
|
using Image<TPixel> image = provider.GetImage(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 : unmanaged, IPixel<TPixel> |
|
|
where TPixel : unmanaged, IPixel<TPixel> |
|
|
{ |
|
|
{ |
|
|
using (Image<TPixel> image = provider.GetImage(BmpDecoder)) |
|
|
using Image<TPixel> image = provider.GetImage(BmpDecoder); |
|
|
{ |
|
|
|
|
|
image.DebugSave(provider); |
|
|
image.DebugSave(provider); |
|
|
image.CompareToOriginal(provider); |
|
|
image.CompareToOriginal(provider); |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
[Theory] |
|
|
[Theory] |
|
|
[InlineData(Bit32Rgb, 32)] |
|
|
[InlineData(Bit32Rgb, 32)] |
|
|
@ -521,13 +465,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)] |
|
|
@ -541,54 +483,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, default)) |
|
|
using Image<Rgba32> image = decoder.Decode<Rgba32>(DecoderOptions.Default, stream, default); |
|
|
{ |
|
|
|
|
|
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 : unmanaged, IPixel<TPixel> |
|
|
where TPixel : unmanaged, IPixel<TPixel> |
|
|
{ |
|
|
{ |
|
|
using (Image<TPixel> image = provider.GetImage(BmpDecoder)) |
|
|
using Image<TPixel> image = provider.GetImage(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 : unmanaged, IPixel<TPixel> |
|
|
where TPixel : unmanaged, IPixel<TPixel> |
|
|
{ |
|
|
{ |
|
|
using (Image<TPixel> image = provider.GetImage(BmpDecoder)) |
|
|
using Image<TPixel> image = provider.GetImage(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,
|
|
|
@ -596,7 +529,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)] |
|
|
@ -611,13 +543,11 @@ 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 : unmanaged, IPixel<TPixel> |
|
|
where TPixel : unmanaged, IPixel<TPixel> |
|
|
{ |
|
|
{ |
|
|
using (Image<TPixel> image = provider.GetImage(BmpDecoder)) |
|
|
using Image<TPixel> image = provider.GetImage(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);
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
} |
|
|
} |
|
|
|