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

Contents of /trunk/gr2lib/core/coretypes/implementation/Layout.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: 1979 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 Layout : ILayout
9 {
10 public Layout()
11 {
12 this.BytesPerPixel = 0;
13 this.ShiftForComponent = new int[4] { 0, 0, 0, 0 };
14 this.BitsForComponent = new int[4] { 0, 0, 0, 0 };
15 this.NativePointer = IntPtr.Zero;
16 }
17
18 internal static Layout ReadFromMemory(IntPtr pointer)
19 {
20 if (pointer == IntPtr.Zero) return null;
21 native.Layout native = Helpers.ReadFromMemory<native.Layout>(pointer);
22 Layout managed = ReadFromNative(native);
23 managed.NativePointer = pointer;
24 return managed;
25 }
26
27 internal static Layout ReadFromNative(native.Layout native)
28 {
29 Layout managed = new Layout();
30 managed.BytesPerPixel = native.BytesPerPixel;
31 unsafe
32 {
33 managed.ShiftForComponent = native.ShiftForComponent;
34 managed.BitsForComponent = native.BitsForComponent;
35 }
36 return managed;
37 }
38
39 #region INativePointer Members
40 private IntPtr _NativePointer;
41 public IntPtr NativePointer { get { return _NativePointer; } set { _NativePointer = value; } }
42 #endregion
43
44 #region ILayout Members
45
46 private int _BytesPerPixel;
47 private int[] _ShiftForComponent;
48 private int[] _BitsForComponent;
49
50 public int BytesPerPixel { get { return _BytesPerPixel; } set { _BytesPerPixel = value; } }
51 public int[] ShiftForComponent { get { return _ShiftForComponent; } set { _ShiftForComponent = value; } }
52 public int[] BitsForComponent { get { return _BitsForComponent; } set { _BitsForComponent = value; } }
53 #endregion
54 }
55 }

  ViewVC Help
Powered by ViewVC 1.1.22