[−][src]Module openpol::paldat
pal.dat data access operations.
pal.dat file format
- The file consists of concatenated 768-byte color palettes.
- Each palette contains 256 3-byte colors.
- Each 3-byte color definition consists of red, green and blue component values, 1 unsigned byte each.
The original game uses Mode 13h. As mode 13h only
supports 6 bits per channel the full byte values cannot be used. The original game shifts the
values by two bits to the right (which is effectively divinding by four), therefore removing
the two least significant bits and leaving the six most significant ones. This module doesn't
truncate the values, therefore full 24-bit colors are used, as long as present in pal.dat
.
Example
An openpol-extract-palette
sample binary which uses this code is provided. You can display
a palette (palette number 3 /0-based/ in this case) like this (the code depends on ImageMagick
being present in the system, the palette is displayed as 16x16 pixel square):
convert -depth 8 -size 16x16 rgb:<(cargo run --bin openpol-extract-palette PAL.DAT 3) image.png
Now view image.png
with the image viewer of your choice.
Structs
Paldat | A way to access pal.dat contents. |
Constants
PALETTE_SIZE_IN_BYTES |