← Tools
OCR GCSE Computer Science · 1.2 Data Representation

Characters & Images

How computers store text with character sets (ASCII, Extended ASCII, Unicode) and images as pixels — colour depth, resolution, DPI, metadata and file sizes. Revise the notes, try the interactive demos, then take the 15-question quiz.

This Lesson

Learning objectives

  • Understand how character sets (ASCII, Extended ASCII and Unicode) are used to represent text as binary.
  • Understand how bitmap images are represented in binary, including colour depth, resolution and metadata.

What we will cover

  • Character sets: ASCII, Extended ASCII and Unicode
  • How to calculate the file size of a piece of text
  • Bitmap images: pixels, colour depth and resolution
  • Image metadata

Do now

Without looking it up — how many different symbols does a standard UK keyboard have? How do you think a computer stores each one as binary?
Count the letters (upper and lower case), digits, punctuation and symbols — it comes to roughly 100. Each one is given its own unique binary code from a character set. With 7 bits there are 27 = 128 codes, which is enough for all of them.

Key Meanings

BinaryComputers can only store 0s and 1s, so text and images must be turned into binary codes.
CharacterAny letter, digit, punctuation mark or symbol — e.g. A, 7, ?, space.
Character setThe collection of characters a computer can recognise, together with the binary code used to represent each one.
ASCII7 bits per character → 128 characters (English letters, digits, punctuation, control codes).
Extended ASCII8 bits per character → 256 characters, adding accented letters and symbols.
Unicode16 or 32 bits per character → every major alphabet, symbol and emoji.
PixelA single dot of colour. Bitmap images are a grid of pixels.
Colour depthThe number of bits used to store each pixel. More bits = more colours.
ResolutionThe number of pixels in an image: width × height.
DPIDots per inch — how many pixels are printed in one inch.
MetadataData about a file (not its content) so it can be opened and displayed correctly.

1. Characters

Computers can only store binary. To store text, every character is given its own unique binary code. The agreed list of characters and their codes is called a character set. When you press a key, the computer stores the code for that character; when it displays text, it looks the code up and draws the matching character.

Text file size (bits) = bits per character × number of characters Divide by 8 to get bytes.

Common character sets

Character setBits per characterNumber of charactersDetails
ASCII727 = 128Standard English letters, digits, punctuation and some control codes (e.g. backspace). A 0 is often added at the front so each code fills a whole byte.
Extended ASCII828 = 256Uses the full byte. The extra 128 codes hold accented letters and symbols for languages such as French or German (é, ü, ç).
Unicode16 or 32Over 65,000 (16-bit) — billions possible (32-bit)Covers every major alphabet, symbols and emoji. Better for international keyboards because it can represent characters from any language, not just English. The first 128 codes are the same as ASCII.

Worked example: encoding characters in ASCII

CharacterBinaryHexDenary
B010000104266
+001010112B43
backspace00001000088
Exam tip: character codes are in sequence. If A = 65, then B = 66, C = 67 and so on. Lower case starts at a = 97, and digits start at 0 = 48. You can work out any letter by counting on.
Try it — character encoder

2. Images

Bitmap images are made of a grid of pixels. Each pixel stores a binary value that represents its colour. The number of bits used for each pixel is the colour depth (or bit depth). The more bits per pixel, the more different colours can be shown.

Number of colours = 2n  (where n = bits per pixel) Each extra bit doubles the number of colours.
Try it — pixel painter

Colour depth

Pick a colour, then click pixels

The whole image in binary (one row of pixels per line)

Colour depth and number of colours

Colour depthNumber of colours
1-bit21 = 2 (e.g. black and white only)
2-bit22 = 4
4-bit24 = 16
8-bit28 = 256
16-bit216 = 65,536
24-bit224 = 16,777,216 (‘true colour’)
The same flower photo at 16-bit, 8-bit, 4-bit and 1-bit colour depth
From the lesson slides: as the colour depth drops from 16-bit to 1-bit, fewer colours are available and the image loses detail and becomes blocky or banded.

How many bits are needed?

This image is 4 × 5 = 20 pixels and uses 8 different colours.

  1. Find the smallest n where 2n ≥ 8 → 23 = 8, so 3 bits per pixel.
  2. Total = 20 pixels × 3 bits = 60 bits.
Watch out: if an image had 9 colours, 3 bits would not be enough (only 8 codes), so you would need 4 bits.

Your turn — Question Time

Look at the pixel-art image from the lesson slides. How many bits are needed to represent all the pixels of this image?

Count the pixels, count the different colours, then use the same two steps as above.

  1. The image is 4 × 4 = 16 pixels.
  2. It uses 8 colours: red, yellow, orange, green, light blue, navy, black and white.
  3. 23 = 8, so 3 bits per pixel.
  4. 16 × 3 = 48 bits.
A 4 by 4 pixel-art image using 8 colours

Resolution and DPI

Resolution is the number of pixels that make up an image (width in pixels × height in pixels). DPI (dots per inch) is how many pixels are printed within one inch. Increasing resolution or DPI gives a sharper, more detailed image — but the file gets bigger.

Image file size (bits) = width (pixels) × height (pixels) × colour depth (bits) ÷ 8 for bytes → ÷ 1,000 for kilobytes → ÷ 1,000 for megabytes.

Metadata

Metadata is data about a file, rather than the file’s actual content. Without it, the computer would just see a long string of bits and wouldn’t know where each row ends or how many bits belong to each pixel, so it couldn’t recreate the image.

For an image, metadata typically includes its dimensions, resolution, colour depth and, for photos, details about the camera used.

A night-time photograph of London and the River Thames
From the lesson slides: the photograph…
The photo's file properties showing its metadata
…and its file properties (metadata).
Metadata from this photoValue
Dimensions (width × height)6240 × 4160 pixels
Resolution238 dpi
Bit (colour) depth24-bit
CameraFUJIFILM X-T30

3. File Size Calculator

Check your working with the calculator — but make sure you can do it by hand for the exam!

Test Yourself — 15 Questions