bmp image header doubts

Posted by vikramtheone on Stack Overflow See other posts from Stack Overflow or by vikramtheone
Published on 2010-05-13T00:35:15Z Indexed on 2010/05/13 0:44 UTC
Read the original article Hit count: 329

Filed under:
|
|
|

Hi Guys, I'm doing a project where I have to make use of the pixel information of a bmp image. So, I'm gathering the image information by reading the header information of the input .bmp image.

I'm quite successful with everything but one thing bothers me, can any one here clarify it?

The header information of my .bmp image is as follows (My test image is very tiny and gray scale)-

BMP File header
  File size 1210
  Offset information 1078

BMP Information header
  Image Header Size 40
  Image Size 132
  Image width 9
  Image height 11
  Image bits_p_p 8

So, from the .bmp header I see that the image size is 132 (bytes) but when I multiply the width and height it is only 99, how is such a thing possible?

I'm confident with 132 bytes because when I subtract the Offset value with the File Size value, I get 132(1210 - 1078 = 132) and also when I manually count the number of bytes (In a HEX editor) from the point 1078 or 436h (End of the offset field), there are exactly 132 bytes of pixel information.

So, why is there a disparity between the size filed and the (width x height)?

My future implementations are dependent on the image width and height information and not on Image size information. So, I have to understand thoroughly whats going on here.

My understanding of the header should be clearly wrong... I guess!!!

Help!!!

Regards Vikram


My bmp structures are a as follows -

typedef struct bmpfile_magic {
  short magic;
}BMP_MAGIC_NUMBER;

typedef struct bmpfile_header {
  uint32_t filesz;
  uint16_t creator1;
  uint16_t creator2;
  uint32_t bmp_offset;
}BMP_FILE_HEADER;


typedef struct {
  uint32_t header_sz;
  uint32_t width;
  uint32_t height;
  uint16_t nplanes;
  uint16_t bitspp;
  uint32_t compress_type;
  uint32_t bmp_bytesz;
  uint32_t hres;
  uint32_t vres;
  uint32_t ncolors;
  uint32_t nimpcolors;
} BMP_INFO_HEADER;

© Stack Overflow or respective owner

Related posts about bmp

Related posts about image