Abrir menu principal

UESPWiki β

Alterações

Daggerfall:Image formats/Palette

3 039 bytes adicionados, 15h23min de 1 de março de 2014
m
Reading Palette Files
{{Daggerfall Hacking Guide Image formats}}
==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|PalFile (*.PAL)]] and [[#ColFile|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).

{| class="wikitable"
|+ 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 Structure|Colour]] structures.

===PalFile===
PalFile files simply contain a single [[#ColourList|ColourList]], 256 elements long.

The following files are valid PAL files:
<gallery>
Image:DF-Map.Pal.Palette.png|MAP.PAL
Image:DF-OldMap.Pal.Palette.png|OLDMAP.PAL
Image:DF-OldPal.Pal.Palette.png|OLDPAL.PAL
Image:DF-Pal.Raw.Palette.png|PAL.RAW
</gallery>

===ColFile===
ColFile files are composed of a ColHeader, immediately followed by a valid [[#PalFile|PalFile]].

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

{| class="wikitable"
|+ 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|PalFile]] structure. Valid COL files are:
<gallery>
Image:DF-Art_Pal.Col.Palette.png|ART_PAL.COL
Image:DF-DankBMap.Col.Palette.png|DANKBMAP.COL
Image:DF-FMap_Pal.Col.Palette.png|FMAP_PAL.COL
Image:DF-NightSky.Col.Palette.png|NIGHTSKY.COL
Image:DF-Pal.Pal.Palette.png|PAL.PAL
</gallery>

===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 [[#Colour Structure|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).
3 895
edições