/[gr2lib]/trunk/gr2lib/core/coretypes/implementation/Image.cs
ViewVC logotype

Contents of /trunk/gr2lib/core/coretypes/implementation/Image.cs

Parent Directory Parent Directory | Revision Log Revision Log


Revision 79 - (show annotations) (download)
Thu Jul 15 21:50:56 2010 UTC (9 years, 6 months ago) by william
File size: 1802 byte(s)
create and implement interfaces for all core classes (for type casting)

1 using System;
2 using System.Collections.Generic;
3 using System.Text;
4 using gr2lib.core.helpers;
5 using gr2lib.core.interfaces;
6 namespace gr2lib.core.coretypes.implementation
7 {
8 public class Image : IImage
9 {
10
11
12
13 public Image()
14 {
15 this.MIPLevels = new List<MIPLevel>();
16 this.NativePointer = IntPtr.Zero;
17 }
18
19 internal static Image ReadFromMemory(IntPtr pointer)
20 {
21 if (pointer == IntPtr.Zero) return null;
22 native.Image native = Helpers.ReadFromMemory<native.Image>(pointer);
23 Image managed = ReadFromNative(native);
24 managed.NativePointer = pointer;
25 return managed;
26 }
27
28 internal static Image ReadFromNative(native.Image native)
29 {
30 Image managed = new Image();
31 IntPtr[] miplevels = Helpers.ReadPtrArrayFromMemory<native.MIPLevel>(native.MIPLevels);
32 int length = miplevels.Length;
33 managed.MIPLevels = new List<MIPLevel>(length);
34 foreach (IntPtr ptr in miplevels)
35 {
36 managed.MIPLevels.Add(new MIPLevel());
37 }
38 for (int i = 0; i < length; i++)
39 {
40 managed.MIPLevels[i] = MIPLevel.ReadFromMemory(miplevels[i]);
41 }
42 return managed;
43 }
44
45 #region INativePointer Members
46 private IntPtr _NativePointer;
47 public IntPtr NativePointer { get { return _NativePointer; } set { _NativePointer = value; } }
48 #endregion
49
50 #region IImage Members
51 private List<MIPLevel> _MIPLevels;
52 public List<MIPLevel> MIPLevels { get { return _MIPLevels; } set { _MIPLevels = value; } }
53 #endregion
54 }
55 }

  ViewVC Help
Powered by ViewVC 1.1.22