diff --git a/tests/ImageSharp.Tests/Formats/Bmp/BmpDecoderTests.cs b/tests/ImageSharp.Tests/Formats/Bmp/BmpDecoderTests.cs
index 4e10de23f1..8a50b760ec 100644
--- a/tests/ImageSharp.Tests/Formats/Bmp/BmpDecoderTests.cs
+++ b/tests/ImageSharp.Tests/Formats/Bmp/BmpDecoderTests.cs
@@ -1,26 +1,38 @@
-//
-// Copyright (c) James Jackson-South and contributors.
+// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
-//
-using ImageSharp.Formats;
+using SixLabors.ImageSharp.Formats;
+using SixLabors.ImageSharp.PixelFormats;
+using Xunit;
+// ReSharper disable InconsistentNaming
-namespace ImageSharp.Tests
+namespace SixLabors.ImageSharp.Tests
{
- using ImageSharp.PixelFormats;
-
- using Xunit;
+ using SixLabors.ImageSharp.Formats.Bmp;
public class BmpDecoderTests : FileTestBase
{
[Theory]
[WithFileCollection(nameof(AllBmpFiles), PixelTypes.Rgb24)]
- public void OpenAllBmpFiles_SaveBmp(TestImageProvider provider)
+ public void DecodeBmp(TestImageProvider provider)
+ where TPixel : struct, IPixel
+ {
+ using (Image image = provider.GetImage(new BmpDecoder()))
+ {
+ image.DebugSave(provider, "bmp");
+ image.CompareToOriginal(provider);
+ }
+ }
+
+ [Theory]
+ [WithFile(TestImages.Bmp.F, CommonNonDefaultPixelTypes)]
+ public void BmpDecoder_IsNotBoundToSinglePixelType(TestImageProvider provider)
where TPixel : struct, IPixel
{
- using (Image image = provider.GetImage())
+ using (Image image = provider.GetImage(new BmpDecoder()))
{
- provider.Utility.SaveTestOutputFile(image, "bmp");
+ image.DebugSave(provider, "bmp");
+ image.CompareToOriginal(provider);
}
}
}
diff --git a/tests/ImageSharp.Tests/TestUtilities/TestEnvironment.cs b/tests/ImageSharp.Tests/TestUtilities/TestEnvironment.cs
index 85d5fffdc7..2bbc7d4ea9 100644
--- a/tests/ImageSharp.Tests/TestUtilities/TestEnvironment.cs
+++ b/tests/ImageSharp.Tests/TestUtilities/TestEnvironment.cs
@@ -48,24 +48,44 @@ namespace SixLabors.ImageSharp.Tests
internal static Configuration Configuration => configuration.Value;
+ private static void ConfigureCodecs(
+ this Configuration cfg,
+ IImageFormat imageFormat,
+ IImageDecoder decoder,
+ IImageEncoder encoder,
+ IImageFormatDetector detector)
+ {
+ cfg.SetDecoder(imageFormat, decoder);
+ cfg.SetEncoder(imageFormat, encoder);
+ cfg.AddImageFormatDetector(detector);
+ }
+
private static Configuration CreateDefaultConfiguration()
{
var configuration = new Configuration(
new PngConfigurationModule(),
new JpegConfigurationModule(),
- new GifConfigurationModule(),
- new BmpConfigurationModule()
+ new GifConfigurationModule()
);
if (!IsLinux)
{
- configuration.SetDecoder(ImageFormats.Png, SystemDrawingReferenceDecoder.Instance);
- configuration.SetEncoder(ImageFormats.Png, SystemDrawingReferenceEncoder.Png);
- configuration.AddImageFormatDetector(new PngImageFormatDetector());
+ configuration.ConfigureCodecs(
+ ImageFormats.Png,
+ SystemDrawingReferenceDecoder.Instance,
+ SystemDrawingReferenceEncoder.Png,
+ new PngImageFormatDetector());
+
+ configuration.ConfigureCodecs(
+ ImageFormats.Bitmap,
+ SystemDrawingReferenceDecoder.Instance,
+ SystemDrawingReferenceEncoder.Png,
+ new PngImageFormatDetector());
}
else
{
- new PngConfigurationModule().Configure(configuration);
+ configuration.Configure(new PngConfigurationModule());
+ configuration.Configure(new BmpConfigurationModule());
}
return configuration;
diff --git a/tests/ImageSharp.Tests/TestUtilities/Tests/TestEnvironmentTests.cs b/tests/ImageSharp.Tests/TestUtilities/Tests/TestEnvironmentTests.cs
index 79478cba25..658fa862df 100644
--- a/tests/ImageSharp.Tests/TestUtilities/Tests/TestEnvironmentTests.cs
+++ b/tests/ImageSharp.Tests/TestUtilities/Tests/TestEnvironmentTests.cs
@@ -14,6 +14,7 @@ using Xunit.Abstractions;
// ReSharper disable InconsistentNaming
namespace SixLabors.ImageSharp.Tests
{
+ using SixLabors.ImageSharp.Formats.Bmp;
using SixLabors.ImageSharp.Formats.Png;
public class TestEnvironmentTests
@@ -67,6 +68,7 @@ namespace SixLabors.ImageSharp.Tests
[Theory]
[InlineData("lol/foo.png", typeof(SystemDrawingReferenceEncoder))]
+ [InlineData("lol/Rofl.bmp", typeof(SystemDrawingReferenceEncoder))]
[InlineData("lol/Baz.JPG", typeof(JpegEncoder))]
[InlineData("lol/Baz.gif", typeof(GifEncoder))]
public void GetReferenceEncoder_ReturnsCorrectEncoders_Windows(string fileName, Type expectedEncoderType)
@@ -79,6 +81,7 @@ namespace SixLabors.ImageSharp.Tests
[Theory]
[InlineData("lol/foo.png", typeof(SystemDrawingReferenceDecoder))]
+ [InlineData("lol/Rofl.bmp", typeof(SystemDrawingReferenceDecoder))]
[InlineData("lol/Baz.JPG", typeof(JpegDecoder))]
[InlineData("lol/Baz.gif", typeof(GifDecoder))]
public void GetReferenceDecoder_ReturnsCorrectEncoders_Windows(string fileName, Type expectedDecoderType)
@@ -91,6 +94,7 @@ namespace SixLabors.ImageSharp.Tests
[Theory]
[InlineData("lol/foo.png", typeof(PngEncoder))]
+ [InlineData("lol/Rofl.bmp", typeof(BmpEncoder))]
[InlineData("lol/Baz.JPG", typeof(JpegEncoder))]
[InlineData("lol/Baz.gif", typeof(GifEncoder))]
public void GetReferenceEncoder_ReturnsCorrectEncoders_Linux(string fileName, Type expectedEncoderType)
@@ -103,6 +107,7 @@ namespace SixLabors.ImageSharp.Tests
[Theory]
[InlineData("lol/foo.png", typeof(PngDecoder))]
+ [InlineData("lol/Rofl.bmp", typeof(BmpDecoder))]
[InlineData("lol/Baz.JPG", typeof(JpegDecoder))]
[InlineData("lol/Baz.gif", typeof(GifDecoder))]
public void GetReferenceDecoder_ReturnsCorrectEncoders_Linux(string fileName, Type expectedDecoderType)
diff --git a/tests/ImageSharp.Tests/TestImages/Formats/Bmp/BitmapCoreHeaderQR.bmp b/tests/Images/Input/Bmp/BitmapCoreHeaderQR.bmp
similarity index 100%
rename from tests/ImageSharp.Tests/TestImages/Formats/Bmp/BitmapCoreHeaderQR.bmp
rename to tests/Images/Input/Bmp/BitmapCoreHeaderQR.bmp