Skip to content

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

varapng=newAPNG("a.png");varbitmaps=apng.ToBitmapSources();// Save to PNG filesforeach(var(bitmap,index)inbitmaps.Select((item,index)=>(item,index))){using(varfileStream=newFileStream($"{index}.png",FileMode.Create)){varencoder=newPngBitmapEncoder();encoder.Frames.Add(BitmapFrame.Create(bitmap));encoder.Save(fileStream);}}

Display APNG to Image control

<ImageName="PngImage" />
varapng=newAPNG("a.png");if(apng.IsSimplePNG)PngImage.Source=BitmapFrame.Create(apng.DefaultImage.GetStream(),BitmapCreateOptions.None,BitmapCacheOption.OnLoad);elseapng.ToAnimation().CreateStoryboardFor(PngImage).Begin(PngImage);

About

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

Resources

Stars

12 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages