Jump to content
  • Advertisement

Archived

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

aker_jus

Getting heightvalues from bitmap

This topic is 5284 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
Advertisement
Ahhh that''s ok, I found it. I used a GraphicsStream and ReadByte() function to fill the height array.


GraphicsWare|RenderTech
http://www.graphicsware.com

3D Graphics & Solutions

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!