Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

ANM animations

ANM files store Deluxe Paint animations as indexed bitmap deltas in LPF pages.

This is the LPF animation format, distinct from IFF ANIM containers. See LBM for IFF bitmaps.

Overall Structure

[LPF header — page counts, dimensions, encoding, and frame rate]
[Color-cycle records — authored palette ranges]
[Palette — 256 BGRX entries]
[Page table — 256 page descriptors]
[Large pages — record sizes and RunSkipDump bitmap records]

All multibyte integers are little-endian.

Header and palette

The header occupies 128 bytes.

OffsetSizeTypeNameDescription
0x004[u8; 4]signatureLPF
0x042u16max_pagesPage-table capacity, 256
0x062u16page_countNumber of active pages
0x084u32record_countTotal records, including the loop delta
0x0C2u16max_records_per_pageAuthored record capacity
0x0E2u16page_table_offsetAbsolute table position
0x104[u8; 4]content_typeANIM
0x142u16widthPixel width
0x162u16heightPixel height
0x181u8variantBitmap variant, zero
0x191u8versionFormat version
0x1A1u8has_last_deltaFinal record is a loop delta
0x1B1u8last_delta_validLoop delta validity flag
0x1C1u8pixel_typeIndexed eight-bit pixels, zero
0x1D1u8compressionRunSkipDump, 1
0x1E1u8other_records_per_frameAdditional record types, zero
0x1F1u8bitmap_typeSingle bitmap, 1
0x2032[u8; 32]record_typesRecord-type fields
0x404u32frame_countAuthored frame-count field
0x442u16frames_per_secondPlayback rate
0x4658[u8; 58]reservedReserved header bytes

Sixteen eight-byte color-cycle records follow at 0x80. The palette begins at 0x100, with 256 entries in blue, green, red, unused order. Pixel index zero is opaque.

Page table and large pages

Each page descriptor is six bytes:

OffsetSizeTypeNameDescription
+0x002u16base_recordFirst record number in the page
+0x022u16record_countLow 14 bits contain the record count; high bits mark continuation records
+0x042u16data_sizeTotal record payload bytes

Page i begins at page_table_offset + 256 * 6 + i * 65536. Its header repeats the descriptor, followed by a reserved word, one u16 size per record, and the record payloads. The last physical page can end before its 64 KiB boundary. Playback follows record numbers rather than physical page order.

Bitmap records

A bitmap record begins with byte 0x42 (B), a zero padding flag, and a two-byte unknown_02 field. RunSkipDump operations follow. Each record starts its output cursor at pixel zero; skipped pixels retain the preceding frame.

ControlOperation
0x01 through 0x7FCopy that many following pixel indices
0x00Read an eight-bit count and index; repeat the index
0x81 through 0xFFSkip the low-seven-bit count
0x80Read a little-endian extended control word

Extended words select these operations:

WordOperation
0x0000End the record
0x0001 through 0x3FFFSkip that many pixels
0x4001 through 0x7FFFSkip the low-14-bit count plus 0x4000 pixels
0x8001 through 0xBFFFCopy the low-14-bit count of following indices
0xC001 through 0xFFFFRepeat the following index for the low-14-bit count
0x4000, 0xC000No operation

0x8000 is invalid. An eight-bit repeat count of zero is also a no-op, but still consumes its index byte.

Playback and looping

gui.anm plays at 10 frames per second. Its final record converts the last display frame back to the first. This loop delta is excluded from the displayed frame sequence. The authored frame-count field includes that record.

External References