Recommended Posts

I'm attempting to generate a procedural texture for my terrain heightmap engine.
I've been following Tobias Franke's tutorial over on flipcode (http://www.flipcode.com/tutorials/tut_proctext.shtml) to get most of this code. However, he uses floats for height values and colour values, and I'm using unsigned bytes (to load RAW images), so I've made my attempt to convert his code over for use in my project. It all seemed to be going fine, until I actually saved out the final image. From the coordinates x (height) = 119, y (width) = 60 (in a 256x128 <height x width> image), the generator just stops working and outputs lines of a single colour for 10 or so rows, and then simply outputs black for the rest of the image.
If anyone can point me in the right direction I'd be most grateful.
Here is the code: (sorry its a bit long)