private void DrawImage()
{
 _mDem = new DemDocument();
 _mDem.Read("terrain.dem");
 var bitmap = new Bitmap(_mDem.ARecord.northings_rows, _mDem.ARecord.eastings_cols);

 for (int col = 0; col < _mDem.ARecord.eastings_cols; col++)
 {
  for (int row = 0; row < _mDem.ARecord.northings_rows; row++)
  {
   double height = _mDem.BRecord.elevations[col, row] * _mDem.ARecord.xyz_resolution[2];
   var min = _mDem.ARecord.elevation_min;
   var max = _mDem.ARecord.elevation_max;
   if (height >= min)
   {
   	int ratio = (int)(((height - min) / (max - min)) * 255f);
   	bitmap.SetPixel(row, col, Color.FromArgb(128, ratio, 128));
   }
  }
 }

 bitmap.Save("terrain.bmp");
}

Last edited Mar 6, 2012 at 5:06 PM by jakesee, version 2

Comments

jakesee Apr 26, 2012 at 11:54 AM 
Official specification PDF is included in the source and download. You may conveniently refer to the specs and extend functionality in a similar fashion for your own purposes.