bitmap file loading :)

hy there

there are things i dont understand…i read some articles about reading in a bitmap…
and in every article the people have 2 seperate structs

something like this…

typedef struct
{
	unsigned short bfType;
	unsigned int bfSize;
	unsigned short bfReserved1;
	unsigned short bfReserved2;
	unsigned int bfOffBits;

}BITMAPFILEHEADER;

typedef struct
{
	unsigned int biSize;
	unsigned int biWidth;
	unsigned int biHeight;
	unsigned short biPlanes;
	unsigned short biBitCount;
	unsigned int biCompression;
	unsigned int biSizeImage;
	unsigned int biXPelsPerMeter;
	unsigned int biYPelsPerMeter;
	unsigned int biClrUsed;
	unsigned int biClrImportant;
}BITMAPINFOHEADER;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

i got no problem with the structures...i got a problem with reading it in...

most of the writer loading the BITMAPFILEHEADER in one step...why they r able to do this?

cause the "real" size is 14 bytes (3 shorts 2 ints)...but the compiler will resize it to 16 (2 bytes padding due to 4 byte align) and there i see the prob...i read 16 instead of 14 bytes...so why i can do that? the 

r they using 2 byte alignment?

am i wrong in my thinking? 

thx for help

bye

apo

I’m not an expert, but depending on your sytem the size of the int change so it can be 16 or 32 bit long (often now it’s about 32 long). Then when you know the composition of the bmp file you can read directly what you want. I’m not sure to understand your problem…You got difficulties to read the field you want?
You should show your code for a better understanding and a better helping.

no i think about a windows int (4bytes)

i thougt i can get in trouble if i read less/more data into a structure…

bye

apo

sorry i mean if i only got a 14 bytes struct…that will be padded to 16 bytes, i read in 16 bytes…but what is with the two bytes i read to far?

bye

apo