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

LBM packed bitmaps

LBM files store IFF bitmap forms containing a header, palette, and pixel data.

gui.lbm uses the PBM form type. Its pixels are packed bytes rather than the separate bitplanes used by ILBM.

Overall Structure

[FORM header — container size and PBM form type]
[BMHD chunk — dimensions and pixel encoding]
[CMAP chunk — RGB palette]
[Additional chunks — application settings, color ranges, and thumbnail]
[BODY chunk — scanline pixel data]

All multibyte integers are big-endian.

IFF container

OffsetSizeTypeNameDescription
0x004[u8; 4]tagFORM
0x044u32sizeBytes following this size field
0x084[u8; 4]form_typePBM , including the trailing space

Each child chunk begins with a four-byte tag and a big-endian u32 payload size. Odd-sized payloads have one padding byte. The size excludes this padding. Unknown chunks remain independent of pixel decoding.

BMHD bitmap header

The header payload is 20 bytes.

OffsetSizeTypeNameDescription
+0x002u16widthVisible pixel width
+0x022u16heightVisible pixel height
+0x042i16xAuthored X position
+0x062i16yAuthored Y position
+0x081u8depthBits per pixel; 8
+0x091u8masking0 for opaque pixels, 2 for a transparent palette index
+0x0A1u8compression0 for raw rows, 1 for ByteRun1
+0x0B1u8reservedReserved byte
+0x0C2u16transparent_colorTransparent index when masking is 2
+0x0E1u8x_aspectHorizontal pixel aspect
+0x0F1u8y_aspectVertical pixel aspect
+0x102i16page_widthAuthored page width
+0x122i16page_heightAuthored page height

Palette and pixel data

CMAP contains three-byte RGB entries. Each component uses its full eight-bit range. BODY stores rows from top to bottom. Each row is padded to an even byte count; padding is excluded from the visible image.

ByteRun1 interprets each control byte as signed:

ControlOperation
0 through 127Copy the next control + 1 bytes
-127 through -1Repeat the next byte 1 - control times
-128No operation

Each row decodes independently. With masking zero, palette index zero is opaque.

Additional chunks

gui.lbm also contains DPPS, CRNG, and TINY chunks. They do not change the stored BODY pixels. A CRNG payload is eight bytes:

OffsetSizeTypeNameDescription
+0x002u16reservedReserved word
+0x022u16rateColor-cycle rate
+0x042u16flagsColor-cycle flags
+0x061u8lowFirst palette index in the range
+0x071u8highLast palette index in the range

The static image uses the stored palette. See also PCX images and COL palettes.

External References