View Full Version : Reading image file to an array
01-05-2003, 01:37 AM
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.
01-06-2003, 07: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.
01-07-2003, 02: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
01-07-2003, 02: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.
01-08-2003, 03: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...
Powered by vBulletin® Version 4.2.2 Copyright © 2016 vBulletin Solutions, Inc. All rights reserved.