aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Environment/Modules/World/WorldMap/TexturedMapTileRenderer.cs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/Environment/Modules/World/WorldMap/TexturedMapTileRenderer.cs33
1 files changed, 19 insertions, 14 deletions
diff --git a/OpenSim/Region/Environment/Modules/World/WorldMap/TexturedMapTileRenderer.cs b/OpenSim/Region/Environment/Modules/World/WorldMap/TexturedMapTileRenderer.cs
index 615befc..ff8d0b9 100644
--- a/OpenSim/Region/Environment/Modules/World/WorldMap/TexturedMapTileRenderer.cs
+++ b/OpenSim/Region/Environment/Modules/World/WorldMap/TexturedMapTileRenderer.cs
@@ -32,15 +32,14 @@ using System.Drawing;
32using System.Drawing.Drawing2D; 32using System.Drawing.Drawing2D;
33using System.Drawing.Imaging; 33using System.Drawing.Imaging;
34using System.Reflection; 34using System.Reflection;
35using Axiom.Math; 35using OpenMetaverse;
36using Nini.Config; 36using Nini.Config;
37using log4net; 37using log4net;
38using OpenJPEGNet; 38using OpenMetaverse.Imaging;
39using OpenSim.Framework; 39using OpenSim.Framework;
40using OpenSim.Region.Environment.Interfaces; 40using OpenSim.Region.Environment.Interfaces;
41using OpenSim.Region.Environment.Scenes; 41using OpenSim.Region.Environment.Scenes;
42using OpenSim.Region.Environment.Modules.World.Terrain; 42using OpenSim.Region.Environment.Modules.World.Terrain;
43using libsecondlife;
44 43
45namespace OpenSim.Region.Environment.Modules.World.WorldMap 44namespace OpenSim.Region.Environment.Modules.World.WorldMap
46{ 45{
@@ -122,15 +121,15 @@ namespace OpenSim.Region.Environment.Modules.World.WorldMap
122 121
123 // some hardcoded terrain UUIDs that work with SL 1.20 (the four default textures and "Blank"). 122 // some hardcoded terrain UUIDs that work with SL 1.20 (the four default textures and "Blank").
124 // The color-values were choosen because they "look right" (at least to me) ;-) 123 // The color-values were choosen because they "look right" (at least to me) ;-)
125 private static readonly LLUUID defaultTerrainTexture1 = new LLUUID("0bc58228-74a0-7e83-89bc-5c23464bcec5"); 124 private static readonly UUID defaultTerrainTexture1 = new UUID("0bc58228-74a0-7e83-89bc-5c23464bcec5");
126 private static readonly Color defaultColor1 = Color.FromArgb(165, 137, 118); 125 private static readonly Color defaultColor1 = Color.FromArgb(165, 137, 118);
127 private static readonly LLUUID defaultTerrainTexture2 = new LLUUID("63338ede-0037-c4fd-855b-015d77112fc8"); 126 private static readonly UUID defaultTerrainTexture2 = new UUID("63338ede-0037-c4fd-855b-015d77112fc8");
128 private static readonly Color defaultColor2 = Color.FromArgb(69, 89, 49); 127 private static readonly Color defaultColor2 = Color.FromArgb(69, 89, 49);
129 private static readonly LLUUID defaultTerrainTexture3 = new LLUUID("303cd381-8560-7579-23f1-f0a880799740"); 128 private static readonly UUID defaultTerrainTexture3 = new UUID("303cd381-8560-7579-23f1-f0a880799740");
130 private static readonly Color defaultColor3 = Color.FromArgb(162, 154, 141); 129 private static readonly Color defaultColor3 = Color.FromArgb(162, 154, 141);
131 private static readonly LLUUID defaultTerrainTexture4 = new LLUUID("53a2f406-4895-1d13-d541-d2e3b86bc19c"); 130 private static readonly UUID defaultTerrainTexture4 = new UUID("53a2f406-4895-1d13-d541-d2e3b86bc19c");
132 private static readonly Color defaultColor4 = Color.FromArgb(200, 200, 200); 131 private static readonly Color defaultColor4 = Color.FromArgb(200, 200, 200);
133 private static readonly LLUUID blankTerrainTexture = new LLUUID("5748decc-f629-461c-9a36-a35a221fe21f"); 132 private static readonly UUID blankTerrainTexture = new UUID("5748decc-f629-461c-9a36-a35a221fe21f");
134 133
135 #endregion 134 #endregion
136 135
@@ -142,14 +141,14 @@ namespace OpenSim.Region.Environment.Modules.World.WorldMap
142 // added when the terrain textures are changed in the estate dialog and a new map is generated (and will stay in 141 // added when the terrain textures are changed in the estate dialog and a new map is generated (and will stay in
143 // that map until the region-server restarts. This could be considered a memory-leak, but it's a *very* small one. 142 // that map until the region-server restarts. This could be considered a memory-leak, but it's a *very* small one.
144 // TODO does it make sense to use a "real" cache and regenerate missing entries on fetch? 143 // TODO does it make sense to use a "real" cache and regenerate missing entries on fetch?
145 private Dictionary<LLUUID, Color> m_mapping; 144 private Dictionary<UUID, Color> m_mapping;
146 145
147 146
148 public void Initialise(Scene scene, IConfigSource source) 147 public void Initialise(Scene scene, IConfigSource source)
149 { 148 {
150 m_scene = scene; 149 m_scene = scene;
151 // m_config = source; // not used currently 150 // m_config = source; // not used currently
152 m_mapping = new Dictionary<LLUUID,Color>(); 151 m_mapping = new Dictionary<UUID,Color>();
153 m_mapping.Add(defaultTerrainTexture1, defaultColor1); 152 m_mapping.Add(defaultTerrainTexture1, defaultColor1);
154 m_mapping.Add(defaultTerrainTexture2, defaultColor2); 153 m_mapping.Add(defaultTerrainTexture2, defaultColor2);
155 m_mapping.Add(defaultTerrainTexture3, defaultColor3); 154 m_mapping.Add(defaultTerrainTexture3, defaultColor3);
@@ -164,12 +163,18 @@ namespace OpenSim.Region.Environment.Modules.World.WorldMap
164 // TODO (- on "map" command: We are in the command-line thread, we will wait for completion anyway) 163 // TODO (- on "map" command: We are in the command-line thread, we will wait for completion anyway)
165 // TODO (- on "automatic" update after some change: We are called from the mapUpdateTimer here and 164 // TODO (- on "automatic" update after some change: We are called from the mapUpdateTimer here and
166 // will wait anyway) 165 // will wait anyway)
167 private Bitmap fetchTexture(LLUUID id) 166 private Bitmap fetchTexture(UUID id)
168 { 167 {
169 AssetBase asset = m_scene.AssetCache.GetAsset(id, true); 168 AssetBase asset = m_scene.AssetCache.GetAsset(id, true);
170 m_log.DebugFormat("Fetched texture {0}, found: {1}", id, asset != null); 169 m_log.DebugFormat("Fetched texture {0}, found: {1}", id, asset != null);
171 if (asset == null) return null; 170 if (asset == null) return null;
172 return new Bitmap(OpenJPEG.DecodeToImage(asset.Data)); 171
172 ManagedImage managedImage;
173 Image image;
174 if (OpenJPEG.DecodeToImage(asset.Data, out managedImage, out image))
175 return new Bitmap(image);
176 else
177 return null;
173 } 178 }
174 179
175 // Compute the average color of a texture. 180 // Compute the average color of a texture.
@@ -196,8 +201,8 @@ namespace OpenSim.Region.Environment.Modules.World.WorldMap
196 201
197 // return either the average color of the texture, or the defaultColor if the texturID is invalid 202 // return either the average color of the texture, or the defaultColor if the texturID is invalid
198 // or the texture couldn't be found 203 // or the texture couldn't be found
199 private Color computeAverageColor(LLUUID textureID, Color defaultColor) { 204 private Color computeAverageColor(UUID textureID, Color defaultColor) {
200 if (textureID == LLUUID.Zero) return defaultColor; // not set 205 if (textureID == UUID.Zero) return defaultColor; // not set
201 if (m_mapping.ContainsKey(textureID)) return m_mapping[textureID]; // one of the predefined textures 206 if (m_mapping.ContainsKey(textureID)) return m_mapping[textureID]; // one of the predefined textures
202 207
203 Bitmap bmp = fetchTexture(textureID); 208 Bitmap bmp = fetchTexture(textureID);