J
James Gregory
I'm pretty sure this is non-totally-trivial enough and standard-C++ enough
to post here, however much it may initially look like a "how do I make a
computer game?" question, though I may be wrong.
I'm loading a bitmap, and as I'm using Linux I've had to define
BITMAPFILEHEADER myself (maybe better practice would be to give my version
a new name or whatever, I dunno). Windows uses WORDs and DWORDs to
define it, I've used some standard-size types provided by SDL (a
graphics/sound library thing) to define it thus:
struct BITMAPFILEHEADER
{
Uint16 bfType;
Uint32 bfSize;
Uint16 bfReserved1;
Uint16 bfReserved2;
Uint32 bfOffBits;
};
For some reason I utterly can't fathom, however, a debugger shows that my
bitmap loader function believes that sizeof(BITMAPFILEHEADER) == 16.
Surely that should be 14?
I then tried redefining it a couple of times:
BITMAPFILEHEADER
{
Uint32 bfType; //changed from 16 to 32
Uint32 bfSize;
Uint16 bfReserved1;
Uint16 bfReserved2;
Uint32 bfOffBits;
};
This gives sizeof(BITMAPFILEHEADER) == 16, which is now correct.
BITMAPFILEHEADER
{
Uint32 bfType;
Uint32 bfSize;
Uint32 bfReserved1;
Uint32 bfReserved2;
Uint32 bfOffBits;
};
This gives sizeof(BITMAPFILEHEADER) == 20, which is also correct.
Most likely I just misunderstand something somewhere, but I've no idea
what.
Thanks,
James
to post here, however much it may initially look like a "how do I make a
computer game?" question, though I may be wrong.
I'm loading a bitmap, and as I'm using Linux I've had to define
BITMAPFILEHEADER myself (maybe better practice would be to give my version
a new name or whatever, I dunno). Windows uses WORDs and DWORDs to
define it, I've used some standard-size types provided by SDL (a
graphics/sound library thing) to define it thus:
struct BITMAPFILEHEADER
{
Uint16 bfType;
Uint32 bfSize;
Uint16 bfReserved1;
Uint16 bfReserved2;
Uint32 bfOffBits;
};
For some reason I utterly can't fathom, however, a debugger shows that my
bitmap loader function believes that sizeof(BITMAPFILEHEADER) == 16.
Surely that should be 14?
I then tried redefining it a couple of times:
BITMAPFILEHEADER
{
Uint32 bfType; //changed from 16 to 32
Uint32 bfSize;
Uint16 bfReserved1;
Uint16 bfReserved2;
Uint32 bfOffBits;
};
This gives sizeof(BITMAPFILEHEADER) == 16, which is now correct.
BITMAPFILEHEADER
{
Uint32 bfType;
Uint32 bfSize;
Uint32 bfReserved1;
Uint32 bfReserved2;
Uint32 bfOffBits;
};
This gives sizeof(BITMAPFILEHEADER) == 20, which is also correct.
Most likely I just misunderstand something somewhere, but I've no idea
what.
Thanks,
James