View Full Version : Height field

09-15-2004, 11:10 PM
Hi! I have a question about reading height field maps. I'm trying to make a terrain visualisation and put there some buildings, etc.

I found quiet lot code samples how to make triangle strips, but I'm having problems with opening and reading the .bmp file. I'm coding in C++. If you have any good solutions, how to get pixels from file, I would realy appreciate it.

Thanks in advance!

09-16-2004, 02:55 AM
hey piotr, kinda OT, but check this out:

found this with a google for "load a bitmap", page 2 ;)

09-16-2004, 07:49 AM
I'm looking for some method to get the value of pixel color. The .bmp file should be in grey scale, and of course the darker pixel, the higher terrain. I worked out something like this, but it's not working:

void __fastcall TFormMain::SetupTextures()
bitmap = new Graphics::TBitmap; //ladowane tylko raz

for(int i = 0; i < 32; i++)
for(int j = 0; j < 32; j++)
height_field[i][j][0]= float(i)*step;
height_field[i][j][1]= (float)(bitmap->Canvas->Pixels[i][j])[(i*(AREA_SIZE+j)*3];
height_field[i][j][2]= -float(i)*step;

The line with Canvas is wrong, but I don't know how to make it work... :(

09-17-2004, 10:32 AM
Nehe has a source code to load .bmp, .gif and .jpg files with IPICTURE (under Windows).

The code change the color of the pixels in order to convert rbg to rgb.

You can use this example to find the color of a pixel.