Representing Images
How a bitmap stores a picture as numbers, what resolution and colour depth actually control, why metadata is needed, and every step of an image file size calculation.
Bitmap images
A bitmap image is stored as a grid of pixels, and a binary value is recorded for the colour of every single pixel. A photograph is a bitmap, as is a screenshot or a scanned document.
The word bitmap is literal: the file is a map of which bits belong to which position in the grid.
Resolution
Resolution is the number of pixels in the image, given as width by height. An image that is 1920 by 1080 has 1920 times 1080, which is 2073600 pixels.
More pixels means more detail, because there are more separate points at which the picture can change. It also means proportionally more data, since every pixel needs its own colour value.
The same 1920 by 1080 image can fill a wall or a phone screen. What changes is how large each pixel appears, not how many there are.
Colour depth
Colour depth is the number of bits used to store the colour of each pixel. It decides how many different colours a pixel can be, and the relationship is a power of two.
| Colour depth | Colours available | Typical use |
|---|---|---|
| 1 bit | 2 | Black and white line art |
| 4 bit | 16 | Very simple icons |
| 8 bit | 256 | Old games, indexed images |
| 24 bit | 16777216 | Photographs, true colour |
In 24 bit colour, 8 bits are given to red, 8 to green and 8 to blue, so each channel has 256 levels and every combination is possible. That is where the value 16.7 million comes from: 256 times 256 times 256.
- 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.
Metadata
Metadata is data about the data. An image file cannot be opened correctly without it, because the raw pixel values alone do not say how they are arranged.
An image file typically stores:
- the width and height in pixels, so software knows where each row ends,
- the colour depth, so it knows how many bits belong to each pixel,
- the file format,
- and often the date, the camera settings, and the location the photograph was taken.
Without the width, a run of colour values is just a list. The width is what turns it back into a rectangle, so software cannot reconstruct the image without it.
The extra metadata raises privacy questions worth knowing about. A photograph taken on a phone commonly records the exact location and time, and those travel with the file when it is shared.
- 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.
Calculating image file size
The formula AQA expects is:
file size in bits = width in pixels x height in pixels x colour depth
Then convert: divide by 8 for bytes, then by 1000 for each unit upwards, since AQA uses 1000.
A worked example
An image is 800 by 600 pixels with a colour depth of 24 bits.
pixels = 800 x 600 = 480 000
size in bits = 480 000 x 24 = 11 520 000 bits
size in bytes = 11 520 000 / 8 = 1 440 000 bytes
size in kB = 1 440 000 / 1000 = 1 440 kB
size in MB = 1 440 / 1000 = 1.44 MBIf the question gives a metadata size, add it after converting it to the same unit. Metadata is usually given in bytes, so convert your image data to bytes first and then add.
There are method marks for the multiplication and for each conversion. A single number on the page, even a correct one, risks losing them if it is not the exact answer expected.
Why the size grows so fast
Doubling the width and the height gives four times as many pixels, so four times the file size. Adding one bit of colour depth adds one bit to every pixel in the image. Both explain why raw uncompressed images are so large, and why compression matters.
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.
Key terms you must be able to define
- Bitmap
- An image stored as a grid of pixels, with a colour value recorded for every pixel.
- Pixel
- The smallest individual element of a bitmap image, holding one colour value.
- 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 the file itself, such as its width, height, colour depth and date.
- True colour
- 24 bit colour, giving 8 bits each to red, green and blue and around 16.7 million colours.
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
Two things earn the last marks on this topic.
Explaining size in terms of every pixel. Increasing colour depth by one bit does not add one bit to the file, it adds one bit to every single pixel. Answers that say so are giving the mechanism rather than the fact.
Being precise about metadata. The strong answer names a specific item and says what would break without it: without the width, software cannot know where each row of pixels ends and the image cannot be reconstructed.
Keeping units visible. Write "bits" and "bytes" beside your numbers as you go. Most lost marks in this topic are a missing division by eight, and labelling the units makes the omission obvious to you before it is obvious to the examiner.
Mistakes that cost marks here
- Giving the answer in bits when the question asked for bytes, or the reverse.
- Forgetting to add the metadata when the question supplies a size for it.
- Confusing resolution with the physical size of the image on screen.
- Saying a higher colour depth means more pixels. It means more bits per pixel.
- Using 1024 rather than 1000 when converting units for AQA.
The very first digital image was made in 1957 by Russell Kirsch, who scanned a photograph of his baby son at 176 by 176 pixels. The square pixel, which we are still using, was his practical choice at the time and he later called it a mistake.
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.
- LThe number of pixels in the image, given as width by height
The resolution of an image is the number of pixels it contains, expressed as the width in pixels multiplied by the height in pixels.
- LMultiplies width by height to get the number of pixels
- LMultiplies by the colour depth to get the size in bits
- LDivides by 8 to get bytes
- LDivides by 1000 to give 921.6 kB
The number of pixels is 640 multiplied by 480, which is 307200. Each pixel needs 24 bits, so the image data is 307200 multiplied by 24, which is 7372800 bits. Dividing by 8 gives 921600 bytes, and dividing by 1000 gives 921.6 kilobytes.
- LColour depth is the number of bits stored for each pixel
- LIncreasing it adds bits to every pixel in the image, not just to some
- LSo the total number of bits, and therefore the file size, increases in proportion
Colour depth is the number of bits used to store the colour of each individual pixel. Increasing the colour depth therefore adds those extra bits to every single pixel in the image rather than to the file as a whole, so an image containing two million pixels gains two million extra bits for each extra bit of colour depth. Since the file size is the number of pixels multiplied by the colour depth, raising the depth raises the size in direct proportion.
- LThe pixel data on its own is just a sequence of values
- LThe width and height tell software how the pixels are arranged into a grid
- LThe colour depth tells software how many bits belong to each pixel
Stored on its own, the pixel data is only a long sequence of binary values with nothing to say how they should be arranged. The metadata supplies that missing information. The width tells the software where one row of pixels ends and the next begins, which is what turns the sequence back into a rectangle, and the height confirms how many rows there should be. The colour depth tells the software how many bits belong to each pixel, without which it cannot divide the sequence into pixels at all. Without metadata the same file could be read as a completely different picture.