|
|
|
@ -423,6 +423,55 @@ public partial class PngDecoderTests |
|
|
|
Assert.Equal(50, imageInfo.FrameMetadataCollection.Count); |
|
|
|
} |
|
|
|
|
|
|
|
[Theory] |
|
|
|
[InlineData(1)] |
|
|
|
[InlineData(2)] |
|
|
|
[InlineData(5)] |
|
|
|
[InlineData(10)] |
|
|
|
[InlineData(100)] |
|
|
|
public void Identify_AnimatedPng_FrameCount_MatchesDecode(int frameCount) |
|
|
|
{ |
|
|
|
using Image<Rgba32> image = new(10, 10, Color.Red.ToPixel<Rgba32>()); |
|
|
|
for (int i = 1; i < frameCount; i++) |
|
|
|
{ |
|
|
|
using ImageFrame<Rgba32> frame = new(Configuration.Default, 10, 10); |
|
|
|
image.Frames.AddFrame(frame); |
|
|
|
} |
|
|
|
|
|
|
|
using MemoryStream stream = new(); |
|
|
|
image.Save(stream, new PngEncoder()); |
|
|
|
stream.Position = 0; |
|
|
|
|
|
|
|
ImageInfo imageInfo = Image.Identify(stream); |
|
|
|
|
|
|
|
Assert.NotNull(imageInfo); |
|
|
|
Assert.Equal(frameCount, imageInfo.FrameMetadataCollection.Count); |
|
|
|
} |
|
|
|
|
|
|
|
[Theory] |
|
|
|
[InlineData(1)] |
|
|
|
[InlineData(2)] |
|
|
|
[InlineData(5)] |
|
|
|
[InlineData(10)] |
|
|
|
[InlineData(100)] |
|
|
|
public void Decode_AnimatedPng_FrameCount(int frameCount) |
|
|
|
{ |
|
|
|
using Image<Rgba32> image = new(10, 10, Color.Red.ToPixel<Rgba32>()); |
|
|
|
for (int i = 1; i < frameCount; i++) |
|
|
|
{ |
|
|
|
using ImageFrame<Rgba32> frame = new(Configuration.Default, 10, 10); |
|
|
|
image.Frames.AddFrame(frame); |
|
|
|
} |
|
|
|
|
|
|
|
using MemoryStream stream = new(); |
|
|
|
image.Save(stream, new PngEncoder()); |
|
|
|
stream.Position = 0; |
|
|
|
|
|
|
|
using Image<Rgba32> decoded = Image.Load<Rgba32>(stream); |
|
|
|
|
|
|
|
Assert.Equal(frameCount, decoded.Frames.Count); |
|
|
|
} |
|
|
|
|
|
|
|
[Theory] |
|
|
|
[WithFile(TestImages.Png.Bad.MissingDataChunk, PixelTypes.Rgba32)] |
|
|
|
public void Decode_MissingDataChunk_ThrowsException<TPixel>(TestImageProvider<TPixel> provider) |
|
|
|
|