Skip to content

Commit f80aa76

Browse files
committed
Additional testcases for gif decoder
1 parent 94df8e3 commit f80aa76

File tree

38 files changed

+168
-0
lines changed

38 files changed

+168
-0
lines changed

tests/ImageSharp.Tests/Formats/Gif/GifDecoderTests.cs

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,41 @@ public void Decode_VerifyAllFrames<TPixel>(TestImageProvider<TPixel> provider)
3434
image.CompareToReferenceOutputMultiFrame(provider, ImageComparer.Exact);
3535
}
3636

37+
[Theory]
38+
[WithFile(TestImages.Gif.AnimatedLoop, PixelTypes.Rgba32)]
39+
[WithFile(TestImages.Gif.AnimatedLoopInterlaced, PixelTypes.Rgba32)]
40+
public void Decode_Animated<TPixel>(TestImageProvider<TPixel> provider)
41+
where TPixel : unmanaged, IPixel<TPixel>
42+
{
43+
using Image<TPixel> image = provider.GetImage();
44+
image.DebugSaveMultiFrame(provider);
45+
image.CompareToReferenceOutputMultiFrame(provider, ImageComparer.Exact);
46+
}
47+
48+
[Theory]
49+
[WithFile(TestImages.Gif.AnimatedTransparentNoRestore, PixelTypes.Rgba32)]
50+
[WithFile(TestImages.Gif.AnimatedTransparentRestorePrevious, PixelTypes.Rgba32)]
51+
[WithFile(TestImages.Gif.AnimatedTransparentLoop, PixelTypes.Rgba32)]
52+
[WithFile(TestImages.Gif.AnimatedTransparentFirstFrameRestorePrev, PixelTypes.Rgba32)]
53+
public void Decode_Animated_WithTransparency<TPixel>(TestImageProvider<TPixel> provider)
54+
where TPixel : unmanaged, IPixel<TPixel>
55+
{
56+
using Image<TPixel> image = provider.GetImage();
57+
image.DebugSaveMultiFrame(provider);
58+
image.CompareToReferenceOutputMultiFrame(provider, ImageComparer.Exact);
59+
}
60+
61+
[Theory]
62+
[WithFile(TestImages.Gif.StaticNontransparent, PixelTypes.Rgba32)]
63+
[WithFile(TestImages.Gif.StaticTransparent, PixelTypes.Rgba32)]
64+
public void Decode_Static_No_Animation<TPixel>(TestImageProvider<TPixel> provider)
65+
where TPixel : unmanaged, IPixel<TPixel>
66+
{
67+
using Image<TPixel> image = provider.GetImage();
68+
image.DebugSave(provider);
69+
image.CompareFirstFrameToReferenceOutput(ImageComparer.Exact, provider);
70+
}
71+
3772
[Theory]
3873
[WithFile(TestImages.Gif.Issues.Issue2450_A, PixelTypes.Rgba32)]
3974
[WithFile(TestImages.Gif.Issues.Issue2450_B, PixelTypes.Rgba32)]

tests/ImageSharp.Tests/TestImages.cs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -507,6 +507,31 @@ public static class Gif
507507
public const string Bit18RGBCube = "Gif/18-bit_RGB_Cube.gif";
508508
public const string Global256NoTrans = "Gif/global-256-no-trans.gif";
509509

510+
// Test imagages from: https://github.com/peterdn/gif-test-suite.git
511+
// Animated gif with 4 frames, looping forever, no transparency.
512+
public const string AnimatedLoop = "Gif/animated_loop.gif";
513+
514+
// Animated gif with 4 frames, interlaced, looping forever, no transparency.
515+
public const string AnimatedLoopInterlaced = "Gif/animated_loop_interlaced.gif";
516+
517+
// Transparent gif with 4 frames, loops forever.
518+
public const string AnimatedTransparentLoop = "Gif/animated_transparent_loop.gif";
519+
520+
// Transparent gif with 4 frames, loops forever, first frame restore previous.
521+
public const string AnimatedTransparentFirstFrameRestorePrev = "Gif/animated_transparent_firstframerestoreprev_loop.gif";
522+
523+
// Transparent gif with 4 transparent frames, loops forever, no dispose
524+
public const string AnimatedTransparentNoRestore = "Gif/animated_transparent_frame_norestore_loop.gif";
525+
526+
// Transparent gif with 4 transparent frames, loops forever, restore previous.
527+
public const string AnimatedTransparentRestorePrevious = "Gif/animated_transparent_frame_restoreprev_loop.gif";
528+
529+
// Static gif with no animation, no transparency.
530+
public const string StaticNontransparent = "Gif/static_nontransparent.gif";
531+
532+
// Static transparent gif with no animation.
533+
public const string StaticTransparent = "Gif/static_transparent.gif";
534+
510535
// Test images from https://github.com/robert-ancell/pygif/tree/master/test-suite
511536
public const string ZeroSize = "Gif/image-zero-size.gif";
512537
public const string ZeroHeight = "Gif/image-zero-height.gif";
Lines changed: 3 additions & 0 deletions
Loading
Lines changed: 3 additions & 0 deletions
Loading
Lines changed: 3 additions & 0 deletions
Loading
Lines changed: 3 additions & 0 deletions
Loading
Lines changed: 3 additions & 0 deletions
Loading
Lines changed: 3 additions & 0 deletions
Loading
Lines changed: 3 additions & 0 deletions
Loading
Lines changed: 3 additions & 0 deletions
Loading

0 commit comments

Comments
 (0)