diff options
Diffstat (limited to '')
3 files changed, 49 insertions, 0 deletions
diff --git a/OpenSim/OpenSim.Terrain.BasicTerrain/OpenSim.Terrain.BasicTerrain.csproj b/OpenSim/OpenSim.Terrain.BasicTerrain/OpenSim.Terrain.BasicTerrain.csproj index e38c879..10bc0fd 100644 --- a/OpenSim/OpenSim.Terrain.BasicTerrain/OpenSim.Terrain.BasicTerrain.csproj +++ b/OpenSim/OpenSim.Terrain.BasicTerrain/OpenSim.Terrain.BasicTerrain.csproj | |||
@@ -62,6 +62,10 @@ | |||
62 | <HintPath>..\..\bin\libTerrain-BSD.dll</HintPath> | 62 | <HintPath>..\..\bin\libTerrain-BSD.dll</HintPath> |
63 | <Private>False</Private> | 63 | <Private>False</Private> |
64 | </Reference> | 64 | </Reference> |
65 | <Reference Include="openjpegnet.dll" > | ||
66 | <HintPath>..\..\bin\openjpegnet.dll</HintPath> | ||
67 | <Private>False</Private> | ||
68 | </Reference> | ||
65 | <Reference Include="System" > | 69 | <Reference Include="System" > |
66 | <HintPath>System.dll</HintPath> | 70 | <HintPath>System.dll</HintPath> |
67 | <Private>False</Private> | 71 | <Private>False</Private> |
diff --git a/OpenSim/OpenSim.Terrain.BasicTerrain/OpenSim.Terrain.BasicTerrain.dll.build b/OpenSim/OpenSim.Terrain.BasicTerrain/OpenSim.Terrain.BasicTerrain.dll.build index 6526648..51cecb9 100644 --- a/OpenSim/OpenSim.Terrain.BasicTerrain/OpenSim.Terrain.BasicTerrain.dll.build +++ b/OpenSim/OpenSim.Terrain.BasicTerrain/OpenSim.Terrain.BasicTerrain.dll.build | |||
@@ -20,6 +20,7 @@ | |||
20 | <include name="${project::get-base-directory()}/${build.dir}" /> | 20 | <include name="${project::get-base-directory()}/${build.dir}" /> |
21 | </lib> | 21 | </lib> |
22 | <include name="../../bin/libTerrain-BSD.dll" /> | 22 | <include name="../../bin/libTerrain-BSD.dll" /> |
23 | <include name="../../bin/openjpegnet.dll" /> | ||
23 | <include name="System.dll" /> | 24 | <include name="System.dll" /> |
24 | <include name="System.Data.dll" /> | 25 | <include name="System.Data.dll" /> |
25 | <include name="System.Drawing.dll" /> | 26 | <include name="System.Drawing.dll" /> |
diff --git a/OpenSim/OpenSim.Terrain.BasicTerrain/TerrainEngine.cs b/OpenSim/OpenSim.Terrain.BasicTerrain/TerrainEngine.cs index ecbd078..e5831a0 100644 --- a/OpenSim/OpenSim.Terrain.BasicTerrain/TerrainEngine.cs +++ b/OpenSim/OpenSim.Terrain.BasicTerrain/TerrainEngine.cs | |||
@@ -30,6 +30,7 @@ using System.Collections.Generic; | |||
30 | using System.Text; | 30 | using System.Text; |
31 | using System.Drawing; | 31 | using System.Drawing; |
32 | using libTerrain; | 32 | using libTerrain; |
33 | using OpenJPEGNet; | ||
33 | 34 | ||
34 | namespace OpenSim.Terrain | 35 | namespace OpenSim.Terrain |
35 | { | 36 | { |
@@ -507,5 +508,48 @@ namespace OpenSim.Terrain | |||
507 | Console.WriteLine("Failed generating terrain map: " + e.ToString()); | 508 | Console.WriteLine("Failed generating terrain map: " + e.ToString()); |
508 | } | 509 | } |
509 | } | 510 | } |
511 | |||
512 | /// <summary> | ||
513 | /// Exports the current heightmap in Jpeg2000 format to a byte[] | ||
514 | /// </summary> | ||
515 | /// <param name="gradientmap">A 1x*height* image which contains the colour gradient to export with. Must be at least 1x2 pixels, 1x256 or more is ideal.</param> | ||
516 | public byte[] exportJpegImage(string gradientmap) | ||
517 | { | ||
518 | byte[] imageData = null; | ||
519 | try | ||
520 | { | ||
521 | Bitmap gradientmapLd = new Bitmap(gradientmap); | ||
522 | |||
523 | int pallete = gradientmapLd.Height; | ||
524 | |||
525 | Bitmap bmp = new Bitmap(heightmap.w, heightmap.h); | ||
526 | Color[] colours = new Color[pallete]; | ||
527 | |||
528 | for (int i = 0; i < pallete; i++) | ||
529 | { | ||
530 | colours[i] = gradientmapLd.GetPixel(0, i); | ||
531 | } | ||
532 | |||
533 | Channel copy = heightmap.copy(); | ||
534 | for (int x = 0; x < copy.w; x++) | ||
535 | { | ||
536 | for (int y = 0; y < copy.h; y++) | ||
537 | { | ||
538 | // 512 is the largest possible height before colours clamp | ||
539 | int colorindex = (int)(Math.Max(Math.Min(1.0, copy.get(copy.w -x, copy.h - y) / 512.0), 0.0) * pallete); | ||
540 | bmp.SetPixel(x, y, colours[colorindex]); | ||
541 | } | ||
542 | } | ||
543 | |||
544 | //bmp.Save(filename, System.Drawing.Imaging.ImageFormat.Png); | ||
545 | imageData = OpenJPEGNet.OpenJPEG.EncodeFromImage(bmp, "map"); | ||
546 | |||
547 | } | ||
548 | catch (Exception e) | ||
549 | { | ||
550 | Console.WriteLine("Failed generating terrain map: " + e.ToString()); | ||
551 | } | ||
552 | return imageData; | ||
553 | } | ||
510 | } | 554 | } |
511 | } \ No newline at end of file | 555 | } \ No newline at end of file |