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