Free example lesson
GCSE Computer Science · Free lesson

Pixels under pressure

Build an image from binary, calculate its size and decide what can—and cannot—be safely compressed.

60–75 minutesInteractive pixel studioGCSE examination practiceNo external websites
1

Pixels, bits and the mystery image

8 mins
Before you begin

A digital bitmap is a grid of tiny squares called pixels. A bit is one binary digit: 0 or 1. In a black-and-white bitmap, one bit can store each pixel because there are only two possible colours. The computer must also know the image width, height and the order in which to read the bits.

Memory is normally grouped into bytes. There are 8 bits in 1 byte.

Think · Pair · Reveal

  1. Reveal one row and predict the image.
  2. After four rows, compare predictions with a partner.
  3. Reveal the remainder. Count its width and height in pixels.

0 of 8 rows revealed.

Teacher promptThe image is 8 × 8 = 64 pixels. At 1 bit per pixel it uses 64 bits = 8 bytes, excluding metadata. Insist on pixel, bit, byte and row order.
2

Learning objectives and image vocabulary

10 mins
RepresentExplain how pixels, resolution and colour depth encode a bitmap.
CalculateCalculate an uncompressed image size in bits and bytes.
EvaluateExplain how compression changes file size and, sometimes, image quality.

Bitmap or vector?

Bitmap graphic
Stored as a grid of coloured pixels. Photographs are normally bitmaps. Enlarging a small bitmap makes individual pixels visible.
Vector graphic
Stored as mathematical descriptions of shapes, lines and fills. It can be resized without becoming pixelated and is useful for logos and diagrams.

Three bitmap terms

Resolution is the width and height in pixels. Colour depth is the number of bits allocated to each pixel and determines how many colours are available. Metadata describes how to interpret the image, including dimensions and colour depth.

The simplified GCSE calculation below gives the uncompressed image data. A real file can be slightly larger because it also contains metadata.

uncompressed image size (bits) = width × height × colour depth

Check the vocabulary

Match each term to the definition just taught, then explain one match aloud.

0 of 3 matched.

3

Apply it: create and encode a bitmap

15 mins

The Pixel Studio uses a fixed four-colour palette. Four different colours require four distinct binary patterns, so every pixel must be allocated 2 bits: white = 00, navy = 01, pink = 10 and cyan = 11. The displayed values 0–3 are a shorter way to show those patterns.

1 · ConstructCreate a recognisable 8 × 8 icon using at least three colours and a line of symmetry.
2 · CalculateConfirm the resolution, number of pixels, colour depth and uncompressed size.
3 · EncodeSelect one row and rewrite its values as two-bit binary codes for a partner to decode.
Your bitmap calculation

Resolution: 8 × 8 = 64 pixels

Palette: 4 possible colours

Colour depth: 2 bits for every pixel

Uncompressed pixel data: 64 × 2 = 128 bits = 16 bytes

Encoded pixel values

Partner reconstruction: give your partner only one encoded row and the colour key. They should draw that row without seeing your artwork.

Assessment checkpointSecure answers distinguish the number of colours actually visible from the fixed colour depth used by the image format.
4

Learn and apply: lossless compression with RLE

15 mins

Compression reduces the number of bits needed to store or transmit a file. Lossless compression allows the original data to be reconstructed exactly. Run-length encoding (RLE) is a lossless method that replaces a run of repeated values with the value and its frequency.

Worked encode: 0 0 0 1 1 2 2 2 becomes (0,3) (1,2) (2,3). Read this as three zeros, two ones and three twos.
Worked decode: (3,2) (0,4) (1,2) becomes 3 3 0 0 0 0 1 1.

RLE is effective only when the saving from long repeated runs is greater than the extra frequency data it stores.

Row A · long runs

00001111

RLE: (0,4) (1,4) — only 2 runs

Row B · frequent changes

01010101

RLE needs 8 runs and may be larger than the original.

Row A
2 runs
Row B
8 runs
EncodeChoose one row of your bitmap and write its RLE pairs.
DecodeDecode (2,3) (0,2) (1,3), then check that it produces eight pixels.
Break the algorithmDesign an eight-pixel row that makes RLE inefficient and explain why.
5

Quality versus file size: lossy or lossless?

10 mins

Lossless methods preserve every bit of the original and are needed when exact reconstruction matters. Lossy methods permanently remove some data to achieve a smaller file. For photographs, audio and video, carefully chosen loss may be difficult for a person to notice—but repeated compression or a high compression level can create visible or audible artefacts.

Lossless priority
Exact recovery
Usually larger file
Suitable for program files, text, diagrams and evidence where detail must not change
Lossy trade-off
Some quality permanently removed
Usually smaller file
Suitable when faster transfer or storage saving outweighs perfect reconstruction

Decision rule: first ask what damage lost detail could cause. Then weigh that risk against storage space, download time and transmission bandwidth.

Medical scan used for diagnosis
Website background photograph
Pixel-perfect company logo
Holiday video sent on mobile data
7

Build towards the examination question

12 mins

Use the same method each time: width × height × colour depth gives bits; divide by 8 for bytes.

Step 1 · 4-bitA 16 × 16 icon uses 4-bit colour. Calculate its available colours, size in bits and size in bytes.
Step 2 · 8-bitA 320 × 200 image uses 8-bit colour. Calculate its size in bits and bytes.
Step 3 · 24-bitA wildlife camera stores 800 × 600 images using 24-bit colour. Calculate the size in bits and bytes.

Now explain why compression helps the camera transmit over a slow connection and recommend lossy or lossless compression. Connect your recommendation to the scientific purpose of the image.

Marking guidanceStep 1: 16 colours, 1,024 bits, 128 bytes. Step 2: 512,000 bits, 64,000 bytes. Step 3: 11,520,000 bits, 1,440,000 bytes.
7

Review: retrieval sprint

0 of 70 words
8

Create my lesson record

Your record includes your pixel artwork, encoded data, activity decisions, calculations and written explanations.

Important: work is saved temporarily in this browser on this computer only. Create and save your record before leaving or changing computer.

Want the complete resource library?

Explore sequenced Computing resources for Years 7–11.

Explore membership and free lessons