From a415615270b3637c2cf82e25756991c86f2ae784 Mon Sep 17 00:00:00 2001 From: Adam Frisby Date: Mon, 4 Jun 2007 11:16:41 +0000 Subject: [PATCH] Added support for bitmap and image loading to libterrain, use "terrain load img filename.ext", the following formats are supported under .NET (unknown under Mono): BMP, GIF, PNG, JPEG, WMF, TGA, TIFF. --- .../TerrainEngine.cs | 24 ++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) 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. ///