IT lexicon › Programming › Color key

Color key

Programming På svenska → Updated: 2026-10-26

One sacrificial colour that the drawing routine skips — the cheapest way to make a rectangular image look like anything but a rectangle.

Before alpha channels were standard, sprites still needed transparent corners. The fix was to give up one colour: palette index 0, or in high-colour modes usually lurid magenta #FF00FF, because no artist would pick it voluntarily. The blit compares each pixel against the key and writes only those that don't match. DirectDraw baked it in as DDCOLORKEY in 1995, and SDL_SetColorKey is still around.

The catch is that transparency is all-or-nothing: a pixel is either fully there or fully gone, so edges come out jagged. Bilinear filtering makes it worse by blending the key colour into neighbouring pixels — hence the pink halos that have given away many a careless port.

← Back to the lexicon