Basic File Format
An ANI file contains a RIFF Chunk with a HeaderID of 'ACON'. This RIFF Chunk must contain at least two subchunks: The header chunk 'anih' and a 'LIST' chunk containing one or more images. In addition to those it may contain a sequence chunk 'seq ' and a frame rate control chunk 'rate'.
Basic File Layout
Name | ID |
---|
RIFF | HeaderID = 'ACON' |
| anih | header chunk |
| LIST | HeaderID = 'fram' |
| | icon | single frame |
| | ... | |
| seq | (optional) specifies the display sequence of frames. Notice the space after the 'q'. |
| rate | (optional) specifies the display timing of frames |
Structure of the 'anih' header chunk.
Name | Size | Description |
---|
HeaderSize | 4 bytes | size of this structure (=32) |
NumFrames | 4 bytes | number of stored frames in this animation |
NumSteps | 4 bytes | number of steps in this animation (may include duplicate frames, = NumFrames, if no 'seq '-chunk is present) |
Width | 4 bytes | total width in pixels |
Height | 4 bytes | total height in pixels |
BitCount | 4 bytes | number of bits/pixel ColorDepth = 2BitCount |
NumPlanes | 4 bytes | =1 |
DisplayRate | 4 bytes | default display rate in 1/60s (Rate = 60 / DisplayRate fps) |
Flags | 4 bytes | currently only 2 bits are used |
| reserved | bits 31..2 | unused =0 |
| SequenceFlag | bit 1 | TRUE: File contains sequence data |
| IconFlag | bit 0 | TRUE: Frames are icon or cursor data FALSE: Frames are raw data |
Structure of the 'icon' chunks
Depending on the anih.Flags.IconFlag these chunks will contain either icon and cursor resources or raw images. Icons and cursors can be mixed within a file, but not together with raw images. If the file contains icons and cursors, they are included in their respective format, including their header. The first 4 bytes decide what format they are in. There are pages on both,
ICO and
CUR resources in this collection.
Raw images are
BMP files, stored without their header, using the Width, Height, BitCount and NumPlanes information in 'anih' for decoding.
- Whether the BMP's color map should be included if BitCount <= 8 is unknown. I haven't seen a ANI with raw images yet.
Structure of the 'seq ' chunk
Notice the space after the 'q' in 'seq '. This chunk defines an order in which the frames are to be displayed, referring to the order in which they appear in the 'fram' - list. There may very well be a 'seq '-chunk without a 'rate' chunk. If there is no 'seq '-chunk in the file, frames will be displayed in the order in which they appear in the frame list. If an ANI file is used as MS-Windows' cursor, the sequence will loop. There is no way of influencing that behavior.
Name | Size | Description |
---|
| Rate | 4 bytes | Frame Number 0 |
repeated anih.NumSteps times |
Structure of the 'rate' chunk
This chunk defines a display rate (in 1/60th sec) for every frame in the sequence. If there is no 'seq '-chunk in the file, it defines a display rate for every frame in the 'fram' - list.
Name | Size | Description |
---|
| Rate | 4 bytes | Display rate for frame 0 |
repeated anih.NumSteps times |