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 depth
Bits for each pixel
Number of colours
1
1
2
2
2
4
3
3
8
4
4
16
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.
Row
Codes
1
00 00 00 00 00 00 00 00
2
00 00 00 00 01 01 00 00
3
00 00 00 01 01 01 01 00
4
00 00 00 00 01 01 00 00
5
10 10 10 10 10 10 10 10
6
10 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.
Shape
Colour
Position
Size
rectangle
blue
rows 1 to 4
full width
rectangle
green
rows 5 and 6
full width
circle
yellow
middle of the top part
small
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?
Row
Codes
1
00 00 01 00 00
2
00 00 01 00 00
3
01 01 01 01 01
4
00 00 01 00 00
5
00 00 01 00 00
Writing the colour for each code gives a red plus sign on a black background.
2
A picture is 12 pixels across, 10 pixels down and has a colour depth of 2. How many bits does it need?
12 × 10 × 2 = 240 bits.
3
How many different colours can a colour depth of 3 give? Explain how you know.
There are 8 colours. Each pixel has 3 bits, and 2 × 2 × 2 = 8 different patterns, from 000 to 111.
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.
(a) A bitmap, because a photo has many tiny changes in colour that need pixels. (b) A vector graphic, because it is just two shapes, takes little space and stays sharp when it is made bigger.