New tests, updates
[mono.git] / mcs / class / System.Drawing / System.Drawing / gdipFunctions.cs
1 //
2 // System.Drawing.gdipFunctions.cs
3 //
4 // Authors: 
5 //      Alexandre Pigolkine (pigolkine@gmx.de)
6 //      Jordi Mas i Hernandez (jordi@ximian.com)
7 //      Sanjay Gupta (gsanjay@novell.com)
8 //      Ravindra (rkumar@novell.com)
9 //      Peter Dennis Bartok (pbartok@novell.com)
10 //      Sebastien Pouliot  <sebastien@ximian.com>
11 //
12 // Copyright (C) 2004 - 2007 Novell, Inc (http://www.novell.com)
13 //
14 // Permission is hereby granted, free of charge, to any person obtaining
15 // a copy of this software and associated documentation files (the
16 // "Software"), to deal in the Software without restriction, including
17 // without limitation the rights to use, copy, modify, merge, publish,
18 // distribute, sublicense, and/or sell copies of the Software, and to
19 // permit persons to whom the Software is furnished to do so, subject to
20 // the following conditions:
21 // 
22 // The above copyright notice and this permission notice shall be
23 // included in all copies or substantial portions of the Software.
24 // 
25 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
26 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
27 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
28 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
29 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
30 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
31 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
32 //
33
34 using System.IO;
35 using System.Runtime.InteropServices;
36 using System.Text;
37 using System.Drawing.Drawing2D;
38 using System.Drawing.Imaging;
39 using System.Drawing.Text;
40 using System.Globalization;
41 using System.Security;
42 #if NET_2_0
43 using System.Runtime.InteropServices.ComTypes;
44 #else
45 using IStream = System.Runtime.InteropServices.UCOMIStream;
46 #endif
47
48 namespace System.Drawing
49 {
50         /// <summary>
51         /// GDI+ API Functions
52         /// </summary>
53         [SuppressUnmanagedCodeSecurity]
54 #if NET_2_0
55         internal static class GDIPlus {
56 #else
57         internal class GDIPlus {
58 #endif
59                 public const int FACESIZE = 32;
60                 public const int LANG_NEUTRAL = 0;
61                 public static IntPtr Display = IntPtr.Zero;
62                 public static bool UseX11Drawable = false;
63                 public static bool UseCarbonDrawable = false;
64
65                 #region gdiplus.dll functions
66
67                 // startup / shutdown
68                 [DllImport("gdiplus.dll")]
69                 static internal extern Status GdiplusStartup(ref ulong token, ref GdiplusStartupInput input, ref GdiplusStartupOutput output);
70                 [DllImport("gdiplus.dll")]
71                 static internal extern void GdiplusShutdown(ref ulong token);
72                 
73                 internal static ulong GdiPlusToken = 0;
74
75                 static void ProcessExit (object sender, EventArgs e)
76                 {               
77                         // Called all pending objects and claim any pending handle before
78                         // shutting down
79                         GC.Collect ();  
80                         GC.WaitForPendingFinalizers ();
81 #if false                       
82                         GdiPlusToken = 0;
83
84                         // This causes crashes in because this call occurs before all
85                         // managed GDI+ objects are finalized. When they are finalized 
86                         // they call into a shutdown GDI+ and we crash.
87                         GdiplusShutdown (ref GdiPlusToken);
88
89                         // This causes crashes in Mono libgdiplus because this call
90                         // occurs before all managed GDI objects are finalized
91                         // When they are finalized they use the closed display and
92                         // crash
93                         if (UseX11Drawable && Display != IntPtr.Zero) {
94                                 XCloseDisplay (Display);
95                         }
96 #endif
97                 }
98
99                 static GDIPlus ()
100                 {
101                         int platform = (int) Environment.OSVersion.Platform;
102                         if ((platform == 4) || (platform == 128)) {
103                                 if (Environment.GetEnvironmentVariable ("not_supported_MONO_MWF_USE_NEW_X11_BACKEND") != null || Environment.GetEnvironmentVariable ("MONO_MWF_MAC_FORCE_X11") != null) {
104                                         UseX11Drawable = true;
105                                 } else {
106                                         IntPtr buf = Marshal.AllocHGlobal (8192);
107                                         // This is kind of a hack but gets us sysname from uname (struct utsname *name) on
108                                         // linux and darwin
109                                         if (uname (buf) != 0) {
110                                                 // WTH: We couldn't detect the OS; lets default to X11
111                                                 UseX11Drawable = true;
112                                         } else {
113                                                 string os = Marshal.PtrToStringAnsi (buf);
114                                                 if (os == "Darwin")
115                                                         UseCarbonDrawable = true;
116                                                 else
117                                                         UseX11Drawable = true;
118                                         }
119                                         Marshal.FreeHGlobal (buf);
120                                 }
121                         }
122
123                         GdiplusStartupInput input = GdiplusStartupInput.MakeGdiplusStartupInput();
124                         GdiplusStartupOutput output = GdiplusStartupOutput.MakeGdiplusStartupOutput();
125                         try {
126                                 GdiplusStartup (ref GdiPlusToken, ref input, ref output);
127                         }
128                         catch (TypeInitializationException) {
129                                 Console.Error.WriteLine (
130                                         "* ERROR: Can not initialize GDI+ library{0}{0}" +
131                                         "Please check http://www.mono-project.com/Problem:GDIPlusInit for details",
132                                         Environment.NewLine);
133                         }
134
135                         // under MS 1.x this event is raised only for the default application domain
136                         AppDomain.CurrentDomain.ProcessExit += new EventHandler (ProcessExit);
137                 }
138
139                 static public bool RunningOnWindows ()
140                 {
141                         return !UseX11Drawable && !UseCarbonDrawable;
142                 }
143
144                 static public bool RunningOnUnix ()
145                 {
146                         return UseX11Drawable || UseCarbonDrawable;
147                 }
148                 
149                 // Copies a Ptr to an array of Points and releases the memory
150                 static public void FromUnManagedMemoryToPointI (IntPtr prt, Point [] pts)
151                 {                                               
152                         int nPointSize = Marshal.SizeOf (pts[0]);
153                         IntPtr pos = prt;
154                         for (int i=0; i<pts.Length; i++, pos = new IntPtr (pos.ToInt64 () + nPointSize))
155                                 pts[i] = (Point) Marshal.PtrToStructure (pos, typeof (Point));
156                         
157                         Marshal.FreeHGlobal (prt);                      
158                 }
159                 
160                 // Copies a Ptr to an array of Points and releases the memory
161                 static public void FromUnManagedMemoryToPoint (IntPtr prt, PointF [] pts)
162                 {                                               
163                         int nPointSize = Marshal.SizeOf (pts[0]);
164                         IntPtr pos = prt;
165                         for (int i=0; i<pts.Length; i++, pos = new IntPtr (pos.ToInt64 () + nPointSize))
166                                 pts[i] = (PointF) Marshal.PtrToStructure (pos, typeof (PointF));
167                         
168                         Marshal.FreeHGlobal (prt);                      
169                 }
170                 
171                 // Copies an array of Points to unmanaged memory
172                 static public IntPtr FromPointToUnManagedMemoryI (Point [] pts)
173                 {
174                         int nPointSize =  Marshal.SizeOf (pts[0]);
175                         IntPtr dest = Marshal.AllocHGlobal (nPointSize * pts.Length);
176                         IntPtr pos = dest;
177                         for (int i=0; i<pts.Length; i++, pos = new IntPtr (pos.ToInt64 () + nPointSize))
178                                 Marshal.StructureToPtr (pts[i], pos, false);    
179                         
180                         return dest;                    
181                 }               
182                                 
183                 // Copies a Ptr to an array of v and releases the memory
184                 static public void FromUnManagedMemoryToRectangles (IntPtr prt, RectangleF [] pts)
185                 {                                               
186                         int nPointSize = Marshal.SizeOf (pts[0]);
187                         IntPtr pos = prt;
188                         for (int i = 0; i < pts.Length; i++, pos = new IntPtr (pos.ToInt64 () + nPointSize))
189                                 pts[i] = (RectangleF) Marshal.PtrToStructure (pos, typeof (RectangleF));
190                         
191                         Marshal.FreeHGlobal (prt);                      
192                 }
193                 
194                 // Copies an array of Points to unmanaged memory
195                 static public IntPtr FromPointToUnManagedMemory (PointF [] pts)
196                 {
197                         int nPointSize =  Marshal.SizeOf (pts[0]);
198                         IntPtr dest = Marshal.AllocHGlobal (nPointSize * pts.Length);                   
199                         IntPtr pos = dest;
200                         for (int i=0; i<pts.Length; i++, pos = new IntPtr (pos.ToInt64 () + nPointSize))
201                                 Marshal.StructureToPtr (pts[i], pos, false);    
202                         
203                         return dest;                    
204                 }
205
206                 // Converts a status into exception
207                 // TODO: Add more status code mappings here
208                 static internal void CheckStatus (Status status)
209                 {
210                         string msg;
211                         switch (status) {
212                         case Status.Ok:
213                                 return;
214                         case Status.GenericError:
215                                 msg = Locale.GetText ("Generic Error [GDI+ status: {0}]", status);
216                                 throw new Exception (msg);
217                         case Status.InvalidParameter:
218                                 msg = Locale.GetText ("A null reference or invalid value was found [GDI+ status: {0}]", status);
219                                 throw new ArgumentException (msg);
220                         case Status.OutOfMemory:
221                                 msg = Locale.GetText ("Not enough memory to complete operation [GDI+ status: {0}]", status);
222                                 throw new OutOfMemoryException (msg);
223                         case Status.ObjectBusy:
224                                 msg = Locale.GetText ("Object is busy and cannot state allow this operation [GDI+ status: {0}]", status);
225                                 throw new MemberAccessException (msg);
226                         case Status.InsufficientBuffer:
227                                 msg = Locale.GetText ("Insufficient buffer provided to complete operation [GDI+ status: {0}]", status);
228                                 throw new InternalBufferOverflowException (msg);
229                         case Status.PropertyNotSupported:
230                                 msg = Locale.GetText ("Property not supported [GDI+ status: {0}]", status);
231                                 throw new NotSupportedException (msg);
232                         case Status.FileNotFound:
233                                 msg = Locale.GetText ("Requested file was not found [GDI+ status: {0}]", status);
234                                 throw new FileNotFoundException (msg);
235                         case Status.AccessDenied:
236                                 msg = Locale.GetText ("Access to resource was denied [GDI+ status: {0}]", status);
237                                 throw new UnauthorizedAccessException (msg);
238                         case Status.UnknownImageFormat:
239                                 msg = Locale.GetText ("Either the image format is unknown or you don't have the required libraries to decode this format [GDI+ status: {0}]", status);
240                                 throw new NotSupportedException (msg);
241                         case Status.NotImplemented:
242                                 msg = Locale.GetText ("The requested feature is not implemented [GDI+ status: {0}]", status);
243                                 throw new NotImplementedException (msg);
244                         case Status.WrongState:
245                                 msg = Locale.GetText ("Object is not in a state that can allow this operation [GDI+ status: {0}]", status);
246                                 throw new ArgumentException (msg);
247                         case Status.FontFamilyNotFound:
248                                 msg = Locale.GetText ("The requested FontFamily could not be found [GDI+ status: {0}]", status);
249                                 throw new ArgumentException (msg);
250                         case Status.ValueOverflow:
251                                 msg = Locale.GetText ("Argument is out of range [GDI+ status: {0}]", status);
252                                 throw new OverflowException (msg);
253                         case Status.Win32Error:
254                                 msg = Locale.GetText ("The operation is invalid [GDI+ status: {0}]", status);
255                                 throw new InvalidOperationException (msg);
256                         default:
257                                 msg = Locale.GetText ("Unknown Error [GDI+ status: {0}]", status);
258                                 throw new Exception (msg);
259                         }
260                 }
261                 
262                 // Memory functions
263                 [DllImport("gdiplus.dll")]
264                 static internal extern IntPtr GdipAlloc (int size);
265                 [DllImport("gdiplus.dll")]
266                 static internal extern void GdipFree (IntPtr ptr);
267
268                 
269                 // Brush functions
270                 [DllImport("gdiplus.dll")]
271                 static internal extern Status GdipCloneBrush (IntPtr brush, out IntPtr clonedBrush);
272                 [DllImport("gdiplus.dll")]
273                 static internal extern Status GdipDeleteBrush (IntPtr brush);
274                 [DllImport("gdiplus.dll")]
275                 static internal extern Status GdipGetBrushType (IntPtr brush, out BrushType type);
276
277
278                 // Region functions
279                 [DllImport("gdiplus.dll")]
280                 static internal extern Status GdipCreateRegion (out IntPtr region);
281
282                 [DllImport("gdiplus.dll")]
283                 static internal extern Status GdipCreateRegionRgnData (byte[] data, int size, out IntPtr region);
284
285                 [DllImport("gdiplus.dll")]
286                 static internal extern Status GdipDeleteRegion (IntPtr region);
287
288                 [DllImport("gdiplus.dll")]
289                 static internal extern Status GdipCloneRegion (IntPtr region, out IntPtr cloned);
290
291                 [DllImport("gdiplus.dll")]
292                 static internal extern Status GdipCreateRegionRect (ref RectangleF rect, out IntPtr region);
293
294                 [DllImport("gdiplus.dll")]
295                 static internal extern Status GdipCreateRegionRectI (ref Rectangle rect,  out IntPtr region);
296
297                 [DllImport("gdiplus.dll")]
298                 static internal extern Status GdipCreateRegionPath (IntPtr path, out IntPtr region);
299
300                 [DllImport("gdiplus.dll")]
301                 static internal extern Status GdipTranslateRegion (IntPtr region, float dx, float dy);
302
303                 [DllImport("gdiplus.dll")]
304                 static internal extern Status GdipTranslateRegionI (IntPtr region, int dx, int dy);
305
306                 [DllImport("gdiplus.dll")]
307                 static internal extern Status GdipIsVisibleRegionPoint (IntPtr region, float x, float y,
308                         IntPtr graphics, out bool result);
309
310                 [DllImport("gdiplus.dll")]
311                 static internal extern Status GdipIsVisibleRegionPointI (IntPtr region, int x, int y,
312                         IntPtr graphics, out bool result);
313
314                 [DllImport("gdiplus.dll")]
315                 static internal extern Status GdipIsVisibleRegionRect (IntPtr region, float x, float y, float width,
316                         float height, IntPtr graphics, out bool result);
317
318                 [DllImport("gdiplus.dll")]
319                 static internal extern Status  GdipIsVisibleRegionRectI (IntPtr region, int x, int y, int width,
320                         int height, IntPtr graphics, out bool result);
321
322
323                 [DllImport("gdiplus.dll")]
324                 static internal extern Status GdipCombineRegionRect (IntPtr region, ref RectangleF rect,
325                         CombineMode combineMode);
326
327                 [DllImport("gdiplus.dll")]
328                 static internal extern Status GdipCombineRegionRectI (IntPtr region, ref Rectangle rect,
329                         CombineMode combineMode);
330
331                 [DllImport("gdiplus.dll")]
332                 static internal extern Status GdipCombineRegionPath (IntPtr region, IntPtr path, CombineMode combineMode);
333
334                 [DllImport("gdiplus.dll")]
335                 static internal extern Status GdipGetRegionBounds (IntPtr region, IntPtr graphics, ref RectangleF rect);
336
337                 [DllImport("gdiplus.dll")]
338                 static internal extern Status GdipSetInfinite (IntPtr region);
339
340                 [DllImport("gdiplus.dll")]
341                 static internal extern Status GdipSetEmpty (IntPtr region);
342
343                 [DllImport("gdiplus.dll")]
344                 static internal extern Status GdipIsEmptyRegion (IntPtr region, IntPtr graphics, out bool result);
345                 
346                 [DllImport("gdiplus.dll")]
347                 static internal extern Status GdipIsInfiniteRegion (IntPtr region, IntPtr graphics, out bool result);
348
349                 [DllImport("gdiplus.dll")]
350                 static internal extern Status GdipCombineRegionRegion (IntPtr region, IntPtr region2,
351                         CombineMode combineMode);
352                         
353                 [DllImport("gdiplus.dll")]
354                 static internal extern Status GdipIsEqualRegion (IntPtr region, IntPtr region2,
355                            IntPtr graphics, out bool result);                                   
356                            
357                 [DllImport("gdiplus.dll")]
358                 static internal extern Status GdipGetRegionDataSize (IntPtr region, out int bufferSize);
359
360                 [DllImport("gdiplus.dll")]
361                 static internal extern Status GdipGetRegionData (IntPtr region, byte[] buffer, int bufferSize, 
362                   out int sizeFilled);
363                   
364                 [DllImport("gdiplus.dll")]
365                 static internal extern Status GdipGetRegionScansCount (IntPtr region, out int count, IntPtr matrix);
366
367                 [DllImport("gdiplus.dll")]
368                 static internal extern Status GdipGetRegionScans (IntPtr region,  IntPtr rects, out int count, 
369                    IntPtr matrix);
370                 
371                 [DllImport("gdiplus.dll")]
372                 static internal extern Status GdipTransformRegion(IntPtr region, IntPtr matrix);
373                 
374                 [DllImport("gdiplus.dll")]
375                 static internal extern Status GdipFillRegion(IntPtr graphics, IntPtr brush, IntPtr region);
376
377                 [DllImport("gdiplus.dll")]
378                 static internal extern Status GdipGetRegionHRgn (IntPtr region, IntPtr graphics, ref IntPtr hRgn);
379
380                 [DllImport("gdiplus.dll")]
381                 static internal extern Status GdipCreateRegionHrgn (IntPtr hRgn, out IntPtr region);
382
383                 // Solid brush functions
384                 [DllImport("gdiplus.dll")]
385                 static internal extern Status GdipCreateSolidFill (int color, out IntPtr brush);
386                 [DllImport("gdiplus.dll")]
387                 static internal extern Status GdipGetSolidFillColor (IntPtr brush, out int color);
388                 [DllImport("gdiplus.dll")]
389                 static internal extern Status GdipSetSolidFillColor (IntPtr brush, int color);
390                 
391                 // Hatch Brush functions
392                 [DllImport("gdiplus.dll")]
393                 static internal extern Status GdipCreateHatchBrush (HatchStyle hatchstyle, int foreColor, int backColor, out IntPtr brush);
394                 [DllImport("gdiplus.dll")]
395                 static internal extern Status GdipGetHatchStyle (IntPtr brush, out HatchStyle hatchstyle);
396                 [DllImport("gdiplus.dll")]
397                 static internal extern Status GdipGetHatchForegroundColor (IntPtr brush, out int foreColor);
398                 [DllImport("gdiplus.dll")]
399                 static internal extern Status GdipGetHatchBackgroundColor (IntPtr brush, out int backColor);
400
401                 // Texture brush functions
402                 [DllImport("gdiplus.dll")]
403                 static internal extern Status GdipGetTextureImage (IntPtr texture, out IntPtr image);
404                 [DllImport("gdiplus.dll")]
405                 static internal extern Status GdipCreateTexture (IntPtr image, WrapMode wrapMode,  out IntPtr texture);
406                 [DllImport("gdiplus.dll")]
407                 static internal extern Status GdipCreateTextureIAI (IntPtr image, IntPtr imageAttributes, int x, int y, int width, int height, out IntPtr texture);
408                 [DllImport("gdiplus.dll")]
409                 static internal extern Status GdipCreateTextureIA (IntPtr image, IntPtr imageAttributes, float x, float y, float width, float height, out IntPtr texture);
410                 [DllImport("gdiplus.dll")]
411                 static internal extern Status GdipCreateTexture2I (IntPtr image, WrapMode wrapMode, int x, int y, int width, int height, out IntPtr texture);
412                 [DllImport("gdiplus.dll")]
413                 static internal extern Status GdipCreateTexture2 (IntPtr image, WrapMode wrapMode, float x, float y, float width, float height, out IntPtr texture);
414                 [DllImport("gdiplus.dll")]
415                 static internal extern Status GdipGetTextureTransform (IntPtr texture, IntPtr matrix);
416                 [DllImport("gdiplus.dll")]
417                 static internal extern Status GdipSetTextureTransform (IntPtr texture, IntPtr matrix);
418                 [DllImport("gdiplus.dll")]
419                 static internal extern Status GdipGetTextureWrapMode (IntPtr texture, out WrapMode wrapMode);
420                 [DllImport("gdiplus.dll")]
421                 static internal extern Status GdipSetTextureWrapMode (IntPtr texture, WrapMode wrapMode);
422                 [DllImport("gdiplus.dll")]
423                 static internal extern Status GdipMultiplyTextureTransform (IntPtr texture, IntPtr matrix, MatrixOrder order);
424                 [DllImport("gdiplus.dll")]
425                 static internal extern Status GdipResetTextureTransform (IntPtr texture);
426                 [DllImport("gdiplus.dll")]
427                 static internal extern Status GdipRotateTextureTransform (IntPtr texture, float angle, MatrixOrder order);
428                 [DllImport("gdiplus.dll")]
429                 static internal extern Status GdipScaleTextureTransform (IntPtr texture, float sx, float sy, MatrixOrder order);
430                 [DllImport("gdiplus.dll")]
431                 static internal extern Status GdipTranslateTextureTransform (IntPtr texture, float dx, float dy, MatrixOrder order);
432
433                 // PathGradientBrush functions
434                 [DllImport("gdiplus.dll")]
435                 static internal extern Status GdipCreatePathGradientFromPath (IntPtr path, out IntPtr brush);
436                 [DllImport("gdiplus.dll")]
437                 static internal extern Status GdipCreatePathGradientI (Point [] points, int count, WrapMode wrapMode, out IntPtr brush);
438                 [DllImport("gdiplus.dll")]
439                 static internal extern Status GdipCreatePathGradient (PointF [] points, int count, WrapMode wrapMode, out IntPtr brush);
440                 [DllImport("gdiplus.dll")]
441                 static internal extern Status GdipGetPathGradientBlendCount (IntPtr brush, out int count);
442                 [DllImport("gdiplus.dll")]
443                 static internal extern Status GdipGetPathGradientBlend (IntPtr brush, float [] blend, float [] positions, int count);
444                 [DllImport("gdiplus.dll")]
445                 static internal extern Status GdipSetPathGradientBlend (IntPtr brush, float [] blend, float [] positions, int count);
446                 [DllImport("gdiplus.dll")]
447                 static internal extern Status GdipGetPathGradientCenterColor (IntPtr brush, out int color);
448                 [DllImport("gdiplus.dll")]
449                 static internal extern Status GdipSetPathGradientCenterColor (IntPtr brush, int color);
450                 [DllImport("gdiplus.dll")]
451                 static internal extern Status GdipGetPathGradientCenterPoint (IntPtr brush, out PointF point);
452                 [DllImport("gdiplus.dll")]
453                 static internal extern Status GdipSetPathGradientCenterPoint (IntPtr brush, ref PointF point);
454                 [DllImport("gdiplus.dll")]
455                 static internal extern Status GdipGetPathGradientFocusScales (IntPtr brush, out float xScale, out float yScale);
456                 [DllImport("gdiplus.dll")]
457                 static internal extern Status GdipSetPathGradientFocusScales (IntPtr brush, float xScale, float yScale);
458                 [DllImport("gdiplus.dll")]
459                 static internal extern Status GdipGetPathGradientPresetBlendCount (IntPtr brush, out int count);
460                 [DllImport("gdiplus.dll")]
461                 static internal extern Status GdipGetPathGradientPresetBlend (IntPtr brush, int [] blend, float [] positions, int count);
462                 [DllImport("gdiplus.dll")]
463                 static internal extern Status GdipSetPathGradientPresetBlend (IntPtr brush, int [] blend, float [] positions, int count);
464                 [DllImport("gdiplus.dll")]
465                 static internal extern Status GdipGetPathGradientRect (IntPtr brush, out RectangleF rect);
466                 [DllImport("gdiplus.dll")]
467                 static internal extern Status GdipGetPathGradientSurroundColorCount (IntPtr brush, out int count);
468                 [DllImport("gdiplus.dll")]
469                 static internal extern Status GdipGetPathGradientSurroundColorsWithCount (IntPtr brush, int [] color, ref int count);
470                 [DllImport("gdiplus.dll")]
471                 static internal extern Status GdipSetPathGradientSurroundColorsWithCount (IntPtr brush, int [] color, ref int count);
472                 [DllImport("gdiplus.dll")]
473                 static internal extern Status GdipGetPathGradientTransform (IntPtr brush, IntPtr matrix);
474                 [DllImport("gdiplus.dll")]
475                 static internal extern Status GdipSetPathGradientTransform (IntPtr brush, IntPtr matrix);
476                 [DllImport("gdiplus.dll")]
477                 static internal extern Status GdipGetPathGradientWrapMode (IntPtr brush, out WrapMode wrapMode);
478                 [DllImport("gdiplus.dll")]
479                 static internal extern Status GdipSetPathGradientWrapMode (IntPtr brush, WrapMode wrapMode);
480                 [DllImport("gdiplus.dll")]
481                 static internal extern Status GdipSetPathGradientLinearBlend (IntPtr brush, float focus, float scale);
482                 [DllImport("gdiplus.dll")]
483                 static internal extern Status GdipSetPathGradientSigmaBlend (IntPtr brush, float focus, float scale);
484                 [DllImport("gdiplus.dll")]
485                 static internal extern Status GdipMultiplyPathGradientTransform (IntPtr texture, IntPtr matrix, MatrixOrder order);
486                 [DllImport("gdiplus.dll")]
487                 static internal extern Status GdipResetPathGradientTransform (IntPtr brush);
488                 [DllImport("gdiplus.dll")]
489                 static internal extern Status GdipRotatePathGradientTransform (IntPtr brush, float angle, MatrixOrder order);
490                 [DllImport("gdiplus.dll")]
491                 static internal extern Status GdipScalePathGradientTransform (IntPtr brush, float sx, float sy, MatrixOrder order);
492                 [DllImport("gdiplus.dll")]
493                 static internal extern Status GdipTranslatePathGradientTransform (IntPtr brush, float dx, float dy, MatrixOrder order);
494
495                 // LinearGradientBrush functions
496                 [DllImport("gdiplus.dll")]
497                 static internal extern Status GdipCreateLineBrushI (ref Point point1, ref Point point2, int color1, int color2, WrapMode wrapMode, out IntPtr brush);
498                 [DllImport("gdiplus.dll")]
499                 static internal extern Status GdipCreateLineBrush (ref PointF point1, ref PointF point2, int color1, int color2, WrapMode wrapMode, out IntPtr brush);
500                 [DllImport("gdiplus.dll")]
501                 static internal extern Status GdipCreateLineBrushFromRectI (ref Rectangle rect, int color1, int color2, LinearGradientMode linearGradientMode, WrapMode wrapMode, out IntPtr brush);
502                 [DllImport("gdiplus.dll")]
503                 static internal extern Status GdipCreateLineBrushFromRect (ref RectangleF rect, int color1, int color2, LinearGradientMode linearGradientMode, WrapMode wrapMode, out IntPtr brush);
504                 [DllImport("gdiplus.dll")]
505                 static internal extern Status GdipCreateLineBrushFromRectWithAngleI (ref Rectangle rect, int color1, int color2, float angle, bool isAngleScaleable, WrapMode wrapMode, out IntPtr brush);
506                 [DllImport("gdiplus.dll")]
507                 static internal extern Status GdipCreateLineBrushFromRectWithAngle (ref RectangleF rect, int color1, int color2, float angle, bool isAngleScaleable, WrapMode wrapMode, out IntPtr brush);
508                 [DllImport("gdiplus.dll")]
509                 static internal extern Status GdipGetLineBlendCount (IntPtr brush, out int count);
510                 [DllImport("gdiplus.dll")]
511                 static internal extern Status GdipSetLineBlend (IntPtr brush, float [] blend, float [] positions, int count);
512                 [DllImport("gdiplus.dll")]
513                 static internal extern Status GdipGetLineBlend (IntPtr brush, float [] blend, float [] positions, int count);
514                 [DllImport("gdiplus.dll")]
515                 static internal extern Status GdipSetLineGammaCorrection (IntPtr brush, bool useGammaCorrection);
516                 [DllImport("gdiplus.dll")]
517                 static internal extern Status GdipGetLineGammaCorrection (IntPtr brush, out bool useGammaCorrection);
518                 [DllImport("gdiplus.dll")]
519                 static internal extern Status GdipGetLinePresetBlendCount (IntPtr brush, out int count);
520                 [DllImport("gdiplus.dll")]
521                 static internal extern Status GdipSetLinePresetBlend (IntPtr brush, int [] blend, float [] positions, int count);
522                 [DllImport("gdiplus.dll")]
523                 static internal extern Status GdipGetLinePresetBlend (IntPtr brush, int [] blend, float [] positions, int count);
524                 [DllImport("gdiplus.dll")]
525                 static internal extern Status GdipSetLineColors (IntPtr brush, int color1, int color2);
526                 [DllImport("gdiplus.dll")]
527                 static internal extern Status GdipGetLineColors (IntPtr brush, int [] colors);
528                 [DllImport("gdiplus.dll")]
529                 static internal extern Status GdipGetLineRectI (IntPtr brush, out Rectangle rect);
530                 [DllImport("gdiplus.dll")]
531                 static internal extern Status GdipGetLineRect (IntPtr brush, out RectangleF rect);
532                 [DllImport("gdiplus.dll")]
533                 static internal extern Status GdipSetLineTransform (IntPtr brush, IntPtr matrix);
534                 [DllImport("gdiplus.dll")]
535                 static internal extern Status GdipGetLineTransform (IntPtr brush, IntPtr matrix);
536                 [DllImport("gdiplus.dll")]
537                 static internal extern Status GdipSetLineWrapMode (IntPtr brush, WrapMode wrapMode);
538                 [DllImport("gdiplus.dll")]
539                 static internal extern Status GdipGetLineWrapMode (IntPtr brush, out WrapMode wrapMode);
540                 [DllImport("gdiplus.dll")]
541                 static internal extern Status GdipSetLineLinearBlend (IntPtr brush, float focus, float scale);
542                 [DllImport("gdiplus.dll")]
543                 static internal extern Status GdipSetLineSigmaBlend (IntPtr brush, float focus, float scale);
544                 [DllImport("gdiplus.dll")]
545                 static internal extern Status GdipMultiplyLineTransform (IntPtr brush, IntPtr matrix, MatrixOrder order);
546                 [DllImport("gdiplus.dll")]
547                 static internal extern Status GdipResetLineTransform (IntPtr brush);
548                 [DllImport("gdiplus.dll")]
549                 static internal extern Status GdipRotateLineTransform (IntPtr brush, float angle, MatrixOrder order);
550                 [DllImport("gdiplus.dll")]
551                 static internal extern Status GdipScaleLineTransform (IntPtr brush, float sx, float sy, MatrixOrder order);
552                 [DllImport("gdiplus.dll")]
553                 static internal extern Status GdipTranslateLineTransform (IntPtr brush, float dx, float dy, MatrixOrder order);
554
555                 // Graphics functions
556                 [DllImport("gdiplus.dll")]
557                 static internal extern Status GdipCreateFromHDC(IntPtr hDC, out IntPtr graphics);
558                 [DllImport("gdiplus.dll")]
559                 static internal extern Status GdipDeleteGraphics(IntPtr graphics);
560                 [DllImport("gdiplus.dll")]
561                 static internal extern Status GdipRestoreGraphics(IntPtr graphics, uint graphicsState);
562                 [DllImport("gdiplus.dll")]
563                 static internal extern Status GdipSaveGraphics(IntPtr graphics, out uint state);
564                 [DllImport("gdiplus.dll")]                
565                 static internal extern Status GdipMultiplyWorldTransform (IntPtr graphics, IntPtr matrix, MatrixOrder order);
566                 
567                 [DllImport("gdiplus.dll")]
568                 static internal extern Status GdipRotateWorldTransform(IntPtr graphics, float angle, MatrixOrder order);
569                 [DllImport("gdiplus.dll")]
570                 static internal extern Status GdipTranslateWorldTransform(IntPtr graphics, float dx, float dy, MatrixOrder order);
571                 [DllImport("gdiplus.dll")]
572                 static internal extern Status GdipDrawArc (IntPtr graphics, IntPtr pen, float x, float y, float width, float height, float startAngle, float sweepAngle);
573                 [DllImport("gdiplus.dll")]
574                 static internal extern Status GdipDrawArcI (IntPtr graphics, IntPtr pen, int x, int y, int width, int height, float startAngle, float sweepAngle);
575                 [DllImport("gdiplus.dll")]
576                 static internal extern Status GdipDrawBezier (IntPtr graphics, IntPtr pen, float x1, float y1, float x2, float y2, float x3, float y3, float x4, float y4);
577                 [DllImport("gdiplus.dll")]
578                 static internal extern Status GdipDrawBezierI (IntPtr graphics, IntPtr pen, int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4);
579                 [DllImport("gdiplus.dll")]
580                 static internal extern Status GdipDrawEllipseI (IntPtr graphics, IntPtr pen, int x, int y, int width, int height);
581                 [DllImport("gdiplus.dll")]
582                 static internal extern Status GdipDrawEllipse (IntPtr graphics, IntPtr pen, float x, float y, float width, float height);
583                 [DllImport("gdiplus.dll")]
584                 static internal extern Status GdipDrawLine (IntPtr graphics, IntPtr pen, float x1, float y1, float x2, float y2);
585                 [DllImport("gdiplus.dll")]
586                 static internal extern Status GdipDrawLineI (IntPtr graphics, IntPtr pen, int x1, int y1, int x2, int y2);
587                 [DllImport ("gdiplus.dll")]
588                 static internal extern Status GdipDrawLines (IntPtr graphics, IntPtr pen, PointF [] points, int count);
589                 [DllImport ("gdiplus.dll")]
590                 static internal extern Status GdipDrawLinesI (IntPtr graphics, IntPtr pen, Point [] points, int count);
591                 [DllImport ("gdiplus.dll")]
592                 static internal extern Status GdipDrawPath (IntPtr graphics, IntPtr pen, IntPtr path);
593                 [DllImport ("gdiplus.dll")]
594                 static internal extern Status GdipDrawPie (IntPtr graphics, IntPtr pen, float x, float y, float width, float height, float startAngle, float sweepAngle);
595                 [DllImport ("gdiplus.dll")]
596                 static internal extern Status GdipDrawPieI (IntPtr graphics, IntPtr pen, int x, int y, int width, int height, float startAngle, float sweepAngle);
597                 [DllImport ("gdiplus.dll")]
598                 static internal extern Status GdipDrawPolygon (IntPtr graphics, IntPtr pen, PointF [] points, int count);
599                 [DllImport ("gdiplus.dll")]
600                 static internal extern Status GdipDrawPolygonI (IntPtr graphics, IntPtr pen, Point [] points, int count);
601                 [DllImport ("gdiplus.dll")]
602                 static internal extern Status GdipDrawRectangle (IntPtr graphics, IntPtr pen, float x, float y, float width, float height);
603                 [DllImport ("gdiplus.dll")]
604                 static internal extern Status GdipDrawRectangleI (IntPtr graphics, IntPtr pen, int x, int y, int width, int height);
605                 [DllImport ("gdiplus.dll")]
606                 static internal extern Status GdipDrawRectangles (IntPtr graphics, IntPtr pen, RectangleF [] rects, int count);
607                 [DllImport ("gdiplus.dll")]
608                 static internal extern Status GdipDrawRectanglesI (IntPtr graphics, IntPtr pen, Rectangle [] rects, int count);
609                 [DllImport("gdiplus.dll")]
610                 static internal extern Status GdipFillEllipseI (IntPtr graphics, IntPtr pen, int x, int y, int width, int height);
611                 [DllImport("gdiplus.dll")]
612                 static internal extern Status GdipFillEllipse (IntPtr graphics, IntPtr pen, float x, float y, float width, float height);
613                 [DllImport ("gdiplus.dll")]
614                 static internal extern  Status GdipFillPolygon (IntPtr graphics, IntPtr brush, PointF [] points, int count, FillMode fillMode);
615                 [DllImport ("gdiplus.dll")]
616                 static internal extern  Status GdipFillPolygonI (IntPtr graphics, IntPtr brush, Point [] points, int count, FillMode fillMode);
617                 [DllImport ("gdiplus.dll")]
618                 static internal extern  Status GdipFillPolygon2 (IntPtr graphics, IntPtr brush, PointF [] points, int count);
619                 [DllImport ("gdiplus.dll")]
620                 static internal extern  Status GdipFillPolygon2I (IntPtr graphics, IntPtr brush, Point [] points, int count);
621                 [DllImport("gdiplus.dll")]
622                 static internal extern Status GdipFillRectangle (IntPtr graphics, IntPtr brush, float x1, float y1, float x2, float y2);
623                 [DllImport("gdiplus.dll")]
624                 static internal extern Status GdipFillRectangleI (IntPtr graphics, IntPtr brush, int x1, int y1, int x2, int y2);
625                 [DllImport("gdiplus.dll")]
626                 static internal extern Status GdipFillRectangles (IntPtr graphics, IntPtr brush, RectangleF [] rects, int count);
627                 [DllImport("gdiplus.dll")]
628                 static internal extern Status GdipFillRectanglesI (IntPtr graphics, IntPtr brush, Rectangle [] rects, int count);
629                 [DllImport("gdiplus.dll", CharSet=CharSet.Unicode)]
630                 static internal extern Status GdipDrawString (IntPtr graphics, string text, int len, IntPtr font, ref RectangleF rc, IntPtr format, IntPtr brush);
631                 [DllImport("gdiplus.dll")]
632                 static internal extern Status GdipGetDC (IntPtr graphics, out IntPtr hdc);
633                 [DllImport("gdiplus.dll")]
634                 static internal extern Status GdipReleaseDC (IntPtr graphics, IntPtr hdc);
635                 [DllImport("gdiplus.dll")]
636                 static internal extern Status GdipDrawImageRectI (IntPtr graphics, IntPtr image, int x, int y, int width, int height);
637                 [DllImport ("gdiplus.dll")]
638                 static internal extern Status GdipGetRenderingOrigin (IntPtr graphics, out int x, out int y);
639                 [DllImport ("gdiplus.dll")]
640                 static internal extern Status GdipSetRenderingOrigin (IntPtr graphics, int x, int y);
641                 [DllImport("gdiplus.dll")]
642                 internal static extern Status GdipCloneBitmapArea (float x, float y, float width, float height, PixelFormat format, IntPtr original, out IntPtr bitmap);
643                 [DllImport("gdiplus.dll")]
644                 internal static extern Status GdipCloneBitmapAreaI (int x, int y, int width, int height, PixelFormat format, IntPtr original, out IntPtr bitmap);
645                 [DllImport("gdiplus.dll")]
646                 internal static extern Status GdipResetWorldTransform (IntPtr graphics);
647                 [DllImport("gdiplus.dll")]
648                 internal static extern Status GdipSetWorldTransform (IntPtr graphics, IntPtr matrix);
649                 [DllImport("gdiplus.dll")]
650                 internal static extern Status GdipGetWorldTransform (IntPtr graphics, IntPtr matrix);
651                 [DllImport("gdiplus.dll")]
652                 internal static extern Status GdipScaleWorldTransform (IntPtr graphics, float sx, float sy, MatrixOrder order);                 
653                 [DllImport("gdiplus.dll")]
654                 internal static extern Status GdipGraphicsClear(IntPtr graphics, int argb);             
655                 [DllImport("gdiplus.dll")]
656                 internal static extern Status GdipDrawClosedCurve(IntPtr graphics, IntPtr pen, PointF [] points, int count);
657                 [DllImport("gdiplus.dll")]
658                 internal static extern Status GdipDrawClosedCurveI(IntPtr graphics, IntPtr pen, Point [] points, int count);            
659                 [DllImport("gdiplus.dll")]
660                 internal static extern Status GdipDrawClosedCurve2(IntPtr graphics, IntPtr pen, PointF [] points, int count, float tension);
661                 [DllImport("gdiplus.dll")]
662                 internal static extern Status GdipDrawClosedCurve2I(IntPtr graphics, IntPtr pen, Point [] points, int count, float tension);            
663                 [DllImport("gdiplus.dll")]
664                 internal static extern Status GdipDrawCurve(IntPtr graphics, IntPtr pen, PointF [] points, int count);
665                 [DllImport("gdiplus.dll")]
666                 internal static extern Status GdipDrawCurveI(IntPtr graphics, IntPtr pen, Point [] points, int count);
667                 [DllImport("gdiplus.dll")]
668                 internal static extern Status GdipDrawCurve2(IntPtr graphics, IntPtr pen, PointF [] points, int count, float tension);
669                 [DllImport("gdiplus.dll")]
670                 internal static extern Status GdipDrawCurve2I(IntPtr graphics, IntPtr pen, Point [] points, int count, float tension);
671                 [DllImport("gdiplus.dll")]
672                 internal static extern Status GdipDrawCurve3(IntPtr graphics, IntPtr pen, PointF [] points, int count, int offset, int numberOfSegments, float tension);
673                 [DllImport("gdiplus.dll")]
674                 internal static extern Status GdipDrawCurve3I(IntPtr graphics, IntPtr pen, Point [] points, int count, int offset, int numberOfSegments, float tension);                
675                 [DllImport("gdiplus.dll")]              
676                 internal static extern Status GdipSetClipRect(IntPtr graphics, float x, float y, float width, float height, CombineMode combineMode);
677                 [DllImport("gdiplus.dll")]      
678                 internal static extern Status GdipSetClipRectI(IntPtr graphics, int x, int y, int width, int height, CombineMode combineMode);
679                 [DllImport("gdiplus.dll")]      
680                 internal static extern Status GdipSetClipPath(IntPtr graphics, IntPtr path, CombineMode combineMode);
681                 [DllImport("gdiplus.dll")]      
682                 internal static extern Status GdipSetClipRegion(IntPtr graphics, IntPtr region, CombineMode combineMode);
683                 [DllImport("gdiplus.dll")]      
684                 internal static extern Status GdipSetClipGraphics(IntPtr graphics, IntPtr srcgraphics, CombineMode combineMode);                
685                 [DllImport("gdiplus.dll")]      
686                 internal static extern Status GdipResetClip(IntPtr graphics);           
687                 [DllImport("gdiplus.dll")]      
688                 internal static extern Status GdipEndContainer(IntPtr graphics, uint state);
689                 [DllImport("gdiplus.dll")]      
690                 internal static extern Status GdipGetClip (IntPtr graphics, IntPtr region);
691
692                 [DllImport("gdiplus.dll")]      
693                 internal static extern Status GdipFillClosedCurve(IntPtr graphics, IntPtr brush, PointF [] points, int count);
694                               
695                 [DllImport("gdiplus.dll")]      
696                 internal static extern Status GdipFillClosedCurveI(IntPtr graphics, IntPtr brush, Point [] points, int count);
697
698                 [DllImport("gdiplus.dll")]      
699                 internal static extern Status GdipFillClosedCurve2(IntPtr graphics, IntPtr brush, 
700                                           PointF [] points, int count, float tension, FillMode fillMode);
701
702                 [DllImport("gdiplus.dll")]      
703                 internal static extern Status GdipFillClosedCurve2I(IntPtr graphics, IntPtr brush,
704                               Point [] points, int count, float tension, FillMode fillMode);
705                               
706                 [DllImport("gdiplus.dll")]      
707                 internal static extern Status GdipFillPie(IntPtr graphics, IntPtr brush, float x, float y,
708                 float width, float height, float startAngle, float sweepAngle);
709
710                 [DllImport("gdiplus.dll")]      
711                 internal static extern Status GdipFillPieI(IntPtr graphics, IntPtr brush, int x, int y,
712              int width, int height, float startAngle, float sweepAngle);
713              
714                 [DllImport("gdiplus.dll")]      
715                 internal static extern Status GdipFillPath(IntPtr graphics, IntPtr brush, IntPtr path);
716                 
717                 [DllImport("gdiplus.dll")]      
718                 internal static extern Status GdipGetNearestColor(IntPtr graphics,  out int argb);
719                 
720                 [DllImport("gdiplus.dll")]      
721                 internal static extern Status GdipIsVisiblePoint(IntPtr graphics, float x, float y, out bool result);
722
723                 [DllImport("gdiplus.dll")]      
724                 internal static extern Status GdipIsVisiblePointI(IntPtr graphics, int x, int y, out bool result);
725
726                 [DllImport("gdiplus.dll")]      
727                 internal static extern Status GdipIsVisibleRect(IntPtr graphics, float x, float y,
728                            float width, float height, out bool result);
729
730                 [DllImport("gdiplus.dll")]      
731                 internal static extern Status GdipIsVisibleRectI(IntPtr graphics, int x, int y,
732                            int width, int height, out bool result);
733                            
734                 [DllImport("gdiplus.dll")]      
735                 internal static extern Status GdipTransformPoints(IntPtr graphics, CoordinateSpace destSpace,
736                              CoordinateSpace srcSpace, IntPtr points,  int count);
737
738                 [DllImport("gdiplus.dll")]      
739                 internal static extern Status GdipTransformPointsI(IntPtr graphics, CoordinateSpace destSpace,
740                              CoordinateSpace srcSpace, IntPtr points, int count);                           
741         
742         [DllImport("gdiplus.dll")]                           
743                 internal static extern Status GdipTranslateClip(IntPtr graphics, float dx, float dy);
744                 [DllImport("gdiplus.dll")]                           
745                 internal static extern Status GdipTranslateClipI(IntPtr graphics, int dx, int dy);              
746                 [DllImport("gdiplus.dll")]                           
747                 internal static extern Status GdipGetClipBounds(IntPtr graphics, out RectangleF rect);          
748                 [DllImport("gdiplus.dll")]                           
749                 internal static extern Status GdipSetCompositingMode(IntPtr graphics, CompositingMode compositingMode);
750                 [DllImport("gdiplus.dll")]                           
751                 internal static extern Status GdipGetCompositingMode(IntPtr graphics, out CompositingMode compositingMode);             
752                 [DllImport("gdiplus.dll")]                           
753                 internal static extern Status GdipSetCompositingQuality(IntPtr graphics, CompositingQuality compositingQuality);
754                 [DllImport("gdiplus.dll")]                           
755                 internal static extern Status GdipGetCompositingQuality(IntPtr graphics, out CompositingQuality compositingQuality);
756                 [DllImport("gdiplus.dll")]                           
757                 internal static extern Status GdipSetInterpolationMode(IntPtr graphics, InterpolationMode interpolationMode);
758                 [DllImport("gdiplus.dll")]                   
759                 internal static extern Status GdipGetInterpolationMode(IntPtr graphics, out InterpolationMode interpolationMode);               
760                 [DllImport("gdiplus.dll")]                   
761                 internal static extern Status GdipGetDpiX(IntPtr graphics, out float dpi);
762                 [DllImport("gdiplus.dll")]                   
763                 internal static extern Status GdipGetDpiY(IntPtr graphics, out float dpi);
764                 [DllImport("gdiplus.dll")]                   
765                 internal static extern Status GdipIsClipEmpty(IntPtr graphics, out bool result);
766                 [DllImport("gdiplus.dll")]                   
767                 internal static extern Status GdipIsVisibleClipEmpty(IntPtr graphics, out bool result);         
768                 [DllImport("gdiplus.dll")]                   
769                 internal static extern Status GdipGetPageUnit(IntPtr graphics, out GraphicsUnit unit);          
770                 [DllImport("gdiplus.dll")]                   
771                 internal static extern Status GdipGetPageScale(IntPtr graphics, out float scale);               
772                 [DllImport("gdiplus.dll")]                   
773                 internal static extern Status GdipSetPageUnit(IntPtr graphics, GraphicsUnit unit);
774                 [DllImport("gdiplus.dll")]                   
775                 internal static extern Status GdipSetPageScale(IntPtr graphics, float scale);
776                 [DllImport("gdiplus.dll")]                   
777                 internal static extern Status GdipSetPixelOffsetMode(IntPtr graphics, PixelOffsetMode pixelOffsetMode);
778                 [DllImport("gdiplus.dll")]                   
779                 internal static extern Status GdipGetPixelOffsetMode(IntPtr graphics, out PixelOffsetMode pixelOffsetMode);
780                 [DllImport("gdiplus.dll")]                   
781                 internal static extern Status GdipSetSmoothingMode(IntPtr graphics, SmoothingMode smoothingMode);
782                 [DllImport("gdiplus.dll")]                   
783                 internal static extern Status GdipGetSmoothingMode(IntPtr graphics, out SmoothingMode smoothingMode);
784                 [DllImport("gdiplus.dll")]                   
785                 internal static extern Status GdipSetTextContrast(IntPtr graphics, int contrast);
786                 [DllImport("gdiplus.dll")]                   
787                 internal static extern Status GdipGetTextContrast(IntPtr graphics, out int contrast);
788                 [DllImport("gdiplus.dll")]                   
789                 internal static extern Status GdipSetTextRenderingHint(IntPtr graphics, TextRenderingHint mode);
790                 [DllImport("gdiplus.dll")]                   
791                 internal static extern Status GdipGetTextRenderingHint(IntPtr graphics, out TextRenderingHint mode);
792                 [DllImport("gdiplus.dll")]                   
793                 internal static extern Status GdipGetVisibleClipBounds(IntPtr graphics, out RectangleF rect);
794                 
795                 [DllImport("gdiplus.dll")]                   
796                 internal static extern Status GdipFlush(IntPtr graphics, FlushIntention intention);
797
798                 [DllImport("gdiplus.dll", CharSet=CharSet.Unicode)]
799                 internal static extern Status GdipAddPathString (IntPtr path, string s, int lenght, IntPtr family, int style, float emSize, ref RectangleF layoutRect, IntPtr format);
800                 [DllImport("gdiplus.dll", CharSet=CharSet.Unicode)]
801                 internal static extern Status GdipAddPathStringI (IntPtr path, string s, int lenght, IntPtr family, int style, float emSize, ref Rectangle layoutRect, IntPtr format);
802
803                                 
804                 // Pen functions
805                 [DllImport("gdiplus.dll")]
806                 internal static extern Status GdipCreatePen1 (int argb, float width, GraphicsUnit unit, out IntPtr pen);
807                 [DllImport("gdiplus.dll")]
808                 internal static extern Status GdipCreatePen2 (IntPtr brush, float width, GraphicsUnit unit, out IntPtr pen);
809                 [DllImport("gdiplus.dll")]
810                 internal static extern Status GdipClonePen (IntPtr pen, out IntPtr clonepen);
811                 [DllImport("gdiplus.dll")]
812                 internal static extern Status GdipDeletePen(IntPtr pen);
813                 [DllImport("gdiplus.dll")]
814                 internal static extern Status GdipSetPenBrushFill (IntPtr pen, IntPtr brush);
815                 [DllImport("gdiplus.dll")]
816                 internal static extern Status GdipGetPenBrushFill (IntPtr pen, out IntPtr brush);
817                 [DllImport("gdiplus.dll")]
818                 internal static extern Status GdipGetPenFillType (IntPtr pen, out PenType type);
819                 [DllImport("gdiplus.dll")]
820                 internal static extern Status GdipSetPenColor (IntPtr pen, int color);
821                 [DllImport("gdiplus.dll")]                
822                 internal static extern Status GdipGetPenColor (IntPtr pen, out int color);
823                 [DllImport("gdiplus.dll")]
824                 internal static extern Status GdipSetPenCompoundArray (IntPtr pen, float[] dash, int count);
825                 [DllImport("gdiplus.dll")]
826                 internal static extern Status GdipGetPenCompoundArray (IntPtr pen, float[] dash, int count);
827                 [DllImport("gdiplus.dll")]
828                 internal static extern Status GdipGetPenCompoundCount (IntPtr pen, out int count);
829                 [DllImport("gdiplus.dll")]
830                 internal static extern Status GdipSetPenDashCap197819 (IntPtr pen, DashCap dashCap);
831                 [DllImport("gdiplus.dll")]
832                 internal static extern Status GdipGetPenDashCap197819 (IntPtr pen, out DashCap dashCap);
833                 [DllImport("gdiplus.dll")]
834                 internal static extern Status GdipSetPenDashStyle (IntPtr pen, DashStyle dashStyle);
835                 [DllImport("gdiplus.dll")]
836                 internal static extern Status GdipGetPenDashStyle (IntPtr pen, out DashStyle dashStyle);
837                 [DllImport("gdiplus.dll")]
838                 internal static extern Status GdipSetPenDashOffset (IntPtr pen, float offset);
839                 [DllImport("gdiplus.dll")]
840                 internal static extern Status GdipGetPenDashOffset (IntPtr pen, out float offset);
841                 [DllImport("gdiplus.dll")]
842                 internal static extern Status GdipGetPenDashCount (IntPtr pen, out int count);
843                 [DllImport("gdiplus.dll")]
844                 internal static extern Status GdipSetPenDashArray (IntPtr pen, float[] dash, int count);
845                 [DllImport("gdiplus.dll")]
846                 internal static extern Status GdipGetPenDashArray (IntPtr pen, float[] dash, int count);
847                 [DllImport("gdiplus.dll")]
848                 internal static extern Status GdipSetPenMiterLimit (IntPtr pen, float miterLimit);
849                 [DllImport("gdiplus.dll")]
850                 internal static extern Status GdipGetPenMiterLimit (IntPtr pen, out float miterLimit);
851                 [DllImport("gdiplus.dll")]
852                 internal static extern Status GdipSetPenLineJoin (IntPtr pen, LineJoin lineJoin);
853                 [DllImport("gdiplus.dll")]
854                 internal static extern Status GdipGetPenLineJoin (IntPtr pen, out LineJoin lineJoin);
855                 [DllImport("gdiplus.dll")]
856                 internal static extern Status GdipSetPenLineCap197819 (IntPtr pen, LineCap startCap, LineCap endCap, DashCap dashCap);
857                 [DllImport("gdiplus.dll")]
858                 internal static extern Status GdipSetPenMode (IntPtr pen, PenAlignment alignment);
859                 [DllImport("gdiplus.dll")]
860                 internal static extern Status GdipGetPenMode (IntPtr pen, out PenAlignment alignment);
861                 [DllImport("gdiplus.dll")]
862                 internal static extern Status GdipSetPenStartCap (IntPtr pen, LineCap startCap);
863                 [DllImport("gdiplus.dll")]
864                 internal static extern Status GdipGetPenStartCap (IntPtr pen, out LineCap startCap);
865                 [DllImport("gdiplus.dll")]
866                 internal static extern Status GdipSetPenEndCap (IntPtr pen, LineCap endCap);
867                 [DllImport("gdiplus.dll")]
868                 internal static extern Status GdipGetPenEndCap (IntPtr pen, out LineCap endCap);
869                 [DllImport("gdiplus.dll")]
870                 internal static extern Status GdipSetPenCustomStartCap (IntPtr pen, IntPtr customCap);
871                 [DllImport("gdiplus.dll")]
872                 internal static extern Status GdipGetPenCustomStartCap (IntPtr pen, out IntPtr customCap);
873                 [DllImport("gdiplus.dll")]
874                 internal static extern Status GdipSetPenCustomEndCap (IntPtr pen, IntPtr customCap);
875                 [DllImport("gdiplus.dll")]
876                 internal static extern Status GdipGetPenCustomEndCap (IntPtr pen, out IntPtr customCap);
877                 [DllImport("gdiplus.dll")]
878                 internal static extern Status GdipSetPenTransform (IntPtr pen, IntPtr matrix);
879                 [DllImport("gdiplus.dll")]
880                 internal static extern Status GdipGetPenTransform (IntPtr pen, IntPtr matrix);
881                 [DllImport("gdiplus.dll")]
882                 internal static extern Status GdipSetPenWidth (IntPtr pen, float width);
883                 [DllImport("gdiplus.dll")]
884                 internal static extern Status GdipGetPenWidth (IntPtr pen, out float width);
885                 [DllImport("gdiplus.dll")]
886                 internal static extern Status GdipResetPenTransform (IntPtr pen);
887                 [DllImport("gdiplus.dll")]
888                 internal static extern Status GdipMultiplyPenTransform (IntPtr pen, IntPtr matrix, MatrixOrder order);
889                 [DllImport("gdiplus.dll")]
890                 internal static extern Status GdipRotatePenTransform (IntPtr pen, float angle, MatrixOrder order);
891                 [DllImport("gdiplus.dll")]
892                 internal static extern Status GdipScalePenTransform (IntPtr pen, float sx, float sy, MatrixOrder order);
893                 [DllImport("gdiplus.dll")]
894                 internal static extern Status GdipTranslatePenTransform (IntPtr pen, float dx, float dy, MatrixOrder order);
895
896                 // CustomLineCap functions
897                 [DllImport("gdiplus.dll")]
898                 internal static extern Status GdipCreateCustomLineCap (IntPtr fillPath, IntPtr strokePath, LineCap baseCap, float baseInset, out IntPtr customCap);
899                 [DllImport("gdiplus.dll")]
900                 internal static extern Status GdipDeleteCustomLineCap (IntPtr customCap);
901                 [DllImport("gdiplus.dll")]
902                 internal static extern Status GdipCloneCustomLineCap (IntPtr customCap, out IntPtr clonedCap);
903                 [DllImport("gdiplus.dll")]
904                 internal static extern Status GdipSetCustomLineCapStrokeCaps (IntPtr customCap, LineCap startCap, LineCap endCap);
905                 [DllImport("gdiplus.dll")]
906                 internal static extern Status GdipGetCustomLineCapStrokeCaps (IntPtr customCap, out LineCap startCap, out LineCap endCap);
907                 [DllImport("gdiplus.dll")]
908                 internal static extern Status GdipSetCustomLineCapStrokeJoin (IntPtr customCap, LineJoin lineJoin);
909                 [DllImport("gdiplus.dll")]
910                 internal static extern Status GdipGetCustomLineCapStrokeJoin (IntPtr customCap, out LineJoin lineJoin);
911                 [DllImport("gdiplus.dll")]
912                 internal static extern Status GdipSetCustomLineCapBaseCap (IntPtr customCap, LineCap baseCap);
913                 [DllImport("gdiplus.dll")]
914                 internal static extern Status GdipGetCustomLineCapBaseCap (IntPtr customCap, out LineCap baseCap);
915                 [DllImport("gdiplus.dll")]
916                 internal static extern Status GdipSetCustomLineCapBaseInset (IntPtr customCap, float inset);
917                 [DllImport("gdiplus.dll")]
918                 internal static extern Status GdipGetCustomLineCapBaseInset (IntPtr customCap, out float inset);
919                 [DllImport("gdiplus.dll")]
920                 internal static extern Status GdipSetCustomLineCapWidthScale (IntPtr customCap, float widthScale);
921                 [DllImport("gdiplus.dll")]
922                 internal static extern Status GdipGetCustomLineCapWidthScale (IntPtr customCap, out float widthScale);
923
924                 // AdjustableArrowCap functions
925                 [DllImport("gdiplus.dll")]
926                 internal static extern Status GdipCreateAdjustableArrowCap (float height, float width, bool isFilled, out IntPtr arrowCap);
927                 [DllImport("gdiplus.dll")]
928                 internal static extern Status GdipSetAdjustableArrowCapHeight (IntPtr arrowCap, float height);
929                 [DllImport("gdiplus.dll")]
930                 internal static extern Status GdipGetAdjustableArrowCapHeight (IntPtr arrowCap, out float height);
931                 [DllImport("gdiplus.dll")]
932                 internal static extern Status GdipSetAdjustableArrowCapWidth (IntPtr arrowCap, float width);
933                 [DllImport("gdiplus.dll")]
934                 internal static extern Status GdipGetAdjustableArrowCapWidth (IntPtr arrowCap, out float width);
935                 [DllImport("gdiplus.dll")]
936                 internal static extern Status GdipSetAdjustableArrowCapMiddleInset (IntPtr arrowCap, float middleInset);
937                 [DllImport("gdiplus.dll")]
938                 internal static extern Status GdipGetAdjustableArrowCapMiddleInset (IntPtr arrowCap, out float middleInset);
939                 [DllImport("gdiplus.dll")]
940                 internal static extern Status GdipSetAdjustableArrowCapFillState (IntPtr arrowCap, bool isFilled);
941                 [DllImport("gdiplus.dll")]
942                 internal static extern Status GdipGetAdjustableArrowCapFillState (IntPtr arrowCap, out bool isFilled);
943
944
945                 [DllImport("gdiplus.dll")]
946                 internal static extern Status GdipCreateFromHWND (IntPtr hwnd, out IntPtr graphics);
947
948                 [DllImport("gdiplus.dll", CharSet=CharSet.Unicode)]
949                 internal unsafe static extern Status GdipMeasureString(IntPtr graphics, string str, int length,
950                         IntPtr font, ref RectangleF layoutRect, IntPtr stringFormat, out RectangleF boundingBox,
951                         int *codepointsFitted, int *linesFilled);
952                                 
953                 [DllImport("gdiplus.dll", CharSet=CharSet.Unicode)]
954                 internal static extern Status GdipMeasureCharacterRanges (IntPtr graphics, string str, int length, IntPtr font,
955                         ref RectangleF layoutRect, IntPtr stringFormat, int regcount, out IntPtr regions);          
956
957                 [DllImport("gdiplus.dll")]
958                 internal static extern Status GdipSetStringFormatMeasurableCharacterRanges (IntPtr native, 
959                         int cnt, CharacterRange [] range);
960                 
961                 [DllImport("gdiplus.dll")]
962                 internal static extern Status GdipGetStringFormatMeasurableCharacterRangeCount (IntPtr native, 
963                         out int cnt);           
964         
965                 // Bitmap functions
966                 [DllImport("gdiplus.dll")]
967                 internal static extern Status GdipCreateBitmapFromScan0 (int width, int height, int stride, PixelFormat format, IntPtr scan0, out IntPtr bmp);
968
969                 [DllImport("gdiplus.dll")]
970                 internal static extern Status GdipCreateBitmapFromGraphics (int width, int height, IntPtr target, out IntPtr bitmap);
971
972                 [DllImport("gdiplus.dll")]
973                 internal static extern Status GdipBitmapLockBits (IntPtr bmp, ref Rectangle rc, ImageLockMode flags, PixelFormat format, [In, Out] BitmapData bmpData);
974                 
975                 [DllImport("gdiplus.dll")]
976                 internal static extern Status GdipBitmapSetResolution(IntPtr bmp, float xdpi, float ydpi);
977                                 
978                 [DllImport("gdiplus.dll")]
979                 internal static extern Status GdipBitmapUnlockBits (IntPtr bmp, [In,Out] BitmapData bmpData);
980                 
981                 [DllImport("gdiplus.dll")]
982                 internal static extern Status GdipBitmapGetPixel (IntPtr bmp, int x, int y, out int argb); 
983                 
984                 [DllImport("gdiplus.dll")]
985                 internal static extern Status GdipBitmapSetPixel (IntPtr bmp, int x, int y, int argb);
986
987                 // Image functions
988                 [DllImport("gdiplus.dll", CharSet=CharSet.Auto)]
989                 internal static extern Status GdipLoadImageFromFile ( [MarshalAs(UnmanagedType.LPWStr)] string filename, out IntPtr image );
990
991 #if !TEST
992                 // Stream functions for Win32 (original Win32 ones)
993                 [DllImport("gdiplus.dll", ExactSpelling=true, CharSet=CharSet.Unicode)]
994                 internal static extern Status GdipLoadImageFromStream([MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(ComIStreamMarshaler))] IStream stream, out IntPtr image);
995                 
996                 [DllImport("gdiplus.dll", ExactSpelling=true, CharSet=CharSet.Unicode)]
997                 internal static extern Status GdipSaveImageToStream(HandleRef image, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(ComIStreamMarshaler))] IStream stream, [In()] ref Guid clsidEncoder, HandleRef encoderParams);
998 #endif                  
999                                 
1000                 [DllImport("gdiplus.dll")]
1001                 internal static extern Status GdipCloneImage(IntPtr image, out IntPtr imageclone);
1002  
1003                 [DllImport("gdiplus.dll", CharSet=CharSet.Auto)]
1004                 internal static extern Status GdipLoadImageFromFileICM ( [MarshalAs(UnmanagedType.LPWStr)] string filename, out IntPtr image );
1005                 
1006                 [DllImport("gdiplus.dll")]
1007                 internal static extern Status GdipCreateBitmapFromHBITMAP ( IntPtr hBitMap, IntPtr gdiPalette, out IntPtr image );
1008                 
1009                 [DllImport("gdiplus.dll")]
1010                 internal static extern Status GdipDisposeImage ( IntPtr image );
1011
1012                 [DllImport("gdiplus.dll")]
1013                 internal static extern Status GdipGetImageFlags(IntPtr image, out int flag);
1014
1015                 [DllImport ("gdiplus.dll")]
1016                 internal static extern Status GdipGetImageType (IntPtr image, out ImageType type);
1017
1018                 [DllImport("gdiplus.dll")]
1019                 internal static extern Status GdipImageGetFrameDimensionsCount ( IntPtr image, out uint count );
1020                                                                                                    
1021                 [DllImport("gdiplus.dll")]
1022                 internal static extern Status GdipImageGetFrameDimensionsList ( IntPtr image, [Out] Guid [] dimensionIDs, uint count );
1023  
1024                 [DllImport("gdiplus.dll")]
1025                 internal static extern Status GdipGetImageHeight (IntPtr image, out uint height);
1026                                                                                                    
1027                 [DllImport("gdiplus.dll")]
1028                 internal static extern Status GdipGetImageHorizontalResolution ( IntPtr image, out float resolution );
1029
1030                 [DllImport("gdiplus.dll")]
1031                 internal static extern Status GdipGetImagePaletteSize ( IntPtr image, out int size );
1032                                                                                                    
1033                 [DllImport("gdiplus.dll")]
1034                 internal static extern Status GdipGetImagePalette (IntPtr image, IntPtr palette, int size);
1035
1036                 [DllImport("gdiplus.dll")]
1037                 internal static extern Status GdipSetImagePalette (IntPtr image, IntPtr palette);
1038                 
1039                 [DllImport("gdiplus.dll")]
1040                 internal static extern Status GdipGetImageDimension ( IntPtr image, out float width, out float height );
1041                                                                                                    
1042                 [DllImport("gdiplus.dll")]
1043                 internal static extern Status GdipGetImagePixelFormat ( IntPtr image, out PixelFormat format );
1044
1045                 [DllImport("gdiplus.dll")]
1046                 internal static extern Status GdipGetPropertyCount (IntPtr image, out uint propNumbers);
1047                 
1048                 [DllImport("gdiplus.dll")]
1049                 internal static extern Status GdipGetPropertyIdList (IntPtr image, uint propNumbers, [Out] int [] list);
1050  
1051                 [DllImport("gdiplus.dll")]
1052                 internal static extern Status GdipGetPropertySize (IntPtr image, out int bufferSize, out int propNumbers);
1053                 
1054                 [DllImport("gdiplus.dll")]
1055                 internal static extern Status GdipGetAllPropertyItems (IntPtr image, int bufferSize, int propNumbers, IntPtr items);
1056                                                                                                    
1057                 [DllImport("gdiplus.dll")]
1058                 internal static extern Status GdipGetImageRawFormat ( IntPtr image, out Guid format );
1059
1060                 [DllImport("gdiplus.dll")]
1061                 internal static extern Status GdipGetImageVerticalResolution ( IntPtr image, out float resolution );
1062                 
1063                 [DllImport("gdiplus.dll")]
1064                 internal static extern Status GdipGetImageWidth (IntPtr image, out uint width);
1065                 
1066                 [DllImport("gdiplus.dll")]
1067                 internal static extern Status GdipGetImageBounds ( IntPtr image, out RectangleF source, ref GraphicsUnit unit );
1068
1069                 [DllImport("gdiplus.dll")]
1070                 internal static extern Status GdipGetEncoderParameterListSize ( IntPtr image, ref Guid encoder, out uint size );
1071
1072                 [DllImport("gdiplus.dll")]
1073                 internal static extern Status GdipGetEncoderParameterList ( IntPtr image, ref Guid encoder, uint size, IntPtr buffer );
1074                 
1075                 [DllImport("gdiplus.dll")]
1076                 internal static extern Status GdipImageGetFrameCount (IntPtr image, ref Guid guidDimension, out uint count );
1077                 
1078                 [DllImport("gdiplus.dll")]
1079                 internal static extern Status GdipImageSelectActiveFrame (IntPtr image, ref Guid guidDimension, int frameIndex);
1080                 
1081                 [DllImport("gdiplus.dll")]
1082                 internal static extern Status GdipGetPropertyItemSize (IntPtr image, int propertyID, out int propertySize);
1083
1084                 [DllImport("gdiplus.dll")]
1085                 internal static extern Status GdipGetPropertyItem (IntPtr image, int propertyID, int propertySize, IntPtr buffer);
1086                 
1087                 [DllImport("gdiplus.dll")]
1088                 internal static extern Status GdipRemovePropertyItem (IntPtr image, int propertyId);
1089                 
1090                 [DllImport("gdiplus.dll")]
1091                 internal unsafe static extern Status GdipSetPropertyItem (IntPtr image, GdipPropertyItem *propertyItem);
1092                 
1093                 [DllImport("gdiplus.dll")]
1094                 internal static extern Status GdipGetImageThumbnail ( IntPtr image, uint width, uint height, out IntPtr thumbImage, IntPtr callback, IntPtr callBackData );
1095                 
1096                 [DllImport("gdiplus.dll")]
1097                 internal static extern Status GdipImageRotateFlip ( IntPtr image, RotateFlipType rotateFlipType );
1098                 
1099                 [DllImport("gdiplus.dll", CharSet=CharSet.Unicode)]
1100                 internal static extern Status GdipSaveImageToFile (IntPtr image, string filename,  ref Guid encoderClsID, IntPtr encoderParameters); 
1101                 
1102                 [DllImport("gdiplus.dll")]
1103                 internal static extern Status GdipSaveAdd ( IntPtr image, IntPtr encoderParameters );
1104                 
1105                 [DllImport("gdiplus.dll")]
1106                 internal static extern Status GdipSaveAddImage (IntPtr image, IntPtr imagenew, IntPtr encoderParameters);
1107                 
1108                 [DllImport("gdiplus.dll")]
1109                 internal static extern Status GdipDrawImageI (IntPtr graphics, IntPtr image, int x, int y);
1110                 [DllImport("gdiplus.dll")]
1111                 internal static extern Status GdipGetImageGraphicsContext (IntPtr image, out IntPtr graphics);          
1112                 [DllImport("gdiplus.dll")]
1113                 internal static extern Status GdipDrawImage (IntPtr graphics, IntPtr image, float x, float y);
1114
1115                 [DllImport("gdiplus.dll")]
1116                 internal static extern Status GdipBeginContainer (IntPtr graphics, ref RectangleF dstrect, ref RectangleF srcrect, GraphicsUnit unit, out uint state);
1117                 [DllImport("gdiplus.dll")]
1118                 internal static extern Status GdipBeginContainerI (IntPtr graphics, ref Rectangle dstrect, ref Rectangle srcrect, GraphicsUnit unit, out uint state);
1119                 [DllImport("gdiplus.dll")]
1120                 internal static extern Status GdipBeginContainer2 (IntPtr graphics, out uint state); 
1121                 
1122                 [DllImport("gdiplus.dll")]
1123                 internal static extern Status GdipDrawImagePoints (IntPtr graphics, IntPtr image, PointF [] destPoints, int count);
1124
1125                 
1126                 [DllImport("gdiplus.dll")]
1127                 internal static extern Status GdipDrawImagePointsI (IntPtr graphics, IntPtr image,  Point [] destPoints, int count);
1128                 
1129                 [DllImport("gdiplus.dll")]
1130                 internal static extern Status GdipDrawImageRectRectI (IntPtr graphics, IntPtr image,
1131                                 int dstx, int dsty, int dstwidth, int dstheight,
1132                                 int srcx, int srcy, int srcwidth, int srcheight,
1133                                 GraphicsUnit srcUnit, IntPtr imageattr, Graphics.DrawImageAbort callback, IntPtr callbackData);                                 
1134
1135                 [DllImport("gdiplus.dll")]
1136                 internal static extern Status GdipDrawImageRectRect (IntPtr graphics, IntPtr image,
1137                                 float dstx, float dsty, float dstwidth, float dstheight,
1138                                 float srcx, float srcy, float srcwidth, float srcheight,
1139                                 GraphicsUnit srcUnit, IntPtr imageattr, Graphics.DrawImageAbort callback, IntPtr callbackData);                                                                 
1140                 
1141                 [DllImport("gdiplus.dll")]
1142                 internal static extern Status GdipDrawImagePointsRectI (IntPtr graphics, IntPtr image,
1143                          Point [] destPoints, int count, int srcx, int srcy, int srcwidth, int srcheight,
1144                          GraphicsUnit srcUnit, IntPtr imageattr, Graphics.DrawImageAbort callback, IntPtr callbackData);
1145                          
1146                 [DllImport("gdiplus.dll")]
1147                 internal static extern Status GdipDrawImagePointsRect (IntPtr graphics, IntPtr image,
1148                          PointF [] destPoints, int count, float srcx, float srcy, float srcwidth, float srcheight,
1149                          GraphicsUnit srcUnit, IntPtr imageattr, Graphics.DrawImageAbort callback, IntPtr callbackData);
1150                                 
1151                 [DllImport("gdiplus.dll")]                                      
1152                 internal static extern Status GdipDrawImageRect(IntPtr graphics, IntPtr image, float x, float y, float width, float height);
1153                 [DllImport("gdiplus.dll")]                                      
1154                 internal static extern Status GdipDrawImagePointRect(IntPtr graphics, IntPtr image, float x,
1155                                 float y, float srcx, float srcy, float srcwidth, float srcheight, GraphicsUnit srcUnit);
1156                 
1157                 [DllImport("gdiplus.dll")]                                      
1158                 internal static extern Status GdipDrawImagePointRectI(IntPtr graphics, IntPtr image, int x,
1159                                 int y, int srcx, int srcy, int srcwidth,
1160                                 int srcheight, GraphicsUnit srcUnit);                           
1161                                 
1162                 [DllImport("gdiplus.dll")]                                      
1163                 internal static extern Status GdipCreateStringFormat(StringFormatFlags formatAttributes,  int language, out IntPtr native);
1164                 
1165                 [DllImport("gdiplus.dll")]              
1166                 internal static extern Status GdipCreateHBITMAPFromBitmap (IntPtr bmp, out IntPtr HandleBmp, int clrbackground);
1167
1168                 [DllImport("gdiplus.dll", CharSet=CharSet.Auto)]
1169                 internal static extern Status GdipCreateBitmapFromFile ([MarshalAs (UnmanagedType.LPWStr)] string filename, out IntPtr bitmap);
1170
1171                 [DllImport("gdiplus.dll", CharSet=CharSet.Auto)]
1172                 internal static extern Status GdipCreateBitmapFromFileICM ([MarshalAs (UnmanagedType.LPWStr)] string filename, out IntPtr bitmap);
1173                 
1174                 [DllImport("gdiplus.dll")]
1175                 internal static extern Status GdipCreateHICONFromBitmap (IntPtr bmp, out IntPtr HandleIcon);
1176                 
1177                 [DllImport("gdiplus.dll")]
1178                 internal static extern Status GdipCreateBitmapFromHICON (IntPtr  hicon,  out IntPtr bitmap);
1179                 
1180                 [DllImport("gdiplus.dll")]
1181                 internal static extern Status GdipCreateBitmapFromResource (IntPtr hInstance,
1182                                 string lpBitmapName, out IntPtr bitmap);
1183
1184                 // Matrix functions
1185                 [DllImport ("gdiplus.dll")]
1186                 internal static extern Status GdipCreateMatrix (out IntPtr matrix);
1187                 [DllImport ("gdiplus.dll")]
1188                 internal static extern Status GdipCreateMatrix2 (float m11, float m12, float m21, float m22, float dx, float dy, out IntPtr matrix);
1189                 [DllImport ("gdiplus.dll")]
1190                 internal static extern Status GdipCreateMatrix3 (ref RectangleF rect, PointF [] dstplg, out IntPtr matrix);
1191                 [DllImport ("gdiplus.dll")]                
1192                 internal static extern Status GdipCreateMatrix3I (ref Rectangle rect, Point [] dstplg, out IntPtr matrix);
1193                 [DllImport ("gdiplus.dll")]
1194                 internal static extern Status GdipDeleteMatrix (IntPtr matrix);
1195
1196                 [DllImport ("gdiplus.dll")]
1197                 internal static extern Status GdipCloneMatrix (IntPtr matrix, out IntPtr cloneMatrix);
1198                 [DllImport ("gdiplus.dll")]
1199                 internal static extern Status GdipSetMatrixElements (IntPtr matrix, float m11, float m12, float m21, float m22, float dx, float dy);
1200                 [DllImport ("gdiplus.dll")]
1201                 internal static extern Status GdipGetMatrixElements (IntPtr matrix, IntPtr matrixOut);
1202                 [DllImport ("gdiplus.dll")]
1203                 internal static extern Status GdipMultiplyMatrix (IntPtr matrix, IntPtr matrix2, MatrixOrder order);
1204                 [DllImport ("gdiplus.dll")]
1205                 internal static extern Status GdipTranslateMatrix (IntPtr matrix, float offsetX, float offsetY, MatrixOrder order);
1206                 [DllImport ("gdiplus.dll")]
1207                 internal static extern Status GdipScaleMatrix (IntPtr matrix, float scaleX, float scaleY, MatrixOrder order);
1208                 [DllImport ("gdiplus.dll")]
1209                 internal static extern Status GdipRotateMatrix (IntPtr matrix, float angle, MatrixOrder order);
1210
1211                 [DllImport ("gdiplus.dll")]
1212                 internal static extern Status GdipShearMatrix (IntPtr matrix, float shearX, float shearY, MatrixOrder order);
1213
1214                 [DllImport ("gdiplus.dll")]
1215                 internal static extern Status GdipInvertMatrix (IntPtr matrix);
1216                 [DllImport ("gdiplus.dll")]
1217                 internal static extern Status GdipTransformMatrixPoints (IntPtr matrix, PointF [] pts, int count);
1218                 [DllImport ("gdiplus.dll")]
1219                 internal static extern Status GdipTransformMatrixPointsI (IntPtr matrix, Point [] pts, int count);                
1220                 [DllImport ("gdiplus.dll")]
1221                 internal static extern Status GdipVectorTransformMatrixPoints (IntPtr matrix, PointF [] pts, int count);
1222                 [DllImport ("gdiplus.dll")]
1223                 internal static extern Status GdipVectorTransformMatrixPointsI (IntPtr matrix, Point [] pts, int count);
1224                 [DllImport ("gdiplus.dll")]
1225                 internal static extern Status GdipIsMatrixInvertible (IntPtr matrix, out bool result);
1226
1227                 [DllImport ("gdiplus.dll")]
1228                 internal static extern Status GdipIsMatrixIdentity (IntPtr matrix, out bool result);
1229                 [DllImport ("gdiplus.dll")]                
1230                 internal static extern Status GdipIsMatrixEqual (IntPtr matrix, IntPtr matrix2, out bool result);
1231
1232                 // GraphicsPath functions
1233                 [DllImport ("gdiplus.dll")]
1234                 internal static extern Status GdipCreatePath (FillMode brushMode, out IntPtr path);
1235                 [DllImport ("gdiplus.dll")]                
1236                 internal static extern Status GdipCreatePath2 (PointF [] points, byte [] types, int count, FillMode brushMode, out IntPtr path);
1237                 [DllImport ("gdiplus.dll")]                
1238                 internal static extern Status GdipCreatePath2I (Point [] points, byte [] types, int count, FillMode brushMode, out IntPtr path);                
1239                 [DllImport ("gdiplus.dll")]
1240                 internal static extern Status GdipClonePath (IntPtr path, out IntPtr clonePath);
1241                 [DllImport ("gdiplus.dll")]                
1242                 internal static extern Status GdipDeletePath (IntPtr path);
1243                 [DllImport ("gdiplus.dll")]                
1244                 internal static extern Status GdipResetPath (IntPtr path);
1245                 [DllImport ("gdiplus.dll")]                
1246                 internal static extern Status GdipGetPointCount (IntPtr path, out int count);
1247                 [DllImport ("gdiplus.dll")]                
1248                 internal static extern Status GdipGetPathTypes (IntPtr path, [Out] byte [] types, int count);
1249                 [DllImport ("gdiplus.dll")]                
1250                 internal static extern Status GdipGetPathPoints (IntPtr path, [Out] PointF [] points, int count);
1251                 [DllImport ("gdiplus.dll")]                
1252                 internal static extern Status GdipGetPathPointsI (IntPtr path, [Out] Point [] points, int count);
1253                 [DllImport ("gdiplus.dll")]                                
1254                 internal static extern Status GdipGetPathFillMode (IntPtr path, out FillMode fillMode);
1255                 [DllImport ("gdiplus.dll")]                                                
1256                 internal static extern Status GdipSetPathFillMode (IntPtr path, FillMode fillMode);
1257                 [DllImport ("gdiplus.dll")]                                                
1258                 internal static extern Status GdipStartPathFigure (IntPtr path);
1259                 [DllImport ("gdiplus.dll")]                                                
1260                 internal static extern Status GdipClosePathFigure (IntPtr path);
1261                 [DllImport ("gdiplus.dll")]                                                
1262                 internal static extern Status GdipClosePathFigures (IntPtr path);
1263                 [DllImport ("gdiplus.dll")]                                                
1264                 internal static extern Status GdipSetPathMarker (IntPtr path);
1265                 [DllImport ("gdiplus.dll")]                                                
1266                 internal static extern Status GdipClearPathMarkers (IntPtr path);
1267                 [DllImport ("gdiplus.dll")]                                                
1268                 internal static extern Status GdipReversePath (IntPtr path);
1269                 [DllImport ("gdiplus.dll")]                                                
1270                 internal static extern Status GdipGetPathLastPoint (IntPtr path, out PointF lastPoint);
1271                 [DllImport ("gdiplus.dll")]                                                
1272                 internal static extern Status GdipAddPathLine (IntPtr path, float x1, float y1, float x2, float y2);
1273                 [DllImport ("gdiplus.dll")]
1274                 internal static extern Status GdipAddPathLine2 (IntPtr path, PointF[] points, int count);
1275                 [DllImport ("gdiplus.dll")]
1276                 internal static extern Status GdipAddPathLine2I (IntPtr path, Point[] points, int count);
1277                 [DllImport ("gdiplus.dll")]                                                
1278                 internal static extern Status GdipAddPathArc (IntPtr path, float x, float y, float width, float height, float startAngle, float sweepAngle);
1279                 [DllImport ("gdiplus.dll")]                                                                
1280                 internal static extern Status GdipAddPathBezier (IntPtr path, float x1, float y1, float x2, float y2, float x3, float y3, float x4, float y4);
1281                 [DllImport ("gdiplus.dll")]                                                                
1282                 internal static extern Status GdipAddPathBeziers (IntPtr path, PointF [] points, int count);
1283                 [DllImport ("gdiplus.dll")]                                                                
1284                 internal static extern Status GdipAddPathCurve (IntPtr path, PointF [] points, int count);
1285                 [DllImport ("gdiplus.dll")]                                                                
1286                 internal static extern Status GdipAddPathCurveI (IntPtr path, Point [] points, int count);
1287                 [DllImport ("gdiplus.dll")]                                                                
1288                 internal static extern Status GdipAddPathCurve2 (IntPtr path, PointF [] points, int count, float tension);
1289                 [DllImport ("gdiplus.dll")]                                                                
1290                 internal static extern Status GdipAddPathCurve2I (IntPtr path, Point [] points, int count, float tension);
1291                 [DllImport ("gdiplus.dll")]                                                                
1292                 internal static extern Status GdipAddPathCurve3 (IntPtr path, PointF [] points, int count, int offset, int numberOfSegments, float tension);
1293                 [DllImport ("gdiplus.dll")]                                                                
1294                 internal static extern Status GdipAddPathCurve3I (IntPtr path, Point [] points, int count, int offset, int numberOfSegments, float tension);
1295                 [DllImport ("gdiplus.dll")]                                                                
1296                 internal static extern Status GdipAddPathClosedCurve (IntPtr path, PointF [] points, int count);
1297                 [DllImport ("gdiplus.dll")]                                                                
1298                 internal static extern Status GdipAddPathClosedCurveI (IntPtr path, Point [] points, int count);
1299                 [DllImport ("gdiplus.dll")]                                                                
1300                 internal static extern Status GdipAddPathClosedCurve2 (IntPtr path, PointF [] points, int count, float tension);
1301                 [DllImport ("gdiplus.dll")]                                                                
1302                 internal static extern Status GdipAddPathClosedCurve2I (IntPtr path, Point [] points, int count, float tension);
1303                 [DllImport ("gdiplus.dll")]                                                                
1304                 internal static extern Status GdipAddPathRectangle (IntPtr path, float x, float y, float width, float height);
1305                 [DllImport ("gdiplus.dll")]                                                                
1306                 internal static extern Status GdipAddPathRectangles (IntPtr path, RectangleF [] rects, int count);
1307                 [DllImport ("gdiplus.dll")]                                                                
1308                 internal static extern Status GdipAddPathEllipse (IntPtr path, float x, float y, float width, float height);
1309                 [DllImport ("gdiplus.dll")]
1310                 internal static extern Status GdipAddPathEllipseI (IntPtr path, int x, int y, int width, int height);
1311                 [DllImport ("gdiplus.dll")]                                                                
1312                 internal static extern Status GdipAddPathPie (IntPtr path, float x, float y, float width, float height, float startAngle, float sweepAngle);
1313                 [DllImport ("gdiplus.dll")]                                                                
1314                 internal static extern Status GdipAddPathPieI (IntPtr path, int x, int y, int width, int height, float startAngle, float sweepAngle);                
1315                 [DllImport ("gdiplus.dll")]                                                                
1316                 internal static extern Status GdipAddPathPolygon (IntPtr path, PointF [] points, int count);
1317                 [DllImport ("gdiplus.dll")]                                                                
1318                 internal static extern Status GdipAddPathPath (IntPtr path, IntPtr addingPath, bool connect);
1319                 [DllImport ("gdiplus.dll")]
1320                 internal static extern Status GdipAddPathLineI (IntPtr path, int x1, int y1, int x2, int y2);
1321                 [DllImport ("gdiplus.dll")]                                                
1322                 internal static extern Status GdipAddPathArcI (IntPtr path, int x, int y, int width, int height, float startAngle, float sweepAngle);
1323                 
1324                 [DllImport ("gdiplus.dll")]                
1325                 internal static extern Status GdipAddPathBezierI (IntPtr path, int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4);
1326                 [DllImport ("gdiplus.dll")]
1327                 internal static extern Status GdipAddPathBeziersI (IntPtr path, Point [] points, int count);
1328                                 
1329                 [DllImport ("gdiplus.dll")]                
1330                 internal static extern Status GdipAddPathPolygonI (IntPtr path, Point [] points, int count);
1331                 [DllImport ("gdiplus.dll")]                
1332                 internal static extern Status GdipAddPathRectangleI (IntPtr path, int x, int y, int width, int height);
1333                 [DllImport ("gdiplus.dll")]                
1334                 internal static extern Status GdipAddPathRectanglesI (IntPtr path, Rectangle [] rects, int count);
1335                 [DllImport ("gdiplus.dll")]
1336                 internal static extern Status GdipFlattenPath (IntPtr path, IntPtr matrix, float floatness);
1337                 [DllImport ("gdiplus.dll")]
1338                 internal static extern Status GdipTransformPath (IntPtr path, IntPtr matrix);
1339                 [DllImport ("gdiplus.dll")]
1340                 internal static extern Status GdipWarpPath (IntPtr path, IntPtr matrix,
1341                                                             PointF [] points, int count,
1342                                                             float srcx, float srcy, float srcwidth, float srcheight,
1343                                                             WarpMode mode, float flatness);
1344                 [DllImport ("gdiplus.dll")]
1345                 internal static extern Status GdipWidenPath (IntPtr path, IntPtr pen, IntPtr matrix, float flatness);
1346                 [DllImport ("gdiplus.dll")]                
1347                 internal static extern Status GdipGetPathWorldBounds (IntPtr path, out RectangleF bounds, IntPtr matrix, IntPtr pen);
1348                 [DllImport ("gdiplus.dll")]                
1349                 internal static extern Status GdipGetPathWorldBoundsI (IntPtr path, out Rectangle bounds, IntPtr matrix, IntPtr pen);
1350                 [DllImport ("gdiplus.dll")]                
1351                 internal static extern Status GdipIsVisiblePathPoint (IntPtr path, float x, float y, IntPtr graphics, out bool result);
1352                 [DllImport ("gdiplus.dll")]                
1353                 internal static extern Status GdipIsVisiblePathPointI (IntPtr path, int x, int y, IntPtr graphics, out bool result); 
1354                 [DllImport ("gdiplus.dll")]                
1355                 internal static extern Status GdipIsOutlineVisiblePathPoint (IntPtr path, float x, float y, IntPtr pen, IntPtr graphics, out bool result);
1356                 [DllImport ("gdiplus.dll")]                
1357                 internal static extern Status GdipIsOutlineVisiblePathPointI (IntPtr path, int x, int y, IntPtr pen, IntPtr graphics, out bool result); 
1358
1359                 // GraphicsPathIterator
1360                 [DllImport("gdiplus.dll")]
1361                 internal static extern Status GdipCreatePathIter (out IntPtr iterator, IntPtr path);
1362                 [DllImport("gdiplus.dll")]
1363                 internal static extern Status GdipPathIterGetCount (IntPtr iterator, out int count);
1364                 [DllImport("gdiplus.dll")]
1365                 internal static extern Status GdipPathIterGetSubpathCount (IntPtr iterator, out int count);
1366                 [DllImport("gdiplus.dll")]
1367                 internal static extern Status GdipDeletePathIter (IntPtr iterator);
1368                 [DllImport("gdiplus.dll")]
1369                 internal static extern Status GdipPathIterCopyData (IntPtr iterator, out int resultCount, PointF [] points, byte [] types, int startIndex, int endIndex);
1370                 [DllImport("gdiplus.dll")]
1371                 internal static extern Status GdipPathIterEnumerate (IntPtr iterator, out int resultCount, PointF [] points, byte [] types, int count);
1372                 [DllImport("gdiplus.dll")]
1373                 internal static extern Status GdipPathIterHasCurve (IntPtr iterator, out bool curve);
1374                 [DllImport("gdiplus.dll")]
1375                 internal static extern Status GdipPathIterNextMarkerPath (IntPtr iterator, out int resultCount, IntPtr path);
1376                 [DllImport("gdiplus.dll")]
1377                 internal static extern Status GdipPathIterNextMarker (IntPtr iterator, out int resultCount, out int startIndex, out int endIndex);
1378                 [DllImport("gdiplus.dll")]
1379                 internal static extern Status GdipPathIterNextPathType (IntPtr iterator, out int resultCount, out byte pathType, out int startIndex, out int endIndex);
1380                 [DllImport("gdiplus.dll")]
1381                 internal static extern Status GdipPathIterNextSubpathPath (IntPtr iterator, out int resultCount, IntPtr path, out bool isClosed);
1382                 [DllImport("gdiplus.dll")]
1383                 internal static extern Status GdipPathIterNextSubpath (IntPtr iterator, out int resultCount, out int startIndex, out int endIndex, out bool isClosed);
1384                 [DllImport("gdiplus.dll")]
1385                 internal static extern Status GdipPathIterRewind (IntPtr iterator);
1386
1387                 // ImageAttributes
1388                 [DllImport ("gdiplus.dll")]     
1389                 internal static extern Status GdipCreateImageAttributes (out IntPtr imageattr);
1390                                 
1391                 [DllImport ("gdiplus.dll")]     
1392                 internal static extern Status GdipSetImageAttributesColorKeys (IntPtr imageattr,
1393                                 ColorAdjustType type, bool enableFlag, int colorLow, int colorHigh);
1394                                 
1395                 [DllImport ("gdiplus.dll")]     
1396                 internal static extern Status GdipDisposeImageAttributes (IntPtr imageattr);
1397                                 
1398                 [DllImport ("gdiplus.dll")]     
1399                 internal static extern Status GdipSetImageAttributesColorMatrix (IntPtr imageattr,
1400                                 ColorAdjustType type, bool enableFlag, IntPtr colorMatrix,
1401                                 IntPtr grayMatrix,  ColorMatrixFlag flags);                                
1402
1403                 [DllImport ("gdiplus.dll")]     
1404                 internal static extern Status GdipSetImageAttributesGamma (IntPtr imageattr, 
1405                         ColorAdjustType type, bool enableFlag,  
1406                                                                                                                                                         float gamma);
1407                 
1408                 [DllImport ("gdiplus.dll")]     
1409                 internal static extern Status GdipSetImageAttributesNoOp (IntPtr imageattr, 
1410                         ColorAdjustType type, bool enableFlag);
1411                 
1412                 [DllImport ("gdiplus.dll")]     
1413                 internal static extern Status GdipSetImageAttributesOutputChannel (IntPtr imageattr,
1414                         ColorAdjustType type, bool enableFlag,  ColorChannelFlag channelFlags);
1415                 
1416                 [DllImport ("gdiplus.dll", CharSet=CharSet.Auto)]     
1417                 internal static extern Status GdipSetImageAttributesOutputChannelColorProfile (IntPtr imageattr,
1418                         ColorAdjustType type, bool enableFlag, [MarshalAs (UnmanagedType.LPWStr)] string profileName);
1419                                 
1420                 [DllImport ("gdiplus.dll")]     
1421                 internal static extern Status GdipSetImageAttributesRemapTable (IntPtr imageattr,
1422                         ColorAdjustType type, bool enableFlag,  uint mapSize, IntPtr colorMap);
1423                 
1424                 [DllImport ("gdiplus.dll")]     
1425                 internal static extern Status GdipSetImageAttributesThreshold (IntPtr imageattr, 
1426                         ColorAdjustType type, bool enableFlag, float thresHold);
1427                         
1428                 [DllImport ("gdiplus.dll")]     
1429                 internal static extern Status GdipCloneImageAttributes(IntPtr imageattr, out IntPtr cloneImageattr);
1430
1431                 [DllImport ("gdiplus.dll")]     
1432                 internal static extern Status GdipGetImageAttributesAdjustedPalette (IntPtr imageattr, IntPtr colorPalette,
1433                         ColorAdjustType colorAdjustType);
1434                         
1435                 [DllImport ("gdiplus.dll")]     
1436                 internal static extern Status GdipSetImageAttributesWrapMode(IntPtr imageattr,  WrapMode wrap,
1437                         int argb, bool clamp);
1438
1439                                
1440                 // Font         
1441                 [DllImport("gdiplus.dll")]                   
1442                 internal static extern Status GdipCreateFont (IntPtr fontFamily, float emSize, FontStyle style, GraphicsUnit  unit,  out IntPtr font);
1443                 [DllImport("gdiplus.dll")]                   
1444                 internal static extern Status GdipDeleteFont (IntPtr font);             
1445                 [DllImport("gdiplus.dll", CharSet=CharSet.Auto)]
1446                 internal static extern Status GdipGetLogFont(IntPtr font, IntPtr graphics, [MarshalAs(UnmanagedType.AsAny), Out] object logfontA);
1447
1448                 [DllImport("gdiplus.dll")]                   
1449                 internal static extern Status GdipCreateFontFromDC(IntPtr hdc, out IntPtr font);
1450                 [DllImport("gdiplus.dll", SetLastError=true, CharSet=CharSet.Auto)]
1451                 internal static extern Status GdipCreateFontFromLogfont(IntPtr hdc, ref LOGFONT lf, out IntPtr ptr);
1452
1453                 // These are our private functions, they exists in our own libgdiplus library, this way we
1454                 // avoid relying on wine in System.Drawing
1455                 [DllImport("gdiplus.dll", CharSet=CharSet.Ansi)]                   
1456                 internal static extern Status GdipCreateFontFromHfont(IntPtr hdc, out IntPtr font, ref LOGFONT lf);
1457
1458                 // This is win32/gdi, not gdiplus, but it's easier to keep in here, also see above comment
1459                 [DllImport("gdi32.dll", CallingConvention=CallingConvention.StdCall, CharSet = CharSet.Auto)]
1460                 internal static extern IntPtr CreateFontIndirect (ref LOGFONT logfont); 
1461                 [DllImport("user32.dll", EntryPoint="GetDC", CallingConvention = CallingConvention.StdCall, CharSet = CharSet.Ansi)]
1462                 internal static extern IntPtr GetDC(IntPtr hwnd);       
1463                 [DllImport("user32.dll", EntryPoint="ReleaseDC", CallingConvention = CallingConvention.StdCall, CharSet = CharSet.Ansi)]
1464                 internal static extern int ReleaseDC (IntPtr hWnd, IntPtr hDC);
1465                 [DllImport("gdi32.dll", EntryPoint="SelectObject", CallingConvention = CallingConvention.StdCall, CharSet = CharSet.Ansi)]
1466                 internal static extern IntPtr SelectObject(IntPtr hdc, IntPtr obj);     
1467                 [DllImport("user32.dll", SetLastError=true)]
1468                 internal static extern bool GetIconInfo (IntPtr hIcon, out IconInfo iconinfo);
1469                 [DllImport("user32.dll", CallingConvention = CallingConvention.StdCall, SetLastError=true)]
1470                 internal static extern IntPtr CreateIconIndirect ([In] ref IconInfo piconinfo);
1471                 [DllImport("user32.dll", CallingConvention = CallingConvention.StdCall, SetLastError=true)]
1472                 internal static extern bool DestroyIcon (IntPtr hIcon);
1473                 [DllImport("gdi32.dll")]
1474                 internal static extern bool DeleteObject (IntPtr hObject);
1475                 [DllImport("user32.dll")]
1476                 internal static extern IntPtr GetDesktopWindow ();
1477
1478                 [DllImport("gdi32.dll", SetLastError=true)]
1479                 public static extern int BitBlt(IntPtr hdcDest, int nXDest, int nYDest, 
1480                         int nWidth, int nHeight, IntPtr hdcSrc, int nXSrc, int nYSrc, int dwRop);
1481
1482                 [DllImport ("user32.dll", EntryPoint = "GetSysColor", CallingConvention = CallingConvention.StdCall)]
1483                 public static extern uint Win32GetSysColor (GetSysColorIndex index);
1484
1485
1486                 // Some special X11 stuff
1487                 [DllImport("libX11", EntryPoint="XOpenDisplay")]
1488                 internal extern static IntPtr XOpenDisplay(IntPtr display);     
1489
1490                 [DllImport("libX11", EntryPoint="XCloseDisplay")]
1491                 internal extern static int XCloseDisplay(IntPtr display);       
1492
1493                 [DllImport ("libX11", EntryPoint="XRootWindow")]
1494                 internal extern static IntPtr XRootWindow(IntPtr display, int screen);
1495                         
1496                 [DllImport ("libX11", EntryPoint="XDefaultScreen")]
1497                 internal extern static int XDefaultScreen(IntPtr display);
1498
1499                 [DllImport ("libX11", EntryPoint="XDefaultDepth")]
1500                 internal extern static uint XDefaultDepth(IntPtr display, int screen);
1501
1502                 [DllImport ("libX11", EntryPoint="XGetImage")]
1503                 internal extern static IntPtr XGetImage(IntPtr display, IntPtr drawable, int src_x, int src_y, int width, int height, int pane, int format);
1504
1505                 [DllImport ("libX11", EntryPoint="XGetPixel")]
1506                 internal extern static int XGetPixel(IntPtr image, int x, int y);
1507
1508                 [DllImport ("libX11", EntryPoint="XDestroyImage")]
1509                 internal extern static int XDestroyImage(IntPtr image);
1510
1511                 [DllImport ("libX11", EntryPoint="XDefaultVisual")]
1512                 internal extern static IntPtr XDefaultVisual(IntPtr display, int screen);
1513
1514                 [DllImport ("libX11", EntryPoint="XGetVisualInfo")]
1515                 internal extern static IntPtr XGetVisualInfo (IntPtr display, int vinfo_mask, ref XVisualInfo vinfo_template, ref int nitems);
1516
1517                 [DllImport ("libX11", EntryPoint="XVisualIDFromVisual")]
1518                 internal extern static int XVisualIDFromVisual(IntPtr visual);
1519
1520                 [DllImport ("libX11", EntryPoint="XFree")]
1521                 internal extern static void XFree (IntPtr data);        
1522                 
1523                 // FontCollection
1524                 [DllImport ("gdiplus.dll")]
1525                 internal static extern Status GdipGetFontCollectionFamilyCount (IntPtr collection, out int found);
1526                 
1527                 [DllImport ("gdiplus.dll")]
1528                 internal static extern Status GdipGetFontCollectionFamilyList (IntPtr collection, int getCount, IntPtr[] dest, out int retCount);
1529                 //internal static extern Status GdipGetFontCollectionFamilyList( IntPtr collection, int getCount, [Out] FontFamily [] familyList, out int retCount );
1530                 
1531                 [DllImport ("gdiplus.dll")]
1532                 internal static extern Status GdipNewInstalledFontCollection (out IntPtr collection);
1533                 
1534                 [DllImport ("gdiplus.dll")]
1535                 internal static extern Status GdipNewPrivateFontCollection (out IntPtr collection);
1536                 
1537                 [DllImport ("gdiplus.dll")]
1538                 internal static extern Status GdipDeletePrivateFontCollection (ref IntPtr collection);
1539                 
1540                 [DllImport ("gdiplus.dll", CharSet=CharSet.Auto)]
1541                 internal static extern Status GdipPrivateAddFontFile (IntPtr collection,
1542                                 [MarshalAs (UnmanagedType.LPWStr)] string fileName );
1543                 
1544                 [DllImport ("gdiplus.dll")]
1545                 internal static extern Status GdipPrivateAddMemoryFont (IntPtr collection, IntPtr mem, int length);
1546
1547                 //FontFamily
1548                 [DllImport ("gdiplus.dll", CharSet=CharSet.Auto)]
1549                 internal static extern Status GdipCreateFontFamilyFromName (
1550                         [MarshalAs(UnmanagedType.LPWStr)] string fName, IntPtr collection, out IntPtr fontFamily);
1551
1552                 [DllImport ("gdiplus.dll", CharSet=CharSet.Unicode)]
1553                 internal static extern Status GdipGetFamilyName(IntPtr family, StringBuilder name, int language);
1554
1555                 [DllImport ("gdiplus.dll")]
1556                 internal static extern Status GdipGetGenericFontFamilySansSerif (out IntPtr fontFamily);
1557
1558                 [DllImport ("gdiplus.dll")]
1559                 internal static extern Status GdipGetGenericFontFamilySerif (out IntPtr fontFamily);
1560
1561                 [DllImport ("gdiplus.dll")]
1562                 internal static extern Status GdipGetGenericFontFamilyMonospace (out IntPtr fontFamily);
1563                 
1564                 [DllImport ("gdiplus.dll")]
1565                 internal static extern Status GdipGetCellAscent (IntPtr fontFamily, int style, out short ascent);
1566
1567                 [DllImport ("gdiplus.dll")]
1568                 internal static extern Status GdipGetCellDescent (IntPtr fontFamily, int style, out short descent);
1569
1570                 [DllImport ("gdiplus.dll")]
1571                 internal static extern Status GdipGetLineSpacing (IntPtr fontFamily, int style, out short spacing);
1572
1573                 [DllImport ("gdiplus.dll")]
1574                 internal static extern Status GdipGetEmHeight (IntPtr fontFamily, int style, out short emHeight);
1575
1576                 [DllImport ("gdiplus.dll")]
1577                 internal static extern Status GdipIsStyleAvailable (IntPtr fontFamily, int style, out bool styleAvailable);
1578
1579                 [DllImport ("gdiplus.dll")]
1580                 internal static extern Status GdipDeleteFontFamily (IntPtr fontFamily);
1581                 
1582                 [DllImport ("gdiplus.dll")]
1583                 internal static extern Status GdipGetFontSize (IntPtr font, out float size);
1584                 
1585                 [DllImport ("gdiplus.dll")]
1586                 internal static extern Status GdipGetFontHeight (IntPtr font, IntPtr graphics, out float height);
1587                 
1588                 [DllImport ("gdiplus.dll")]
1589                 internal static extern Status GdipGetFontHeightGivenDPI (IntPtr font, float dpi, out float height);
1590
1591                 [DllImport ("gdiplus.dll")]
1592                 internal static extern Status GdipCloneFontFamily (IntPtr fontFamily, out IntPtr clone);
1593                 
1594                 
1595                 // String Format
1596                 [DllImport ("gdiplus.dll")]
1597                 internal static extern Status GdipCreateStringFormat(int formatAttributes, int language, out IntPtr  format);
1598                 [DllImport ("gdiplus.dll")]
1599                 internal static extern Status GdipStringFormatGetGenericDefault(out IntPtr format);
1600                 [DllImport ("gdiplus.dll")]
1601                 internal static extern Status GdipStringFormatGetGenericTypographic(out IntPtr format);
1602                 [DllImport ("gdiplus.dll")]
1603                 internal static extern Status GdipDeleteStringFormat(IntPtr format);
1604                 [DllImport ("gdiplus.dll")]
1605                 internal static extern Status GdipCloneStringFormat(IntPtr srcformat, out IntPtr format);
1606                 [DllImport ("gdiplus.dll")]
1607                 internal static extern Status GdipSetStringFormatFlags(IntPtr format, StringFormatFlags flags);
1608                 [DllImport ("gdiplus.dll")]
1609                 internal static extern Status GdipGetStringFormatFlags(IntPtr format, out StringFormatFlags flags);
1610                 [DllImport ("gdiplus.dll")]
1611                 internal static extern Status GdipSetStringFormatAlign(IntPtr format, StringAlignment align);
1612                 [DllImport ("gdiplus.dll")]
1613                 internal static extern Status GdipGetStringFormatAlign(IntPtr format, out StringAlignment align);
1614                 [DllImport ("gdiplus.dll")]
1615                 internal static extern Status GdipSetStringFormatLineAlign(IntPtr format, StringAlignment align);
1616                 [DllImport ("gdiplus.dll")]
1617                 internal static extern Status GdipGetStringFormatLineAlign(IntPtr format, out StringAlignment align);
1618                 [DllImport ("gdiplus.dll")]
1619                 internal static extern Status GdipSetStringFormatTrimming(IntPtr format, StringTrimming trimming);
1620                 [DllImport ("gdiplus.dll")]
1621                 internal static extern Status GdipGetStringFormatTrimming(IntPtr format, out StringTrimming trimming);
1622                 [DllImport ("gdiplus.dll")]
1623                 internal static extern Status GdipSetStringFormatHotkeyPrefix(IntPtr format, HotkeyPrefix hotkeyPrefix);
1624                 [DllImport ("gdiplus.dll")]
1625                 internal static extern Status GdipGetStringFormatHotkeyPrefix(IntPtr format, out HotkeyPrefix hotkeyPrefix);
1626                 [DllImport ("gdiplus.dll")]
1627                 internal static extern Status GdipSetStringFormatTabStops(IntPtr format, float firstTabOffset, int count, float [] tabStops);
1628                 [DllImport ("gdiplus.dll")]
1629                 internal static extern Status GdipGetStringFormatDigitSubstitution(IntPtr format, int language, out StringDigitSubstitute substitute);
1630                 [DllImport ("gdiplus.dll")]
1631                 internal static extern Status GdipSetStringFormatDigitSubstitution(IntPtr format, int language, StringDigitSubstitute substitute);
1632                 [DllImport ("gdiplus.dll")]
1633                 internal static extern Status GdipGetStringFormatTabStopCount(IntPtr format, out int count);
1634                 [DllImport ("gdiplus.dll")]
1635                 internal static extern Status GdipGetStringFormatTabStops(IntPtr format, int count, out float firstTabOffset, [In, Out] float [] tabStops);
1636                                 
1637                 // metafile
1638                 [DllImport ("gdiplus.dll", CharSet = CharSet.Auto)]
1639                 internal static extern Status GdipCreateMetafileFromFile ([MarshalAs (UnmanagedType.LPWStr)] string filename, out IntPtr metafile);
1640                 [DllImport ("gdiplus.dll")]
1641                 internal static extern Status GdipCreateMetafileFromEmf (IntPtr hEmf, bool deleteEmf, out IntPtr metafile);
1642                 [DllImport ("gdiplus.dll")]
1643                 internal static extern Status GdipCreateMetafileFromWmf (IntPtr hWmf, bool deleteWmf, WmfPlaceableFileHeader wmfPlaceableFileHeader, out IntPtr metafile);
1644                 [DllImport ("gdiplus.dll", CharSet = CharSet.Auto)]
1645                 internal static extern Status GdipGetMetafileHeaderFromFile ([MarshalAs (UnmanagedType.LPWStr)] string filename, IntPtr header);
1646                 [DllImport ("gdiplus.dll")]
1647                 internal static extern Status GdipGetMetafileHeaderFromMetafile (IntPtr metafile, IntPtr header);
1648                 [DllImport ("gdiplus.dll")]
1649                 internal static extern Status GdipGetMetafileHeaderFromEmf (IntPtr hEmf, IntPtr header);
1650                 [DllImport ("gdiplus.dll")]
1651                 internal static extern Status GdipGetMetafileHeaderFromWmf (IntPtr hWmf, IntPtr wmfPlaceableFileHeader, IntPtr header);
1652                 [DllImport ("gdiplus.dll")]
1653                 internal static extern Status GdipGetHemfFromMetafile (IntPtr metafile, out IntPtr hEmf);
1654                 [DllImport ("gdiplus.dll")]
1655                 internal static extern Status GdipGetMetafileDownLevelRasterizationLimit (IntPtr metafile, ref uint metafileRasterizationLimitDpi);
1656                 [DllImport ("gdiplus.dll")]
1657                 internal static extern Status GdipSetMetafileDownLevelRasterizationLimit (IntPtr metafile, uint metafileRasterizationLimitDpi);
1658                 [DllImport ("gdiplus.dll")]
1659                 internal static extern Status GdipPlayMetafileRecord (IntPtr metafile, EmfPlusRecordType recordType, int flags, int dataSize, byte[] data);
1660
1661                 [DllImport ("gdiplus.dll")]
1662                 internal static extern Status GdipRecordMetafile (IntPtr hdc, EmfType type, ref RectangleF frameRect, 
1663                         MetafileFrameUnit frameUnit, [MarshalAs (UnmanagedType.LPWStr)] string description, out IntPtr metafile);
1664                 [DllImport ("gdiplus.dll")]
1665                 internal static extern Status GdipRecordMetafileI (IntPtr hdc, EmfType type, ref Rectangle frameRect, 
1666                         MetafileFrameUnit frameUnit, [MarshalAs (UnmanagedType.LPWStr)] string description, out IntPtr metafile);
1667                 [DllImport ("gdiplus.dll")]
1668                 internal static extern Status GdipRecordMetafileFileName ([MarshalAs (UnmanagedType.LPWStr)] string filename, IntPtr hdc, EmfType type,
1669                         ref RectangleF frameRect, MetafileFrameUnit frameUnit, [MarshalAs (UnmanagedType.LPWStr)] string description, out IntPtr metafile);
1670                 [DllImport ("gdiplus.dll")]
1671                 internal static extern Status GdipRecordMetafileFileNameI ([MarshalAs (UnmanagedType.LPWStr)] string filename, IntPtr hdc, EmfType type,
1672                         ref Rectangle frameRect, MetafileFrameUnit frameUnit, [MarshalAs (UnmanagedType.LPWStr)] string description, out IntPtr metafile);
1673 #if !TEST
1674                 [DllImport("gdiplus.dll", ExactSpelling=true, CharSet=CharSet.Unicode)]
1675                 internal static extern Status GdipCreateMetafileFromStream([MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(ComIStreamMarshaler))] IStream stream, out IntPtr metafile);
1676                 [DllImport("gdiplus.dll", ExactSpelling=true, CharSet=CharSet.Unicode)]
1677                 internal static extern Status GdipGetMetafileHeaderFromStream([MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(ComIStreamMarshaler))] IStream stream, IntPtr header);
1678
1679                 [DllImport ("gdiplus.dll")]
1680                 internal static extern Status GdipRecordMetafileStream ([MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(ComIStreamMarshaler))] IStream stream, IntPtr hdc, 
1681                         EmfType type, ref RectangleF frameRect, MetafileFrameUnit frameUnit, [MarshalAs (UnmanagedType.LPWStr)] string description, out IntPtr metafile);
1682                 [DllImport ("gdiplus.dll")]
1683                 internal static extern Status GdipRecordMetafileStreamI ([MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(ComIStreamMarshaler))] IStream stream, IntPtr hdc, 
1684                         EmfType type, ref Rectangle frameRect, MetafileFrameUnit frameUnit, [MarshalAs (UnmanagedType.LPWStr)] string description, out IntPtr metafile);
1685 #endif
1686                 //ImageCodecInfo functions
1687                 [DllImport("gdiplus.dll")]
1688                 static internal extern Status GdipGetImageDecodersSize (out int decoderNums, out int arraySize);
1689                 [DllImport("gdiplus.dll")]
1690                 static internal extern Status GdipGetImageDecoders (int decoderNums, int arraySize, IntPtr decoders);
1691                 [DllImport("gdiplus.dll")]
1692                 static internal extern Status GdipGetImageEncodersSize (out int encoderNums, out int arraySize);
1693                 [DllImport("gdiplus.dll")]
1694                 static internal extern Status GdipGetImageEncoders (int encoderNums, int arraySize, IntPtr encoders);
1695
1696                 //
1697                 // These are stuff that is unix-only
1698                 //
1699                 public delegate int StreamGetHeaderDelegate(IntPtr buf, int bufsz);
1700                 public delegate int StreamGetBytesDelegate (IntPtr buf, int bufsz, bool peek);
1701                 public delegate long StreamSeekDelegate (int offset, int whence);
1702                 public delegate int StreamPutBytesDelegate (IntPtr buf, int bufsz);
1703                 public delegate void StreamCloseDelegate ();
1704                 public delegate long StreamSizeDelegate ();
1705
1706                 internal sealed class GdiPlusStreamHelper {
1707                         public Stream stream;
1708                         
1709                         private StreamGetHeaderDelegate sghd = null;
1710                         private StreamGetBytesDelegate sgbd = null;
1711                         private StreamSeekDelegate skd = null;
1712                         private StreamPutBytesDelegate spbd = null;
1713                         private StreamCloseDelegate scd = null;
1714                         private StreamSizeDelegate ssd = null;
1715                         private byte[]  start_buf;
1716                         private int     start_buf_pos;
1717                         private int     start_buf_len;
1718                         private byte[]  managedBuf;
1719                         private const int default_bufsize = 4096;
1720                         
1721                         public GdiPlusStreamHelper (Stream s, bool seekToOrigin) 
1722                         { 
1723                                 managedBuf = new byte [default_bufsize];
1724                                 
1725                                 stream = s;
1726                                 if (stream != null && stream.CanSeek && seekToOrigin) {
1727                                         stream.Seek (0, SeekOrigin.Begin);
1728                                 }
1729                         }
1730
1731                         public int StreamGetHeaderImpl (IntPtr buf, int bufsz)  {
1732                                 int     bytesRead;
1733
1734                                 start_buf = new byte[bufsz];
1735
1736                                 try {
1737                                         bytesRead = stream.Read (start_buf, 0, bufsz);
1738                                 } catch (IOException) {
1739                                         return -1;
1740                                 }
1741
1742                                 if (bytesRead > 0 && buf != IntPtr.Zero) {
1743                                         Marshal.Copy (start_buf, 0, (IntPtr) (buf.ToInt64()), bytesRead);
1744                                 }
1745
1746                                 start_buf_pos = 0;
1747                                 start_buf_len = bytesRead;
1748
1749                                 return bytesRead;
1750                         }
1751
1752                         public StreamGetHeaderDelegate GetHeaderDelegate {
1753                                 get {
1754                                         if (stream != null && stream.CanRead) {
1755                                                 if (sghd == null) {
1756                                                         sghd = new StreamGetHeaderDelegate (StreamGetHeaderImpl);
1757                                                 }
1758                                                 return sghd;
1759                                         }
1760                                         return null;
1761                                 }
1762                         }
1763
1764                         public int StreamGetBytesImpl (IntPtr buf, int bufsz, bool peek) 
1765                         {
1766                                 if (buf == IntPtr.Zero && peek) {
1767                                         return -1;
1768                                 }
1769
1770                                 if (bufsz > managedBuf.Length)
1771                                         managedBuf = new byte[bufsz];
1772                                 int bytesRead = 0;
1773                                 long streamPosition = 0;
1774
1775                                 if (bufsz > 0) {
1776                                         if (stream.CanSeek) {
1777                                                 streamPosition = stream.Position;
1778                                         }
1779                                         if (start_buf_len > 0) {
1780                                                 if (start_buf_len > bufsz) {
1781                                                         Array.Copy(start_buf, start_buf_pos, managedBuf, 0, bufsz);
1782                                                         start_buf_pos += bufsz;
1783                                                         start_buf_len -= bufsz;
1784                                                         bytesRead = bufsz;
1785                                                         bufsz = 0;
1786                                                 } else {
1787                                                         // this is easy
1788                                                         Array.Copy(start_buf, start_buf_pos, managedBuf, 0, start_buf_len);
1789                                                         bufsz -= start_buf_len;
1790                                                         bytesRead = start_buf_len;
1791                                                         start_buf_len = 0;
1792                                                 }
1793                                         }
1794
1795                                         if (bufsz > 0) {
1796                                                 try {
1797                                                         bytesRead += stream.Read (managedBuf, bytesRead, bufsz);
1798                                                 } catch (IOException) {
1799                                                         return -1;
1800                                                 }
1801                                         }
1802                         
1803                                         if (bytesRead > 0 && buf != IntPtr.Zero) {
1804                                                 Marshal.Copy (managedBuf, 0, (IntPtr) (buf.ToInt64()), bytesRead);
1805                                         }
1806
1807                                         if (!stream.CanSeek && (bufsz == 10) && peek) {
1808                                                 // Special 'hack' to support peeking of the type for gdi+ on non-seekable streams
1809                                         }
1810                                 
1811                                         if (peek) {
1812                                                 if (stream.CanSeek) {
1813                                                         // If we are peeking bytes, then go back to original position before peeking
1814                                                         stream.Seek (streamPosition, SeekOrigin.Begin);
1815                                                 } else {
1816                                                         throw new NotSupportedException();
1817                                                 }
1818                                         }
1819                                 }
1820                                 
1821                                 return bytesRead;
1822                         }
1823
1824                         public StreamGetBytesDelegate GetBytesDelegate {
1825                                 get {
1826                                         if (stream != null && stream.CanRead) {
1827                                                 if (sgbd == null) {
1828                                                         sgbd = new StreamGetBytesDelegate (StreamGetBytesImpl);
1829                                                 }
1830                                                 return sgbd;
1831                                         }
1832                                         return null;
1833                                 }
1834                         }
1835
1836                         public long StreamSeekImpl (int offset, int whence) 
1837                         {
1838                                 // Make sure we have a valid 'whence'.
1839                                 if ((whence < 0) || (whence > 2))
1840                                         return -1;
1841
1842                                 // Invalidate the start_buf if we're actually going to call a Seek method.
1843                                 start_buf_pos += start_buf_len;
1844                                 start_buf_len = 0;
1845
1846                                 SeekOrigin origin;
1847
1848                                 // Translate 'whence' into a SeekOrigin enum member.
1849                                 switch (whence)
1850                                 {
1851                                         case 0: origin = SeekOrigin.Begin;   break;
1852                                         case 1: origin = SeekOrigin.Current; break;
1853                                         case 2: origin = SeekOrigin.End;     break;
1854
1855                                         // The following line is redundant but necessary to avoid a
1856                                         // "Use of unassigned local variable" error without actually
1857                                         // initializing 'origin' to a dummy value.
1858                                         default: return -1;
1859                                 }
1860
1861                                 // Do the actual seek operation and return its result.
1862                                 return stream.Seek ((long) offset, origin);
1863                         }
1864
1865                         public StreamSeekDelegate SeekDelegate {
1866                                 get {
1867                                         if (stream != null && stream.CanSeek) {
1868                                                 if (skd == null) {
1869                                                         skd = new StreamSeekDelegate (StreamSeekImpl);
1870                                                 }
1871                                                 return skd;
1872                                         }
1873                                         return null;
1874                                 }
1875                         }
1876
1877                         public int StreamPutBytesImpl (IntPtr buf, int bufsz) 
1878                         {
1879                                 if (bufsz > managedBuf.Length)
1880                                         managedBuf = new byte[bufsz];
1881                                 Marshal.Copy (buf, managedBuf, 0, bufsz);
1882                                 stream.Write (managedBuf, 0, bufsz);
1883                                 return bufsz;
1884                         }
1885
1886                         public StreamPutBytesDelegate PutBytesDelegate {
1887                                 get {
1888                                         if (stream != null && stream.CanWrite) {
1889                                                 if (spbd == null) {
1890                                                         spbd = new StreamPutBytesDelegate (StreamPutBytesImpl);
1891                                                 }
1892                                                 return spbd;
1893                                         }
1894                                         return null;
1895                                 }
1896                         }
1897                         
1898                         public void StreamCloseImpl ()
1899                         {
1900                                 stream.Close ();
1901                         }
1902
1903                         public StreamCloseDelegate CloseDelegate {
1904                                 get {
1905                                         if (stream != null) {
1906                                                 if (scd == null) {
1907                                                         scd = new StreamCloseDelegate (StreamCloseImpl);
1908                                                 }
1909                                                 return scd;
1910                                         }
1911                                         return null;
1912                                 }
1913                         }
1914                         
1915                         public long StreamSizeImpl ()
1916                         {
1917                                 try {
1918                                         return stream.Length;
1919                                 } catch {
1920                                         return -1;
1921                                 }
1922                         }
1923
1924                         public StreamSizeDelegate SizeDelegate {
1925                                 get {
1926                                         if (stream != null) {
1927                                                 if (ssd == null) {
1928                                                         ssd = new StreamSizeDelegate (StreamSizeImpl);
1929                                                 }
1930                                                 return ssd;
1931                                         }
1932                                         return null;
1933                                 }
1934                         }
1935
1936                 }
1937                 
1938                 /* Mac only function calls */
1939                 [DllImport("gdiplus.dll")]
1940                 internal static extern Status GdipCreateFromContext_macosx (IntPtr cgref, int width, int height, out IntPtr graphics);
1941
1942                 /* Linux only function calls*/
1943                 [DllImport("gdiplus.dll")]
1944                 internal static extern Status GdipSetVisibleClip_linux (IntPtr graphics, ref Rectangle rect);
1945                 
1946                 [DllImport("gdiplus.dll")]
1947                 internal static extern Status GdipCreateFromXDrawable_linux (IntPtr drawable, IntPtr display, out IntPtr graphics);
1948                 
1949                 // Stream functions for non-Win32 (libgdiplus specific)
1950                 [DllImport("gdiplus.dll")]
1951                 static internal extern Status GdipLoadImageFromDelegate_linux (StreamGetHeaderDelegate getHeader, 
1952                         StreamGetBytesDelegate getBytes, StreamPutBytesDelegate putBytes, StreamSeekDelegate doSeek, 
1953                         StreamCloseDelegate close, StreamSizeDelegate size, out IntPtr image);
1954
1955                 [DllImport("gdiplus.dll")]
1956                 static internal extern Status GdipSaveImageToDelegate_linux (IntPtr image, StreamGetBytesDelegate getBytes, 
1957                         StreamPutBytesDelegate putBytes, StreamSeekDelegate doSeek, StreamCloseDelegate close, 
1958                         StreamSizeDelegate size, ref Guid encoderClsID, IntPtr encoderParameters);              
1959
1960                 [DllImport("gdiplus.dll")]
1961                 static internal extern Status GdipCreateMetafileFromDelegate_linux (StreamGetHeaderDelegate getHeader, 
1962                         StreamGetBytesDelegate getBytes, StreamPutBytesDelegate putBytes, StreamSeekDelegate doSeek, 
1963                         StreamCloseDelegate close, StreamSizeDelegate size, out IntPtr metafile);
1964
1965                 [DllImport("gdiplus.dll")]
1966                 static internal extern Status GdipGetMetafileHeaderFromDelegate_linux (StreamGetHeaderDelegate getHeader, 
1967                         StreamGetBytesDelegate getBytes, StreamPutBytesDelegate putBytes, StreamSeekDelegate doSeek, 
1968                         StreamCloseDelegate close, StreamSizeDelegate size, IntPtr header);
1969
1970                 [DllImport("gdiplus.dll")]
1971                 static internal extern Status GdipRecordMetafileFromDelegate_linux (StreamGetHeaderDelegate getHeader, 
1972                         StreamGetBytesDelegate getBytes, StreamPutBytesDelegate putBytes, StreamSeekDelegate doSeek, 
1973                         StreamCloseDelegate close, StreamSizeDelegate size, IntPtr hdc, EmfType type, ref RectangleF frameRect, 
1974                         MetafileFrameUnit frameUnit, [MarshalAs (UnmanagedType.LPWStr)] string description, out IntPtr metafile);
1975
1976                 [DllImport("gdiplus.dll")]
1977                 static internal extern Status GdipRecordMetafileFromDelegateI_linux (StreamGetHeaderDelegate getHeader, 
1978                         StreamGetBytesDelegate getBytes, StreamPutBytesDelegate putBytes, StreamSeekDelegate doSeek, 
1979                         StreamCloseDelegate close, StreamSizeDelegate size, IntPtr hdc, EmfType type, ref Rectangle frameRect, 
1980                         MetafileFrameUnit frameUnit, [MarshalAs (UnmanagedType.LPWStr)] string description, out IntPtr metafile);
1981
1982                 [DllImport ("libc")]
1983                 static extern int uname (IntPtr buf);
1984 #endregion
1985         }
1986 }