Palette (computing)
Palette (computing) describes one of the oldest compression tricks in digital imagery: instead of telling the computer the exact color of every pixel, you hand it an index. That index points to a lookup table, the color lookup table or CLUT, where the real color information lives. By 2019, the most common color space in graphics cards used 24 bits per pixel, which the RGB model distributes across three channels at 8 bits each. That means a single full-fidelity pixel carries enough data to represent over 16 million distinct shades. The CLUT approach trades that full range for a curated shortlist, cutting storage from 24 bits down to as few as 8 bits per pixel. The tradeoff shapes how images are stored, transmitted, and displayed across decades of computing.
The GIF file format made the 256-color palette famous. A program building a GIF picks exactly 256 colors from the full 24-bit color space, assigns each an 8-bit index, and then describes every pixel by its index number rather than its actual color. The result is a file one-third the size of an uncompressed equivalent. That bandwidth saving mattered enormously when storage was measured in kilobytes and network speeds in kilobits per second.
Two strategies emerged for choosing which colors belong in a palette, and they pull in opposite directions. The adaptive palette is tailored to a single image, picking or quantizing the colors directly from that image by selecting the most frequent shades. Paired with dithering, an adaptive palette can bring an indexed image remarkably close to a truecolor original. The catch is a hard dependency: on an 8-bit display, the adaptive palette must be loaded into the hardware color registers before the image surface itself reaches the frame buffer. Showing several images in sequence forces a slideshow-style load, one adaptive palette swapped out for the next.
The master palette, sometimes called a universal palette, takes the opposite approach. It sacrifices per-image optimality to serve many images at once, something that matters whenever an application must show a mosaic of thumbnails simultaneously. A master palette is built to resemble the full RGB color space "in miniature", setting fixed limits on how many distinct levels each channel may have. Human vision adds a wrinkle here: the eye is most sensitive to green, least to blue. Palette designers exploit that asymmetry. An arrangement of 8 red levels by 8 green levels by 4 blue levels fills 256 slots exactly, but that leaves no room for reserved color indices the program might need for special purposes. More practical configurations use 6R by 6G by 6B for 216 colors, matching the Web colors standard, or 6R by 8G by 5B for 240 colors, or 6R by 7G by 6B for 252 colors, each leaving a margin for reserved entries.
A single palette entry can serve an entirely different role: the transparent color. Designating one index as transparent lets software superimpose one image over another so that pixels carrying that index reveal the background rather than cover it. Superimposing film and television titles and credits is a standard application of that technique.
In practice, index number 0 is the conventional transparent entry, though software-driven overlays can choose any index freely. At design time, the transparent palette entry is assigned an arbitrary but visually distinctive color so the artist can see clearly which regions will vanish at runtime. An orange background is a typical choice: orange patches mark what will become invisible when the image is blended over a background. This is the mechanism behind pointers, sprites in 2-D videogames, and video titling systems.
Several early computers handled transparency in hardware. The Commodore 64, MSX, and Amiga all supported sprites and full-screen video overlay at the hardware level, with the transparent palette entry number fixed by the hardware design, conventionally entry 0. On the file format side, GIF natively supports designating any palette entry as transparent. The BMP format reserves space in its Color Table for alpha channel values but leaves that space set to zero with no translucency data stored. PNG goes further, supporting full alpha channel values per palette entry, which enables degrees of semi-transparency rather than a binary visible-or-invisible switch.
When palettes are not in play, video mixing equipment can designate the RGB triplet (0,0,0), the darkest possible black, as a transparent color. That value is sometimes called superblack in this context. At design time it is replaced with what practitioners call magic pink. Desktop publishing software can follow a parallel convention, treating pure white, the RGB triplet (255,255,255), as a region to be excluded so that text paragraphs can flow irregularly around the shapes within a photograph or illustration.
2-D painting programs handle transparency differently again. Microsoft Paint and Deluxe Paint both use the user-designated background color as the transparent color during cut, copy, and paste operations. These approaches share a purpose with palette-based transparency but operate without a CLUT. Image bit masks and alpha channels are the related techniques that handle the same overlay goals through entirely separate mechanisms, adding extra binary data layers outside the image itself rather than repurposing a palette entry.
Microsoft Windows built a structured architecture around palette management for 4-bit and 8-bit indexed color displays. The Win32 API exposes specialized functions for this, governing two distinct objects: the system palette and logical palettes. The system palette is a RAM copy of the display hardware's physical color registers. It is a single shared resource for the entire system, loaded at boot with a default master palette that works acceptably with most programs.
Each application that wants to output colorized graphics can define its own logical palette, a private selection of up to 256 colors. Before any output reaches the screen, the program must "realize" that logical palette: the system attempts to match each logical color against the colors already in the system palette. A match means the system simply maps the logical index to the correct system palette index. No match means the system runs an algorithm to evict the least-used color currently in the system palette, generally one belonging to a background window, and replaces it with the requested color. The algorithm also tries to consolidate similar colors and avoid redundant entries.
The foreground window always receives priority in this negotiation. Background windows may appear corrupted or may redraw themselves rapidly in response. When the system palette changes, Windows fires a specific event that applications can receive and use to trigger a single-function redraw via the Win32 API. Many programs fail to handle that event explicitly, which is why windows turn visually corrupt when palette contention grows heavy. An application can also force specific colors into fixed palette positions by flagging those entries as reserved for animation, which prevents the system's eviction algorithm from reclaiming them. The reliability of that trick depends on the skills of the program doing the forcing and on the behavior of every other application running at the same time.
Continue Browsing
Common questions
What is a color palette in computing and how does it work?
A computing palette is the set of colors available for rendering an image, often implemented as a color lookup table (CLUT) where each color is assigned an index number. Pixels reference their color by index rather than storing full color data, reducing storage from 24 bits per pixel down to as few as 8 bits per pixel. The GIF file format is a well-known example, using 256 colors each assigned an 8-bit index.
What is the difference between an adaptive palette and a master palette?
An adaptive palette is chosen directly from a single image by selecting its most frequent colors, giving better fidelity to that image but requiring the palette to be reloaded for each new image. A master palette is a fixed universal set designed to represent the full RGB color space in miniature, allowing multiple images to be displayed simultaneously without reloading palette data.
What common palette configurations are used for the web and why?
The 6R by 6G by 6B arrangement produces 216 colors and matches the Web colors standard, leaving 40 reserved slots in a 256-entry palette for special-purpose color indices. Alternatives include 6R by 8G by 5B for 240 colors and 6R by 7G by 6B for 252 colors. Blue receives fewer levels because the human eye is least sensitive to blue compared to red and green.
How does palette-based transparency work in indexed color images?
One palette entry is designated as the transparent color, typically index 0. Pixels carrying that index reveal the background layer rather than displaying a color, enabling image overlay for sprites, pointers, and video titles. GIF natively supports this designation; PNG extends it further by supporting alpha channel values per palette entry for semi-transparency.
Which early computers supported hardware palette transparency?
The Commodore 64, MSX, and Amiga all supported sprites and full-screen video overlay at the hardware level. In these systems the transparent palette entry number was fixed by the hardware, conventionally set to entry 0.
How does Microsoft Windows manage palettes for 8-bit displays?
Windows maintains a single shared system palette in RAM that mirrors the display hardware's physical color registers. Each application defines its own logical palette of up to 256 colors, which the system realizes by matching logical colors to system palette entries or evicting least-used colors to make room. The foreground window receives priority, and background windows may appear corrupted when palette slots run out.