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