diff options
author | Adam Frisby | 2007-07-21 22:25:42 +0000 |
---|---|---|
committer | Adam Frisby | 2007-07-21 22:25:42 +0000 |
commit | f84937367f7180140bd17444d507977f9b7e3d2e (patch) | |
tree | 944f2824669e42b5df3b6655bd09999c89b50376 /OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/File.cs | |
parent | * Renamed terrain functions to match OpenSim naming styles. (diff) | |
download | opensim-SC_OLD-f84937367f7180140bd17444d507977f9b7e3d2e.zip opensim-SC_OLD-f84937367f7180140bd17444d507977f9b7e3d2e.tar.gz opensim-SC_OLD-f84937367f7180140bd17444d507977f9b7e3d2e.tar.bz2 opensim-SC_OLD-f84937367f7180140bd17444d507977f9b7e3d2e.tar.xz |
* Deleted libTerrain-BSD.dll
* Added libTerrain to BasicTerrain directly as a subfolder
Diffstat (limited to 'OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/File.cs')
-rw-r--r-- | OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/File.cs | 75 |
1 files changed, 75 insertions, 0 deletions
diff --git a/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/File.cs b/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/File.cs new file mode 100644 index 0000000..4163a5f --- /dev/null +++ b/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/File.cs | |||
@@ -0,0 +1,75 @@ | |||
1 | /* | ||
2 | Redistribution and use in source and binary forms, with or without | ||
3 | modification, are permitted provided that the following conditions are | ||
4 | met: | ||
5 | |||
6 | * Redistributions of source code must retain the above copyright | ||
7 | notice, this list of conditions and the following disclaimer. | ||
8 | |||
9 | * Redistributions in binary form must reproduce the above | ||
10 | copyright notice, this list of conditions and the following | ||
11 | disclaimer in the documentation and/or other materials provided | ||
12 | with the distribution. | ||
13 | |||
14 | * Neither the name of libTerrain nor the names of | ||
15 | its contributors may be used to endorse or promote products | ||
16 | derived from this software without specific prior written | ||
17 | permission. | ||
18 | |||
19 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
20 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
21 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | ||
22 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | ||
23 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
24 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | ||
25 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||
26 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | ||
27 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
28 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
29 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
30 | */ | ||
31 | |||
32 | using System; | ||
33 | using System.Collections.Generic; | ||
34 | using System.Text; | ||
35 | using System.Drawing; | ||
36 | |||
37 | namespace libTerrain | ||
38 | { | ||
39 | partial class Channel | ||
40 | { | ||
41 | public Channel loadImage(string filename) | ||
42 | { | ||
43 | Bitmap bit = new Bitmap(filename); | ||
44 | Channel chan = new Channel(bit.Width, bit.Height); | ||
45 | |||
46 | int x, y; | ||
47 | for (x = 0; x < bit.Width; x++) | ||
48 | { | ||
49 | for (y = 0; y < bit.Height; y++) | ||
50 | { | ||
51 | Color val = bit.GetPixel(x, y); | ||
52 | chan.map[x, y] = (((double)val.R + (double)val.G + (double)val.B) / 3.0) / 255.0; | ||
53 | } | ||
54 | } | ||
55 | |||
56 | return chan; | ||
57 | } | ||
58 | |||
59 | public void saveImage(string filename) | ||
60 | { | ||
61 | Bitmap bit = new Bitmap(w, h, System.Drawing.Imaging.PixelFormat.Format24bppRgb); | ||
62 | int x, y; | ||
63 | for (x = 0; x < w; x++) | ||
64 | { | ||
65 | for (y = 0; y < h; y++) | ||
66 | { | ||
67 | int val = Math.Min(255, (int)(map[x,y] * 255)); | ||
68 | Color col = Color.FromArgb(val,val,val); | ||
69 | bit.SetPixel(x, y, col); | ||
70 | } | ||
71 | } | ||
72 | bit.Save(filename); | ||
73 | } | ||
74 | } | ||
75 | } | ||