For this we need to first understand the bmp file format
As illustrated by the figure below:
The bitmap image consists of 3 main parts:
1) Header ( Including the signature and the image info data)
2) Colour Profile
3) Image data
Image source: http://en.wikipedia.org/wiki/BMP_file_format
The header data is of size 54 bytes. This can be observed by adding up the size requirements of the individual entries as written below. Also mentioned is the offset value for individual entries. An interesting observation is that the total size is not a multiple of 4 which might create several problems as in most compilers memory is read in chunks of 4 bytes.
offset size description
0     2      signature, must be 4D42 hex
2     4       size of BMP file in bytes (not very reliable)
6     2       reserved, must be zero
8     2       reserved, must be zero
10    4       offset to start of image data in bytes
14    4       size of BITMAPINFOHEADER structure, must be 40
18    4       image width in pixels
22   4       image height in pixels
26   2       number of planes in the image, must be 1
28   2       number of bits per pixel (1, 4, 8, or 24)
30   4       compression type (0=none, 1=Run Length Encoding (RLE)-8, 2=RLE-4)
34   4       size of image data in bytes (including padding, to make it a multiple of 4)
38   4       horizontal resolution in pixels per meter
42   4       vertical resolution in pixels per meter
46   4       number of colours in image, or zero
50   4       number of important colours, or zero
(To be continued in next post)
As illustrated by the figure below:
The bitmap image consists of 3 main parts:
1) Header ( Including the signature and the image info data)
2) Colour Profile
3) Image data
Image source: http://en.wikipedia.org/wiki/BMP_file_format
The header data is of size 54 bytes. This can be observed by adding up the size requirements of the individual entries as written below. Also mentioned is the offset value for individual entries. An interesting observation is that the total size is not a multiple of 4 which might create several problems as in most compilers memory is read in chunks of 4 bytes.
offset size description
0     2      signature, must be 4D42 hex
2     4       size of BMP file in bytes (not very reliable)
6     2       reserved, must be zero
8     2       reserved, must be zero
10    4       offset to start of image data in bytes
14    4       size of BITMAPINFOHEADER structure, must be 40
18    4       image width in pixels
22   4       image height in pixels
26   2       number of planes in the image, must be 1
28   2       number of bits per pixel (1, 4, 8, or 24)
30   4       compression type (0=none, 1=Run Length Encoding (RLE)-8, 2=RLE-4)
34   4       size of image data in bytes (including padding, to make it a multiple of 4)
38   4       horizontal resolution in pixels per meter
42   4       vertical resolution in pixels per meter
46   4       number of colours in image, or zero
50   4       number of important colours, or zero
(To be continued in next post)