Code archives/3D Graphics - Misc/Save terrain as heightmap bmp

This code has been declared by its author to be Public Domain code.

Download source code

Save terrain as heightmap bmp by Per Jonsson2002
Works only when running 32-bit colordepth.
Function SaveTerrainHeightmap(terrainhandle,filename$)
	gridsize=TerrainSize(terrainhandle)
	img=CreateImage(gridsize,gridsize)
	ib=ImageBuffer(img)
	LockBuffer ib
	For x=1 To gridsize
		For y=1 To gridsize
			WritePixel x,gridsize-y-1,Floor(TerrainHeight#(terrainhandle,x,y)*16777215.0),ib
		Next
	Next
	UnlockBuffer ib
	SaveImage(img,filename$)	
End Function

Comments

None.

Code Archives Forum