ScholaFly

CS03-02 Computer Science Watch

From binary to bitmap and back

Watch on YouTube

In this lesson

In this video you'll learn about from binary to bitmap and back for GCSE Computer Science. Watch first: {{video:CS03-01}}

By the end: Draw the image that a given binary pattern represents, and write down the bit pattern that represents a given simple bitmap - reading the grid in the right order, grouping the bits by the colour depth, and using only the colour key supplied.

What it covers

  • Given a binary pattern that represents a simple bitmap, DRAW the resulting image as a series of pixels (AQA's own scope wording)
  • Given a simple bitmap, WRITE DOWN a bit pattern that represents it (AQA's own scope wording)
  • The reading order, stated as a rule and never varied: start at the top left, work along the row, then drop to the start of the next row
  • Splitting the bit string into groups the size of the colour depth - one group per pixel, in order
  • Using the colour key GIVEN in the question and nothing else, however obvious another scheme looks
  • A 1-bit grid is two colours; a 2-bit grid is four; the group length is the colour depth, which CS03-01 defined
  • The arithmetic check that catches most slips: width x height pixels means width x height groups, so the length of the bit string has to come out exactly

Key words

About this video

From binary to bitmap and back | GCSE Computer Science

How to turn binary into a bitmap and a bitmap back into binary, reading the grid in order with the colour key.
AQA 8525 GCSE. Images and sound 2 of 7.
Full Images and sound playlist: https://www.youtube.com/playlist?list=PLAonf4a5MXts
More at https://scholafly.com

Watch first: How an image is stored: pixels, resolution and colour depth - https://youtu.be/HKb8YHkv23c
Video code: CS03-02 (search "ScholaFly CS03-02")

Videos in this chapter:
CS03-00 Images, sound and compression - Intro: https://youtu.be/5_VNvpWBbVU
CS03-01 How an image is stored: https://youtu.be/HKb8YHkv23c
CS03-02 From binary to bitmap and back: https://youtu.be/D7AjvZoKT_M
CS03-03 How sound is stored: https://youtu.be/LOCcQaN-_fI
CS03-04 Working out image and sound file sizes: https://youtu.be/_CcijC_0L1U
CS03-05 Why we compress data: https://youtu.be/ylXSh7OO4dI
CS03-06 Huffman coding: https://youtu.be/ig0uHFLoc9U
CS03-07 Run length encoding

#GCSEComputerScience #ImagesAndSound #FromBinaryToBitmapAndBack

For teachers
This GCSE Computer Science lesson teaches from binary to bitmap and back. By the end, students should be able to draw the image that a given binary pattern represents, and write down the bit pattern that represents a given simple bitmap - reading the grid in the right order, grouping the bits by the colour depth, and using only the colour key supplied. It works through four worked examples and the mistakes examiners report, and suits Foundation and Higher tier students.

Exam board specification references:
AQA GCSE Computer Science (8525)
- 3.3.6 Representing images

Read the transcript

Before any picture appears on a screen, something has to turn a row of ones and zeros into coloured squares, in a fixed order, with no guessing. Start in the wrong corner and the picture comes out upside down and back to front. The hardest grid in this video has twelve bits, two squares across, three down and four colours. By the end you will draw it with a pencil, without hesitating. It builds from a grid where every square is black or white, and that is where we start.

Images, sound and compression, video two of seven. If pixels and colour depth still feel wobbly, go back to How an image is stored first.

A bitmap is an image stored as a grid of pixels, with each pixel held as bits. Turning bits into a bitmap needs three things from the question: the size of the grid, the colour depth and the colour key. This conversion is named on one exam board's course. If yours is a different course, it is still good practice, because another board has set this same task on a paper. The colour key says which code means which colour. Here the colour depth is one bit, so the key has two entries: zero is white, and one is black. The reading order never changes. Start at the top left, work along the row, then drop to the start of the next row down. The grid is four by four, so draw sixteen empty squares first. Sixteen squares at one bit each means the string must be sixteen bits long, and it is: one zero zero one, zero one one zero, zero one one zero, one zero zero one. Take the first four bits for the top row. One is black, zero is white, zero is white, and one is black, so the top row is black, white, white, black. Each bit fills one square here, because the colour depth is one, and nothing is skipped along the way. Now the second row, from zero one one zero. What colours go in, left to right? White, black, black, white. Each zero gives white and each one gives black, in order along the row. Rows three and four follow the same way. Row three is zero one one zero again, and row four is one zero zero one, the same as the top. The finished picture has black corners and a black block of four in the middle. That pattern looks the same from every corner, so it cannot test the reading order. A lopsided grid will do that later. One examiner's report notes a strength here. A large number of correct responses were seen for descriptions of bitmap representation. Describing a bitmap is the part students already manage. The way to make the skill itself stick is doing it with a pencil, which is the rest of this video.

Now go the other way: a picture in, bits out. The rules do not change. Start top left, go along each row, and write the code the key gives for each colour. On the four by four grid, the top row is black, white, white, black, so it gives one, zero, zero, one. The other rows follow the same way, and the full string is the one we started from. Same key as before. Here is a new picture, three pixels wide and two high. Top row: black, white, black. Bottom row: white, black, white. What six bits does that picture give, reading from the top left? One zero one, zero one zero. That is the upper three first, then the lower three.

Now the grid from the start of the video, where each pixel needs two bits. The grid is two pixels wide and three high, and the colour depth is two bits. Width comes first, so two across and three down. Draw the six empty squares before reading anything, and the shape cannot go wrong later. Read the key next, because it is part of the question. Zero zero is white, zero one is red, one zero is blue, and one one is black. The bit string is zero one one zero, zero zero one one, zero one one zero. Six pixels at two bits each: how long should that string be, and is it? Twelve bits, and it is twelve long. Six groups for six squares, so the count check passes before a single colour goes in. Next, cut the string into pairs, one pair per pixel. Zero one. One zero. Zero zero. One one. Zero one. One zero. Look up the first pair in the key. Zero one is red, so the top-left square is red. Every other pair is looked up the same way, in reading order. Fill in the other five squares from the key before I show you. One zero is blue, so the top right is blue. Across the middle row, zero zero is white and one one is black. Along the bottom, zero one is red and one zero is blue. A different student reads this string one bit per square, out of habit from the black and white grid. Why can that student not read this string one bit per square? With a colour depth of two, each pixel needs two bits. Reading one at a time fills six squares with six bits, leaves six unread, and a single bit is not even in the key. One examiner's report describes a task like this one, where the bits had to be cut into groups of four and matched to colours. It says: This was completed accurately by many candidates who were able to match the codes and colours. So the grouping step can be learned. The habit is to draw the cuts into the string before you look anything up, then count the groups against the squares.

Two slips can happen before a single colour goes in: starting in the wrong corner, and using a key of your own. Fill the same two by three grid starting at the bottom right and working backwards. The bits are right and the key is right, but every pair lands in a different square. Filling that way, which colour lands in the top-left square? Blue. The final two bits, one zero, are blue, and reading in reverse sends them to the top left. Every row comes out the wrong way round. One examiner's report records this slip on a real paper. The instructions stated that the image starts in the top left, but some candidates started in the bottom right instead. The fix is a start dot. Put it on the top-left square before you read a single bit, and never move it. Now the other slip. A student fills that same two by three grid in the right shape, but draws it in black and white. What did that student get wrong, even though the shape was right? They ignored the key. The key asks for four colours, including red and blue, so their picture no longer matches the bits. A different line in the same report describes it. Some responses did not use the colours provided in the question and created their own colour scheme for the image, commonly just using black and white. The habit: read the key first, before the bit string, and keep it beside you while you fill. The key is data in the question, not decoration.

Four questions on what this video built, and the last one goes back to where it began. Where does the reading start, and which way does it go? The reading starts at the top left, goes along the row, then drops to the start of the next row. Now a new grid. Four wide, two high, three bits a pixel: how long is the bit string? Twenty-four bits. Four times two is eight pixels, and eight pixels at three bits each is twenty-four. Next, a key question. With two bits per pixel, how many colours can the key hold? Four colours. Two bits make four patterns: zero zero, zero one, one zero and one one. Now the last one, back to the row of ones and zeros. What fixes the starting corner? The rule, not the bits. The start is always the top left, so a row of ones and zeros can only ever make one picture.

If you can take any bit string, a grid shape and a key and draw the picture without stopping to check, that's in the bag, so the thumb is yours to press. If the grouping still trips you up, keep the video saved; three grids in, it starts to feel normal.

Next in the chapter: How sound is stored.

For more, visit scholafly.com, or watch the next video.

Related terms

For: AQA GCSE 8525

On the specification

BoardSpecStatement
AQA GCSE 85253.3.6Representing images
For teachers

This GCSE Computer Science lesson teaches from binary to bitmap and back. By the end, students should be able to draw the image that a given binary pattern represents, and write down the bit pattern that represents a given simple bitmap - reading the grid in the right order, grouping the bits by the colour depth, and using only the colour key supplied. It works through four worked examples and the mistakes examiners report, and suits Foundation and Higher tier students.