diff --git a/tests/ImageSharp.Tests/Formats/Tga/TgaDecoderTests.cs b/tests/ImageSharp.Tests/Formats/Tga/TgaDecoderTests.cs index d9f51701e..ccd00b49f 100644 --- a/tests/ImageSharp.Tests/Formats/Tga/TgaDecoderTests.cs +++ b/tests/ImageSharp.Tests/Formats/Tga/TgaDecoderTests.cs @@ -31,6 +31,42 @@ namespace SixLabors.ImageSharp.Tests.Formats.Tga } } + [Theory] + [WithFile(Gray8BitBottomLeft, PixelTypes.Rgba32)] + public void TgaDecoder_CanDecode_Gray_WithBottomLeftOrigin_8Bit(TestImageProvider provider) + where TPixel : unmanaged, IPixel + { + using (Image image = provider.GetImage(TgaDecoder)) + { + image.DebugSave(provider); + TgaTestUtils.CompareWithReferenceDecoder(provider, image); + } + } + + [Theory] + [WithFile(Gray8BitTopRight, PixelTypes.Rgba32)] + public void TgaDecoder_CanDecode_Gray_WithTopRightOrigin_8Bit(TestImageProvider provider) + where TPixel : unmanaged, IPixel + { + using (Image image = provider.GetImage(TgaDecoder)) + { + image.DebugSave(provider); + TgaTestUtils.CompareWithReferenceDecoder(provider, image); + } + } + + [Theory] + [WithFile(Gray8BitBottomRight, PixelTypes.Rgba32)] + public void TgaDecoder_CanDecode_Gray_WithBottomRightOrigin_8Bit(TestImageProvider provider) + where TPixel : unmanaged, IPixel + { + using (Image image = provider.GetImage(TgaDecoder)) + { + image.DebugSave(provider); + TgaTestUtils.CompareWithReferenceDecoder(provider, image); + } + } + [Theory] [WithFile(Gray8BitRle, PixelTypes.Rgba32)] public void TgaDecoder_CanDecode_RunLengthEncoded_Gray_8Bit(TestImageProvider provider) @@ -88,6 +124,21 @@ namespace SixLabors.ImageSharp.Tests.Formats.Tga } } + [Theory] + [WithFile(Gray16BitTopRight, PixelTypes.Rgba32)] + public void TgaDecoder_CanDecode_Gray_WithTopRightOrigin_16Bit(TestImageProvider provider) + where TPixel : unmanaged, IPixel + { + using (Image image = provider.GetImage(TgaDecoder)) + { + image.DebugSave(provider); + + // Using here the reference output instead of the the reference decoder, + // because the reference decoder output seems not to be correct for 16bit gray images. + image.CompareToReferenceOutput(ImageComparer.Exact, provider); + } + } + [Theory] [WithFile(Gray16BitRle, PixelTypes.Rgba32)] public void TgaDecoder_CanDecode_RunLengthEncoded_Gray_16Bit(TestImageProvider provider) @@ -173,8 +224,8 @@ namespace SixLabors.ImageSharp.Tests.Formats.Tga } [Theory] - [WithFile(Bit16, PixelTypes.Rgba32)] - public void TgaDecoder_CanDecode_16Bit(TestImageProvider provider) + [WithFile(Bit16BottomLeft, PixelTypes.Rgba32)] + public void TgaDecoder_CanDecode_WithBottomLeftOrigin_16Bit(TestImageProvider provider) where TPixel : unmanaged, IPixel { using (Image image = provider.GetImage(TgaDecoder)) @@ -208,6 +259,18 @@ namespace SixLabors.ImageSharp.Tests.Formats.Tga } } + [Theory] + [WithFile(Bit24BottomLeft, PixelTypes.Rgba32)] + public void TgaDecoder_CanDecode_WithBottomLeftOrigin_24Bit(TestImageProvider provider) + where TPixel : unmanaged, IPixel + { + using (Image image = provider.GetImage(TgaDecoder)) + { + image.DebugSave(provider); + TgaTestUtils.CompareWithReferenceDecoder(provider, image); + } + } + [Theory] [WithFile(Bit24TopRight, PixelTypes.Rgba32)] public void TgaDecoder_CanDecode_WithTopRightOrigin_24Bit(TestImageProvider provider) @@ -292,6 +355,18 @@ namespace SixLabors.ImageSharp.Tests.Formats.Tga } } + [Theory] + [WithFile(Bit32BottomLeft, PixelTypes.Rgba32)] + public void TgaDecoder_CanDecode_WithBottomLeftOrigin_32Bit(TestImageProvider provider) + where TPixel : unmanaged, IPixel + { + using (Image image = provider.GetImage(TgaDecoder)) + { + image.DebugSave(provider); + TgaTestUtils.CompareWithReferenceDecoder(provider, image); + } + } + [Theory] [WithFile(Bit32BottomRight, PixelTypes.Rgba32)] public void TgaDecoder_CanDecode_WithBottomRightOrigin_32Bit(TestImageProvider provider) @@ -477,8 +552,8 @@ namespace SixLabors.ImageSharp.Tests.Formats.Tga } [Theory] - [WithFile(Bit16, PixelTypes.Rgba32)] - [WithFile(Bit24, PixelTypes.Rgba32)] + [WithFile(Bit16BottomLeft, PixelTypes.Rgba32)] + [WithFile(Bit24BottomLeft, PixelTypes.Rgba32)] [WithFile(Bit32, PixelTypes.Rgba32)] public void TgaDecoder_DegenerateMemoryRequest_ShouldTranslateTo_ImageFormatException(TestImageProvider provider) where TPixel : unmanaged, IPixel @@ -489,7 +564,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Tga } [Theory] - [WithFile(Bit24, PixelTypes.Rgba32)] + [WithFile(Bit24BottomLeft, PixelTypes.Rgba32)] [WithFile(Bit32, PixelTypes.Rgba32)] public void TgaDecoder_CanDecode_WithLimitedAllocatorBufferCapacity(TestImageProvider provider) where TPixel : unmanaged, IPixel diff --git a/tests/ImageSharp.Tests/Formats/Tga/TgaEncoderTests.cs b/tests/ImageSharp.Tests/Formats/Tga/TgaEncoderTests.cs index c6b8b71f9..4e3e2d24c 100644 --- a/tests/ImageSharp.Tests/Formats/Tga/TgaEncoderTests.cs +++ b/tests/ImageSharp.Tests/Formats/Tga/TgaEncoderTests.cs @@ -26,8 +26,8 @@ namespace SixLabors.ImageSharp.Tests.Formats.Tga new TheoryData { { Gray8Bit, TgaBitsPerPixel.Pixel8 }, - { Bit16, TgaBitsPerPixel.Pixel16 }, - { Bit24, TgaBitsPerPixel.Pixel24 }, + { Bit16BottomLeft, TgaBitsPerPixel.Pixel16 }, + { Bit24BottomLeft, TgaBitsPerPixel.Pixel24 }, { Bit32, TgaBitsPerPixel.Pixel32 }, }; @@ -124,7 +124,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Tga [Theory] [WithFile(Bit32, PixelTypes.Rgba32, TgaBitsPerPixel.Pixel32)] - [WithFile(Bit24, PixelTypes.Rgba32, TgaBitsPerPixel.Pixel24)] + [WithFile(Bit24BottomLeft, PixelTypes.Rgba32, TgaBitsPerPixel.Pixel24)] public void TgaEncoder_WorksWithDiscontiguousBuffers(TestImageProvider provider, TgaBitsPerPixel bitsPerPixel) where TPixel : unmanaged, IPixel { diff --git a/tests/ImageSharp.Tests/TestImages.cs b/tests/ImageSharp.Tests/TestImages.cs index 197210f67..38ef8d9e2 100644 --- a/tests/ImageSharp.Tests/TestImages.cs +++ b/tests/ImageSharp.Tests/TestImages.cs @@ -375,40 +375,54 @@ namespace SixLabors.ImageSharp.Tests public static class Tga { + public const string Gray8Bit = "Tga/targa_8bit.tga"; + public const string Gray8BitBottomLeft = "Tga/grayscale_LL.tga"; + public const string Gray8BitTopRight = "Tga/grayscale_UR.tga"; + public const string Gray8BitBottomRight = "Tga/grayscale_UR.tga"; + public const string Gray8BitRle = "Tga/targa_8bit_rle.tga"; + public const string Bit15 = "Tga/rgb15.tga"; public const string Bit15Rle = "Tga/rgb15rle.tga"; - public const string Bit16 = "Tga/targa_16bit.tga"; + public const string Bit16BottomLeft = "Tga/targa_16bit.tga"; public const string Bit16PalRle = "Tga/ccm8.tga"; - public const string Bit24 = "Tga/targa_24bit.tga"; - public const string Bit24TopRight = "Tga/rgb_UR.tga"; + + public const string Gray16Bit = "Tga/grayscale_a_UL.tga"; + public const string Gray16BitBottomLeft = "Tga/grayscale_a_LL.tga"; + public const string Gray16BitBottomRight = "Tga/grayscale_a_LR.tga"; + public const string Gray16BitTopRight = "Tga/grayscale_a_UR.tga"; + public const string Gray16BitRle = "Tga/grayscale_a_rle_UL.tga"; + public const string Gray16BitRleBottomLeft = "Tga/grayscale_a_rle_LL.tga"; + public const string Gray16BitRleBottomRight = "Tga/grayscale_a_rle_LR.tga"; + public const string Gray16BitRleTopRight = "Tga/grayscale_a_rle_UR.tga"; + + public const string Bit24 = "Tga/rgb24_top_left.tga"; + public const string Bit24BottomLeft = "Tga/targa_24bit.tga"; public const string Bit24BottomRight = "Tga/rgb_LR.tga"; + public const string Bit24TopRight = "Tga/rgb_UR.tga"; public const string Bit24TopLeft = "Tga/targa_24bit_pal_origin_topleft.tga"; + public const string Bit24RleTopLeft = "Tga/targa_24bit_rle_origin_topleft.tga"; public const string Bit24RleTopRight = "Tga/rgb_rle_UR.tga"; public const string Bit24RleBottomRight = "Tga/rgb_rle_LR.tga"; + public const string Bit32 = "Tga/targa_32bit.tga"; + public const string Bit32BottomLeft = "Tga/rgb_a_LL.tga"; + public const string Bit32TopRight = "Tga/rgb_a_UR.tga"; + public const string Bit32BottomRight = "Tga/rgb_a_LR.tga"; + public const string Bit32Pal = "Tga/indexed_a_UL.tga"; public const string Bit32PalBottomLeft = "Tga/indexed_a_LL.tga"; public const string Bit32PalBottomRight = "Tga/indexed_a_LR.tga"; public const string Bit32PalTopRight = "Tga/indexed_a_UR.tga"; - public const string Bit32TopRight = "Tga/rgb_a_UR.tga"; - public const string Bit32BottomRight = "Tga/rgb_a_LR.tga"; public const string Bit32RleTopRight = "Tga/rgb_a_rle_UR.tga"; public const string Bit32RleBottomRight = "Tga/rgb_a_rle_LR.tga"; - public const string Gray8Bit = "Tga/targa_8bit.tga"; - public const string Gray8BitRle = "Tga/targa_8bit_rle.tga"; - public const string Gray16Bit = "Tga/grayscale_a_UL.tga"; - public const string Gray16BitBottomLeft = "Tga/grayscale_a_LL.tga"; - public const string Gray16BitBottomRight = "Tga/grayscale_a_LR.tga"; - public const string Gray16BitRle = "Tga/grayscale_a_rle_UL.tga"; - public const string Gray16BitRleBottomLeft = "Tga/grayscale_a_rle_LL.tga"; - public const string Gray16BitRleBottomRight = "Tga/grayscale_a_rle_LR.tga"; - public const string Gray16BitRleTopRight = "Tga/grayscale_a_rle_UR.tga"; + public const string Bit16Rle = "Tga/targa_16bit_rle.tga"; public const string Bit24Rle = "Tga/targa_24bit_rle.tga"; public const string Bit32Rle = "Tga/targa_32bit_rle.tga"; public const string Bit16Pal = "Tga/targa_16bit_pal.tga"; public const string Bit24Pal = "Tga/targa_24bit_pal.tga"; + public const string NoAlphaBits16Bit = "Tga/16bit_noalphabits.tga"; public const string NoAlphaBits16BitRle = "Tga/16bit_rle_noalphabits.tga"; public const string NoAlphaBits32Bit = "Tga/32bit_no_alphabits.tga"; diff --git a/tests/Images/External b/tests/Images/External index 6f81d7a95..fe694a393 160000 --- a/tests/Images/External +++ b/tests/Images/External @@ -1 +1 @@ -Subproject commit 6f81d7a95e285b1449efd4319a5cc7b071dec679 +Subproject commit fe694a3938bea3565071a96cb1c90c4cbc586ff9 diff --git a/tests/Images/Input/Tga/grayscale_LL.tga b/tests/Images/Input/Tga/grayscale_LL.tga new file mode 100644 index 000000000..fe9ba822f Binary files /dev/null and b/tests/Images/Input/Tga/grayscale_LL.tga differ diff --git a/tests/Images/Input/Tga/grayscale_UR.tga b/tests/Images/Input/Tga/grayscale_UR.tga new file mode 100644 index 000000000..dc09c5f38 Binary files /dev/null and b/tests/Images/Input/Tga/grayscale_UR.tga differ diff --git a/tests/Images/Input/Tga/grayscale_a_UR.tga b/tests/Images/Input/Tga/grayscale_a_UR.tga new file mode 100644 index 000000000..f09a8c153 Binary files /dev/null and b/tests/Images/Input/Tga/grayscale_a_UR.tga differ diff --git a/tests/Images/Input/Tga/rgb24_top_left.tga b/tests/Images/Input/Tga/rgb24_top_left.tga new file mode 100644 index 000000000..2ad891c28 Binary files /dev/null and b/tests/Images/Input/Tga/rgb24_top_left.tga differ diff --git a/tests/Images/Input/Tga/rgb_a_LL.tga b/tests/Images/Input/Tga/rgb_a_LL.tga new file mode 100644 index 000000000..746bc9e00 Binary files /dev/null and b/tests/Images/Input/Tga/rgb_a_LL.tga differ