blob: 4de249f2ea7d09634320fb8071e25cf7463de07e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
using System.Drawing;
using OpenMetaverse;
using OpenMetaverse.Imaging;
using OpenSim.Framework;
using OpenSim.Region.Framework.Scenes;
namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
{
class Graphics : IGraphics
{
private readonly Scene m_scene;
public Graphics(Scene m_scene)
{
this.m_scene = m_scene;
}
public UUID SaveBitmap(Bitmap data)
{
return SaveBitmap(data, false, true);
}
public UUID SaveBitmap(Bitmap data, bool lossless, bool temporary)
{
AssetBase asset = new AssetBase();
asset.FullID = UUID.Random();
asset.Data = OpenJPEG.EncodeFromImage(data, lossless);
asset.Name = "MRMDynamicImage" + Util.RandomClass.Next(1, 10000);
asset.Type = 0;
asset.Description = "MRM Image";
asset.Local = false;
asset.Temporary = temporary;
m_scene.CommsManager.AssetCache.AddAsset(asset);
return asset.FullID;
}
public Bitmap LoadBitmap(UUID assetID)
{
AssetBase bmp = m_scene.CommsManager.AssetCache.GetAsset(assetID, true);
ManagedImage outimg;
Image img;
OpenJPEG.DecodeToImage(bmp.Data, out outimg, out img);
return new Bitmap(img);
}
}
}
|