Palettes

From Just Solve the File Format Problem
(Difference between revisions)
Jump to: navigation, search
(Structure)
Line 17: Line 17:
 
Game palettes often comprise a the following chunks of data:
 
Game palettes often comprise a the following chunks of data:
  
* The '''palette''' itself, usually containing 256 ''swatches'', 3 bytes per color totaling 768 bytes in length. The 256 limit corresponds to the ''8bpp mode'' (or ''256 color mode'') limitations of personal computers of the time.
+
* 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.
 
* 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''':
 
The '''palette''':
  
* Palettes are often stored as '''tuples''' (1 byte for the red, green and blue channel 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 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 format needed by the underlying hardware.
 
* Whilst <code>RGB</code> component ordering is conventional, the components are sometimes ordered differently.
 
* Whilst <code>RGB</code> component ordering is conventional, the components are sometimes ordered differently.
 
* 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). These would need to be multiplied by 4 to map the components back to the expected range of 0-255.  
 
* 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). These would need to be multiplied by 4 to map the components back to the expected range of 0-255.  
 
* Often, the palette is the first chunk of data within the file.
 
* Often, the palette is the first chunk of data within the file.

Revision as of 12:49, 11 January 2023

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 format needed by the underlying hardware.
  • Whilst RGB component ordering is conventional, the components are sometimes ordered differently.
  • 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). These would need to be multiplied by 4 to map the components back to the expected range of 0-255.
  • Often, the palette is the first chunk of data within the file.
Personal tools
Namespaces

Variants
Actions
Navigation
Toolbox