GCSE · Computer Science · AQA · Spec 8525

Bitmap file size calculation

Zoom into a digital image and it breaks into tiny squares, each stored as a short binary code. Know the code's length and you can size the whole image.

Computer Science · Bitmap images

Paint it however you like. Watch the file size.

8 × 8 pixels · 2-bit

8 by 8 pixel grid, 2 bits per pixel, 4 colours. File size in bits: 128 bit

Paint
Colours4Bit depth2-bitFile size in bits128 bit
pick a colour, paint some pixels, then check the file size

Each of the four colours has its own 2-bit code: 00 is white, 01 is yellow, 10 is black and 11 is red. The grid is 8 pixels wide and 8 pixels high, so that's 64 pixels, and every one of them stores a 2-bit code. That code length, the number of bits per pixel, is called the colour depth. 64 × 2 = 128 bits, and 128 ÷ 8 = 16 bytes. Repaint the whole face and the number doesn't move.

Computer Science · Colour depth

Why each extra bit doubles the colours

Every bit is a two-way choice: 0 or 1. Walk down the tree and build a 3-bit colour code, then count how many different codes there are.

1st bit → 2nd bit → 3rd bit

  • Each bit you add is a new choice: 0 or 1.

2 × 2 × 2 = 8 different 3-bit codes, and the tree ends 8 times.

On Start a pixel's code. 2 branches to choose from.

Keep going and the pattern never breaks: 4 bits give 16 colours and 8 bits give 256. Each new bit splits every existing code in two, so n bits give 2ⁿ different colours.

Watch out: If the number of colours you need isn't a power of 2, round up to the next one. 20 colours needs 5 bits, because 4 bits only give 16 codes and 5 bits give 32.

Computer Science · File size

Your turn to make the two big decisions

An icon is 32 pixels wide and 20 pixels high, with a colour depth of 4 bits. Calculate its file size in bytes.

  1. Write down what you know: width 32 pixels, height 20 pixels, colour depth 4 bits per pixel.
  2. missing step
Which line is step 2?

Computer Science · Spot the slip

One line of this answer is wrong. Which one?

A bitmap image is 60 pixels wide and 40 pixels high, and it can show 256 different colours. Calculate its file size in bytes.

A student's answer — which line goes wrong?

Computer Science · Bigger images

Double the width and the height. How much bigger is the file?

An image's width and height are both doubled. Its colour depth stays the same. How many times bigger is its file size now?

Your estimate

5 times bigger

1 times bigger8 times bigger

WHAT YOU'VE LEARNED

A quick recap of today's lesson.

Count the pixels, multiply by the bits each one uses, then divide by 8 for bytes.

What you need to know

  • A bitmap image is a grid of pixels (picture elements), and each pixel's colour is stored as a binary code.
  • Image size is the width in pixels multiplied by the height in pixels.
  • Colour depth is the number of bits used to store the colour of each pixel.
  • A colour depth of n bits can represent 2ⁿ different colours.
  • File size in bits = width × height × colour depth. Divide by 8 to get bytes, because 1 byte = 8 bits.

The big picture

A bitmap image is a grid of pixels, and each pixel's colour is stored as a binary code. Every code in the image is the same length, and that length is the colour depth. File size in bits = width × height × colour depth; divide by 8 to get bytes. A colour depth of n bits gives 2ⁿ colours. More pixels or more bits per pixel means a bigger file, and fewer means a smaller one.

Key points

1Every pixel uses the same number of bits whatever its colour, so the calculation never depends on what the picture shows.
2Colour depth is a number of bits, not a number of colours: 256 colours means a colour depth of 8 bits, because 2⁸ = 256.
3Each extra bit of colour depth doubles the number of colours: 1 bit gives 2, 2 bits give 4, 3 bits give 8.
4If the number of colours isn't a power of 2, round the colour depth up: 4 bits only give 16 colours, so 20 colours needs 5 bits.
5Changing the width and the height multiplies the pixel count by both changes: double both and the file is 4 times bigger; halve both and it is a quarter of the size.
6Increasing the colour depth increases the file size and decreasing it reduces the file size, because every pixel's code gets longer or shorter.
7The multiplication gives bits. Always divide by 8 if the answer is wanted in bytes.

Worked example

Problem

An image is 40 pixels wide and 25 pixels high, and it can show 16 different colours. Calculate its file size in bytes.

⚠ Watch out

Putting the number of colours into the formula instead of the colour depth. For a 256-colour image, multiply by 8 (the bits per pixel), not by 256.

🧠

Memory hook

Count them, cost them, byte them: count the pixels (width × height), cost them (× bits per pixel), then byte them (÷ 8).

✓

Check yourself

A 10 × 10 image can show 8 colours. What is its file size in bits? (Answer: 8 = 2³, so 3 bits per pixel; 100 × 3 = 300 bits.)

Flashcards

(12)
What is a pixel?
A picture element: one of the tiny squares in the grid that makes up a bitmap image.
How is the colour of each pixel stored?
As a binary code.
How do you work out the image size of a bitmap, in pixels?
Width in pixels × height in pixels.
What is colour depth?
The number of bits used to store the colour of each pixel.
How many colours can a colour depth of n bits represent?
2ⁿ colours.
How many colours does a colour depth of 8 bits give?
256 colours, because 2⁸ = 256.
What colour depth do you need for 32 colours?
5 bits, because 2⁵ = 32.
What is the formula for the file size of a bitmap image in bits?
Width (pixels) × height (pixels) × colour depth (bits per pixel).
How do you turn a file size in bits into bytes?
Divide by 8, because 1 byte = 8 bits.
An image's width and height are both doubled. What happens to its file size?
It becomes 4 times bigger, because there are 4 times as many pixels.
An image's colour depth is doubled but its size in pixels stays the same. What happens to its file size?
It doubles, because every pixel's code is twice as long.
Does repainting pixels in different colours change a bitmap's file size?
No. Every pixel uses the same number of bits whatever colour it is.

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 posted

More AQA GCSE Computer Science topics

See the full AQA Computer Science curriculum →

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 30 September 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.