/[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 86 - (show annotations) (download)
Fri Jul 16 23:35:21 2010 UTC (10 years, 1 month ago) by william
File size: 1923 byte(s)
Add Try/Catch blocks in to all API Calls

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 managed.ShiftForComponent = native.ShiftForComponent;
32 managed.BitsForComponent = native.BitsForComponent;
33 return managed;
34 }
35
36 #region INativePointer Members
37 private IntPtr _NativePointer;
38 public IntPtr NativePointer { get { return _NativePointer; } set { _NativePointer = value; } }
39 #endregion
40
41 #region ILayout Members
42
43 private int _BytesPerPixel;
44 private int[] _ShiftForComponent;
45 private int[] _BitsForComponent;
46
47 public int BytesPerPixel { get { return _BytesPerPixel; } set { _BytesPerPixel = value; } }
48 public int[] ShiftForComponent { get { return _ShiftForComponent; } set { _ShiftForComponent = value; } }
49 public int[] BitsForComponent { get { return _BitsForComponent; } set { _BitsForComponent = value; } }
50 #endregion
51 }
52 }

  ViewVC Help
Powered by ViewVC 1.1.22