ANI (file format)


The ANI file format is a graphics file format used for animated mouse cursors on the Microsoft Windows operating system.
The format is based on the Microsoft Resource Interchange File Format, which is used as a container for storing the individual frames of the animation.

File structure

The RIFF file structure description:

  1. define AF_ICON 0x1 // Frames are in Windows ICO format.
  2. define AF_SEQUENCE 0x2 // Animation is sequenced.
typedef struct ANIHEADER;
RIFF] // Title. Optional.
// Author. Optional.
)]
'anih' // ANI file header.
// Rate table.
// If the AF_SEQUENCE flag is set
// then the count is ANIHEADER.cSteps,
// otherwise ANIHEADER.cFrames.
// Sequence table.
// Should be present when AF_SEQUENCE flag is set.
// Count is ANIHEADER.cSteps.
LIST // Frame 1
'icon' // Frame 2
...
)
)

Individual frames are in ICO format.
Frame rates are measured in jiffies, with one jiffy equal to 1/60 of a second, or 16.666 ms.
Sequence information present in the file determines the sequence of frames, and allows frames to be played more than once, or in a different order than that in which they appear in the file. For example, if the animation contains three different images numbered 1, 2 and 3, and the sequence is 1-2-3-2-1, then only three icons need to be stored in the file, thereby saving storage space.
If an ANI file is used as Windows cursor, the sequence will loop. There is no way of influencing that behavior.
Animated Cursor Editor for Windows NT source code from MSDN October 2001 Library is a good source of knowledge about ANI file format structure.