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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 72 - (show annotations) (download)
Thu Jul 15 14:22:00 2010 UTC (11 years, 4 months ago) by william
File size: 1341 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 MIPLevel
9 {
10 public int Stride;
11 public List<Pixel> Pixels;
12
13 public IntPtr NativePointer;
14
15 internal static MIPLevel ReadFromMemory(IntPtr pointer)
16 {
17 if (pointer == IntPtr.Zero) return null;
18 native.MIPLevel native = Helpers.ReadFromMemory<native.MIPLevel>(pointer);
19 MIPLevel managed = ReadFromNative(native);
20 managed.NativePointer = pointer;
21 return managed;
22 }
23
24 internal static MIPLevel ReadFromNative(native.MIPLevel native)
25 {
26 MIPLevel managed = new MIPLevel();
27 managed.Stride = native.Stride;
28 IntPtr[] pixels = Helpers.ReadPtrArrayFromMemory<native.Pixel>(native.Pixels);
29 int length = pixels.Length;
30 managed.Pixels = new List<Pixel>(length);
31 foreach (IntPtr ptr in pixels)
32 {
33 managed.Pixels.Add(new Pixel());
34 }
35 for (int i = 0; i < length; i++)
36 {
37 managed.Pixels[i] = Pixel.ReadFromMemory(pixels[i]);
38 }
39 return managed;
40 }
41 }
42 }

  ViewVC Help
Powered by ViewVC 1.1.22