/[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 72 - (show annotations) (download)
Thu Jul 15 14:22:00 2010 UTC (9 years, 6 months ago) by william
File size: 1283 byte(s)
add: reading of textures

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 internal static Image ReadFromMemory(IntPtr pointer)
15 {
16 if (pointer == IntPtr.Zero) return null;
17 native.Image native = Helpers.ReadFromMemory<native.Image>(pointer);
18 Image managed = ReadFromNative(native);
19 managed.NativePointer = pointer;
20 return managed;
21 }
22
23 internal static Image ReadFromNative(native.Image native)
24 {
25 Image managed = new Image();
26 IntPtr[] miplevels = Helpers.ReadPtrArrayFromMemory<native.MIPLevel>(native.MIPLevels);
27 int length = miplevels.Length;
28 managed.MIPLevels = new List<MIPLevel>(length);
29 foreach (IntPtr ptr in miplevels)
30 {
31 managed.MIPLevels.Add(new MIPLevel());
32 }
33 for (int i = 0; i < length; i++)
34 {
35 managed.MIPLevels[i] = MIPLevel.ReadFromMemory(miplevels[i]);
36 }
37 return managed;
38 }
39 }
40 }

  ViewVC Help
Powered by ViewVC 1.1.22