* Catch a WebException in the LoadImageURLModule
parent
f4acaafd3a
commit
eb777b7373
|
@ -133,42 +133,49 @@ namespace OpenSim.Region.Environment.Modules.Scripting.LoadImageURL
|
||||||
{
|
{
|
||||||
RequestState state = (RequestState) result.AsyncState;
|
RequestState state = (RequestState) result.AsyncState;
|
||||||
WebRequest request = (WebRequest) state.Request;
|
WebRequest request = (WebRequest) state.Request;
|
||||||
HttpWebResponse response = (HttpWebResponse) request.EndGetResponse(result);
|
try
|
||||||
if (response.StatusCode == HttpStatusCode.OK)
|
|
||||||
{
|
{
|
||||||
Bitmap image = new Bitmap(response.GetResponseStream());
|
HttpWebResponse response = (HttpWebResponse)request.EndGetResponse(result);
|
||||||
Size newsize;
|
if (response.StatusCode == HttpStatusCode.OK)
|
||||||
|
{
|
||||||
|
Bitmap image = new Bitmap(response.GetResponseStream());
|
||||||
|
Size newsize;
|
||||||
|
|
||||||
// TODO: make this a bit less hard coded
|
// TODO: make this a bit less hard coded
|
||||||
if ((image.Height < 64) && (image.Width < 64))
|
if ((image.Height < 64) && (image.Width < 64))
|
||||||
{
|
{
|
||||||
newsize = new Size(32, 32);
|
newsize = new Size(32, 32);
|
||||||
}
|
}
|
||||||
else if ((image.Height < 128) && (image.Width < 128))
|
else if ((image.Height < 128) && (image.Width < 128))
|
||||||
{
|
{
|
||||||
newsize = new Size(64, 64);
|
newsize = new Size(64, 64);
|
||||||
}
|
}
|
||||||
else if ((image.Height < 256) && (image.Width < 256))
|
else if ((image.Height < 256) && (image.Width < 256))
|
||||||
{
|
{
|
||||||
newsize = new Size(128, 128);
|
newsize = new Size(128, 128);
|
||||||
}
|
}
|
||||||
else if ((image.Height < 512 && image.Width < 512))
|
else if ((image.Height < 512 && image.Width < 512))
|
||||||
{
|
{
|
||||||
newsize = new Size(256, 256);
|
newsize = new Size(256, 256);
|
||||||
}
|
}
|
||||||
else if ((image.Height < 1024 && image.Width < 1024))
|
else if ((image.Height < 1024 && image.Width < 1024))
|
||||||
{
|
{
|
||||||
newsize = new Size(512, 512);
|
newsize = new Size(512, 512);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
newsize = new Size(1024, 1024);
|
newsize = new Size(1024, 1024);
|
||||||
}
|
}
|
||||||
|
|
||||||
Bitmap resize = new Bitmap(image, newsize);
|
Bitmap resize = new Bitmap(image, newsize);
|
||||||
byte[] imageJ2000 = OpenJPEG.EncodeFromImage(resize, true);
|
byte[] imageJ2000 = OpenJPEG.EncodeFromImage(resize, true);
|
||||||
|
|
||||||
m_textureManager.ReturnData(state.RequestID, imageJ2000);
|
m_textureManager.ReturnData(state.RequestID, imageJ2000);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (WebException)
|
||||||
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue