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