AnimatedPngCreator.System.Drawing is the module to use System.Drawing for loading and writing the images AnimatedPngCreator Create animated PNGs (APNGs) easily and efficiently in .NET projects. The package provides a modular structure that separates core functionality from platform-specific wrappers, allowing developers to choose the appropriate image backend (e.g., System.Drawing or Skia) for their environment. Key Features: Generate animated PNGs from a sequence of images Modular design with separate core and wrapper packages Choose your preferred image backend without affecting core logic Compatible with multiple .NET frameworks through multi-targeting
$ dotnet add package AnimatedPngCreator.System.DrawingCreates animated PNG out ouf a sequence of Images.
Please use the newest version on NuGet.
Get the package on NuGet
Dispose the creator to end the creating process. On disposing the count of images will be written to the header.
24.08.2025 v2.0.0 New project stucture: AnimatedPngCreator and AnimatedPngCreator.System.Drawing or AnimatedPngCreator.SkiaSharp is needed
12.10.2018 Bug fixed, tests added, new static methods added - v1.0.3 merged to master
29.8.2018 Bug fixed, test added, v1.0.2 deployed on NuGet
27.8.2018 Filter added to detect unchanged pixels, console app added, v1.0.1 deployed on NuGet
V1.0.3 makes it possible to use the static Create method.
The third parameter is the time to show the frame, in milli seconds.
v2.0.0 Use BitmapFactory.FromFile instead of Image.FromFile and install AnimatedPngCreator.System.Drawing or AnimatedPngCreator.SkiaSharp
// Example 1:
var filePaths = new List<string>
{
"1.bmp", "2.bmp", "3.bmp"
};
CMK.AnimatedPngCreator.Create("out.png", filePaths, 1000);
// Example 2:
var images = new List<Image>
{
BitmapFactory.FromFile("1.bmp"),
BitmapFactory.FromFile("2.bmp"),
BitmapFactory.FromFile("3.bmp")
};
CMK.AnimatedPngCreator.Create("out.png", images, 1000);
// Example 3:
var frames = new List<Frame>
{
CMK.AnimatedPngCreator.Frame(BitmapFactory.FromFile("1.bmp"), 1000),
CMK.AnimatedPngCreator.Frame(BitmapFactory.FromFile("2.bmp"), 1000),
CMK.AnimatedPngCreator.Frame(BitmapFactory.FromFile("3.bmp"), 1000)
};
CMK.AnimatedPngCreator.Create("out.png", frames);
The filter to remove unchanged pixels is on by default. If you don't want to use the filter, you just have to pass a config to the constructor:
var config = new AnimatedPngCreator.Config
{
FilterUnchangedPixels = false
};
using (var apngCreator = new AnimatedPngCreator(outputFile, image1.Width, image1.Height, config))
Example 1:
// Add three images to an APNG
using CMK;
using System.Drawing;
using System.IO;
namespace ApngTest
{
class Program
{
static void Main(string[] args)
{
Image image1 = BitmapFactory.FromFile("filename1.bmp");
Image image2 = BitmapFactory.FromFile("filename2.jpg");
Image image3 = BitmapFactory.FromFile("filename3.png");
short frameDelay = 1000 / 5; //5 frames per second
using (FileStream outputFile = File.Create("animated.png"))
{
using (var apngCreator = new AnimatedPngCreator(outputFile, image1.Width, image1.Height))
{
apngCreator.WriteFrame(image1, frameDelay);
apngCreator.WriteFrame(image2, frameDelay);
apngCreator.WriteFrame(image3, frameDelay);
}
}
}
}
}
Example 2:
using CMK;
using System.Collections.Generic;
using System.Drawing;
using System.IO;
namespace ApngTest
{
class Program
{
static void Main(string[] args)
{
List<Image> images = new List<Image>
{
BitmapFactory.FromFile("filename1.bmp"),
BitmapFactory.FromFile("filename2.jpg"),
BitmapFactory.FromFile("filename3.png")
};
short frameDelay = 1000 / 5; //5 frames per second
using (FileStream outputFile = File.Create("animated.png"))
{
using (var apngCreator = new AnimatedPngCreator(outputFile, images[0].Width, images[0].Height))
{
foreach(var image in images)
{
apngCreator.WriteFrame(image, frameDelay);
}
}
}
}
}
}