aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Services/Connectors/Hypergrid/GatekeeperServiceConnector.cs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Services/Connectors/Hypergrid/GatekeeperServiceConnector.cs36
1 files changed, 19 insertions, 17 deletions
diff --git a/OpenSim/Services/Connectors/Hypergrid/GatekeeperServiceConnector.cs b/OpenSim/Services/Connectors/Hypergrid/GatekeeperServiceConnector.cs
index 85c1380..a1d9167 100644
--- a/OpenSim/Services/Connectors/Hypergrid/GatekeeperServiceConnector.cs
+++ b/OpenSim/Services/Connectors/Hypergrid/GatekeeperServiceConnector.cs
@@ -29,6 +29,7 @@ using System;
29using System.Collections; 29using System.Collections;
30using System.Collections.Generic; 30using System.Collections.Generic;
31using System.Drawing; 31using System.Drawing;
32using System.IO;
32using System.Net; 33using System.Net;
33using System.Reflection; 34using System.Reflection;
34using OpenSim.Framework; 35using OpenSim.Framework;
@@ -48,7 +49,7 @@ namespace OpenSim.Services.Connectors.Hypergrid
48 { 49 {
49 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 50 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
50 51
51// private static UUID m_HGMapImage = new UUID("00000000-0000-1111-9999-000000000013"); 52 private static UUID m_HGMapImage = new UUID("00000000-0000-1111-9999-000000000013");
52 53
53 private IAssetService m_AssetService; 54 private IAssetService m_AssetService;
54 55
@@ -143,43 +144,44 @@ namespace OpenSim.Services.Connectors.Hypergrid
143 return true; 144 return true;
144 } 145 }
145 146
146 UUID m_MissingTexture = new UUID("5748decc-f629-461c-9a36-a35a221fe21f"); 147 public UUID GetMapImage(UUID regionID, string imageURL, string storagePath)
147
148 public UUID GetMapImage(UUID regionID, string imageURL)
149 { 148 {
150 if (m_AssetService == null) 149 if (m_AssetService == null)
151 return m_MissingTexture; 150 {
151 m_log.DebugFormat("[GATEKEEPER SERVICE CONNECTOR]: No AssetService defined. Map tile not retrieved.");
152 return m_HGMapImage;
153 }
152 154
155 UUID mapTile = m_HGMapImage;
156 string filename = string.Empty;
157 Bitmap bitmap = null;
153 try 158 try
154 { 159 {
155
156 WebClient c = new WebClient(); 160 WebClient c = new WebClient();
157 //m_log.Debug("JPEG: " + imageURL); 161 //m_log.Debug("JPEG: " + imageURL);
158 string filename = regionID.ToString(); 162 string name = regionID.ToString();
159 c.DownloadFile(imageURL, filename + ".jpg"); 163 filename = Path.Combine(storagePath, name + ".jpg");
160 Bitmap m = new Bitmap(filename + ".jpg"); 164 c.DownloadFile(imageURL, filename);
165 bitmap = new Bitmap(filename);
161 //m_log.Debug("Size: " + m.PhysicalDimension.Height + "-" + m.PhysicalDimension.Width); 166 //m_log.Debug("Size: " + m.PhysicalDimension.Height + "-" + m.PhysicalDimension.Width);
162 byte[] imageData = OpenJPEG.EncodeFromImage(m, true); 167 byte[] imageData = OpenJPEG.EncodeFromImage(bitmap, true);
163 AssetBase ass = new AssetBase(UUID.Random(), "region " + filename, (sbyte)AssetType.Texture, regionID.ToString()); 168 AssetBase ass = new AssetBase(UUID.Random(), "region " + name, (sbyte)AssetType.Texture, regionID.ToString());
164 169
165 // !!! for now 170 // !!! for now
166 //info.RegionSettings.TerrainImageID = ass.FullID; 171 //info.RegionSettings.TerrainImageID = ass.FullID;
167 172
168 ass.Temporary = true;
169 ass.Local = true;
170 ass.Data = imageData; 173 ass.Data = imageData;
171 174
172 m_AssetService.Store(ass); 175 m_AssetService.Store(ass);
173 176
174 // finally 177 // finally
175 return ass.FullID; 178 mapTile = ass.FullID;
176
177 } 179 }
178 catch // LEGIT: Catching problems caused by OpenJPEG p/invoke 180 catch // LEGIT: Catching problems caused by OpenJPEG p/invoke
179 { 181 {
180 m_log.Warn("[GATEKEEPER SERVICE CONNECTOR]: Failed getting/storing map image, because it is probably already in the cache"); 182 m_log.Info("[GATEKEEPER SERVICE CONNECTOR]: Failed getting/storing map image, because it is probably already in the cache");
181 } 183 }
182 return UUID.Zero; 184 return mapTile;
183 } 185 }
184 186
185 public GridRegion GetHyperlinkRegion(GridRegion gatekeeper, UUID regionID) 187 public GridRegion GetHyperlinkRegion(GridRegion gatekeeper, UUID regionID)