diff options
author | Adam Frisby | 2009-04-09 14:19:49 +0000 |
---|---|---|
committer | Adam Frisby | 2009-04-09 14:19:49 +0000 |
commit | c77e7fce9ebbdb0a7a5baee316fcf940bf641416 (patch) | |
tree | 5930b5f6c76983c1fe4ea44285ad6f163570b953 /OpenSim/Region/OptionalModules/Scripting/Minimodule/Graphics.cs | |
parent | * Adds World.OnNewUser += delegate(IWorld sender, NewUserEventArgs e); (diff) | |
download | opensim-SC-c77e7fce9ebbdb0a7a5baee316fcf940bf641416.zip opensim-SC-c77e7fce9ebbdb0a7a5baee316fcf940bf641416.tar.gz opensim-SC-c77e7fce9ebbdb0a7a5baee316fcf940bf641416.tar.bz2 opensim-SC-c77e7fce9ebbdb0a7a5baee316fcf940bf641416.tar.xz |
* Implements IGraphics interface for MRM Scripting.
* This allows you to utilize System.Drawing tools on textures within the region.
* Example: use System.Drawing.Bitmap to make your texture, then use Host.Graphics.SaveBitmap to make an asset from it in JPEG2K. You can edit (but not overwrite) existing textures using Host.Graphics.LoadBitmap.
Diffstat (limited to 'OpenSim/Region/OptionalModules/Scripting/Minimodule/Graphics.cs')
-rw-r--r-- | OpenSim/Region/OptionalModules/Scripting/Minimodule/Graphics.cs | 48 |
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 @@ | |||
1 | using System.Drawing; | ||
2 | using OpenMetaverse; | ||
3 | using OpenMetaverse.Imaging; | ||
4 | using OpenSim.Framework; | ||
5 | using OpenSim.Region.Framework.Scenes; | ||
6 | |||
7 | namespace 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 | } | ||