Browse Source

Add additional tests for monochrome images

pull/1160/head
Brian Popow 6 years ago
parent
commit
41208b851d
  1. 112
      tests/ImageSharp.Tests/Formats/Tga/TgaDecoderTests.cs
  2. 10
      tests/ImageSharp.Tests/Formats/Tga/TgaEncoderTests.cs
  3. 11
      tests/ImageSharp.Tests/TestImages.cs
  4. BIN
      tests/Images/Input/Tga/grayscale_a_LL.tga
  5. BIN
      tests/Images/Input/Tga/grayscale_a_LR.tga
  6. BIN
      tests/Images/Input/Tga/grayscale_a_UL.tga
  7. BIN
      tests/Images/Input/Tga/grayscale_a_rle_LL.tga
  8. BIN
      tests/Images/Input/Tga/grayscale_a_rle_LR.tga
  9. BIN
      tests/Images/Input/Tga/grayscale_a_rle_UL.tga
  10. BIN
      tests/Images/Input/Tga/grayscale_a_rle_UR.tga

112
tests/ImageSharp.Tests/Formats/Tga/TgaDecoderTests.cs

@ -20,8 +20,104 @@ namespace SixLabors.ImageSharp.Tests.Formats.Tga
private static TgaDecoder TgaDecoder => new TgaDecoder();
[Theory]
[WithFile(Grey, PixelTypes.Rgba32)]
public void TgaDecoder_CanDecode_Uncompressed_MonoChrome<TPixel>(TestImageProvider<TPixel> provider)
[WithFile(Gray8Bit, PixelTypes.Rgba32)]
public void TgaDecoder_CanDecode_Uncompressed_MonoChrome_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_MonoChrome_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(Gray16Bit, PixelTypes.Rgba32)]
public void TgaDecoder_CanDecode_Uncompressed_MonoChrome_16Bit<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(Gray16BitBottomLeft, PixelTypes.Rgba32)]
public void TgaDecoder_CanDecode_Uncompressed_MonoChrome_WithBottomLeftOrigin_16Bit<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(Gray16BitBottomRight, PixelTypes.Rgba32)]
public void TgaDecoder_CanDecode_Uncompressed_MonoChrome_WithBottomRightOrigin_16Bit<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(Gray16BitRle, PixelTypes.Rgba32)]
public void TgaDecoder_CanDecode_RunLengthEncoded_MonoChrome_16Bit<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(Gray16BitRleBottomLeft, PixelTypes.Rgba32)]
public void TgaDecoder_CanDecode_RunLengthEncoded_MonoChrome_WithBottomLeftOrigin_16Bit<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(Gray16BitRleBottomRight, PixelTypes.Rgba32)]
public void TgaDecoder_CanDecode_RunLengthEncoded_MonoChrome_WithBottomRightOrigin_16Bit<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(Gray16BitRleTopRight, PixelTypes.Rgba32)]
public void TgaDecoder_CanDecode_RunLengthEncoded_MonoChrome_WithTopRightOrigin_16Bit<TPixel>(TestImageProvider<TPixel> provider)
where TPixel : unmanaged, IPixel<TPixel>
{
using (Image<TPixel> image = provider.GetImage(TgaDecoder))
@ -127,18 +223,6 @@ namespace SixLabors.ImageSharp.Tests.Formats.Tga
}
}
[Theory]
[WithFile(GreyRle, PixelTypes.Rgba32)]
public void TgaDecoder_CanDecode_RunLengthEncoded_MonoChrome<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(Bit16Rle, PixelTypes.Rgba32)]
public void TgaDecoder_CanDecode_RunLengthEncoded_16Bit<TPixel>(TestImageProvider<TPixel> provider)

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

@ -25,10 +25,10 @@ namespace SixLabors.ImageSharp.Tests.Formats.Tga
public static readonly TheoryData<string, TgaBitsPerPixel> TgaBitsPerPixelFiles =
new TheoryData<string, TgaBitsPerPixel>
{
{ Grey, TgaBitsPerPixel.Pixel8 },
{ Bit32, TgaBitsPerPixel.Pixel32 },
{ Bit24, TgaBitsPerPixel.Pixel24 },
{ Gray8Bit, TgaBitsPerPixel.Pixel8 },
{ Bit16, TgaBitsPerPixel.Pixel16 },
{ Bit24, TgaBitsPerPixel.Pixel24 },
{ Bit32, TgaBitsPerPixel.Pixel32 },
};
[Theory]
@ -37,14 +37,14 @@ namespace SixLabors.ImageSharp.Tests.Formats.Tga
{
var options = new TgaEncoder();
TestFile testFile = TestFile.Create(imagePath);
var testFile = TestFile.Create(imagePath);
using (Image<Rgba32> input = testFile.CreateRgba32Image())
{
using (var memStream = new MemoryStream())
{
input.Save(memStream, options);
memStream.Position = 0;
using (Image<Rgba32> output = Image.Load<Rgba32>(memStream))
using (var output = Image.Load<Rgba32>(memStream))
{
TgaMetadata meta = output.Metadata.GetTgaMetadata();
Assert.Equal(bmpBitsPerPixel, meta.BitsPerPixel);

11
tests/ImageSharp.Tests/TestImages.cs

@ -383,8 +383,15 @@ namespace SixLabors.ImageSharp.Tests
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 Bit32 = "Tga/targa_32bit.tga";
public const string Grey = "Tga/targa_8bit.tga";
public const string GreyRle = "Tga/targa_8bit_rle.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";

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

Binary file not shown.

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

Binary file not shown.

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

Binary file not shown.

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

Binary file not shown.

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

Binary file not shown.

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

Binary file not shown.

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

Binary file not shown.
Loading…
Cancel
Save