diff --git a/OpenSim/OpenSim.Terrain.BasicTerrain/TerrainEngine.cs b/OpenSim/OpenSim.Terrain.BasicTerrain/TerrainEngine.cs index 047187a7e0..a018ce86df 100644 --- a/OpenSim/OpenSim.Terrain.BasicTerrain/TerrainEngine.cs +++ b/OpenSim/OpenSim.Terrain.BasicTerrain/TerrainEngine.cs @@ -175,7 +175,7 @@ namespace OpenSim.Terrain break; case "img": - resultText = "Error - IMG mode is presently unsupported."; + loadFromFileIMG(args[2]); return false; default: @@ -229,6 +229,28 @@ namespace OpenSim.Terrain tainted++; } + /// + /// Loads a file from an image compatible with System.Drawing + /// + /// File to load + public void loadFromFileIMG(string filename) + { + System.Drawing.Bitmap bmp = new Bitmap(filename); + + if (bmp.Width != heightmap.w && bmp.Height != heightmap.h) + throw new Exception("Wrong image size! Images for this region must be " + heightmap.w.ToString() + " by " + heightmap.h.ToString() + " pixels in dimension"); + + int x, y; + + for (x = 0; x < w; x++) + { + for (y = 0; y < h; y++) + { + Color c = bmp.GetPixel(x, y); + } + } + } + /// /// Loads a file consisting of 256x256 doubles and imports it as an array into the map. ///