Daggerfall:Image formats/Palette

A UESPWiki – Sua fonte de The Elder Scrolls desde 1995

Palette Files

Palette files each contain a contiguous list of Colour 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.

There are two types of palette files: PalFile (*.PAL) and ColFle (*.COL). Each has a similar structure and format, but there is a trivial difference between them.

Colour Structure

Daggerfall uses a 3-byte triplet to encode a colour value. Each component is from 0 (darkest) to 255 (brightest).

Colour Structure Format
Offset Type Name Description
0 UInt8 Red Red component/channel for the colour
1 UInt8 Green Green component/channel for the colour
2 UInt8 Blue Blue component/channel for the colour

ColourList

A ColourList structure is simply a contiguous list of Colour structures.

PalFile

PalFile files simply contain a single ColourList, 256 elements long.

The following files are valid PAL files:

ColFile

ColFile files are composed of a ColHeader, immediately followed by a valid PalFile.

ColHeader

The 8-byte long ColHeader conforms to the Autodesk format:

ColHeader Structure
Offset Type Name Description
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 Colour structure, and all Daggerfall palette files include a ColourList 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 Files

Since PalFile files always contain 768 bytes of data (256 Colours, 3 bytes per colour), 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 Colours do not encode an Alpha component/channel, the first entry is considered the "Transparent" colour (0 Alpha) and all other colours are considered opaque (255 Alpha).