From ec6a195e40ad570a6e812c952f0505e76e7323d1 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Sat, 14 Jul 2012 01:11:30 +0100 Subject: When generating a Warp3D texture, set the detailTexture[i] variable on resize from the JPEG2000 original rather than only saving it to disk. This appears to be the cause of the warp 3d exception seen when starting a new region for the first time. Subsequent starts were okay because resized saved bitmap was correctly retrieved from disk. Should fix http://opensimulator.org/mantis/view.php?id=5204 and http://opensimulator.org/mantis/view.php?id=5272 --- .../CoreModules/World/Warp3DMap/TerrainSplat.cs | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/OpenSim/Region/CoreModules/World/Warp3DMap/TerrainSplat.cs b/OpenSim/Region/CoreModules/World/Warp3DMap/TerrainSplat.cs index 91252f7..df5ac92 100644 --- a/OpenSim/Region/CoreModules/World/Warp3DMap/TerrainSplat.cs +++ b/OpenSim/Region/CoreModules/World/Warp3DMap/TerrainSplat.cs @@ -111,6 +111,9 @@ namespace OpenSim.Region.CoreModules.World.Warp3DMap asset = assetService.GetCached(cacheID.ToString()); if (asset != null) { +// m_log.DebugFormat( +// "[TERRAIN SPLAT]: Got asset service cached terrain texture {0} {1}", i, asset.ID); + try { using (System.IO.MemoryStream stream = new System.IO.MemoryStream(asset.Data)) @@ -129,6 +132,9 @@ namespace OpenSim.Region.CoreModules.World.Warp3DMap asset = assetService.Get(textureIDs[i].ToString()); if (asset != null) { +// m_log.DebugFormat( +// "[TERRAIN SPLAT]: Got cached original JPEG2000 terrain texture {0} {1}", i, asset.ID); + try { detailTexture[i] = (Bitmap)CSJ2K.J2kImage.FromBytes(asset.Data); } catch (Exception ex) { @@ -137,15 +143,13 @@ namespace OpenSim.Region.CoreModules.World.Warp3DMap } if (detailTexture[i] != null) - { - Bitmap bitmap = detailTexture[i]; - + { // Make sure this texture is the correct size, otherwise resize - if (bitmap.Width != 256 || bitmap.Height != 256) + if (detailTexture[i].Width != 256 || detailTexture[i].Height != 256) { - using (Bitmap origBitmap = bitmap) + using (Bitmap origBitmap = detailTexture[i]) { - bitmap = ImageUtils.ResizeImage(origBitmap, 256, 256); + detailTexture[i] = ImageUtils.ResizeImage(origBitmap, 256, 256); } } @@ -153,7 +157,7 @@ namespace OpenSim.Region.CoreModules.World.Warp3DMap byte[] data; using (System.IO.MemoryStream stream = new System.IO.MemoryStream()) { - bitmap.Save(stream, ImageFormat.Png); + detailTexture[i].Save(stream, ImageFormat.Png); data = stream.ToArray(); } @@ -185,6 +189,9 @@ namespace OpenSim.Region.CoreModules.World.Warp3DMap { if (detailTexture[i] == null) { +// m_log.DebugFormat( +// "[TERRAIN SPLAT]: Generating solid colour for missing texture {0}", i); + // Create a solid color texture for this layer detailTexture[i] = new Bitmap(256, 256, PixelFormat.Format24bppRgb); using (Graphics gfx = Graphics.FromImage(detailTexture[i])) -- cgit v1.1