More precisely this refers to the
bits allocated per
pixel (thus depth) for a
display device. The actual use of the
bits per pixel may vary depending on the desired goal. Commonly
8 bits per pixel allows the value for the pixel to be referenced to a
lookup table of 256 different
preset colors, however other times the bits are simply used to generate a
monochrome value for the pixel ranging from 0 to 255 representing
intensity. In contrast,
24 bits per pixel allocates 8 bits for the
red,
green, and
blue value of each pixel. With small bit depths,
bit packing tends to occur, such that
multiple pixels are packed into a single
byte. This may require the use of a combination of
logical operations to insert the desired bits into the byte for a single pixel without disturbing the others, yielding a
tradeoff between
size and
speed.