AdvertisementYour brand could be hereYour brand hereOn every Darslab page · students, parents and teachersinfo@darslab.comAsk for pricesPricesinfo@darslab.com
☰ Year plan · Computing

Pixels, bits and sound

Week 24 · Unit 7.5: Living with AI · 3 lessons
2

More colours, more bits

Computing 7: Unit 7.5, pp. 150–181
GoalUse a colour depth of 2 to store four colours, and compare bitmap pictures with vector pictures.
New words
colour key · a list that says which code stands for which colourcolour code · the pattern of bits that stands for one colourvector graphic · a picture stored as shapes and instructions, such as a circle with a size, colour and positionfile size · the amount of data a file needs, measured in bits or bytes
Explanation

With a colour depth of 1, each pixel has two choices, 0 or 1, so a picture can use only two colours. If you give each pixel two bits, there are four patterns: 00, 01, 10 and 11. So four colours are possible. A key tells you which colour each code stands for. The file size is pixels across × pixels down × colour depth. A picture with a colour depth of 2 needs twice as many bits as the same picture with a colour depth of 1. A bitmap stores every pixel, but a vector graphic stores a list of shapes, so a simple picture can take less space. If you zoom in on a bitmap you see squares, but a vector graphic stays smooth.

Colour depthBits for each pixelNumber of colours
112
224
338
4416
Worked examples
This sun-and-field picture uses a colour depth of 2. The key is 00 = blue, 01 = yellow, 10 = green and 11 = white.
RowCodes
100 00 00 00 00 00 00 00
200 00 00 00 01 01 00 00
300 00 00 01 01 01 01 00
400 00 00 00 01 01 00 00
510 10 10 10 10 10 10 10
610 10 10 10 10 10 10 10
Here are the codes for the same picture, row by row. Each colour has two bits. The picture is 8 across and 6 down, so it needs 8 × 6 × 2 = 96 bits.
ShapeColourPositionSize
rectanglebluerows 1 to 4full width
rectanglegreenrows 5 and 6full width
circleyellowmiddle of the top partsmall
A vector graphic stores instructions instead of pixels. A bitmap of the sun above needs all 96 bits. The vector version only lists three shapes and so is much shorter, and you can make the sun bigger without losing quality.
Class activity

Colour code game (no computer): invent your own key with four colours and codes 00, 01, 10 and 11, for example 00 = white, 01 = red, 10 = blue and 11 = green. Draw a 6 by 6 grid on squared paper and colour a simple flag. Write the code for each square, row by row, with a space between pairs. Work out the bits: 6 × 6 × 2. Swap the key and codes with a partner, who draws the flag. For vector practice, describe a smiley face with three shapes and positions. If you have a computer or tablet, an adult can help you zoom in on a bitmap and a vector picture to see the difference.

Practice
1
Decode the rows. The key is 00 = black, 01 = red, 10 = white. What shape does the picture show?
RowCodes
100 00 01 00 00
200 00 01 00 00
301 01 01 01 01
400 00 01 00 00
500 00 01 00 00
2
A picture is 12 pixels across, 10 pixels down and has a colour depth of 2. How many bits does it need?
3
How many different colours can a colour depth of 3 give? Explain how you know.
4
Would you store (a) a photo of a market and (b) a simple logo made of two circles as a bitmap or a vector graphic? Explain each answer.