Browse Source

add failing test for global quantization

pull/1574/head
Anton Firszov 6 years ago
parent
commit
c1033ffb6d
  1. 25
      tests/ImageSharp.Tests/Formats/Gif/GifEncoderTests.cs
  2. 1
      tests/ImageSharp.Tests/TestImages.cs
  3. 3
      tests/Images/Input/Gif/GlobalQuantizationTest.gif

25
tests/ImageSharp.Tests/Formats/Gif/GifEncoderTests.cs

@ -2,6 +2,7 @@
// Licensed under the Apache License, Version 2.0.
using System.IO;
using SixLabors.ImageSharp.Formats;
using SixLabors.ImageSharp.Formats.Gif;
using SixLabors.ImageSharp.Metadata;
using SixLabors.ImageSharp.PixelFormats;
@ -132,6 +133,30 @@ namespace SixLabors.ImageSharp.Tests.Formats.Gif
}
}
[Theory]
[WithFile(TestImages.Gif.GlobalQuantizationTest, PixelTypes.Rgba32)]
public void Encode_GlobalPalette_QuantizeMultipleFrames<TPixel>(TestImageProvider<TPixel> provider)
where TPixel : unmanaged, IPixel<TPixel>
{
using Image<TPixel> image = provider.GetImage();
var encoder = new GifEncoder()
{
ColorTableMode = GifColorTableMode.Global
};
string testOutputFile = provider.Utility.SaveTestOutputFile(
image,
"gif",
encoder,
appendPixelTypeToFileName: false,
appendSourceFileOrDescription: false);
IImageDecoder referenceDecoder = TestEnvironment.GetReferenceDecoder(testOutputFile);
using var encoded = Image.Load<TPixel>(testOutputFile, referenceDecoder);
ValidatorComparer.VerifySimilarity(image, encoded);
}
[Fact]
public void NonMutatingEncodePreservesPaletteCount()
{

1
tests/ImageSharp.Tests/TestImages.cs

@ -396,6 +396,7 @@ namespace SixLabors.ImageSharp.Tests
public const string Ratio4x1 = "Gif/base_4x1.gif";
public const string Ratio1x4 = "Gif/base_1x4.gif";
public const string LargeComment = "Gif/large_comment.gif";
public const string GlobalQuantizationTest = "Gif/GlobalQuantizationTest.gif";
// Test images from https://github.com/robert-ancell/pygif/tree/master/test-suite
public const string ZeroSize = "Gif/image-zero-size.gif";

3
tests/Images/Input/Gif/GlobalQuantizationTest.gif

@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:c67df4b08561c14054ed911e6cfc99f1fc726b32e2c7a5e2dbb8392e24109b5a
size 101868
Loading…
Cancel
Save