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

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

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 79 by william, Thu Jul 15 21:50:56 2010 UTC revision 86 by william, Fri Jul 16 23:35:21 2010 UTC
# Line 13  namespace gr2lib.core.coretypes.implemen Line 13  namespace gr2lib.core.coretypes.implemen
13          public Image()          public Image()
14          {          {
15              this.MIPLevels = new List<MIPLevel>();              this.MIPLevels = new List<MIPLevel>();
16              this.NativePointer = IntPtr.Zero;              //this.NativePointer = IntPtr.Zero;
17          }          }
18    
19          internal static Image ReadFromMemory(IntPtr pointer)          internal static Image ReadFromMemory(IntPtr pointer)
20          {          {
21                try
22                {
23              if (pointer == IntPtr.Zero) return null;              if (pointer == IntPtr.Zero) return null;
24              native.Image native = Helpers.ReadFromMemory<native.Image>(pointer);              native.Image native = Helpers.ReadFromMemory<native.Image>(pointer);
25              Image managed = ReadFromNative(native);              Image managed = ReadFromNative(native);
26              managed.NativePointer = pointer;              managed.NativePointer = pointer;
27              return managed;              return managed;
28                }
29                catch (Exception ex)
30                {
31                    Console.WriteLine(ex.ToString());
32                    return default(Image);
33                }
34          }          }
35    
36          internal static Image ReadFromNative(native.Image native)          internal static Image ReadFromNative(native.Image native)
37          {          {
38              Image managed = new Image();              try
             IntPtr[] miplevels = Helpers.ReadPtrArrayFromMemory<native.MIPLevel>(native.MIPLevels);  
             int length = miplevels.Length;  
             managed.MIPLevels = new List<MIPLevel>(length);  
             foreach (IntPtr ptr in miplevels)  
39              {              {
40                  managed.MIPLevels.Add(new MIPLevel());                  Image managed = new Image();
41                    IntPtr[] miplevels = Helpers.ReadPtrArrayFromMemory<native.MIPLevel>(native.MIPLevels);
42                    int length = miplevels.Length;
43                    managed.MIPLevels = new List<MIPLevel>(length);
44                    foreach (IntPtr ptr in miplevels)
45                    {
46                        MIPLevel _tmp = new MIPLevel();
47                        _tmp.NativePointer = ptr;
48                        managed.MIPLevels.Add(_tmp);
49                    }
50                    for (int i = 0; i < length; i++)
51                    {
52                        managed.MIPLevels[i] = MIPLevel.ReadFromMemory(miplevels[i]);
53                    }
54                    return managed;
55              }              }
56              for (int i = 0; i < length; i++)              catch (Exception ex)
57              {              {
58                  managed.MIPLevels[i] = MIPLevel.ReadFromMemory(miplevels[i]);                  Console.WriteLine(ex.ToString());
59                    return default(Image);
60              }              }
             return managed;  
61          }          }
62    
63          #region INativePointer Members          #region INativePointer Members

Legend:
Removed from v.79  
changed lines
  Added in v.86

  ViewVC Help
Powered by ViewVC 1.1.22