AnimatedPngCreator 1.0.3

Creates animated PNG out ouf a sequence of Images.

Install-Package AnimatedPngCreator -Version 1.0.3
dotnet add package AnimatedPngCreator --version 1.0.3
<PackageReference Include="AnimatedPngCreator" Version="1.0.3" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add AnimatedPngCreator --version 1.0.3
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: AnimatedPngCreator, 1.0.3"
For F# scripts that support #r syntax, copy this into the source code to reference the package.

AnimatedPngCreator

Creates 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.

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

From v1.0.3 it is possible to use the static Create method.

// 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>
{
    Image.FromFile("1.bmp"),
    Image.FromFile("2.bmp"),
    Image.FromFile("3.bmp")
};
CMK.AnimatedPngCreator.Create("out.png", images, 1000);

// Example 3:
var frames = new List<Frame>
{
    CMK.AnimatedPngCreator.Frame(Image.FromFile("1.bmp"), 1000),
    CMK.AnimatedPngCreator.Frame(Image.FromFile("2.bmp"), 1000),
    CMK.AnimatedPngCreator.Frame(Image.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 = Image.FromFile("filename1.bmp");
            Image image2 = Image.FromFile("filename2.jpg");
            Image image3 = Image.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>
            {
                Image.FromFile("filename1.bmp"),
                Image.FromFile("filename2.jpg"),
                Image.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);
                    }
                }
            }
        }
    }
}

AnimatedPngCreator

Creates 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.

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

From v1.0.3 it is possible to use the static Create method.

// 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>
{
    Image.FromFile("1.bmp"),
    Image.FromFile("2.bmp"),
    Image.FromFile("3.bmp")
};
CMK.AnimatedPngCreator.Create("out.png", images, 1000);

// Example 3:
var frames = new List<Frame>
{
    CMK.AnimatedPngCreator.Frame(Image.FromFile("1.bmp"), 1000),
    CMK.AnimatedPngCreator.Frame(Image.FromFile("2.bmp"), 1000),
    CMK.AnimatedPngCreator.Frame(Image.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 = Image.FromFile("filename1.bmp");
            Image image2 = Image.FromFile("filename2.jpg");
            Image image3 = Image.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>
            {
                Image.FromFile("filename1.bmp"),
                Image.FromFile("filename2.jpg"),
                Image.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);
                    }
                }
            }
        }
    }
}

Release Notes

Bug fixed, tests added, new static methods added

Dependencies

This package has no dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version History

Version Downloads Last updated
1.0.3 2,607 10/11/2018
1.0.2 419 8/29/2018
1.0.1 434 8/27/2018
1.0.0 408 8/23/2018