diff options
author | Jeff Ames | 2008-05-01 14:31:30 +0000 |
---|---|---|
committer | Jeff Ames | 2008-05-01 14:31:30 +0000 |
commit | d51ce47b2d7635b17f3dd429158e8f59b78b83aa (patch) | |
tree | d3595bd5194199184059aa398b91a51dc6c799cf /OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders | |
parent | * Looks like I had the bamboo build right in the first place - it was just th... (diff) | |
download | opensim-SC_OLD-d51ce47b2d7635b17f3dd429158e8f59b78b83aa.zip opensim-SC_OLD-d51ce47b2d7635b17f3dd429158e8f59b78b83aa.tar.gz opensim-SC_OLD-d51ce47b2d7635b17f3dd429158e8f59b78b83aa.tar.bz2 opensim-SC_OLD-d51ce47b2d7635b17f3dd429158e8f59b78b83aa.tar.xz |
Update svn properties. Minor formatting cleanup.
Diffstat (limited to 'OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders')
9 files changed, 888 insertions, 888 deletions
diff --git a/OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/BMP.cs b/OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/BMP.cs index 4705dad..eb981d9 100644 --- a/OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/BMP.cs +++ b/OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/BMP.cs | |||
@@ -1,62 +1,62 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) Contributors, http://opensimulator.org/ | 2 | * Copyright (c) Contributors, http://opensimulator.org/ |
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | 3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. |
4 | * | 4 | * |
5 | * Redistribution and use in source and binary forms, with or without | 5 | * Redistribution and use in source and binary forms, with or without |
6 | * modification, are permitted provided that the following conditions are met: | 6 | * modification, are permitted provided that the following conditions are met: |
7 | * * Redistributions of source code must retain the above copyright | 7 | * * Redistributions of source code must retain the above copyright |
8 | * notice, this list of conditions and the following disclaimer. | 8 | * notice, this list of conditions and the following disclaimer. |
9 | * * Redistributions in binary form must reproduce the above copyright | 9 | * * Redistributions in binary form must reproduce the above copyright |
10 | * notice, this list of conditions and the following disclaimer in the | 10 | * notice, this list of conditions and the following disclaimer in the |
11 | * documentation and/or other materials provided with the distribution. | 11 | * documentation and/or other materials provided with the distribution. |
12 | * * Neither the name of the OpenSim Project nor the | 12 | * * Neither the name of the OpenSim Project nor the |
13 | * names of its contributors may be used to endorse or promote products | 13 | * names of its contributors may be used to endorse or promote products |
14 | * derived from this software without specific prior written permission. | 14 | * derived from this software without specific prior written permission. |
15 | * | 15 | * |
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | 16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY |
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | 17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | 19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY |
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
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 | using System.Drawing; | 27 | using System.Drawing; |
28 | using System.Drawing.Imaging; | 28 | using System.Drawing.Imaging; |
29 | using OpenSim.Region.Environment.Interfaces; | 29 | using OpenSim.Region.Environment.Interfaces; |
30 | 30 | ||
31 | namespace OpenSim.Region.Environment.Modules.World.Terrain.FileLoaders | 31 | namespace OpenSim.Region.Environment.Modules.World.Terrain.FileLoaders |
32 | { | 32 | { |
33 | /// <summary> | 33 | /// <summary> |
34 | /// A generic windows bitmap loader. | 34 | /// A generic windows bitmap loader. |
35 | /// Should be capable of handling 24-bit RGB images. | 35 | /// Should be capable of handling 24-bit RGB images. |
36 | /// | 36 | /// |
37 | /// Uses the System.Drawing filesystem loader. | 37 | /// Uses the System.Drawing filesystem loader. |
38 | /// </summary> | 38 | /// </summary> |
39 | internal class BMP : GenericSystemDrawing | 39 | internal class BMP : GenericSystemDrawing |
40 | { | 40 | { |
41 | /// <summary> | 41 | /// <summary> |
42 | /// Exports a file to a image on the disk using a System.Drawing exporter. | 42 | /// Exports a file to a image on the disk using a System.Drawing exporter. |
43 | /// </summary> | 43 | /// </summary> |
44 | /// <param name="filename">The target filename</param> | 44 | /// <param name="filename">The target filename</param> |
45 | /// <param name="map">The terrain channel being saved</param> | 45 | /// <param name="map">The terrain channel being saved</param> |
46 | public override void SaveFile(string filename, ITerrainChannel map) | 46 | public override void SaveFile(string filename, ITerrainChannel map) |
47 | { | 47 | { |
48 | Bitmap colours = CreateGrayscaleBitmapFromMap(map); | 48 | Bitmap colours = CreateGrayscaleBitmapFromMap(map); |
49 | 49 | ||
50 | colours.Save(filename, ImageFormat.Bmp); | 50 | colours.Save(filename, ImageFormat.Bmp); |
51 | } | 51 | } |
52 | 52 | ||
53 | /// <summary> | 53 | /// <summary> |
54 | /// The human readable version of the file format(s) this loader handles | 54 | /// The human readable version of the file format(s) this loader handles |
55 | /// </summary> | 55 | /// </summary> |
56 | /// <returns></returns> | 56 | /// <returns></returns> |
57 | public override string ToString() | 57 | public override string ToString() |
58 | { | 58 | { |
59 | return "BMP"; | 59 | return "BMP"; |
60 | } | 60 | } |
61 | } | 61 | } |
62 | } \ No newline at end of file | 62 | } \ No newline at end of file |
diff --git a/OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/GIF.cs b/OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/GIF.cs index 9c2fedc..9bfe851 100644 --- a/OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/GIF.cs +++ b/OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/GIF.cs | |||
@@ -1,47 +1,47 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) Contributors, http://opensimulator.org/ | 2 | * Copyright (c) Contributors, http://opensimulator.org/ |
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | 3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. |
4 | * | 4 | * |
5 | * Redistribution and use in source and binary forms, with or without | 5 | * Redistribution and use in source and binary forms, with or without |
6 | * modification, are permitted provided that the following conditions are met: | 6 | * modification, are permitted provided that the following conditions are met: |
7 | * * Redistributions of source code must retain the above copyright | 7 | * * Redistributions of source code must retain the above copyright |
8 | * notice, this list of conditions and the following disclaimer. | 8 | * notice, this list of conditions and the following disclaimer. |
9 | * * Redistributions in binary form must reproduce the above copyright | 9 | * * Redistributions in binary form must reproduce the above copyright |
10 | * notice, this list of conditions and the following disclaimer in the | 10 | * notice, this list of conditions and the following disclaimer in the |
11 | * documentation and/or other materials provided with the distribution. | 11 | * documentation and/or other materials provided with the distribution. |
12 | * * Neither the name of the OpenSim Project nor the | 12 | * * Neither the name of the OpenSim Project nor the |
13 | * names of its contributors may be used to endorse or promote products | 13 | * names of its contributors may be used to endorse or promote products |
14 | * derived from this software without specific prior written permission. | 14 | * derived from this software without specific prior written permission. |
15 | * | 15 | * |
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | 16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY |
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | 17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | 19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY |
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
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 | using System.Drawing; | 27 | using System.Drawing; |
28 | using System.Drawing.Imaging; | 28 | using System.Drawing.Imaging; |
29 | using OpenSim.Region.Environment.Interfaces; | 29 | using OpenSim.Region.Environment.Interfaces; |
30 | 30 | ||
31 | namespace OpenSim.Region.Environment.Modules.World.Terrain.FileLoaders | 31 | namespace OpenSim.Region.Environment.Modules.World.Terrain.FileLoaders |
32 | { | 32 | { |
33 | internal class GIF : GenericSystemDrawing | 33 | internal class GIF : GenericSystemDrawing |
34 | { | 34 | { |
35 | public override void SaveFile(string filename, ITerrainChannel map) | 35 | public override void SaveFile(string filename, ITerrainChannel map) |
36 | { | 36 | { |
37 | Bitmap colours = CreateGrayscaleBitmapFromMap(map); | 37 | Bitmap colours = CreateGrayscaleBitmapFromMap(map); |
38 | 38 | ||
39 | colours.Save(filename, ImageFormat.Gif); | 39 | colours.Save(filename, ImageFormat.Gif); |
40 | } | 40 | } |
41 | 41 | ||
42 | public override string ToString() | 42 | public override string ToString() |
43 | { | 43 | { |
44 | return "GIF"; | 44 | return "GIF"; |
45 | } | 45 | } |
46 | } | 46 | } |
47 | } \ No newline at end of file | 47 | } \ No newline at end of file |
diff --git a/OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/GenericSystemDrawing.cs b/OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/GenericSystemDrawing.cs index b5e6bd9..9730b16 100644 --- a/OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/GenericSystemDrawing.cs +++ b/OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/GenericSystemDrawing.cs | |||
@@ -1,172 +1,172 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) Contributors, http://opensimulator.org/ | 2 | * Copyright (c) Contributors, http://opensimulator.org/ |
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | 3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. |
4 | * | 4 | * |
5 | * Redistribution and use in source and binary forms, with or without | 5 | * Redistribution and use in source and binary forms, with or without |
6 | * modification, are permitted provided that the following conditions are met: | 6 | * modification, are permitted provided that the following conditions are met: |
7 | * * Redistributions of source code must retain the above copyright | 7 | * * Redistributions of source code must retain the above copyright |
8 | * notice, this list of conditions and the following disclaimer. | 8 | * notice, this list of conditions and the following disclaimer. |
9 | * * Redistributions in binary form must reproduce the above copyright | 9 | * * Redistributions in binary form must reproduce the above copyright |
10 | * notice, this list of conditions and the following disclaimer in the | 10 | * notice, this list of conditions and the following disclaimer in the |
11 | * documentation and/or other materials provided with the distribution. | 11 | * documentation and/or other materials provided with the distribution. |
12 | * * Neither the name of the OpenSim Project nor the | 12 | * * Neither the name of the OpenSim Project nor the |
13 | * names of its contributors may be used to endorse or promote products | 13 | * names of its contributors may be used to endorse or promote products |
14 | * derived from this software without specific prior written permission. | 14 | * derived from this software without specific prior written permission. |
15 | * | 15 | * |
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | 16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY |
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | 17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | 19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY |
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
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 | 27 | ||
28 | using System; | 28 | using System; |
29 | using System.Drawing; | 29 | using System.Drawing; |
30 | using System.Drawing.Imaging; | 30 | using System.Drawing.Imaging; |
31 | using OpenSim.Region.Environment.Interfaces; | 31 | using OpenSim.Region.Environment.Interfaces; |
32 | 32 | ||
33 | namespace OpenSim.Region.Environment.Modules.World.Terrain.FileLoaders | 33 | namespace OpenSim.Region.Environment.Modules.World.Terrain.FileLoaders |
34 | { | 34 | { |
35 | /// <summary> | 35 | /// <summary> |
36 | /// A virtual class designed to have methods overloaded, | 36 | /// A virtual class designed to have methods overloaded, |
37 | /// this class provides an interface for a generic image | 37 | /// this class provides an interface for a generic image |
38 | /// saving and loading mechanism, but does not specify the | 38 | /// saving and loading mechanism, but does not specify the |
39 | /// format. It should not be insubstantiated directly. | 39 | /// format. It should not be insubstantiated directly. |
40 | /// </summary> | 40 | /// </summary> |
41 | public class GenericSystemDrawing : ITerrainLoader | 41 | public class GenericSystemDrawing : ITerrainLoader |
42 | { | 42 | { |
43 | #region ITerrainLoader Members | 43 | #region ITerrainLoader Members |
44 | 44 | ||
45 | public string FileExtension | 45 | public string FileExtension |
46 | { | 46 | { |
47 | get { return ".gsd"; } | 47 | get { return ".gsd"; } |
48 | } | 48 | } |
49 | 49 | ||
50 | /// <summary> | 50 | /// <summary> |
51 | /// Loads a file from a specified filename on the disk, | 51 | /// Loads a file from a specified filename on the disk, |
52 | /// parses the image using the System.Drawing parsers | 52 | /// parses the image using the System.Drawing parsers |
53 | /// then returns a terrain channel. Values are | 53 | /// then returns a terrain channel. Values are |
54 | /// returned based on HSL brightness between 0m and 128m | 54 | /// returned based on HSL brightness between 0m and 128m |
55 | /// </summary> | 55 | /// </summary> |
56 | /// <param name="filename">The target image to load</param> | 56 | /// <param name="filename">The target image to load</param> |
57 | /// <returns>A terrain channel generated from the image.</returns> | 57 | /// <returns>A terrain channel generated from the image.</returns> |
58 | public virtual ITerrainChannel LoadFile(string filename) | 58 | public virtual ITerrainChannel LoadFile(string filename) |
59 | { | 59 | { |
60 | Bitmap file = new Bitmap(filename); | 60 | Bitmap file = new Bitmap(filename); |
61 | 61 | ||
62 | ITerrainChannel retval = new TerrainChannel(file.Width, file.Height); | 62 | ITerrainChannel retval = new TerrainChannel(file.Width, file.Height); |
63 | 63 | ||
64 | int x, y; | 64 | int x, y; |
65 | for (x = 0; x < file.Width; x++) | 65 | for (x = 0; x < file.Width; x++) |
66 | { | 66 | { |
67 | for (y = 0; y < file.Height; y++) | 67 | for (y = 0; y < file.Height; y++) |
68 | { | 68 | { |
69 | retval[x, y] = file.GetPixel(x, y).GetBrightness() * 128; | 69 | retval[x, y] = file.GetPixel(x, y).GetBrightness() * 128; |
70 | } | 70 | } |
71 | } | 71 | } |
72 | 72 | ||
73 | return retval; | 73 | return retval; |
74 | } | 74 | } |
75 | 75 | ||
76 | public ITerrainChannel LoadFile(string filename, int x, int y, int fileWidth, int fileHeight, int w, int h) | 76 | public ITerrainChannel LoadFile(string filename, int x, int y, int fileWidth, int fileHeight, int w, int h) |
77 | { | 77 | { |
78 | throw new NotImplementedException(); | 78 | throw new NotImplementedException(); |
79 | } | 79 | } |
80 | 80 | ||
81 | /// <summary> | 81 | /// <summary> |
82 | /// Exports a file to a image on the disk using a System.Drawing exporter. | 82 | /// Exports a file to a image on the disk using a System.Drawing exporter. |
83 | /// </summary> | 83 | /// </summary> |
84 | /// <param name="filename">The target filename</param> | 84 | /// <param name="filename">The target filename</param> |
85 | /// <param name="map">The terrain channel being saved</param> | 85 | /// <param name="map">The terrain channel being saved</param> |
86 | public virtual void SaveFile(string filename, ITerrainChannel map) | 86 | public virtual void SaveFile(string filename, ITerrainChannel map) |
87 | { | 87 | { |
88 | Bitmap colours = CreateGrayscaleBitmapFromMap(map); | 88 | Bitmap colours = CreateGrayscaleBitmapFromMap(map); |
89 | 89 | ||
90 | colours.Save(filename, ImageFormat.Png); | 90 | colours.Save(filename, ImageFormat.Png); |
91 | } | 91 | } |
92 | 92 | ||
93 | #endregion | 93 | #endregion |
94 | 94 | ||
95 | public override string ToString() | 95 | public override string ToString() |
96 | { | 96 | { |
97 | return "SYS.DRAWING"; | 97 | return "SYS.DRAWING"; |
98 | } | 98 | } |
99 | 99 | ||
100 | /// <summary> | 100 | /// <summary> |
101 | /// Protected method, generates a grayscale bitmap | 101 | /// Protected method, generates a grayscale bitmap |
102 | /// image from a specified terrain channel. | 102 | /// image from a specified terrain channel. |
103 | /// </summary> | 103 | /// </summary> |
104 | /// <param name="map">The terrain channel to export to bitmap</param> | 104 | /// <param name="map">The terrain channel to export to bitmap</param> |
105 | /// <returns>A System.Drawing.Bitmap containing a grayscale image</returns> | 105 | /// <returns>A System.Drawing.Bitmap containing a grayscale image</returns> |
106 | protected Bitmap CreateGrayscaleBitmapFromMap(ITerrainChannel map) | 106 | protected Bitmap CreateGrayscaleBitmapFromMap(ITerrainChannel map) |
107 | { | 107 | { |
108 | Bitmap bmp = new Bitmap(map.Width, map.Height); | 108 | Bitmap bmp = new Bitmap(map.Width, map.Height); |
109 | 109 | ||
110 | int pallete = 256; | 110 | int pallete = 256; |
111 | 111 | ||
112 | Color[] grays = new Color[pallete]; | 112 | Color[] grays = new Color[pallete]; |
113 | for (int i = 0; i < grays.Length; i++) | 113 | for (int i = 0; i < grays.Length; i++) |
114 | { | 114 | { |
115 | grays[i] = Color.FromArgb(i, i, i); | 115 | grays[i] = Color.FromArgb(i, i, i); |
116 | } | 116 | } |
117 | 117 | ||
118 | for (int y = 0; y < map.Height; y++) | 118 | for (int y = 0; y < map.Height; y++) |
119 | { | 119 | { |
120 | for (int x = 0; x < map.Width; x++) | 120 | for (int x = 0; x < map.Width; x++) |
121 | { | 121 | { |
122 | // 512 is the largest possible height before colours clamp | 122 | // 512 is the largest possible height before colours clamp |
123 | int colorindex = (int) (Math.Max(Math.Min(1.0, map[x, y] / 128.0), 0.0) * (pallete - 1)); | 123 | int colorindex = (int) (Math.Max(Math.Min(1.0, map[x, y] / 128.0), 0.0) * (pallete - 1)); |
124 | 124 | ||
125 | // Handle error conditions | 125 | // Handle error conditions |
126 | if (colorindex > pallete - 1 || colorindex < 0) | 126 | if (colorindex > pallete - 1 || colorindex < 0) |
127 | bmp.SetPixel(x, map.Height - y - 1, Color.Red); | 127 | bmp.SetPixel(x, map.Height - y - 1, Color.Red); |
128 | else | 128 | else |
129 | bmp.SetPixel(x, map.Height - y - 1, grays[colorindex]); | 129 | bmp.SetPixel(x, map.Height - y - 1, grays[colorindex]); |
130 | } | 130 | } |
131 | } | 131 | } |
132 | return bmp; | 132 | return bmp; |
133 | } | 133 | } |
134 | 134 | ||
135 | /// <summary> | 135 | /// <summary> |
136 | /// Protected method, generates a coloured bitmap | 136 | /// Protected method, generates a coloured bitmap |
137 | /// image from a specified terrain channel. | 137 | /// image from a specified terrain channel. |
138 | /// </summary> | 138 | /// </summary> |
139 | /// <param name="map">The terrain channel to export to bitmap</param> | 139 | /// <param name="map">The terrain channel to export to bitmap</param> |
140 | /// <returns>A System.Drawing.Bitmap containing a coloured image</returns> | 140 | /// <returns>A System.Drawing.Bitmap containing a coloured image</returns> |
141 | protected Bitmap CreateBitmapFromMap(ITerrainChannel map) | 141 | protected Bitmap CreateBitmapFromMap(ITerrainChannel map) |
142 | { | 142 | { |
143 | Bitmap gradientmapLd = new Bitmap("defaultstripe.png"); | 143 | Bitmap gradientmapLd = new Bitmap("defaultstripe.png"); |
144 | 144 | ||
145 | int pallete = gradientmapLd.Height; | 145 | int pallete = gradientmapLd.Height; |
146 | 146 | ||
147 | Bitmap bmp = new Bitmap(map.Width, map.Height); | 147 | Bitmap bmp = new Bitmap(map.Width, map.Height); |
148 | Color[] colours = new Color[pallete]; | 148 | Color[] colours = new Color[pallete]; |
149 | 149 | ||
150 | for (int i = 0; i < pallete; i++) | 150 | for (int i = 0; i < pallete; i++) |
151 | { | 151 | { |
152 | colours[i] = gradientmapLd.GetPixel(0, i); | 152 | colours[i] = gradientmapLd.GetPixel(0, i); |
153 | } | 153 | } |
154 | 154 | ||
155 | for (int y = 0; y < map.Height; y++) | 155 | for (int y = 0; y < map.Height; y++) |
156 | { | 156 | { |
157 | for (int x = 0; x < map.Width; x++) | 157 | for (int x = 0; x < map.Width; x++) |
158 | { | 158 | { |
159 | // 512 is the largest possible height before colours clamp | 159 | // 512 is the largest possible height before colours clamp |
160 | int colorindex = (int) (Math.Max(Math.Min(1.0, map[x, y] / 512.0), 0.0) * (pallete - 1)); | 160 | int colorindex = (int) (Math.Max(Math.Min(1.0, map[x, y] / 512.0), 0.0) * (pallete - 1)); |
161 | 161 | ||
162 | // Handle error conditions | 162 | // Handle error conditions |
163 | if (colorindex > pallete - 1 || colorindex < 0) | 163 | if (colorindex > pallete - 1 || colorindex < 0) |
164 | bmp.SetPixel(x, map.Height - y - 1, Color.Red); | 164 | bmp.SetPixel(x, map.Height - y - 1, Color.Red); |
165 | else | 165 | else |
166 | bmp.SetPixel(x, map.Height - y - 1, colours[colorindex]); | 166 | bmp.SetPixel(x, map.Height - y - 1, colours[colorindex]); |
167 | } | 167 | } |
168 | } | 168 | } |
169 | return bmp; | 169 | return bmp; |
170 | } | 170 | } |
171 | } | 171 | } |
172 | } \ No newline at end of file | 172 | } \ No newline at end of file |
diff --git a/OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/JPEG.cs b/OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/JPEG.cs index 39ade10..d58926e 100644 --- a/OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/JPEG.cs +++ b/OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/JPEG.cs | |||
@@ -1,94 +1,94 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) Contributors, http://opensimulator.org/ | 2 | * Copyright (c) Contributors, http://opensimulator.org/ |
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | 3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. |
4 | * | 4 | * |
5 | * Redistribution and use in source and binary forms, with or without | 5 | * Redistribution and use in source and binary forms, with or without |
6 | * modification, are permitted provided that the following conditions are met: | 6 | * modification, are permitted provided that the following conditions are met: |
7 | * * Redistributions of source code must retain the above copyright | 7 | * * Redistributions of source code must retain the above copyright |
8 | * notice, this list of conditions and the following disclaimer. | 8 | * notice, this list of conditions and the following disclaimer. |
9 | * * Redistributions in binary form must reproduce the above copyright | 9 | * * Redistributions in binary form must reproduce the above copyright |
10 | * notice, this list of conditions and the following disclaimer in the | 10 | * notice, this list of conditions and the following disclaimer in the |
11 | * documentation and/or other materials provided with the distribution. | 11 | * documentation and/or other materials provided with the distribution. |
12 | * * Neither the name of the OpenSim Project nor the | 12 | * * Neither the name of the OpenSim Project nor the |
13 | * names of its contributors may be used to endorse or promote products | 13 | * names of its contributors may be used to endorse or promote products |
14 | * derived from this software without specific prior written permission. | 14 | * derived from this software without specific prior written permission. |
15 | * | 15 | * |
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | 16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY |
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | 17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | 19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY |
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
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 | 27 | ||
28 | using System; | 28 | using System; |
29 | using System.Drawing; | 29 | using System.Drawing; |
30 | using System.Drawing.Imaging; | 30 | using System.Drawing.Imaging; |
31 | using OpenSim.Region.Environment.Interfaces; | 31 | using OpenSim.Region.Environment.Interfaces; |
32 | 32 | ||
33 | namespace OpenSim.Region.Environment.Modules.World.Terrain.FileLoaders | 33 | namespace OpenSim.Region.Environment.Modules.World.Terrain.FileLoaders |
34 | { | 34 | { |
35 | public class JPEG : ITerrainLoader | 35 | public class JPEG : ITerrainLoader |
36 | { | 36 | { |
37 | #region ITerrainLoader Members | 37 | #region ITerrainLoader Members |
38 | 38 | ||
39 | public string FileExtension | 39 | public string FileExtension |
40 | { | 40 | { |
41 | get { return ".jpg"; } | 41 | get { return ".jpg"; } |
42 | } | 42 | } |
43 | 43 | ||
44 | public ITerrainChannel LoadFile(string filename) | 44 | public ITerrainChannel LoadFile(string filename) |
45 | { | 45 | { |
46 | throw new NotImplementedException(); | 46 | throw new NotImplementedException(); |
47 | } | 47 | } |
48 | 48 | ||
49 | public ITerrainChannel LoadFile(string filename, int x, int y, int fileWidth, int fileHeight, int w, int h) | 49 | public ITerrainChannel LoadFile(string filename, int x, int y, int fileWidth, int fileHeight, int w, int h) |
50 | { | 50 | { |
51 | throw new NotImplementedException(); | 51 | throw new NotImplementedException(); |
52 | } | 52 | } |
53 | 53 | ||
54 | public void SaveFile(string filename, ITerrainChannel map) | 54 | public void SaveFile(string filename, ITerrainChannel map) |
55 | { | 55 | { |
56 | Bitmap colours = CreateBitmapFromMap(map); | 56 | Bitmap colours = CreateBitmapFromMap(map); |
57 | 57 | ||
58 | colours.Save(filename, ImageFormat.Jpeg); | 58 | colours.Save(filename, ImageFormat.Jpeg); |
59 | } | 59 | } |
60 | 60 | ||
61 | #endregion | 61 | #endregion |
62 | 62 | ||
63 | public override string ToString() | 63 | public override string ToString() |
64 | { | 64 | { |
65 | return "JPEG"; | 65 | return "JPEG"; |
66 | } | 66 | } |
67 | 67 | ||
68 | private Bitmap CreateBitmapFromMap(ITerrainChannel map) | 68 | private Bitmap CreateBitmapFromMap(ITerrainChannel map) |
69 | { | 69 | { |
70 | Bitmap gradientmapLd = new Bitmap("defaultstripe.png"); | 70 | Bitmap gradientmapLd = new Bitmap("defaultstripe.png"); |
71 | 71 | ||
72 | int pallete = gradientmapLd.Height; | 72 | int pallete = gradientmapLd.Height; |
73 | 73 | ||
74 | Bitmap bmp = new Bitmap(map.Width, map.Height); | 74 | Bitmap bmp = new Bitmap(map.Width, map.Height); |
75 | Color[] colours = new Color[pallete]; | 75 | Color[] colours = new Color[pallete]; |
76 | 76 | ||
77 | for (int i = 0; i < pallete; i++) | 77 | for (int i = 0; i < pallete; i++) |
78 | { | 78 | { |
79 | colours[i] = gradientmapLd.GetPixel(0, i); | 79 | colours[i] = gradientmapLd.GetPixel(0, i); |
80 | } | 80 | } |
81 | 81 | ||
82 | for (int y = 0; y < map.Height; y++) | 82 | for (int y = 0; y < map.Height; y++) |
83 | { | 83 | { |
84 | for (int x = 0; x < map.Width; x++) | 84 | for (int x = 0; x < map.Width; x++) |
85 | { | 85 | { |
86 | // 512 is the largest possible height before colours clamp | 86 | // 512 is the largest possible height before colours clamp |
87 | int colorindex = (int) (Math.Max(Math.Min(1.0, map[x, y] / 512.0), 0.0) * (pallete - 1)); | 87 | int colorindex = (int) (Math.Max(Math.Min(1.0, map[x, y] / 512.0), 0.0) * (pallete - 1)); |
88 | bmp.SetPixel(x, map.Height - y - 1, colours[colorindex]); | 88 | bmp.SetPixel(x, map.Height - y - 1, colours[colorindex]); |
89 | } | 89 | } |
90 | } | 90 | } |
91 | return bmp; | 91 | return bmp; |
92 | } | 92 | } |
93 | } | 93 | } |
94 | } \ No newline at end of file | 94 | } \ No newline at end of file |
diff --git a/OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/LLRAW.cs b/OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/LLRAW.cs index 468ecc9..5d6723f 100644 --- a/OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/LLRAW.cs +++ b/OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/LLRAW.cs | |||
@@ -1,148 +1,148 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) Contributors, http://opensimulator.org/ | 2 | * Copyright (c) Contributors, http://opensimulator.org/ |
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | 3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. |
4 | * | 4 | * |
5 | * Redistribution and use in source and binary forms, with or without | 5 | * Redistribution and use in source and binary forms, with or without |
6 | * modification, are permitted provided that the following conditions are met: | 6 | * modification, are permitted provided that the following conditions are met: |
7 | * * Redistributions of source code must retain the above copyright | 7 | * * Redistributions of source code must retain the above copyright |
8 | * notice, this list of conditions and the following disclaimer. | 8 | * notice, this list of conditions and the following disclaimer. |
9 | * * Redistributions in binary form must reproduce the above copyright | 9 | * * Redistributions in binary form must reproduce the above copyright |
10 | * notice, this list of conditions and the following disclaimer in the | 10 | * notice, this list of conditions and the following disclaimer in the |
11 | * documentation and/or other materials provided with the distribution. | 11 | * documentation and/or other materials provided with the distribution. |
12 | * * Neither the name of the OpenSim Project nor the | 12 | * * Neither the name of the OpenSim Project nor the |
13 | * names of its contributors may be used to endorse or promote products | 13 | * names of its contributors may be used to endorse or promote products |
14 | * derived from this software without specific prior written permission. | 14 | * derived from this software without specific prior written permission. |
15 | * | 15 | * |
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | 16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY |
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | 17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | 19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY |
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
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 | 27 | ||
28 | using System; | 28 | using System; |
29 | using System.IO; | 29 | using System.IO; |
30 | using OpenSim.Region.Environment.Interfaces; | 30 | using OpenSim.Region.Environment.Interfaces; |
31 | 31 | ||
32 | namespace OpenSim.Region.Environment.Modules.World.Terrain.FileLoaders | 32 | namespace OpenSim.Region.Environment.Modules.World.Terrain.FileLoaders |
33 | { | 33 | { |
34 | public class LLRAW : ITerrainLoader | 34 | public class LLRAW : ITerrainLoader |
35 | { | 35 | { |
36 | #region ITerrainLoader Members | 36 | #region ITerrainLoader Members |
37 | 37 | ||
38 | public ITerrainChannel LoadFile(string filename) | 38 | public ITerrainChannel LoadFile(string filename) |
39 | { | 39 | { |
40 | TerrainChannel retval = new TerrainChannel(); | 40 | TerrainChannel retval = new TerrainChannel(); |
41 | 41 | ||
42 | FileInfo file = new FileInfo(filename); | 42 | FileInfo file = new FileInfo(filename); |
43 | FileStream s = file.Open(FileMode.Open, FileAccess.Read); | 43 | FileStream s = file.Open(FileMode.Open, FileAccess.Read); |
44 | BinaryReader bs = new BinaryReader(s); | 44 | BinaryReader bs = new BinaryReader(s); |
45 | int x, y; | 45 | int x, y; |
46 | for (y = 0; y < retval.Height; y++) | 46 | for (y = 0; y < retval.Height; y++) |
47 | { | 47 | { |
48 | for (x = 0; x < retval.Width; x++) | 48 | for (x = 0; x < retval.Width; x++) |
49 | { | 49 | { |
50 | retval[x, y] = (double) bs.ReadByte() * ((double) bs.ReadByte() / 127.0); | 50 | retval[x, y] = (double) bs.ReadByte() * ((double) bs.ReadByte() / 127.0); |
51 | bs.ReadBytes(11); // Advance the stream to next bytes. | 51 | bs.ReadBytes(11); // Advance the stream to next bytes. |
52 | } | 52 | } |
53 | } | 53 | } |
54 | 54 | ||
55 | bs.Close(); | 55 | bs.Close(); |
56 | s.Close(); | 56 | s.Close(); |
57 | 57 | ||
58 | return retval; | 58 | return retval; |
59 | } | 59 | } |
60 | 60 | ||
61 | public ITerrainChannel LoadFile(string filename, int x, int y, int fileWidth, int fileHeight, int w, int h) | 61 | public ITerrainChannel LoadFile(string filename, int x, int y, int fileWidth, int fileHeight, int w, int h) |
62 | { | 62 | { |
63 | throw new NotImplementedException(); | 63 | throw new NotImplementedException(); |
64 | } | 64 | } |
65 | 65 | ||
66 | public void SaveFile(string filename, ITerrainChannel map) | 66 | public void SaveFile(string filename, ITerrainChannel map) |
67 | { | 67 | { |
68 | FileInfo file = new FileInfo(filename); | 68 | FileInfo file = new FileInfo(filename); |
69 | FileStream s = file.Open(FileMode.CreateNew, FileAccess.Write); | 69 | FileStream s = file.Open(FileMode.CreateNew, FileAccess.Write); |
70 | BinaryWriter binStream = new BinaryWriter(s); | 70 | BinaryWriter binStream = new BinaryWriter(s); |
71 | 71 | ||
72 | // Generate a smegging big lookup table to speed the operation up (it needs it) | 72 | // Generate a smegging big lookup table to speed the operation up (it needs it) |
73 | double[] lookupHeightTable = new double[65536]; | 73 | double[] lookupHeightTable = new double[65536]; |
74 | int i, j, x, y; | 74 | int i, j, x, y; |
75 | for (i = 0; i < 256; i++) | 75 | for (i = 0; i < 256; i++) |
76 | { | 76 | { |
77 | for (j = 0; j < 256; j++) | 77 | for (j = 0; j < 256; j++) |
78 | { | 78 | { |
79 | lookupHeightTable[i + (j * 256)] = ((double) i * ((double) j / 127.0)); | 79 | lookupHeightTable[i + (j * 256)] = ((double) i * ((double) j / 127.0)); |
80 | } | 80 | } |
81 | } | 81 | } |
82 | 82 | ||
83 | // Output the calculated raw | 83 | // Output the calculated raw |
84 | for (y = 0; y < map.Height; y++) | 84 | for (y = 0; y < map.Height; y++) |
85 | { | 85 | { |
86 | for (x = 0; x < map.Width; x++) | 86 | for (x = 0; x < map.Width; x++) |
87 | { | 87 | { |
88 | double t = map[x, y]; | 88 | double t = map[x, y]; |
89 | double min = double.MaxValue; | 89 | double min = double.MaxValue; |
90 | int index = 0; | 90 | int index = 0; |
91 | 91 | ||
92 | for (i = 0; i < 65536; i++) | 92 | for (i = 0; i < 65536; i++) |
93 | { | 93 | { |
94 | if (Math.Abs(t - lookupHeightTable[i]) < min) | 94 | if (Math.Abs(t - lookupHeightTable[i]) < min) |
95 | { | 95 | { |
96 | min = Math.Abs(t - lookupHeightTable[i]); | 96 | min = Math.Abs(t - lookupHeightTable[i]); |
97 | index = i; | 97 | index = i; |
98 | } | 98 | } |
99 | } | 99 | } |
100 | 100 | ||
101 | byte red = (byte) (index & 0xFF); | 101 | byte red = (byte) (index & 0xFF); |
102 | byte green = (byte) ((index >> 8) & 0xFF); | 102 | byte green = (byte) ((index >> 8) & 0xFF); |
103 | byte blue = 20; | 103 | byte blue = 20; |
104 | byte alpha1 = 0; // Land Parcels | 104 | byte alpha1 = 0; // Land Parcels |
105 | byte alpha2 = 0; // For Sale Land | 105 | byte alpha2 = 0; // For Sale Land |
106 | byte alpha3 = 0; // Public Edit Object | 106 | byte alpha3 = 0; // Public Edit Object |
107 | byte alpha4 = 0; // Public Edit Land | 107 | byte alpha4 = 0; // Public Edit Land |
108 | byte alpha5 = 255; // Safe Land | 108 | byte alpha5 = 255; // Safe Land |
109 | byte alpha6 = 255; // Flying Allowed | 109 | byte alpha6 = 255; // Flying Allowed |
110 | byte alpha7 = 255; // Create Landmark | 110 | byte alpha7 = 255; // Create Landmark |
111 | byte alpha8 = 255; // Outside Scripts | 111 | byte alpha8 = 255; // Outside Scripts |
112 | byte alpha9 = red; | 112 | byte alpha9 = red; |
113 | byte alpha10 = green; | 113 | byte alpha10 = green; |
114 | 114 | ||
115 | binStream.Write(red); | 115 | binStream.Write(red); |
116 | binStream.Write(green); | 116 | binStream.Write(green); |
117 | binStream.Write(blue); | 117 | binStream.Write(blue); |
118 | binStream.Write(alpha1); | 118 | binStream.Write(alpha1); |
119 | binStream.Write(alpha2); | 119 | binStream.Write(alpha2); |
120 | binStream.Write(alpha3); | 120 | binStream.Write(alpha3); |
121 | binStream.Write(alpha4); | 121 | binStream.Write(alpha4); |
122 | binStream.Write(alpha5); | 122 | binStream.Write(alpha5); |
123 | binStream.Write(alpha6); | 123 | binStream.Write(alpha6); |
124 | binStream.Write(alpha7); | 124 | binStream.Write(alpha7); |
125 | binStream.Write(alpha8); | 125 | binStream.Write(alpha8); |
126 | binStream.Write(alpha9); | 126 | binStream.Write(alpha9); |
127 | binStream.Write(alpha10); | 127 | binStream.Write(alpha10); |
128 | } | 128 | } |
129 | } | 129 | } |
130 | 130 | ||
131 | binStream.Close(); | 131 | binStream.Close(); |
132 | s.Close(); | 132 | s.Close(); |
133 | } | 133 | } |
134 | 134 | ||
135 | 135 | ||
136 | public string FileExtension | 136 | public string FileExtension |
137 | { | 137 | { |
138 | get { return ".raw"; } | 138 | get { return ".raw"; } |
139 | } | 139 | } |
140 | 140 | ||
141 | #endregion | 141 | #endregion |
142 | 142 | ||
143 | public override string ToString() | 143 | public override string ToString() |
144 | { | 144 | { |
145 | return "LL/SL RAW"; | 145 | return "LL/SL RAW"; |
146 | } | 146 | } |
147 | } | 147 | } |
148 | } \ No newline at end of file | 148 | } \ No newline at end of file |
diff --git a/OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/PNG.cs b/OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/PNG.cs index 2925c7d..b893f70 100644 --- a/OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/PNG.cs +++ b/OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/PNG.cs | |||
@@ -1,47 +1,47 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) Contributors, http://opensimulator.org/ | 2 | * Copyright (c) Contributors, http://opensimulator.org/ |
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | 3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. |
4 | * | 4 | * |
5 | * Redistribution and use in source and binary forms, with or without | 5 | * Redistribution and use in source and binary forms, with or without |
6 | * modification, are permitted provided that the following conditions are met: | 6 | * modification, are permitted provided that the following conditions are met: |
7 | * * Redistributions of source code must retain the above copyright | 7 | * * Redistributions of source code must retain the above copyright |
8 | * notice, this list of conditions and the following disclaimer. | 8 | * notice, this list of conditions and the following disclaimer. |
9 | * * Redistributions in binary form must reproduce the above copyright | 9 | * * Redistributions in binary form must reproduce the above copyright |
10 | * notice, this list of conditions and the following disclaimer in the | 10 | * notice, this list of conditions and the following disclaimer in the |
11 | * documentation and/or other materials provided with the distribution. | 11 | * documentation and/or other materials provided with the distribution. |
12 | * * Neither the name of the OpenSim Project nor the | 12 | * * Neither the name of the OpenSim Project nor the |
13 | * names of its contributors may be used to endorse or promote products | 13 | * names of its contributors may be used to endorse or promote products |
14 | * derived from this software without specific prior written permission. | 14 | * derived from this software without specific prior written permission. |
15 | * | 15 | * |
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | 16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY |
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | 17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | 19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY |
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
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 | using System.Drawing; | 27 | using System.Drawing; |
28 | using System.Drawing.Imaging; | 28 | using System.Drawing.Imaging; |
29 | using OpenSim.Region.Environment.Interfaces; | 29 | using OpenSim.Region.Environment.Interfaces; |
30 | 30 | ||
31 | namespace OpenSim.Region.Environment.Modules.World.Terrain.FileLoaders | 31 | namespace OpenSim.Region.Environment.Modules.World.Terrain.FileLoaders |
32 | { | 32 | { |
33 | internal class PNG : GenericSystemDrawing | 33 | internal class PNG : GenericSystemDrawing |
34 | { | 34 | { |
35 | public override void SaveFile(string filename, ITerrainChannel map) | 35 | public override void SaveFile(string filename, ITerrainChannel map) |
36 | { | 36 | { |
37 | Bitmap colours = CreateGrayscaleBitmapFromMap(map); | 37 | Bitmap colours = CreateGrayscaleBitmapFromMap(map); |
38 | 38 | ||
39 | colours.Save(filename, ImageFormat.Png); | 39 | colours.Save(filename, ImageFormat.Png); |
40 | } | 40 | } |
41 | 41 | ||
42 | public override string ToString() | 42 | public override string ToString() |
43 | { | 43 | { |
44 | return "PNG"; | 44 | return "PNG"; |
45 | } | 45 | } |
46 | } | 46 | } |
47 | } \ No newline at end of file | 47 | } \ No newline at end of file |
diff --git a/OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/RAW32.cs b/OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/RAW32.cs index 71f56c5..fd2136c 100644 --- a/OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/RAW32.cs +++ b/OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/RAW32.cs | |||
@@ -1,153 +1,153 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) Contributors, http://opensimulator.org/ | 2 | * Copyright (c) Contributors, http://opensimulator.org/ |
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | 3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. |
4 | * | 4 | * |
5 | * Redistribution and use in source and binary forms, with or without | 5 | * Redistribution and use in source and binary forms, with or without |
6 | * modification, are permitted provided that the following conditions are met: | 6 | * modification, are permitted provided that the following conditions are met: |
7 | * * Redistributions of source code must retain the above copyright | 7 | * * Redistributions of source code must retain the above copyright |
8 | * notice, this list of conditions and the following disclaimer. | 8 | * notice, this list of conditions and the following disclaimer. |
9 | * * Redistributions in binary form must reproduce the above copyright | 9 | * * Redistributions in binary form must reproduce the above copyright |
10 | * notice, this list of conditions and the following disclaimer in the | 10 | * notice, this list of conditions and the following disclaimer in the |
11 | * documentation and/or other materials provided with the distribution. | 11 | * documentation and/or other materials provided with the distribution. |
12 | * * Neither the name of the OpenSim Project nor the | 12 | * * Neither the name of the OpenSim Project nor the |
13 | * names of its contributors may be used to endorse or promote products | 13 | * names of its contributors may be used to endorse or promote products |
14 | * derived from this software without specific prior written permission. | 14 | * derived from this software without specific prior written permission. |
15 | * | 15 | * |
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | 16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY |
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | 17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | 19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY |
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
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 | 27 | ||
28 | using System.IO; | 28 | using System.IO; |
29 | using OpenSim.Region.Environment.Interfaces; | 29 | using OpenSim.Region.Environment.Interfaces; |
30 | 30 | ||
31 | namespace OpenSim.Region.Environment.Modules.World.Terrain.FileLoaders | 31 | namespace OpenSim.Region.Environment.Modules.World.Terrain.FileLoaders |
32 | { | 32 | { |
33 | public class RAW32 : ITerrainLoader | 33 | public class RAW32 : ITerrainLoader |
34 | { | 34 | { |
35 | #region ITerrainLoader Members | 35 | #region ITerrainLoader Members |
36 | 36 | ||
37 | public string FileExtension | 37 | public string FileExtension |
38 | { | 38 | { |
39 | get { return ".r32"; } | 39 | get { return ".r32"; } |
40 | } | 40 | } |
41 | 41 | ||
42 | public ITerrainChannel LoadFile(string filename) | 42 | public ITerrainChannel LoadFile(string filename) |
43 | { | 43 | { |
44 | TerrainChannel retval = new TerrainChannel(); | 44 | TerrainChannel retval = new TerrainChannel(); |
45 | 45 | ||
46 | FileInfo file = new FileInfo(filename); | 46 | FileInfo file = new FileInfo(filename); |
47 | FileStream s = file.Open(FileMode.Open, FileAccess.Read); | 47 | FileStream s = file.Open(FileMode.Open, FileAccess.Read); |
48 | BinaryReader bs = new BinaryReader(s); | 48 | BinaryReader bs = new BinaryReader(s); |
49 | int x, y; | 49 | int x, y; |
50 | for (y = 0; y < retval.Height; y++) | 50 | for (y = 0; y < retval.Height; y++) |
51 | { | 51 | { |
52 | for (x = 0; x < retval.Width; x++) | 52 | for (x = 0; x < retval.Width; x++) |
53 | { | 53 | { |
54 | retval[x, y] = bs.ReadSingle(); | 54 | retval[x, y] = bs.ReadSingle(); |
55 | } | 55 | } |
56 | } | 56 | } |
57 | 57 | ||
58 | bs.Close(); | 58 | bs.Close(); |
59 | s.Close(); | 59 | s.Close(); |
60 | 60 | ||
61 | return retval; | 61 | return retval; |
62 | } | 62 | } |
63 | 63 | ||
64 | public ITerrainChannel LoadFile(string filename, int offsetX, int offsetY, int fileWidth, int fileHeight, int sectionWidth, int sectionHeight) | 64 | public ITerrainChannel LoadFile(string filename, int offsetX, int offsetY, int fileWidth, int fileHeight, int sectionWidth, int sectionHeight) |
65 | { | 65 | { |
66 | TerrainChannel retval = new TerrainChannel(sectionWidth, sectionHeight); | 66 | TerrainChannel retval = new TerrainChannel(sectionWidth, sectionHeight); |
67 | 67 | ||
68 | FileInfo file = new FileInfo(filename); | 68 | FileInfo file = new FileInfo(filename); |
69 | FileStream s = file.Open(FileMode.Open, FileAccess.Read); | 69 | FileStream s = file.Open(FileMode.Open, FileAccess.Read); |
70 | BinaryReader bs = new BinaryReader(s); | 70 | BinaryReader bs = new BinaryReader(s); |
71 | 71 | ||
72 | int currFileXOffset = 0; | 72 | int currFileXOffset = 0; |
73 | int currFileYOffset = 0; | 73 | int currFileYOffset = 0; |
74 | 74 | ||
75 | // if our region isn't on the first Y section of the areas to be landscaped, then | 75 | // if our region isn't on the first Y section of the areas to be landscaped, then |
76 | // advance to our section of the file | 76 | // advance to our section of the file |
77 | while (currFileYOffset < offsetY) | 77 | while (currFileYOffset < offsetY) |
78 | { | 78 | { |
79 | // read a whole strip of regions | 79 | // read a whole strip of regions |
80 | int heightsToRead = sectionHeight * (fileWidth * sectionWidth); | 80 | int heightsToRead = sectionHeight * (fileWidth * sectionWidth); |
81 | bs.ReadBytes(heightsToRead * 4); // because the floats are 4 bytes in the file | 81 | bs.ReadBytes(heightsToRead * 4); // because the floats are 4 bytes in the file |
82 | currFileYOffset++; | 82 | currFileYOffset++; |
83 | } | 83 | } |
84 | 84 | ||
85 | // got to the Y start offset within the file of our region | 85 | // got to the Y start offset within the file of our region |
86 | // so read the file bits associated with our region | 86 | // so read the file bits associated with our region |
87 | int x, y; | 87 | int x, y; |
88 | // for each Y within our Y offset | 88 | // for each Y within our Y offset |
89 | for (y = 0; y < sectionHeight; y++) | 89 | for (y = 0; y < sectionHeight; y++) |
90 | { | 90 | { |
91 | currFileXOffset = 0; | 91 | currFileXOffset = 0; |
92 | 92 | ||
93 | // if our region isn't the first X section of the areas to be landscaped, then | 93 | // if our region isn't the first X section of the areas to be landscaped, then |
94 | // advance the stream to the X start pos of our section in the file | 94 | // advance the stream to the X start pos of our section in the file |
95 | // i.e. eat X upto where we start | 95 | // i.e. eat X upto where we start |
96 | while (currFileXOffset < offsetX) | 96 | while (currFileXOffset < offsetX) |
97 | { | 97 | { |
98 | bs.ReadBytes(sectionWidth * 4); // 4 bytes = single | 98 | bs.ReadBytes(sectionWidth * 4); // 4 bytes = single |
99 | currFileXOffset++; | 99 | currFileXOffset++; |
100 | } | 100 | } |
101 | 101 | ||
102 | // got to our X offset, so write our regions X line | 102 | // got to our X offset, so write our regions X line |
103 | for (x = 0; x < sectionWidth; x++) | 103 | for (x = 0; x < sectionWidth; x++) |
104 | { | 104 | { |
105 | // Read a strip and continue | 105 | // Read a strip and continue |
106 | retval[x, y] = bs.ReadSingle(); | 106 | retval[x, y] = bs.ReadSingle(); |
107 | } | 107 | } |
108 | // record that we wrote it | 108 | // record that we wrote it |
109 | currFileXOffset++; | 109 | currFileXOffset++; |
110 | 110 | ||
111 | // if our region isn't the last X section of the areas to be landscaped, then | 111 | // if our region isn't the last X section of the areas to be landscaped, then |
112 | // advance the stream to the end of this Y column | 112 | // advance the stream to the end of this Y column |
113 | while (currFileXOffset < fileWidth) | 113 | while (currFileXOffset < fileWidth) |
114 | { | 114 | { |
115 | // eat the next regions x line | 115 | // eat the next regions x line |
116 | bs.ReadBytes(sectionWidth * 4); // 4 bytes = single | 116 | bs.ReadBytes(sectionWidth * 4); // 4 bytes = single |
117 | currFileXOffset++; | 117 | currFileXOffset++; |
118 | } | 118 | } |
119 | } | 119 | } |
120 | 120 | ||
121 | bs.Close(); | 121 | bs.Close(); |
122 | s.Close(); | 122 | s.Close(); |
123 | 123 | ||
124 | return retval; | 124 | return retval; |
125 | } | 125 | } |
126 | 126 | ||
127 | public void SaveFile(string filename, ITerrainChannel map) | 127 | public void SaveFile(string filename, ITerrainChannel map) |
128 | { | 128 | { |
129 | FileInfo file = new FileInfo(filename); | 129 | FileInfo file = new FileInfo(filename); |
130 | FileStream s = file.Open(FileMode.Create, FileAccess.Write); | 130 | FileStream s = file.Open(FileMode.Create, FileAccess.Write); |
131 | BinaryWriter bs = new BinaryWriter(s); | 131 | BinaryWriter bs = new BinaryWriter(s); |
132 | 132 | ||
133 | int x, y; | 133 | int x, y; |
134 | for (y = 0; y < map.Height; y++) | 134 | for (y = 0; y < map.Height; y++) |
135 | { | 135 | { |
136 | for (x = 0; x < map.Width; x++) | 136 | for (x = 0; x < map.Width; x++) |
137 | { | 137 | { |
138 | bs.Write((float) map[x, y]); | 138 | bs.Write((float) map[x, y]); |
139 | } | 139 | } |
140 | } | 140 | } |
141 | 141 | ||
142 | bs.Close(); | 142 | bs.Close(); |
143 | s.Close(); | 143 | s.Close(); |
144 | } | 144 | } |
145 | 145 | ||
146 | #endregion | 146 | #endregion |
147 | 147 | ||
148 | public override string ToString() | 148 | public override string ToString() |
149 | { | 149 | { |
150 | return "RAW32"; | 150 | return "RAW32"; |
151 | } | 151 | } |
152 | } | 152 | } |
153 | } \ No newline at end of file | 153 | } \ No newline at end of file |
diff --git a/OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/TIFF.cs b/OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/TIFF.cs index 3a137ae..c081aea 100644 --- a/OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/TIFF.cs +++ b/OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/TIFF.cs | |||
@@ -1,47 +1,47 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) Contributors, http://opensimulator.org/ | 2 | * Copyright (c) Contributors, http://opensimulator.org/ |
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | 3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. |
4 | * | 4 | * |
5 | * Redistribution and use in source and binary forms, with or without | 5 | * Redistribution and use in source and binary forms, with or without |
6 | * modification, are permitted provided that the following conditions are met: | 6 | * modification, are permitted provided that the following conditions are met: |
7 | * * Redistributions of source code must retain the above copyright | 7 | * * Redistributions of source code must retain the above copyright |
8 | * notice, this list of conditions and the following disclaimer. | 8 | * notice, this list of conditions and the following disclaimer. |
9 | * * Redistributions in binary form must reproduce the above copyright | 9 | * * Redistributions in binary form must reproduce the above copyright |
10 | * notice, this list of conditions and the following disclaimer in the | 10 | * notice, this list of conditions and the following disclaimer in the |
11 | * documentation and/or other materials provided with the distribution. | 11 | * documentation and/or other materials provided with the distribution. |
12 | * * Neither the name of the OpenSim Project nor the | 12 | * * Neither the name of the OpenSim Project nor the |
13 | * names of its contributors may be used to endorse or promote products | 13 | * names of its contributors may be used to endorse or promote products |
14 | * derived from this software without specific prior written permission. | 14 | * derived from this software without specific prior written permission. |
15 | * | 15 | * |
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | 16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY |
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | 17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | 19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY |
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
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 | using System.Drawing; | 27 | using System.Drawing; |
28 | using System.Drawing.Imaging; | 28 | using System.Drawing.Imaging; |
29 | using OpenSim.Region.Environment.Interfaces; | 29 | using OpenSim.Region.Environment.Interfaces; |
30 | 30 | ||
31 | namespace OpenSim.Region.Environment.Modules.World.Terrain.FileLoaders | 31 | namespace OpenSim.Region.Environment.Modules.World.Terrain.FileLoaders |
32 | { | 32 | { |
33 | internal class TIFF : GenericSystemDrawing | 33 | internal class TIFF : GenericSystemDrawing |
34 | { | 34 | { |
35 | public override void SaveFile(string filename, ITerrainChannel map) | 35 | public override void SaveFile(string filename, ITerrainChannel map) |
36 | { | 36 | { |
37 | Bitmap colours = CreateGrayscaleBitmapFromMap(map); | 37 | Bitmap colours = CreateGrayscaleBitmapFromMap(map); |
38 | 38 | ||
39 | colours.Save(filename, ImageFormat.Tiff); | 39 | colours.Save(filename, ImageFormat.Tiff); |
40 | } | 40 | } |
41 | 41 | ||
42 | public override string ToString() | 42 | public override string ToString() |
43 | { | 43 | { |
44 | return "TIFF"; | 44 | return "TIFF"; |
45 | } | 45 | } |
46 | } | 46 | } |
47 | } \ No newline at end of file | 47 | } \ No newline at end of file |
diff --git a/OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/Terragen.cs b/OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/Terragen.cs index f2672ad..7cb4b00 100644 --- a/OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/Terragen.cs +++ b/OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/Terragen.cs | |||
@@ -1,127 +1,127 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) Contributors, http://opensimulator.org/ | 2 | * Copyright (c) Contributors, http://opensimulator.org/ |
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | 3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. |
4 | * | 4 | * |
5 | * Redistribution and use in source and binary forms, with or without | 5 | * Redistribution and use in source and binary forms, with or without |
6 | * modification, are permitted provided that the following conditions are met: | 6 | * modification, are permitted provided that the following conditions are met: |
7 | * * Redistributions of source code must retain the above copyright | 7 | * * Redistributions of source code must retain the above copyright |
8 | * notice, this list of conditions and the following disclaimer. | 8 | * notice, this list of conditions and the following disclaimer. |
9 | * * Redistributions in binary form must reproduce the above copyright | 9 | * * Redistributions in binary form must reproduce the above copyright |
10 | * notice, this list of conditions and the following disclaimer in the | 10 | * notice, this list of conditions and the following disclaimer in the |
11 | * documentation and/or other materials provided with the distribution. | 11 | * documentation and/or other materials provided with the distribution. |
12 | * * Neither the name of the OpenSim Project nor the | 12 | * * Neither the name of the OpenSim Project nor the |
13 | * names of its contributors may be used to endorse or promote products | 13 | * names of its contributors may be used to endorse or promote products |
14 | * derived from this software without specific prior written permission. | 14 | * derived from this software without specific prior written permission. |
15 | * | 15 | * |
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | 16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY |
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | 17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | 19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY |
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
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 | 27 | ||
28 | using System; | 28 | using System; |
29 | using System.IO; | 29 | using System.IO; |
30 | using System.Text; | 30 | using System.Text; |
31 | using OpenSim.Region.Environment.Interfaces; | 31 | using OpenSim.Region.Environment.Interfaces; |
32 | 32 | ||
33 | namespace OpenSim.Region.Environment.Modules.World.Terrain.FileLoaders | 33 | namespace OpenSim.Region.Environment.Modules.World.Terrain.FileLoaders |
34 | { | 34 | { |
35 | /// <summary> | 35 | /// <summary> |
36 | /// Terragen File Format Loader | 36 | /// Terragen File Format Loader |
37 | /// Built from specification at | 37 | /// Built from specification at |
38 | /// http://www.planetside.co.uk/terragen/dev/tgterrain.html | 38 | /// http://www.planetside.co.uk/terragen/dev/tgterrain.html |
39 | /// </summary> | 39 | /// </summary> |
40 | internal class Terragen : ITerrainLoader | 40 | internal class Terragen : ITerrainLoader |
41 | { | 41 | { |
42 | #region ITerrainLoader Members | 42 | #region ITerrainLoader Members |
43 | 43 | ||
44 | public ITerrainChannel LoadFile(string filename) | 44 | public ITerrainChannel LoadFile(string filename) |
45 | { | 45 | { |
46 | TerrainChannel retval = new TerrainChannel(); | 46 | TerrainChannel retval = new TerrainChannel(); |
47 | 47 | ||
48 | FileInfo file = new FileInfo(filename); | 48 | FileInfo file = new FileInfo(filename); |
49 | FileStream s = file.Open(FileMode.Open, FileAccess.Read); | 49 | FileStream s = file.Open(FileMode.Open, FileAccess.Read); |
50 | BinaryReader bs = new BinaryReader(s); | 50 | BinaryReader bs = new BinaryReader(s); |
51 | 51 | ||
52 | bool eof = false; | 52 | bool eof = false; |
53 | if (ASCIIEncoding.ASCII.GetString(bs.ReadBytes(16)) == "TERRAGENTERRAIN ") | 53 | if (ASCIIEncoding.ASCII.GetString(bs.ReadBytes(16)) == "TERRAGENTERRAIN ") |
54 | { | 54 | { |
55 | // Terragen file | 55 | // Terragen file |
56 | while (eof == false) | 56 | while (eof == false) |
57 | { | 57 | { |
58 | int w = 256; | 58 | int w = 256; |
59 | int h = 256; | 59 | int h = 256; |
60 | string tmp = ASCIIEncoding.ASCII.GetString(bs.ReadBytes(4)); | 60 | string tmp = ASCIIEncoding.ASCII.GetString(bs.ReadBytes(4)); |
61 | switch (tmp) | 61 | switch (tmp) |
62 | { | 62 | { |
63 | case "SIZE": | 63 | case "SIZE": |
64 | int sztmp = bs.ReadInt16() + 1; | 64 | int sztmp = bs.ReadInt16() + 1; |
65 | w = sztmp; | 65 | w = sztmp; |
66 | h = sztmp; | 66 | h = sztmp; |
67 | bs.ReadInt16(); | 67 | bs.ReadInt16(); |
68 | break; | 68 | break; |
69 | case "XPTS": | 69 | case "XPTS": |
70 | w = bs.ReadInt16(); | 70 | w = bs.ReadInt16(); |
71 | bs.ReadInt16(); | 71 | bs.ReadInt16(); |
72 | break; | 72 | break; |
73 | case "YPTS": | 73 | case "YPTS": |
74 | h = bs.ReadInt16(); | 74 | h = bs.ReadInt16(); |
75 | bs.ReadInt16(); | 75 | bs.ReadInt16(); |
76 | break; | 76 | break; |
77 | case "ALTW": | 77 | case "ALTW": |
78 | eof = true; | 78 | eof = true; |
79 | Int16 heightScale = bs.ReadInt16(); | 79 | Int16 heightScale = bs.ReadInt16(); |
80 | Int16 baseHeight = bs.ReadInt16(); | 80 | Int16 baseHeight = bs.ReadInt16(); |
81 | retval = new TerrainChannel(w, h); | 81 | retval = new TerrainChannel(w, h); |
82 | int x, y; | 82 | int x, y; |
83 | for (x = 0; x < w; x++) | 83 | for (x = 0; x < w; x++) |
84 | { | 84 | { |
85 | for (y = 0; y < h; y++) | 85 | for (y = 0; y < h; y++) |
86 | { | 86 | { |
87 | retval[x, y] = (double) baseHeight + (double) bs.ReadInt16() * (double) heightScale / 65536.0; | 87 | retval[x, y] = (double) baseHeight + (double) bs.ReadInt16() * (double) heightScale / 65536.0; |
88 | } | 88 | } |
89 | } | 89 | } |
90 | break; | 90 | break; |
91 | default: | 91 | default: |
92 | bs.ReadInt32(); | 92 | bs.ReadInt32(); |
93 | break; | 93 | break; |
94 | } | 94 | } |
95 | } | 95 | } |
96 | } | 96 | } |
97 | 97 | ||
98 | bs.Close(); | 98 | bs.Close(); |
99 | s.Close(); | 99 | s.Close(); |
100 | 100 | ||
101 | return retval; | 101 | return retval; |
102 | } | 102 | } |
103 | 103 | ||
104 | public void SaveFile(string filename, ITerrainChannel map) | 104 | public void SaveFile(string filename, ITerrainChannel map) |
105 | { | 105 | { |
106 | char[] header = "TERRAGENTERRAIN".ToCharArray(); | 106 | char[] header = "TERRAGENTERRAIN".ToCharArray(); |
107 | throw new NotImplementedException(); | 107 | throw new NotImplementedException(); |
108 | } | 108 | } |
109 | 109 | ||
110 | public string FileExtension | 110 | public string FileExtension |
111 | { | 111 | { |
112 | get { return ".ter"; } | 112 | get { return ".ter"; } |
113 | } | 113 | } |
114 | 114 | ||
115 | public ITerrainChannel LoadFile(string filename, int x, int y, int fileWidth, int fileHeight, int w, int h) | 115 | public ITerrainChannel LoadFile(string filename, int x, int y, int fileWidth, int fileHeight, int w, int h) |
116 | { | 116 | { |
117 | throw new NotImplementedException(); | 117 | throw new NotImplementedException(); |
118 | } | 118 | } |
119 | 119 | ||
120 | #endregion | 120 | #endregion |
121 | 121 | ||
122 | public override string ToString() | 122 | public override string ToString() |
123 | { | 123 | { |
124 | return "Terragen"; | 124 | return "Terragen"; |
125 | } | 125 | } |
126 | } | 126 | } |
127 | } \ No newline at end of file | 127 | } \ No newline at end of file |