diff options
author | Adam Frisby | 2007-06-04 11:16:41 +0000 |
---|---|---|
committer | Adam Frisby | 2007-06-04 11:16:41 +0000 |
commit | a415615270b3637c2cf82e25756991c86f2ae784 (patch) | |
tree | e6803e421316a3755fe748393bb4dd23a8e357c4 /OpenSim/OpenSim.Terrain.BasicTerrain/TerrainEngine.cs | |
parent | * Added /bin/data (diff) | |
download | opensim-SC_OLD-a415615270b3637c2cf82e25756991c86f2ae784.zip opensim-SC_OLD-a415615270b3637c2cf82e25756991c86f2ae784.tar.gz opensim-SC_OLD-a415615270b3637c2cf82e25756991c86f2ae784.tar.bz2 opensim-SC_OLD-a415615270b3637c2cf82e25756991c86f2ae784.tar.xz |
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.
Diffstat (limited to '')
-rw-r--r-- | OpenSim/OpenSim.Terrain.BasicTerrain/TerrainEngine.cs | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/OpenSim/OpenSim.Terrain.BasicTerrain/TerrainEngine.cs b/OpenSim/OpenSim.Terrain.BasicTerrain/TerrainEngine.cs index 047187a..a018ce8 100644 --- a/OpenSim/OpenSim.Terrain.BasicTerrain/TerrainEngine.cs +++ b/OpenSim/OpenSim.Terrain.BasicTerrain/TerrainEngine.cs | |||
@@ -175,7 +175,7 @@ namespace OpenSim.Terrain | |||
175 | break; | 175 | break; |
176 | 176 | ||
177 | case "img": | 177 | case "img": |
178 | resultText = "Error - IMG mode is presently unsupported."; | 178 | loadFromFileIMG(args[2]); |
179 | return false; | 179 | return false; |
180 | 180 | ||
181 | default: | 181 | default: |
@@ -230,6 +230,28 @@ namespace OpenSim.Terrain | |||
230 | } | 230 | } |
231 | 231 | ||
232 | /// <summary> | 232 | /// <summary> |
233 | /// Loads a file from an image compatible with System.Drawing | ||
234 | /// </summary> | ||
235 | /// <param name="filename">File to load</param> | ||
236 | public void loadFromFileIMG(string filename) | ||
237 | { | ||
238 | System.Drawing.Bitmap bmp = new Bitmap(filename); | ||
239 | |||
240 | if (bmp.Width != heightmap.w && bmp.Height != heightmap.h) | ||
241 | throw new Exception("Wrong image size! Images for this region must be " + heightmap.w.ToString() + " by " + heightmap.h.ToString() + " pixels in dimension"); | ||
242 | |||
243 | int x, y; | ||
244 | |||
245 | for (x = 0; x < w; x++) | ||
246 | { | ||
247 | for (y = 0; y < h; y++) | ||
248 | { | ||
249 | Color c = bmp.GetPixel(x, y); | ||
250 | } | ||
251 | } | ||
252 | } | ||
253 | |||
254 | /// <summary> | ||
233 | /// Loads a file consisting of 256x256 doubles and imports it as an array into the map. | 255 | /// Loads a file consisting of 256x256 doubles and imports it as an array into the map. |
234 | /// </summary> | 256 | /// </summary> |
235 | /// <remarks>TODO: Move this to libTerrain itself</remarks> | 257 | /// <remarks>TODO: Move this to libTerrain itself</remarks> |