Representing Text, Images and Sound
Character sets, bitmap images and sampled sound, and every calculation Edexcel can ask you to do on each, with the conversions set out step by step.
Representing text
A computer stores only numbers, so text is turned into numbers using a character set: an agreed table giving every character a unique binary code.
ASCII
ASCII uses 7 bits, giving 2 to the power 7, which is 128 codes. That covers the English alphabet in both cases, the digits, punctuation and control characters such as carriage return. Extended ASCII uses 8 bits and has 256 codes.
The codes are assigned in order, which is useful:
'A'is 65, so'B'is 66 and'Z'is 90.'a'is 97, so lower case is always upper case plus 32.'0'is 48, so the value of a digit character is its code minus 48.
'7' is stored as the code 55. That is why anything typed at a keyboard must be converted before it can be used in arithmetic.
Unicode
ASCII has no codes for Greek, Arabic, Chinese, Hindi or emoji. Unicode uses more bits per character and has room for over a million codes, which covers every writing system in current use.
The trade is storage: characters outside the basic set need more than one byte. The first 128 Unicode codes are deliberately identical to ASCII, so plain English text costs the same in both and every existing ASCII file is already valid Unicode.
Calculating the size of a text file
size in bits = number of characters x bits per character
A 500 character message in 8 bit extended ASCII is 500 times 8, which is 4000 bits, or 500 bytes. Spaces and punctuation are characters and must be counted.
- Each character has a code number, and the computer stores that number in binary.
- The codes run in order, so you can work out C from A. The character 7 is not the number 7.
- More bits per character means more characters: 128, then 256, then over a million.
Representing images
A bitmap image is stored as a grid of pixels, with a binary value recorded for the colour of every pixel.
Resolution is the number of pixels, given as width by height. More pixels means more detail and proportionally more data.
Colour depth is the number of bits used per pixel, and it decides how many colours a pixel can be:
| Colour depth | Colours |
|---|---|
| 1 bit | 2 |
| 4 bit | 16 |
| 8 bit | 256 |
| 24 bit | 16 777 216 |
Metadata is data about the file: width, height, colour depth, format, date. Without the width, software cannot know where each row of pixels ends, so the picture cannot be reconstructed at all.
Calculating image file size
size in bits = width x height x colour depth
An image 1024 by 768 at 24 bit colour:
pixels = 1024 x 768 = 786 432
size in bits = 786 432 x 24 = 18 874 368 bits
size in bytes = 18 874 368 / 8 = 2 359 296 bytes
size in KiB = 2 359 296 / 1024 = 2 304 KiB
size in MiB = 2 304 / 1024 = 2.25 MiBA kibibyte is 1024 bytes, a mebibyte is 1024 kibibytes. Dividing by 1000 will not match the mark scheme.
- A bitmap is a grid of pixels. This one is 8 by 8, so 64 of them.
- Pick one pixel. Its colour is three numbers: red, green and blue.
- Each number is 8 bits, so one pixel costs 24 bits, which is 3 bytes.
- File size = width × height × colour depth. That is the whole formula.
- The picture is a grid of pixels, stored as one long stream of bits.
- Metadata that must be stored: width, height and colour depth. Without them the bits cannot be turned back into the picture.
- Extra metadata such as date, device and GPS location is useful, but sharing it can be a privacy risk.
Representing sound
Sound is an analogue wave: continuous, with a value at every instant. A computer cannot store something continuous, so the wave is sampled, meaning its height is measured at regular intervals and each measurement is stored as a binary number.
The result is a staircase that follows the wave without exactly matching it. How close it gets depends on two things.
Sample rate is how many samples are taken each second, in hertz. A higher rate means narrower steps, so rapid changes and higher frequencies survive. CD audio uses 44100 Hz.
Bit depth, also called sample resolution, is how many bits store each sample. Eight bits gives 256 possible levels, sixteen gives 65536. Every measured height is rounded to the nearest available level, so more bits means less rounding and a more faithful recording.
Calculating sound file size
size in bits = sample rate x bit depth x seconds x channels
A 2 minute stereo recording at 44100 Hz and 16 bits:
seconds = 2 x 60 = 120
size in bits = 44100 x 16 x 120 x 2 = 169 344 000 bits
size in bytes = 169 344 000 / 8 = 21 168 000 bytes
size in KiB = 21 168 000 / 1024 = 20 671.875 KiB
size in MiB = 20 671.875 / 1024 ≈ 20.2 MiBWrite it as the first line of your working. It is the single most common lost mark on this question.
File size calculator
Work out the size of an image, a sound file or a block of text, one conversion at a time. This tool needs JavaScript, so turn it on to use it. Everything you need to answer the exam question is explained in the text above.
- Sound is a wave: a smooth, continuous change in air pressure.
- A computer cannot store smooth. It measures the height at intervals.
- Sample more often and the shape you recorded is closer to the original.
- Bit depth is how finely each measurement is rounded.
Key terms you must be able to define
- Character set
- An agreed table giving every character a unique binary code.
- ASCII
- A 7 bit character set with 128 codes covering English text and control characters.
- Unicode
- A character set using more bits per character, covering over a million characters from every writing system.
- Bitmap
- An image stored as a grid of pixels with a colour value recorded for each.
- Resolution
- The number of pixels in an image, given as width by height.
- Colour depth
- The number of bits used to store the colour of each pixel.
- Metadata
- Data about a file, such as its width, height, colour depth and date.
- Sampling
- Measuring an analogue wave at regular intervals and storing each measurement as a number.
- Sample rate
- The number of samples taken per second, measured in hertz.
- Bit depth
- The number of bits used to store each individual sample.
- Kibibyte
- 1024 bytes, the binary prefix unit Edexcel uses.
Flashcards
Say the definition out loud before you flip the card. Retrieving it from memory is what builds recall, reading it again is not.
Reach the top grade on this topic
Most of the marks here are arithmetic, and most of the lost marks are conversions.
Label your units as you go. Write "bits" and "bytes" beside each line of working. It makes a missing division by eight obvious to you before it is obvious to the examiner.
Divide by 1024, not 1000. Edexcel uses kibibytes and mebibytes. This is a genuine board difference and it changes your answer.
Give the mechanism, not the label. "Increasing colour depth adds bits to every single pixel, so the file grows in proportion" earns more than "more colours makes the file bigger".
Name both sound controls with their separate effects. Sample rate is detail across time, bit depth is detail in amplitude, and questions expect you to know which is which.
Mistakes that cost marks here
- Dividing by 1000 rather than 1024. Edexcel uses binary prefixes.
- Leaving the duration in minutes in a sound calculation.
- Forgetting to multiply by two for a stereo recording.
- Saying ASCII has 256 characters. Standard ASCII is 7 bit with 128.
- Treating a digit character as its numeric value without converting it.
The reason a screenshot of a paragraph of text is hundreds of times larger than the text itself is that the image stores a colour for every pixel, including all the white space, while the text stores one code per character.
Knowledge check
Exam-style questions
Five written questions in the style of the real paper. Write a full answer, then let the marker check it against the mark scheme.
- LData about the file rather than the picture content itself
- LGives an example such as width, height, colour depth or date
Metadata is data stored in a file that describes the file itself rather than forming part of the picture, such as its width and height in pixels, its colour depth, its format and the date it was created.
- LMultiplies width by height
- LMultiplies by the colour depth to get bits
- LDivides by 8 to get bytes
- LDivides by 1024 to give approximately 937.5 KiB
The number of pixels is 800 multiplied by 600, which is 480000. At 16 bits each that is 480000 multiplied by 16, giving 7680000 bits. Dividing by 8 gives 960000 bytes. Dividing by 1024 gives 937.5 kibibytes.
- LSample rate is the number of samples taken each second
- LA higher sample rate captures faster changes and higher frequencies
- LBit depth is the number of bits used to store each sample
- LA higher bit depth gives more possible levels, so each height is recorded more accurately
Sample rate is how many measurements of the wave are taken each second, measured in hertz. Raising it places the measurements closer together in time, so faster changes in the wave are captured and higher frequencies survive into the recording. Bit depth is how many bits are used to store each individual measurement. Raising it increases the number of levels a sample can take, so each measured height is rounded by a smaller amount and the recorded loudness is closer to the true value. The rate therefore controls detail across time and the bit depth controls detail in amplitude, and both increase the file size in direct proportion.
- LA text file stores one code per character
- LAn image stores a colour value for every pixel
- LThe image includes all the blank space, and there are far more pixels than characters
A text file stores one character code per character, so 2000 characters in extended ASCII takes 2000 bytes. A screenshot is a bitmap, which stores a colour value for every single pixel in the picture. A modest screenshot of 1000 by 800 pixels contains 800000 pixels, and at 24 bit colour that is 2.4 megabytes before any compression. Crucially the image also has to store the blank background between and around the letters, because a bitmap has no concept of a character at all: it records only colours at positions.