Introduction

The purpose of this tutorial is to show you how to use libpng with the APNG extensions to work with animated PNG images. The APNG specification can be found here. In this tutorial I assume you are familiar with this spec and are already a competent libpng user. For learning to use libpng, see the libpng manual.

To keep things simple, the examples used in this tutorial do not do any displaying but only convert an animated PNG into several simple ones and the reverse. Since you already know how to display a regular PNG image, this ought not bother you.

This tutorial is very much based on examples, but the examples here are just the simplest way I could think of to show you what you need to know about APNG. The point is to show you what you can do, not what you should do.

Overview

An animated PNG image is basically a usual PNG image with more then one set of pixel data. Any information in the old PNG chunks applies to each frame equally. The only exception is the information in the fcTl chunk, which is present for each frame that's expected to be displayed in an animated PNG image.

Basically the only difference in reading and writing an animated PNG image from a regular image is that image data needs to be read/written in a loop.