2007-02-28 Sebastien Pouliot <sebastien@ximian.com>
[mono.git] / mcs / class / System.Drawing / System.Drawing / gdipFunctions.cs
index df783d7e2182bbfd0ff5499e1695ffd6fbb76a07..e58b6cc4a332904ce27cac67bd60de0d246fe0f7 100644 (file)
@@ -7,8 +7,9 @@
 //     Sanjay Gupta (gsanjay@novell.com)
 //     Ravindra (rkumar@novell.com)
 //     Peter Dennis Bartok (pbartok@novell.com)
+//     Sebastien Pouliot  <sebastien@ximian.com>
 //
-// Copyright (C) 2004 - 2006 Novell, Inc (http://www.novell.com)
+// Copyright (C) 2004 - 2007 Novell, Inc (http://www.novell.com)
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
@@ -114,6 +115,16 @@ namespace System.Drawing
                        
                        AppDomain.CurrentDomain.ProcessExit += new EventHandler (ProcessExit);
                }
+
+               static public bool RunningOnWindows ()
+               {
+                       return !UseX11Drawable;
+               }
+
+               static public bool RunningOnUnix ()
+               {
+                       return UseX11Drawable;
+               }
                
                // Copies a Ptr to an array of Points and releases the memory
                static public void FromUnManagedMemoryToPointI(IntPtr prt, Point [] pts)
@@ -980,6 +991,9 @@ namespace System.Drawing
                [DllImport("gdiplus.dll")]
                internal static extern Status GdipGetImageFlags(IntPtr image, out int flag);
 
+               [DllImport ("gdiplus.dll")]
+               internal static extern Status GdipGetImageType (IntPtr image, out ImageType type);
+
                [DllImport("gdiplus.dll")]
                internal static extern Status GdipImageGetFrameDimensionsCount ( IntPtr image, out uint count );
                                                                                                   
@@ -987,7 +1001,7 @@ namespace System.Drawing
                internal static extern Status GdipImageGetFrameDimensionsList ( IntPtr image, [Out] Guid [] dimensionIDs, uint count );
  
                [DllImport("gdiplus.dll")]
-               internal static extern Status GdipGetImageHeight (IntPtr image, out int height);
+               internal static extern Status GdipGetImageHeight (IntPtr image, out uint height);
                                                                                                   
                [DllImport("gdiplus.dll")]
                internal static extern Status GdipGetImageHorizontalResolution ( IntPtr image, out float resolution );
@@ -1038,7 +1052,7 @@ namespace System.Drawing
                internal static extern Status GdipGetEncoderParameterList ( IntPtr image, ref Guid encoder, uint size, IntPtr buffer );
                
                [DllImport("gdiplus.dll")]
-               internal static extern Status GdipImageGetFrameCount (IntPtr image, ref Guid guidDimension, out int count );
+               internal static extern Status GdipImageGetFrameCount (IntPtr image, ref Guid guidDimension, out uint count );
                
                [DllImport("gdiplus.dll")]
                internal static extern Status GdipImageSelectActiveFrame (IntPtr image, ref Guid guidDimension, int frameIndex);
@@ -1428,12 +1442,17 @@ namespace System.Drawing
                [DllImport("user32.dll", EntryPoint="GetDC", CallingConvention = CallingConvention.StdCall, CharSet = CharSet.Ansi)]
                internal static extern IntPtr GetDC(IntPtr hwnd);       
                [DllImport("user32.dll", EntryPoint="ReleaseDC", CallingConvention = CallingConvention.StdCall, CharSet = CharSet.Ansi)]
-               internal static extern int ReleaseDC(IntPtr hdc);
+               internal static extern int ReleaseDC (IntPtr hWnd, IntPtr hDC);
                [DllImport("gdi32.dll", EntryPoint="SelectObject", CallingConvention = CallingConvention.StdCall, CharSet = CharSet.Ansi)]
                internal static extern IntPtr SelectObject(IntPtr hdc, IntPtr obj);     
                [DllImport("user32.dll", SetLastError=true)]
                internal static extern bool GetIconInfo (IntPtr hIcon, out IconInfo iconinfo);
+               [DllImport("user32.dll", CallingConvention = CallingConvention.StdCall, SetLastError=true)]
+               internal static extern IntPtr CreateIconIndirect ([In] ref IconInfo piconinfo);
+               [DllImport("user32.dll", CallingConvention = CallingConvention.StdCall, SetLastError=true)]
+               internal static extern bool DestroyIcon (IntPtr hIcon);
+               [DllImport("gdi32.dll")]
+               internal static extern bool DeleteObject (IntPtr hObject);
                [DllImport("user32.dll")]
                internal static extern IntPtr GetDesktopWindow ();
 
@@ -1587,6 +1606,35 @@ namespace System.Drawing
                 [DllImport ("gdiplus.dll")]
                 internal static extern Status GdipGetStringFormatTabStops(IntPtr format, int count, out float firstTabOffset, [In, Out] float [] tabStops);
                                
