Skip to content
/ APNG.NET Public
forked from xupefei/APNG.NET

APNG (Animated PNG) for C#, WPF and .NET Standard

License

Notifications You must be signed in to change notification settings

jz5/APNG.NET

 
 

Repository files navigation

APNG.NET

A fully-managed APNG (Animated Portable Network Graphics) Parser

Original is https://github.com/xupefei/APNG.NET

Difference

  • LibAPNG is .NET Standard libary
  • Extensions for WPF (.NET Framework)
    • Convert each PNG frame to BitmapSource objects
    • Create key frame animation, So you can display APNG to Image control using Storyboard.
  • Remove XNA projects
  • Update to Visual Studio 2019

Usages

APNG to BitmapSource objects

var apng = new APNG("a.png");
var bitmaps = apng.ToBitmapSources();

// Save to PNG files
foreach (var (bitmap, index) in bitmaps.Select((item, index) => (item, index)))
{
    using (var fileStream = new FileStream($"{index}.png", FileMode.Create))
    {
        var encoder = new PngBitmapEncoder();
        encoder.Frames.Add(BitmapFrame.Create(bitmap));
        encoder.Save(fileStream);
    }
}

Display APNG to Image control

<Image Name="PngImage" />
var apng = new APNG("a.png");
if (apng.IsSimplePNG)
    PngImage.Source = BitmapFrame.Create(
        apng.DefaultImage.GetStream(), BitmapCreateOptions.None, BitmapCacheOption.OnLoad);
else
    apng.ToAnimation().CreateStoryboardFor(PngImage).Begin(PngImage);

About

APNG (Animated PNG) for C#, WPF and .NET Standard

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C# 100.0%