workaround potencial memory leaks
parent
426e8a798f
commit
c8a1d7e5a7
|
@ -47,8 +47,7 @@ namespace OpenSim.Region.CoreModules.World.Terrain.FileLoaders
|
|||
/// <param name="map">The terrain channel being saved</param>
|
||||
public override void SaveFile(string filename, ITerrainChannel map)
|
||||
{
|
||||
Bitmap colours = CreateGrayscaleBitmapFromMap(map);
|
||||
|
||||
using(Bitmap colours = CreateGrayscaleBitmapFromMap(map))
|
||||
colours.Save(filename,ImageFormat.Bmp);
|
||||
}
|
||||
|
||||
|
@ -59,8 +58,7 @@ namespace OpenSim.Region.CoreModules.World.Terrain.FileLoaders
|
|||
/// <param name="map">The terrain channel being saved</param>
|
||||
public override void SaveStream(Stream stream, ITerrainChannel map)
|
||||
{
|
||||
Bitmap colours = CreateGrayscaleBitmapFromMap(map);
|
||||
|
||||
using(Bitmap colours = CreateGrayscaleBitmapFromMap(map))
|
||||
colours.Save(stream,ImageFormat.Bmp);
|
||||
}
|
||||
|
||||
|
|
|
@ -36,8 +36,7 @@ namespace OpenSim.Region.CoreModules.World.Terrain.FileLoaders
|
|||
{
|
||||
public override void SaveFile(string filename, ITerrainChannel map)
|
||||
{
|
||||
Bitmap colours = CreateGrayscaleBitmapFromMap(map);
|
||||
|
||||
using(Bitmap colours = CreateGrayscaleBitmapFromMap(map))
|
||||
colours.Save(filename,ImageFormat.Gif);
|
||||
}
|
||||
|
||||
|
@ -48,8 +47,7 @@ namespace OpenSim.Region.CoreModules.World.Terrain.FileLoaders
|
|||
/// <param name="map">The terrain channel being saved</param>
|
||||
public override void SaveStream(Stream stream, ITerrainChannel map)
|
||||
{
|
||||
Bitmap colours = CreateGrayscaleBitmapFromMap(map);
|
||||
|
||||
using(Bitmap colours = CreateGrayscaleBitmapFromMap(map))
|
||||
colours.Save(stream,ImageFormat.Gif);
|
||||
}
|
||||
|
||||
|
|
|
@ -111,8 +111,7 @@ namespace OpenSim.Region.CoreModules.World.Terrain.FileLoaders
|
|||
/// <param name="map">The terrain channel being saved</param>
|
||||
public virtual void SaveFile(string filename, ITerrainChannel map)
|
||||
{
|
||||
Bitmap colours = CreateGrayscaleBitmapFromMap(map);
|
||||
|
||||
using(Bitmap colours = CreateGrayscaleBitmapFromMap(map))
|
||||
colours.Save(filename,ImageFormat.Png);
|
||||
}
|
||||
|
||||
|
@ -123,8 +122,7 @@ namespace OpenSim.Region.CoreModules.World.Terrain.FileLoaders
|
|||
/// <param name="map">The terrain channel being saved</param>
|
||||
public virtual void SaveStream(Stream stream, ITerrainChannel map)
|
||||
{
|
||||
Bitmap colours = CreateGrayscaleBitmapFromMap(map);
|
||||
|
||||
using(Bitmap colours = CreateGrayscaleBitmapFromMap(map))
|
||||
colours.Save(stream,ImageFormat.Png);
|
||||
}
|
||||
|
||||
|
|
|
@ -59,8 +59,7 @@ namespace OpenSim.Region.CoreModules.World.Terrain.FileLoaders
|
|||
|
||||
public void SaveFile(string filename, ITerrainChannel map)
|
||||
{
|
||||
Bitmap colours = CreateBitmapFromMap(map);
|
||||
|
||||
using(Bitmap colours = CreateBitmapFromMap(map))
|
||||
colours.Save(filename,ImageFormat.Jpeg);
|
||||
}
|
||||
|
||||
|
@ -71,8 +70,7 @@ namespace OpenSim.Region.CoreModules.World.Terrain.FileLoaders
|
|||
/// <param name="map">The terrain channel being saved</param>
|
||||
public void SaveStream(Stream stream, ITerrainChannel map)
|
||||
{
|
||||
Bitmap colours = CreateBitmapFromMap(map);
|
||||
|
||||
using(Bitmap colours = CreateBitmapFromMap(map))
|
||||
colours.Save(stream,ImageFormat.Jpeg);
|
||||
}
|
||||
|
||||
|
|
|
@ -36,8 +36,7 @@ namespace OpenSim.Region.CoreModules.World.Terrain.FileLoaders
|
|||
{
|
||||
public override void SaveFile(string filename, ITerrainChannel map)
|
||||
{
|
||||
Bitmap colours = CreateGrayscaleBitmapFromMap(map);
|
||||
|
||||
using(Bitmap colours = CreateGrayscaleBitmapFromMap(map))
|
||||
colours.Save(filename,ImageFormat.Png);
|
||||
}
|
||||
|
||||
|
@ -48,8 +47,7 @@ namespace OpenSim.Region.CoreModules.World.Terrain.FileLoaders
|
|||
/// <param name="map">The terrain channel being saved</param>
|
||||
public override void SaveStream(Stream stream, ITerrainChannel map)
|
||||
{
|
||||
Bitmap colours = CreateGrayscaleBitmapFromMap(map);
|
||||
|
||||
using(Bitmap colours = CreateGrayscaleBitmapFromMap(map))
|
||||
colours.Save(stream,ImageFormat.Png);
|
||||
}
|
||||
|
||||
|
|
|
@ -36,8 +36,7 @@ namespace OpenSim.Region.CoreModules.World.Terrain.FileLoaders
|
|||
{
|
||||
public override void SaveFile(string filename, ITerrainChannel map)
|
||||
{
|
||||
Bitmap colours = CreateGrayscaleBitmapFromMap(map);
|
||||
|
||||
using(Bitmap colours = CreateGrayscaleBitmapFromMap(map))
|
||||
colours.Save(filename,ImageFormat.Tiff);
|
||||
}
|
||||
|
||||
|
@ -48,8 +47,7 @@ namespace OpenSim.Region.CoreModules.World.Terrain.FileLoaders
|
|||
/// <param name="map">The terrain channel being saved</param>
|
||||
public override void SaveStream(Stream stream, ITerrainChannel map)
|
||||
{
|
||||
Bitmap colours = CreateGrayscaleBitmapFromMap(map);
|
||||
|
||||
using(Bitmap colours = CreateGrayscaleBitmapFromMap(map))
|
||||
colours.Save(stream,ImageFormat.Tiff);
|
||||
}
|
||||
|
||||
|
|
|
@ -69,16 +69,8 @@ namespace PrimMesher
|
|||
needsScaling = true;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
if (needsScaling)
|
||||
bm = ScaleImage(bm, width, height);
|
||||
}
|
||||
|
||||
catch (Exception e)
|
||||
{
|
||||
throw new Exception("Exception in ScaleImage(): e: " + e.ToString());
|
||||
}
|
||||
|
||||
if (width * height > numLodPixels)
|
||||
{
|
||||
|
@ -129,11 +121,15 @@ namespace PrimMesher
|
|||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
if (needsScaling)
|
||||
bm.Dispose();
|
||||
throw new Exception("Caught exception processing byte arrays in SculptMap(): e: " + e.ToString());
|
||||
}
|
||||
|
||||
width++;
|
||||
height++;
|
||||
if(needsScaling)
|
||||
bm.Dispose();
|
||||
}
|
||||
|
||||
public List<List<Coord>> ToRows(bool mirror)
|
||||
|
@ -168,12 +164,10 @@ namespace PrimMesher
|
|||
|
||||
private Bitmap ScaleImage(Bitmap srcImage, int destWidth, int destHeight)
|
||||
{
|
||||
|
||||
Bitmap scaledImage = new Bitmap(destWidth, destHeight, PixelFormat.Format24bppRgb);
|
||||
|
||||
Color c;
|
||||
|
||||
|
||||
// will let last step to be eventually diferent, as seems to be in sl
|
||||
|
||||
float xscale = (float)srcImage.Width / (float)destWidth;
|
||||
|
|
Loading…
Reference in New Issue