Year 9 · Audio-Visual · Part A: Storing information

Representing images

In one line

A picture is a grid of tiny squares called pixels. Each pixel's colour is stored as a binary number. More pixels and more colours make a better picture, and a bigger file.

1

Explain how a bitmap image is a grid of pixels, stored row by row as binary.

2

Use colour depth: work out how many colours d bits give, and how many bits n colours need.

3

Read RGB and hex colour codes like #FF8000.

4

Calculate an image's file size by hand, in bits, bytes, KB and MB, and explain the quality–size trade-off.

PixelThe smallest dot of one colour in an image.
BitmapAn image stored as a grid of pixels.
ResolutionHow many pixels: width × height.
Colour depthBits per pixel. Sets how many colours.
MetadataData about the data: width, height, depth.
VectorAn image stored as shapes, not pixels.

Zoom in: a picture is a grid of pixels

Zoom right into any photo on a screen. It turns into little squares. Each square is one pixel. A pixel is the smallest dot of one single colour.

What you see It looks smooth from far away. Zoomed in 8 times Each square is one pixel, one colour.
The dashed square on the left is blown up on the right. The curved edge is really a staircase of squares. Each square is filled with exactly one colour. The black outline marks one pixel.
  1. Pixel is short for picture element. One element: one dot.

  2. One pixel = one colour. A pixel can't be half red and half blue. If you need two colours, you need two pixels.

  3. One colour = one binary number. The computer stores a number for each pixel. The number says which colour it is.

  4. An image stored like this is a bitmap: a map of bits. Most photos are bitmaps (JPEG, PNG, GIF, BMP).

e.g.Example

A phone screen packs about 400 to 500 pixels into every inch. That's why you can't see them without a magnifying glass. An old 1980s computer screen had about 70 per inch: you could see every one.

The simplest image: 1 bit per pixel

If a pixel can only be black or white, it only has two choices. Two choices need just 1 bit. Here we use 1 = black and 0 = white.

The picture (5 × 5) Stored one row after another: 25 bits 11111 00100 00100 00100 00100
Read each row left to right, then go down to the next row, like reading a book. The colours only show where each row starts. The computer just sees one long line of bits.
!Watch out

The long line of bits has no "new row" mark in it. The computer must also be told the width (5) to cut the line into rows again. That extra information is called metadata. Step 9 shows what goes wrong without it.

Decode a picture by hand

Width = 5. The bits are 10001 01010 00100 01010 10001. What's the picture?

  1. Cut the bits into rows of 5 (the width). You get 5 rows.

  2. Row 1 = 10001: black, white, white, white, black. ■□□□■

  3. Row 2 = 01010: □■□■□

  4. Row 3 = 00100: □□■□□

  5. Rows 4 and 5 mirror rows 2 and 1: □■□■□ then ■□□□■.

  6. Stack them: it's a big X. Size: 5 × 5 pixels × 1 bit = 25 bits.

More colours need more bits per pixel

The number of bits used for each pixel is the colour depth. It's the same rule you met with bits and bytes: every extra bit doubles the number of patterns, so it doubles the number of colours.

Each row is a palette: the list that says which code means which colour. Here the colours are greys, from white (all 0s) to black (all 1s). Add one bit and the palette doubles.
Colour depthColoursWhere you see it
1 bit2Black and white. Fax, old e-readers, a QR code.
2 bits4Very early games (the original Game Boy had 4 greens).
8 bits256GIFs, retro "pixel art" graphics.
16 bits65,536Older phones and games consoles.
24 bits16,777,216 (about 16.7 million)Normal photos and screens: "true colour".

By hand: how many colours does 8 bits give?

  1. Start with 1 bit: 2 colours.

  2. Double for each extra bit: 2 bits → 4, 3 bits → 8, 4 bits → 16.

  3. Keep going: 5 bits → 32, 6 bits → 64, 7 bits → 128.

  4. 8 bits → 256 colours. That's 2⁸ = 2 × 2 × 2 × 2 × 2 × 2 × 2 × 2.

