James Gregory wrote:
> 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.
Relax - padding is on-topic.
> 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).
There must be a graphics library you can use. Start with ImageMagick.
> 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?
Plenty of hardware works best reading integers aligned on quad-word
boundaries. Put another way, the address of a bfSize can evenly divide by 4
with 0 remainder.
The compiler inserted an invisible 16-bit padding element between bfType and
bfSize. Compilers are allowed to do this, and required to give notice how
they do it. It's "implementation specified".
Now ask the documentation or forum that covers your compiler how to turn it
off. They will probably point out a library that already reads BMP files,
too.
--
Phlip
http://www.xpsd.org/cgi-bin/wiki?Tes...UserInterfaces