diff options
Diffstat (limited to 'OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/GenericSystemDrawing.cs')
-rw-r--r-- | OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/GenericSystemDrawing.cs | 43 |
1 files changed, 32 insertions, 11 deletions
diff --git a/OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/GenericSystemDrawing.cs b/OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/GenericSystemDrawing.cs index f87d3ee..4d213e0 100644 --- a/OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/GenericSystemDrawing.cs +++ b/OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/GenericSystemDrawing.cs | |||
@@ -28,6 +28,7 @@ | |||
28 | using System; | 28 | using System; |
29 | using System.Drawing; | 29 | using System.Drawing; |
30 | using System.Drawing.Imaging; | 30 | using System.Drawing.Imaging; |
31 | using System.IO; | ||
31 | using OpenSim.Region.Environment.Interfaces; | 32 | using OpenSim.Region.Environment.Interfaces; |
32 | 33 | ||
33 | namespace OpenSim.Region.Environment.Modules.World.Terrain.FileLoaders | 34 | namespace OpenSim.Region.Environment.Modules.World.Terrain.FileLoaders |
@@ -57,26 +58,34 @@ namespace OpenSim.Region.Environment.Modules.World.Terrain.FileLoaders | |||
57 | /// <returns>A terrain channel generated from the image.</returns> | 58 | /// <returns>A terrain channel generated from the image.</returns> |
58 | public virtual ITerrainChannel LoadFile(string filename) | 59 | public virtual ITerrainChannel LoadFile(string filename) |
59 | { | 60 | { |
60 | Bitmap file = new Bitmap(filename); | 61 | return LoadBitmap(new Bitmap(filename)); |
62 | } | ||
61 | 63 | ||
62 | ITerrainChannel retval = new TerrainChannel(file.Width, file.Height); | 64 | public ITerrainChannel LoadFile(string filename, int x, int y, int fileWidth, int fileHeight, int w, int h) |
65 | { | ||
66 | throw new NotImplementedException(); | ||
67 | } | ||
68 | |||
69 | public virtual ITerrainChannel LoadStream(Stream stream) | ||
70 | { | ||
71 | return LoadBitmap(new Bitmap(stream)); | ||
72 | } | ||
73 | |||
74 | protected virtual ITerrainChannel LoadBitmap(Bitmap bitmap) | ||
75 | { | ||
76 | ITerrainChannel retval = new TerrainChannel(bitmap.Width, bitmap.Height); | ||
63 | 77 | ||
64 | int x; | 78 | int x; |
65 | for (x = 0; x < file.Width; x++) | 79 | for (x = 0; x < bitmap.Width; x++) |
66 | { | 80 | { |
67 | int y; | 81 | int y; |
68 | for (y = 0; y < file.Height; y++) | 82 | for (y = 0; y < bitmap.Height; y++) |
69 | { | 83 | { |
70 | retval[x, y] = file.GetPixel(x, file.Height - y - 1).GetBrightness() * 128; | 84 | retval[x, y] = bitmap.GetPixel(x, bitmap.Height - y - 1).GetBrightness() * 128; |
71 | } | 85 | } |
72 | } | 86 | } |
73 | 87 | ||
74 | return retval; | 88 | return retval; |
75 | } | ||
76 | |||
77 | public ITerrainChannel LoadFile(string filename, int x, int y, int fileWidth, int fileHeight, int w, int h) | ||
78 | { | ||
79 | throw new NotImplementedException(); | ||
80 | } | 89 | } |
81 | 90 | ||
82 | /// <summary> | 91 | /// <summary> |
@@ -90,6 +99,18 @@ namespace OpenSim.Region.Environment.Modules.World.Terrain.FileLoaders | |||
90 | 99 | ||
91 | colours.Save(filename, ImageFormat.Png); | 100 | colours.Save(filename, ImageFormat.Png); |
92 | } | 101 | } |
102 | |||
103 | /// <summary> | ||
104 | /// Exports a stream using a System.Drawing exporter. | ||
105 | /// </summary> | ||
106 | /// <param name="stream">The target stream</param> | ||
107 | /// <param name="map">The terrain channel being saved</param> | ||
108 | public virtual void SaveStream(Stream stream, ITerrainChannel map) | ||
109 | { | ||
110 | Bitmap colours = CreateGrayscaleBitmapFromMap(map); | ||
111 | |||
112 | colours.Save(stream, ImageFormat.Png); | ||
113 | } | ||
93 | 114 | ||
94 | #endregion | 115 | #endregion |
95 | 116 | ||