Encoding and decoding a small colour image
A table giving each colour a binary code. Write each pixel's code row by row to encode an image; read the codes back to redraw it. 4 colours need 2 bits.
Understanding Encoding and decoding a small colour image in IGCSE Computer Science Paper 1
What it does: 2 bits can make 2 x 2 = 4 different values. These are exactly the four codes needed to give 4 colours their own code. A grid 4 pixels wide and 3 rows tall has 12 pixels. Each pixel uses a 2-bit code, so 12 x 2 = 24 bits. Read each 2-bit code in order and look it up in the colour code table: 01 = red, 00 = white, 11 = black, 10 = blue. Red is 01 and white is 00, so the row is 01 01 00. 10 is blue, not red. Reading the codes back in pairs gives 00 white, 11 blue, 00 white, 11 blue, so the row can be redrawn on the grid.
Common mistakes: 1 bit only gives 2 codes (0 and 1), so it can't store 4 colours. 4 colours need 2 bits per pixel. In the colour code table red is 10, not 11 (11 is blue). The row should be 01 10.
Free printable worksheet with full answer key — or add this module to a class and your students practise it interactively.
This module's key terms are also in a printable crossword (Modules 43–58) and word search (Modules 28–58).
Take this worksheet further — free with Cloodit
Each concept is reinforced from every angle — learned, then applied, then tested.
Cloodit turns curriculum-aligned coding content into journeys students work through one biome at a time.
Over 100 of them, across seven natural biomes.
Turns their work into revision material ready for Flash Cards and Exam study.
Live, competitive practice for the start of the lesson or a teacher-led lesson finisher.
Honour your top performers, or encourage a student who's trying hard — ready to print in seconds.
Quick Questions
Match the Pairs
Key Term
colour code tableFill in the Blanks
Spot the Error
Student with a class code? Join your class →