2007-12-19 Sebastien Pouliot <sebastien@ximian.com>
[mono.git] / mcs / class / System.Drawing / System.Drawing / gdipFunctions.cs
index f96a4dc2ba2b3792d0af24fa3b3ae89e31e7ab60..6c5f90c02dc53def0a90434b1e5a22cd37385f55 100644 (file)
@@ -57,7 +57,7 @@ namespace System.Drawing
                public const int LANG_NEUTRAL = 0;
                public static IntPtr Display = IntPtr.Zero;
                public static bool UseX11Drawable;
-               public static bool UseQuartzDrawable = (Environment.GetEnvironmentVariable ("MONO_MWF_USE_QUARTZ_BACKEND") != null);
+               public static bool UseQuartzDrawable = (Environment.GetEnvironmentVariable ("MONO_MWF_USE_CARBON_BACKEND") != null);
                public static bool UseCocoaDrawable = (Environment.GetEnvironmentVariable ("MONO_GDIP_USE_COCOA_BACKEND") != null);
 
                #region gdiplus.dll functions
@@ -128,35 +128,35 @@ namespace System.Drawing
                }
                
                // Copies a Ptr to an array of Points and releases the memory
-               static public void FromUnManagedMemoryToPointI(IntPtr prt, Point [] pts)
+               static public void FromUnManagedMemoryToPointI (IntPtr prt, Point [] pts)
                {                                               
-                       int nPointSize = Marshal.SizeOf(pts[0]);
+                       int nPointSize = Marshal.SizeOf (pts[0]);
                        IntPtr pos = prt;
                        for (int i=0; i<pts.Length; i++, pos = new IntPtr (pos.ToInt64 () + nPointSize))
-                               pts[i] = (Point) Marshal.PtrToStructure(pos, typeof(Point));
+                               pts[i] = (Point) Marshal.PtrToStructure (pos, typeof (Point));
                        
-                       Marshal.FreeHGlobal(prt);                       
+                       Marshal.FreeHGlobal (prt);                      
                }
                
                // Copies a Ptr to an array of Points and releases the memory
                static public void FromUnManagedMemoryToPoint (IntPtr prt, PointF [] pts)
                {                                               
-                       int nPointSize = Marshal.SizeOf(pts[0]);
+                       int nPointSize = Marshal.SizeOf (pts[0]);
                        IntPtr pos = prt;
                        for (int i=0; i<pts.Length; i++, pos = new IntPtr (pos.ToInt64 () + nPointSize))
-                               pts[i] = (PointF) Marshal.PtrToStructure(pos, typeof(Point));
+                               pts[i] = (PointF) Marshal.PtrToStructure (pos, typeof (PointF));
                        
-                       Marshal.FreeHGlobal(prt);                       
+                       Marshal.FreeHGlobal (prt);                      
                }
                
                // Copies an array of Points to unmanaged memory
-               static public IntPtr FromPointToUnManagedMemoryI(Point [] pts)
+               static public IntPtr FromPointToUnManagedMemoryI (Point [] pts)
                {
-                       int nPointSize =  Marshal.SizeOf(pts[0]);
-                       IntPtr dest = Marshal.AllocHGlobal(nPointSize* pts.Length);
+                       int nPointSize =  Marshal.SizeOf (pts[0]);
+                       IntPtr dest = Marshal.AllocHGlobal (nPointSize * pts.Length);
                        IntPtr pos = dest;
                        for (int i=0; i<pts.Length; i++, pos = new IntPtr (pos.ToInt64 () + nPointSize))
-                               Marshal.StructureToPtr(pts[i], pos, false);     
+                               Marshal.StructureToPtr (pts[i], pos, false);    
                        
                        return dest;                    
                }               
@@ -167,19 +167,19 @@ namespace System.Drawing
                        int nPointSize = Marshal.SizeOf (pts[0]);
                        IntPtr pos = prt;
                        for (int i = 0; i < pts.Length; i++, pos = new IntPtr (pos.ToInt64 () + nPointSize))
-                               pts[i] = (RectangleF) Marshal.PtrToStructure(pos, typeof(RectangleF));
+                               pts[i] = (RectangleF) Marshal.PtrToStructure (pos, typeof (RectangleF));
                        
-                       Marshal.FreeHGlobal(prt);                       
+                       Marshal.FreeHGlobal (prt);                      
                }
                
                // Copies an array of Points to unmanaged memory
-               static public IntPtr FromPointToUnManagedMemory(PointF [] pts)
+               static public IntPtr FromPointToUnManagedMemory (PointF [] pts)
                {
-                       int nPointSize =  Marshal.SizeOf(pts[0]);
-                       IntPtr dest = Marshal.AllocHGlobal(nPointSize* pts.Length);                     
+                       int nPointSize =  Marshal.SizeOf (pts[0]);
+                       IntPtr dest = Marshal.AllocHGlobal (nPointSize * pts.Length);                   
                        IntPtr pos = dest;
                        for (int i=0; i<pts.Length; i++, pos = new IntPtr (pos.ToInt64 () + nPointSize))
-                               Marshal.StructureToPtr(pts[i], pos, false);     
+                               Marshal.StructureToPtr (pts[i], pos, false);    
                        
                        return dest;                    
                }
@@ -927,9 +927,9 @@ namespace System.Drawing
                internal static extern Status GdipCreateFromHWND (IntPtr hwnd, out IntPtr graphics);
 
                [DllImport("gdiplus.dll", CharSet=CharSet.Unicode)]
-               internal static extern Status GdipMeasureString(IntPtr graphics, string str, int length, IntPtr font,
-                ref RectangleF layoutRect, IntPtr stringFormat, out RectangleF boundingBox, out int codepointsFitted,
-                               out int linesFilled);                                           
+               internal unsafe static extern Status GdipMeasureString(IntPtr graphics, string str, int length,
+                       IntPtr font, ref RectangleF layoutRect, IntPtr stringFormat, out RectangleF boundingBox,
+                       int *codepointsFitted, int *linesFilled);
                                
                [DllImport("gdiplus.dll", CharSet=CharSet.Unicode)]
                internal static extern Status GdipMeasureCharacterRanges (IntPtr graphics, string str, int length, IntPtr font,
@@ -1069,7 +1069,7 @@ namespace System.Drawing
                internal static extern Status GdipRemovePropertyItem (IntPtr image, int propertyId);
                
                [DllImport("gdiplus.dll")]
-               internal static extern Status GdipSetPropertyItem (IntPtr image, IntPtr propertyItem);
+               internal unsafe static extern Status GdipSetPropertyItem (IntPtr image, GdipPropertyItem *propertyItem);
                
                [DllImport("gdiplus.dll")]
                internal static extern Status GdipGetImageThumbnail ( IntPtr image, uint width, uint height, out IntPtr thumbImage, IntPtr callback, IntPtr callBackData );
@@ -1697,12 +1697,12 @@ namespace System.Drawing
                        private byte[]  managedBuf;
                        private const int default_bufsize = 4096;
                        
-                       public GdiPlusStreamHelper (Stream s) 
+                       public GdiPlusStreamHelper (Stream s, bool seekToOrigin
                        { 
                                managedBuf = new byte [default_bufsize];
                                
                                stream = s;
-                               if (stream != null && stream.CanSeek) {
+                               if (stream != null && stream.CanSeek && seekToOrigin) {
                                        stream.Seek (0, SeekOrigin.Begin);
                                }
                        }