/[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/22 14:55:47	167
+++ trunk/gr2lib/core/typedefs/granny_pixel_layouts.cs	2010/07/24 06:31:50	191
@@ -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,41 +9,34 @@
 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,
-        //GrannyRGB565PixelFormat,
-        //GrannyRGBA5551PixelFormat,
-        //GrannyRGBA4444PixelFormat,
-        //GrannyRGB888PixelFormat,
-        //GrannyRGBA8888PixelFormat,
-        //GrannyARGB8888PixelFormat,
-        //GrannyBGR555PixelFormat,
-        //GrannyBGR565PixelFormat,
-        //GrannyBGRA5551PixelFormat,
-        //GrannyBGRA4444PixelFormat,
-        //GrannyBGR888PixelFormat,
-        //GrannyBGRA8888PixelFormat
-
-        GrannyBGR555PixelFormat,
-        GrannyBGR565PixelFormat,
-        GrannyBGRA5551PixelFormat,
-        GrannyBGRA4444PixelFormat,
-        GrannyBGR888PixelFormat,
-        GrannyBGRA8888PixelFormat,
         GrannyRGB555PixelFormat,
         GrannyRGB565PixelFormat,
         GrannyRGBA5551PixelFormat,
         GrannyRGBA4444PixelFormat,
         GrannyRGB888PixelFormat,
         GrannyRGBA8888PixelFormat,
-        GrannyARGB8888PixelFormat
-
+        GrannyARGB8888PixelFormat,
+        GrannyBGR555PixelFormat,
+        GrannyBGR565PixelFormat,
+        GrannyBGRA5551PixelFormat,
+        GrannyBGRA4444PixelFormat,
+        GrannyBGR888PixelFormat,
+        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)
@@ -63,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
@@ -87,10 +81,10 @@
             #region Get GrannyRGB555PixelFormat Layout
             get
             {
-                IntPtr hdl = coreapi.LoadLibrary("granny2.dll");
+                IntPtr hdl = coreapi.ExternalSupport.LoadLibrary("granny2.dll");
                 if (hdl != IntPtr.Zero)
                 {
-                    IntPtr addr = coreapi.GetProcAddress(hdl, "GrannyRGB555PixelFormat");
+                    IntPtr addr = coreapi.ExternalSupport.GetProcAddress(hdl, "GrannyRGB555PixelFormat");
                     if (addr != IntPtr.Zero)
                     {
                         gr2lib.core.coretypes.native.Layout _native_ptr;
@@ -117,8 +111,6 @@
             #endregion
         }
         #endregion
-
-
         #region Pixel Layout: GrannyRGB565PixelFormat
         /// <summary>
         /// 16bpp  5-bit red, 6-bit green, 5-bit blue
@@ -128,10 +120,10 @@
             #region Get GrannyRGB565PixelFormat Layout
             get
             {
-                IntPtr hdl = coreapi.LoadLibrary("granny2.dll");
+                IntPtr hdl = coreapi.ExternalSupport.LoadLibrary("granny2.dll");
                 if (hdl != IntPtr.Zero)
                 {
-                    IntPtr addr = coreapi.GetProcAddress(hdl, "GrannyRGB565PixelFormat");
+                    IntPtr addr = coreapi.ExternalSupport.GetProcAddress(hdl, "GrannyRGB565PixelFormat");
                     if (addr != IntPtr.Zero)
                     {
                         gr2lib.core.coretypes.native.Layout _native_ptr;
@@ -158,7 +150,6 @@
             #endregion
         }
         #endregion
-
         #region Pixel Layout: GrannyRGBA5551PixelFormat
         /// <summary>
         /// 16bpp  5-bit red, 5-bit green, 5-bit blue, 1-bit alpha
@@ -168,10 +159,10 @@
             #region Get GrannyRGBA5551PixelFormat Layout
             get
             {
-                IntPtr hdl = coreapi.LoadLibrary("granny2.dll");
+                IntPtr hdl = coreapi.ExternalSupport.LoadLibrary("granny2.dll");
                 if (hdl != IntPtr.Zero)
                 {
-                    IntPtr addr = coreapi.GetProcAddress(hdl, "GrannyRGBA5551PixelFormat");
+                    IntPtr addr = coreapi.ExternalSupport.GetProcAddress(hdl, "GrannyRGBA5551PixelFormat");
                     if (addr != IntPtr.Zero)
                     {
                         gr2lib.core.coretypes.native.Layout _native_ptr;
@@ -207,10 +198,10 @@
             #region Get GrannyRGBA4444PixelFormat Layout
             get
             {
-                IntPtr hdl = coreapi.LoadLibrary("granny2.dll");
+                IntPtr hdl = coreapi.ExternalSupport.LoadLibrary("granny2.dll");
                 if (hdl != IntPtr.Zero)
                 {
-                    IntPtr addr = coreapi.GetProcAddress(hdl, "GrannyRGBA4444PixelFormat");
+                    IntPtr addr = coreapi.ExternalSupport.GetProcAddress(hdl, "GrannyRGBA4444PixelFormat");
                     if (addr != IntPtr.Zero)
                     {
                         gr2lib.core.coretypes.native.Layout _native_ptr;
@@ -246,10 +237,10 @@
             #region Get GrannyRGB888PixelFormat Layout
             get
             {
-                IntPtr hdl = coreapi.LoadLibrary("granny2.dll");
+                IntPtr hdl = coreapi.ExternalSupport.LoadLibrary("granny2.dll");
                 if (hdl != IntPtr.Zero)
                 {
-                    IntPtr addr = coreapi.GetProcAddress(hdl, "GrannyRGB888PixelFormat");
+                    IntPtr addr = coreapi.ExternalSupport.GetProcAddress(hdl, "GrannyRGB888PixelFormat");
                     if (addr != IntPtr.Zero)
                     {
                         gr2lib.core.coretypes.native.Layout _native_ptr;
@@ -285,10 +276,10 @@
             #region Get GrannyRGBA8888PixelFormat Layout
             get
             {
-                IntPtr hdl = coreapi.LoadLibrary("granny2.dll");
+                IntPtr hdl = coreapi.ExternalSupport.LoadLibrary("granny2.dll");
                 if (hdl != IntPtr.Zero)
                 {
-                    IntPtr addr = coreapi.GetProcAddress(hdl, "GrannyRGBA8888PixelFormat");
+                    IntPtr addr = coreapi.ExternalSupport.GetProcAddress(hdl, "GrannyRGBA8888PixelFormat");
                     if (addr != IntPtr.Zero)
                     {
                         gr2lib.core.coretypes.native.Layout _native_ptr;
@@ -324,10 +315,10 @@
             #region Get GrannyARGB8888PixelFormat Layout
             get
             {
-                IntPtr hdl = coreapi.LoadLibrary("granny2.dll");
+                IntPtr hdl = coreapi.ExternalSupport.LoadLibrary("granny2.dll");
                 if (hdl != IntPtr.Zero)
                 {
-                    IntPtr addr = coreapi.GetProcAddress(hdl, "GrannyARGB8888PixelFormat");
+                    IntPtr addr = coreapi.ExternalSupport.GetProcAddress(hdl, "GrannyARGB8888PixelFormat");
                     if (addr != IntPtr.Zero)
                     {
                         gr2lib.core.coretypes.native.Layout _native_ptr;
@@ -354,6 +345,33 @@
             #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
+                {
+                    GCHandle layoutHandle = GCHandle.Alloc(_tmp_layout.BytesPerPixel, GCHandleType.Pinned);                    
+                    _tmp_layout.NativePointer = layoutHandle.AddrOfPinnedObject();
+                    layoutHandle.Free();
+                }            
+                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
@@ -363,10 +381,10 @@
             #region Get GrannyBGR555PixelFormat Layout
             get
             {
-                IntPtr hdl = coreapi.LoadLibrary("granny2.dll");
+                IntPtr hdl = coreapi.ExternalSupport.LoadLibrary("granny2.dll");
                 if (hdl != IntPtr.Zero)
                 {
-                    IntPtr addr = coreapi.GetProcAddress(hdl, "GrannyBGR555PixelFormat");
+                    IntPtr addr = coreapi.ExternalSupport.GetProcAddress(hdl, "GrannyBGR555PixelFormat");
                     if (addr != IntPtr.Zero)
                     {
                         gr2lib.core.coretypes.native.Layout _native_ptr;
@@ -402,10 +420,10 @@
             #region Get GrannyBGR565PixelFormat Layout
             get
             {
-                IntPtr hdl = coreapi.LoadLibrary("granny2.dll");
+                IntPtr hdl = coreapi.ExternalSupport.LoadLibrary("granny2.dll");
                 if (hdl != IntPtr.Zero)
                 {
-                    IntPtr addr = coreapi.GetProcAddress(hdl, "GrannyBGR565PixelFormat");
+                    IntPtr addr = coreapi.ExternalSupport.GetProcAddress(hdl, "GrannyBGR565PixelFormat");
                     if (addr != IntPtr.Zero)
                     {
                         gr2lib.core.coretypes.native.Layout _native_ptr;
@@ -441,10 +459,10 @@
             #region Get GrannyBGRA5551PixelFormat Layout
             get
             {
-                IntPtr hdl = coreapi.LoadLibrary("granny2.dll");
+                IntPtr hdl = coreapi.ExternalSupport.LoadLibrary("granny2.dll");
                 if (hdl != IntPtr.Zero)
                 {
-                    IntPtr addr = coreapi.GetProcAddress(hdl, "GrannyBGRA5551PixelFormat");
+                    IntPtr addr = coreapi.ExternalSupport.GetProcAddress(hdl, "GrannyBGRA5551PixelFormat");
                     if (addr != IntPtr.Zero)
                     {
                         gr2lib.core.coretypes.native.Layout _native_ptr;
@@ -480,10 +498,10 @@
             #region Get GrannyBGRA4444PixelFormat Layout
             get
             {
-                IntPtr hdl = coreapi.LoadLibrary("granny2.dll");
+                IntPtr hdl = coreapi.ExternalSupport.LoadLibrary("granny2.dll");
                 if (hdl != IntPtr.Zero)
                 {
-                    IntPtr addr = coreapi.GetProcAddress(hdl, "GrannyBGRA4444PixelFormat");
+                    IntPtr addr = coreapi.ExternalSupport.GetProcAddress(hdl, "GrannyBGRA4444PixelFormat");
                     if (addr != IntPtr.Zero)
                     {
                         gr2lib.core.coretypes.native.Layout _native_ptr;
@@ -519,10 +537,10 @@
             #region Get GrannyBGR888PixelFormat Layout
             get
             {
-                IntPtr hdl = coreapi.LoadLibrary("granny2.dll");
+                IntPtr hdl = coreapi.ExternalSupport.LoadLibrary("granny2.dll");
                 if (hdl != IntPtr.Zero)
                 {
-                    IntPtr addr = coreapi.GetProcAddress(hdl, "GrannyBGR888PixelFormat");
+                    IntPtr addr = coreapi.ExternalSupport.GetProcAddress(hdl, "GrannyBGR888PixelFormat");
                     if (addr != IntPtr.Zero)
                     {
                         gr2lib.core.coretypes.native.Layout _native_ptr;
@@ -558,10 +576,10 @@
             #region Get GrannyBGRA8888PixelFormat Layout
             get
             {
-                IntPtr hdl = coreapi.LoadLibrary("granny2.dll");
+                IntPtr hdl = coreapi.ExternalSupport.LoadLibrary("granny2.dll");
                 if (hdl != IntPtr.Zero)
                 {
-                    IntPtr addr = coreapi.GetProcAddress(hdl, "GrannyBGRA8888PixelFormat");
+                    IntPtr addr = coreapi.ExternalSupport.GetProcAddress(hdl, "GrannyBGRA8888PixelFormat");
                     if (addr != IntPtr.Zero)
                     {
                         gr2lib.core.coretypes.native.Layout _native_ptr;
@@ -589,4 +607,9 @@
         }
         #endregion
     }
+    #endregion
+
+#if HIDE_MISSING_XML_COMMENTS_FOR_TYPEDEFS
+#pragma warning restore 1591
+#endif
 }

 

  ViewVC Help
Powered by ViewVC 1.1.22