PDA

View Full Version : Reading image file to an array



bramley1
01-05-2003, 02:37 AM
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

Halcyon
01-06-2003, 08:26 PM
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

Gavin
01-07-2003, 03:27 AM
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

Halcyon
01-07-2003, 03:08 PM
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

Allan Walton
01-08-2003, 04:52 AM
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