GCSE · Computer Science · AQA · Spec 8525
Convert binary ↔ bitmap image
Every picture on your screen is secretly one long line of 0s and 1s. Know the width and the colour key, and you could redraw it with a pencil.
Computer Science · Bitmap images
View
Explore
Here's the whole image as data: 24 bits in a row. On their own they're just 0s and 1s. To rebuild the picture you also need three things: 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.
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's the smallest colour depth that gives each colour its own code?
Resolution and total bits
Paint it. Does the total change?
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, with the same key as before: 00 white, 01 black, 10 red, 11 yellow. Total: 8 × 6 × 2 = 96 bits. Now repaint as many squares as you like and watch the total.
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. A bitmap image is just 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 each pixel uses. It counts bits, not colours.
- With n bits per pixel you get 2ⁿ different colours, because every extra bit doubles the number of patterns.
Have a goYour mate says: "Going from 2 bits to 3 bits per pixel just gets you one extra colour." Are they right?
No. It goes from 4 colours to 8.
An extra bit doesn't add one colour, it doubles the patterns: 2² = 4 becomes 2³ = 8.
- Resolution describes how many pixels an image has in total, from its width and height in pixels.
Have a goAn image is 10 pixels wide and 4 pixels high. How many pixels does it have?
40 pixels.
Resolution counts pixels, so it's width × height: 10 × 4 = 40. The colour depth doesn't change the pixel count.
- Turning binary into a picture? Cut the data into colour-depth-sized groups, one group per pixel, and look each group up in the key.
- Fill the grid from the top-left, left to right, starting a new row after "width" pixels (unless the question says otherwise).
Have a goYou're drawing an image 3 pixels wide. Where does the 7th pixel go?
Row 3, first square on the left.
Rows hold pixels 1–3, then 4–6, so pixel 7 wraps back to the left edge of row 3. The width, not the colour depth, decides when a row ends.
- Going from picture to binary is the same trip backwards: row by row from the top-left, write down each pixel's code.
- In a 1-bit image each pixel is a single bit, and only the key says whether 0 or 1 is which colour.
- The data is always width × height × colour depth bits long, so that total is your built-in check.
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. Colour depth is the number of bits per pixel, and n bits give 2ⁿ colours. Binary to 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. Image to binary: write each pixel's code in that same order. Either way, the data is width × height × colour depth bits long.
Key points
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. It's tempting because both are small numbers sitting in the question. But the colour depth sets the group size, and 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?
What is a bitmap image?
What does colour depth measure?
How many colours do n bits per pixel give?
How many colours can a colour depth of 4 bits give?
What does resolution describe?
How do you work out how many bits an image's data needs?
In a 1-bit image, what decides whether 1 is black or white?
Binary to bitmap: how many bits go in each group?
When do you start a new row of pixels?
What is the usual order for filling or reading a bitmap?
Bitmap to binary: what do you write for each pixel?
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 postedMore AQA GCSE Computer Science topics
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 28 October 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.