aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim')
-rw-r--r--OpenSim/Region/Application/OpenSimMain.cs14
-rw-r--r--OpenSim/Region/Environment/Scenes/Scene.cs42
2 files changed, 56 insertions, 0 deletions
diff --git a/OpenSim/Region/Application/OpenSimMain.cs b/OpenSim/Region/Application/OpenSimMain.cs
index ce2b856..eb09de3 100644
--- a/OpenSim/Region/Application/OpenSimMain.cs
+++ b/OpenSim/Region/Application/OpenSimMain.cs
@@ -688,6 +688,20 @@ namespace OpenSim
688 688
689 break; 689 break;
690 690
691 case "export-map":
692 if (m_sceneManager.CurrentScene != null)
693 {
694 if (cmdparams.Length > 0)
695 {
696 m_sceneManager.CurrentScene.ExportWorldMap(cmdparams[0]);
697 }
698 else
699 {
700 m_sceneManager.CurrentScene.ExportWorldMap("exportmap.jpg");
701 }
702 }
703 break;
704
691 default: 705 default:
692 m_log.Error("Unknown command"); 706 m_log.Error("Unknown command");
693 break; 707 break;
diff --git a/OpenSim/Region/Environment/Scenes/Scene.cs b/OpenSim/Region/Environment/Scenes/Scene.cs
index 1400e60..bc4fa3c 100644
--- a/OpenSim/Region/Environment/Scenes/Scene.cs
+++ b/OpenSim/Region/Environment/Scenes/Scene.cs
@@ -470,6 +470,48 @@ namespace OpenSim.Region.Environment.Scenes
470 470
471 #region Load Terrain 471 #region Load Terrain
472 472
473 public void ExportWorldMap(string fileName)
474 {
475 List<MapBlockData> mapBlocks = this.CommsManager.GridService.RequestNeighbourMapBlocks((int)(this.RegionInfo.RegionLocX - 9), (int)(this.RegionInfo.RegionLocY - 9), (int)(this.RegionInfo.RegionLocX + 9), (int)(this.RegionInfo.RegionLocY + 9));
476 List<AssetBase> textures = new List<AssetBase>();
477 List<System.Drawing.Image> bitImages = new List<System.Drawing.Image>();
478
479 foreach (MapBlockData mapBlock in mapBlocks)
480 {
481 AssetBase texAsset = this.AssetCache.GetAsset(mapBlock.MapImageId, true);
482
483 if (texAsset != null)
484 {
485 textures.Add(texAsset);
486 }
487 else
488 {
489 texAsset = this.AssetCache.GetAsset(mapBlock.MapImageId, true);
490 if (texAsset != null)
491 {
492 textures.Add(texAsset);
493 }
494 }
495 }
496
497 foreach(AssetBase asset in textures)
498 {
499 System.Drawing.Image image= OpenJPEGNet.OpenJPEG.DecodeToImage(asset.Data);
500 bitImages.Add(image);
501 }
502
503 System.Drawing.Bitmap mapTexture = new System.Drawing.Bitmap(2560, 2560);
504 System.Drawing.Graphics g = System.Drawing.Graphics.FromImage(mapTexture);
505
506 for(int i =0; i<mapBlocks.Count; i++)
507 {
508 ushort x = (ushort) ((mapBlocks[i].X - this.RegionInfo.RegionLocX) + 10);
509 ushort y = (ushort) ((mapBlocks[i].Y - this.RegionInfo.RegionLocY) + 10);
510 g.DrawImage(bitImages[i], (x*128), (y*128), 128, 128);
511 }
512 mapTexture.Save(fileName, System.Drawing.Imaging.ImageFormat.Jpeg);
513 }
514
473 /// <summary> 515 /// <summary>
474 /// Loads the World heightmap 516 /// Loads the World heightmap
475 /// </summary> 517 /// </summary>