Browse Source

Add additional tga test cases

pull/1160/head
Brian Popow 6 years ago
parent
commit
ce35ce248a
  1. 85
      tests/ImageSharp.Tests/Formats/Tga/TgaDecoderTests.cs
  2. 6
      tests/ImageSharp.Tests/Formats/Tga/TgaEncoderTests.cs
  3. 42
      tests/ImageSharp.Tests/TestImages.cs
  4. 2
      tests/Images/External
  5. BIN
      tests/Images/Input/Tga/grayscale_LL.tga
  6. BIN
      tests/Images/Input/Tga/grayscale_UR.tga
  7. BIN
      tests/Images/Input/Tga/grayscale_a_UR.tga
  8. BIN
      tests/Images/Input/Tga/rgb24_top_left.tga
  9. BIN
      tests/Images/Input/Tga/rgb_a_LL.tga

85
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<TPixel>(TestImageProvider<TPixel> provider)
where TPixel : unmanaged, IPixel<TPixel>
{
using (Image<TPixel> image = provider.GetImage(TgaDecoder))
{
image.DebugSave(provider);
TgaTestUtils.CompareWithReferenceDecoder(provider, image);
}
}
[Theory]
[WithFile(Gray8BitTopRight, PixelTypes.Rgba32)]
public void TgaDecoder_CanDecode_Gray_WithTopRightOrigin_8Bit<TPixel>(TestImageProvider<TPixel> provider)
where TPixel : unmanaged, IPixel<TPixel>
{
using (Image<TPixel> image = provider.GetImage(TgaDecoder))
{
image.DebugSave(provider);
TgaTestUtils.CompareWithReferenceDecoder(provider, image);
}
}
[Theory]
[WithFile(Gray8BitBottomRight, PixelTypes.Rgba32)]
public void TgaDecoder_CanDecode_Gray_WithBottomRightOrigin_8Bit<TPixel>(TestImageProvider<TPixel> provider)
where TPixel : unmanaged, IPixel<TPixel>
{
using (Image<TPixel> image = provider.GetImage(TgaDecoder))
{
image.DebugSave(provider);
TgaTestUtils.CompareWithReferenceDecoder(provider, image);
}
}
[Theory]
[WithFile(Gray8BitRle, PixelTypes.Rgba32)]
public void TgaDecoder_CanDecode_RunLengthEncoded_Gray_8Bit<TPixel>(TestImageProvider<TPixel> provider)
@ -88,6 +124,21 @@ namespace SixLabors.ImageSharp.Tests.Formats.Tga
}
}
[Theory]
[WithFile(Gray16BitTopRight, PixelTypes.Rgba32)]
public void TgaDecoder_CanDecode_Gray_WithTopRightOrigin_16Bit<TPixel>(TestImageProvider<TPixel> provider)
where TPixel : unmanaged, IPixel<TPixel>
{
using (Image<TPixel> 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<TPixel>(TestImageProvider<TPixel> provider)
@ -173,8 +224,8 @@ namespace SixLabors.ImageSharp.Tests.Formats.Tga
}
[Theory]
[WithFile(Bit16, PixelTypes.Rgba32)]
public void TgaDecoder_CanDecode_16Bit<TPixel>(TestImageProvider<TPixel> provider)
[WithFile(Bit16BottomLeft, PixelTypes.Rgba32)]
public void TgaDecoder_CanDecode_WithBottomLeftOrigin_16Bit<TPixel>(TestImageProvider<TPixel> provider)
where TPixel : unmanaged, IPixel<TPixel>
{
using (Image<TPixel> 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<TPixel>(TestImageProvider<TPixel> provider)
where TPixel : unmanaged, IPixel<TPixel>
{
using (Image<TPixel> image = provider.GetImage(TgaDecoder))
{
image.DebugSave(provider);
TgaTestUtils.CompareWithReferenceDecoder(provider, image);
}
}
[Theory]
[WithFile(Bit24TopRight, PixelTypes.Rgba32)]
public void TgaDecoder_CanDecode_WithTopRightOrigin_24Bit<TPixel>(TestImageProvider<TPixel> provider)
@ -292,6 +355,18 @@ namespace SixLabors.ImageSharp.Tests.Formats.Tga
}
}
[Theory]
[WithFile(Bit32BottomLeft, PixelTypes.Rgba32)]
public void TgaDecoder_CanDecode_WithBottomLeftOrigin_32Bit<TPixel>(TestImageProvider<TPixel> provider)
where TPixel : unmanaged, IPixel<TPixel>
{
using (Image<TPixel> image = provider.GetImage(TgaDecoder))
{
image.DebugSave(provider);
TgaTestUtils.CompareWithReferenceDecoder(provider, image);
}
}
[Theory]
[WithFile(Bit32BottomRight, PixelTypes.Rgba32)]
public void TgaDecoder_CanDecode_WithBottomRightOrigin_32Bit<TPixel>(TestImageProvider<TPixel> 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<TPixel>(TestImageProvider<TPixel> provider)
where TPixel : unmanaged, IPixel<TPixel>
@ -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<TPixel>(TestImageProvider<TPixel> provider)
where TPixel : unmanaged, IPixel<TPixel>

6
tests/ImageSharp.Tests/Formats/Tga/TgaEncoderTests.cs

@ -26,8 +26,8 @@ namespace SixLabors.ImageSharp.Tests.Formats.Tga
new TheoryData<string, TgaBitsPerPixel>
{
{ 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<TPixel>(TestImageProvider<TPixel> provider, TgaBitsPerPixel bitsPerPixel)
where TPixel : unmanaged, IPixel<TPixel>
{

42
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";

2
tests/Images/External

@ -1 +1 @@
Subproject commit 6f81d7a95e285b1449efd4319a5cc7b071dec679
Subproject commit fe694a3938bea3565071a96cb1c90c4cbc586ff9

BIN
tests/Images/Input/Tga/grayscale_LL.tga

Binary file not shown.

BIN
tests/Images/Input/Tga/grayscale_UR.tga

Binary file not shown.

BIN
tests/Images/Input/Tga/grayscale_a_UR.tga

Binary file not shown.

BIN
tests/Images/Input/Tga/rgb24_top_left.tga

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

BIN
tests/Images/Input/Tga/rgb_a_LL.tga

Binary file not shown.

After

Width:  |  Height:  |  Size: 256 KiB

Loading…
Cancel
Save