The anih chunk holds an ANIHEADER structure: nine 32-bit
little-endian values, 36 bytes. With the chunk’s own 8-byte ID and length it takes 44
bytes of the file.
Fields
| Offset | Size | Type | Name | Description |
|---|---|---|---|---|
| 0 | 4 | u32 | cbSizeof | the size of the structure: 36 |
| 4 | 4 | u32 | cFrames | the number of distinct frames: the icon chunks in the fram list; at least 1 |
| 8 | 4 | u32 | cSteps | the number of steps in one cycle of the animation, and the number of entries in rate and seq |
| 12 | 4 | u32 | cx | width; unused when AF_ICON is set, written as 0 |
| 16 | 4 | u32 | cy | height; unused, 0 |
| 20 | 4 | u32 | cBitCount | bits per pixel; unused, 0 |
| 24 | 4 | u32 | cPlanes | colour planes; unused, 0 |
| 28 | 4 | u32 | jifRate | the default time to show each step, in jiffies of 1/60 second; used when there is no rate chunk |
| 32 | 4 | u32 | fl | flags (below) |
The image size and colour depth are taken from the frames themselves, which are complete icon or cursor files. The four size fields date from the raw-bitmap form that third-party notes describe, and are left at 0.
A reader should check that cbSizeof is 36 and that the counts are
consistent with the chunks that follow. Windows had serious security flaws in its
handling of malformed anih chunks (Microsoft security bulletins MS05-002
and MS07-017), the second caused by a file with two anih chunks.
Flags
| Bit | Mask | Name | Meaning |
|---|---|---|---|
| 0 | 0x1 | AF_ICON | each frame is a complete Windows icon or cursor file; always set in practice |
| 1 | 0x2 | AF_SEQUENCE | the file has a seq chunk |
| 2–31 | reserved; 0 |
AF_SEQUENCE appears in third-party descriptions and is written by the usual
editors, but it is informational: Windows reads a seq chunk whenever one
is present, whatever this bit says.
Timing
A jiffy is 1/60 second, about 16.7 ms. The animation shows step 0, then step 1, and
so on up to step cSteps − 1, then starts again. At step i it
shows frame seq[i], or frame i when there
is no seq chunk, for rate[i] jiffies,
or jifRate when there is no rate chunk.
| jifRate | Time per step | Steps per second |
|---|---|---|
| 1 | 16.7 ms | 60 |
| 6 | 100 ms | 10 |
| 15 | 250 ms | 4 |
| 60 | 1 s | 1 |
Example
Eight frames played forwards and then backwards, 14 steps, with the
seq chunk that does it:
| Field | Bytes | Value |
|---|---|---|
cbSizeof | 24 00 00 00 | 36 |
cFrames | 08 00 00 00 | 8 |
cSteps | 0E 00 00 00 | 14 |
cx to cPlanes | 16 × 00 | unused |
jifRate | 06 00 00 00 | 6 jiffies, 100 ms |
fl | 03 00 00 00 | AF_ICON and AF_SEQUENCE |
The seq chunk then holds 14 values: 0, 1, 2, 3, 4, 5, 6, 7, 6, 5, 4, 3,
2, 1.