DynamicTextureModule memory leaks

LSLKeyTest
UbitUmarov 2016-08-24 01:05:01 +01:00
parent 35cc0420c8
commit 6744ec95a9
1 changed files with 41 additions and 34 deletions

View File

@ -553,18 +553,28 @@ namespace OpenSim.Region.CoreModules.Scripting.DynamicTexture
ManagedImage managedImage; ManagedImage managedImage;
Image image; Image image;
if (OpenJPEG.DecodeToImage(frontImage, out managedImage, out image)) if (!OpenJPEG.DecodeToImage(frontImage, out managedImage, out image) || image == null)
{ return null;
Bitmap image1 = new Bitmap(image);
if (OpenJPEG.DecodeToImage(backImage, out managedImage, out image)) Bitmap image1 = new Bitmap(image);
image.Dispose();
if (!OpenJPEG.DecodeToImage(backImage, out managedImage, out image) || image == null)
{ {
image1.Dispose();
return null;
}
Bitmap image2 = new Bitmap(image); Bitmap image2 = new Bitmap(image);
image.Dispose();
if (setNewAlpha) if (setNewAlpha)
SetAlpha(ref image1, newAlpha); SetAlpha(ref image1, newAlpha);
Bitmap joint = MergeBitMaps(image1, image2); using(Bitmap joint = MergeBitMaps(image1, image2))
{
image1.Dispose();
image2.Dispose();
byte[] result = new byte[0]; byte[] result = new byte[0];
@ -583,22 +593,19 @@ namespace OpenSim.Region.CoreModules.Scripting.DynamicTexture
} }
} }
return null;
}
public Bitmap MergeBitMaps(Bitmap front, Bitmap back) public Bitmap MergeBitMaps(Bitmap front, Bitmap back)
{ {
Bitmap joint; Bitmap joint;
Graphics jG; Graphics jG;
joint = new Bitmap(back.Width, back.Height, PixelFormat.Format32bppArgb); joint = new Bitmap(back.Width, back.Height, PixelFormat.Format32bppArgb);
jG = Graphics.FromImage(joint); using(jG = Graphics.FromImage(joint))
{
jG.DrawImage(back, 0, 0, back.Width, back.Height); jG.DrawImage(back, 0, 0, back.Width, back.Height);
jG.DrawImage(front, 0, 0, back.Width, back.Height); jG.DrawImage(front, 0, 0, back.Width, back.Height);
return joint; return joint;
} }
}
private void SetAlpha(ref Bitmap b, byte alpha) private void SetAlpha(ref Bitmap b, byte alpha)
{ {