AQA GCSE Computer Science (8525), section 3.3.6 (Representing images)
File size calculation
where is the width in pixels, the height in pixels and the colour depth in bits.
To get bytes, divide by 8:
Example 1
An image is 800 × 600 pixels with a colour depth of 24 bits.
- Bits: bits.
- Bytes: bytes.
- Megabytes: MB.
Example 2
An 8 × 8 image with colour depth 1: bits bytes.
Only the number of pixels and the colour depth are used in these calculations.
Converting a bit pattern into a bitmap
Given a pattern and the image width, split it into rows and colour the pixels. With 1 = black and 0 = white, a 4-pixel wide image:
0110 1001 1001 0110
Converting a bitmap into a bit pattern
Read the pixels row by row, left to right, writing a 1 for each black pixel and a 0 for each white one.
Pattern: 1111 1000 1110.
With more colours
If the colour depth is 2 bits, each pixel uses two bits, with 4 possible codes, for example 00 = white, 01 = red, 10 = green, 11 = black. Split the pattern into pairs for each pixel.
Common mistake: forgetting to divide by 8 when the answer is needed in bytes. Also, do not forget to use the colour depth: for a 1-bit image, each pixel is just one bit. Reading the pattern in the wrong order also gives a mirror image.
Exam tip: write out the formula, substitute the numbers, then do each step on its own line. Include the units (bits, bytes) in your answer.
Check yourself
Calculate the file size in bytes of a 100 × 50 image with colour depth 8.
100 × 50 × 8 = 40 000 bits, which is 5000 bytes.
How many bits are needed to store one pixel of a 4-colour image?
2 bits.
What image does the pattern 10 01 (width 2, 1 = black) show?
Two rows: black white on the first row, white black on the second.