Resources | Subject Notes | Computer Science
To perform calculations to estimate the file size for a bitmap image.
Bitmaps are a common way to represent images digitally. They store image data as a grid of pixels, where each pixel has a specific color. The file size of a bitmap image is determined by several factors, primarily the image dimensions and the number of bits used to represent each pixel.
For an uncompressed bitmap image, the file size can be estimated using the following formula:
$$ \text{File Size (bytes)} = \text{Image Width (pixels)} \times \text{Image Height (pixels)} \times \text{Bits per Pixel} $$
The Bits per Pixel depends on the colour depth:
Let's calculate the estimated file size for a grayscale image:
Image Dimensions: 640 pixels wide x 480 pixels high
Colour Depth: 8 bits per pixel (grayscale)
Calculation:
Parameter | Value |
---|---|
Image Width | 640 pixels |
Image Height | 480 pixels |
Bits per Pixel | 8 bits |
$$ \text{File Size} = 640 \times 480 \times 8 = 24,576,000 \text{ bytes} $$
This is approximately 24.58 MB.
When images are compressed, the file size is reduced. The amount of reduction depends on the compression algorithm and the compression ratio. Common compression methods include:
The calculations above provide an estimate for uncompressed images. Real-world file sizes can vary depending on the specific image format, the presence of headers and metadata, and the level of compression used.