forked from judero01col/GMap.NET
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPureImage.cs
More file actions
80 lines (65 loc) · 1.73 KB
/
Copy pathPureImage.cs
File metadata and controls
80 lines (65 loc) · 1.73 KB
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
using System;
using System.IO;
namespace GMap.NET
{
/// <summary>
/// image abstraction proxy
/// </summary>
public abstract class PureImageProxy
{
public abstract PureImage FromStream(Stream stream);
public abstract bool Save(Stream stream, PureImage image);
public PureImage FromArray(byte[] data)
{
var m = new MemoryStream(data, 0, data.Length, false, true);
var pi = FromStream(m);
if (pi != null)
{
m.Position = 0;
pi.Data = m;
}
return pi;
}
}
/// <summary>
/// image abstraction
/// </summary>
public abstract class PureImage : IDisposable
{
public MemoryStream Data;
internal bool IsParent;
internal long Ix;
internal long Xoff;
internal long Yoff;
#region IDisposable Members
public abstract void Dispose();
#endregion
}
public class DefaultImageProxy : PureImageProxy
{
public static readonly DefaultImageProxy Instance = new DefaultImageProxy();
private DefaultImageProxy()
{
}
public override PureImage FromStream(Stream stream)
{
return new DefaultImage();
}
public override bool Save(Stream stream, PureImage image)
{
if (image.Data != null)
{
image.Data.WriteTo(stream);
image.Data.Position = 0;
return true;
}
return false;
}
private class DefaultImage : PureImage
{
public override void Dispose()
{
}
}
}
}