diff --git a/OpenSim/Region/Terrain.BasicTerrain/TerrainEngine.cs b/OpenSim/Region/Terrain.BasicTerrain/TerrainEngine.cs
index 4b9c5d60d7..4976e5d3fa 100644
--- a/OpenSim/Region/Terrain.BasicTerrain/TerrainEngine.cs
+++ b/OpenSim/Region/Terrain.BasicTerrain/TerrainEngine.cs
@@ -400,6 +400,10 @@ namespace OpenSim.Region.Terrain
LoadFromFileF32(args[2], Convert.ToInt32(args[3]), Convert.ToInt32(args[4]),
Convert.ToInt32(args[5]), Convert.ToInt32(args[6]));
break;
+ case "img":
+ LoadFromFileIMG(args[2], Convert.ToInt32(args[3]), Convert.ToInt32(args[4]),
+ Convert.ToInt32(args[5]), Convert.ToInt32(args[6]));
+ break;
default:
resultText = "Unknown or unsupported image or data format";
return false;
@@ -657,6 +661,43 @@ namespace OpenSim.Region.Terrain
tainted++;
}
+ ///
+ /// Loads a larger tiled image across a terrain
+ ///
+ /// Filename to load from (any generic image format should work)
+ /// The dimensions of the image
+ /// The dimensions of the image
+ /// Where sim coords begin for this patch
+ /// Where sim coords begin for this patch
+ public void LoadFromFileIMG(string filename, int dimensionX, int dimensionY, int lowerboundX, int lowerboundY)
+ {
+ int sectionToLoadX = ((this.offsetX - lowerboundX) * this.w);
+ int sectionToLoadY = ((this.offsetY - lowerboundY) * this.h);
+
+ double[,] tempMap = new double[dimensionX, dimensionY];
+
+ System.Drawing.Bitmap lgrBmp = new Bitmap(filename);
+
+ int x, y;
+ for (x = 0; x < dimensionX; x++)
+ {
+ for (y = 0; y < dimensionY; y++)
+ {
+ tempMap[x, y] = (float)lgrBmp.GetPixel(x, y).GetBrightness();
+ }
+ }
+
+ for (y = 0; y < h; y++)
+ {
+ for (x = 0; x < w; x++)
+ {
+ heightmap.Set(x, y, tempMap[x + sectionToLoadX, y + sectionToLoadY]);
+ }
+ }
+
+ tainted++;
+ }
+
///
/// Loads a file formatted in the SL .RAW Format used on the main grid
///