aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Environment/Modules/Terrain/FileLoaders/GenericSystemDrawing.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/Environment/Modules/Terrain/FileLoaders/GenericSystemDrawing.cs')
-rw-r--r--OpenSim/Region/Environment/Modules/Terrain/FileLoaders/GenericSystemDrawing.cs35
1 files changed, 18 insertions, 17 deletions
diff --git a/OpenSim/Region/Environment/Modules/Terrain/FileLoaders/GenericSystemDrawing.cs b/OpenSim/Region/Environment/Modules/Terrain/FileLoaders/GenericSystemDrawing.cs
index 9bcf94d..47e0e4cb 100644
--- a/OpenSim/Region/Environment/Modules/Terrain/FileLoaders/GenericSystemDrawing.cs
+++ b/OpenSim/Region/Environment/Modules/Terrain/FileLoaders/GenericSystemDrawing.cs
@@ -27,6 +27,7 @@
27 27
28using System; 28using System;
29using System.Drawing; 29using System.Drawing;
30using System.Drawing.Imaging;
30using OpenSim.Region.Environment.Interfaces; 31using OpenSim.Region.Environment.Interfaces;
31 32
32namespace OpenSim.Region.Environment.Modules.Terrain.FileLoaders 33namespace OpenSim.Region.Environment.Modules.Terrain.FileLoaders
@@ -72,6 +73,20 @@ namespace OpenSim.Region.Environment.Modules.Terrain.FileLoaders
72 throw new NotImplementedException(); 73 throw new NotImplementedException();
73 } 74 }
74 75
76 /// <summary>
77 /// Exports a file to a image on the disk using a System.Drawing exporter.
78 /// </summary>
79 /// <param name="filename">The target filename</param>
80 /// <param name="map">The terrain channel being saved</param>
81 public virtual void SaveFile(string filename, ITerrainChannel map)
82 {
83 Bitmap colours = CreateGrayscaleBitmapFromMap(map);
84
85 colours.Save(filename, ImageFormat.Png);
86 }
87
88 #endregion
89
75 public override string ToString() 90 public override string ToString()
76 { 91 {
77 return "SYS.DRAWING"; 92 return "SYS.DRAWING";
@@ -100,7 +115,7 @@ namespace OpenSim.Region.Environment.Modules.Terrain.FileLoaders
100 for (int x = 0; x < map.Width; x++) 115 for (int x = 0; x < map.Width; x++)
101 { 116 {
102 // 512 is the largest possible height before colours clamp 117 // 512 is the largest possible height before colours clamp
103 int colorindex = (int)(Math.Max(Math.Min(1.0, map[x, y] / 128.0), 0.0) * (pallete - 1)); 118 int colorindex = (int) (Math.Max(Math.Min(1.0, map[x, y] / 128.0), 0.0) * (pallete - 1));
104 119
105 // Handle error conditions 120 // Handle error conditions
106 if (colorindex > pallete - 1 || colorindex < 0) 121 if (colorindex > pallete - 1 || colorindex < 0)
@@ -137,7 +152,7 @@ namespace OpenSim.Region.Environment.Modules.Terrain.FileLoaders
137 for (int x = 0; x < map.Width; x++) 152 for (int x = 0; x < map.Width; x++)
138 { 153 {
139 // 512 is the largest possible height before colours clamp 154 // 512 is the largest possible height before colours clamp
140 int colorindex = (int)(Math.Max(Math.Min(1.0, map[x, y] / 512.0), 0.0) * (pallete - 1)); 155 int colorindex = (int) (Math.Max(Math.Min(1.0, map[x, y] / 512.0), 0.0) * (pallete - 1));
141 156
142 // Handle error conditions 157 // Handle error conditions
143 if (colorindex > pallete - 1 || colorindex < 0) 158 if (colorindex > pallete - 1 || colorindex < 0)
@@ -148,19 +163,5 @@ namespace OpenSim.Region.Environment.Modules.Terrain.FileLoaders
148 } 163 }
149 return bmp; 164 return bmp;
150 } 165 }
151
152 /// <summary>
153 /// Exports a file to a image on the disk using a System.Drawing exporter.
154 /// </summary>
155 /// <param name="filename">The target filename</param>
156 /// <param name="map">The terrain channel being saved</param>
157 public virtual void SaveFile(string filename, ITerrainChannel map)
158 {
159 Bitmap colours = CreateGrayscaleBitmapFromMap(map);
160
161 colours.Save(filename, System.Drawing.Imaging.ImageFormat.Png);
162 }
163
164 #endregion
165 } 166 }
166} 167} \ No newline at end of file