/[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 73 - (show annotations) (download)
Thu Jul 15 14:31:59 2010 UTC (9 years, 6 months ago) by william
File size: 1430 byte(s)
setup default constructors to initialize each class to its default values

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

  ViewVC Help
Powered by ViewVC 1.1.22