diff --git a/tests/ImageSharp.Tests/Formats/Png/PngEncoderTests.cs b/tests/ImageSharp.Tests/Formats/Png/PngEncoderTests.cs index 2584391bb..04503330e 100644 --- a/tests/ImageSharp.Tests/Formats/Png/PngEncoderTests.cs +++ b/tests/ImageSharp.Tests/Formats/Png/PngEncoderTests.cs @@ -195,6 +195,49 @@ namespace SixLabors.ImageSharp.Tests.Formats.Png } } + [Theory] + // does the following make sense? Or is it supposed to encode a 16bpp with two 8bit channels? + [WithBlankImages(1, 1, PixelTypes.Alpha8, PngColorType.GrayscaleWithAlpha, PngBitDepth.Bit8)] + [WithBlankImages(1, 1, PixelTypes.Argb32, PngColorType.RgbWithAlpha, PngBitDepth.Bit8)] + // [WithBlankImages(1, 1, PixelTypes.Bgr565, Can't reasonably be inferred)] + // [WithBlankImages(1, 1, PixelTypes.Bgra4444, Can't reasonably be inferred)] + // [WithBlankImages(1, 1, PixelTypes.Byte4, I'm not sure)] + // [WithBlankImages(1, 1, PixelTypes.HalfSingle, I'm not sure)] + // [WithBlankImages(1, 1, PixelTypes.HalfVector2, I'm not sure)] + // [WithBlankImages(1, 1, PixelTypes.HalfVector4, I'm not sure)] + // [WithBlankImages(1, 1, PixelTypes.NormalizedByte2, I'm not sure)] + // [WithBlankImages(1, 1, PixelTypes.NormalizedByte4, I'm not sure)] + // [WithBlankImages(1, 1, PixelTypes.NormalizedShort4, I'm not sure)] + // [WithBlankImages(1, 1, PixelTypes.Rg32, I'm not sure)] + // [WithBlankImages(1, 1, PixelTypes.Rgba1010102, I'm not sure)] + // [WithBlankImages(1, 1, PixelTypes.Rgba32, PngColorType.RgbWithAlpha, PngBitDepth.Bit8)] + // [WithBlankImages(1, 1, PixelTypes.Rgba64, PngColorType.RgbWithAlpha, PngBitDepth.Bit16)] + // [WithBlankImages(1, 1, PixelTypes.RgbaVector, I'm not sure)] + // [WithBlankImages(1, 1, PixelTypes.Short2, I'm not sure)] + // [WithBlankImages(1, 1, PixelTypes.Short4, I'm not sure)] + [WithBlankImages(1, 1, PixelTypes.Rgb24, PngColorType.Rgb, PngBitDepth.Bit8)] + // [WithBlankImages(1, 1, PixelTypes.Bgr24, I'm not sure)] + // [WithBlankImages(1, 1, PixelTypes.Bgra32, I'm not sure)] + [WithBlankImages(1, 1, PixelTypes.Rgb48, PngColorType.Rgb, PngBitDepth.Bit16)] + // [WithBlankImages(1, 1, PixelTypes.Bgra5551, I'm not sure)] + [WithBlankImages(1, 1, PixelTypes.Gray8, PngColorType.Grayscale, PngBitDepth.Bit8)] + [WithBlankImages(1, 1, PixelTypes.Gray16, PngColorType.Grayscale, PngBitDepth.Bit8)] + public void InfersColorTypeAndBitDepth(TestImageProvider provider, PngColorType pngColorType, PngBitDepth pngBitDepth) + where TPixel : struct, IPixel + { + Stream stream = new MemoryStream(); + PngEncoder encoder = new PngEncoder(); + encoder.Encode(provider.GetImage(), stream); + + stream.Seek(0, SeekOrigin.Begin); + + PngDecoder decoder = new PngDecoder(); + + Image image = decoder.Decode(Configuration.Default, stream); + + Assert.True(image is Image); + } + [Theory] [WithFile(TestImages.Png.Palette8Bpp, nameof(PaletteLargeOnly), PixelTypes.Rgba32)] public void PaletteColorType_WuQuantizer(TestImageProvider provider, int paletteSize) diff --git a/tests/ImageSharp.Tests/TestUtilities/PixelTypes.cs b/tests/ImageSharp.Tests/TestUtilities/PixelTypes.cs index 78431f31a..36c08a848 100644 --- a/tests/ImageSharp.Tests/TestUtilities/PixelTypes.cs +++ b/tests/ImageSharp.Tests/TestUtilities/PixelTypes.cs @@ -62,6 +62,8 @@ namespace SixLabors.ImageSharp.Tests Gray8 = 1 << 23, + Gray16 = 1 << 24, + // TODO: Add multi-flag entries by rules defined in PackedPixelConverterHelper // "All" is handled as a separate, individual case instead of using bitwise OR