diff --git a/src/ImageSharp/Formats/Jpeg/GolangPort/OrigJpegDecoder.cs b/src/ImageSharp/Formats/Jpeg/GolangPort/OrigJpegDecoder.cs index 13be70e30..97a424c41 100644 --- a/src/ImageSharp/Formats/Jpeg/GolangPort/OrigJpegDecoder.cs +++ b/src/ImageSharp/Formats/Jpeg/GolangPort/OrigJpegDecoder.cs @@ -27,5 +27,16 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.GolangPort return decoder.Decode(stream); } } + + /// + public PixelTypeInfo DetectPixelType(Configuration configuration, Stream stream) + { + Guard.NotNull(stream, "stream"); + + using (var decoder = new OrigJpegDecoderCore(configuration, this)) + { + return new PixelTypeInfo(decoder.DetectPixelSize(stream)); + } + } } } \ No newline at end of file diff --git a/src/ImageSharp/Formats/Jpeg/JpegDecoder.cs b/src/ImageSharp/Formats/Jpeg/JpegDecoder.cs index d4ec048d3..6845314c1 100644 --- a/src/ImageSharp/Formats/Jpeg/JpegDecoder.cs +++ b/src/ImageSharp/Formats/Jpeg/JpegDecoder.cs @@ -4,7 +4,6 @@ using System.IO; using SixLabors.ImageSharp.Formats.Jpeg.GolangPort; -using SixLabors.ImageSharp.Formats.Jpeg.PdfJsPort; using SixLabors.ImageSharp.PixelFormats; namespace SixLabors.ImageSharp.Formats.Jpeg @@ -36,7 +35,7 @@ namespace SixLabors.ImageSharp.Formats.Jpeg { Guard.NotNull(stream, "stream"); - using (JpegDecoderCore decoder = new JpegDecoderCore(configuration, this)) + using (var decoder = new OrigJpegDecoderCore(configuration, this)) { return new PixelTypeInfo(decoder.DetectPixelSize(stream)); } diff --git a/src/ImageSharp/Formats/Jpeg/PdfJsPort/PdfJsJpegDecoder.cs b/src/ImageSharp/Formats/Jpeg/PdfJsPort/PdfJsJpegDecoder.cs index 37ce0151f..1458d54e5 100644 --- a/src/ImageSharp/Formats/Jpeg/PdfJsPort/PdfJsJpegDecoder.cs +++ b/src/ImageSharp/Formats/Jpeg/PdfJsPort/PdfJsJpegDecoder.cs @@ -27,5 +27,11 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.PdfJsPort return decoder.Decode(stream); } } + + /// + public PixelTypeInfo DetectPixelType(Configuration configuration, Stream stream) + { + throw new System.NotImplementedException(); + } } } \ No newline at end of file diff --git a/src/ImageSharp/Formats/PixelTypeInfo.cs b/src/ImageSharp/Formats/PixelTypeInfo.cs index c33154351..d4b72a00b 100644 --- a/src/ImageSharp/Formats/PixelTypeInfo.cs +++ b/src/ImageSharp/Formats/PixelTypeInfo.cs @@ -1,4 +1,4 @@ -namespace ImageSharp.Formats +namespace SixLabors.ImageSharp.Formats { /// /// Stores information about pixel diff --git a/tests/ImageSharp.Tests/Formats/Bmp/BmpDecoderTests.cs b/tests/ImageSharp.Tests/Formats/Bmp/BmpDecoderTests.cs index c6598fab8..b6f894386 100644 --- a/tests/ImageSharp.Tests/Formats/Bmp/BmpDecoderTests.cs +++ b/tests/ImageSharp.Tests/Formats/Bmp/BmpDecoderTests.cs @@ -8,6 +8,8 @@ using Xunit; namespace SixLabors.ImageSharp.Tests { + using System.IO; + using SixLabors.ImageSharp.Formats.Bmp; public class BmpDecoderTests : FileTestBase diff --git a/tests/ImageSharp.Tests/Formats/Gif/GifDecoderTests.cs b/tests/ImageSharp.Tests/Formats/Gif/GifDecoderTests.cs index f57b0f128..a13730eb6 100644 --- a/tests/ImageSharp.Tests/Formats/Gif/GifDecoderTests.cs +++ b/tests/ImageSharp.Tests/Formats/Gif/GifDecoderTests.cs @@ -11,6 +11,8 @@ using Xunit; // ReSharper disable InconsistentNaming namespace SixLabors.ImageSharp.Tests { + using System.IO; + public class GifDecoderTests { private const PixelTypes PixelTypes = Tests.PixelTypes.Rgba32 | Tests.PixelTypes.RgbaVector | Tests.PixelTypes.Argb32; diff --git a/tests/ImageSharp.Tests/TestUtilities/ReferenceCodecs/SystemDrawingReferenceDecoder.cs b/tests/ImageSharp.Tests/TestUtilities/ReferenceCodecs/SystemDrawingReferenceDecoder.cs index 23ff61eb3..d36fd2a14 100644 --- a/tests/ImageSharp.Tests/TestUtilities/ReferenceCodecs/SystemDrawingReferenceDecoder.cs +++ b/tests/ImageSharp.Tests/TestUtilities/ReferenceCodecs/SystemDrawingReferenceDecoder.cs @@ -45,5 +45,13 @@ namespace SixLabors.ImageSharp.Tests.TestUtilities.ReferenceCodecs } } } + + public PixelTypeInfo DetectPixelType(Configuration configuration, Stream stream) + { + using (var sourceBitmap = new System.Drawing.Bitmap(stream)) + { + return new PixelTypeInfo(System.Drawing.Image.GetPixelFormatSize(sourceBitmap.PixelFormat)); + } + } } } \ No newline at end of file diff --git a/tests/ImageSharp.Tests/TestUtilities/Tests/TestImageProviderTests.cs b/tests/ImageSharp.Tests/TestUtilities/Tests/TestImageProviderTests.cs index 88d7fa2b8..24becce2e 100644 --- a/tests/ImageSharp.Tests/TestUtilities/Tests/TestImageProviderTests.cs +++ b/tests/ImageSharp.Tests/TestUtilities/Tests/TestImageProviderTests.cs @@ -83,6 +83,11 @@ namespace SixLabors.ImageSharp.Tests return new Image(42, 42); } + public PixelTypeInfo DetectPixelType(Configuration configuration, Stream stream) + { + throw new NotImplementedException(); + } + // Couldn't make xUnit happy without this hackery: private static ConcurrentDictionary invocationCounts = new ConcurrentDictionary(); @@ -145,6 +150,11 @@ namespace SixLabors.ImageSharp.Tests return new Image(42, 42); } + public PixelTypeInfo DetectPixelType(Configuration configuration, Stream stream) + { + throw new NotImplementedException(); + } + private static ConcurrentDictionary invocationCounts = new ConcurrentDictionary(); private string callerName = null; diff --git a/tests/ImageSharp.Tests/TestImages/Formats/Bmp/bpp8.bmp b/tests/Images/Input/Bmp/bpp8.bmp similarity index 100% rename from tests/ImageSharp.Tests/TestImages/Formats/Bmp/bpp8.bmp rename to tests/Images/Input/Bmp/bpp8.bmp diff --git a/tests/ImageSharp.Tests/TestImages/Formats/Png/bpp1.png b/tests/Images/Input/Png/bpp1.png similarity index 100% rename from tests/ImageSharp.Tests/TestImages/Formats/Png/bpp1.png rename to tests/Images/Input/Png/bpp1.png diff --git a/tests/ImageSharp.Tests/TestImages/Formats/Png/gray_4bpp.png b/tests/Images/Input/Png/gray_4bpp.png similarity index 100% rename from tests/ImageSharp.Tests/TestImages/Formats/Png/gray_4bpp.png rename to tests/Images/Input/Png/gray_4bpp.png diff --git a/tests/ImageSharp.Tests/TestImages/Formats/Png/palette-8bpp.png b/tests/Images/Input/Png/palette-8bpp.png similarity index 100% rename from tests/ImageSharp.Tests/TestImages/Formats/Png/palette-8bpp.png rename to tests/Images/Input/Png/palette-8bpp.png