Animated Portable Graphics (APG) Format Model
Editor
"Goals" and "Design Model" sections extracted and revised from the
APG-0.94.4 proposal
Version 0.94.4-1, 30 September 2015
The current version of this document and the full APG proposal
may be found at
Some version of this document may be used to update the "Goals" and
"Design Model" sections of a future version of the APG proposal.
Comments on this document can be sent to the editor or to the
PNG specification maintainers at one of the following addresses:
Distribution of this memo is unlimited.
- Format for storing and transmitting animations compactly.
- Avoid the complexity of MNG.
- Accommodate both lossless (PNG) and lossy (JPEG) images.
- Allow "sprite" animation (reuseable images).
- Ability to accomplish GIF "restore_to_previous" disposal efficiently.
- Allow transparent animations in which opaque areas can
become transparent again.
- Allow variable interframe delays.
- Allow images to be displayed on-the-fly as they are decoded, or
to be stored for later use. MNG allowed both to happen at once but
APG does not allow that.
- No requirement for images to be stored or transmitted in a concrete
lossless form. This does not accommodate MNG-style delta images; in
MNG terms, all objects are "abstract".
- Allow looping of the entire animation or parts of it.
- Provide optional named seek points where the animation can be restarted.
- General
- The APG format is like PNG, with an 8-byte signature and PNG-style chunks.
- An APG animation consists of a sequence of frames together with timing
information (a non-zero interframe delay and timeout)
Times are expressed in "ticks" and each frame can have its own interframe
delay and timeout.
Frames can be optionally grouped into segments.
- Segments
- A segment is a group of frames, with a name, delimited by "NAME" chunks.
A player can ignore the "NAME" chunks and display the frames in the order
that they appear in the datastream, but is also free to select segments by
name and display them in any order. An APG file without "NAME" chunks
contains a single (prologue) segment that does not have a name.
- The first segment is the prologue segment, which contains all information
needed to restart the animation at the beginning of any segment.
- Frames
- Frames are delimited by layers that have a non-zero interframe delay.
- Each frame consists of the coalescence of zero or more layers with
zero time delay followed by one layer with a non-zero time delay (the top
layer). The frame itself inherits that non-zero time delay and the timeout
from its top layer.
- Frames can have transparency or an alpha channel.
- A frame has the dimensions specified on the MHDR chunk. Any areas
not defined by any layer are unchanged from the previous frame if the
compose mode is "none" or "over", and become transparent if the compose
mode of its top layer is "replace".
- The initial frame of a segment can have a name, which also serves
as the name of the segment. Other frames are not named.
- Layers
- An APG decoder creates a sequence of layers, each with a time delay, which
can be zero or a positive number, and optionally a timeout.
- Layers can have transparency or an alpha channel.
- A layer is created by decoding an image into Object 0 or by using the
PAST or PLAY chunk to copy a stored object in Object 0.
- A layer has its own dimensions and location with respect to the upper
left corner of the animation as specified on the MHDR chunk. These dimensions
and location are provided by the DEFI, PAST, or PLAY chunk that created
the layer.
- A layer has a compose mode that can be "none", "over", or "replace".
- Objects
- Images are handled internally as numbered objects.
- Each object has an associated set of attributes (dimensions, location, etc.)
- Object 0 is special in that it is not stored internally,
as it is intended for immediate on-the-fly output.
- Object 0 is always immediately output (this is a change from versions
0.93.3 and earlier, and from MNG).
- Other objects are sent to the output by composing or copying them
into Object 0.
- A decoder has write-only access to Object 0.
- Any object, including Object 0, can have transparency or an alpha channel.
- Object 0, but not necessarily any other object, has an associated
interframe delay and timeout.