/[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 79 - (show annotations) (download)
Thu Jul 15 21:50:56 2010 UTC (11 years, 6 months ago) by william
File size: 1943 byte(s)
create and implement interfaces for all core classes (for type casting)

1 using System;
2 using System.Collections.Generic;
3 using System.Text;
4 using gr2lib.core.helpers;
5 using gr2lib.core.interfaces;
6 namespace gr2lib.core.coretypes.implementation
7 {
8 public class MIPLevel : IMIPLevel
9 {
10 public MIPLevel()
11 {
12 this.Stride = 0;
13 this.Pixels = new PixelList();
14 this.NativePointer = IntPtr.Zero;
15 }
16
17 internal static MIPLevel ReadFromMemory(IntPtr pointer)
18 {
19 if (pointer == IntPtr.Zero) return null;
20 native.MIPLevel native = Helpers.ReadFromMemory<native.MIPLevel>(pointer);
21 MIPLevel managed = ReadFromNative(native);
22 managed.NativePointer = pointer;
23 return managed;
24 }
25
26 internal static MIPLevel ReadFromNative(native.MIPLevel native)
27 {
28 MIPLevel managed = new MIPLevel();
29 managed.Stride = native.Stride;
30 IntPtr[] pixels = Helpers.ReadPtrArrayFromMemory<native.Pixel>(native.Pixels);
31 int length = pixels.Length;
32 managed.Pixels = new PixelList(length);
33 foreach (IntPtr ptr in pixels)
34 {
35 managed.Pixels.Add(new Pixel());
36 }
37 for (int i = 0; i < length; i++)
38 {
39 managed.Pixels[i] = Pixel.ReadFromMemory(pixels[i]);
40 }
41 return managed;
42 }
43
44 #region INativePointer Members
45 private IntPtr _NativePointer;
46 public IntPtr NativePointer { get { return _NativePointer; } set { _NativePointer = value; } }
47 #endregion
48
49 #region IMIPLevel Members
50 private int _Stride;
51 private PixelList _Pixels;
52
53 public int Stride { get { return _Stride; } set { _Stride = value; } }
54 public PixelList Pixels { get { return _Pixels; } set { _Pixels = value; } }
55 #endregion
56 }
57 }

  ViewVC Help
Powered by ViewVC 1.1.22