Bitmap images

GCSE Computer Science (Edexcel) · Edexcel 1CP2 · 2.2.2 · Data › Data representation

66 exam-style questions plus unlimited generated ones on this topic, at up to four difficulty levels, with full mark schemes. Notes and past-paper booklets are open to everyone. Practice needs a free account.

Or take a quick quiz: 10 questions on this subtopic in GCSE Computer Science (Edexcel), marked as you tap.

Revision notes

How bitmap images are stored in binary as a grid of pixels, and how resolution and colour depth affect image quality and file size. Expect definitions, questions on reading or writing pixel codes, 'explain the effect' questions and file size expressions.

Key facts

  • Pixel = the smallest single-coloured element of a bitmap image
  • Colour depth = number of bits per pixel
  • Resolution = number of pixels (width × height)
  • Number of colours = 2colour depth
  • Image size in bits = width × height × colour depth
  • bits ÷ 8 = bytes; bytes ÷ 1024 = KiB; KiB ÷ 1024 = MiB
  • More pixels or more bits per pixel: better quality, bigger file

Notes

Pixels and binary

diagram
  • A bitmap image is a grid of tiny dots called pixels (picture elements). Each pixel is a single colour.
  • The colour of each pixel is stored as a binary code, and the codes are stored in order, row by row.
  • In a black-and-white image, 1 bit per pixel is enough, e.g. 1 = black and 0 = white.
  • 1000011000011111111000011000011 bit per pixelstored row by row
    A two-colour bitmap needs 1 bit per pixel: here 1 = coloured, 0 = blank. A black-and-white image works the same way

Colour depth

  • Colour depth is the number of bits used to store the colour of each pixel.
  • n bits give 2n colours: 1 bit gives 2, 2 bits give 4, 4 bits give 16, 8 bits give 256 and 24 bits give 16,777,216.
  • A greater colour depth gives more colours, so the image looks more realistic, but the file is larger.
  • If every code is already used, adding one more colour needs 1 extra bit per pixel, which doubles the number of colours available. Grade 6+ only

Resolution

diagram
  • Resolution is the number of pixels in an image, usually given as width × height, e.g. 800 × 600 pixels.
  • A higher resolution means more pixels, so more detail and a sharper image, but a larger file.
  • A low-resolution image looks blocky (pixelated) when it is enlarged.
  • 6 × 6 = 36 pixels16 × 16 = 256 pixels
    Higher resolution: more pixels, more detail, but a bigger file

File size

  • File size in bits = width × height × colour depth.
  • Divide by 8 for bytes, then by 1024 for KiB and by 1024 again for MiB.
  • Example: 256 × 128 pixels with a colour depth of 8 bits: 256 × 128 × 8 = 262,144 bits = 32,768 bytes = 32 KiB.
  • Work out the pixel data only, unless the question tells you otherwise.

How to answer each type of question

Define the key terms

1 mark eachGrade 4
  1. Pixel: the smallest element of the image, a single colour.
  2. Colour depth: use the words 'number of bits' and 'each pixel'.
  3. Resolution: the number of pixels, width × height.

Example. (a) Define the term 'colour depth'.
(b) State the number of different colours that can be represented with a colour depth of 5 bits.

Show the model answerHide the model answer
(a) The number of bits used to store the colour of each pixel
(1)
(b) 32 (25)
(1)

Encode a small image

2 marksGrade 5
  1. Use the colour codes given in the question.
  2. Work along each row from left to right.
  3. Number of bits = number of pixels × colour depth.

Example. A bitmap image is 4 pixels wide and 2 pixels high. It has a colour depth of 2 bits and uses these codes:

ColourCode
white00
green01
blue10
black11
The colours of the pixels are:
Pixel 1Pixel 2Pixel 3Pixel 4
Row 1whitegreengreenblack
Row 2bluebluewhitewhite
(a) Give the binary code for row 1.
(b) State the number of bits needed to store the whole image.

Show the model answerHide the model answer
(a) 00 01 01 11
(1)
(b) 8 pixels × 2 bits = 16 bits
(1)

Explain the effect of changing resolution or colour depth

2 marksGrade 6
  1. Say what happens to the image quality, and why.
  2. Say what happens to the file size, and by how much if you can.
  3. Use numbers from the question.

Example. A photographer reduces the resolution of a photo from 4000 × 3000 pixels to 2000 × 1500 pixels. The colour depth is unchanged.
Explain the effect of this change on the photo and on its file size.

Show the model answerHide the model answer
There are fewer pixels, so less detail can be shown and the photo may look pixelated when it is enlarged (1). Only a quarter as many pixels are stored (3,000,000 instead of 12,000,000), so the file size is a quarter of the original (1).

Construct an expression for the file size of an image

2 to 3 marksGrade 7
  1. Multiply width × height to get the number of pixels.
  2. Multiply by the colour depth to get bits.
  3. Divide by 8 for bytes, then by 1024 for each step up (KiB, MiB).
  4. You do not have to work it out unless the question asks you to.

Example. A bitmap image is 1200 pixels wide and 900 pixels high, with a colour depth of 24 bits.
Construct an expression to calculate the file size of the image in mebibytes (MiB). You do not need to do the calculation.

Show the model answerHide the model answer
1200 × 900 × 24 (1) ÷ 8 (1) ÷ 1024 ÷ 1024 (1)

