aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Environment/Modules/World
diff options
context:
space:
mode:
authorTeravus Ovares2008-06-16 22:06:55 +0000
committerTeravus Ovares2008-06-16 22:06:55 +0000
commit53c9ce46b3cdb9a4bb1cbb5d91641bbacf70866c (patch)
treea0612fba2bf2d51e466f019f72cb1f37275fb2f5 /OpenSim/Region/Environment/Modules/World
parent* minor: Get rid of rogue "Current node RootPart" message in the SceneObjectG... (diff)
downloadopensim-SC-53c9ce46b3cdb9a4bb1cbb5d91641bbacf70866c.zip
opensim-SC-53c9ce46b3cdb9a4bb1cbb5d91641bbacf70866c.tar.gz
opensim-SC-53c9ce46b3cdb9a4bb1cbb5d91641bbacf70866c.tar.bz2
opensim-SC-53c9ce46b3cdb9a4bb1cbb5d91641bbacf70866c.tar.xz
* Enables binary data in BaseHttpServer with 'image' in content type.
* Enables regular jpeg map images to be served directly from the region. * EX: http://192.168.1.127:9000/index.php?method=regionImagecc4583cd269b41bfa525dd198e19a5c5 * This is actually HTTP server address + port + index.php?method=regionImage<REGIONUUID, no dashes> * The Webmap image location gets printed on the console when the simulator starts up. * JPEG data is cached so we only create the webjpeg once.
Diffstat (limited to 'OpenSim/Region/Environment/Modules/World')
-rw-r--r--OpenSim/Region/Environment/Modules/World/WorldMap/WorldMapModule.cs81
1 files changed, 80 insertions, 1 deletions
diff --git a/OpenSim/Region/Environment/Modules/World/WorldMap/WorldMapModule.cs b/OpenSim/Region/Environment/Modules/World/WorldMap/WorldMapModule.cs
index ebcb440..1dc0d0b 100644
--- a/OpenSim/Region/Environment/Modules/World/WorldMap/WorldMapModule.cs
+++ b/OpenSim/Region/Environment/Modules/World/WorldMap/WorldMapModule.cs
@@ -28,8 +28,12 @@
28using System; 28using System;
29using System.Collections; 29using System.Collections;
30using System.Collections.Generic; 30using System.Collections.Generic;
31using System.Drawing;
32using System.Drawing.Imaging;
33using System.IO;
31using System.Reflection; 34using System.Reflection;
32using libsecondlife; 35using libsecondlife;
36using OpenJPEGNet;
33using log4net; 37using log4net;
34using Nini.Config; 38using Nini.Config;
35using OpenSim.Framework; 39using OpenSim.Framework;
@@ -55,6 +59,7 @@ namespace OpenSim.Region.Environment.Modules.World.WorldMap
55 private Scene m_scene; 59 private Scene m_scene;
56 private List<MapBlockData> cachedMapBlocks = new List<MapBlockData>(); 60 private List<MapBlockData> cachedMapBlocks = new List<MapBlockData>();
57 private int cachedTime = 0; 61 private int cachedTime = 0;
62 private byte[] myMapImageJPEG;
58 63
59 //private int CacheRegionsDistance = 256; 64 //private int CacheRegionsDistance = 256;
60 65
@@ -62,8 +67,15 @@ namespace OpenSim.Region.Environment.Modules.World.WorldMap
62 67
63 public void Initialise(Scene scene, IConfigSource config) 68 public void Initialise(Scene scene, IConfigSource config)
64 { 69 {
70 myMapImageJPEG = new byte[0];
71
65 m_scene = scene; 72 m_scene = scene;
66 73 string regionimage = "regionImage" + scene.RegionInfo.RegionID.ToString();
74 regionimage = regionimage.Replace("-", "");
75 m_log.Warn("[WEBMAP]: JPEG Map location: http://" + m_scene.RegionInfo.ExternalEndPoint.Address.ToString() + ":" + m_scene.RegionInfo.HttpPort.ToString() + "/index.php?method=" + regionimage);
76
77
78 m_scene.AddHTTPHandler(regionimage, OnHTTPGetMapImage);
67 //QuadTree.Subdivide(); 79 //QuadTree.Subdivide();
68 //QuadTree.Subdivide(); 80 //QuadTree.Subdivide();
69 81
@@ -235,5 +247,72 @@ namespace OpenSim.Region.Environment.Modules.World.WorldMap
235 mapBlocks = m_scene.CommsManager.GridService.RequestNeighbourMapBlocks(minX - 4, minY - 4, minX + 4, minY + 4); 247 mapBlocks = m_scene.CommsManager.GridService.RequestNeighbourMapBlocks(minX - 4, minY - 4, minX + 4, minY + 4);
236 remoteClient.SendMapBlock(mapBlocks); 248 remoteClient.SendMapBlock(mapBlocks);
237 } 249 }
250 public Hashtable OnHTTPGetMapImage(Hashtable keysvals)
251 {
252 m_log.Info("[WEBMAP]: Sending map image jpeg");
253 Hashtable reply = new Hashtable();
254 int statuscode = 200;
255
256 byte[] jpeg;
257
258
259 if (myMapImageJPEG.Length == 0)
260 {
261 MemoryStream imgstream = new MemoryStream();
262 Bitmap mapTexture = new Bitmap(1,1);
263 System.Drawing.Image image = (System.Drawing.Image)mapTexture;
264
265
266 try
267 {
268 // Taking our jpeg2000 data, decoding it, then saving it to a byte array with regular jpeg data
269
270
271 imgstream = new MemoryStream();
272
273 // non-async because we know we have the asset immediately.
274 AssetBase mapasset = m_scene.AssetCache.GetAsset(m_scene.RegionInfo.lastMapUUID, true);
275
276 // Decode image to System.Drawing.Image
277 image = OpenJPEG.DecodeToImage(mapasset.Data);
278
279 // Save to bitmap
280 mapTexture = new Bitmap(image);
281
282 // Save bitmap to stream
283 mapTexture.Save(imgstream, ImageFormat.Jpeg);
284
285 // Write the stream to a byte array for output
286 jpeg = imgstream.ToArray();
287 myMapImageJPEG = jpeg;
288 }
289 catch (Exception)
290 {
291 // Dummy!
292 jpeg = new byte[0];
293 m_log.Warn("[WEBMAP]: Unable to generate Map image");
294 }
295 finally
296 {
297 // Reclaim memory, these are unmanaged resources
298 mapTexture.Dispose();
299 image.Dispose();
300 imgstream.Close();
301 imgstream.Dispose();
302 }
303 }
304 else
305 {
306 // Use cached version so we don't have to loose our mind
307 jpeg = myMapImageJPEG;
308 }
309 //jpeg = new byte[0];
310
311 reply["str_response_string"] = Convert.ToBase64String(jpeg);
312 reply["int_response_code"] = statuscode;
313 reply["content_type"] = "image/jpeg";
314
315 return reply;
316 }
238 } 317 }
239} 318}