Bitmap Graphics & Pixel Calculations

Computers store visual images in one of two formats: vector graphics (which store mathematical formulas defining lines and shapes) or bitmap graphics (also called raster graphics). Cambridge IGCSE focuses on bitmap graphics and how their pixel values are encoded in binary.


Learning Objectives

  • Explain how bitmap images are constructed from a grid of pixels with binary colour values.
  • Define and distinguish between image resolution and colour depth (bit depth).
  • Calculate uncompressed bitmap image file sizes in bits, bytes, and binary multiples (KiB, MiB).
  • Explain the role and necessity of metadata in digital graphic files.

Pixels and Bitmap Structure

A bitmap graphic is composed of a two-dimensional grid of picture elements called pixels:

  • Pixel (Picture Element): The smallest controllable, addressable unit of a digital display or bitmap image.
  • Each pixel in the grid has a specific $(x, y)$ coordinate and is assigned a binary number representing its colour.
  • When an image is zoomed in significantly, individual square pixels become visible, causing pixelation.
+---+---+---+---+
| W | B | B | W |   W = White (binary 1)
+---+---+---+---+   B = Black (binary 0)
| B | W | W | B |
+---+---+---+---+   A 4x4 monochrome bitmap
| B | W | W | B |   requires 16 bits of pixel data.
+---+---+---+---+
| W | B | B | W |
+---+---+---+---+

Key Image Properties

1. Image Resolution

  • Definition: The total number of pixels that make up the image, typically expressed as:
$$\text{Resolution} = \text{Width (pixels)} \times \text{Height (pixels)}$$
  • Display Resolution / Pixel Density: Often measured in PPI (pixels per inch) or DPI (dots per inch).
  • A higher resolution contains more pixels per unit of area, providing finer detail and sharper clarity, but increasing total storage size.

2. Colour Depth (Bit Depth)

  • Definition: The number of binary bits allocated to store the colour value of each individual pixel.
  • The number of distinct colours that can be represented is determined by the formula:
$$\text{Number of Unique Colours} = 2^{\text{Colour Depth (bits)}}$$

Colour Depth

Available Colours Formula

Total Colours

Common Usage

1-bit

$2^1$

2 colours

Monochrome (Pure Black and White)

4-bit

$2^4$

16 colours

Early computer graphics / EGA

8-bit

$2^8$

256 colours

Grayscale or 256-colour indexed palette (GIF)

16-bit

$2^{16}$

65,536 colours

High Colour

24-bit

$2^{24}$

$16,777,216$ colours

True Colour (8 bits Red, 8 bits Green, 8 bits Blue)

32-bit

$2^{24}$ colours + $2^8$ alpha

$16.7\text{M colours} + \text{Transparency}$

True Colour with 8-bit Alpha transparency channel

In 24-bit True Colour, every pixel uses three 8-bit bytes:

  • 1 byte (8 bits) for Red ($0\text{ to }255$)
  • 1 byte (8 bits) for Green ($0\text{ to }255$)
  • 1 byte (8 bits) for Blue ($0\text{ to }255$)

Combining 256 levels for each of the three primary light colours yields $256 \times 256 \times 256 = 16,777,216$ unique shades.


Image File Size Calculations

To calculate the minimum uncompressed file size of a bitmap image (excluding header metadata):

$$\text{File Size (bits)} = \text{Width (pixels)} \times \text{Height (pixels)} \times \text{Colour Depth (bits)}$$

To express the size in bytes:

$$\text{File Size (bytes)} = \frac{\text{Width} \times \text{Height} \times \text{Colour Depth}}{8}$$

Worked Example: Bitmap File Size Calculation

Problem: A digital camera captures an uncompressed bitmap photo with a resolution of $1920 \times 1080$ pixels using a $24\text{-bit}$ True Colour depth. Calculate the file size in:

  1. Total pixels
  2. Bits
  3. Bytes
  4. Mebibytes (MiB), rounded to two decimal places.

Step-by-step Solution:

  1. Calculate total pixels:
$$\text{Total Pixels} = 1920 \times 1080 = 2,073,600\text{ pixels}$$
  1. Calculate size in bits:
$$\text{Size in bits} = 2,073,600 \times 24 = 49,766,400\text{ bits}$$
  1. Convert to bytes:
$$\text{Size in bytes} = \frac{49,766,400}{8} = 6,220,800\text{ bytes}$$

(Shortcut: Notice that 24 bits = 3 bytes, so $2,073,600 \times 3 = 6,220,800\text{ bytes}$).

  1. Convert to binary Mebibytes (MiB):
$$\text{Size in KiB} = \frac{6,220,800}{1,024} = 6,075\text{ KiB}$$
$$\text{Size in MiB} = \frac{6,075}{1,024} \approx 5.93\text{ MiB}$$

Image Metadata

When an image file is saved, it contains more than just raw pixel values. It also includes metadata.

  • Definition: Metadata is data about data. It consists of technical and descriptive parameters stored in the file header.
  • Why Metadata is Essential:
  • A raw bitmap file is simply a continuous stream of binary bits (e.g., 110100101011...).
  • Without metadata, a computer cannot know the grid dimensions (how many pixels make up one horizontal row) or how many bits belong to each pixel.
  • An image of 12 pixels could be $1 \times 12$, $2 \times 6$, $3 \times 4$, $4 \times 3$, $6 \times 2$, or $12 \times 1$. Metadata tells the rendering engine how to reshape the linear bitstream into the correct 2D visual matrix.
  • Examples of Stored Metadata:
  • Image width and height (dimensions in pixels).
  • Colour depth (number of bits per pixel).
  • Image resolution (e.g. 300 DPI).
  • File format / compression type (e.g. BMP, PNG, JPEG).
  • Date and time of creation.
  • Camera settings (focal length, shutter speed, ISO, GPS coordinates).

Written practice and self-review

Define what is meant by metadata in the context of digital images.

Explain why image viewing software requires metadata to display an uncompressed bitmap file correctly, and give two specific examples of metadata stored in an image file.

Write an explanation before checking the theory. Check that each claim answers the question, uses the correct concept and explains why it applies. Discuss uncertain points with a teacher. The structured exercise below checks specific facts; it does not automatically mark this explanation.

AI Socratic Tutor

All-Access
Sign in or create an account. AI Tutor is an All-Access benefit.
Sign Up

Need guidance? Ask a question or use the hint below.

AI Socratic Tutor is an All-Access Benefit

Unlock step-by-step Socratic hints, algorithm trace table walkthroughs, and error diagnostics for every Cambridge exercise.

You're chatting with an AI tutor, not a person. AI can make mistakes, so double-check its answers.

Exam-Style Check: Bitmap Image Resolution & Colour Depth

• Multiple Choice
+25 XP
Question

A bitmap image has dimensions of 100 × 50 pixels and uses an 8-bit colour depth. What is the minimum uncompressed file size in bytes (excluding metadata)?

Sign in or create a free account to test your solution and track XP.