Palettes

From Just Solve the File Format Problem
Revision as of 12:56, 11 January 2023 by Foxtrot (Talk | contribs)

Jump to: navigation, search

A palette is, at its simplest, a lookup-table of colors with their corresponding index that is utilized when displaying computer graphics. Palettes are either:

  • Defined by the hardware (i.e. the palette used by the graphics hardware of the NES) or
  • Embedded within a file-format or specific to a piece of software (such as a palette embedded within a GIF or 8-bit PNG)

Whilst palettes are common across all media, they are particularly common in games.

Game palettes

Early game formats would often make use of a palette for two primary reasons:

  • The historical limits of graphics hardware meant that a full-spectrum of colors was not feasible or necessary.
  • Palette's allow for greater compression of in-game assets and less processing-time when loading these assets or displaying them on screen.

Structure

Game palettes often comprise a the following chunks of data:

  • The palette itself, usually containing 256 swatches, 3 bytes per color component totaling 768 bytes in length. The 256 limit corresponds to the 8bpp mode (or 256 color mode) limitations of personal computers of the time.
  • Any number of Blending tables, which store pre-computed transformations on a palette, such as shading or blending. The results refer back to an index in the palette itself.

The palette:

  • Palettes are often stored as tuples (1 byte for the red, green and blue component in sequence) or in planes (1 byte for the red component for each swatch, then 1 byte for the green, then 1 byte for the blue). Palettes are often loaded directly into memory, and as such, their format usually matches the underlying hardware.
  • Whilst RGB component ordering is conventional, the components are sometimes ordered differently based on the underlying hardware.
  • If the palette appears dimmer than expected, it might be using less bits per byte in one or all components. It was common to store components using 6-bits (0-63) instead of the full 8-bits (0-255). 6-bit components would need to be multiplied by 4 to map the components back to the expected range of 0-255. Naturally, a 6-bit component would result in loss of precision when converting from 8-bit.
  • Often, the palette is the first chunk of data within the file. If the palette appears randomized, or ordered by brightness or hue, this is an indication that the palette was generated by graphics software and not used directly by artists. Conversely, if a palette appears structured, the palette itself may have been authored by an graphics artist or the color indices have additional meaning (i.e. an index of 0 or 255 is often used for 1-bit transparency.)
Personal tools
Namespaces

Variants
Actions
Navigation
Toolbox