From 9a24c0b41c786f49766c212c656f8162e4c263ef Mon Sep 17 00:00:00 2001 From: Marck Date: Mon, 13 Dec 2010 21:19:33 +0100 Subject: Show map tile for hyperlinks. Perform Check4096 before adding a hyperlink. Configuration option AssetService in section [GridService] must be set to enable this functionality. Map tiles do currently not show for hyperlinks set in simulators that are connected to grids, see Mantis #5270. --- .../Hypergrid/GatekeeperServiceConnector.cs | 29 +++++++++++----------- 1 file changed, 15 insertions(+), 14 deletions(-) (limited to 'OpenSim/Services/Connectors/Hypergrid') diff --git a/OpenSim/Services/Connectors/Hypergrid/GatekeeperServiceConnector.cs b/OpenSim/Services/Connectors/Hypergrid/GatekeeperServiceConnector.cs index 85c1380..d4fd1b8 100644 --- a/OpenSim/Services/Connectors/Hypergrid/GatekeeperServiceConnector.cs +++ b/OpenSim/Services/Connectors/Hypergrid/GatekeeperServiceConnector.cs @@ -29,6 +29,7 @@ using System; using System.Collections; using System.Collections.Generic; using System.Drawing; +using System.IO; using System.Net; using System.Reflection; using OpenSim.Framework; @@ -48,7 +49,7 @@ namespace OpenSim.Services.Connectors.Hypergrid { private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); -// private static UUID m_HGMapImage = new UUID("00000000-0000-1111-9999-000000000013"); + private static UUID m_HGMapImage = new UUID("00000000-0000-1111-9999-000000000013"); private IAssetService m_AssetService; @@ -143,24 +144,25 @@ namespace OpenSim.Services.Connectors.Hypergrid return true; } - UUID m_MissingTexture = new UUID("5748decc-f629-461c-9a36-a35a221fe21f"); - - public UUID GetMapImage(UUID regionID, string imageURL) + public UUID GetMapImage(UUID regionID, string imageURL, string storagePath) { if (m_AssetService == null) - return m_MissingTexture; + return m_HGMapImage; + UUID mapTile = m_HGMapImage; + string filename = string.Empty; + Bitmap bitmap = null; try { - WebClient c = new WebClient(); //m_log.Debug("JPEG: " + imageURL); - string filename = regionID.ToString(); - c.DownloadFile(imageURL, filename + ".jpg"); - Bitmap m = new Bitmap(filename + ".jpg"); + string name = regionID.ToString(); + filename = Path.Combine(storagePath, name + ".jpg"); + c.DownloadFile(imageURL, filename); + bitmap = new Bitmap(filename); //m_log.Debug("Size: " + m.PhysicalDimension.Height + "-" + m.PhysicalDimension.Width); - byte[] imageData = OpenJPEG.EncodeFromImage(m, true); - AssetBase ass = new AssetBase(UUID.Random(), "region " + filename, (sbyte)AssetType.Texture, regionID.ToString()); + byte[] imageData = OpenJPEG.EncodeFromImage(bitmap, true); + AssetBase ass = new AssetBase(UUID.Random(), "region " + name, (sbyte)AssetType.Texture, regionID.ToString()); // !!! for now //info.RegionSettings.TerrainImageID = ass.FullID; @@ -172,14 +174,13 @@ namespace OpenSim.Services.Connectors.Hypergrid m_AssetService.Store(ass); // finally - return ass.FullID; - + mapTile = ass.FullID; } catch // LEGIT: Catching problems caused by OpenJPEG p/invoke { m_log.Warn("[GATEKEEPER SERVICE CONNECTOR]: Failed getting/storing map image, because it is probably already in the cache"); } - return UUID.Zero; + return mapTile; } public GridRegion GetHyperlinkRegion(GridRegion gatekeeper, UUID regionID) -- cgit v1.1