Results 1 to 7 of 7

Thread: Reading BMP files

  1. #1
    Junior Member Newbie
    Join Date
    Jan 2001
    Location
    Israel
    Posts
    2

    Reading BMP files

    Is it possible to read a bmp file and to get from it the graylevel value of each pixel using OpenGL?
    Thanks

  2. #2
    Senior Member Regular Contributor
    Join Date
    Sep 2000
    Location
    Italy
    Posts
    124

    Re: Reading BMP files

    Sure! www.wotsit.org and you'll find info & source about all (ALL) the file formats known in the universe.

    You do it in C/C++ and then you can use it in opengl...
    Fuzz

    [This message has been edited by Teofuzz (edited 01-18-2001).]

  3. #3
    Member Contributor
    Join Date
    Dec 2000
    Location
    Kaifeng,He'nan,PRC
    Posts
    69

    Re: Reading BMP files

    graylevel value of each pixel using OpenGL?

    I do not understand what you mean.How to count the socalled graylevel?
    So, A RGB pixel (25,34,77) <---its graylevel value is ???
    ========================
    As an old Chinese saying:One Live a Short while Die a Long...
    If I am useful to this world,I am reasonable to myself.
    =========================

  4. #4
    Senior Member OpenGL Pro
    Join Date
    Dec 2007
    Posts
    1,077

    Re: Reading BMP files

    Well, the brightness of a pixel was somewhat like 0.3*r+0.5*g+0.2*b. Anyway, that were more exact constants in the formula. As you can see, that already represents a value between 0 and 1. There was some graylevel texture format in opengl I think. Anyway, take the brightness and use it a r,g and b in the texture. Will waste a lot of memory but will work...

  5. #5
    Junior Member Newbie
    Join Date
    Jan 2001
    Location
    Muncie, IN, USA
    Posts
    6

    Re: Reading BMP files

    try 0.3 * red + 0.59 * green + 0.11 * blue

  6. #6
    Senior Member Regular Contributor
    Join Date
    Dec 2000
    Location
    Slovak Republic( Slovakia )
    Posts
    110

    Re: Reading BMP files

    Declare pointer on AUX_RGBImageRec.
    The AUX_RGBImageRec is struct of
    |GLint sizeX,sizeY| and |unsigned char *data|.On load bitmap use auxDIBImageLoad.
    For example :
    AUX_RGBImageRec *bmp=auxDIBImageLoad("E:/Stone01.bmp");

    On draw (or as texture)it use glDrawPixels(bmp->sizeX,bmp->sizeY,GL_RGB,GL_UNSIGNED_BYTE,bmp->data)

  7. #7
    Senior Member OpenGL Pro
    Join Date
    Dec 2007
    Posts
    1,077

    Re: Reading BMP files

    That's it spak!

Similar Threads

  1. Reading obj and raw files
    By imported_Rodrigo in forum OpenGL: Basic Coding
    Replies: 7
    Last Post: 08-04-2010, 11:58 AM
  2. Reading Text Files
    By in forum OpenGL: Basic Coding
    Replies: 12
    Last Post: 06-15-2004, 03:28 PM
  3. Reading 3DS files
    By in forum OpenGL: Basic Coding
    Replies: 5
    Last Post: 08-20-2003, 09:39 AM
  4. reading and displaying .PPM files
    By ammir in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 10-02-2001, 10:46 AM
  5. *.x - files reading - please help!
    By TB-Rex in forum OpenGL: Advanced Coding
    Replies: 4
    Last Post: 04-20-2001, 04:30 AM

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