Images
The file size of a bitmap image is worked out from the number of bits needed to store all of its pixels. You calculate it in bits by multiplying the image's width in pixels by its height in pixels by its colour depth in bits. Width × height gives the number of pixels, so this is the number of pixels multiplied by the bits used for each one. Use the colour depth itself, not the number of colours it allows.
Take an image 400 pixels wide and 250 pixels high with a colour depth of 12 bits. It has 400 × 250 = 100,000 pixels. Each pixel needs 12 bits, so the file size is 100,000 × 12 = 1,200,000 bits. Image size is 400 × 250 pixels; file size is the storage figure in bits or bytes.
Bits are small, so answers are usually converted. Divide by 8 because there are 8 bits in a byte: 1,200,000 ÷ 8 = 150,000 bytes. Divide by 1024 to change bytes to kibibytes: 150,000 ÷ 1024 ≈ 146.5 KiB. Divide by 1024 again for mebibytes: about 0.14 MiB. The divisor is 1024, not 1000, because these units step up in powers of two.
The calculation is often written as a single fraction. For bytes, put width × height × colour depth on top and 8 underneath. For kibibytes, use 8 × 1024 underneath; for mebibytes, use 8 × 1024 × 1024. So the same image in MiB is (400 × 250 × 12) ÷ (8 × 1024 × 1024).
Increasing the resolution, so using more pixels, or increasing the colour depth, so using more bits per pixel, increases the file size. A 500 × 300 image has 150,000 pixels. At 8 bits per pixel it needs 1,200,000 bits, or 150,000 bytes; at 24 bits per pixel it needs 3,600,000 bits, or 450,000 bytes. More pixels or more bits per pixel means more data to store, so the file gets larger.
Edexcel GCSE Computer Science · Images
Edexcel GCSE Computer Science · Units & Conversion