APNG Tutorial | ||
---|---|---|
<<< Previous | Next >>> |
In this section we will read several non-animated PNG images and create an animated PNG image out of them. To keep things simple, it is assumed that every image given on the command-line is of the same configuration (number of bits per pixel, pallete, etc). To create the source images you can use your favourite image editor to create one regular PNG image, then make some changes to it and save it with a different name, make some more changes, and so on.
An overview of what we're going to do:
Create a png_struct and an info_struct for the animated image (the one we're writing).
Once the information from the first image is read:
Fill the general PNG information in the animated image using the info from the first simple image given on the command line
Set the acTl chunk for the animation and the fcTl chunk for the first frame
Write the animated image info
For each png image given on the command line (image data from each will end up beng a frame):
Create a png_struct and an info_struct for the simple image (the one we're reading)
Read the simple image information
Read the simple image data
png_write_frame_head()
Write the image data
png_write_frame_tail()
Destroy the structs used for reading the simple image
png_write_end()
For simplicity's sake the frame information is set to minimalistic values for each frame: no offset, 1 second delay and only the APNG_RENDER_OP_DISPOSE_BACKGROUND render flag.
The commented out png_write_frame_head() call should give you an idea about how to give each frame different settings if you so desire.
<<< Previous | Home | Next >>> |
Source code | Source code |