diff options
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/File.cs | 154 |
1 files changed, 77 insertions, 77 deletions
diff --git a/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/File.cs b/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/File.cs index c0173c0..cfefb6b 100644 --- a/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/File.cs +++ b/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/File.cs | |||
@@ -1,77 +1,77 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) Contributors, http://www.openmetaverse.org/ | 2 | * Copyright (c) Contributors, http://www.openmetaverse.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 | 28 | ||
29 | using System; | 29 | using System; |
30 | using System.Collections.Generic; | 30 | using System.Collections.Generic; |
31 | using System.Text; | 31 | using System.Text; |
32 | using System.Drawing; | 32 | using System.Drawing; |
33 | 33 | ||
34 | namespace libTerrain | 34 | namespace libTerrain |
35 | { | 35 | { |
36 | partial class Channel | 36 | partial class Channel |
37 | { | 37 | { |
38 | public Channel LoadImage(string filename) | 38 | public Channel LoadImage(string filename) |
39 | { | 39 | { |
40 | SetDiff(); | 40 | SetDiff(); |
41 | 41 | ||
42 | Bitmap bit = new Bitmap(filename); | 42 | Bitmap bit = new Bitmap(filename); |
43 | Channel chan = new Channel(bit.Width, bit.Height); | 43 | Channel chan = new Channel(bit.Width, bit.Height); |
44 | 44 | ||
45 | int x, y; | 45 | int x, y; |
46 | for (x = 0; x < bit.Width; x++) | 46 | for (x = 0; x < bit.Width; x++) |
47 | { | 47 | { |
48 | for (y = 0; y < bit.Height; y++) | 48 | for (y = 0; y < bit.Height; y++) |
49 | { | 49 | { |
50 | Color val = bit.GetPixel(x, y); | 50 | Color val = bit.GetPixel(x, y); |
51 | chan.map[x, y] = (((double)val.R + (double)val.G + (double)val.B) / 3.0) / 255.0; | 51 | chan.map[x, y] = (((double)val.R + (double)val.G + (double)val.B) / 3.0) / 255.0; |
52 | } | 52 | } |
53 | } | 53 | } |
54 | 54 | ||
55 | return chan; | 55 | return chan; |
56 | } | 56 | } |
57 | 57 | ||
58 | public void SaveImage(string filename) | 58 | public void SaveImage(string filename) |
59 | { | 59 | { |
60 | Channel outmap = this.Copy(); | 60 | Channel outmap = this.Copy(); |
61 | outmap.Normalise(); | 61 | outmap.Normalise(); |
62 | 62 | ||
63 | Bitmap bit = new Bitmap(w, h, System.Drawing.Imaging.PixelFormat.Format24bppRgb); | 63 | Bitmap bit = new Bitmap(w, h, System.Drawing.Imaging.PixelFormat.Format24bppRgb); |
64 | int x, y; | 64 | int x, y; |
65 | for (x = 0; x < w; x++) | 65 | for (x = 0; x < w; x++) |
66 | { | 66 | { |
67 | for (y = 0; y < h; y++) | 67 | for (y = 0; y < h; y++) |
68 | { | 68 | { |
69 | int val = Math.Min(255, (int)(outmap.map[x,y] * 255)); | 69 | int val = Math.Min(255, (int)(outmap.map[x,y] * 255)); |
70 | Color col = Color.FromArgb(val,val,val); | 70 | Color col = Color.FromArgb(val,val,val); |
71 | bit.SetPixel(x, y, col); | 71 | bit.SetPixel(x, y, col); |
72 | } | 72 | } |
73 | } | 73 | } |
74 | bit.Save(filename); | 74 | bit.Save(filename); |
75 | } | 75 | } |
76 | } | 76 | } |
77 | } | 77 | } |