CS20: Representing Images
How images are stored as bitmap data using pixels, resolution and colour depth, and how these properties affect file size and quality.
How images are stored as bitmap data using pixels, resolution and colour depth, and how these properties affect file size and quality.
Computers store images as numbers. In a bitmap image, the image is divided into a grid of tiny squares called pixels. Each pixel stores a binary number that represents a specific colour. When viewed from a distance, these pixels blend together to form the complete image.
A simple 3x3 black and white image of a cross:
1 0 1
0 1 0
1 0 1
Where 1 = black, 0 = white. This 9-pixel image needs 9 bits of storage (1 bit per pixel).
A pixel is the smallest addressable element of a bitmap image. Each pixel stores colour data as a binary value. The total number of pixels in an image determines its level of detail.
An image with resolution 800 x 600 has 480,000 pixels.
An image with resolution 1920 x 1080 has 2,073,600 pixels.
The higher resolution image contains over 4 times as many pixels and will show much more detail.
The colour depth determines how many different colours can be represented in an image:
| Colour Depth | Bits per Pixel | Number of Colours | Example Use |
|---|---|---|---|
| 1-bit | 1 | 2 (black and white) | Simple icons, fax |
| 8-bit | 8 | 256 | GIF images, early games |
| 16-bit | 16 | 65,536 | High colour displays |
| 24-bit | 24 | 16,777,216 | True colour (photographs) |
| 32-bit | 32 | 4,294,967,296 | True colour + alpha channel |
A 24-bit image uses 8 bits for red, 8 bits for green, and 8 bits for blue (RGB). Each channel can represent 256 shades (0-255), giving 256 x 256 x 256 = 16,777,216 possible colours. This is known as "True Colour" because it is enough colours to represent what the human eye can distinguish.
Calculate the file size of a 1024 x 768 image with 24-bit colour depth.
File size = 1024 x 768 x 24
= 786,432 x 24
= 18,874,368 bits
= 18,874,368 / 8 = 2,359,296 bytes
= 2,359,296 / 1024 = 2,304 KB
= 2,304 / 1024 = 2.25 MB
Calculate the file size of a 640 x 480 image with 8-bit colour depth.
File size = 640 x 480 x 8
= 307,200 x 8
= 2,457,600 bits
= 2,457,600 / 8 = 307,200 bytes
= 307,200 / 1024 = 300 KB
A 2000 x 1500 image uses 16-bit colour depth. How many megabytes is the uncompressed file?
File size = 2000 x 1500 x 16
= 3,000,000 x 16
= 48,000,000 bits
= 48,000,000 / 8 = 6,000,000 bytes
= 6,000,000 / 1024 / 1024 = 5.72 MB
| Change | Effect on File Size | Effect on Quality |
|---|---|---|
| Increase resolution (more pixels) | Increases | Improves (more detail) |
| Decrease resolution (fewer pixels) | Decreases | Degrades (pixelation) |
| Increase colour depth | Increases | Improves (more colours, smoother gradients) |
| Decrease colour depth | Decreases | Degrades (banding, colour steps) |
If you double both the width and the height of an image, the file size quadruples (4x), because the total number of pixels is width x height - doubling both means 2 x 2 = 4 times as many pixels.
Image A: 100 x 100 at 24-bit = 100 x 100 x 24 = 240,000 bits
Image B: 200 x 200 at 24-bit = 200 x 200 x 24 = 960,000 bits
Doubling both dimensions = 4x the file size, not 2x.
Doubling the colour depth doubles the file size, as each pixel now uses twice as many bits.
Image A: 100 x 100 at 8-bit = 100 x 100 x 8 = 80,000 bits
Image B: 100 x 100 at 16-bit = 100 x 100 x 16 = 160,000 bits
Doubling colour depth = 2x the file size.
| Property | Bitmap | Vector |
|---|---|---|
| Made of | Pixels | Geometric shapes (lines, curves) |
| Scaling up | Becomes pixelated/blurred | Stays sharp at any size |
| File size | Large for detailed images | Generally smaller |
| Best for | Photographs | Logos, diagrams, illustrations |
| Editing | Edit individual pixels | Edit properties of shapes |
| Examples | JPEG, PNG, GIF, BMP | SVG, AI |
| Mistake | Why It's Wrong | How to Fix It |
|---|---|---|
| Forgetting to convert bits to bytes | File sizes are usually given in bytes or KB | Always divide by 8 to get bytes first |
| Confusing resolution with image size on screen | Resolution is pixel count, not physical dimensions | Think of resolution as width x height in pixels |
| Saying "doubling resolution doubles file size" | Doubling both dimensions quadruples the pixel count | Remember: 2W x 2H = 4x pixels |
| Forgetting the formula includes colour depth | File size depends on both pixel count and colour depth | Always use: W x H x colour depth |
| Confusing bitmap with vector | They store images in fundamentally different ways | Bitmap = pixels; Vector = mathematical instructions |
Q1: An image has a resolution of 1920 x 1080 and a colour depth of 24 bits. Calculate the file size in megabytes.
Q2: What is the effect on file size if you double the width of an image but keep the height and colour depth the same?
Q3: An image uses 8-bit colour depth. How many different colours can it represent?
Q4: Explain the trade-off between image quality and file size when increasing colour depth.
Q5: A 500 x 400 image has a file size of 1,600,000 bits. What is the colour depth?
โ Thinking higher resolution always means a better image regardless of colour depth โ Image quality depends on BOTH resolution (pixels) and colour depth (bits per pixel). A high-resolution image with 1-bit colour looks worse than a lower-resolution 24-bit colour image.
โ Confusing pixel resolution with image file size โ File size depends on resolution ร colour depth. Two images with the same pixel dimensions can have different file sizes if they use different colour depths.
โ Forgetting that increasing resolution or colour depth increases file size โ Doubling the resolution (width and height) quadruples the number of pixels, and therefore quadruples the file size (assuming same colour depth).
โ Thinking vector images are made of pixels โ Vector images use mathematical descriptions of shapes (coordinates, lines, curves), not pixels. They can be scaled without losing quality, unlike bitmap images.
A bitmap image is 1024 ร 768 pixels with 24-bit colour depth. Calculate the file size in megabytes. If the colour depth is reduced to 8 bits, calculate the new file size and the percentage reduction. [4 marks]
Original file size: Number of pixels = 1024 ร 768 = 786,432 File size in bits = 786,432 ร 24 = 18,874,368 bits File size in bytes = 18,874,368 รท 8 = 2,359,296 bytes File size in MB = 2,359,296 รท (1024 ร 1024) = 2.25 MB Reduced colour depth (8-bit): File size = 786,432 ร 8 รท 8 รท (1024 ร 1024) = 0.75 MB Percentage reduction = (2.25 - 0.75) รท 2.25 ร 100 = 66.7% Reducing colour depth from 24-bit to 8-bit reduces the file size by approximately 66.7%.
AO1 (Computational Thinking โ 40%): Demonstrate knowledge and understanding of the principles and concepts of computer science, including representing images: bitmap and vector graphics for AQA 8525, OCR J277 & Edexcel 1CP2.
AO2 (Application โ 40%): Apply knowledge and understanding of computer science, including representing images: bitmap and vector graphics to analyse problems in computational terms and to design, write and evaluate solutions.
AO3 (Evaluation โ 20%): Evaluate the effectiveness, correctness and efficiency of computational solutions, including representing images: bitmap and vector graphics, and make reasoned judgements about trade-offs.
Get the best revision books and guides to boost your grades.