Backwards: how many bits do I need for 100 colours?

  1. Keep doubling until you reach at least 100: 2, 4, 8, 16, 32, 64, 128.

  2. 64 is too few (only 64 colours). 128 is enough.

  3. 128 = 2⁷, so you need 7 bits. The 28 spare codes are simply not used.

!Watch out

You can't use part of a bit. Maths says 100 colours need about 6.64 bits. A computer must round up to 7. Rounding down to 6 would only give 64 colours.

e.g.Year 9 link: the micro:bit

The micro:bit's screen is a 5 × 5 bitmap. Each LED has 10 brightness levels, 0 to 9. 3 bits (8 levels) is not enough, so each LED needs 4 bits (16 levels, 6 unused). The whole screen: 25 × 4 = 100 bits.

from microbit import *
# each digit is one pixel's brightness, 0 (off) to 9 (full). ":" starts a new row
heart = Image("09090:99999:99999:09990:00900")
display.show(heart)

24-bit colour: three bytes, red, green and blue

Look very closely at a screen pixel. It's really three tiny lights: red, green and blue. Each light gets its own byte (0 to 255) saying how bright it is. 3 bytes × 8 bits = 24 bits per pixel.

One orange pixel full · half · off 8 + 8 + 8 = 24 bits for every pixel
Red on full, green at half, blue off: your eye blends the three lights into orange. Each light's brightness is one byte.
ColourRedGreenBlueHex
?Why?

Why is red + green = yellow? Mixing light adds colours together: more light, brighter colour. All three on full makes white. Mixing paint works the other way: each paint soaks up some light, so mixing gets darker. Screens make light, so they follow the light rules.

Where does "16.7 million" come from?

  1. Red has 256 possible brightness levels (0 to 255).

  2. For each red, green can be any of 256. That's 256 × 256 = 65,536 mixes.

  3. For each of those, blue can be any of 256: 65,536 × 256 = 16,777,216.

  4. Same answer as the formula: 2²⁴ = 16,777,216. Three bytes are just 24 bits.

★Remember

(0, 0, 0) = all lights off = black. (255, 255, 255) = all on full = white. Equal amounts of all three = a grey.

Hex colour codes: #RRGGBB

Web pages and design apps write colours in hex. One byte is exactly 2 hex digits (you met this in Year 8: binary, denary and hex). So 3 bytes = 6 hex digits: two for red, two for green, two for blue.

# FFRed15×16+15= 255 80Green8×16+0= 128 00Blue0×16+0= 0 The # just means "a hex colour follows". Each pair is one byte.

By hand: what colour is #FF8000?

  1. Drop the #. Split the 6 digits into 3 pairs: FF | 80 | 00.

  2. Red FF: F = 15. First digit counts sixteens: 15 × 16 = 240. Add the second: 240 + 15 = 255 (full on).

  3. Green 80: 8 × 16 = 128, plus 0 = 128 (about half).

  4. Blue 00: 0 (off).

  5. Red full + green half + no blue = orange.

▶

RGB mixer: see every bit

Slide the three lights. Each slider is one byte. Watch the binary and the hex change together.

e.g.Try it in class

In Python's turtle, turtle.color("#FF8000") draws in orange. In HTML/CSS, color: #FF8000; does the same. Same 6 digits everywhere.

Resolution: how many pixels

Resolution is the number of pixels in an image, written width × height. More pixels means smaller squares, so you see finer detail.

Same picture, same size on the page. Only the number of pixels changes. At 4 × 4 the sun is a blocky square. At 16 × 16 it starts to look round.
NameWidth × heightPixels
Old school projector (VGA)640 × 480307,200
HD (720p)1280 × 720921,600
Full HD (1080p)1920 × 10802,073,600 (about 2 million)
4K UHD3840 × 21608,294,400 (about 8.3 million)
A 12 megapixel phone photo4000 × 300012,000,000

