Colour could be represented in a computer as a three bit figure representing RGB values. For example, the bits representing red, green and blue values as on or off would be:
So three bits will then access colour n which looks up a 3 x 8 byte value to be displayed (0 - 255 for each of red, green and blue). For example, the bits 110 (or 6) will access an area of the CLT and values for an RGB colour will be returned such as 156 for red, 74 for blue and 196 for green.
As Bradley (1993) points out, most colour X displays use a 'visual' model known as PseudoColour. On a typical 8-bit colour X display, pixel values can range between 0 and 255, inclusive. So a 256-entry colourmap would be used to get the RGB triple for each possible pixel value.
In the X Window system, entries on the display's colourmap (called colourcells) are a scarce resource. At any time, out of the 256 colours available (in an 8-bit PseudoColour system), several of these colours may already be in use by your window manager, the cursor and other applications. As such, a programme such as a GIF viewer can't assume it has 256 colours at its disposal, because generally it doesn't.