@ -37,13 +37,11 @@ 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 ( ) ) )
using Image < TPixel > image = provider . GetImage ( new BmpDecoder ( ) ) ;
image . DebugSave ( provider ) ;
if ( TestEnvironment . IsWindows )
{
image . DebugSave ( provider ) ;
if ( TestEnvironment . IsWindows )
{
image . CompareToOriginal ( provider ) ;
}
image . CompareToOriginal ( provider ) ;
}
}
@ -52,11 +50,9 @@ 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]
@ -65,11 +61,9 @@ 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]
@ -78,11 +72,9 @@ 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]
@ -90,15 +82,13 @@ 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 ) ;
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 )
{
image . CompareToOriginal ( provider ) ;
}
// The Magick Reference Decoder can not decode 4-Bit bitmaps, so only execute this on windows.
if ( TestEnvironment . IsWindows )
{
image . CompareToOriginal ( provider ) ;
}
}
@ -107,11 +97,9 @@ 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]
@ -119,11 +107,9 @@ 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]
@ -131,11 +117,9 @@ 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]
@ -143,11 +127,9 @@ 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]
@ -157,15 +139,13 @@ 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 ) ;
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 )
{
image . CompareToOriginal ( provider ) ;
}
// The Magick Reference Decoder can not decode 4-Bit bitmaps, so only execute this on windows.
if ( TestEnvironment . IsWindows )
{
image . CompareToOriginal ( provider ) ;
}
}
@ -174,15 +154,13 @@ 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 ) ;
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 )
{
image . CompareToOriginal ( provider ) ;
}
// The Magick Reference Decoder can not decode 4-Bit bitmaps, so only execute this on windows.
if ( TestEnvironment . IsWindows )
{
image . CompareToOriginal ( provider ) ;
}
}
@ -194,13 +172,11 @@ 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 } ) )
using Image < TPixel > image = provider . GetImage ( new BmpDecoder { RleSkippedPixelHandling = RleSkippedPixelHandling . Black } ) ;
image . DebugSave ( provider ) ;
if ( TestEnvironment . IsWindows )
{
image . DebugSave ( provider ) ;
if ( TestEnvironment . IsWindows )
{
image . CompareToOriginal ( provider , new SystemDrawingReferenceDecoder ( ) ) ;
}
image . CompareToOriginal ( provider , new SystemDrawingReferenceDecoder ( ) ) ;
}
}
@ -210,11 +186,9 @@ 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]
@ -223,11 +197,9 @@ 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]
@ -237,13 +209,11 @@ 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]
@ -251,13 +221,11 @@ 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]
@ -265,11 +233,9 @@ 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]
@ -277,17 +243,15 @@ 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]
@ -296,11 +260,9 @@ 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]
@ -308,11 +270,9 @@ 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]
@ -320,11 +280,9 @@ 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]
@ -333,13 +291,11 @@ 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 ( ) ) )
using Image < TPixel > image = provider . GetImage ( new BmpDecoder ( ) ) ;
image . DebugSave ( provider ) ;
if ( TestEnvironment . IsWindows )
{
image . DebugSave ( provider ) ;
if ( TestEnvironment . IsWindows )
{
image . CompareToOriginal ( provider ) ;
}
image . CompareToOriginal ( provider ) ;
}
}
@ -375,11 +331,9 @@ 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]
@ -387,11 +341,9 @@ 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]
@ -399,11 +351,9 @@ 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]
@ -412,11 +362,9 @@ 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]
@ -424,11 +372,9 @@ 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]
@ -436,11 +382,9 @@ 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]
@ -448,11 +392,9 @@ 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]
@ -471,12 +413,10 @@ 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]
@ -491,13 +431,11 @@ 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]
@ -505,17 +443,13 @@ 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]
@ -523,13 +457,11 @@ 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]
@ -537,15 +469,13 @@ 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]
@ -561,13 +491,11 @@ 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);
}
}
}