@ -37,11 +37,13 @@ namespace SixLabors.ImageSharp.Tests.Formats.Bmp
public void BmpDecoder_CanDecode_MiscellaneousBitmaps < TPixel > ( TestImageProvider < TPixel > provider )
where TPixel : struct , IPixel < TPixel >
{
using Image < TPixel > image = provider . GetImage ( new BmpDecoder ( ) ) ;
image . DebugSave ( provider ) ;
if ( TestEnvironment . IsWindows )
using ( Image < TPixel > image = provider . GetImage ( new BmpDecoder ( ) ) )
{
image . CompareToOriginal ( provider ) ;
image . DebugSave ( provider ) ;
if ( TestEnvironment . IsWindows )
{
image . CompareToOriginal ( provider ) ;
}
}
}
@ -50,9 +52,11 @@ namespace SixLabors.ImageSharp.Tests.Formats.Bmp
public void BmpDecoder_CanDecodeBitfields < TPixel > ( TestImageProvider < TPixel > provider )
where TPixel : struct , IPixel < TPixel >
{
using Image < TPixel > image = provider . GetImage ( new BmpDecoder ( ) ) ;
image . DebugSave ( provider ) ;
image . CompareToOriginal ( provider ) ;
using ( Image < TPixel > image = provider . GetImage ( new BmpDecoder ( ) ) )
{
image . DebugSave ( provider ) ;
image . CompareToOriginal ( provider ) ;
}
}
[Theory]
@ -61,9 +65,11 @@ namespace SixLabors.ImageSharp.Tests.Formats.Bmp
public void BmpDecoder_CanDecode_Inverted < TPixel > ( TestImageProvider < TPixel > provider )
where TPixel : struct , IPixel < TPixel >
{
using Image < TPixel > image = provider . GetImage ( new BmpDecoder ( ) ) ;
image . DebugSave ( provider ) ;
image . CompareToOriginal ( provider ) ;
using ( Image < TPixel > image = provider . GetImage ( new BmpDecoder ( ) ) )
{
image . DebugSave ( provider ) ;
image . CompareToOriginal ( provider ) ;
}
}
[Theory]
@ -72,9 +78,11 @@ namespace SixLabors.ImageSharp.Tests.Formats.Bmp
public void BmpDecoder_CanDecode_1Bit < TPixel > ( TestImageProvider < TPixel > provider )
where TPixel : struct , IPixel < TPixel >
{
using Image < TPixel > image = provider . GetImage ( new BmpDecoder ( ) ) ;
image . DebugSave ( provider ) ;
image . CompareToOriginal ( provider , new SystemDrawingReferenceDecoder ( ) ) ;
using ( Image < TPixel > image = provider . GetImage ( new BmpDecoder ( ) ) )
{
image . DebugSave ( provider ) ;
image . CompareToOriginal ( provider , new SystemDrawingReferenceDecoder ( ) ) ;
}
}
[Theory]
@ -82,13 +90,15 @@ namespace SixLabors.ImageSharp.Tests.Formats.Bmp
public void BmpDecoder_CanDecode_4Bit < TPixel > ( TestImageProvider < TPixel > provider )
where TPixel : struct , IPixel < TPixel >
{
using Image < TPixel > image = provider . GetImage ( new BmpDecoder ( ) ) ;
image . DebugSave ( provider ) ;
// The Magick Reference Decoder can not decode 4-Bit bitmaps, so only execute this on windows.
if ( TestEnvironment . IsWindows )
using ( Image < TPixel > image = provider . GetImage ( new BmpDecoder ( ) ) )
{
image . CompareToOriginal ( provider ) ;
image . DebugSave ( provider ) ;
// The Magick Reference Decoder can not decode 4-Bit bitmaps, so only execute this on windows.
if ( TestEnvironment . IsWindows )
{
image . CompareToOriginal ( provider ) ;
}
}
}
@ -97,9 +107,11 @@ namespace SixLabors.ImageSharp.Tests.Formats.Bmp
public void BmpDecoder_CanDecode_8Bit < TPixel > ( TestImageProvider < TPixel > provider )
where TPixel : struct , IPixel < TPixel >
{
using Image < TPixel > image = provider . GetImage ( new BmpDecoder ( ) ) ;
image . DebugSave ( provider ) ;
image . CompareToOriginal ( provider ) ;
using ( Image < TPixel > image = provider . GetImage ( new BmpDecoder ( ) ) )
{
image . DebugSave ( provider ) ;
image . CompareToOriginal ( provider ) ;
}
}
[Theory]
@ -107,9 +119,11 @@ namespace SixLabors.ImageSharp.Tests.Formats.Bmp
public void BmpDecoder_CanDecode_16Bit < TPixel > ( TestImageProvider < TPixel > provider )
where TPixel : struct , IPixel < TPixel >
{
using Image < TPixel > image = provider . GetImage ( new BmpDecoder ( ) ) ;
image . DebugSave ( provider ) ;
image . CompareToOriginal ( provider ) ;
using ( Image < TPixel > image = provider . GetImage ( new BmpDecoder ( ) ) )
{
image . DebugSave ( provider ) ;
image . CompareToOriginal ( provider ) ;
}
}
[Theory]
@ -117,9 +131,11 @@ namespace SixLabors.ImageSharp.Tests.Formats.Bmp
public void BmpDecoder_CanDecode_32Bit < TPixel > ( TestImageProvider < TPixel > provider )
where TPixel : struct , IPixel < TPixel >
{
using Image < TPixel > image = provider . GetImage ( new BmpDecoder ( ) ) ;
image . DebugSave ( provider ) ;
image . CompareToOriginal ( provider ) ;
using ( Image < TPixel > image = provider . GetImage ( new BmpDecoder ( ) ) )
{
image . DebugSave ( provider ) ;
image . CompareToOriginal ( provider ) ;
}
}
[Theory]
@ -127,9 +143,11 @@ namespace SixLabors.ImageSharp.Tests.Formats.Bmp
public void BmpDecoder_CanDecode_32BitV4Header_Fast < TPixel > ( TestImageProvider < TPixel > provider )
where TPixel : struct , IPixel < TPixel >
{
using Image < TPixel > image = provider . GetImage ( new BmpDecoder ( ) ) ;
image . DebugSave ( provider ) ;
image . CompareToOriginal ( provider ) ;
using ( Image < TPixel > image = provider . GetImage ( new BmpDecoder ( ) ) )
{
image . DebugSave ( provider ) ;
image . CompareToOriginal ( provider ) ;
}
}
[Theory]
@ -139,13 +157,15 @@ namespace SixLabors.ImageSharp.Tests.Formats.Bmp
public void BmpDecoder_CanDecode_RunLengthEncoded_4Bit_WithDelta < TPixel > ( TestImageProvider < TPixel > provider )
where TPixel : struct , IPixel < TPixel >
{
using Image < TPixel > image = provider . GetImage ( new BmpDecoder { RleSkippedPixelHandling = RleSkippedPixelHandling . Black } ) ;
image . DebugSave ( provider ) ;
// The Magick Reference Decoder can not decode 4-Bit bitmaps, so only execute this on windows.
if ( TestEnvironment . IsWindows )
using ( Image < TPixel > image = provider . GetImage ( new BmpDecoder { RleSkippedPixelHandling = RleSkippedPixelHandling . Black } ) )
{
image . CompareToOriginal ( provider ) ;
image . DebugSave ( provider ) ;
// The Magick Reference Decoder can not decode 4-Bit bitmaps, so only execute this on windows.
if ( TestEnvironment . IsWindows )
{
image . CompareToOriginal ( provider ) ;
}
}
}
@ -154,13 +174,15 @@ namespace SixLabors.ImageSharp.Tests.Formats.Bmp
public void BmpDecoder_CanDecode_RunLengthEncoded_4Bit < TPixel > ( TestImageProvider < TPixel > provider )
where TPixel : struct , IPixel < TPixel >
{
using Image < TPixel > image = provider . GetImage ( new BmpDecoder { RleSkippedPixelHandling = RleSkippedPixelHandling . Black } ) ;
image . DebugSave ( provider ) ;
// The Magick Reference Decoder can not decode 4-Bit bitmaps, so only execute this on windows.
if ( TestEnvironment . IsWindows )
using ( Image < TPixel > image = provider . GetImage ( new BmpDecoder { RleSkippedPixelHandling = RleSkippedPixelHandling . Black } ) )
{
image . CompareToOriginal ( provider ) ;
image . DebugSave ( provider ) ;
// The Magick Reference Decoder can not decode 4-Bit bitmaps, so only execute this on windows.
if ( TestEnvironment . IsWindows )
{
image . CompareToOriginal ( provider ) ;
}
}
}
@ -172,11 +194,13 @@ namespace SixLabors.ImageSharp.Tests.Formats.Bmp
public void BmpDecoder_CanDecode_RunLengthEncoded_8Bit_WithDelta_SystemDrawingRefDecoder < TPixel > ( TestImageProvider < TPixel > provider )
where TPixel : struct , IPixel < TPixel >
{
using Image < TPixel > image = provider . GetImage ( new BmpDecoder { RleSkippedPixelHandling = RleSkippedPixelHandling . Black } ) ;
image . DebugSave ( provider ) ;
if ( TestEnvironment . IsWindows )
using ( Image < TPixel > image = provider . GetImage ( new BmpDecoder { RleSkippedPixelHandling = RleSkippedPixelHandling . Black } ) )
{
image . CompareToOriginal ( provider , new SystemDrawingReferenceDecoder ( ) ) ;
image . DebugSave ( provider ) ;
if ( TestEnvironment . IsWindows )
{
image . CompareToOriginal ( provider , new SystemDrawingReferenceDecoder ( ) ) ;
}
}
}
@ -186,9 +210,11 @@ namespace SixLabors.ImageSharp.Tests.Formats.Bmp
public void BmpDecoder_CanDecode_RunLengthEncoded_8Bit_WithDelta_MagickRefDecoder < TPixel > ( TestImageProvider < TPixel > provider )
where TPixel : struct , IPixel < TPixel >
{
using Image < TPixel > image = provider . GetImage ( new BmpDecoder { RleSkippedPixelHandling = RleSkippedPixelHandling . FirstColorOfPalette } ) ;
image . DebugSave ( provider ) ;
image . CompareToOriginal ( provider , new MagickReferenceDecoder ( ) ) ;
using ( Image < TPixel > image = provider . GetImage ( new BmpDecoder { RleSkippedPixelHandling = RleSkippedPixelHandling . FirstColorOfPalette } ) )
{
image . DebugSave ( provider ) ;
image . CompareToOriginal ( provider , new MagickReferenceDecoder ( ) ) ;
}
}
[Theory]
@ -197,9 +223,11 @@ namespace SixLabors.ImageSharp.Tests.Formats.Bmp
public void BmpDecoder_CanDecode_RunLengthEncoded_8Bit < TPixel > ( TestImageProvider < TPixel > provider )
where TPixel : struct , IPixel < TPixel >
{
using Image < TPixel > image = provider . GetImage ( new BmpDecoder { RleSkippedPixelHandling = RleSkippedPixelHandling . FirstColorOfPalette } ) ;
image . DebugSave ( provider ) ;
image . CompareToOriginal ( provider , new MagickReferenceDecoder ( ) ) ;
using ( Image < TPixel > image = provider . GetImage ( new BmpDecoder { RleSkippedPixelHandling = RleSkippedPixelHandling . FirstColorOfPalette } ) )
{
image . DebugSave ( provider ) ;
image . CompareToOriginal ( provider , new MagickReferenceDecoder ( ) ) ;
}
}
[Theory]
@ -209,11 +237,13 @@ namespace SixLabors.ImageSharp.Tests.Formats.Bmp
public void BmpDecoder_CanDecode_RunLengthEncoded_24Bit < TPixel > ( TestImageProvider < TPixel > provider )
where TPixel : struct , IPixel < TPixel >
{
using Image < TPixel > image = provider . GetImage ( new BmpDecoder { RleSkippedPixelHandling = RleSkippedPixelHandling . Black } ) ;
image . DebugSave ( provider ) ;
using ( Image < TPixel > image = provider . GetImage ( new BmpDecoder { RleSkippedPixelHandling = RleSkippedPixelHandling . Black } ) )
{
image . DebugSave ( provider ) ;
// TODO: Neither System.Drawing nor MagickReferenceDecoder decode this file.
// image.CompareToOriginal(provider);
// TODO: Neither System.Drawing nor MagickReferenceDecoder decode this file.
// image.CompareToOriginal(provider);
}
}
[Theory]
@ -221,11 +251,13 @@ namespace SixLabors.ImageSharp.Tests.Formats.Bmp
public void BmpDecoder_CanDecodeAlphaBitfields < TPixel > ( TestImageProvider < TPixel > provider )
where TPixel : struct , IPixel < TPixel >
{
using Image < TPixel > image = provider . GetImage ( new BmpDecoder ( ) ) ;
image . DebugSave ( provider ) ;
using ( Image < TPixel > image = provider . GetImage ( new BmpDecoder ( ) ) )
{
image . DebugSave ( provider ) ;
// TODO: Neither System.Drawing nor MagickReferenceDecoder decode this file.
// image.CompareToOriginal(provider);
// TODO: Neither System.Drawing nor MagickReferenceDecoder decode this file.
// image.CompareToOriginal(provider);
}
}
[Theory]
@ -233,9 +265,11 @@ namespace SixLabors.ImageSharp.Tests.Formats.Bmp
public void BmpDecoder_CanDecodeBitmap_WithAlphaChannel < TPixel > ( TestImageProvider < TPixel > provider )
where TPixel : struct , IPixel < TPixel >
{
using Image < TPixel > image = provider . GetImage ( new BmpDecoder ( ) ) ;
image . DebugSave ( provider ) ;
image . CompareToOriginal ( provider , new MagickReferenceDecoder ( ) ) ;
using ( Image < TPixel > image = provider . GetImage ( new BmpDecoder ( ) ) )
{
image . DebugSave ( provider ) ;
image . CompareToOriginal ( provider , new MagickReferenceDecoder ( ) ) ;
}
}
[Theory]
@ -243,15 +277,17 @@ namespace SixLabors.ImageSharp.Tests.Formats.Bmp
public void BmpDecoder_CanDecodeBitfields_WithUnusualBitmasks < TPixel > ( TestImageProvider < TPixel > provider )
where TPixel : struct , IPixel < TPixel >
{
using Image < TPixel > image = provider . GetImage ( new BmpDecoder ( ) ) ;
image . DebugSave ( provider ) ;
// Choosing large tolerance of 6.1 here, because for some reason with the MagickReferenceDecoder the alpha channel
// seems to be wrong. This bitmap has an alpha channel of two bits. In many cases this alpha channel has a value of 3,
// which should be remapped to 255 for RGBA32, but the magick decoder has a value of 191 set.
// The total difference without the alpha channel is still: 0.0204%
// 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 ( ) ) ;
using ( Image < TPixel > image = provider . GetImage ( new BmpDecoder ( ) ) )
{
image . DebugSave ( provider ) ;
// Choosing large tolerance of 6.1 here, because for some reason with the MagickReferenceDecoder the alpha channel
// seems to be wrong. This bitmap has an alpha channel of two bits. In many cases this alpha channel has a value of 3,
// which should be remapped to 255 for RGBA32, but the magick decoder has a value of 191 set.
// The total difference without the alpha channel is still: 0.0204%
// 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 ( ) ) ;
}
}
[Theory]
@ -260,9 +296,11 @@ namespace SixLabors.ImageSharp.Tests.Formats.Bmp
public void BmpDecoder_CanDecodeBmpv2 < TPixel > ( TestImageProvider < TPixel > provider )
where TPixel : struct , IPixel < TPixel >
{
using Image < TPixel > image = provider . GetImage ( new BmpDecoder ( ) ) ;
image . DebugSave ( provider ) ;
image . CompareToOriginal ( provider ) ;
using ( Image < TPixel > image = provider . GetImage ( new BmpDecoder ( ) ) )
{
image . DebugSave ( provider ) ;
image . CompareToOriginal ( provider ) ;
}
}
[Theory]
@ -270,9 +308,11 @@ namespace SixLabors.ImageSharp.Tests.Formats.Bmp
public void BmpDecoder_CanDecodeBmpv3 < TPixel > ( TestImageProvider < TPixel > provider )
where TPixel : struct , IPixel < TPixel >
{
using Image < TPixel > image = provider . GetImage ( new BmpDecoder ( ) ) ;
image . DebugSave ( provider ) ;
image . CompareToOriginal ( provider ) ;
using ( Image < TPixel > image = provider . GetImage ( new BmpDecoder ( ) ) )
{
image . DebugSave ( provider ) ;
image . CompareToOriginal ( provider ) ;
}
}
[Theory]
@ -280,9 +320,11 @@ namespace SixLabors.ImageSharp.Tests.Formats.Bmp
public void BmpDecoder_CanDecodeLessThanFullPalette < TPixel > ( TestImageProvider < TPixel > provider )
where TPixel : struct , IPixel < TPixel >
{
using Image < TPixel > image = provider . GetImage ( new BmpDecoder ( ) ) ;
image . DebugSave ( provider ) ;
image . CompareToOriginal ( provider , new MagickReferenceDecoder ( ) ) ;
using ( Image < TPixel > image = provider . GetImage ( new BmpDecoder ( ) ) )
{
image . DebugSave ( provider ) ;
image . CompareToOriginal ( provider , new MagickReferenceDecoder ( ) ) ;
}
}
[Theory]
@ -291,11 +333,13 @@ namespace SixLabors.ImageSharp.Tests.Formats.Bmp
public void BmpDecoder_CanDecodeOversizedPalette < TPixel > ( TestImageProvider < TPixel > provider )
where TPixel : struct , IPixel < TPixel >
{
using Image < TPixel > image = provider . GetImage ( new BmpDecoder ( ) ) ;
image . DebugSave ( provider ) ;
if ( TestEnvironment . IsWindows )
using ( Image < TPixel > image = provider . GetImage ( new BmpDecoder ( ) ) )
{
image . CompareToOriginal ( provider ) ;
image . DebugSave ( provider ) ;
if ( TestEnvironment . IsWindows )
{
image . CompareToOriginal ( provider ) ;
}
}
}
@ -331,9 +375,11 @@ namespace SixLabors.ImageSharp.Tests.Formats.Bmp
public void BmpDecoder_CanDecodeAdobeBmpv3 < TPixel > ( TestImageProvider < TPixel > provider )
where TPixel : struct , IPixel < TPixel >
{
using Image < TPixel > image = provider . GetImage ( new BmpDecoder ( ) ) ;
image . DebugSave ( provider ) ;
image . CompareToOriginal ( provider , new MagickReferenceDecoder ( ) ) ;
using ( Image < TPixel > image = provider . GetImage ( new BmpDecoder ( ) ) )
{
image . DebugSave ( provider ) ;
image . CompareToOriginal ( provider , new MagickReferenceDecoder ( ) ) ;
}
}
[Theory]
@ -341,9 +387,11 @@ namespace SixLabors.ImageSharp.Tests.Formats.Bmp
public void BmpDecoder_CanDecodeAdobeBmpv3_WithAlpha < TPixel > ( TestImageProvider < TPixel > provider )
where TPixel : struct , IPixel < TPixel >
{
using Image < TPixel > image = provider . GetImage ( new BmpDecoder ( ) ) ;
image . DebugSave ( provider ) ;
image . CompareToOriginal ( provider , new MagickReferenceDecoder ( ) ) ;
using ( Image < TPixel > image = provider . GetImage ( new BmpDecoder ( ) ) )
{
image . DebugSave ( provider ) ;
image . CompareToOriginal ( provider , new MagickReferenceDecoder ( ) ) ;
}
}
[Theory]
@ -351,9 +399,11 @@ namespace SixLabors.ImageSharp.Tests.Formats.Bmp
public void BmpDecoder_CanDecodeBmpv4 < TPixel > ( TestImageProvider < TPixel > provider )
where TPixel : struct , IPixel < TPixel >
{
using Image < TPixel > image = provider . GetImage ( new BmpDecoder ( ) ) ;
image . DebugSave ( provider ) ;
image . CompareToOriginal ( provider ) ;
using ( Image < TPixel > image = provider . GetImage ( new BmpDecoder ( ) ) )
{
image . DebugSave ( provider ) ;
image . CompareToOriginal ( provider ) ;
}
}
[Theory]
@ -362,9 +412,11 @@ namespace SixLabors.ImageSharp.Tests.Formats.Bmp
public void BmpDecoder_CanDecodeBmpv5 < TPixel > ( TestImageProvider < TPixel > provider )
where TPixel : struct , IPixel < TPixel >
{
using Image < TPixel > image = provider . GetImage ( new BmpDecoder ( ) ) ;
image . DebugSave ( provider ) ;
image . CompareToOriginal ( provider ) ;
using ( Image < TPixel > image = provider . GetImage ( new BmpDecoder ( ) ) )
{
image . DebugSave ( provider ) ;
image . CompareToOriginal ( provider ) ;
}
}
[Theory]
@ -372,9 +424,11 @@ namespace SixLabors.ImageSharp.Tests.Formats.Bmp
public void BmpDecoder_RespectsFileHeaderOffset < TPixel > ( TestImageProvider < TPixel > provider )
where TPixel : struct , IPixel < TPixel >
{
using Image < TPixel > image = provider . GetImage ( new BmpDecoder ( ) ) ;
image . DebugSave ( provider ) ;
image . CompareToOriginal ( provider ) ;
using ( Image < TPixel > image = provider . GetImage ( new BmpDecoder ( ) ) )
{
image . DebugSave ( provider ) ;
image . CompareToOriginal ( provider ) ;
}
}
[Theory]
@ -382,9 +436,11 @@ namespace SixLabors.ImageSharp.Tests.Formats.Bmp
public void BmpDecoder_IsNotBoundToSinglePixelType < TPixel > ( TestImageProvider < TPixel > provider )
where TPixel : struct , IPixel < TPixel >
{
using Image < TPixel > image = provider . GetImage ( new BmpDecoder ( ) ) ;
image . DebugSave ( provider ) ;
image . CompareToOriginal ( provider ) ;
using ( Image < TPixel > image = provider . GetImage ( new BmpDecoder ( ) ) )
{
image . DebugSave ( provider ) ;
image . CompareToOriginal ( provider ) ;
}
}
[Theory]
@ -392,9 +448,11 @@ namespace SixLabors.ImageSharp.Tests.Formats.Bmp
public void BmpDecoder_CanDecode4BytePerEntryPalette < TPixel > ( TestImageProvider < TPixel > provider )
where TPixel : struct , IPixel < TPixel >
{
using Image < TPixel > image = provider . GetImage ( new BmpDecoder ( ) ) ;
image . DebugSave ( provider ) ;
image . CompareToOriginal ( provider ) ;
using ( Image < TPixel > image = provider . GetImage ( new BmpDecoder ( ) ) )
{
image . DebugSave ( provider ) ;
image . CompareToOriginal ( provider ) ;
}
}
[Theory]
@ -413,10 +471,12 @@ namespace SixLabors.ImageSharp.Tests.Formats.Bmp
public void Identify_DetectsCorrectPixelType ( string imagePath , int expectedPixelSize )
{
var testFile = TestFile . Create ( imagePath ) ;
using var stream = new MemoryStream ( testFile . Bytes , false ) ;
IImageInfo imageInfo = Image . Identify ( stream ) ;
Assert . NotNull ( imageInfo ) ;
Assert . Equal ( expectedPixelSize , imageInfo . PixelType ? . BitsPerPixel ) ;
using ( var stream = new MemoryStream ( testFile . Bytes , false ) )
{
IImageInfo imageInfo = Image . Identify ( stream ) ;
Assert . NotNull ( imageInfo ) ;
Assert . Equal ( expectedPixelSize , imageInfo . PixelType ? . BitsPerPixel ) ;
}
}
[Theory]
@ -431,11 +491,13 @@ namespace SixLabors.ImageSharp.Tests.Formats.Bmp
public void Identify_DetectsCorrectWidthAndHeight ( string imagePath , int expectedWidth , int expectedHeight )
{
var testFile = TestFile . Create ( imagePath ) ;
using var stream = new MemoryStream ( testFile . Bytes , false ) ;
IImageInfo imageInfo = Image . Identify ( stream ) ;
Assert . NotNull ( imageInfo ) ;
Assert . Equal ( expectedWidth , imageInfo . Width ) ;
Assert . Equal ( expectedHeight , imageInfo . Height ) ;
using ( var stream = new MemoryStream ( testFile . Bytes , false ) )
{
IImageInfo imageInfo = Image . Identify ( stream ) ;
Assert . NotNull ( imageInfo ) ;
Assert . Equal ( expectedWidth , imageInfo . Width ) ;
Assert . Equal ( expectedHeight , imageInfo . Height ) ;
}
}
[Theory]
@ -443,13 +505,17 @@ namespace SixLabors.ImageSharp.Tests.Formats.Bmp
public void Decode_VerifyRatio ( string imagePath , int xResolution , int yResolution , PixelResolutionUnit resolutionUnit )
{
var testFile = TestFile . Create ( imagePath ) ;
using var stream = new MemoryStream ( testFile . Bytes , false ) ;
var decoder = new BmpDecoder ( ) ;
using Image < Rgba32 > image = decoder . Decode < Rgba32 > ( Configuration . Default , stream ) ;
ImageMetadata meta = image . Metadata ;
Assert . Equal ( xResolution , meta . HorizontalResolution ) ;
Assert . Equal ( yResolution , meta . VerticalResolution ) ;
Assert . Equal ( resolutionUnit , meta . ResolutionUnits ) ;
using ( var stream = new MemoryStream ( testFile . Bytes , false ) )
{
var decoder = new BmpDecoder ( ) ;
using ( Image < Rgba32 > image = decoder . Decode < Rgba32 > ( Configuration . Default , stream ) )
{
ImageMetadata meta = image . Metadata ;
Assert . Equal ( xResolution , meta . HorizontalResolution ) ;
Assert . Equal ( yResolution , meta . VerticalResolution ) ;
Assert . Equal ( resolutionUnit , meta . ResolutionUnits ) ;
}
}
}
[Theory]
@ -457,11 +523,13 @@ namespace SixLabors.ImageSharp.Tests.Formats.Bmp
public void BmpDecoder_CanDecode_Os2v2XShortHeader < TPixel > ( TestImageProvider < TPixel > provider )
where TPixel : struct , IPixel < TPixel >
{
using Image < TPixel > image = provider . GetImage ( new BmpDecoder ( ) ) ;
image . DebugSave ( provider ) ;
using ( Image < TPixel > image = provider . GetImage ( new BmpDecoder ( ) ) )
{
image . DebugSave ( provider ) ;
// TODO: Neither System.Drawing or MagickReferenceDecoder can correctly decode this file.
// image.CompareToOriginal(provider);
// TODO: Neither System.Drawing or MagickReferenceDecoder can correctly decode this file.
// image.CompareToOriginal(provider);
}
}
[Theory]
@ -469,13 +537,15 @@ namespace SixLabors.ImageSharp.Tests.Formats.Bmp
public void BmpDecoder_CanDecode_Os2v2Header < TPixel > ( TestImageProvider < TPixel > provider )
where TPixel : struct , IPixel < TPixel >
{
using Image < TPixel > image = provider . GetImage ( new BmpDecoder ( ) ) ;
image . DebugSave ( provider ) ;
using ( Image < TPixel > image = provider . GetImage ( new BmpDecoder ( ) ) )
{
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());
// 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());
}
}
[Theory]
@ -491,11 +561,13 @@ namespace SixLabors.ImageSharp.Tests.Formats.Bmp
public void BmpDecoder_CanDecode_Os2BitmapArray < TPixel > ( TestImageProvider < TPixel > provider )
where TPixel : struct , IPixel < TPixel >
{
using Image < TPixel > image = provider . GetImage ( new BmpDecoder ( ) ) ;
image . DebugSave ( provider ) ;
using ( Image < TPixel > image = provider . GetImage ( new BmpDecoder ( ) ) )
{
image . DebugSave ( provider ) ;
// TODO: Neither System.Drawing or MagickReferenceDecoder can correctly decode this file.
// image.CompareToOriginal(provider);
// TODO: Neither System.Drawing or MagickReferenceDecoder can correctly decode this file.
// image.CompareToOriginal(provider);
}
}
}
}