How bitmaps represent images

How a Bitmap Represents an Image

A bitmap represents an image by dividing it into a rectangular grid of pixels. Each pixel occupies one position in the grid and stores a single colour value. The complete image is nothing more than the full set of colour values for every pixel arranged in order - row by row, from top-left to bottom-right. When the image is displayed, each pixel's stored colour is used to light up the corresponding point on the screen, reconstructing the original picture.

Crucially, bitmaps store colour values as binary numbers. The number of bits used to represent each pixel's colour is the colour depth. A higher colour depth means more bits per pixel, which allows more distinct colours to be stored. For example, a 1-bit colour depth can only store 2 colours (0 = black, 1 = white), while an 8-bit colour depth can store 28 = 256 different colours, and 24-bit colour can store over 16 million.

The SVG below shows how a small 4 × 3 pixel grid maps onto binary colour codes. Each coloured square in the grid corresponds to a binary value stored in the bitmap file.

4 × 3 pixel grid stored as Row 1: 00 00 01 10 Row 2: 01 10 00 01 Row 3: 10 00 10 00 = 00 (red) = 01 (blue) = 10 (teal)

Each pixel's colour is encoded as a binary value. Reading the codes row by row recreates the image.

 Key Takeaways

  • A bitmap represents an image as a grid of pixels, each storing a single colour value as a binary number.
  • Colour depth determines how many bits are used per pixel - more bits means more possible colour values (2n colours for n bits).
  • The bitmap file is essentially a sequence of binary colour codes for every pixel, read row by row from top-left to bottom-right.
  • Displaying the image reverses this: each binary code is read in order and the corresponding colour is shown at the correct position on screen.