BMP Format - DustStormPettigrew/LibLR1 GitHub Wiki
BMP — Bitmap (Non-Standard)
Custom compressed image format. Does NOT use the token-based binary encoding. This is completely independent.
Header
| Offset | Size | Type | Description |
|---|---|---|---|
| 0 | 1 | byte | Encoding type |
| 1 | 1 | byte | Palette size (entries = value + 1) |
| 2 | 2 | int16 | Width |
| 4 | 2 | int16 | Height |
| 6 | varies | BGR × palette | Color palette (if palettized) |
Encoding Types
| Value | Hex | Mode | Description |
|---|---|---|---|
| 4 | 0x04 |
Palette 4-bit | 16-color palette, 2 pixels per byte |
| 8 | 0x08 |
Palette 8-bit | 256-color palette, 1 pixel per byte |
| 152 | 0x98 |
Direct RGB | 3 bytes per pixel, no palette |
Palette Colors
Stored as BGR (blue first, then green, then red) — 3 bytes per entry.
Pixel Data Compression (RLE)
After the palette, pixel data is stored in compressed blocks:
- Read
blockLengthDecompressed(int16) andblockLengthCompressed(int16) - If equal → raw copy
- If different → RLE decompression using a bitmap-driven sub-block scheme:
- Read a
blockMapbyte — each bit controls one operation - Bit = 0 → copy next byte literally
- Bit = 1 → RLE: read lookback distance + repeat count, copy from earlier in buffer
- Read a
The RLE algorithm was reverse-engineered by Sluicer.
Read/Write Support
Read only. No encoder implemented.