GCSE · Computer Science · AQA · Spec 8525

Convert binary ↔ bitmap image

Every picture on your screen is really one long line of 0s and 1s. Know the width and the colour key, and you can redraw it with a pencil.

Computer Science · Bitmap images

From 0s and 1s to a picture
The data: 24 bits001010001011111001010101width 4 pixels · 3 rowsKey · 2 bits per pixel00 = white01 = black10 = red11 = yellow

View: 1 · The bits. Showing 1 layer: Data, grid and key

View

Explore

This is the whole image as data: 24 bits in a row. On their own they are just 0s and 1s. To rebuild the picture you also need the width (4 pixels), the colour depth (2 bits per pixel) and the key.

Step through the four views, then pick a pixel to see which two bits made it.

What do the bits actually mean?

A black-and-white image

A black-and-white image uses 1 bit per pixel. Its key says 0 = black and 1 = white.

Which of these is closest to what you think right now?
How sure are you?

Predict, then check

Every colour in the key needs its own bit pattern.

A picture needs 5 different colours, and every pixel uses the same number of bits. What is the smallest colour depth that gives each colour its own code?

Resolution and total bits

Paint it. Does the total change?

8 × 6 pixels · 2-bit

8 by 6 pixel grid, 2 bits per pixel, 4 colours. Total bits: 96 bit

Paint
Colours4Bit depth2-bitTotal bits96 bit
pick a colour, then tap squares

This image is 8 pixels wide and 6 pixels high, so its resolution is 8 × 6: 48 pixels. The colour depth (shown here as bit depth) is 2 bits, using the same key as before: 00 white, 01 black, 10 red, 11 yellow. Total: 8 × 6 × 2 = 96 bits.

Watch out: A busier picture does not need more bits. Every pixel always takes exactly 2 bits, whatever its colour. Only the width, the height and the colour depth change the total.

Your turn: binary to bitmap

Fill in the missing steps

Turn this data into a bitmap image. Width: 3 pixels. Colour depth: 2 bits. Key: 00 = white, 01 = blue, 10 = green, 11 = black. Data: 011100101001

  1. Note what you are given: 12 bits of data, a width of 3 pixels and a colour depth of 2 bits.
  2. missing step
Which line is step 2?

Spot the slip: bitmap to binary

Where does this answer go wrong?

An image is 4 pixels wide and 2 rows high, with a colour depth of 2 bits. Key: 00 = white, 01 = black, 10 = red, 11 = blue. Row 1: black, black, white, red. Row 2: blue, white, white, black. Write the image as binary.

A student's answer — which line goes wrong?

WHAT YOU'VE LEARNED

A quick recap of today's lesson.

What you need to know

  • A pixel is the smallest element of an image, and a bitmap image is a grid of pixels.
  • Each pixel's colour is stored as a pattern of bits, and a key says which colour each pattern stands for.
  • Colour depth is the number of bits used for each pixel. With n bits per pixel, 2ⁿ different colours are available.
  • Resolution describes how many pixels an image has, from its width and height in pixels.
  • An image's data is width × height × colour depth bits long.

The big picture

A bitmap image is a grid of pixels, and each pixel's colour is stored as a bit pattern that a key turns into a colour. The colour depth is the number of bits per pixel, and n bits give 2ⁿ colours. To turn binary into an image, cut the bits into colour-depth-sized groups, look each one up in the key, and fill the grid row by row from the top-left, starting a new row after "width" pixels. To go back, write each pixel's code in the same order. The data is always width × height × colour depth bits long.

Key points

1Binary to bitmap: cut the bits into groups the size of the colour depth. Each group is one pixel.
2Fill the grid from the top-left, left to right, and start a new row after "width" pixels, unless a question sets a different order.
3Colour each pixel by looking up its group in the key the question gives you.
4Bitmap to binary: work row by row from the top-left and write down each pixel's code from the key.
5In a 1-bit (black-and-white) image each pixel is a single bit, and the key says which of 0 and 1 is which colour.

Worked example

Problem

A 1-bit image is 5 pixels wide. Key: 0 = white, 1 = black. Data: 001000111000100. Draw the image.

⚠ Watch out

Using the width to decide how many bits each pixel gets. The colour depth sets the group size. The width only tells you when to start a new row.

🧠

Memory hook

Cut, key, wrap: cut by the colour depth, colour from the key, and wrap to a new row after the width.

✓

Check yourself

Cover the page. In three steps, how would you turn 16 bits into an image 4 pixels wide with a colour depth of 2 bits? How many rows would it have?

Flashcards

(12)
What is a pixel?
The smallest element of an image: one square of a bitmap's grid.
What is a bitmap image?
An image made from a grid of pixels, where each pixel's colour is stored as a bit pattern.
What does colour depth measure?
The number of bits used for each pixel.
How many colours do n bits per pixel give?
2ⁿ. Each extra bit doubles the number of different codes.
How many colours can a colour depth of 4 bits give?
2⁴ = 16 colours.
What does resolution describe?
How many pixels an image contains, from its width and height in pixels.
How do you work out how many bits an image's data needs?
Width × height × colour depth.
In a 1-bit image, what decides whether 1 is black or white?
The key. A bit has no colour of its own.
Binary to bitmap: how many bits go in each group?
As many as the colour depth. One group is one pixel.
When do you start a new row of pixels?
After "width" pixels. Then go back to the left edge.
What is the usual order for filling or reading a bitmap?
Row by row from the top-left, left to right, unless the question says otherwise.
Bitmap to binary: what do you write for each pixel?
The bit pattern the key gives for that pixel's colour, in reading order.

Tap any card to flip it, or use Study as deck to go through them one at a time. In the full lesson these run as a spaced-repetition deck — you rate each card Hard, Good or Easy and the tricky ones keep coming back until they stick.

Learning with Lightbulb is opening soon

You can use this lesson now. Join the waitlist and we'll let you know when the full Lightbulb experience is ready.

Keep me posted

More AQA GCSE Computer Science topics

See the full AQA Computer Science curriculum →

How this lesson was checked. This AQA GCSE Computer Science (specification 8525)lesson was published through Lightbulb Learning's human-designed editorial process — the educational standards, accuracy rules and publication checks it must pass were authored and approved by Philip Halpin. It passed subject-specific assessment, automated educational checks and technical publication verification before going live (publication checks completed 30 September 2026). Published pages are monitored, human spot-checking is ongoing across the lesson library, and anything found wrong is corrected or withdrawn. How our lessons are made and checked. Spotted a mistake? Email hello@lightbulblearning.co and we'll review it.