By hand: how many pixels is Full HD?

  1. We need 1920 × 1080. Split 1080 into 1000 + 80, which are easier.

  2. 1920 × 1000 = 1,920,000.

  3. 1920 × 80 = 1920 × 8 × 10 = 15,360 × 10 = 153,600.

  4. Add them: 1,920,000 + 153,600 = 2,073,600 pixels. "Mega" means million, so about 2 megapixels.

!Watch out

"Resolution" has a second meaning: pixels per inch (ppi, or dpi for printers). That's about how tightly pixels are packed on a screen or paper. In GCSE image-size questions, resolution always means width × height.

?Why?

Why does a small photo go blurry or blocky when you blow it up? Enlarging can't invent detail that was never stored. The computer can only make each pixel bigger, or guess the colours in between (which looks blurry).

Calculating an image's file size

Every pixel needs the same number of bits (the colour depth). So: count the pixels, then multiply by the bits for each one. Then change units to bytes, KB and MB.

An 800 × 600 photo at 24-bit colour. Two multiplications give bits. Then divide your way up the units ladder.

By hand: an exam-style question

"An image is 100 × 50 pixels with a colour depth of 4 bits. Work out its size in bytes, then in KB."

  1. Pixels: width × height = 100 × 50 = 5,000 pixels.

  2. Bits: each pixel needs 4 bits. 5,000 × 4 = 20,000 bits.

  3. Bytes: 8 bits make 1 byte, so divide by 8. 20,000 ÷ 8 = 2,500 bytes.

  4. KB: 1,000 bytes make 1 KB, so divide by 1,000. 2,500 ÷ 1,000 = 2.5 KB.

  5. Check it makes sense: a tiny 16-colour image is a few KB. A phone photo is a few MB. ✓

★Remember

size in bits = width × height × colour depth. Then ÷ 8 for bytes, ÷ 1000 for KB, ÷ 1000 again for MB.

★Exams

AQA 8525 writes it as W × H × colour depth and asks for bits or bytes. OCR J277 writes colour depth × height × width. Same thing: multiplying works in any order. Both accept ÷ 1000 or ÷ 1024 for KB if you're consistent. Real files are a little bigger (metadata) or much smaller (compression, Topic 7). Exam answers ignore both.

The trade-off: quality against file size

More pixels and more colours make a better picture. They also make a bigger file. Use the toy to feel the trade-off.

▶

Shrink the resolution and the colours

The picture is drawn by maths, then stored at the resolution and colour depth you pick.

Resolution
Colour depth
Pixels
Colours
File size

You change…PixelsFile size
Double the colour depth (e.g. 8 → 16 bits)same× 2
Add 1 bit of colour depth (e.g. 8 → 9 bits)samea little bigger, but × 2 the colours
Double the width only× 2× 2
Double the width and the height× 4× 4
Halve the width and the height÷ 4÷ 4
?Why?

Why does doubling both sides give 4 times the size? Picture a 2 × 2 square of 4 tiles. Make it 4 × 4: now there are 16 tiles. Twice as wide and twice as tall is 2 × 2 = 4 times the tiles.

e.g.Choosing

A school logo for a web page: small, few colours. A photo for a printed poster: high resolution, 24-bit. A thumbnail in a search result: tiny. Pick the lowest settings that still look good for the job.

Metadata: the header that explains the pixels

An image file starts with a header. The header holds metadata: data about the data. It tells the computer how to read the pixel bits that follow.

Header (metadata) Pixel data width = 5 height = 5 colour depth = 1 Extra (EXIF)date and timecamera modelGPS location 11111 00100 00100 00100 00100 … "Start a new row every 5 bits" The header comes first, so the program knows how to read what follows.
Without the width, height and colour depth, the pixel bits are just a long line of 0s and 1s with no meaning.
▶

Change the width in the header

These 24 bits never change. Only the width in the header changes. Which width shows the real picture?

!Watch out: GPS in photos

Phones save extra metadata called EXIF: the date, the phone model, and often the exact GPS location. A photo of your front door can tell a stranger where you live. Many social apps strip it out, but messaging and email often keep it.

