Archived

This topic is now archived and is closed to further replies.

Getting heightvalues from bitmap

This topic is 4999 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I am making a geomipmapping terrain renderer, but I am having some trouble getting the height values. This is C# btw. This is my loading code:
//Create the heightmap data.

D3D.Surface		HeightSurf;
D3D.ImageInformation HeightInfo = D3D.TextureLoader.ImageInformationFromFile (Heightmap);

D3D.Device	D3DDev = RTKernel.CreatedDevice.Device;
HeightSurf = D3DDev.CreateOffscreenPlainSurface (HeightInfo.Width, HeightInfo.Height,
			D3D.Format.R8G8B8, D3D.Pool.Scratch);
D3D.SurfaceLoader.FromFile (HeightSurf, Heightmap, D3D.Filter.None, 0);


m_Heights = new byte [HeightInfo.Width * HeightInfo.Height * 3];

Array arr = HeightSurf.LockRectangle (typeof(byte), D3D.LockFlags.None, 1);
arr.CopyTo (m_Heights, 0);
HeightSurf.UnlockRectangle();
All the elements in the height array are 0, except the first one which is 65. This is not corresponding to the heightmap I load at all. In c++, I would have a LOCKED_RECT structure passed out from the lockRectangle, and use the pBits to copy the memory to the array. I don''t seem to find such a parameter in MDX though, so I think that the array it returns (or the graphicsstream class), contains the image data, but it doesn''t work that way it seems. GraphicsWare|RenderTech http://www.graphicsware.com 3D Graphics & Solutions

Share this post


Link to post
Share on other sites