/[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 76 - (show annotations) (download)
Thu Jul 15 19:28:46 2010 UTC (11 years, 4 months ago) by william
File size: 1509 byte(s)
Add/Update: PixelList

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 PixelList Pixels;
12
13 public IntPtr NativePointer;
14
15 public MIPLevel()
16 {
17 this.Stride = 0;
18 this.Pixels = new PixelList();
19 this.NativePointer = IntPtr.Zero;
20 }
21
22 internal static MIPLevel ReadFromMemory(IntPtr pointer)
23 {
24 if (pointer == IntPtr.Zero) return null;
25 native.MIPLevel native = Helpers.ReadFromMemory<native.MIPLevel>(pointer);
26 MIPLevel managed = ReadFromNative(native);
27 managed.NativePointer = pointer;
28 return managed;
29 }
30
31 internal static MIPLevel ReadFromNative(native.MIPLevel native)
32 {
33 MIPLevel managed = new MIPLevel();
34 managed.Stride = native.Stride;
35 IntPtr[] pixels = Helpers.ReadPtrArrayFromMemory<native.Pixel>(native.Pixels);
36 int length = pixels.Length;
37 managed.Pixels = new PixelList(length);
38 foreach (IntPtr ptr in pixels)
39 {
40 managed.Pixels.Add(new Pixel());
41 }
42 for (int i = 0; i < length; i++)
43 {
44 managed.Pixels[i] = Pixel.ReadFromMemory(pixels[i]);
45 }
46 return managed;
47 }
48 }
49 }

  ViewVC Help
Powered by ViewVC 1.1.22