/[gr2lib]/trunk/gr2lib/core/typedefs/granny_pixel_layouts.cs
ViewVC logotype

Diff of /trunk/gr2lib/core/typedefs/granny_pixel_layouts.cs

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

--- trunk/gr2lib/core/typedefs/granny_pixel_layouts.cs	2010/07/20 06:30:31	147
+++ trunk/gr2lib/core/typedefs/granny_pixel_layouts.cs	2010/07/20 08:11:31	148
@@ -52,7 +52,7 @@
 
         #region Pixel Layout: GrannyDefaultPixelLayout
         /// <summary>
-        /// default pixel layout
+        /// default pixel layout (GrannyRGBA8888PixelFormat)
         /// </summary>
         public static Layout GrannyDefaultPixelLayout
         {
@@ -69,35 +69,74 @@
         /// </summary>
         public static Layout GrannyRGB555PixelFormat
         {
+            #region Get GrannyRGB555PixelFormat Layout
             get
             {
-                int bits_per_pixel = 16;
-                int bytes_per_pixel = bits_per_pixel / 8;
-                Layout _layout = new Layout();
-                _layout.BytesPerPixel = bytes_per_pixel;
-                _layout.ShiftForComponent = new int[3] { 0, 5, 10};
-                _layout.BitsForComponent = new int[3] { 5, 5, 5 };
-                return _layout;
+                IntPtr hdl = coreapi.LoadLibrary("granny2.dll");
+                if (hdl != IntPtr.Zero)
+                {
+                    IntPtr addr = coreapi.GetProcAddress(hdl, "GrannyRGB555PixelFormat");
+                    if (addr != IntPtr.Zero)
+                    {
+                        gr2lib.core.coretypes.native.Layout _native;
+                        Layout _tmp_layout = new Layout();
+                        _native = (gr2lib.core.coretypes.native.Layout)Marshal.PtrToStructure(addr, typeof(gr2lib.core.coretypes.native.Layout));
+                        _tmp_layout.BytesPerPixel = Marshal.ReadInt32((IntPtr)_native.BytesPerPixel);
+                        for (int i = 0; i < _native.ShiftForComponent.Length; i++) { _tmp_layout.ShiftForComponent[i] = Marshal.ReadInt32((IntPtr)_native.ShiftForComponent[i]); }
+                        for (int i = 0; i < _native.BitsForComponent.Length; i++) { _tmp_layout.BitsForComponent[i] = Marshal.ReadInt32((IntPtr)_native.BitsForComponent[i]); }
+                        _tmp_layout.NativePointer = (IntPtr)_native.BytesPerPixel;
+                        return _tmp_layout;
+                    }
+                    else
+                    {
+                        return new Layout();
+                    }
+                }
+                else
+                {
+                    return new Layout();
+                }
             }
+            #endregion
         }
         #endregion
 
+
         #region Pixel Layout: GrannyRGB565PixelFormat
         /// <summary>
         /// 16bpp  5-bit red, 6-bit green, 5-bit blue
         /// </summary>
         public static Layout GrannyRGB565PixelFormat
         {
+            #region Get GrannyRGB565PixelFormat Layout
             get
             {
-                int bits_per_pixel = 16;
-                int bytes_per_pixel = bits_per_pixel / 8;
-                Layout _layout = new Layout();
-                _layout.BytesPerPixel = bytes_per_pixel;
-                _layout.ShiftForComponent = new int[3] { 0, 6, 11 };
-                _layout.BitsForComponent = new int[3] { 5, 6, 5 };
-                return _layout;
+                IntPtr hdl = coreapi.LoadLibrary("granny2.dll");
+                if (hdl != IntPtr.Zero)
+                {
+                    IntPtr addr = coreapi.GetProcAddress(hdl, "GrannyRGB565PixelFormat");
+                    if (addr != IntPtr.Zero)
+                    {
+                        gr2lib.core.coretypes.native.Layout _native;
+                        Layout _tmp_layout = new Layout();
+                        _native = (gr2lib.core.coretypes.native.Layout)Marshal.PtrToStructure(addr, typeof(gr2lib.core.coretypes.native.Layout));
+                        _tmp_layout.BytesPerPixel = Marshal.ReadInt32((IntPtr)_native.BytesPerPixel);
+                        for (int i = 0; i < _native.ShiftForComponent.Length; i++) { _tmp_layout.ShiftForComponent[i] = Marshal.ReadInt32((IntPtr)_native.ShiftForComponent[i]); }
+                        for (int i = 0; i < _native.BitsForComponent.Length; i++) { _tmp_layout.BitsForComponent[i] = Marshal.ReadInt32((IntPtr)_native.BitsForComponent[i]); }
+                        _tmp_layout.NativePointer = (IntPtr)_native.BytesPerPixel;
+                        return _tmp_layout;
+                    }
+                    else
+                    {
+                        return new Layout();
+                    }
+                }
+                else
+                {
+                    return new Layout();
+                }
             }
+            #endregion
         }
         #endregion
 
@@ -107,210 +146,413 @@
         /// </summary>
         public static Layout GrannyRGBA5551PixelFormat
         {
+            #region Get GrannyRGBA5551PixelFormat Layout
             get
             {
-                int bits_per_pixel = 16;
-                int bytes_per_pixel = bits_per_pixel / 8;
-                Layout _layout = new Layout();
-                _layout.BytesPerPixel = bytes_per_pixel;
-                _layout.ShiftForComponent = new int[4] { 0, 5, 10, 1 };
-                _layout.BitsForComponent = new int[4] { 5, 5, 5, 1 };
-                return _layout;
+                IntPtr hdl = coreapi.LoadLibrary("granny2.dll");
+                if (hdl != IntPtr.Zero)
+                {
+                    IntPtr addr = coreapi.GetProcAddress(hdl, "GrannyRGBA5551PixelFormat");
+                    if (addr != IntPtr.Zero)
+                    {
+                        gr2lib.core.coretypes.native.Layout _native;
+                        Layout _tmp_layout = new Layout();
+                        _native = (gr2lib.core.coretypes.native.Layout)Marshal.PtrToStructure(addr, typeof(gr2lib.core.coretypes.native.Layout));
+                        _tmp_layout.BytesPerPixel = Marshal.ReadInt32((IntPtr)_native.BytesPerPixel);
+                        for (int i = 0; i < _native.ShiftForComponent.Length; i++) { _tmp_layout.ShiftForComponent[i] = Marshal.ReadInt32((IntPtr)_native.ShiftForComponent[i]); }
+                        for (int i = 0; i < _native.BitsForComponent.Length; i++) { _tmp_layout.BitsForComponent[i] = Marshal.ReadInt32((IntPtr)_native.BitsForComponent[i]); }
+                        _tmp_layout.NativePointer = (IntPtr)_native.BytesPerPixel;
+                        return _tmp_layout;
+                    }
+                    else
+                    {
+                        return new Layout();
+                    }
+                }
+                else
+                {
+                    return new Layout();
+                }
             }
+            #endregion
         }
         #endregion
-
         #region Pixel Layout: GrannyRGBA4444PixelFormat
         /// <summary>
         /// 16bpp  4-bit red, 4-bit green, 4-bit blue, 4-bit alpha
         /// </summary>
         public static Layout GrannyRGBA4444PixelFormat
         {
+            #region Get GrannyRGBA4444PixelFormat Layout
             get
             {
-                int bits_per_pixel = 16;
-                int bytes_per_pixel = bits_per_pixel / 8;
-                Layout _layout = new Layout();
-                _layout.BytesPerPixel = bytes_per_pixel;
-                _layout.ShiftForComponent = new int[4] { 0, 4, 8, 12 };
-                _layout.BitsForComponent = new int[4] { 4, 4, 4, 4 };
-                return _layout;
+                IntPtr hdl = coreapi.LoadLibrary("granny2.dll");
+                if (hdl != IntPtr.Zero)
+                {
+                    IntPtr addr = coreapi.GetProcAddress(hdl, "GrannyRGBA4444PixelFormat");
+                    if (addr != IntPtr.Zero)
+                    {
+                        gr2lib.core.coretypes.native.Layout _native;
+                        Layout _tmp_layout = new Layout();
+                        _native = (gr2lib.core.coretypes.native.Layout)Marshal.PtrToStructure(addr, typeof(gr2lib.core.coretypes.native.Layout));
+                        _tmp_layout.BytesPerPixel = Marshal.ReadInt32((IntPtr)_native.BytesPerPixel);
+                        for (int i = 0; i < _native.ShiftForComponent.Length; i++) { _tmp_layout.ShiftForComponent[i] = Marshal.ReadInt32((IntPtr)_native.ShiftForComponent[i]); }
+                        for (int i = 0; i < _native.BitsForComponent.Length; i++) { _tmp_layout.BitsForComponent[i] = Marshal.ReadInt32((IntPtr)_native.BitsForComponent[i]); }
+                        _tmp_layout.NativePointer = (IntPtr)_native.BytesPerPixel;
+                        return _tmp_layout;
+                    }
+                    else
+                    {
+                        return new Layout();
+                    }
+                }
+                else
+                {
+                    return new Layout();
+                }
             }
+            #endregion
         }
         #endregion
-
         #region Pixel Layout: GrannyRGB888PixelFormat
         /// <summary>
         /// 24bpp  8-bit red, 8-bit green, 8-bit blue
         /// </summary>
         public static Layout GrannyRGB888PixelFormat
         {
+            #region Get GrannyRGB888PixelFormat Layout
             get
             {
-                int bits_per_pixel = 24;
-                int bytes_per_pixel = bits_per_pixel / 8;
-                Layout _layout = new Layout();
-                _layout.BytesPerPixel = bytes_per_pixel;
-                _layout.ShiftForComponent = new int[3] { 0, 8, 16};
-                _layout.BitsForComponent = new int[3] { 8, 8, 8};
-                return _layout;
+                IntPtr hdl = coreapi.LoadLibrary("granny2.dll");
+                if (hdl != IntPtr.Zero)
+                {
+                    IntPtr addr = coreapi.GetProcAddress(hdl, "GrannyRGB888PixelFormat");
+                    if (addr != IntPtr.Zero)
+                    {
+                        gr2lib.core.coretypes.native.Layout _native;
+                        Layout _tmp_layout = new Layout();
+                        _native = (gr2lib.core.coretypes.native.Layout)Marshal.PtrToStructure(addr, typeof(gr2lib.core.coretypes.native.Layout));
+                        _tmp_layout.BytesPerPixel = Marshal.ReadInt32((IntPtr)_native.BytesPerPixel);
+                        for (int i = 0; i < _native.ShiftForComponent.Length; i++) { _tmp_layout.ShiftForComponent[i] = Marshal.ReadInt32((IntPtr)_native.ShiftForComponent[i]); }
+                        for (int i = 0; i < _native.BitsForComponent.Length; i++) { _tmp_layout.BitsForComponent[i] = Marshal.ReadInt32((IntPtr)_native.BitsForComponent[i]); }
+                        _tmp_layout.NativePointer = (IntPtr)_native.BytesPerPixel;
+                        return _tmp_layout;
+                    }
+                    else
+                    {
+                        return new Layout();
+                    }
+                }
+                else
+                {
+                    return new Layout();
+                }
             }
+            #endregion
         }
         #endregion
-
         #region Pixel Layout: GrannyRGBA8888PixelFormat
         /// <summary>
         /// 32bpp  8-bit red, 8-bit green, 8-bit blue, 8-bit alpha
         /// </summary>
         public static Layout GrannyRGBA8888PixelFormat
         {
+            #region Get GrannyRGBA8888PixelFormat Layout
             get
             {
-                int bits_per_pixel = 32;
-                int bytes_per_pixel = bits_per_pixel / 8;
-                Layout _layout = new Layout();
-                _layout.BytesPerPixel = bytes_per_pixel;
-
-                _layout.ShiftForComponent = new int[4] { 0, 8, 16, 24 };
-                _layout.BitsForComponent = new int[4] { 8, 8, 8, 8 };
-                return _layout;
-
+                IntPtr hdl = coreapi.LoadLibrary("granny2.dll");
+                if (hdl != IntPtr.Zero)
+                {
+                    IntPtr addr = coreapi.GetProcAddress(hdl, "GrannyRGBA8888PixelFormat");
+                    if (addr != IntPtr.Zero)
+                    {
+                        gr2lib.core.coretypes.native.Layout _native_ptr;
+                        gr2lib.core.coretypes.native.Layout _native;
+                        Layout _tmp_layout = new Layout();
+                        _native_ptr = (gr2lib.core.coretypes.native.Layout)Marshal.PtrToStructure(addr, typeof(gr2lib.core.coretypes.native.Layout));
+                        _native = (gr2lib.core.coretypes.native.Layout)Marshal.PtrToStructure((IntPtr)_native_ptr.BytesPerPixel, typeof(gr2lib.core.coretypes.native.Layout));
+                        _tmp_layout.BytesPerPixel = _native.BytesPerPixel;
+                        _tmp_layout.ShiftForComponent = _native.ShiftForComponent;
+                        _tmp_layout.BitsForComponent = _native.BitsForComponent;
+                        return _tmp_layout;
+                    }
+                    else
+                    {
+                        return new Layout();
+                    }
+                }
+                else
+                {
+                    return new Layout();
+                }
             }
+            #endregion
         }
         #endregion
-
         #region Pixel Layout: GrannyARGB8888PixelFormat
         /// <summary>
-        /// 24bpp  8-bit alpha, 8-bit red, 8-bit green, 8-bit blue
+        /// 32bpp  8-bit red, 8-bit green, 8-bit blue, 8-bit alpha
         /// </summary>
         public static Layout GrannyARGB8888PixelFormat
         {
+            #region Get GrannyARGB8888PixelFormat Layout
             get
             {
-                int bits_per_pixel = 24;
-                int bytes_per_pixel = bits_per_pixel / 8;
-                Layout _layout = new Layout();
-                _layout.BytesPerPixel = bytes_per_pixel;
-                _layout.ShiftForComponent = new int[4] { 24, 0, 8, 16 };
-                _layout.BitsForComponent = new int[4] { 8, 8, 8, 8 };
-                return _layout;
+                IntPtr hdl = coreapi.LoadLibrary("granny2.dll");
+                if (hdl != IntPtr.Zero)
+                {
+                    IntPtr addr = coreapi.GetProcAddress(hdl, "GrannyARGB8888PixelFormat");
+                    if (addr != IntPtr.Zero)
+                    {
+                        gr2lib.core.coretypes.native.Layout _native_ptr;
+                        gr2lib.core.coretypes.native.Layout _native;
+                        Layout _tmp_layout = new Layout();
+                        _native_ptr = (gr2lib.core.coretypes.native.Layout)Marshal.PtrToStructure(addr, typeof(gr2lib.core.coretypes.native.Layout));
+                        _native = (gr2lib.core.coretypes.native.Layout)Marshal.PtrToStructure((IntPtr)_native_ptr.BytesPerPixel, typeof(gr2lib.core.coretypes.native.Layout));
+                        _tmp_layout.BytesPerPixel = _native.BytesPerPixel;
+                        _tmp_layout.ShiftForComponent = _native.ShiftForComponent;
+                        _tmp_layout.BitsForComponent = _native.BitsForComponent;
+                        return _tmp_layout;
+                    }
+                    else
+                    {
+                        return new Layout();
+                    }
+                }
+                else
+                {
+                    return new Layout();
+                }
             }
+            #endregion
         }
         #endregion
-
         #region Pixel Layout: GrannyBGR555PixelFormat
         /// <summary>
-        /// 16bpp  5-bit red, 5-bit green, 5-bit blue
+        /// 16bpp  5-bit blue, 5-bit green, 5-bit red
         /// </summary>
         public static Layout GrannyBGR555PixelFormat
         {
+            #region Get GrannyBGR555PixelFormat Layout
             get
             {
-                int bits_per_pixel = 16;
-                int bytes_per_pixel = bits_per_pixel / 8;
-                Layout _layout = new Layout();
-                _layout.BytesPerPixel = bytes_per_pixel;
-                _layout.ShiftForComponent = new int[3] { 10, 5, 0 };
-                _layout.BitsForComponent = new int[3] { 5, 5, 5 };
-                return _layout;
+                IntPtr hdl = coreapi.LoadLibrary("granny2.dll");
+                if (hdl != IntPtr.Zero)
+                {
+                    IntPtr addr = coreapi.GetProcAddress(hdl, "GrannyBGR555PixelFormat");
+                    if (addr != IntPtr.Zero)
+                    {
+                        gr2lib.core.coretypes.native.Layout _native_ptr;
+                        gr2lib.core.coretypes.native.Layout _native;
+                        Layout _tmp_layout = new Layout();
+                        _native_ptr = (gr2lib.core.coretypes.native.Layout)Marshal.PtrToStructure(addr, typeof(gr2lib.core.coretypes.native.Layout));
+                        _native = (gr2lib.core.coretypes.native.Layout)Marshal.PtrToStructure((IntPtr)_native_ptr.BytesPerPixel, typeof(gr2lib.core.coretypes.native.Layout));
+                        _tmp_layout.BytesPerPixel = _native.BytesPerPixel;
+                        _tmp_layout.ShiftForComponent = _native.ShiftForComponent;
+                        _tmp_layout.BitsForComponent = _native.BitsForComponent;
+                        return _tmp_layout;
+                    }
+                    else
+                    {
+                        return new Layout();
+                    }
+                }
+                else
+                {
+                    return new Layout();
+                }
             }
+            #endregion
         }
         #endregion
-
-
         #region Pixel Layout: GrannyBGR565PixelFormat
         /// <summary>
-        /// 16bpp  5-bit red, 6-bit green, 5-bit blue
+        /// 16bpp  5-bit blue, 6-bit green, 5-bit red
         /// </summary>
         public static Layout GrannyBGR565PixelFormat
         {
+            #region Get GrannyBGR565PixelFormat Layout
             get
             {
-                int bits_per_pixel = 16;
-                int bytes_per_pixel = bits_per_pixel / 8;
-                Layout _layout = new Layout();
-                _layout.BytesPerPixel = bytes_per_pixel;
-                _layout.ShiftForComponent = new int[3] { 11, 6, 0 };
-                _layout.BitsForComponent = new int[3] { 5, 6, 5 };
-                return _layout;
+                IntPtr hdl = coreapi.LoadLibrary("granny2.dll");
+                if (hdl != IntPtr.Zero)
+                {
+                    IntPtr addr = coreapi.GetProcAddress(hdl, "GrannyBGR565PixelFormat");
+                    if (addr != IntPtr.Zero)
+                    {
+                        gr2lib.core.coretypes.native.Layout _native_ptr;
+                        gr2lib.core.coretypes.native.Layout _native;
+                        Layout _tmp_layout = new Layout();
+                        _native_ptr = (gr2lib.core.coretypes.native.Layout)Marshal.PtrToStructure(addr, typeof(gr2lib.core.coretypes.native.Layout));
+                        _native = (gr2lib.core.coretypes.native.Layout)Marshal.PtrToStructure((IntPtr)_native_ptr.BytesPerPixel, typeof(gr2lib.core.coretypes.native.Layout));
+                        _tmp_layout.BytesPerPixel = _native.BytesPerPixel;
+                        _tmp_layout.ShiftForComponent = _native.ShiftForComponent;
+                        _tmp_layout.BitsForComponent = _native.BitsForComponent;
+                        return _tmp_layout;
+                    }
+                    else
+                    {
+                        return new Layout();
+                    }
+                }
+                else
+                {
+                    return new Layout();
+                }
             }
+            #endregion
         }
         #endregion
-
         #region Pixel Layout: GrannyBGRA5551PixelFormat
         /// <summary>
         /// 16bpp  5-bit blue, 5-bit green, 5-bit red, 1-bit alpha
         /// </summary>
         public static Layout GrannyBGRA5551PixelFormat
         {
+            #region Get GrannyBGRA5551PixelFormat Layout
             get
             {
-                int bits_per_pixel = 16;
-                int bytes_per_pixel = bits_per_pixel / 8;
-                Layout _layout = new Layout();
-                _layout.BytesPerPixel = bytes_per_pixel;
-                _layout.ShiftForComponent = new int[4] { 10, 5, 0, 1 };
-                _layout.BitsForComponent = new int[4] { 5, 5, 5, 1 };
-                return _layout;
+                IntPtr hdl = coreapi.LoadLibrary("granny2.dll");
+                if (hdl != IntPtr.Zero)
+                {
+                    IntPtr addr = coreapi.GetProcAddress(hdl, "GrannyBGRA5551PixelFormat");
+                    if (addr != IntPtr.Zero)
+                    {
+                        gr2lib.core.coretypes.native.Layout _native_ptr;
+                        gr2lib.core.coretypes.native.Layout _native;
+                        Layout _tmp_layout = new Layout();
+                        _native_ptr = (gr2lib.core.coretypes.native.Layout)Marshal.PtrToStructure(addr, typeof(gr2lib.core.coretypes.native.Layout));
+                        _native = (gr2lib.core.coretypes.native.Layout)Marshal.PtrToStructure((IntPtr)_native_ptr.BytesPerPixel, typeof(gr2lib.core.coretypes.native.Layout));
+                        _tmp_layout.BytesPerPixel = _native.BytesPerPixel;
+                        _tmp_layout.ShiftForComponent = _native.ShiftForComponent;
+                        _tmp_layout.BitsForComponent = _native.BitsForComponent;
+                        return _tmp_layout;
+                    }
+                    else
+                    {
+                        return new Layout();
+                    }
+                }
+                else
+                {
+                    return new Layout();
+                }
             }
+            #endregion
         }
         #endregion
-
         #region Pixel Layout: GrannyBGRA4444PixelFormat
         /// <summary>
-        ///  16bpp  4-bit red, 4-bit green, 4-bit blue, 4-bit alpha
+        /// 16bpp  4-bit blue, 4-bit green, 4-bit red, 4-bit alpha
         /// </summary>
         public static Layout GrannyBGRA4444PixelFormat
         {
+            #region Get GrannyBGRA4444PixelFormat Layout
             get
             {
-                int bits_per_pixel = 16;
-                int bytes_per_pixel = bits_per_pixel / 8;
-                Layout _layout = new Layout();
-                _layout.BytesPerPixel = bytes_per_pixel;
-                _layout.ShiftForComponent = new int[4] { 8, 4, 0, 12 };
-                _layout.BitsForComponent = new int[4] { 4, 4, 4, 4 };
-                return _layout;
-
+                IntPtr hdl = coreapi.LoadLibrary("granny2.dll");
+                if (hdl != IntPtr.Zero)
+                {
+                    IntPtr addr = coreapi.GetProcAddress(hdl, "GrannyBGRA4444PixelFormat");
+                    if (addr != IntPtr.Zero)
+                    {
+                        gr2lib.core.coretypes.native.Layout _native_ptr;
+                        gr2lib.core.coretypes.native.Layout _native;
+                        Layout _tmp_layout = new Layout();
+                        _native_ptr = (gr2lib.core.coretypes.native.Layout)Marshal.PtrToStructure(addr, typeof(gr2lib.core.coretypes.native.Layout));
+                        _native = (gr2lib.core.coretypes.native.Layout)Marshal.PtrToStructure((IntPtr)_native_ptr.BytesPerPixel, typeof(gr2lib.core.coretypes.native.Layout));
+                        _tmp_layout.BytesPerPixel = _native.BytesPerPixel;
+                        _tmp_layout.ShiftForComponent = _native.ShiftForComponent;
+                        _tmp_layout.BitsForComponent = _native.BitsForComponent;
+                        return _tmp_layout;
+                    }
+                    else
+                    {
+                        return new Layout();
+                    }
+                }
+                else
+                {
+                    return new Layout();
+                }
             }
+            #endregion
         }
         #endregion
-
         #region Pixel Layout: GrannyBGR888PixelFormat
         /// <summary>
         /// 24bpp  8-bit blue, 8-bit green, 8-bit red
         /// </summary>
         public static Layout GrannyBGR888PixelFormat
         {
+            #region Get GrannyBGR888PixelFormat Layout
             get
             {
-                int bits_per_pixel = 24;
-                int bytes_per_pixel = bits_per_pixel / 8;
-                Layout _layout = new Layout();
-                _layout.BytesPerPixel = bytes_per_pixel;
-                _layout.ShiftForComponent = new int[3] { 16, 8, 0 };
-                _layout.BitsForComponent = new int[3] { 8, 8, 8 };
-                return _layout;
+                IntPtr hdl = coreapi.LoadLibrary("granny2.dll");
+                if (hdl != IntPtr.Zero)
+                {
+                    IntPtr addr = coreapi.GetProcAddress(hdl, "GrannyBGR888PixelFormat");
+                    if (addr != IntPtr.Zero)
+                    {
+                        gr2lib.core.coretypes.native.Layout _native_ptr;
+                        gr2lib.core.coretypes.native.Layout _native;
+                        Layout _tmp_layout = new Layout();
+                        _native_ptr = (gr2lib.core.coretypes.native.Layout)Marshal.PtrToStructure(addr, typeof(gr2lib.core.coretypes.native.Layout));
+                        _native = (gr2lib.core.coretypes.native.Layout)Marshal.PtrToStructure((IntPtr)_native_ptr.BytesPerPixel, typeof(gr2lib.core.coretypes.native.Layout));
+                        _tmp_layout.BytesPerPixel = _native.BytesPerPixel;
+                        _tmp_layout.ShiftForComponent = _native.ShiftForComponent;
+                        _tmp_layout.BitsForComponent = _native.BitsForComponent;
+                        return _tmp_layout;
+                    }
+                    else
+                    {
+                        return new Layout();
+                    }
+                }
+                else
+                {
+                    return new Layout();
+                }
             }
+            #endregion
         }
         #endregion
-
         #region Pixel Layout: GrannyBGRA8888PixelFormat
         /// <summary>
         /// 32bpp  8-bit blue, 8-bit green, 8-bit red, 8-bit alpha
         /// </summary>
         public static Layout GrannyBGRA8888PixelFormat
         {
+            #region Get GrannyBGRA8888PixelFormat Layout
             get
             {
-                int bits_per_pixel = 32;
-                int bytes_per_pixel = bits_per_pixel / 8;
-                Layout _layout = new Layout();
-                _layout.BytesPerPixel = bytes_per_pixel;
-                _layout.ShiftForComponent = new int[4] { 16, 8, 0, 24 };
-                _layout.BitsForComponent = new int[4] { 8, 8, 8, 8 };
-                return _layout;
+                IntPtr hdl = coreapi.LoadLibrary("granny2.dll");
+                if (hdl != IntPtr.Zero)
+                {
+                    IntPtr addr = coreapi.GetProcAddress(hdl, "GrannyBGRA8888PixelFormat");
+                    if (addr != IntPtr.Zero)
+                    {
+                        gr2lib.core.coretypes.native.Layout _native_ptr;
+                        gr2lib.core.coretypes.native.Layout _native;
+                        Layout _tmp_layout = new Layout();
+                        _native_ptr = (gr2lib.core.coretypes.native.Layout)Marshal.PtrToStructure(addr, typeof(gr2lib.core.coretypes.native.Layout));
+                        _native = (gr2lib.core.coretypes.native.Layout)Marshal.PtrToStructure((IntPtr)_native_ptr.BytesPerPixel, typeof(gr2lib.core.coretypes.native.Layout));
+                        _tmp_layout.BytesPerPixel = _native.BytesPerPixel;
+                        _tmp_layout.ShiftForComponent = _native.ShiftForComponent;
+                        _tmp_layout.BitsForComponent = _native.BitsForComponent;
+                        return _tmp_layout;
+                    }
+                    else
+                    {
+                        return new Layout();
+                    }
+                }
+                else
+                {
+                    return new Layout();
+                }
             }
+            #endregion
         }
         #endregion
     }

 

  ViewVC Help
Powered by ViewVC 1.1.22