Loading a heightmap

BlitzMax Forums/BlitzMax Beginners Area/Loading a heightmap

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

I was trying to load in a height map, to generate a terrain with it using MiniB3D, but I'm having problems with getting the actualy height from a pixel value.
This is what I have now:
Global world:TPixmap	

Function LoadTerrainFromHeightMap(hmap:String)
	
	'load the heightmap image
	world = LoadPixmap(hmap)
	If Not world Then RuntimeError("can't load heightmap")
	
	'load pixmap dimensions
	ZoneX = world.width
	ZoneZ = world.height
	
	'create the array that will hold the height of the terrain
	Global ZN:Float[zonex, zonez]
	
	'loop trough the whole map, storing the height
	For x:Int = 0 To ZoneX - 1
		For z:Int = 0 To ZoneZ - 1
			
			'read the pixel and store in array
			Local h:Float = ReadPixel(world, x, (ZoneZ - 1) - z)
			h# = Abs(h#)
			ZN#(x, z) = (h#)
			
		Next
	Next

	RuntimeError(ZN#(1,1))
	
End Function

LoadTerrainFromHeightMap("bitmap.bmp")


For testing purpose I used a black bitmap, and it returned the value 16777260, wich is quite weird since I figured a black bitmap should return 0, and a white bitmap should return 16777216 (R*G*B=256^3).

And once I get the right rgb value from my pixelmap, I would have no idea how to get a good value from it that could serve as my Y variable when generating the terrain.

(I allready made the function that generates the terrain, the only problem I'm having is reading the height.)

Could anyone help me out please?

Thanks in advantage.

*edit*
I used a runtimeerror to return the value btw. :P