/[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 08:11:31	148
+++ 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,21 +57,21 @@
                 default: return granny_pixel_layouts.GrannyDefaultPixelLayout;
             }
         }
-
-
+        #endregion
         #region Pixel Layout: GrannyDefaultPixelLayout
         /// <summary>
         /// 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
@@ -78,13 +87,15 @@
                     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 = (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;
+                        _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
@@ -100,8 +111,6 @@
             #endregion
         }
         #endregion
-
-
         #region Pixel Layout: GrannyRGB565PixelFormat
         /// <summary>
         /// 16bpp  5-bit red, 6-bit green, 5-bit blue
@@ -117,13 +126,15 @@
                     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 = (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;
+                        _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
@@ -139,7 +150,6 @@
             #endregion
         }
         #endregion
-
         #region Pixel Layout: GrannyRGBA5551PixelFormat
         /// <summary>
         /// 16bpp  5-bit red, 5-bit green, 5-bit blue, 1-bit alpha
@@ -155,13 +165,15 @@
                     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 = (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;
+                        _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
@@ -192,13 +204,15 @@
                     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 = (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;
+                        _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
@@ -229,13 +243,15 @@
                     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 = (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;
+                        _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
@@ -271,6 +287,7 @@
                         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;
@@ -309,6 +326,7 @@
                         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;
@@ -327,6 +345,36 @@
             #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
+            {
+                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 blue, 5-bit green, 5-bit red
@@ -347,6 +395,7 @@
                         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;
@@ -385,6 +434,7 @@
                         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;
@@ -423,6 +473,7 @@
                         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;
@@ -461,6 +512,7 @@
                         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;
@@ -499,6 +551,7 @@
                         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;
@@ -537,6 +590,7 @@
                         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;
@@ -556,4 +610,9 @@
         }
         #endregion
     }
+    #endregion
+
+#if HIDE_MISSING_XML_COMMENTS_FOR_TYPEDEFS
+#pragma warning restore 1591
+#endif
 }

 

  ViewVC Help
Powered by ViewVC 1.1.22