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

Diff of /trunk/gr2lib/core/coretypes/implementation/Texture.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 95 by william, Sat Jul 17 05:10:22 2010 UTC
# Line 4  using System.Text; Line 4  using System.Text;
4  using gr2lib.core.helpers;  using gr2lib.core.helpers;
5    
6  using gr2lib.core.interfaces;  using gr2lib.core.interfaces;
7    using System.Diagnostics;
8    
9  namespace gr2lib.core.coretypes.implementation  namespace gr2lib.core.coretypes.implementation
10  {  {
# Line 17  namespace gr2lib.core.coretypes.implemen Line 18  namespace gr2lib.core.coretypes.implemen
18          private int _SubFormat;          private int _SubFormat;
19          private Layout _Layout;          private Layout _Layout;
20          private List<Image> _Images;          private List<Image> _Images;
21          private IntPtr _ExtendedData;  
22    
23                    
24    
# Line 31  namespace gr2lib.core.coretypes.implemen Line 32  namespace gr2lib.core.coretypes.implemen
32              this.SubFormat = 0;              this.SubFormat = 0;
33              this.Layout = new Layout();              this.Layout = new Layout();
34              this.Images = new List<Image>();              this.Images = new List<Image>();
35              this.ExtendedData = IntPtr.Zero;              //this.ExtendedData = new IntPtr();
36              this.NativePointer = IntPtr.Zero;              //this.NativePointer = IntPtr.Zero;
37          }          }
38    
39          internal static Texture ReadFromMemory(IntPtr pointer)          internal static Texture ReadFromMemory(IntPtr pointer)
40          {          {
41                try
42                {
43              if (pointer == IntPtr.Zero) return null;              if (pointer == IntPtr.Zero) return null;
44              native.Texture native = Helpers.ReadFromMemory<native.Texture>(pointer);              native.Texture native = Helpers.ReadFromMemory<native.Texture>(pointer);
45              Texture managed = ReadFromNative(native);              Texture managed = ReadFromNative(native);
46              managed.NativePointer = pointer;              managed.NativePointer = pointer;
47              return managed;              return managed;
48                }
49                catch (Exception ex)
50                {
51                    StackTrace st = new StackTrace(true);
52                    Console.WriteLine(st.ToString() + "\n\n" + "Stack Trace: \n" + ex.ToString());
53                    return default(Texture);
54                }
55          }          }
56    
57          internal static Texture ReadFromNative(native.Texture native)          internal static Texture ReadFromNative(native.Texture native)
58          {          {
59              Texture managed = new Texture();              try
             managed.FromFileName = native.FromFileName;  
             managed.TextureType = native.TextureType;  
             managed.Width = native.Width;  
             managed.Height = native.Height;  
             managed.Encoding = native.Encoding;  
             managed.SubFormat = native.SubFormat;  
             managed.Layout = Layout.ReadFromNative(native.Layout);  
             IntPtr[] images = Helpers.ReadPtrArrayFromMemory<native.Image>(native.Images);  
             int length = images.Length;  
             managed.Images = new List<Image>(length);  
             foreach (IntPtr ptr in images)  
60              {              {
61                  managed.Images.Add(new Image());                  Texture managed = new Texture();
62                    managed.FromFileName = native.FromFileName;
63                    managed.TextureType = native.TextureType;
64                    managed.Width = native.Width;
65                    managed.Height = native.Height;
66                    managed.Encoding = native.Encoding;
67                    managed.SubFormat = native.SubFormat;
68                    managed.Layout = Layout.ReadFromNative(native.Layout);
69                    IntPtr[] images = Helpers.ReadPtrArrayFromMemory<native.Image>(native.Images);
70                    int length = images.Length;
71                    managed.Images = new List<Image>(length);
72                    foreach (IntPtr ptr in images)
73                    {
74                        Image _tmp = new Image();
75                        _tmp.NativePointer = ptr;
76                        managed.Images.Add(_tmp);
77                    }
78                    for (int i = 0; i < length; i++)
79                    {
80                        managed.Images[i] = Image.ReadFromMemory(images[i]);
81                    }
82                    managed.ExtendedData = native.ExtendedData;
83                    return managed;
84              }              }
85              for (int i = 0; i < length; i++)              catch (Exception ex)
86              {              {
87                  managed.Images[i] = Image.ReadFromMemory(images[i]);                  StackTrace st = new StackTrace(true);
88                    Console.WriteLine(st.ToString() + "\n\n" + "Stack Trace: \n" + ex.ToString());
89                    return default(Texture);
90              }              }
             managed.ExtendedData = native.ExtendedData;  
             return managed;  
91          }          }
92    
93          #region ITexture Members          #region ITexture Members
# Line 78  namespace gr2lib.core.coretypes.implemen Line 99  namespace gr2lib.core.coretypes.implemen
99          public int SubFormat { get { return _SubFormat; } set { _SubFormat = value; } }          public int SubFormat { get { return _SubFormat; } set { _SubFormat = value; } }
100          public Layout Layout { get { return _Layout; } set { _Layout = value; } }          public Layout Layout { get { return _Layout; } set { _Layout = value; } }
101          public List<Image> Images { get { return _Images; } set { _Images = value; } }          public List<Image> Images { get { return _Images; } set { _Images = value; } }
         public IntPtr ExtendedData { get { return _ExtendedData; } set { _ExtendedData = value; } }  
102          #endregion          #endregion
103    
104          #region INativePointer Members          #region INativePointer Members
105          private IntPtr _NativePointer;          private IntPtr _NativePointer;
106          public IntPtr NativePointer { get { return _NativePointer; } set { _NativePointer = value; } }          public IntPtr NativePointer { get { return _NativePointer; } set { _NativePointer = value; } }
107          #endregion          #endregion
108    
109            #region IExtendedData Members
110            private IntPtr _ExtendedData;
111            public IntPtr ExtendedData { get { return _ExtendedData; } set { _ExtendedData = value; } }
112            #endregion
113      }      }
114  }  }

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

  ViewVC Help
Powered by ViewVC 1.1.22