Don’t lose marks

  • Defining colour depth as 'the number of colours'. It is the number of bits per pixel.
  • Forgetting to divide by 8 to change bits into bytes.
  • Dividing by 1000 instead of 1024 when converting to KiB or MiB.
  • Saying a higher resolution means 'bigger pixels'. It means more pixels.
  • Giving only one effect when the question asks about quality and file size.

More tips

Memory tricks

  • Colour depth to colours: 2 to the power of the bits. Colours to colour depth: the smallest power of 2 that is enough.
  • Double the colour depth and the file size doubles. Double both the width and the height and there are four times as many pixels, so the file is four times as big.
  • Divide early to keep numbers small: 24 bits = 3 bytes per pixel, so the size in bytes is width × height × 3.
  • Remember the chain: bits (÷ 8) bytes (÷ 1024) KiB (÷ 1024) MiB.

Exam technique

  • 'Construct an expression' only needs the expression: marks are given for each stage (bits, bytes, then the final unit).
  • When explaining a change, cover both sides: what happens to the quality and what happens to the file size.
  • Quote numbers from the context (e.g. 256 colours instead of 16) to make an explanation precise.

What each grade needs

What you need to be able to do, from the first marks up to the top grade.

  1. Grade 3
    Define pixelThe smallest single-coloured element (dot) of a bitmap image.
  2. Grade 4
    Define resolution and colour depthResolution is the number of pixels (width × height); colour depth is the number of bits per pixel.
  3. Grade 5
    Find the number of coloursA colour depth of n bits gives 2n colours, e.g. 8 bits give 256.
  4. Grade 5
    Encode and decode a simple bitmapUse the given code for each colour to turn the pixels into binary, row by row.
  5. Grade 6
    Explain effects of changing resolution or colour depthMore pixels or more bits per pixel improve quality but increase the file size.
  6. Grade 7
    Construct a file size expression for an imagewidth × height × colour depth gives bits; ÷ 8 for bytes, then ÷ 1024 for KiB.
  7. Grade 8
    Work backwards to find colour depthColour depth = total bits ÷ number of pixels, after converting the size into bits.

Quick recall

Cover the answers and test yourself. The app has these as flashcards that come back just before you'd forget them.

Define the term 'pixel'.
The smallest single-coloured element (dot) of a bitmap image.
Give the number of colours that can be represented by a colour depth of 2 bits.
4
State the number of bytes in 1 kibibyte (1 KiB).
1,024
State the smallest colour depth, in bits, that can store 16 different colours.
4 bits
When the number of pixels in an uncompressed image is increased, the file size ………… .
increases
A row of eight pixels in a two-colour image is stored using 1 for black and 0 for white. From left to right the pixels are: white, black, black, white, black, white, white, black. Write the binary pattern that is stored for this row.
01101001

Sample questions

Written for this site in the style of Edexcel exam questions. They are not taken from real past papers.

Question 1Easy3 marks
(a) Define the term 'pixel'.
[1]
(b) Define the term 'colour depth'.
[1]
(c) State the number of different colours that can be represented with a colour depth of 3 bits.
[1]
Show the answer and mark scheme
(a) Answer: The smallest single-coloured element (dot) of a bitmap image.
  • the smallest element of a bitmap image / a single point (dot) of one colour in the image
(b) Answer: The number of bits used for each pixel’s colour.
  • the number of bits used to store the colour of each pixel
(c) Answer: 8
  • 8 (23)
Question 2Medium4 marks
A photo-editing app allows a user to change the colour depth and the resolution of a bitmap image.
(a) Explain the effect of reducing the colour depth of a photo from 24 bits to 8 bits.
[2]
(b) Explain the effect of increasing the resolution of the photo.
[2]
Show the answer and mark scheme
(a) Answer: Only 256 colours instead of over 16 million, so the photo looks less realistic, but the file is a third of the size.
  • fewer colours can be represented (256 instead of 16,777,216), so the photo looks less realistic / colours may appear as bands
  • the file size is reduced (to a third of the original)
(b) Answer: More pixels give more detail and a sharper image, but the file size increases.
  • there are more pixels, so more detail can be shown / the image is sharper / less pixelated
  • more pixels must be stored, so the file size increases
Question 3Hard5 marks
A game uses a small sprite that is 4 pixels wide and 3 pixels high with a colour depth of 2 bits. The colour codes are: 00 = white, 01 = red, 10 = blue and 11 = black. The sprite is stored row by row, starting with the top row:
Row 1: 00 01 01 00
Row 2: 10 11 11 10
Row 3: 00 01 01 00
(a) State the colour of the pixel in row 2, column 1.
[1]
(b) State the number of bits needed to store the sprite.
[1]
(c) The designer wants to add green to the sprite’s colours.
Explain why the colour depth must increase, and state the new colour depth needed.
[2]
(d) State the increase in the size of the sprite, in bits, when the new colour depth is used.
[1]
Show the answer and mark scheme
(a) Answer: blue
  • blue
(b) Answer: 24 bits
  • 24 (12 pixels × 2 bits)
(c) Answer: All 4 two-bit codes are in use, so a fifth colour needs 3 bits (up to 8 colours).
  • 2 bits give only 4 codes / colours, and all four are already used
  • a fifth colour needs a colour depth of 3 bits (23 = 8 colours)
(d) Answer: 12 bits
  • 12 (12 pixels × 1 extra bit)

More in Data representation

Stuck? Get 1-to-1 help.

Chhetri Academy tutors GCSE and A level Maths and Science online, with a free 30-minute trial lesson.