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

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

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

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

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