aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/OptionalModules/Scripting/Minimodule/Graphics.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/OptionalModules/Scripting/Minimodule/Graphics.cs')
-rw-r--r--OpenSim/Region/OptionalModules/Scripting/Minimodule/Graphics.cs48
1 files changed, 48 insertions, 0 deletions
diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/Graphics.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Graphics.cs
new file mode 100644
index 0000000..4de249f
--- /dev/null
+++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Graphics.cs
@@ -0,0 +1,48 @@
1using System.Drawing;
2using OpenMetaverse;
3using OpenMetaverse.Imaging;
4using OpenSim.Framework;
5using OpenSim.Region.Framework.Scenes;
6
7namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
8{
9 class Graphics : IGraphics
10 {
11 private readonly Scene m_scene;
12
13 public Graphics(Scene m_scene)
14 {
15 this.m_scene = m_scene;
16 }
17
18 public UUID SaveBitmap(Bitmap data)
19 {
20 return SaveBitmap(data, false, true);
21 }
22
23 public UUID SaveBitmap(Bitmap data, bool lossless, bool temporary)
24 {
25 AssetBase asset = new AssetBase();
26 asset.FullID = UUID.Random();
27 asset.Data = OpenJPEG.EncodeFromImage(data, lossless);
28 asset.Name = "MRMDynamicImage" + Util.RandomClass.Next(1, 10000);
29 asset.Type = 0;
30 asset.Description = "MRM Image";
31 asset.Local = false;
32 asset.Temporary = temporary;
33 m_scene.CommsManager.AssetCache.AddAsset(asset);
34
35 return asset.FullID;
36 }
37
38 public Bitmap LoadBitmap(UUID assetID)
39 {
40 AssetBase bmp = m_scene.CommsManager.AssetCache.GetAsset(assetID, true);
41 ManagedImage outimg;
42 Image img;
43 OpenJPEG.DecodeToImage(bmp.Data, out outimg, out img);
44
45 return new Bitmap(img);
46 }
47 }
48}