+               // metafile
+               [DllImport ("gdiplus.dll", CharSet = CharSet.Auto)]
+               internal static extern Status GdipCreateMetafileFromFile ([MarshalAs (UnmanagedType.LPWStr)] string filename, out IntPtr metafile);
+               [DllImport ("gdiplus.dll")]
+               internal static extern Status GdipCreateMetafileFromEmf (IntPtr hEmf, bool deleteEmf, out IntPtr metafile);
+               [DllImport ("gdiplus.dll")]
+               internal static extern Status GdipCreateMetafileFromWmf (IntPtr hWmf, bool deleteWmf, WmfPlaceableFileHeader wmfPlaceableFileHeader, out IntPtr metafile);
+               [DllImport ("gdiplus.dll", CharSet = CharSet.Auto)]
+               internal static extern Status GdipGetMetafileHeaderFromFile ([MarshalAs (UnmanagedType.LPWStr)] string filename, IntPtr header);
+               [DllImport ("gdiplus.dll")]
+               internal static extern Status GdipGetMetafileHeaderFromMetafile (IntPtr metafile, IntPtr header);
+               [DllImport ("gdiplus.dll")]
+               internal static extern Status GdipGetMetafileHeaderFromEmf (IntPtr hEmf, IntPtr header);
+               [DllImport ("gdiplus.dll")]
+               internal static extern Status GdipGetMetafileHeaderFromWmf (IntPtr hWmf, IntPtr wmfPlaceableFileHeader, IntPtr header);
+               [DllImport ("gdiplus.dll")]
+               internal static extern Status GdipGetHemfFromMetafile (IntPtr metafile, out IntPtr hEmf);
+               [DllImport ("gdiplus.dll")]
+               internal static extern Status GdipGetMetafileDownLevelRasterizationLimit (IntPtr metafile, ref uint metafileRasterizationLimitDpi);
+               [DllImport ("gdiplus.dll")]
+               internal static extern Status GdipSetMetafileDownLevelRasterizationLimit (IntPtr metafile, uint metafileRasterizationLimitDpi);
+               [DllImport ("gdiplus.dll")]
+               internal static extern Status GdipPlayMetafileRecord (IntPtr metafile, EmfPlusRecordType recordType, int flags, int dataSize, byte[] data);
+#if !TEST
+               [DllImport("gdiplus.dll", ExactSpelling=true, CharSet=CharSet.Unicode)]
+               internal static extern Status GdipCreateMetafileFromStream([MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(ComIStreamMarshaler))] IStream stream, out IntPtr metafile);
+               [DllImport("gdiplus.dll", ExactSpelling=true, CharSet=CharSet.Unicode)]
+               internal static extern Status GdipGetMetafileHeaderFromStream([MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(ComIStreamMarshaler))] IStream stream, IntPtr header);
+#endif
                //ImageCodecInfo functions
                [DllImport("gdiplus.dll")]
                static internal extern Status GdipGetImageDecodersSize (out int decoderNums, out int arraySize);
@@ -1851,14 +1899,26 @@ namespace System.Drawing
                [DllImport("gdiplus.dll")]
                internal static extern Status GdipCreateFromXDrawable_linux (IntPtr drawable, IntPtr display, out IntPtr graphics);
                
-               // Stream functions for non-Win32 (libgdiplus specific(
+               // Stream functions for non-Win32 (libgdiplus specific)
                [DllImport("gdiplus.dll")]
-               static internal extern Status GdipLoadImageFromDelegate_linux ( StreamGetHeaderDelegate getHeader, StreamGetBytesDelegate getBytes, StreamPutBytesDelegate putBytes, 
-                                                       StreamSeekDelegate doSeek, StreamCloseDelegate close, StreamSizeDelegate size, out IntPtr image);
+               static internal extern Status GdipLoadImageFromDelegate_linux (StreamGetHeaderDelegate getHeader, 
+                       StreamGetBytesDelegate getBytes, StreamPutBytesDelegate putBytes, StreamSeekDelegate doSeek, 
+                       StreamCloseDelegate close, StreamSizeDelegate size, out IntPtr image);
+
                [DllImport("gdiplus.dll")]
-               static internal extern Status GdipSaveImageToDelegate_linux ( IntPtr image, StreamGetBytesDelegate getBytes, StreamPutBytesDelegate putBytes, 
-                       StreamSeekDelegate doSeek, StreamCloseDelegate close, StreamSizeDelegate size, ref Guid encoderClsID, IntPtr encoderParameters );               
-               
+               static internal extern Status GdipSaveImageToDelegate_linux (IntPtr image, StreamGetBytesDelegate getBytes, 
+                       StreamPutBytesDelegate putBytes, StreamSeekDelegate doSeek, StreamCloseDelegate close, 
+                       StreamSizeDelegate size, ref Guid encoderClsID, IntPtr encoderParameters);              
+
+               [DllImport("gdiplus.dll")]
+               static internal extern Status GdipCreateMetafileFromDelegate_linux (StreamGetHeaderDelegate getHeader, 
+                       StreamGetBytesDelegate getBytes, StreamPutBytesDelegate putBytes, StreamSeekDelegate doSeek, 
+                       StreamCloseDelegate close, StreamSizeDelegate size, out IntPtr metafile);
+
+               [DllImport("gdiplus.dll")]
+               static internal extern Status GdipGetMetafileHeaderFromDelegate_linux (StreamGetHeaderDelegate getHeader, 
+                       StreamGetBytesDelegate getBytes, StreamPutBytesDelegate putBytes, StreamSeekDelegate doSeek, 
+                       StreamCloseDelegate close, StreamSizeDelegate size, IntPtr header);
 #endregion
        }
 }