aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders')
-rw-r--r--OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/BMP.cs14
-rw-r--r--OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/GIF.cs14
-rw-r--r--OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/GenericSystemDrawing.cs43
-rw-r--r--OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/JPEG.cs18
-rw-r--r--OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/LLRAW.cs41
-rw-r--r--OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/PNG.cs14
-rw-r--r--OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/RAW32.cs44
-rw-r--r--OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/TIFF.cs14
-rw-r--r--OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/Terragen.cs21
9 files changed, 179 insertions, 44 deletions
diff --git a/OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/BMP.cs b/OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/BMP.cs
index 98d69a5..34bbf78 100644
--- a/OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/BMP.cs
+++ b/OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/BMP.cs
@@ -24,8 +24,10 @@
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */ 26 */
27
27using System.Drawing; 28using System.Drawing;
28using System.Drawing.Imaging; 29using System.Drawing.Imaging;
30using System.IO;
29using OpenSim.Region.Environment.Interfaces; 31using OpenSim.Region.Environment.Interfaces;
30 32
31namespace OpenSim.Region.Environment.Modules.World.Terrain.FileLoaders 33namespace OpenSim.Region.Environment.Modules.World.Terrain.FileLoaders
@@ -49,6 +51,18 @@ namespace OpenSim.Region.Environment.Modules.World.Terrain.FileLoaders
49 51
50 colours.Save(filename, ImageFormat.Bmp); 52 colours.Save(filename, ImageFormat.Bmp);
51 } 53 }
54
55 /// <summary>
56 /// Exports a stream using a System.Drawing exporter.
57 /// </summary>
58 /// <param name="stream">The target stream</param>
59 /// <param name="map">The terrain channel being saved</param>
60 public override void SaveStream(Stream stream, ITerrainChannel map)
61 {
62 Bitmap colours = CreateGrayscaleBitmapFromMap(map);
63
64 colours.Save(stream, ImageFormat.Png);
65 }
52 66
53 /// <summary> 67 /// <summary>
54 /// The human readable version of the file format(s) this loader handles 68 /// The human readable version of the file format(s) this loader handles
diff --git a/OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/GIF.cs b/OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/GIF.cs
index 9bfe851..0cd9000 100644
--- a/OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/GIF.cs
+++ b/OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/GIF.cs
@@ -24,8 +24,10 @@
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */ 26 */
27
27using System.Drawing; 28using System.Drawing;
28using System.Drawing.Imaging; 29using System.Drawing.Imaging;
30using System.IO;
29using OpenSim.Region.Environment.Interfaces; 31using OpenSim.Region.Environment.Interfaces;
30 32
31namespace OpenSim.Region.Environment.Modules.World.Terrain.FileLoaders 33namespace OpenSim.Region.Environment.Modules.World.Terrain.FileLoaders
@@ -38,6 +40,18 @@ namespace OpenSim.Region.Environment.Modules.World.Terrain.FileLoaders
38 40
39 colours.Save(filename, ImageFormat.Gif); 41 colours.Save(filename, ImageFormat.Gif);
40 } 42 }
43
44 /// <summary>
45 /// Exports a stream using a System.Drawing exporter.
46 /// </summary>
47 /// <param name="stream">The target stream</param>
48 /// <param name="map">The terrain channel being saved</param>
49 public override void SaveStream(Stream stream, ITerrainChannel map)
50 {
51 Bitmap colours = CreateGrayscaleBitmapFromMap(map);
52
53 colours.Save(stream, ImageFormat.Gif);
54 }
41 55
42 public override string ToString() 56 public override string ToString()
43 { 57 {
diff --git a/OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/GenericSystemDrawing.cs b/OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/GenericSystemDrawing.cs
index f87d3ee..4d213e0 100644
--- a/OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/GenericSystemDrawing.cs
+++ b/OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/GenericSystemDrawing.cs
@@ -28,6 +28,7 @@
28using System; 28using System;
29using System.Drawing; 29using System.Drawing;
30using System.Drawing.Imaging; 30using System.Drawing.Imaging;
31using System.IO;
31using OpenSim.Region.Environment.Interfaces; 32using OpenSim.Region.Environment.Interfaces;
32 33
33namespace OpenSim.Region.Environment.Modules.World.Terrain.FileLoaders 34namespace OpenSim.Region.Environment.Modules.World.Terrain.FileLoaders
@@ -57,26 +58,34 @@ namespace OpenSim.Region.Environment.Modules.World.Terrain.FileLoaders
57 /// <returns>A terrain channel generated from the image.</returns> 58 /// <returns>A terrain channel generated from the image.</returns>
58 public virtual ITerrainChannel LoadFile(string filename) 59 public virtual ITerrainChannel LoadFile(string filename)
59 { 60 {
60 Bitmap file = new Bitmap(filename); 61 return LoadBitmap(new Bitmap(filename));
62 }
61 63
62 ITerrainChannel retval = new TerrainChannel(file.Width, file.Height); 64 public ITerrainChannel LoadFile(string filename, int x, int y, int fileWidth, int fileHeight, int w, int h)
65 {
66 throw new NotImplementedException();
67 }
68
69 public virtual ITerrainChannel LoadStream(Stream stream)
70 {
71 return LoadBitmap(new Bitmap(stream));
72 }
73
74 protected virtual ITerrainChannel LoadBitmap(Bitmap bitmap)
75 {
76 ITerrainChannel retval = new TerrainChannel(bitmap.Width, bitmap.Height);
63 77
64 int x; 78 int x;
65 for (x = 0; x < file.Width; x++) 79 for (x = 0; x < bitmap.Width; x++)
66 { 80 {
67 int y; 81 int y;
68 for (y = 0; y < file.Height; y++) 82 for (y = 0; y < bitmap.Height; y++)
69 { 83 {
70 retval[x, y] = file.GetPixel(x, file.Height - y - 1).GetBrightness() * 128; 84 retval[x, y] = bitmap.GetPixel(x, bitmap.Height - y - 1).GetBrightness() * 128;
71 } 85 }
72 } 86 }
73 87
74 return retval; 88 return retval;
75 }
76
77 public ITerrainChannel LoadFile(string filename, int x, int y, int fileWidth, int fileHeight, int w, int h)
78 {
79 throw new NotImplementedException();
80 } 89 }
81 90
82 /// <summary> 91 /// <summary>
@@ -90,6 +99,18 @@ namespace OpenSim.Region.Environment.Modules.World.Terrain.FileLoaders
90 99
91 colours.Save(filename, ImageFormat.Png); 100 colours.Save(filename, ImageFormat.Png);
92 } 101 }
102
103 /// <summary>
104 /// Exports a stream using a System.Drawing exporter.
105 /// </summary>
106 /// <param name="stream">The target stream</param>
107 /// <param name="map">The terrain channel being saved</param>
108 public virtual void SaveStream(Stream stream, ITerrainChannel map)
109 {
110 Bitmap colours = CreateGrayscaleBitmapFromMap(map);
111
112 colours.Save(stream, ImageFormat.Png);
113 }
93 114
94 #endregion 115 #endregion
95 116
diff --git a/OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/JPEG.cs b/OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/JPEG.cs
index 628c201..9886b81 100644
--- a/OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/JPEG.cs
+++ b/OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/JPEG.cs
@@ -28,6 +28,7 @@
28using System; 28using System;
29using System.Drawing; 29using System.Drawing;
30using System.Drawing.Imaging; 30using System.Drawing.Imaging;
31using System.IO;
31using OpenSim.Region.Environment.Interfaces; 32using OpenSim.Region.Environment.Interfaces;
32 33
33namespace OpenSim.Region.Environment.Modules.World.Terrain.FileLoaders 34namespace OpenSim.Region.Environment.Modules.World.Terrain.FileLoaders
@@ -50,6 +51,11 @@ namespace OpenSim.Region.Environment.Modules.World.Terrain.FileLoaders
50 { 51 {
51 throw new NotImplementedException(); 52 throw new NotImplementedException();
52 } 53 }
54
55 public ITerrainChannel LoadStream(Stream stream)
56 {
57 throw new NotImplementedException();
58 }
53 59
54 public void SaveFile(string filename, ITerrainChannel map) 60 public void SaveFile(string filename, ITerrainChannel map)
55 { 61 {
@@ -57,6 +63,18 @@ namespace OpenSim.Region.Environment.Modules.World.Terrain.FileLoaders
57 63
58 colours.Save(filename, ImageFormat.Jpeg); 64 colours.Save(filename, ImageFormat.Jpeg);
59 } 65 }
66
67 /// <summary>
68 /// Exports a stream using a System.Drawing exporter.
69 /// </summary>
70 /// <param name="stream">The target stream</param>
71 /// <param name="map">The terrain channel being saved</param>
72 public void SaveStream(Stream stream, ITerrainChannel map)
73 {
74 Bitmap colours = CreateBitmapFromMap(map);
75
76 colours.Save(stream, ImageFormat.Jpeg);
77 }
60 78
61 #endregion 79 #endregion
62 80
diff --git a/OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/LLRAW.cs b/OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/LLRAW.cs
index 85afaf8..d8d0648 100644
--- a/OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/LLRAW.cs
+++ b/OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/LLRAW.cs
@@ -71,10 +71,24 @@ namespace OpenSim.Region.Environment.Modules.World.Terrain.FileLoaders
71 71
72 public ITerrainChannel LoadFile(string filename) 72 public ITerrainChannel LoadFile(string filename)
73 { 73 {
74 TerrainChannel retval = new TerrainChannel();
75
76 FileInfo file = new FileInfo(filename); 74 FileInfo file = new FileInfo(filename);
77 FileStream s = file.Open(FileMode.Open, FileAccess.Read); 75 FileStream s = file.Open(FileMode.Open, FileAccess.Read);
76 ITerrainChannel retval = LoadStream(s);
77
78 s.Close();
79
80 return retval;
81 }
82
83 public ITerrainChannel LoadFile(string filename, int x, int y, int fileWidth, int fileHeight, int w, int h)
84 {
85 throw new NotImplementedException();
86 }
87
88 public ITerrainChannel LoadStream(Stream s)
89 {
90 TerrainChannel retval = new TerrainChannel();
91
78 BinaryReader bs = new BinaryReader(s); 92 BinaryReader bs = new BinaryReader(s);
79 int y; 93 int y;
80 for (y = 0; y < retval.Height; y++) 94 for (y = 0; y < retval.Height; y++)
@@ -87,21 +101,22 @@ namespace OpenSim.Region.Environment.Modules.World.Terrain.FileLoaders
87 } 101 }
88 } 102 }
89 103
90 bs.Close(); 104 bs.Close();
91 s.Close(); 105
92
93 return retval; 106 return retval;
94 } 107 }
95 108
96 public ITerrainChannel LoadFile(string filename, int x, int y, int fileWidth, int fileHeight, int w, int h)
97 {
98 throw new NotImplementedException();
99 }
100
101 public void SaveFile(string filename, ITerrainChannel map) 109 public void SaveFile(string filename, ITerrainChannel map)
102 { 110 {
103 FileInfo file = new FileInfo(filename); 111 FileInfo file = new FileInfo(filename);
104 FileStream s = file.Open(FileMode.CreateNew, FileAccess.Write); 112 FileStream s = file.Open(FileMode.CreateNew, FileAccess.Write);
113 SaveStream(s, map);
114
115 s.Close();
116 }
117
118 public void SaveStream(Stream s, ITerrainChannel map)
119 {
105 BinaryWriter binStream = new BinaryWriter(s); 120 BinaryWriter binStream = new BinaryWriter(s);
106 121
107 // Output the calculated raw 122 // Output the calculated raw
@@ -150,11 +165,9 @@ namespace OpenSim.Region.Environment.Modules.World.Terrain.FileLoaders
150 } 165 }
151 } 166 }
152 167
153 binStream.Close(); 168 binStream.Close();
154 s.Close();
155 } 169 }
156 170
157
158 public string FileExtension 171 public string FileExtension
159 { 172 {
160 get { return ".raw"; } 173 get { return ".raw"; }
diff --git a/OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/PNG.cs b/OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/PNG.cs
index b893f70..cf95486 100644
--- a/OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/PNG.cs
+++ b/OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/PNG.cs
@@ -24,8 +24,10 @@
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */ 26 */
27
27using System.Drawing; 28using System.Drawing;
28using System.Drawing.Imaging; 29using System.Drawing.Imaging;
30using System.IO;
29using OpenSim.Region.Environment.Interfaces; 31using OpenSim.Region.Environment.Interfaces;
30 32
31namespace OpenSim.Region.Environment.Modules.World.Terrain.FileLoaders 33namespace OpenSim.Region.Environment.Modules.World.Terrain.FileLoaders
@@ -38,6 +40,18 @@ namespace OpenSim.Region.Environment.Modules.World.Terrain.FileLoaders
38 40
39 colours.Save(filename, ImageFormat.Png); 41 colours.Save(filename, ImageFormat.Png);
40 } 42 }
43
44 /// <summary>
45 /// Exports a stream using a System.Drawing exporter.
46 /// </summary>
47 /// <param name="stream">The target stream</param>
48 /// <param name="map">The terrain channel being saved</param>
49 public override void SaveStream(Stream stream, ITerrainChannel map)
50 {
51 Bitmap colours = CreateGrayscaleBitmapFromMap(map);
52
53 colours.Save(stream, ImageFormat.Png);
54 }
41 55
42 public override string ToString() 56 public override string ToString()
43 { 57 {
diff --git a/OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/RAW32.cs b/OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/RAW32.cs
index 689abcf..bb8b0f7 100644
--- a/OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/RAW32.cs
+++ b/OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/RAW32.cs
@@ -41,22 +41,10 @@ namespace OpenSim.Region.Environment.Modules.World.Terrain.FileLoaders
41 41
42 public ITerrainChannel LoadFile(string filename) 42 public ITerrainChannel LoadFile(string filename)
43 { 43 {
44 TerrainChannel retval = new TerrainChannel();
45
46 FileInfo file = new FileInfo(filename); 44 FileInfo file = new FileInfo(filename);
47 FileStream s = file.Open(FileMode.Open, FileAccess.Read); 45 FileStream s = file.Open(FileMode.Open, FileAccess.Read);
48 BinaryReader bs = new BinaryReader(s); 46 ITerrainChannel retval = LoadStream(s);
49 int y;
50 for (y = 0; y < retval.Height; y++)
51 {
52 int x;
53 for (x = 0; x < retval.Width; x++)
54 {
55 retval[x, y] = bs.ReadSingle();
56 }
57 }
58 47
59 bs.Close();
60 s.Close(); 48 s.Close();
61 49
62 return retval; 50 return retval;
@@ -124,11 +112,38 @@ namespace OpenSim.Region.Environment.Modules.World.Terrain.FileLoaders
124 112
125 return retval; 113 return retval;
126 } 114 }
115
116 public ITerrainChannel LoadStream(Stream s)
117 {
118 TerrainChannel retval = new TerrainChannel();
119
120 BinaryReader bs = new BinaryReader(s);
121 int y;
122 for (y = 0; y < retval.Height; y++)
123 {
124 int x;
125 for (x = 0; x < retval.Width; x++)
126 {
127 retval[x, y] = bs.ReadSingle();
128 }
129 }
127 130
131 bs.Close();
132
133 return retval;
134 }
135
128 public void SaveFile(string filename, ITerrainChannel map) 136 public void SaveFile(string filename, ITerrainChannel map)
129 { 137 {
130 FileInfo file = new FileInfo(filename); 138 FileInfo file = new FileInfo(filename);
131 FileStream s = file.Open(FileMode.Create, FileAccess.Write); 139 FileStream s = file.Open(FileMode.Create, FileAccess.Write);
140 SaveStream(s, map);
141
142 s.Close();
143 }
144
145 public void SaveStream(Stream s, ITerrainChannel map)
146 {
132 BinaryWriter bs = new BinaryWriter(s); 147 BinaryWriter bs = new BinaryWriter(s);
133 148
134 int y; 149 int y;
@@ -141,8 +156,7 @@ namespace OpenSim.Region.Environment.Modules.World.Terrain.FileLoaders
141 } 156 }
142 } 157 }
143 158
144 bs.Close(); 159 bs.Close();
145 s.Close();
146 } 160 }
147 161
148 #endregion 162 #endregion
diff --git a/OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/TIFF.cs b/OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/TIFF.cs
index c081aea..3f98f40 100644
--- a/OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/TIFF.cs
+++ b/OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/TIFF.cs
@@ -24,8 +24,10 @@
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */ 26 */
27
27using System.Drawing; 28using System.Drawing;
28using System.Drawing.Imaging; 29using System.Drawing.Imaging;
30using System.IO;
29using OpenSim.Region.Environment.Interfaces; 31using OpenSim.Region.Environment.Interfaces;
30 32
31namespace OpenSim.Region.Environment.Modules.World.Terrain.FileLoaders 33namespace OpenSim.Region.Environment.Modules.World.Terrain.FileLoaders
@@ -38,6 +40,18 @@ namespace OpenSim.Region.Environment.Modules.World.Terrain.FileLoaders
38 40
39 colours.Save(filename, ImageFormat.Tiff); 41 colours.Save(filename, ImageFormat.Tiff);
40 } 42 }
43
44 /// <summary>
45 /// Exports a stream using a System.Drawing exporter.
46 /// </summary>
47 /// <param name="stream">The target stream</param>
48 /// <param name="map">The terrain channel being saved</param>
49 public override void SaveStream(Stream stream, ITerrainChannel map)
50 {
51 Bitmap colours = CreateGrayscaleBitmapFromMap(map);
52
53 colours.Save(stream, ImageFormat.Tiff);
54 }
41 55
42 public override string ToString() 56 public override string ToString()
43 { 57 {
diff --git a/OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/Terragen.cs b/OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/Terragen.cs
index fe36cf7..5dc2aa5 100644
--- a/OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/Terragen.cs
+++ b/OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/Terragen.cs
@@ -43,10 +43,19 @@ namespace OpenSim.Region.Environment.Modules.World.Terrain.FileLoaders
43 43
44 public ITerrainChannel LoadFile(string filename) 44 public ITerrainChannel LoadFile(string filename)
45 { 45 {
46 TerrainChannel retval = new TerrainChannel();
47
48 FileInfo file = new FileInfo(filename); 46 FileInfo file = new FileInfo(filename);
49 FileStream s = file.Open(FileMode.Open, FileAccess.Read); 47 FileStream s = file.Open(FileMode.Open, FileAccess.Read);
48 ITerrainChannel retval = LoadStream(s);
49
50 s.Close();
51
52 return retval;
53 }
54
55 public ITerrainChannel LoadStream(Stream s)
56 {
57 TerrainChannel retval = new TerrainChannel();
58
50 BinaryReader bs = new BinaryReader(s); 59 BinaryReader bs = new BinaryReader(s);
51 60
52 bool eof = false; 61 bool eof = false;
@@ -98,8 +107,7 @@ namespace OpenSim.Region.Environment.Modules.World.Terrain.FileLoaders
98 } 107 }
99 108
100 bs.Close(); 109 bs.Close();
101 s.Close(); 110
102
103 return retval; 111 return retval;
104 } 112 }
105 113
@@ -107,6 +115,11 @@ namespace OpenSim.Region.Environment.Modules.World.Terrain.FileLoaders
107 { 115 {
108 throw new NotImplementedException(); 116 throw new NotImplementedException();
109 } 117 }
118
119 public void SaveStream(Stream stream, ITerrainChannel map)
120 {
121 throw new NotImplementedException();
122 }
110 123
111 public string FileExtension 124 public string FileExtension
112 { 125 {