diff --git a/OpenSim/Region/CoreModules/World/Terrain/FileLoaders/GenericSystemDrawing.cs b/OpenSim/Region/CoreModules/World/Terrain/FileLoaders/GenericSystemDrawing.cs index d5c77ec3e1..c0b276a707 100644 --- a/OpenSim/Region/CoreModules/World/Terrain/FileLoaders/GenericSystemDrawing.cs +++ b/OpenSim/Region/CoreModules/World/Terrain/FileLoaders/GenericSystemDrawing.cs @@ -128,7 +128,7 @@ namespace OpenSim.Region.CoreModules.World.Terrain.FileLoaders colours.Save(stream, ImageFormat.Png); } - public virtual void SaveFile(ITerrainChannel m_channel, string filename, + public virtual void SaveFile(ITerrainChannel m_channel, string filename, int offsetX, int offsetY, int fileWidth, int fileHeight, int regionSizeX, int regionSizeY) @@ -162,13 +162,13 @@ namespace OpenSim.Region.CoreModules.World.Terrain.FileLoaders { newBitmap = new Bitmap(fileWidth * regionSizeX, fileHeight * regionSizeY); } - + thisBitmap = CreateGrayscaleBitmapFromMap(m_channel); - // Console.WriteLine("offsetX=" + offsetX + " offsetY=" + offsetY); + // Console.WriteLine("offsetX=" + offsetX + " offsetY=" + offsetY); for (int x = 0; x < regionSizeX; x++) for (int y = 0; y < regionSizeY; y++) newBitmap.SetPixel(x + offsetX * regionSizeX, y + (fileHeight - 1 - offsetY) * regionSizeY, thisBitmap.GetPixel(x, y)); - + Save(newBitmap, filename); } finally @@ -227,59 +227,21 @@ namespace OpenSim.Region.CoreModules.World.Terrain.FileLoaders { for (int x = 0; x < map.Width; x++) { - // 512 is the largest possible height before colours clamp - int colorindex = (int) (Math.Max(Math.Min(1.0, map[x, y] / 128.0), 0.0) * (pallete - 1)); + int colorindex = (int)map[x, y]; // one to one conversion as seems apparent on sl docs + // or 0-511 range? + // int colorindex = (int)map[x, y]/2; // 0-511 - // Handle error conditions - if (colorindex > pallete - 1 || colorindex < 0) - bmp.SetPixel(x, map.Height - y - 1, Color.Red); - else - bmp.SetPixel(x, map.Height - y - 1, grays[colorindex]); - } - } - return bmp; - } - - /// - /// Protected method, generates a coloured bitmap - /// image from a specified terrain channel. - /// - /// The terrain channel to export to bitmap - /// A System.Drawing.Bitmap containing a coloured image - protected static Bitmap CreateBitmapFromMap(ITerrainChannel map) - { - int pallete; - Bitmap bmp; - Color[] colours; - - using (Bitmap gradientmapLd = new Bitmap("defaultstripe.png")) - { - pallete = gradientmapLd.Height; - - bmp = new Bitmap(map.Width, map.Height); - colours = new Color[pallete]; - - for (int i = 0; i < pallete; i++) - { - colours[i] = gradientmapLd.GetPixel(0, i); - } - } - - for (int y = 0; y < map.Height; y++) - { - for (int x = 0; x < map.Width; x++) - { - // 512 is the largest possible height before colours clamp - int colorindex = (int) (Math.Max(Math.Min(1.0, map[x, y] / 512.0), 0.0) * (pallete - 1)); - - // Handle error conditions - if (colorindex > pallete - 1 || colorindex < 0) - bmp.SetPixel(x, map.Height - y - 1, Color.Red); - else - bmp.SetPixel(x, map.Height - y - 1, colours[colorindex]); + // clamp it not adding the red warning + if (colorindex < 0) + colorindex = 0; + else if (colorindex >= pallete) + colorindex = pallete - 1; + bmp.SetPixel(x, map.Height - y - 1, grays[colorindex]); } } return bmp; } } } + +