A library to display animated GIF, PNG and WebP images
$ dotnet add package AnimatedImageA library to read animated GIF images , animated PNG images and animated WEBP images, usable in code.
When displaying in the UI, consider using AnimatedImage.Avalonia or AnimatedImage.Wpf instead of this library.
This library abstracts pixel read/write operations, requiring you to implement them yourself. For implementations using SkiaSharp, please refer to BitmapFaceFactory and BitmapFace.
The following code opens a GIF image and renders its frames.
// Read image file
using var imageStream = File.Open("/path/to/image.gif", FileMode.Open);
FrameRenderer.TryCreate(imageStream, new BitmapFaceFactory(), out var renderer);
// If you want to draw an image by frame index.
renderer.ProcessFrame(9);
// If you want to draw an image by time span.
renderer.ProcessFrame(TimeSpan.FromSeconds(34));
// Get the rendererd image.
var bitmapface = (BitmapFace)renderer.Current;
SKBitmap image = bitmapface.Bitmap;
To use WebP, AnimatedImage.Native library is required.
Image control; no need to use a specific control