aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/CoreModules/Scripting/LoadImageURL
diff options
context:
space:
mode:
authorDr Scofield2009-05-22 16:22:49 +0000
committerDr Scofield2009-05-22 16:22:49 +0000
commit3b689e506f82ea45fcf703b22eb50a00e40baa4f (patch)
tree4c99a98342400d3f9f49670e3f6754554d3c8235 /OpenSim/Region/CoreModules/Scripting/LoadImageURL
parentFrom: Alan Webb <alan_webb@us.ibm.com> (diff)
downloadopensim-SC_OLD-3b689e506f82ea45fcf703b22eb50a00e40baa4f.zip
opensim-SC_OLD-3b689e506f82ea45fcf703b22eb50a00e40baa4f.tar.gz
opensim-SC_OLD-3b689e506f82ea45fcf703b22eb50a00e40baa4f.tar.bz2
opensim-SC_OLD-3b689e506f82ea45fcf703b22eb50a00e40baa4f.tar.xz
From: Alan Webb <alan_webb@us.ibm.com>
Changes to support client-side image pre-caching in the region. This commit adds an additional calling sequence to the DynamicTexture data and URL calls. The new interface allows a dynamic image to be loaded into a specific object face (rather than the mandatory ALL_SIDES supported today. This is in part fulfilment of ticket #458.
Diffstat (limited to 'OpenSim/Region/CoreModules/Scripting/LoadImageURL')
-rw-r--r--OpenSim/Region/CoreModules/Scripting/LoadImageURL/LoadImageURLModule.cs96
1 files changed, 57 insertions, 39 deletions
diff --git a/OpenSim/Region/CoreModules/Scripting/LoadImageURL/LoadImageURLModule.cs b/OpenSim/Region/CoreModules/Scripting/LoadImageURL/LoadImageURLModule.cs
index 864d6ac..61c37b9 100644
--- a/OpenSim/Region/CoreModules/Scripting/LoadImageURL/LoadImageURLModule.cs
+++ b/OpenSim/Region/CoreModules/Scripting/LoadImageURL/LoadImageURLModule.cs
@@ -162,62 +162,80 @@ namespace OpenSim.Region.CoreModules.Scripting.LoadImageURL
162 162
163 private void HttpRequestReturn(IAsyncResult result) 163 private void HttpRequestReturn(IAsyncResult result)
164 { 164 {
165
165 RequestState state = (RequestState) result.AsyncState; 166 RequestState state = (RequestState) result.AsyncState;
166 WebRequest request = (WebRequest) state.Request; 167 WebRequest request = (WebRequest) state.Request;
168 Stream stream = null;
169 byte[] imageJ2000 = new byte[0];
170
167 try 171 try
168 { 172 {
169 HttpWebResponse response = (HttpWebResponse)request.EndGetResponse(result); 173 HttpWebResponse response = (HttpWebResponse)request.EndGetResponse(result);
170 if (response.StatusCode == HttpStatusCode.OK) 174 if (response != null && response.StatusCode == HttpStatusCode.OK)
171 { 175 {
172 Bitmap image = new Bitmap(response.GetResponseStream()); 176 stream = response.GetResponseStream();
173 Size newsize; 177 if(stream != null)
174
175 // TODO: make this a bit less hard coded
176 if ((image.Height < 64) && (image.Width < 64))
177 {
178 newsize = new Size(32, 32);
179 }
180 else if ((image.Height < 128) && (image.Width < 128))
181 {
182 newsize = new Size(64, 64);
183 }
184 else if ((image.Height < 256) && (image.Width < 256))
185 {
186 newsize = new Size(128, 128);
187 }
188 else if ((image.Height < 512 && image.Width < 512))
189 {
190 newsize = new Size(256, 256);
191 }
192 else if ((image.Height < 1024 && image.Width < 1024))
193 { 178 {
194 newsize = new Size(512, 512); 179 Bitmap image = new Bitmap(stream);
180 Size newsize;
181
182 // TODO: make this a bit less hard coded
183 if ((image.Height < 64) && (image.Width < 64))
184 {
185 newsize = new Size(32, 32);
186 }
187 else if ((image.Height < 128) && (image.Width < 128))
188 {
189 newsize = new Size(64, 64);
190 }
191 else if ((image.Height < 256) && (image.Width < 256))
192 {
193 newsize = new Size(128, 128);
194 }
195 else if ((image.Height < 512 && image.Width < 512))
196 {
197 newsize = new Size(256, 256);
198 }
199 else if ((image.Height < 1024 && image.Width < 1024))
200 {
201 newsize = new Size(512, 512);
202 }
203 else
204 {
205 newsize = new Size(1024, 1024);
206 }
207
208 Bitmap resize = new Bitmap(image, newsize);
209
210 try
211 {
212 imageJ2000 = OpenJPEG.EncodeFromImage(resize, true);
213 }
214 catch (Exception)
215 {
216 m_log.Error("[LOADIMAGEURLMODULE]: OpenJpeg Encode Failed. Empty byte data returned!");
217 }
195 } 218 }
196 else 219 else
197 { 220 {
198 newsize = new Size(1024, 1024); 221 m_log.WarnFormat("[LOADIMAGEURLMODULE] No data returned");
199 }
200
201 Bitmap resize = new Bitmap(image, newsize);
202 byte[] imageJ2000 = new byte[0];
203
204 try
205 {
206 imageJ2000 = OpenJPEG.EncodeFromImage(resize, true);
207 }
208 catch (Exception)
209 {
210 m_log.Error("[LOADIMAGEURLMODULE]: OpenJpeg Encode Failed. Empty byte data returned!");
211 } 222 }
212
213 m_textureManager.ReturnData(state.RequestID, imageJ2000);
214 return;
215 } 223 }
216 } 224 }
217 catch (WebException) 225 catch (WebException)
218 { 226 {
219 227
220 } 228 }
229 finally
230 {
231 if(stream != null)
232 {
233 stream.Close();
234 }
235 }
236 m_log.DebugFormat("[LOADIMAGEURLMODULE] Returning {0} bytes of image data for request {1}",
237 imageJ2000.Length, state.RequestID);
238 m_textureManager.ReturnData(state.RequestID, imageJ2000);
221 } 239 }
222 240
223 #region Nested type: RequestState 241 #region Nested type: RequestState