Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Page 2 of 2 FirstFirst 12
Results 11 to 14 of 14

Thread: Error Reading File BMP File Size ?

  1. #11
    Senior Member OpenGL Pro
    Join Date
    Feb 2000
    Location
    France
    Posts
    1,118

    Re: Error Reading File BMP File Size ?

    Originally posted by dslater:
    Anyway, I believe the correct way to read and write the BMP structures is to do it a member at a time to avoid alignment problems.
    Didn't know that so thanks a lot for this post: that's spot on and that will avoid headaches if I ever have such a problem !

    Regards.

    Eric

  2. #12
    Intern Newbie
    Join Date
    Jan 2002
    Posts
    49

    Re: Error Reading File BMP File Size ?

    Originally posted by dslater:
    I believe the correct way to read and write the BMP structures is to do it a member at a time to avoid alignment problems.
    dslater, ... you're a "G"! I just tried this. It worked like magic!!!

    ThanX

    ________________________________

    Comment
    (For Geeks and Bitmap Phreaks)

    Ever wondered why an unsigned short (bfType) is tested against 'MB' (which looks like a string)? ...

    Well, I did too; for a while, till I disovered that since:

    'M' = 0100 1101
    'B' = 0100 0010

    'BM' is a concatenatation of 'M' and 'B' (as shown below):

    'BM' = 0100 1101 0100 0010 = 19778 = 0x4D42

    (Dont tell me these numbers dont look familair ...)

  3. #13
    Intern Contributor
    Join Date
    Jun 2001
    Posts
    69

    Re: Error Reading File BMP File Size ?

    Originally posted by Olumide:
    Comment
    (For Geeks and Bitmap Phreaks)

    Ever wondered why an unsigned short (bfType) is tested against 'MB' (which looks like a string)? ...

    Well, I did too; for a while, till I disovered that since:

    'M' = 0100 1101
    'B' = 0100 0010

    'BM' is a concatenatation of 'M' and 'B' (as shown below):

    'BM' = 0100 1101 0100 0010 = 19778 = 0x4D42

    (Dont tell me these numbers dont look familair ...)
    in fact it is not a string ("MB"), it's a a 2 byte charachter literal ('MB')

    but this is NOT portable! e.g. try it with MinGW and it will fail, because MinGW compiles this the other way round, so you have to test against 'BM'
    always test against the hex-number (and write a nice comment to explain *g*)
    i learned that the hard way when i changed from borland compiler (what a f*** stupid optimizer) to MinGW and wondered why my image class failed loading a simple BMP...

  4. #14
    Intern Newbie
    Join Date
    Jan 2002
    Posts
    49

    Re: Error Reading File BMP File Size ?

    Hi Tron

    I see your point. But mind you my statement about 'MB' was that it "..looks like a string" - I never said it was! (Surely a string cannot be compared to an integral type variable ?!?)

    I say, these "character literal" thingies; arent they also called "multibyte characters" ?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •