From b11b67e7d76447adb6dffb014257cd1e6041cd34 Mon Sep 17 00:00:00 2001 From: Jim Radford Date: Wed, 16 Jul 2008 06:07:36 +0000 Subject: [PATCH] LIBOMV-282 Applies Patch from Dahlia Trimble which catches exception when baking is called with a bad or missing texture and allows baking to continue. git-svn-id: http://libopenmetaverse.googlecode.com/svn/trunk@1916 52acb1d6-8a22-11de-b505-999d5b087335 --- libsecondlife/BakeLayer.cs | 34 ++++++++++++++++++++++------------ 1 file changed, 22 insertions(+), 12 deletions(-) diff --git a/libsecondlife/BakeLayer.cs b/libsecondlife/BakeLayer.cs index 33ba2ad3..cb954087 100644 --- a/libsecondlife/BakeLayer.cs +++ b/libsecondlife/BakeLayer.cs @@ -235,21 +235,31 @@ namespace libsecondlife.Baking int i = 0; AssetTexture texture; - if (!_textures.TryGetValue(textureIndex, out texture)) - return false; + Image source; - Image source = texture.Image; - - bool sourceHasAlpha = ((source.Channels & ImageChannels.Alpha) != 0 && source.Alpha != null); - bool sourceHasBump = ((source.Channels & ImageChannels.Bump) != 0 && source.Bump != null); + bool sourceHasAlpha; + bool sourceHasBump; + bool copySourceAlphaToBakedLayer; - bool copySourceAlphaToBakedLayer = sourceHasAlpha && ( - textureIndex == AppearanceManager.TextureIndex.HeadBodypaint || - textureIndex == AppearanceManager.TextureIndex.Skirt - ); + try + { + if (!_textures.TryGetValue(textureIndex, out texture)) + return false; - if (source.Width != _bakeWidth || source.Height != _bakeHeight) - source.ResizeNearestNeighbor(_bakeWidth, _bakeHeight); + source = texture.Image; + + sourceHasAlpha = ((source.Channels & ImageChannels.Alpha) != 0 && source.Alpha != null); + sourceHasBump = ((source.Channels & ImageChannels.Bump) != 0 && source.Bump != null); + + copySourceAlphaToBakedLayer = sourceHasAlpha && ( + textureIndex == AppearanceManager.TextureIndex.HeadBodypaint || + textureIndex == AppearanceManager.TextureIndex.Skirt + ); + + if (source.Width != _bakeWidth || source.Height != _bakeHeight) + source.ResizeNearestNeighbor(_bakeWidth, _bakeHeight); + } + catch { return false; } int alpha = 255; //int alphaInv = 255 - alpha;