Results 1 to 10 of 10

Thread: BMP File Format Help!

  1. #1
    Senior Member Regular Contributor
    Join Date
    Nov 2000
    Location
    Sydney, NSW, Australia
    Posts
    426

    BMP File Format Help!

    I am trying to create a heightmap program that loads BMP greyscale images. But the values seem all screwed up. a white pixel is -1.0, a black one is 0.0, some grey ones are < -1.0 some are > 0.0, please help!
    :: Sleep is a poor substitute for caffeine ::

  2. #2
    Senior Member OpenGL Guru
    Join Date
    Mar 2001
    Posts
    3,574

    Re: BMP File Format Help!

    Remember, colors are usually stored as unsigned bytes. That's pretty much the only way you'd be getting -1 out of a bitmap file.

  3. #3
    Senior Member Regular Contributor
    Join Date
    Nov 2000
    Location
    Sydney, NSW, Australia
    Posts
    426

    Re: BMP File Format Help!

    Sorry, i dont understand... I have something like
    float height = image->data[whatever]
    whatever is the pixel i want to access. You are saying i should be using
    unsigned byte height = image->data[whatever]
    instead?
    :: Sleep is a poor substitute for caffeine ::

  4. #4
    Senior Member Regular Contributor
    Join Date
    May 2001
    Location
    Germany, Hannover
    Posts
    160

    Re: BMP File Format Help!

    1st is this a 24bit image, or 256color, then do you read the image by yourself or did you use some funtions from glut etc ???

    if you use 24bit color images, then the greyscale colors would have same rgb values all stored in unsigned byte format !, so you would read: float height= (image->data[nelement * 3] / 12 -1.0f;

    then you get from the blue component( bmp= BGR) a value betwen -1 an 1 ...
    the f of "-1.0f" is to cast the type into float ...

    if you use 256color bmps then you have to readin the colortable and then do like:
    float height= colortable[image->data[nelement]] ...

    [This message has been edited by T2k (edited 06-14-2001).]

  5. #5
    Senior Member Regular Contributor
    Join Date
    Nov 2000
    Location
    Sydney, NSW, Australia
    Posts
    426

    Re: BMP File Format Help!

    Its a 24bit Bitmap, I will try your method, thanks.
    :: Sleep is a poor substitute for caffeine ::

  6. #6
    Junior Member Newbie
    Join Date
    Jun 2001
    Posts
    10

    Re: BMP File Format Help!

    Perhaps this link might help:
    http://www.dcs.ed.ac.uk/home/mxr/gfx/2d-hi.html

    The page is a list of links pertaining to info on most of the popular graphics formats.

  7. #7
    Member Newbie
    Join Date
    Jun 2001
    Location
    Gary, IN, United States of America
    Posts
    35

    Re: BMP File Format Help!

    Who uses BMP's? They are way too large, which equals way too slow.
    :-} {-:

  8. #8
    Senior Member Regular Contributor
    Join Date
    Nov 2000
    Location
    Sydney, NSW, Australia
    Posts
    426

    Re: BMP File Format Help!

    BMPs have the best image quality of any image file (i think)... far better than TGAs at least.
    :: Sleep is a poor substitute for caffeine ::

  9. #9
    Senior Member OpenGL Pro
    Join Date
    Oct 2000
    Location
    Fargo, ND
    Posts
    1,753

    Re: BMP File Format Help!

    I don't see how a BMP files image quality can be any better than TGA. Neither of them use a lossy compression like JPG so they are perfectly capable of storing the same RGB data and a TGA has the additional option of storing an Alpha channel.

    So far as "way too large" == "way too slow", that's not necessarily true. BMP files are big because they aren't compressed. JPG files are smaller because they are compressed, but it takes time to uncompress them. It doesn't take any time at all to uncompress a BMP since there is no compression.
    Deiussum
    Software Engineer and OpenGL enthusiast

  10. #10
    Member Newbie
    Join Date
    May 2001
    Location
    Hungary
    Posts
    30

    Re: BMP File Format Help!

    Bitmaps are uncompressed. That's why they're so big.

    But you have to use uncompressed images as textures in OpenGL(compressed textures are only compressed when they are already specified), or to draw onto the screen.

    By the way, BMP file format is to be found on MSDN Library CDs. If you don't have one e-mail me.

    By the way if you want to convert 8-bit grayscale to [0.0;1.0] float you should clamp it this way:

    float f=(double)(data[offset])/256.0;

    where data is an unsigned byte array.


    [This message has been edited by kistompika (edited 06-18-2001).]

Similar Threads

  1. txt file 2 NVIDIA scenegraph file format (.nbf)
    By Giancarlo in forum OpenGL: General
    Replies: 1
    Last Post: 07-20-2009, 06:37 PM
  2. Replies: 12
    Last Post: 05-25-2005, 12:42 PM
  3. OT - TGA File format ...
    By Shag in forum OpenGL: Basic Coding
    Replies: 4
    Last Post: 12-19-2001, 12:14 AM
  4. DXF file format
    By anngo in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 08-10-2001, 02:33 AM
  5. Replies: 5
    Last Post: 12-14-2000, 03:19 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean