Palette files each contain a contiguous list of Color structures, defined below. Daggerfall images are palettized; this means the pixel data is actually an index to a specific palette. One cannot properly decode any Daggerfall image without a palette.
Daggerfall uses a 3-byte triplet to encode a color value. Each component is from 0 (darkest) to 255 (brightest).
|0||UInt8||Red||Red component/channel for the color|
|1||UInt8||Green||Green component/channel for the color|
|2||UInt8||Blue||Blue component/channel for the color|
A ColorList structure is simply a contiguous list of Color structures.
PalFile files simply contain a single ColourList, 256 elements long.
The following files are valid PAL files:
ColFile files are composed of a ColHeader, immediately followed by a valid PalFile.
The 8-byte long ColHeader conforms to the Autodesk format:
|0-3||Int32||Length||This is the total length, in bytes, of the ColFile's data including this header. Since there are 3 bytes per Color structure, and all Daggerfall palette files include a ColorList structure 256 elements in count, and the ColHeader is 8 bytes long, the value for this field should always be 776 (0x00000308).|
|4-5||UInt16||FileFormatMajor||This should always be 0xb123.|
|6-7||UInt16||FileFormatMinor||This should always be 0x0000.|
Immediately following the ColHeader is a valid PalFile structure. Valid COL files are:
Reading Palette FilesEdit
Since PalFile files always contain 768 bytes of data (256 Colors, 3 bytes per color), PalFile files are identified by being 768 bytes in length. Likewise, ColFiles are always 776 bytes in length (ColHeader plus the PalFile's 768 bytes). This makes opening either a .COL or .PAL file trivial, since the specific type can be derived based on the file's length.
Since Colors do not encode an Alpha component/channel, the first entry is considered the "Transparent" color (0 Alpha) and all other colors are considered opaque (255 Alpha).