diff options
author | Teravus Ovares | 2008-12-18 08:50:25 +0000 |
---|---|---|
committer | Teravus Ovares | 2008-12-18 08:50:25 +0000 |
commit | eb777b7373830effd53f616873af78b8c95a0949 (patch) | |
tree | 064da9f25935877d76bff3992bfc003244be1a8e | |
parent | * Added more articulate logging of HttpServer so we can diagnose issues. (diff) | |
download | opensim-SC-eb777b7373830effd53f616873af78b8c95a0949.zip opensim-SC-eb777b7373830effd53f616873af78b8c95a0949.tar.gz opensim-SC-eb777b7373830effd53f616873af78b8c95a0949.tar.bz2 opensim-SC-eb777b7373830effd53f616873af78b8c95a0949.tar.xz |
* Catch a WebException in the LoadImageURLModule
-rw-r--r-- | OpenSim/Region/Environment/Modules/Scripting/LoadImageURL/LoadImageURLModule.cs | 73 |
1 files changed, 40 insertions, 33 deletions
diff --git a/OpenSim/Region/Environment/Modules/Scripting/LoadImageURL/LoadImageURLModule.cs b/OpenSim/Region/Environment/Modules/Scripting/LoadImageURL/LoadImageURLModule.cs index 339ad42..631051b 100644 --- a/OpenSim/Region/Environment/Modules/Scripting/LoadImageURL/LoadImageURLModule.cs +++ b/OpenSim/Region/Environment/Modules/Scripting/LoadImageURL/LoadImageURLModule.cs | |||
@@ -133,42 +133,49 @@ namespace OpenSim.Region.Environment.Modules.Scripting.LoadImageURL | |||
133 | { | 133 | { |
134 | RequestState state = (RequestState) result.AsyncState; | 134 | RequestState state = (RequestState) result.AsyncState; |
135 | WebRequest request = (WebRequest) state.Request; | 135 | WebRequest request = (WebRequest) state.Request; |
136 | HttpWebResponse response = (HttpWebResponse) request.EndGetResponse(result); | 136 | try |
137 | if (response.StatusCode == HttpStatusCode.OK) | ||
138 | { | 137 | { |
139 | Bitmap image = new Bitmap(response.GetResponseStream()); | 138 | HttpWebResponse response = (HttpWebResponse)request.EndGetResponse(result); |
140 | Size newsize; | 139 | if (response.StatusCode == HttpStatusCode.OK) |
141 | |||
142 | // TODO: make this a bit less hard coded | ||
143 | if ((image.Height < 64) && (image.Width < 64)) | ||
144 | { | ||
145 | newsize = new Size(32, 32); | ||
146 | } | ||
147 | else if ((image.Height < 128) && (image.Width < 128)) | ||
148 | { | ||
149 | newsize = new Size(64, 64); | ||
150 | } | ||
151 | else if ((image.Height < 256) && (image.Width < 256)) | ||
152 | { | ||
153 | newsize = new Size(128, 128); | ||
154 | } | ||
155 | else if ((image.Height < 512 && image.Width < 512)) | ||
156 | { | 140 | { |
157 | newsize = new Size(256, 256); | 141 | Bitmap image = new Bitmap(response.GetResponseStream()); |
142 | Size newsize; | ||
143 | |||
144 | // TODO: make this a bit less hard coded | ||
145 | if ((image.Height < 64) && (image.Width < 64)) | ||
146 | { | ||
147 | newsize = new Size(32, 32); | ||
148 | } | ||
149 | else if ((image.Height < 128) && (image.Width < 128)) | ||
150 | { | ||
151 | newsize = new Size(64, 64); | ||
152 | } | ||
153 | else if ((image.Height < 256) && (image.Width < 256)) | ||
154 | { | ||
155 | newsize = new Size(128, 128); | ||
156 | } | ||
157 | else if ((image.Height < 512 && image.Width < 512)) | ||
158 | { | ||
159 | newsize = new Size(256, 256); | ||
160 | } | ||
161 | else if ((image.Height < 1024 && image.Width < 1024)) | ||
162 | { | ||
163 | newsize = new Size(512, 512); | ||
164 | } | ||
165 | else | ||
166 | { | ||
167 | newsize = new Size(1024, 1024); | ||
168 | } | ||
169 | |||
170 | Bitmap resize = new Bitmap(image, newsize); | ||
171 | byte[] imageJ2000 = OpenJPEG.EncodeFromImage(resize, true); | ||
172 | |||
173 | m_textureManager.ReturnData(state.RequestID, imageJ2000); | ||
158 | } | 174 | } |
159 | else if ((image.Height < 1024 && image.Width < 1024)) | 175 | } |
160 | { | 176 | catch (WebException) |
161 | newsize = new Size(512, 512); | 177 | { |
162 | } | 178 | |
163 | else | ||
164 | { | ||
165 | newsize = new Size(1024, 1024); | ||
166 | } | ||
167 | |||
168 | Bitmap resize = new Bitmap(image, newsize); | ||
169 | byte[] imageJ2000 = OpenJPEG.EncodeFromImage(resize, true); | ||
170 | |||
171 | m_textureManager.ReturnData(state.RequestID, imageJ2000); | ||
172 | } | 179 | } |
173 | } | 180 | } |
174 | 181 | ||