Back

File calculations of bitmapped images

Introduction
When you store a bitmap file, you store information about the file (the metadata) in the file header, and then you store all of the information about each pixel in each row. This is called the 'raw file'. You can calculate the size of any bitmapped image if you know the width and height in pixels, and the colour depth in bits.

The formula for the file size in Kilobytes is given by:

WIDTH x HEIGHT x COLOUR DEPTH
---------------------------------------------------------
                  8 x 1024

For example, if an image is 200 pixels by 100 pixels, with a colour depth of 1 bit, then the file size is given by;

200 x 100 x 1
-------------------
   8 x 1024

= 2 Kb

If an image is 500 pixels by 300 pixels, with a colour depth of 8 bit, then the file size is given by;

500 x 300 x 8
-------------------
   8 x 1024

= 146 Kb

The values given above are (close) approximations because a very small amount of space is also used for the file header.

If an image is 600 pixels by 600 pixels, with a colour depth of 24 bit, then the file size is given by;

600 x 600 x 24
-------------------
   8 x 1024

= 1055 Kb = 1 Mb approximately.

The values given above are (close) approximations because a very small amount of space is also used for the file header.

Data compression
As you can see, when you start to use 24 bit colour depth (for high quality photos, for example), the file sizes of raw files start to get very big. This means more storage is needed, and transmission times across networks are relatively high and pictures take a while to appear on web pages. This is why 'data compression' is important. We frequently don't save a file in its raw form. We save it as a JPG, of GIF, for example. These are simply maths formulas that are applied to the raw data to 'squash' the file and make it smaller. They are also known as 'codecs'.

There are various was of compressing a file so that the quality of the picture is not compromised at all and a viewer would probably not even notice it has been done. The different methods are classified either as a 'lossy' compression method or a 'lossless' compression method. Different codecs will also generate different file sizes. This is dealt with in another section.

Back