Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 5 of 5

Thread: Reading image file to an array

  1. #1

    Reading image file to an array

    Hi
    Most of us can read in a texture image file and map it onto a polygon/shape.

    But I want to know how can I read nay image file into an array. So Im able to have access to any (x,) position and its rgb values.

    Thx

  2. #2
    Junior Member Regular Contributor
    Join Date
    Nov 2002
    Location
    Minnesota, US
    Posts
    187

    Re: Reading image file to an array

    Well you could load the picture manually so you would have an array of unsigned ints. Then you would know the image width and height so you could locate your pixel that way. Check out tutorials on loading bitmaps in Win32API or MFC ... which ever you use. There are other good tutorials over the internet. But basically, you have to load them pixel per pixel from the file.

    -Halcyon
    "Programming is an art form that fights back."

    - I forgot who said it!

  3. #3
    Advanced Member Frequent Contributor
    Join Date
    Aug 2000
    Location
    Cardiff University
    Posts
    668

    Re: Reading image file to an array

    loading pixel by pixel? There are many different image file loaders out there. jpeg lib for instance. Source code is available, if you are writing your own then try something simple like tga, rasterfiles or bmp, or pgm

  4. #4
    Junior Member Regular Contributor
    Join Date
    Nov 2002
    Location
    Minnesota, US
    Posts
    187

    Re: Reading image file to an array

    Well, I assumed that bramley1 was loading textures using a library that encapsulates the picture data. So, I was saying that he would have to load in the file himself. By pixel by pixel, i meant organize an array so that each element represents a pixel on the screen.

    - Halcyon
    "Programming is an art form that fights back."

    - I forgot who said it!

  5. #5
    Intern Contributor
    Join Date
    Jun 2001
    Posts
    73

    Re: Reading image file to an array

    You could also load the image in, display it in frame 0, glReadPixels and then clear the image - it's fast enough so you don't notice a flicker...

    Ta.

    Allan

Posting Permissions

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