Calculate bitmap file size
The File Size Formula
Every pixel in a bitmap stores a colour value as a binary number. The total number of bits in the file is therefore the number of pixels multiplied by the bits used per pixel (the colour depth). AQA uses the following formula:
The conversion from bits to bytes is always a division by 8, because there are 8 bits in a byte. You will generally be expected to give your final answer in bytes unless the question specifies otherwise.
Multiply all three inputs to get file size in bits; divide by 8 for bytes.
Worked Examples
Standard Forward Calculation
Calculate the file size of an image 320 × 240 pixels with a colour depth of 4 bits.
- Total pixels: 320 × 240 = 76,800 pixels
- File size in bits: 76,800 × 4 = 307,200 bits
- File size in bytes: 307,200 ÷ 8 = 38,400 bytes
Check: 4-bit colour = 16 colours. Small image, low colour depth - 38.4 kB is a reasonable result.
Large Image - Unit Conversion
Calculate the file size of a 1920 × 1080 pixel image with a colour depth of 24 bits. Express the answer in megabytes (1 MB = 1,000,000 bytes).
- Total pixels: 1920 × 1080 = 2,073,600 pixels
- File size in bits: 2,073,600 × 24 = 49,766,400 bits
- File size in bytes: 49,766,400 ÷ 8 = 6,220,800 bytes
- File size in MB: 6,220,800 ÷ 1,000,000 = 6.22 MB
This is a typical uncompressed Full HD photograph. Real JPEG files are far smaller because compression removes redundant data.
Reverse Calculation - Find Colour Depth
An uncompressed bitmap is 400 × 300 pixels and has a file size of 240,000 bytes. Calculate the colour depth used.
- Total pixels: 400 × 300 = 120,000 pixels
- File size in bits: 240,000 × 8 = 1,920,000 bits
- Colour depth: 1,920,000 ÷ 120,000 = 16 bits per pixel
Rearranging the formula: D = Size(bits) ÷ (W × H). Always convert bytes to bits first before dividing by pixel count.
Key Takeaways
- The formula is: Size (bits) = W × H × D; divide by 8 to convert to bytes.
- Always calculate total pixel count (W × H) as the first step, then multiply by colour depth.
- To convert bytes to a larger unit, divide by 1,000 (kB) or 1,000,000 (MB) using decimal prefixes.
- The formula can be rearranged to find any unknown: if file size and dimensions are known, divide to find colour depth.
- When reversing to find colour depth from bytes, always convert the file size to bits first (multiply by 8) before dividing by pixel count.