Added support for bitmap and image loading to libterrain, use "terrain load img filename.ext", the following formats are supported under .NET (unknown under Mono): BMP, GIF, PNG, JPEG, WMF, TGA, TIFF.

zircon^2
Adam Frisby 2007-06-04 11:16:41 +00:00
parent 2b8a8d3dad
commit a415615270
1 changed files with 23 additions and 1 deletions

View File

@ -175,7 +175,7 @@ namespace OpenSim.Terrain
break; break;
case "img": case "img":
resultText = "Error - IMG mode is presently unsupported."; loadFromFileIMG(args[2]);
return false; return false;
default: default:
@ -229,6 +229,28 @@ namespace OpenSim.Terrain
tainted++; tainted++;
} }
/// <summary>
/// Loads a file from an image compatible with System.Drawing
/// </summary>
/// <param name="filename">File to load</param>
public void loadFromFileIMG(string filename)
{
System.Drawing.Bitmap bmp = new Bitmap(filename);
if (bmp.Width != heightmap.w && bmp.Height != heightmap.h)
throw new Exception("Wrong image size! Images for this region must be " + heightmap.w.ToString() + " by " + heightmap.h.ToString() + " pixels in dimension");
int x, y;
for (x = 0; x < w; x++)
{
for (y = 0; y < h; y++)
{
Color c = bmp.GetPixel(x, y);
}
}
}
/// <summary> /// <summary>
/// Loads a file consisting of 256x256 doubles and imports it as an array into the map. /// Loads a file consisting of 256x256 doubles and imports it as an array into the map.
/// </summary> /// </summary>