/[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/24 04:16:43	187
@@ -1,4 +1,5 @@
-´╗┐using System;
+´╗┐#define HIDE_MISSING_XML_COMMENTS_FOR_TYPEDEFS // when defined will disable warnings about missing XML comments for all typedefs (CS1591)
+using System;
 using System.Collections.Generic;
 using System.Linq;
 using System.Text;
@@ -8,6 +9,11 @@
 namespace gr2lib.core.typedefs
 {
 
+#if HIDE_MISSING_XML_COMMENTS_FOR_TYPEDEFS
+#pragma warning disable 1591
+#endif
+
+    #region public enum granny_pixel_layout
     public enum granny_pixel_layout
     {
         GrannyRGB555PixelFormat,
@@ -22,12 +28,15 @@
         GrannyBGRA5551PixelFormat,
         GrannyBGRA4444PixelFormat,
         GrannyBGR888PixelFormat,
-        GrannyBGRA8888PixelFormat
+        GrannyBGRA8888PixelFormat,
+        GrannyABGR8888PixelFormat
     }
+    #endregion
 
+    #region public struct granny_pixel_layouts
     public struct granny_pixel_layouts
     {
-
+        #region GetPixelLayoutFromEnum(granny_pixel_layout layout_type)
         public static Layout GetPixelLayoutFromEnum(granny_pixel_layout layout_type)
         {
             switch (layout_type)
@@ -48,270 +57,562 @@
                 default: return granny_pixel_layouts.GrannyDefaultPixelLayout;
             }
         }
-
-
+        #endregion
         #region Pixel Layout: GrannyDefaultPixelLayout
         /// <summary>
-        /// default pixel layout
+        /// default pixel layout (GrannyRGBA8888PixelFormat)
         /// </summary>
         public static Layout GrannyDefaultPixelLayout
         {
+            #region Get GrannyDefaultPixelLayout
             get
             {
                 return GetPixelLayoutFromEnum(granny_pixel_layout.GrannyRGBA8888PixelFormat);
             }
+            #endregion
         }
         #endregion
-
         #region Pixel Layout: GrannyRGB555PixelFormat
         /// <summary>
         /// 16bpp  5-bit red, 5-bit green, 5-bit blue
         /// </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_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.NativePointer = (IntPtr)_native_ptr.BytesPerPixel;
+                        _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: 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_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.NativePointer = (IntPtr)_native_ptr.BytesPerPixel;
+                        _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: GrannyRGBA5551PixelFormat
         /// <summary>
         /// 16bpp  5-bit red, 5-bit green, 5-bit blue, 1-bit alpha
         /// </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_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.NativePointer = (IntPtr)_native_ptr.BytesPerPixel;
+                        _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: 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_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.NativePointer = (IntPtr)_native_ptr.BytesPerPixel;
+                        _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: 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_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.NativePointer = (IntPtr)_native_ptr.BytesPerPixel;
+                        _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: 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.NativePointer = (IntPtr)_native_ptr.BytesPerPixel;
+                        _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
+            {
+                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.NativePointer = (IntPtr)_native_ptr.BytesPerPixel;
+                        _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: GrannyABGR8888PixelFormat
+        /// <summary>
+        /// 32bpp  8-bit red, 8-bit green, 8-bit blue, 8-bit alpha
+        /// </summary>
+        public static Layout GrannyABGR8888PixelFormat
+        {
+            #region Get GrannyABGR8888PixelFormat 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;
+                Layout _tmp_layout = granny_pixel_layouts.GrannyARGB8888PixelFormat;
+
+                unsafe
+                {
+                    IntPtr layoutPTR = (IntPtr)_tmp_layout.BytesPerPixel;
+                    _tmp_layout.NativePointer = layoutPTR;
+                }            
+
+                int R = _tmp_layout.ShiftForComponent[1];
+                int B = _tmp_layout.ShiftForComponent[3];
+
+                // swap R & B
+                _tmp_layout.ShiftForComponent[1] = B;
+                _tmp_layout.ShiftForComponent[3] = R;
+                return _tmp_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.NativePointer = (IntPtr)_native_ptr.BytesPerPixel;
+                        _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.NativePointer = (IntPtr)_native_ptr.BytesPerPixel;
+                        _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.NativePointer = (IntPtr)_native_ptr.BytesPerPixel;
+                        _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.NativePointer = (IntPtr)_native_ptr.BytesPerPixel;
+                        _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.NativePointer = (IntPtr)_native_ptr.BytesPerPixel;
+                        _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.NativePointer = (IntPtr)_native_ptr.BytesPerPixel;
+                        _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
     }
+    #endregion
+
+#if HIDE_MISSING_XML_COMMENTS_FOR_TYPEDEFS
+#pragma warning restore 1591
+#endif
 }

 

  ViewVC Help
Powered by ViewVC 1.1.22