The law treats a location linked to a person as personal data: UK GDPR and the Data Protection Act 2018 (amended by the Data (Use and Access) Act 2025) in the UK; the EU GDPR and the LOPDGDD 3/2018 in Spain. Schools sharing pupil photos must think about this.

Bonus: bitmap vs vector

A bitmap stores every pixel. A vector image stores instructions to draw shapes, like "circle here, radius 40, orange". The computer redraws the shapes at whatever size you need.

Bitmap, zoomed in Vector, zoomed in Jagged "staircase" edges: the jaggies. Redrawn smooth at every size. stored as: circle(x, y, r, orange) stored as: every pixel's colour
Fun fact: every diagram on this page is a vector image (SVG). That's why they stay sharp when you zoom the page.
BitmapVector
StoresThe colour of every pixelShapes: lines, curves, fills
Zoom inGoes blocky or blurryStays sharp at any size
Good forPhotos, scans, detailed scenesLogos, icons, fonts, maps, diagrams
File sizeGrows with width × heightGrows with the number of shapes
File typesJPEG, PNG, GIF, BMPSVG, PDF drawings, fonts
★Exams

The current AQA 8525 and OCR J277 GCSEs only test bitmaps. Vectors are useful background, and they explain why logos and fonts never go blocky.

Common mix-ups

The mistakes nearly everyone makes the first time. Read the left side, then the right.

People think

Colour depth is the number of colours.

Actually

Colour depth is the number of bits per pixel. The colours are 2 to the power of it: depth 8 → 256 colours.

People think

Doubling the colour depth doubles the colours.

Actually

It doubles the file size. The colours are squared: 8 bits = 256 colours, 16 bits = 65,536.

People think

Double the width and height → double the file size.

Actually

4 times the pixels, so 4 times the size.

People think

width × height × depth gives bytes.

Actually

It gives bits. Divide by 8 for bytes, before you go to KB or MB.

People think

100 colours need 6 bits, because 2⁶ is close to 100.

Actually

2⁶ = 64 is too few. Round up: 7 bits (128).

People think

Zooming in on a photo shows you more detail.

Actually

It only makes the stored pixels bigger. Detail that wasn't captured can't appear.

People think

The pixel bits contain the width.

Actually

The width lives in the header (metadata). The pixel data is just one long line of bits.

Check yourself

Quick questions first. Then endless practice: a wrong answer shows you the working, step by step.

[ {"q":"A colour depth of 2 bits gives how many colours?","o":["2","4","8"],"a":1,"w":"2 × 2 = 4: the codes 00, 01, 10, 11."}, {"q":"A 10 × 10 black-and-white image needs…","o":["100 bits","20 bits","10 bits"],"a":0,"w":"100 pixels × 1 bit = 100 bits."}, {"q":"Double the width **and** the height. The file becomes…","o":["2 times bigger","4 times bigger","8 times bigger"],"a":1,"w":"2 × 2 = 4 times the pixels, so 4 times the bits."}, {"q":"You need 300 different colours. The smallest colour depth is…","o":["8 bits","9 bits","300 bits"],"a":1,"w":"2⁸ = 256 is too few. 2⁹ = 512 is enough."}, {"q":"In #00FF00, which light is on?","o":["Red","Green","Blue"],"a":1,"w":"The pairs are RR GG BB. Only the middle pair (green) is FF = 255."}, {"q":"width × height × colour depth gives the size in…","o":["bits","bytes","KB"],"a":0,"w":"Each pixel needs d **bits**. Divide by 8 for bytes."}, {"q":"Which is metadata?","o":["The image's width","The colour of pixel 7","A pixel's red value"],"a":0,"w":"Width, height and colour depth describe the data. They aren't pixels themselves."}, {"q":"A logo must look sharp on a pen and on a billboard. Best stored as…","o":["A bitmap","A vector"],"a":1,"w":"Vectors are redrawn from shapes, so they're sharp at any size."} ]