Height field

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!

hey piotr, kinda OT, but check this out:

found this with a google for “load a bitmap”, page 2 :wink:

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… :frowning:

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.