From 8d31e2d36f78498649be3c44f5d4173c5e5d4616 Mon Sep 17 00:00:00 2001 From: Jim Radford Date: Fri, 15 Jan 2010 04:30:13 +0000 Subject: [PATCH] LIBOMV-785 Applies Patch from Sheet Spotter (what an obscene choice for a name) Which fixes alpha channel decode issue git-svn-id: http://libopenmetaverse.googlecode.com/svn/libopenmetaverse/trunk@3244 52acb1d6-8a22-11de-b505-999d5b087335 --- OpenMetaverse/Imaging/TGALoader.cs | 13 ++++++++++--- Programs/WinGridProxy/FormWinGridProxy.cs | 2 ++ 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/OpenMetaverse/Imaging/TGALoader.cs b/OpenMetaverse/Imaging/TGALoader.cs index d50176d2..e09affa1 100644 --- a/OpenMetaverse/Imaging/TGALoader.cs +++ b/OpenMetaverse/Imaging/TGALoader.cs @@ -455,11 +455,18 @@ namespace OpenMetaverse.Imaging throw new ArgumentException("Image too large."); System.Drawing.Bitmap b = new System.Drawing.Bitmap( - header.ImageSpec.Width, header.ImageSpec.Height); + header.ImageSpec.Width, + header.ImageSpec.Height, + header.ImageSpec.AlphaBits > 0 + ? System.Drawing.Imaging.PixelFormat.Format32bppArgb + : System.Drawing.Imaging.PixelFormat.Format32bppRgb); - System.Drawing.Imaging.BitmapData bd = b.LockBits(new System.Drawing.Rectangle(0, 0, b.Width, b.Height), + System.Drawing.Imaging.BitmapData bd = b.LockBits(new System.Drawing.Rectangle(0, 0, b.Width, b.Height), System.Drawing.Imaging.ImageLockMode.WriteOnly, - System.Drawing.Imaging.PixelFormat.Format32bppPArgb); + header.ImageSpec.AlphaBits > 0 + ? System.Drawing.Imaging.PixelFormat.Format32bppPArgb + : System.Drawing.Imaging.PixelFormat.Format32bppRgb); + switch (header.ImageSpec.PixelDepth) { case 8: diff --git a/Programs/WinGridProxy/FormWinGridProxy.cs b/Programs/WinGridProxy/FormWinGridProxy.cs index 70290c07..e3a7f81a 100644 --- a/Programs/WinGridProxy/FormWinGridProxy.cs +++ b/Programs/WinGridProxy/FormWinGridProxy.cs @@ -118,6 +118,8 @@ namespace WinGridProxy FireEventAppender.Instance.MessageLoggedEvent += new MessageLoggedEventHandler(Instance_MessageLoggedEvent); } + + // Attempt to work around some mono inefficiencies monoRuntime = Type.GetType("Mono.Runtime") != null; // Officially supported way of detecting mono if (monoRuntime)