PDA

View Full Version : aux bmp structure



Tim Stirling
02-23-2001, 09:36 AM
I am loading a bitmap with the AUX libary i.e.
AUX_RGBImageRec *image;
image = LoadBMP("grass2.bmp")

What I want is to get the color data from the structure so I can use it load a bitmap to use as a height map. I can't find out any inforamtion on the way the rgb data is stored. Thanks for reading this.
Tim

... Programm long and prosper.

Deiussum
02-23-2001, 10:27 AM
It's stored as, well.. RGB data. http://www.opengl.org/discussion_boards/ubb/smile.gif

For instance, to get the RGB data for a given point in the image you can use a function like so...




void GetColor(AUX_RGBImageRec* pImg, int x, int y, int& r, int& g, int& b)
{
int nIndex = 3*(pImg->sizeX * y + x);

r = pImg->data[nIndex];
g = pImg->data[nIndex+1];
b = pImg->data[nIndex+2];
}


I just wrote that up on the fly and haven't tested it, but it should do what you want.

To get a grayscale value for that you can either average the individual rgb values (the sloppy way) or use the proper rgb->grayscale formula which I don't remember offhand. (It is basically an average, but gives more weight to one of the r,g, or b values.)

Tim Stirling
02-23-2001, 11:55 PM
thanks alot, tim