diff options
author | Adam Frisby | 2008-04-15 03:07:31 +0000 |
---|---|---|
committer | Adam Frisby | 2008-04-15 03:07:31 +0000 |
commit | 0b4a8191a1d69294fa95381bfe7f2fa2aa400cfb (patch) | |
tree | 78e5c2ced40f3a941c5b9a0e7f3bf33809d9dc81 /OpenSim/Region/Environment/Modules/Terrain/MapImageModule.cs | |
parent | * Working towards notifying the client if the inventory service has failed, r... (diff) | |
download | opensim-SC_OLD-0b4a8191a1d69294fa95381bfe7f2fa2aa400cfb.zip opensim-SC_OLD-0b4a8191a1d69294fa95381bfe7f2fa2aa400cfb.tar.gz opensim-SC_OLD-0b4a8191a1d69294fa95381bfe7f2fa2aa400cfb.tar.bz2 opensim-SC_OLD-0b4a8191a1d69294fa95381bfe7f2fa2aa400cfb.tar.xz |
* Quick patch before I start on a bigger project
* Renamed ITerrainTemp to IMapImageGenerator
* Renamed WriteJpegImage to WriteJpeg2000Image to better reflect it's function.
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Region/Environment/Modules/Terrain/MapImageModule.cs | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/OpenSim/Region/Environment/Modules/Terrain/MapImageModule.cs b/OpenSim/Region/Environment/Modules/Terrain/MapImageModule.cs index c791ac3..458d781 100644 --- a/OpenSim/Region/Environment/Modules/Terrain/MapImageModule.cs +++ b/OpenSim/Region/Environment/Modules/Terrain/MapImageModule.cs | |||
@@ -10,7 +10,7 @@ using OpenSim.Region.Environment.Modules.ModuleFramework; | |||
10 | 10 | ||
11 | namespace OpenSim.Region.Environment.Modules.Terrain | 11 | namespace OpenSim.Region.Environment.Modules.Terrain |
12 | { | 12 | { |
13 | class MapImageModule : ITerrainTemp, IRegionModule | 13 | class MapImageModule : IMapImageGenerator, IRegionModule |
14 | { | 14 | { |
15 | private Scene m_scene; | 15 | private Scene m_scene; |
16 | #region IRegionModule Members | 16 | #region IRegionModule Members |
@@ -18,7 +18,7 @@ namespace OpenSim.Region.Environment.Modules.Terrain | |||
18 | public void Initialise(Scene scene, IConfigSource source) | 18 | public void Initialise(Scene scene, IConfigSource source) |
19 | { | 19 | { |
20 | m_scene = scene; | 20 | m_scene = scene; |
21 | m_scene.RegisterModuleInterface<ITerrainTemp>(this); | 21 | m_scene.RegisterModuleInterface<IMapImageGenerator>(this); |
22 | } | 22 | } |
23 | 23 | ||
24 | public void PostInitialise() | 24 | public void PostInitialise() |
@@ -40,15 +40,15 @@ namespace OpenSim.Region.Environment.Modules.Terrain | |||
40 | } | 40 | } |
41 | 41 | ||
42 | 42 | ||
43 | public byte[] WriteJpegImage(string gradientmap) | 43 | public byte[] WriteJpeg2000Image(string gradientmap) |
44 | { | 44 | { |
45 | byte[] imageData = null; | 45 | byte[] imageData = null; |
46 | |||
47 | Bitmap bmp = TerrainToBitmap(gradientmap); | ||
48 | |||
46 | try | 49 | try |
47 | { | 50 | { |
48 | Bitmap bmp = TerrainToBitmap(gradientmap); | ||
49 | |||
50 | imageData = OpenJPEGNet.OpenJPEG.EncodeFromImage(bmp, true); | 51 | imageData = OpenJPEGNet.OpenJPEG.EncodeFromImage(bmp, true); |
51 | |||
52 | } | 52 | } |
53 | catch (Exception e) // LEGIT: Catching problems caused by OpenJPEG p/invoke | 53 | catch (Exception e) // LEGIT: Catching problems caused by OpenJPEG p/invoke |
54 | { | 54 | { |
@@ -122,7 +122,12 @@ namespace OpenSim.Region.Environment.Modules.Terrain | |||
122 | { | 122 | { |
123 | // 512 is the largest possible height before colours clamp | 123 | // 512 is the largest possible height before colours clamp |
124 | int colorindex = (int)(Math.Max(Math.Min(1.0, copy[x, y] / 512.0), 0.0) * (pallete - 1)); | 124 | int colorindex = (int)(Math.Max(Math.Min(1.0, copy[x, y] / 512.0), 0.0) * (pallete - 1)); |
125 | bmp.SetPixel(x, copy.Height - y - 1, colours[colorindex]); | 125 | |
126 | // Handle error conditions | ||
127 | if (colorindex > pallete - 1 || colorindex < 0) | ||
128 | bmp.SetPixel(x, copy.Height - y - 1, Color.Red); | ||
129 | else | ||
130 | bmp.SetPixel(x, copy.Height - y - 1, colours[colorindex]); | ||
126 | } | 131 | } |
127 | } | 132 | } |
128 | ShadeBuildings(ref bmp); | 133 | ShadeBuildings(ref bmp); |