Perform calculations to estimate the file size for a bitmap image

Published by Patrick Mutisya · 14 days ago

Cambridge A-Level Computer Science 9618 – 1.2 Multimedia

1.2 Multimedia – Estimating Bitmap Image File Size

Learning Objective

Perform calculations to estimate the file size for a bitmap (raster) image.

Key Concepts

  • Resolution: Number of pixels in the horizontal and vertical directions (e.g., 1920 × 1080).
  • Colour depth (bits per pixel): Number of bits used to represent the colour of a single pixel.
  • Uncompressed bitmap size: Calculated directly from resolution and colour depth.
  • Compression: Reduces file size but is not considered in the basic estimation.

Formula for Uncompressed Bitmap Size

The size \$S\$ (in bits) of an uncompressed bitmap image is given by:

\$S = \text{horizontal pixels} \times \text{vertical pixels} \times \text{bits per pixel}\$

To convert bits to more convenient units:

  • 1 byte = 8 bits
  • 1 kilobyte (KB) = 1024 bytes
  • 1 megabyte (MB) = 1024 KB
  • 1 gigabyte (GB) = 1024 MB

Step‑by‑Step Calculation

  1. Determine the image resolution (width × height).
  2. Identify the colour depth (bits per pixel). Common values:

    • 1‑bit (black & white)
    • 8‑bit (256 colours)
    • 24‑bit (true colour, 16.7 million colours)
    • 32‑bit (true colour + alpha channel)

  3. Apply the formula \$S = w \times h \times b\$ to obtain the size in bits.
  4. Convert bits to bytes, then to KB/MB/GB as required.

Worked Example

Estimate the file size of a 1280 × 720 pixel photograph stored as a 24‑bit true‑colour bitmap.

  1. Resolution: \$w = 1280\$, \$h = 720\$.
  2. Colour depth: \$b = 24\$ bits.
  3. Calculate bits:

    \$S = 1280 \times 720 \times 24 = 22\,118\,400\ \text{bits}\$

  4. Convert to bytes:

    \$\frac{22\,118\,400}{8} = 2\,764\,800\ \text{bytes}\$

  5. Convert to megabytes:

    \$\frac{2\,764\,800}{1024 \times 1024} \approx 2.64\ \text{MB}\$

Therefore, the uncompressed bitmap would be roughly 2.64 MB.

Summary Table

Resolution (pixels)Colour Depth (bits per pixel)Size (bits)Size (bytes)Size (KB)Size (MB)
640 × 48082 457 600307 2003000.29
800 × 6002411 520 0001 440 0001 406.251.37
1920 × 10802449 766 4006 220 8006 074.225.93

Practice Questions

  1. Calculate the uncompressed file size of a 1024 × 768 image using a 32‑bit colour depth. Express your answer in megabytes (MB) to two decimal places.
  2. A digital camera saves photos as 24‑bit bitmaps with a resolution of 4000 × 3000 pixels. What is the file size in gigabytes (GB)? (Round to two decimal places.)
  3. If you reduce the colour depth of a 640 × 480 image from 24‑bit to 8‑bit, by what factor does the file size decrease?

Answers (for teacher reference)

  1. \$S = 1024 \times 768 \times 32 = 25\,165\,824\ \text{bits}\$

    \$\text{Bytes} = \frac{25\,165\,824}{8} = 3\,145\,728\$

    \$\text{MB} = \frac{3\,145\,728}{1024^2} \approx 3.00\ \text{MB}\$

  2. \$S = 4000 \times 3000 \times 24 = 288\,000\,000\ \text{bits}\$

    \$\text{Bytes} = 36\,000\,000\$

    \$\text{GB} = \frac{36\,000\,000}{1024^3} \approx 0.03\ \text{GB}\$

  3. Size ratio = \$\frac{24}{8} = 3\$. The file size becomes one‑third of the original (a reduction factor of 3).

Suggested diagram: A grid illustrating pixels, colour depth, and how each pixel contributes bits to the total file size.