CS With NehalCS With Nehal

Bitmap File Size Simulator

Calculate image file size from resolution and colour depth, with a live preview of how colour depth changes the image.

Image settings

Change the resolution and colour depth. The file size updates instantly.

Colour depth (bits per pixel)

24 bits → 2^24 = 16,777,216 colours

Preview with millions of colours (shown at a reduced resolution). Lower the depth to see banding.

307,200
Pixels
1.7e+7
Colours
7,372,800
Bits
900 KiB
File size

Working

File size = width × height × colour depth (in bits). Divide by 8 for bytes.

  1. 1. Pixels = 640 × 480 = 307,200
  2. 2. Bits = 307,200 × 24 = 7,372,800 bits
  3. 3. Bytes = 7,372,800 ÷ 8 = 921,600 bytes
  4. 4. KiB = 921,600 ÷ 1024 = 900
  5. 5. MiB = ÷ 1024 again = 0.879
Colour depth n bits gives 2ⁿ colours. To store c colours you need ⌈log₂ c⌉ bits: for example 100 colours need 7 bits, because 2⁶ = 64 is too few.
Real files also contain a header (metadata such as width, height and colour depth), so they are a little larger. Exam questions usually ignore it unless they say otherwise.

Same image, different colour depths

DepthColoursFile size
1-bit237.5 KiB
2-bit475 KiB
4-bit16150 KiB
8-bit256300 KiB
16-bit65,536600 KiB
24-bit1.68e+7900 KiB
32-bit4.29e+91.17 MiB

About This Simulation

This bitmap file size simulator calculates how much storage an image needs from its resolution (width × height in pixels) and its colour depth (bits per pixel). It shows every step of the working and a live preview of how fewer bits per pixel reduce the number of colours.

Features

  • Width, height and any colour depth from 1 to 32 bits, with presets from icons to 4K
  • Step-by-step working: pixels, bits, bytes, KiB/kB and MiB/MB
  • Switch between 1024-based (KiB) and 1000-based (kB) units
  • Live preview showing banding at low colour depths
  • Table comparing the same image at every colour depth

Topics covered

  • Bitmap Images
  • Pixels and Resolution
  • Colour Depth
  • File Size Calculation
  • Binary Prefixes (KiB, MiB)

Explanation

A bitmap image is a grid of pixels. Each pixel stores a colour as a binary number, and the number of bits used per pixel is the colour depth. With a colour depth of n bits, 2ⁿ different colours can be shown. The file size depends only on how many pixels there are and how many bits each one uses.

How it works

  1. Count the pixels: width × height. A 640 × 480 image has 307,200 pixels.
  2. Multiply by the colour depth to get the number of bits: 307,200 × 24 = 7,372,800 bits.
  3. Divide by 8 to get bytes: 7,372,800 ÷ 8 = 921,600 bytes.
  4. Divide by 1024 for kibibytes (KiB) and again for mebibytes (MiB), or by 1000 for kilobytes and megabytes if the question uses denary prefixes.
  5. To find the colour depth needed for c colours, use the smallest n where 2ⁿ ≥ c. For 100 colours, 2⁷ = 128, so 7 bits.

Why it matters

File size calculations appear in almost every Cambridge IGCSE and AS Level paper. Understanding the trade-off between image quality (resolution and colour depth) and file size also explains why images are compressed before being sent over the internet.

Frequently Asked Questions

What is the formula for bitmap file size?

File size in bits = width in pixels × height in pixels × colour depth in bits. Divide by 8 for bytes, then by 1024 for KiB.

What is the difference between KB and KiB?

A kilobyte (kB) is 1000 bytes and a kibibyte (KiB) is 1024 bytes. Cambridge syllabuses use KiB, MiB and GiB for the binary (1024) prefixes.

Why is a real image file bigger than my calculation?

Files also store a header with metadata such as the width, height, colour depth and sometimes a colour palette. Exam questions usually ignore this unless they mention it.

How does colour depth affect image quality?

More bits per pixel means more possible colours, so gradients look smoother and colours more accurate. Fewer bits cause visible banding but make the file smaller.

Related Simulations