Images
Pixels
A bitmap image is a grid of tiny squares called pixels (short for picture elements). Each pixel is one colour, and that colour is stored as a binary code.
In a black-and-white image, each pixel needs just 1 bit: say 1 for black and 0 for white. This 5 × 5 image of the letter T is stored row by row:
| 1 | 1 | 1 | 1 | 1 |
| 0 | 0 | 1 | 0 | 0 |
| 0 | 0 | 1 | 0 | 0 |
| 0 | 0 | 1 | 0 | 0 |
| 0 | 0 | 1 | 0 | 0 |
The computer reads the codes back in order to rebuild the picture.
Key terms
Colour depth and resolution
Colour depth is the number of bits per pixel. With n bits, each pixel can be one of 2ⁿ colours:
| Colour depth | Number of colours |
|---|---|
| 1 bit | 2 |
| 8 bits | 256 |
| 24 bits | 16,777,216 (about 16.7 million) |
Resolution is the number of pixels in the image, given as width × height, such as 1,920 × 1,080.
| Increase the... | Effect on quality | Effect on file size |
|---|---|---|
| Colour depth | More colours, so more realistic colours and smoother shading | Bigger |
| Resolution | More pixels, so more detail; less blocky (pixelated) when enlarged | Bigger |
Key terms
Metadata
An image file also stores metadata: data about the image. It includes its width, height and colour depth, which the computer needs to rebuild the image: without the width, it wouldn't know where each row of pixels ends.
Metadata can also include the date the photo was taken, the camera used, and the location. Metadata makes the file a little bigger.
Key terms
Image file size
image file size = colour depth × image height (px) × image width (px)
The answer is in bits.
Example: an image is 200 pixels wide and 100 pixels high, with a colour depth of 8 bits. How big is the file in kilobytes?
- 8 × 100 × 200 = 160,000 bits
- Bits to bytes: 160,000 ÷ 8 = 20,000 bytes
- Bytes to KB: 20,000 ÷ 1,000 = 20 KB
With a colour depth of 16 bits, the file would be twice as big: 40 KB.
Exam tip
The formula gives bits. Read the question carefully for the unit it wants, and convert at the end.