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>
|
||||
public override void SaveFile(string filename, ITerrainChannel map)
|
||||
{
|
||||
Bitmap colours = CreateGrayscaleBitmapFromMap(map);
|
||||
|
||||
colours.Save(filename, ImageFormat.Bmp);
|
||||
using(Bitmap colours = CreateGrayscaleBitmapFromMap(map))
|
||||
colours.Save(filename,ImageFormat.Bmp);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -59,9 +58,8 @@ 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);
|
||||
|
||||
colours.Save(stream, ImageFormat.Bmp);
|
||||
using(Bitmap colours = CreateGrayscaleBitmapFromMap(map))
|
||||
colours.Save(stream,ImageFormat.Bmp);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
@ -36,9 +36,8 @@ namespace OpenSim.Region.CoreModules.World.Terrain.FileLoaders
|
|||
{
|
||||
public override void SaveFile(string filename, ITerrainChannel map)
|
||||
{
|
||||
Bitmap colours = CreateGrayscaleBitmapFromMap(map);
|
||||
|
||||
colours.Save(filename, ImageFormat.Gif);
|
||||
using(Bitmap colours = CreateGrayscaleBitmapFromMap(map))
|
||||
colours.Save(filename,ImageFormat.Gif);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -48,9 +47,8 @@ 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);
|
||||
|
||||
colours.Save(stream, ImageFormat.Gif);
|
||||
using(Bitmap colours = CreateGrayscaleBitmapFromMap(map))
|
||||
colours.Save(stream,ImageFormat.Gif);
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
|
|
|
@ -59,7 +59,7 @@ namespace OpenSim.Region.CoreModules.World.Terrain.FileLoaders
|
|||
/// <returns>A terrain channel generated from the image.</returns>
|
||||
public virtual ITerrainChannel LoadFile(string filename)
|
||||
{
|
||||
using (Bitmap b = new Bitmap(filename))
|
||||
using(Bitmap b = new Bitmap(filename))
|
||||
return LoadBitmap(b);
|
||||
}
|
||||
|
||||
|
@ -111,9 +111,8 @@ 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);
|
||||
|
||||
colours.Save(filename, ImageFormat.Png);
|
||||
using(Bitmap colours = CreateGrayscaleBitmapFromMap(map))
|
||||
colours.Save(filename,ImageFormat.Png);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -123,9 +122,8 @@ 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);
|
||||
|
||||
colours.Save(stream, ImageFormat.Png);
|
||||
using(Bitmap colours = CreateGrayscaleBitmapFromMap(map))
|
||||
colours.Save(stream,ImageFormat.Png);
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
Bitmap colours = CreateBitmapFromMap(map);
|
||||
|
||||
colours.Save(filename, ImageFormat.Jpeg);
|
||||
using(Bitmap colours = CreateBitmapFromMap(map))
|
||||
colours.Save(filename,ImageFormat.Jpeg);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -71,9 +70,8 @@ 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);
|
||||
|
||||
colours.Save(stream, ImageFormat.Jpeg);
|
||||
using(Bitmap colours = CreateBitmapFromMap(map))
|
||||
colours.Save(stream,ImageFormat.Jpeg);
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
Bitmap colours = CreateGrayscaleBitmapFromMap(map);
|
||||
|
||||
colours.Save(filename, ImageFormat.Png);
|
||||
using(Bitmap colours = CreateGrayscaleBitmapFromMap(map))
|
||||
colours.Save(filename,ImageFormat.Png);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -48,9 +47,8 @@ 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);
|
||||
|
||||
colours.Save(stream, ImageFormat.Png);
|
||||
using(Bitmap colours = CreateGrayscaleBitmapFromMap(map))
|
||||
colours.Save(stream,ImageFormat.Png);
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
|
|
|
@ -36,9 +36,8 @@ namespace OpenSim.Region.CoreModules.World.Terrain.FileLoaders
|
|||
{
|
||||
public override void SaveFile(string filename, ITerrainChannel map)
|
||||
{
|
||||
Bitmap colours = CreateGrayscaleBitmapFromMap(map);
|
||||
|
||||
colours.Save(filename, ImageFormat.Tiff);
|
||||
using(Bitmap colours = CreateGrayscaleBitmapFromMap(map))
|
||||
colours.Save(filename,ImageFormat.Tiff);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -48,9 +47,8 @@ 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);
|
||||
|
||||
colours.Save(stream, ImageFormat.Tiff);
|
||||
using(Bitmap colours = CreateGrayscaleBitmapFromMap(map))
|
||||
colours.Save(stream,ImageFormat.Tiff);
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
|
|
|
@ -57,7 +57,7 @@ namespace PrimMesher
|
|||
int numLodPixels = lod * lod; // (32 * 2)^2 = 64^2 pixels for default sculpt map image
|
||||
|
||||
bool needsScaling = false;
|
||||
bool smallMap = false;
|
||||
bool smallMap = false;
|
||||
|
||||
width = bmW;
|
||||
height = bmH;
|
||||
|
@ -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 (needsScaling)
|
||||
bm = ScaleImage(bm, width, height);
|
||||
|
||||
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,11 +164,9 @@ 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
|
||||
|
||||
|
|
Loading…
Reference in New Issue