PyGCSE Python Lab

Image Representation Visualiser

Paint pixels on an interactive grid and see how resolution and colour depth affect image quality and file size. Covers AQA A Level CS (7517) §4.5.6.1.

📖 Learn Step-by-Step

File Size Calculation

Image dimensions:8 × 8 px
Total pixels:64
Colour depth:2 bits/pixel

Total bits:64 × 2 = 128
File size:128 ÷ 8 = 16 bytes

File size = width × height × colour depth ÷ 8
Real files also include metadata (dimensions, colour depth, compression, etc.)

Size comparison at 8×8

1-bit
8 bytes
2-bit
16 bytes
4-bit
32 bytes
8-bit
64 bytes

Image Representation Practice Questions

Q1

A bitmap image is 1024 pixels wide and 768 pixels tall. It uses a colour depth of 24 bits per pixel. Calculate the file size in bytes (ignoring metadata).

0/2 marks
bytes
Q2

An image uses a colour depth of 4 bits per pixel. How many different colours can each pixel represent?

0/1 mark
Q3

A 200×200 pixel image uses 8-bit colour. Calculate the file size in kilobytes (1 KB = 1024 bytes). Give your answer to 2 decimal places.

0/2 marks
KB
Q4

A 1920×1080 image uses 32-bit colour depth. Calculate the file size in megabytes (1 MB = 1024×1024 bytes). Give your answer to 2 decimal places.

0/3 marks
MB
Q5

An image file must be no larger than 500 KB. The image is 640×480 pixels. What is the maximum colour depth (in bits) that can be used? Give a whole number.

0/2 marks
Quick reference — bitmap image representation

Bitmap basics:

  • A bitmap is a grid of pixels (picture elements)
  • Each pixel stores a colour value as a binary number
  • The number of bits per pixel is the colour depth

Key definitions:

  • Resolution: width × height in pixels (or pixels per inch — PPI)
  • Colour depth: number of bits used to represent each pixel's colour
  • Metadata: additional header info (dimensions, colour depth, creation date, etc.)

File size formula:

file size (bits) = width × height × colour depth

Divide by 8 to get bytes, then ÷1024 for KB, etc.

Trade-offs:

  • ↑ Resolution → better detail → larger file
  • ↑ Colour depth → more colours → larger file
  • Compression can reduce file size (lossy or lossless)