From 4cc5aac18bab0d8bdcf78bcb6f6c497ca4375d51 Mon Sep 17 00:00:00 2001 From: Sean Dague Date: Fri, 15 Feb 2008 15:55:23 +0000 Subject: be smarter about the size of dynamic textures that we pull in --- .../Environment/Modules/LoadImageURLModule.cs | 30 +++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/OpenSim/Region/Environment/Modules/LoadImageURLModule.cs b/OpenSim/Region/Environment/Modules/LoadImageURLModule.cs index dc894e4..0548b9d 100644 --- a/OpenSim/Region/Environment/Modules/LoadImageURLModule.cs +++ b/OpenSim/Region/Environment/Modules/LoadImageURLModule.cs @@ -126,7 +126,35 @@ namespace OpenSim.Region.Environment.Modules if (response.StatusCode == HttpStatusCode.OK) { Bitmap image = new Bitmap(response.GetResponseStream()); - Bitmap resize = new Bitmap(image, new Size(1024, 1024)); + Size newsize; + + // TODO: make this a bit less hard coded + if ((image.Height < 64) && (image.Width < 64)) + { + newsize = new Size(32, 32); + } + else if ((image.Height < 128) && (image.Width < 128)) + { + newsize = new Size(64, 64); + } + else if ((image.Height <256) && (image.Width < 256)) + { + newsize = new Size(128, 128); + } + else if ((image.Height < 512 && image.Width < 512)) + { + newsize = new Size(256, 256); + } + else if ((image.Height < 1024 && image.Width < 1024)) + { + newsize = new Size(512, 512); + } + else + { + newsize = new Size(1024,1024); + } + + Bitmap resize = new Bitmap(image, newsize); byte[] imageJ2000 = OpenJPEG.EncodeFromImage(resize, true); m_textureManager.ReturnData(state.RequestID, imageJ2000); -- cgit v1.1