(DISTFILES): Comment out a few missing files.
[mono-project.git] / mcs / class / System.Drawing / System.Drawing / gdipFunctions.cs
blobb2f2c0576020682e32107d621c73f1c428c58589
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 //
10 // Copyright (C) 2004 Novell, Inc (http://www.novell.com)
12 // Permission is hereby granted, free of charge, to any person obtaining
13 // a copy of this software and associated documentation files (the
14 // "Software"), to deal in the Software without restriction, including
15 // without limitation the rights to use, copy, modify, merge, publish,
16 // distribute, sublicense, and/or sell copies of the Software, and to
17 // permit persons to whom the Software is furnished to do so, subject to
18 // the following conditions:
19 //
20 // The above copyright notice and this permission notice shall be
21 // included in all copies or substantial portions of the Software.
22 //
23 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
24 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
25 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
26 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
27 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
28 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
29 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
32 using System;
33 using System.IO;
34 using System.Runtime.InteropServices;
35 using System.Text;
36 using System.Drawing.Drawing2D;
37 using System.Drawing.Imaging;
38 using System.Drawing.Text;
40 namespace System.Drawing
42 /// <summary>
43 /// GDI+ API Functions
44 /// </summary>
45 internal class GDIPlus
47 public const int FACESIZE = 32;
48 public const int LANG_NEUTRAL = 0;
50 #region gdiplus.dll functions
52 // startup / shutdown
53 [DllImport("gdiplus.dll")]
54 static internal extern Status GdiplusStartup(ref ulong token, ref GdiplusStartupInput input, ref GdiplusStartupOutput output);
55 [DllImport("gdiplus.dll")]
56 static internal extern void GdiplusShutdown(ref ulong token);
58 static ulong GdiPlusToken;
59 static GDIPlus ()
61 GdiplusStartupInput input = GdiplusStartupInput.MakeGdiplusStartupInput();
62 GdiplusStartupOutput output = GdiplusStartupOutput.MakeGdiplusStartupOutput();
63 GdiplusStartup (ref GdiPlusToken, ref input, ref output);
66 // Copies a Ptr to an array of Points and releases the memory
67 static public void FromUnManagedMemoryToPointI(IntPtr prt, Point [] pts)
69 int nPointSize = Marshal.SizeOf(pts[0]);
70 int pos = prt.ToInt32();
71 for (int i=0; i<pts.Length; i++, pos+=nPointSize)
72 pts[i] = (Point) Marshal.PtrToStructure((IntPtr)pos, typeof(Point));
74 Marshal.FreeHGlobal(prt);
77 // Copies a Ptr to an array of Points and releases the memory
78 static public void FromUnManagedMemoryToPoint (IntPtr prt, PointF [] pts)
80 int nPointSize = Marshal.SizeOf(pts[0]);
81 int pos = prt.ToInt32();
82 for (int i=0; i<pts.Length; i++, pos+=nPointSize)
83 pts[i] = (PointF) Marshal.PtrToStructure((IntPtr)pos, typeof(Point));
85 Marshal.FreeHGlobal(prt);
88 // Copies an array of Points to unmanaged memory
89 static public IntPtr FromPointToUnManagedMemoryI(Point [] pts)
91 int nPointSize = Marshal.SizeOf(pts[0]);
92 IntPtr dest = Marshal.AllocHGlobal(nPointSize* pts.Length);
93 int pos = dest.ToInt32();
95 for (int i=0; i<pts.Length; i++, pos+=nPointSize)
96 Marshal.StructureToPtr(pts[i], (IntPtr)pos, false);
98 return dest;
101 // Copies a Ptr to an array of v and releases the memory
102 static public void FromUnManagedMemoryToRectangles (IntPtr prt, RectangleF [] pts)
104 int nPointSize = Marshal.SizeOf (pts[0]);
105 int pos = prt.ToInt32 ();
106 for (int i = 0; i < pts.Length; i++, pos+=nPointSize)
107 pts[i] = (RectangleF) Marshal.PtrToStructure((IntPtr)pos, typeof(RectangleF));
109 Marshal.FreeHGlobal(prt);
112 // Copies an array of Points to unmanaged memory
113 static public IntPtr FromPointToUnManagedMemory(PointF [] pts)
115 int nPointSize = Marshal.SizeOf(pts[0]);
116 IntPtr dest = Marshal.AllocHGlobal(nPointSize* pts.Length);
117 int pos = dest.ToInt32();
119 for (int i=0; i<pts.Length; i++, pos+=nPointSize)
120 Marshal.StructureToPtr(pts[i], (IntPtr)pos, false);
122 return dest;
125 // Converts a status into exception
126 static internal void CheckStatus (Status status)
128 switch (status) {
130 case Status.Ok:
131 return;
133 // TODO: Add more status code mappings here
135 case Status.GenericError:
136 throw new Exception ("Generic Error.");
138 case Status.InvalidParameter:
139 throw new ArgumentException ("Invalid Parameter. A null reference or invalid value was found.");
141 case Status.OutOfMemory:
142 throw new OutOfMemoryException ("Out of memory.");
144 case Status.ObjectBusy:
145 throw new MemberAccessException ("Object busy.");
147 case Status.InsufficientBuffer:
148 throw new IO.InternalBufferOverflowException ("Insufficient buffer.");
150 case Status.PropertyNotSupported:
151 throw new NotSupportedException ("Property not supported.");
153 case Status.FileNotFound:
154 throw new IO.FileNotFoundException ("File not found.");
156 case Status.AccessDenied:
157 throw new UnauthorizedAccessException ("Access denied.");
159 case Status.UnknownImageFormat:
160 throw new NotSupportedException ("Either image format is unknown or you don't have the required libraries for this format.");
162 case Status.NotImplemented:
163 throw new NotImplementedException ("Feature not implemented.");
165 case Status.WrongState:
166 throw new ArgumentException ("Properties not set properly.");
168 default:
169 throw new Exception ("Unknown Error.");
174 // Memory functions
175 [DllImport("gdiplus.dll")]
176 static internal extern IntPtr GdipAlloc (int size);
177 [DllImport("gdiplus.dll")]
178 static internal extern void GdipFree (IntPtr ptr);
181 // Brush functions
182 [DllImport("gdiplus.dll")]
183 static internal extern Status GdipCloneBrush (IntPtr brush, out IntPtr clonedBrush);
184 [DllImport("gdiplus.dll")]
185 static internal extern Status GdipDeleteBrush (IntPtr brush);
186 [DllImport("gdiplus.dll")]
187 static internal extern Status GdipGetBrushType (IntPtr brush, out BrushType type);
190 // Region functions
191 [DllImport("gdiplus.dll")]
192 static internal extern Status GdipCreateRegion (out IntPtr region);
194 [DllImport("gdiplus.dll")]
195 static internal extern Status GdipDeleteRegion (IntPtr region);
197 [DllImport("gdiplus.dll")]
198 static internal extern Status GdipCloneRegion (IntPtr region, out IntPtr cloned);
200 [DllImport("gdiplus.dll")]
201 static internal extern Status GdipCreateRegionRect (ref RectangleF rect, out IntPtr region);
203 [DllImport("gdiplus.dll")]
204 static internal extern Status GdipCreateRegionRectI (ref Rectangle rect, out IntPtr region);
206 [DllImport("gdiplus.dll")]
207 static internal extern Status GdipCreateRegionPath (IntPtr path, out IntPtr region);
209 [DllImport("gdiplus.dll")]
210 static internal extern Status GdipTranslateRegion (IntPtr region, float dx, float dy);
212 [DllImport("gdiplus.dll")]
213 static internal extern Status GdipTranslateRegionI (IntPtr region, int dx, int dy);
215 [DllImport("gdiplus.dll")]
216 static internal extern Status GdipIsVisibleRegionPoint (IntPtr region, float x, float y,
217 IntPtr graphics, out bool result);
219 [DllImport("gdiplus.dll")]
220 static internal extern Status GdipIsVisibleRegionPointI (IntPtr region, int x, int y,
221 IntPtr graphics, out bool result);
223 [DllImport("gdiplus.dll")]
224 static internal extern Status GdipIsVisibleRegionRect (IntPtr region, float x, float y, float width,
225 float height, IntPtr graphics, out bool result);
227 [DllImport("gdiplus.dll")]
228 static internal extern Status GdipIsVisibleRegionRectI (IntPtr region, int x, int y, int width,
229 int height, IntPtr graphics, out bool result);
232 [DllImport("gdiplus.dll")]
233 static internal extern Status GdipCombineRegionRect (IntPtr region, ref RectangleF rect,
234 CombineMode combineMode);
236 [DllImport("gdiplus.dll")]
237 static internal extern Status GdipCombineRegionRectI (IntPtr region, ref Rectangle rect,
238 CombineMode combineMode);
240 [DllImport("gdiplus.dll")]
241 static internal extern Status GdipCombineRegionPath (IntPtr region, IntPtr path, CombineMode combineMode);
243 [DllImport("gdiplus.dll")]
244 static internal extern Status GdipGetRegionBounds (IntPtr region, IntPtr graphics, ref RectangleF rect);
246 [DllImport("gdiplus.dll")]
247 static internal extern Status GdipSetInfinite (IntPtr region);
249 [DllImport("gdiplus.dll")]
250 static internal extern Status GdipSetEmpty (IntPtr region);
252 [DllImport("gdiplus.dll")]
253 static internal extern Status GdipIsEmptyRegion (IntPtr region, IntPtr graphics, out bool result);
255 [DllImport("gdiplus.dll")]
256 static internal extern Status GdipIsInfiniteRegion (IntPtr region, IntPtr graphics, out bool result);
258 [DllImport("gdiplus.dll")]
259 static internal extern Status GdipCombineRegionRegion (IntPtr region, IntPtr region2,
260 CombineMode combineMode);
262 [DllImport("gdiplus.dll")]
263 static internal extern Status GdipIsEqualRegion (IntPtr region, IntPtr region2,
264 IntPtr graphics, out bool result);
266 [DllImport("gdiplus.dll")]
267 static internal extern Status GdipGetRegionDataSize (IntPtr region, out int bufferSize);
269 [DllImport("gdiplus.dll")]
270 static internal extern Status GdipGetRegionData (IntPtr region, byte[] buffer, int bufferSize,
271 out int sizeFilled);
273 [DllImport("gdiplus.dll")]
274 static internal extern Status GdipGetRegionScansCount (IntPtr region, out int count, IntPtr matrix);
276 [DllImport("gdiplus.dll")]
277 static internal extern Status GdipGetRegionScans (IntPtr region, IntPtr rects, out int count,
278 IntPtr matrix);
280 [DllImport("gdiplus.dll")]
281 static internal extern Status GdipTransformRegion(IntPtr region, IntPtr matrix);
283 [DllImport("gdiplus.dll")]
284 static internal extern Status GdipFillRegion(IntPtr graphics, IntPtr brush, IntPtr region);
286 // Solid brush functions
287 [DllImport("gdiplus.dll")]
288 static internal extern Status GdipCreateSolidFill (int color, out IntPtr brush);
289 [DllImport("gdiplus.dll")]
290 static internal extern Status GdipGetSolidFillColor (IntPtr brush, out int color);
291 [DllImport("gdiplus.dll")]
292 static internal extern Status GdipSetSolidFillColor (IntPtr brush, int color);
294 // Hatch Brush functions
295 [DllImport("gdiplus.dll")]
296 static internal extern Status GdipCreateHatchBrush (HatchStyle hatchstyle, int foreColor, int backColor, out IntPtr brush);
297 [DllImport("gdiplus.dll")]
298 static internal extern Status GdipGetHatchStyle (IntPtr brush, out HatchStyle hatchstyle);
299 [DllImport("gdiplus.dll")]
300 static internal extern Status GdipGetHatchForegroundColor (IntPtr brush, out int foreColor);
301 [DllImport("gdiplus.dll")]
302 static internal extern Status GdipGetHatchBackgroundColor (IntPtr brush, out int backColor);
304 // Texture brush functions
305 [DllImport("gdiplus.dll")]
306 static internal extern Status GdipGetTextureImage (IntPtr texture, out IntPtr image);
307 [DllImport("gdiplus.dll")]
308 static internal extern Status GdipCreateTexture (IntPtr image, WrapMode wrapMode, out IntPtr texture);
309 [DllImport("gdiplus.dll")]
310 static internal extern Status GdipCreateTextureIAI (IntPtr image, IntPtr imageAttributes, int x, int y, int width, int height, out IntPtr texture);
311 [DllImport("gdiplus.dll")]
312 static internal extern Status GdipCreateTextureIA (IntPtr image, IntPtr imageAttributes, float x, float y, float width, float height, out IntPtr texture);
313 [DllImport("gdiplus.dll")]
314 static internal extern Status GdipCreateTexture2I (IntPtr image, WrapMode wrapMode, int x, int y, int width, int height, out IntPtr texture);
315 [DllImport("gdiplus.dll")]
316 static internal extern Status GdipCreateTexture2 (IntPtr image, WrapMode wrapMode, float x, float y, float width, float height, out IntPtr texture);
317 [DllImport("gdiplus.dll")]
318 static internal extern Status GdipGetTextureTransform (IntPtr texture, IntPtr matrix);
319 [DllImport("gdiplus.dll")]
320 static internal extern Status GdipSetTextureTransform (IntPtr texture, IntPtr matrix);
321 [DllImport("gdiplus.dll")]
322 static internal extern Status GdipGetTextureWrapMode (IntPtr texture, out WrapMode wrapMode);
323 [DllImport("gdiplus.dll")]
324 static internal extern Status GdipSetTextureWrapMode (IntPtr texture, WrapMode wrapMode);
325 [DllImport("gdiplus.dll")]
326 static internal extern Status GdipMultiplyTextureTransform (IntPtr texture, IntPtr matrix, MatrixOrder order);
327 [DllImport("gdiplus.dll")]
328 static internal extern Status GdipResetTextureTransform (IntPtr texture);
329 [DllImport("gdiplus.dll")]
330 static internal extern Status GdipRotateTextureTransform (IntPtr texture, float angle, MatrixOrder order);
331 [DllImport("gdiplus.dll")]
332 static internal extern Status GdipScaleTextureTransform (IntPtr texture, float sx, float sy, MatrixOrder order);
333 [DllImport("gdiplus.dll")]
334 static internal extern Status GdipTranslateTextureTransform (IntPtr texture, float dx, float dy, MatrixOrder order);
336 // PathGradientBrush functions
337 [DllImport("gdiplus.dll")]
338 static internal extern Status GdipCreatePathGradientFromPath (IntPtr path, out IntPtr brush);
339 [DllImport("gdiplus.dll")]
340 static internal extern Status GdipCreatePathGradientI (Point [] points, int count, WrapMode wrapMode, out IntPtr brush);
341 [DllImport("gdiplus.dll")]
342 static internal extern Status GdipCreatePathGradient (PointF [] points, int count, WrapMode wrapMode, out IntPtr brush);
343 [DllImport("gdiplus.dll")]
344 static internal extern Status GdipGetPathGradientBlendCount (IntPtr brush, out int count);
345 [DllImport("gdiplus.dll")]
346 static internal extern Status GdipGetPathGradientBlend (IntPtr brush, float [] blend, float [] positions, int count);
347 [DllImport("gdiplus.dll")]
348 static internal extern Status GdipSetPathGradientBlend (IntPtr brush, float [] blend, float [] positions, int count);
349 [DllImport("gdiplus.dll")]
350 static internal extern Status GdipGetPathGradientCenterColor (IntPtr brush, out int color);
351 [DllImport("gdiplus.dll")]
352 static internal extern Status GdipSetPathGradientCenterColor (IntPtr brush, int color);
353 [DllImport("gdiplus.dll")]
354 static internal extern Status GdipGetPathGradientCenterPoint (IntPtr brush, out PointF point);
355 [DllImport("gdiplus.dll")]
356 static internal extern Status GdipSetPathGradientCenterPoint (IntPtr brush, ref PointF point);
357 [DllImport("gdiplus.dll")]
358 static internal extern Status GdipGetPathGradientFocusScales (IntPtr brush, out float xScale, out float yScale);
359 [DllImport("gdiplus.dll")]
360 static internal extern Status GdipSetPathGradientFocusScales (IntPtr brush, float xScale, float yScale);
361 [DllImport("gdiplus.dll")]
362 static internal extern Status GdipGetPathGradientPresetBlendCount (IntPtr brush, out int count);
363 [DllImport("gdiplus.dll")]
364 static internal extern Status GdipGetPathGradientPresetBlend (IntPtr brush, int [] blend, float [] positions, int count);
365 [DllImport("gdiplus.dll")]
366 static internal extern Status GdipSetPathGradientPresetBlend (IntPtr brush, int [] blend, float [] positions, int count);
367 [DllImport("gdiplus.dll")]
368 static internal extern Status GdipGetPathGradientRect (IntPtr brush, out RectangleF rect);
369 [DllImport("gdiplus.dll")]
370 static internal extern Status GdipGetPathGradientSurroundColorCount (IntPtr brush, out int count);
371 [DllImport("gdiplus.dll")]
372 static internal extern Status GdipGetPathGradientSurroundColorsWithCount (IntPtr brush, int [] color, ref int count);
373 [DllImport("gdiplus.dll")]
374 static internal extern Status GdipSetPathGradientSurroundColorsWithCount (IntPtr brush, int [] color, ref int count);
375 [DllImport("gdiplus.dll")]
376 static internal extern Status GdipGetPathGradientTransform (IntPtr brush, IntPtr matrix);
377 [DllImport("gdiplus.dll")]
378 static internal extern Status GdipSetPathGradientTransform (IntPtr brush, IntPtr matrix);
379 [DllImport("gdiplus.dll")]
380 static internal extern Status GdipGetPathGradientWrapMode (IntPtr brush, out WrapMode wrapMode);
381 [DllImport("gdiplus.dll")]
382 static internal extern Status GdipSetPathGradientWrapMode (IntPtr brush, WrapMode wrapMode);
383 [DllImport("gdiplus.dll")]
384 static internal extern Status GdipSetPathGradientLinearBlend (IntPtr brush, float focus, float scale);
385 [DllImport("gdiplus.dll")]
386 static internal extern Status GdipSetPathGradientSigmaBlend (IntPtr brush, float focus, float scale);
387 [DllImport("gdiplus.dll")]
388 static internal extern Status GdipMultiplyPathGradientTransform (IntPtr texture, IntPtr matrix, MatrixOrder order);
389 [DllImport("gdiplus.dll")]
390 static internal extern Status GdipResetPathGradientTransform (IntPtr brush);
391 [DllImport("gdiplus.dll")]
392 static internal extern Status GdipRotatePathGradientTransform (IntPtr brush, float angle, MatrixOrder order);
393 [DllImport("gdiplus.dll")]
394 static internal extern Status GdipScalePathGradientTransform (IntPtr brush, float sx, float sy, MatrixOrder order);
395 [DllImport("gdiplus.dll")]
396 static internal extern Status GdipTranslatePathGradientTransform (IntPtr brush, float dx, float dy, MatrixOrder order);
398 // LinearGradientBrush functions
399 [DllImport("gdiplus.dll")]
400 static internal extern Status GdipCreateLineBrushI (ref Point point1, ref Point point2, int color1, int color2, WrapMode wrapMode, out IntPtr brush);
401 [DllImport("gdiplus.dll")]
402 static internal extern Status GdipCreateLineBrush (ref PointF point1, ref PointF point2, int color1, int color2, WrapMode wrapMode, out IntPtr brush);
403 [DllImport("gdiplus.dll")]
404 static internal extern Status GdipCreateLineBrushFromRectI (ref Rectangle rect, int color1, int color2, LinearGradientMode linearGradientMode, WrapMode wrapMode, out IntPtr brush);
405 [DllImport("gdiplus.dll")]
406 static internal extern Status GdipCreateLineBrushFromRect (ref RectangleF rect, int color1, int color2, LinearGradientMode linearGradientMode, WrapMode wrapMode, out IntPtr brush);
407 [DllImport("gdiplus.dll")]
408 static internal extern Status GdipCreateLineBrushFromRectWithAngleI (ref Rectangle rect, int color1, int color2, float angle, bool isAngleScaleable, WrapMode wrapMode, out IntPtr brush);
409 [DllImport("gdiplus.dll")]
410 static internal extern Status GdipCreateLineBrushFromRectWithAngle (ref RectangleF rect, int color1, int color2, float angle, bool isAngleScaleable, WrapMode wrapMode, out IntPtr brush);
411 [DllImport("gdiplus.dll")]
412 static internal extern Status GdipGetLineBlendCount (IntPtr brush, out int count);
413 [DllImport("gdiplus.dll")]
414 static internal extern Status GdipSetLineBlend (IntPtr brush, float [] blend, float [] positions, int count);
415 [DllImport("gdiplus.dll")]
416 static internal extern Status GdipGetLineBlend (IntPtr brush, float [] blend, float [] positions, int count);
417 [DllImport("gdiplus.dll")]
418 static internal extern Status GdipSetLineGammaCorrection (IntPtr brush, bool useGammaCorrection);
419 [DllImport("gdiplus.dll")]
420 static internal extern Status GdipGetLineGammaCorrection (IntPtr brush, out bool useGammaCorrection);
421 [DllImport("gdiplus.dll")]
422 static internal extern Status GdipGetLinePresetBlendCount (IntPtr brush, out int count);
423 [DllImport("gdiplus.dll")]
424 static internal extern Status GdipSetLinePresetBlend (IntPtr brush, int [] blend, float [] positions, int count);
425 [DllImport("gdiplus.dll")]
426 static internal extern Status GdipGetLinePresetBlend (IntPtr brush, int [] blend, float [] positions, int count);
427 [DllImport("gdiplus.dll")]
428 static internal extern Status GdipSetLineColors (IntPtr brush, int color1, int color2);
429 [DllImport("gdiplus.dll")]
430 static internal extern Status GdipGetLineColors (IntPtr brush, int [] colors);
431 [DllImport("gdiplus.dll")]
432 static internal extern Status GdipGetLineRectI (IntPtr brush, out Rectangle rect);
433 [DllImport("gdiplus.dll")]
434 static internal extern Status GdipGetLineRect (IntPtr brush, out RectangleF rect);
435 [DllImport("gdiplus.dll")]
436 static internal extern Status GdipSetLineTransform (IntPtr brush, IntPtr matrix);
437 [DllImport("gdiplus.dll")]
438 static internal extern Status GdipGetLineTransform (IntPtr brush, IntPtr matrix);
439 [DllImport("gdiplus.dll")]
440 static internal extern Status GdipSetLineWrapMode (IntPtr brush, WrapMode wrapMode);
441 [DllImport("gdiplus.dll")]
442 static internal extern Status GdipGetLineWrapMode (IntPtr brush, out WrapMode wrapMode);
443 [DllImport("gdiplus.dll")]
444 static internal extern Status GdipSetLineLinearBlend (IntPtr brush, float focus, float scale);
445 [DllImport("gdiplus.dll")]
446 static internal extern Status GdipSetLineSigmaBlend (IntPtr brush, float focus, float scale);
447 [DllImport("gdiplus.dll")]
448 static internal extern Status GdipMultiplyLineTransform (IntPtr brush, IntPtr matrix, MatrixOrder order);
449 [DllImport("gdiplus.dll")]
450 static internal extern Status GdipResetLineTransform (IntPtr brush);
451 [DllImport("gdiplus.dll")]
452 static internal extern Status GdipRotateLineTransform (IntPtr brush, float angle, MatrixOrder order);
453 [DllImport("gdiplus.dll")]
454 static internal extern Status GdipScaleLineTransform (IntPtr brush, float sx, float sy, MatrixOrder order);
455 [DllImport("gdiplus.dll")]
456 static internal extern Status GdipTranslateLineTransform (IntPtr brush, float dx, float dy, MatrixOrder order);
458 // Graphics functions
459 [DllImport("gdiplus.dll")]
460 static internal extern Status GdipCreateFromHDC(IntPtr hDC, out IntPtr graphics);
461 [DllImport("gdiplus.dll")]
462 static internal extern Status GdipDeleteGraphics(IntPtr graphics);
463 [DllImport("gdiplus.dll")]
464 static internal extern Status GdipRestoreGraphics(IntPtr graphics, uint graphicsState);
465 [DllImport("gdiplus.dll")]
466 static internal extern Status GdipSaveGraphics(IntPtr graphics, out uint state);
467 [DllImport("gdiplus.dll")]
468 static internal extern Status GdipMultiplyWorldTransform (IntPtr graphics, IntPtr matrix, MatrixOrder order);
470 [DllImport("gdiplus.dll")]
471 static internal extern Status GdipRotateWorldTransform(IntPtr graphics, float angle, MatrixOrder order);
472 [DllImport("gdiplus.dll")]
473 static internal extern Status GdipTranslateWorldTransform(IntPtr graphics, float dx, float dy, MatrixOrder order);
474 [DllImport("gdiplus.dll")]
475 static internal extern Status GdipDrawArc (IntPtr graphics, IntPtr pen, float x, float y, float width, float height, float startAngle, float sweepAngle);
476 [DllImport("gdiplus.dll")]
477 static internal extern Status GdipDrawArcI (IntPtr graphics, IntPtr pen, int x, int y, int width, int height, float startAngle, float sweepAngle);
478 [DllImport("gdiplus.dll")]
479 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);
480 [DllImport("gdiplus.dll")]
481 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);
482 [DllImport("gdiplus.dll")]
483 static internal extern Status GdipDrawEllipseI (IntPtr graphics, IntPtr pen, int x, int y, int width, int height);
484 [DllImport("gdiplus.dll")]
485 static internal extern Status GdipDrawEllipse (IntPtr graphics, IntPtr pen, float x, float y, float width, float height);
486 [DllImport("gdiplus.dll")]
487 static internal extern Status GdipDrawLine (IntPtr graphics, IntPtr pen, float x1, float y1, float x2, float y2);
488 [DllImport("gdiplus.dll")]
489 static internal extern Status GdipDrawLineI (IntPtr graphics, IntPtr pen, int x1, int y1, int x2, int y2);
490 [DllImport ("gdiplus.dll")]
491 static internal extern Status GdipDrawLines (IntPtr graphics, IntPtr pen, PointF [] points, int count);
492 [DllImport ("gdiplus.dll")]
493 static internal extern Status GdipDrawLinesI (IntPtr graphics, IntPtr pen, Point [] points, int count);
494 [DllImport ("gdiplus.dll")]
495 static internal extern Status GdipDrawPath (IntPtr graphics, IntPtr pen, IntPtr path);
496 [DllImport ("gdiplus.dll")]
497 static internal extern Status GdipDrawPie (IntPtr graphics, IntPtr pen, float x, float y, float width, float height, float startAngle, float sweepAngle);
498 [DllImport ("gdiplus.dll")]
499 static internal extern Status GdipDrawPieI (IntPtr graphics, IntPtr pen, int x, int y, int width, int height, float startAngle, float sweepAngle);
500 [DllImport ("gdiplus.dll")]
501 static internal extern Status GdipDrawPolygon (IntPtr graphics, IntPtr pen, PointF [] points, int count);
502 [DllImport ("gdiplus.dll")]
503 static internal extern Status GdipDrawPolygonI (IntPtr graphics, IntPtr pen, Point [] points, int count);
504 [DllImport ("gdiplus.dll")]
505 static internal extern Status GdipDrawRectangle (IntPtr graphics, IntPtr pen, float x, float y, float width, float height);
506 [DllImport ("gdiplus.dll")]
507 static internal extern Status GdipDrawRectangleI (IntPtr graphics, IntPtr pen, int x, int y, int width, int height);
508 [DllImport ("gdiplus.dll")]
509 static internal extern Status GdipDrawRectangles (IntPtr graphics, IntPtr pen, RectangleF [] rects, int count);
510 [DllImport ("gdiplus.dll")]
511 static internal extern Status GdipDrawRectanglesI (IntPtr graphics, IntPtr pen, Rectangle [] rects, int count);
512 [DllImport("gdiplus.dll")]
513 static internal extern Status GdipFillEllipseI (IntPtr graphics, IntPtr pen, int x, int y, int width, int height);
514 [DllImport("gdiplus.dll")]
515 static internal extern Status GdipFillEllipse (IntPtr graphics, IntPtr pen, float x, float y, float width, float height);
516 [DllImport ("gdiplus.dll")]
517 static internal extern Status GdipFillPolygon (IntPtr graphics, IntPtr brush, PointF [] points, int count, FillMode fillMode);
518 [DllImport ("gdiplus.dll")]
519 static internal extern Status GdipFillPolygonI (IntPtr graphics, IntPtr brush, Point [] points, int count, FillMode fillMode);
520 [DllImport ("gdiplus.dll")]
521 static internal extern Status GdipFillPolygon2 (IntPtr graphics, IntPtr brush, PointF [] points, int count);
522 [DllImport ("gdiplus.dll")]
523 static internal extern Status GdipFillPolygon2I (IntPtr graphics, IntPtr brush, Point [] points, int count);
524 [DllImport("gdiplus.dll")]
525 static internal extern Status GdipFillRectangle (IntPtr graphics, IntPtr brush, float x1, float y1, float x2, float y2);
526 [DllImport("gdiplus.dll")]
527 static internal extern Status GdipFillRectangleI (IntPtr graphics, IntPtr brush, int x1, int y1, int x2, int y2);
528 [DllImport("gdiplus.dll")]
529 static internal extern Status GdipFillRectangles (IntPtr graphics, IntPtr brush, RectangleF [] rects, int count);
530 [DllImport("gdiplus.dll")]
531 static internal extern Status GdipFillRectanglesI (IntPtr graphics, IntPtr brush, Rectangle [] rects, int count);
532 [DllImport("gdiplus.dll", CharSet=CharSet.Unicode)]
533 static internal extern Status GdipDrawString (IntPtr graphics, string text, int len, IntPtr font, ref RectangleF rc, IntPtr format, IntPtr brush);
534 [DllImport("gdiplus.dll")]
535 static internal extern Status GdipGetDC (IntPtr graphics, out int hdc);
536 [DllImport("gdiplus.dll")]
537 static internal extern Status GdipReleaseDC (IntPtr graphics, IntPtr hdc);
538 [DllImport("gdiplus.dll")]
539 static internal extern Status GdipDrawImageRectI (IntPtr graphics, IntPtr image, int x, int y, int width, int height);
540 [DllImport ("gdiplus.dll")]
541 static internal extern Status GdipGetRenderingOrigin (IntPtr graphics, out int x, out int y);
542 [DllImport ("gdiplus.dll")]
543 static internal extern Status GdipSetRenderingOrigin (IntPtr graphics, int x, int y);
544 [DllImport("gdiplus.dll")]
545 internal static extern Status GdipCloneBitmapArea (float x, float y, float width, float height, PixelFormat format, IntPtr original, out IntPtr bitmap);
546 [DllImport("gdiplus.dll")]
547 internal static extern Status GdipCloneBitmapAreaI (int x, int y, int width, int height, PixelFormat format, IntPtr original, out IntPtr bitmap);
548 [DllImport("gdiplus.dll")]
549 internal static extern Status GdipResetWorldTransform (IntPtr graphics);
550 [DllImport("gdiplus.dll")]
551 internal static extern Status GdipSetWorldTransform (IntPtr graphics, IntPtr matrix);
552 [DllImport("gdiplus.dll")]
553 internal static extern Status GdipGetWorldTransform (IntPtr graphics, IntPtr matrix);
554 [DllImport("gdiplus.dll")]
555 internal static extern Status GdipScaleWorldTransform (IntPtr graphics, float sx, float sy, MatrixOrder order);
556 [DllImport("gdiplus.dll")]
557 internal static extern Status GdipGraphicsClear(IntPtr graphics, int argb);
558 [DllImport("gdiplus.dll")]
559 internal static extern Status GdipDrawClosedCurve(IntPtr graphics, IntPtr pen, PointF [] points, int count);
560 [DllImport("gdiplus.dll")]
561 internal static extern Status GdipDrawClosedCurveI(IntPtr graphics, IntPtr pen, Point [] points, int count);
562 [DllImport("gdiplus.dll")]
563 internal static extern Status GdipDrawClosedCurve2(IntPtr graphics, IntPtr pen, PointF [] points, int count, float tension);
564 [DllImport("gdiplus.dll")]
565 internal static extern Status GdipDrawClosedCurve2I(IntPtr graphics, IntPtr pen, Point [] points, int count, float tension);
566 [DllImport("gdiplus.dll")]
567 internal static extern Status GdipDrawCurve(IntPtr graphics, IntPtr pen, PointF [] points, int count);
568 [DllImport("gdiplus.dll")]
569 internal static extern Status GdipDrawCurveI(IntPtr graphics, IntPtr pen, Point [] points, int count);
570 [DllImport("gdiplus.dll")]
571 internal static extern Status GdipDrawCurve2(IntPtr graphics, IntPtr pen, PointF [] points, int count, float tension);
572 [DllImport("gdiplus.dll")]
573 internal static extern Status GdipDrawCurve2I(IntPtr graphics, IntPtr pen, Point [] points, int count, float tension);
574 [DllImport("gdiplus.dll")]
575 internal static extern Status GdipDrawCurve3(IntPtr graphics, IntPtr pen, PointF [] points, int count, int offset, int numberOfSegments, float tension);
576 [DllImport("gdiplus.dll")]
577 internal static extern Status GdipDrawCurve3I(IntPtr graphics, IntPtr pen, Point [] points, int count, int offset, int numberOfSegments, float tension);
578 [DllImport("gdiplus.dll")]
579 internal static extern Status GdipSetClipRect(IntPtr graphics, float x, float y, float width, float height, CombineMode combineMode);
580 [DllImport("gdiplus.dll")]
581 internal static extern Status GdipSetClipRectI(IntPtr graphics, int x, int y, int width, int height, CombineMode combineMode);
582 [DllImport("gdiplus.dll")]
583 internal static extern Status GdipSetClipPath(IntPtr graphics, IntPtr path, CombineMode combineMode);
584 [DllImport("gdiplus.dll")]
585 internal static extern Status GdipSetClipRegion(IntPtr graphics, IntPtr region, CombineMode combineMode);
586 [DllImport("gdiplus.dll")]
587 internal static extern Status GdipSetClipGraphics(IntPtr graphics, IntPtr srcgraphics, CombineMode combineMode);
588 [DllImport("gdiplus.dll")]
589 internal static extern Status GdipResetClip(IntPtr graphics);
590 [DllImport("gdiplus.dll")]
591 internal static extern Status GdipEndContainer(IntPtr graphics, int state);
592 [DllImport("gdiplus.dll")]
593 internal static extern Status GdipGetClip (IntPtr graphics, IntPtr region);
595 [DllImport("gdiplus.dll")]
596 internal static extern Status GdipFillClosedCurve(IntPtr graphics, IntPtr brush, PointF [] points, int count);
598 [DllImport("gdiplus.dll")]
599 internal static extern Status GdipFillClosedCurveI(IntPtr graphics, IntPtr brush, Point [] points, int count);
601 [DllImport("gdiplus.dll")]
602 internal static extern Status GdipFillClosedCurve2(IntPtr graphics, IntPtr brush,
603 PointF [] points, int count, float tension, FillMode fillMode);
605 [DllImport("gdiplus.dll")]
606 internal static extern Status GdipFillClosedCurve2I(IntPtr graphics, IntPtr brush,
607 Point [] points, int count, float tension, FillMode fillMode);
609 [DllImport("gdiplus.dll")]
610 internal static extern Status GdipFillPie(IntPtr graphics, IntPtr brush, float x, float y,
611 float width, float height, float startAngle, float sweepAngle);
613 [DllImport("gdiplus.dll")]
614 internal static extern Status GdipFillPieI(IntPtr graphics, IntPtr brush, int x, int y,
615 int width, int height, float startAngle, float sweepAngle);
617 [DllImport("gdiplus.dll")]
618 internal static extern Status GdipFillPath(IntPtr graphics, IntPtr brush, IntPtr path);
620 [DllImport("gdiplus.dll")]
621 internal static extern Status GdipGetNearestColor(IntPtr graphics, out int argb);
623 [DllImport("gdiplus.dll")]
624 internal static extern Status GdipIsVisiblePoint(IntPtr graphics, float x, float y, out bool result);
626 [DllImport("gdiplus.dll")]
627 internal static extern Status GdipIsVisiblePointI(IntPtr graphics, int x, int y, out bool result);
629 [DllImport("gdiplus.dll")]
630 internal static extern Status GdipIsVisibleRect(IntPtr graphics, float x, float y,
631 float width, float height, out bool result);
633 [DllImport("gdiplus.dll")]
634 internal static extern Status GdipIsVisibleRectI(IntPtr graphics, int x, int y,
635 int width, int height, out bool result);
637 [DllImport("gdiplus.dll")]
638 internal static extern Status GdipTransformPoints(IntPtr graphics, CoordinateSpace destSpace,
639 CoordinateSpace srcSpace, IntPtr points, int count);
641 [DllImport("gdiplus.dll")]
642 internal static extern Status GdipTransformPointsI(IntPtr graphics, CoordinateSpace destSpace,
643 CoordinateSpace srcSpace, IntPtr points, int count);
645 [DllImport("gdiplus.dll")]
646 internal static extern Status GdipTranslateClip(IntPtr graphics, float dx, float dy);
647 [DllImport("gdiplus.dll")]
648 internal static extern Status GdipTranslateClipI(IntPtr graphics, int dx, int dy);
649 [DllImport("gdiplus.dll")]
650 internal static extern Status GdipGetClipBounds(IntPtr graphics, out RectangleF rect);
651 [DllImport("gdiplus.dll")]
652 internal static extern Status GdipSetCompositingMode(IntPtr graphics, CompositingMode compositingMode);
653 [DllImport("gdiplus.dll")]
654 internal static extern Status GdipGetCompositingMode(IntPtr graphics, out CompositingMode compositingMode);
655 [DllImport("gdiplus.dll")]
656 internal static extern Status GdipSetCompositingQuality(IntPtr graphics, CompositingQuality compositingQuality);
657 [DllImport("gdiplus.dll")]
658 internal static extern Status GdipGetCompositingQuality(IntPtr graphics, out CompositingQuality compositingQuality);
659 [DllImport("gdiplus.dll")]
660 internal static extern Status GdipSetInterpolationMode(IntPtr graphics, InterpolationMode interpolationMode);
661 [DllImport("gdiplus.dll")]
662 internal static extern Status GdipGetInterpolationMode(IntPtr graphics, out InterpolationMode interpolationMode);
663 [DllImport("gdiplus.dll")]
664 internal static extern Status GdipGetDpiX(IntPtr graphics, out float dpi);
665 [DllImport("gdiplus.dll")]
666 internal static extern Status GdipGetDpiY(IntPtr graphics, out float dpi);
667 [DllImport("gdiplus.dll")]
668 internal static extern Status GdipIsClipEmpty(IntPtr graphics, out bool result);
669 [DllImport("gdiplus.dll")]
670 internal static extern Status GdipIsVisibleClipEmpty(IntPtr graphics, out bool result);
671 [DllImport("gdiplus.dll")]
672 internal static extern Status GdipGetPageUnit(IntPtr graphics, out GraphicsUnit unit);
673 [DllImport("gdiplus.dll")]
674 internal static extern Status GdipGetPageScale(IntPtr graphics, out float scale);
675 [DllImport("gdiplus.dll")]
676 internal static extern Status GdipSetPageUnit(IntPtr graphics, GraphicsUnit unit);
677 [DllImport("gdiplus.dll")]
678 internal static extern Status GdipSetPageScale(IntPtr graphics, float scale);
679 [DllImport("gdiplus.dll")]
680 internal static extern Status GdipSetPixelOffsetMode(IntPtr graphics, PixelOffsetMode pixelOffsetMode);
681 [DllImport("gdiplus.dll")]
682 internal static extern Status GdipGetPixelOffsetMode(IntPtr graphics, out PixelOffsetMode pixelOffsetMode);
683 [DllImport("gdiplus.dll")]
684 internal static extern Status GdipSetSmoothingMode(IntPtr graphics, SmoothingMode smoothingMode);
685 [DllImport("gdiplus.dll")]
686 internal static extern Status GdipGetSmoothingMode(IntPtr graphics, out SmoothingMode smoothingMode);
687 [DllImport("gdiplus.dll")]
688 internal static extern Status GdipSetTextContrast(IntPtr graphics, int contrast);
689 [DllImport("gdiplus.dll")]
690 internal static extern Status GdipGetTextContrast(IntPtr graphics, out int contrast);
691 [DllImport("gdiplus.dll")]
692 internal static extern Status GdipSetTextRenderingHint(IntPtr graphics, TextRenderingHint mode);
693 [DllImport("gdiplus.dll")]
694 internal static extern Status GdipGetTextRenderingHint(IntPtr graphics, out TextRenderingHint mode);
695 [DllImport("gdiplus.dll")]
696 internal static extern Status GdipGetVisibleClipBounds(IntPtr graphics, out RectangleF rect);
698 [DllImport("gdiplus.dll")]
699 internal static extern Status GdipFlush(IntPtr graphics, FlushIntention intention);
702 // Pen functions
703 [DllImport("gdiplus.dll")]
704 internal static extern Status GdipCreatePen1 (int argb, float width, Unit unit, out IntPtr pen);
705 [DllImport("gdiplus.dll")]
706 internal static extern Status GdipCreatePen2 (IntPtr brush, float width, Unit unit, out IntPtr pen);
707 [DllImport("gdiplus.dll")]
708 internal static extern Status GdipClonePen (IntPtr pen, out IntPtr clonepen);
709 [DllImport("gdiplus.dll")]
710 internal static extern Status GdipDeletePen(IntPtr pen);
711 [DllImport("gdiplus.dll")]
712 internal static extern Status GdipSetPenBrushFill (IntPtr pen, IntPtr brush);
713 [DllImport("gdiplus.dll")]
714 internal static extern Status GdipGetPenBrushFill (IntPtr pen, out IntPtr brush);
715 [DllImport("gdiplus.dll")]
716 internal static extern Status GdipGetPenFillType (IntPtr pen, out PenType type);
717 [DllImport("gdiplus.dll")]
718 internal static extern Status GdipSetPenColor (IntPtr pen, int color);
719 [DllImport("gdiplus.dll")]
720 internal static extern Status GdipGetPenColor (IntPtr pen, out int color);
721 [DllImport("gdiplus.dll")]
722 internal static extern Status GdipSetPenCompoundArray (IntPtr pen, float[] dash, int count);
723 [DllImport("gdiplus.dll")]
724 internal static extern Status GdipGetPenCompoundArray (IntPtr pen, float[] dash, int count);
725 [DllImport("gdiplus.dll")]
726 internal static extern Status GdipGetPenCompoundCount (IntPtr pen, out int count);
727 [DllImport("gdiplus.dll")]
728 internal static extern Status GdipSetPenDashCap197819 (IntPtr pen, DashCap dashCap);
729 [DllImport("gdiplus.dll")]
730 internal static extern Status GdipGetPenDashCap197819 (IntPtr pen, out DashCap dashCap);
731 [DllImport("gdiplus.dll")]
732 internal static extern Status GdipSetPenDashStyle (IntPtr pen, DashStyle dashStyle);
733 [DllImport("gdiplus.dll")]
734 internal static extern Status GdipGetPenDashStyle (IntPtr pen, out DashStyle dashStyle);
735 [DllImport("gdiplus.dll")]
736 internal static extern Status GdipSetPenDashOffset (IntPtr pen, float offset);
737 [DllImport("gdiplus.dll")]
738 internal static extern Status GdipGetPenDashOffset (IntPtr pen, out float offset);
739 [DllImport("gdiplus.dll")]
740 internal static extern Status GdipGetPenDashCount (IntPtr pen, out int count);
741 [DllImport("gdiplus.dll")]
742 internal static extern Status GdipSetPenDashArray (IntPtr pen, float[] dash, int count);
743 [DllImport("gdiplus.dll")]
744 internal static extern Status GdipGetPenDashArray (IntPtr pen, float[] dash, int count);
745 [DllImport("gdiplus.dll")]
746 internal static extern Status GdipSetPenMiterLimit (IntPtr pen, float miterLimit);
747 [DllImport("gdiplus.dll")]
748 internal static extern Status GdipGetPenMiterLimit (IntPtr pen, out float miterLimit);
749 [DllImport("gdiplus.dll")]
750 internal static extern Status GdipSetPenLineJoin (IntPtr pen, LineJoin lineJoin);
751 [DllImport("gdiplus.dll")]
752 internal static extern Status GdipGetPenLineJoin (IntPtr pen, out LineJoin lineJoin);
753 [DllImport("gdiplus.dll")]
754 internal static extern Status GdipSetPenLineCap197819 (IntPtr pen, LineCap startCap, LineCap endCap, DashCap dashCap);
755 [DllImport("gdiplus.dll")]
756 internal static extern Status GdipSetPenMode (IntPtr pen, PenAlignment alignment);
757 [DllImport("gdiplus.dll")]
758 internal static extern Status GdipGetPenMode (IntPtr pen, out PenAlignment alignment);
759 [DllImport("gdiplus.dll")]
760 internal static extern Status GdipSetPenStartCap (IntPtr pen, LineCap startCap);
761 [DllImport("gdiplus.dll")]
762 internal static extern Status GdipGetPenStartCap (IntPtr pen, out LineCap startCap);
763 [DllImport("gdiplus.dll")]
764 internal static extern Status GdipSetPenEndCap (IntPtr pen, LineCap endCap);
765 [DllImport("gdiplus.dll")]
766 internal static extern Status GdipGetPenEndCap (IntPtr pen, out LineCap endCap);
767 [DllImport("gdiplus.dll")]
768 internal static extern Status GdipSetPenCustomStartCap (IntPtr pen, IntPtr customCap);
769 [DllImport("gdiplus.dll")]
770 internal static extern Status GdipGetPenCustomStartCap (IntPtr pen, out IntPtr customCap);
771 [DllImport("gdiplus.dll")]
772 internal static extern Status GdipSetPenCustomEndCap (IntPtr pen, IntPtr customCap);
773 [DllImport("gdiplus.dll")]
774 internal static extern Status GdipGetPenCustomEndCap (IntPtr pen, out IntPtr customCap);
775 [DllImport("gdiplus.dll")]
776 internal static extern Status GdipSetPenTransform (IntPtr pen, IntPtr matrix);
777 [DllImport("gdiplus.dll")]
778 internal static extern Status GdipGetPenTransform (IntPtr pen, IntPtr matrix);
779 [DllImport("gdiplus.dll")]
780 internal static extern Status GdipSetPenWidth (IntPtr pen, float width);
781 [DllImport("gdiplus.dll")]
782 internal static extern Status GdipGetPenWidth (IntPtr pen, out float width);
783 [DllImport("gdiplus.dll")]
784 internal static extern Status GdipResetPenTransform (IntPtr pen);
785 [DllImport("gdiplus.dll")]
786 internal static extern Status GdipMultiplyPenTransform (IntPtr pen, IntPtr matrix, MatrixOrder order);
787 [DllImport("gdiplus.dll")]
788 internal static extern Status GdipRotatePenTransform (IntPtr pen, float angle, MatrixOrder order);
789 [DllImport("gdiplus.dll")]
790 internal static extern Status GdipScalePenTransform (IntPtr pen, float sx, float sy, MatrixOrder order);
791 [DllImport("gdiplus.dll")]
792 internal static extern Status GdipTranslatePenTransform (IntPtr pen, float dx, float dy, MatrixOrder order);
794 // CustomLineCap functions
795 [DllImport("gdiplus.dll")]
796 internal static extern Status GdipCreateCustomLineCap (IntPtr fillPath, IntPtr strokePath, LineCap baseCap, float baseInset, out IntPtr customCap);
797 [DllImport("gdiplus.dll")]
798 internal static extern Status GdipDeleteCustomLineCap (IntPtr customCap);
799 [DllImport("gdiplus.dll")]
800 internal static extern Status GdipCloneCustomLineCap (IntPtr customCap, out IntPtr clonedCap);
801 [DllImport("gdiplus.dll")]
802 internal static extern Status GdipSetCustomLineCapStrokeCaps (IntPtr customCap, LineCap startCap, LineCap endCap);
803 [DllImport("gdiplus.dll")]
804 internal static extern Status GdipGetCustomLineCapStrokeCaps (IntPtr customCap, out LineCap startCap, out LineCap endCap);
805 [DllImport("gdiplus.dll")]
806 internal static extern Status GdipSetCustomLineCapStrokeJoin (IntPtr customCap, LineJoin lineJoin);
807 [DllImport("gdiplus.dll")]
808 internal static extern Status GdipGetCustomLineCapStrokeJoin (IntPtr customCap, out LineJoin lineJoin);
809 [DllImport("gdiplus.dll")]
810 internal static extern Status GdipSetCustomLineCapBaseCap (IntPtr customCap, LineCap baseCap);
811 [DllImport("gdiplus.dll")]
812 internal static extern Status GdipGetCustomLineCapBaseCap (IntPtr customCap, out LineCap baseCap);
813 [DllImport("gdiplus.dll")]
814 internal static extern Status GdipSetCustomLineCapBaseInset (IntPtr customCap, float inset);
815 [DllImport("gdiplus.dll")]
816 internal static extern Status GdipGetCustomLineCapBaseInset (IntPtr customCap, out float inset);
817 [DllImport("gdiplus.dll")]
818 internal static extern Status GdipSetCustomLineCapWidthScale (IntPtr customCap, float widthScale);
819 [DllImport("gdiplus.dll")]
820 internal static extern Status GdipGetCustomLineCapWidthScale (IntPtr customCap, out float widthScale);
822 // AdjustableArrowCap functions
823 [DllImport("gdiplus.dll")]
824 internal static extern Status GdipCreateAdjustableArrowCap (float height, float width, bool isFilled, out IntPtr arrowCap);
825 [DllImport("gdiplus.dll")]
826 internal static extern Status GdipSetAdjustableArrowCapHeight (IntPtr arrowCap, float height);
827 [DllImport("gdiplus.dll")]
828 internal static extern Status GdipGetAdjustableArrowCapHeight (IntPtr arrowCap, out float height);
829 [DllImport("gdiplus.dll")]
830 internal static extern Status GdipSetAdjustableArrowCapWidth (IntPtr arrowCap, float width);
831 [DllImport("gdiplus.dll")]
832 internal static extern Status GdipGetAdjustableArrowCapWidth (IntPtr arrowCap, out float width);
833 [DllImport("gdiplus.dll")]
834 internal static extern Status GdipSetAdjustableArrowCapMiddleInset (IntPtr arrowCap, float middleInset);
835 [DllImport("gdiplus.dll")]
836 internal static extern Status GdipGetAdjustableArrowCapMiddleInset (IntPtr arrowCap, out float middleInset);
837 [DllImport("gdiplus.dll")]
838 internal static extern Status GdipSetAdjustableArrowCapFillState (IntPtr arrowCap, bool isFilled);
839 [DllImport("gdiplus.dll")]
840 internal static extern Status GdipGetAdjustableArrowCapFillState (IntPtr arrowCap, out bool isFilled);
843 [DllImport("gdiplus.dll")]
844 internal static extern Status GdipCreateFromHWND (IntPtr hwnd, out IntPtr graphics);
846 [DllImport("gdiplus.dll", CharSet=CharSet.Unicode)]
847 internal static extern Status GdipMeasureString(IntPtr graphics, string str, int length, IntPtr font,
848 ref RectangleF layoutRect, IntPtr stringFormat, out RectangleF boundingBox, out int codepointsFitted,
849 out int linesFilled);
851 [DllImport("gdiplus.dll", CharSet=CharSet.Unicode)]
852 internal static extern Status GdipMeasureCharacterRanges (IntPtr graphics, string str, int length, IntPtr font,
853 ref RectangleF layoutRect, IntPtr stringFormat, int regcount, out IntPtr regions);
855 [DllImport("gdiplus.dll")]
856 internal static extern Status GdipSetStringFormatMeasurableCharacterRanges (IntPtr native,
857 int cnt, CharacterRange [] range);
859 [DllImport("gdiplus.dll")]
860 internal static extern Status GdipGetStringFormatMeasurableCharacterRangeCount (IntPtr native,
861 out int cnt);
863 // Bitmap functions
864 [DllImport("gdiplus.dll")]
865 internal static extern Status GdipCreateBitmapFromScan0 (int width, int height, int stride, PixelFormat format, IntPtr scan0, out IntPtr bmp);
867 [DllImport("gdiplus.dll")]
868 internal static extern Status GdipCreateBitmapFromGraphics (int width, int height, IntPtr target, out IntPtr bitmap);
870 [DllImport("gdiplus.dll")]
871 internal static extern Status GdipBitmapLockBits (IntPtr bmp, ref Rectangle rc, ImageLockMode flags, PixelFormat format, [In, Out] IntPtr bmpData);
873 [DllImport("gdiplus.dll")]
874 internal static extern Status GdipBitmapSetResolution(IntPtr bmp, float xdpi, float ydpi);
877 // This an internal GDIPlus Cairo function, not part GDIPlus interface
878 //[DllImport("gdiplus.dll")]
879 //(internal static extern Status ____BitmapLockBits (IntPtr bmp, ref GpRect rc, ImageLockMode flags, PixelFormat format, ref int width, ref int height, ref int stride, ref int format2, ref int reserved, ref IntPtr scan0);
881 [DllImport("gdiplus.dll")]
882 internal static extern Status GdipBitmapUnlockBits (IntPtr bmp, [In,Out] BitmapData bmpData);
884 [DllImport("gdiplus.dll")]
885 internal static extern Status GdipBitmapGetPixel (IntPtr bmp, int x, int y, out int argb);
887 [DllImport("gdiplus.dll")]
888 internal static extern Status GdipBitmapSetPixel (IntPtr bmp, int x, int y, int argb);
890 // Image functions
891 [DllImport("gdiplus.dll", CharSet=CharSet.Auto)]
892 internal static extern Status GdipLoadImageFromFile ( [MarshalAs(UnmanagedType.LPWStr)] string filename, out IntPtr image );
894 [DllImport("gdiplus.dll")]
895 internal static extern Status GdipCloneImage(IntPtr image, out IntPtr imageclone);
897 [DllImport("gdiplus.dll", CharSet=CharSet.Auto)]
898 internal static extern Status GdipLoadImageFromFileICM ( [MarshalAs(UnmanagedType.LPWStr)] string filename, out IntPtr image );
900 [DllImport("gdiplus.dll")]
901 internal static extern Status GdipCreateBitmapFromHBITMAP ( IntPtr hBitMap, IntPtr gdiPalette, out IntPtr image );
903 [DllImport("gdiplus.dll")]
904 internal static extern Status GdipDisposeImage ( IntPtr image );
906 [DllImport("gdiplus.dll")]
907 internal static extern Status GdipGetImageFlags(IntPtr image, out int flag);
909 [DllImport("gdiplus.dll")]
910 internal static extern Status GdipImageGetFrameDimensionsCount ( IntPtr image, out uint count );
912 [DllImport("gdiplus.dll")]
913 internal static extern Status GdipImageGetFrameDimensionsList ( IntPtr image, [Out] Guid [] dimensionIDs, uint count );
915 [DllImport("gdiplus.dll")]
916 internal static extern Status GdipGetImageHeight (IntPtr image, out int height);
918 [DllImport("gdiplus.dll")]
919 internal static extern Status GdipGetImageHorizontalResolution ( IntPtr image, out float resolution );
921 [DllImport("gdiplus.dll")]
922 internal static extern Status GdipGetImagePaletteSize ( IntPtr image, out int size );
924 [DllImport("gdiplus.dll")]
925 internal static extern Status GdipGetImagePalette (IntPtr image, out IntPtr palette, int size);
927 [DllImport("gdiplus.dll")]
928 internal static extern Status GdipSetImagePalette (IntPtr image, IntPtr palette);
930 [DllImport("gdiplus.dll")]
931 internal static extern Status GdipGetImageDimension ( IntPtr image, out float width, out float height );
933 [DllImport("gdiplus.dll")]
934 internal static extern Status GdipGetImagePixelFormat ( IntPtr image, out PixelFormat format );
936 [DllImport("gdiplus.dll")]
937 internal static extern Status GdipGetPropertyCount (IntPtr image, out uint propNumbers);
939 [DllImport("gdiplus.dll")]
940 internal static extern Status GdipGetPropertyIdList (IntPtr image, uint propNumbers, [Out] int [] list);
942 [DllImport("gdiplus.dll")]
943 internal static extern Status GdipGetPropertySize (IntPtr image, out int bufferSize, out int propNumbers);
945 [DllImport("gdiplus.dll")]
946 internal static extern Status GdipGetAllPropertyItems (IntPtr image, int bufferSize, int propNumbers, IntPtr items);
948 [DllImport("gdiplus.dll")]
949 internal static extern Status GdipGetImageRawFormat ( IntPtr image, out Guid format );
951 [DllImport("gdiplus.dll")]
952 internal static extern Status GdipGetImageVerticalResolution ( IntPtr image, out float resolution );
954 [DllImport("gdiplus.dll")]
955 internal static extern Status GdipGetImageWidth ( IntPtr image, out int width);
957 [DllImport("gdiplus.dll")]
958 internal static extern Status GdipGetImageBounds ( IntPtr image, out RectangleF source, ref GraphicsUnit unit );
960 [DllImport("gdiplus.dll")]
961 internal static extern Status GdipGetEncoderParameterListSize ( IntPtr image, ref Guid encoder, out uint size );
963 [DllImport("gdiplus.dll")]
964 internal static extern Status GdipGetEncoderParameterList ( IntPtr image, ref Guid encoder, uint size, IntPtr buffer );
966 [DllImport("gdiplus.dll")]
967 internal static extern Status GdipImageGetFrameCount (IntPtr image, ref Guid guidDimension, out int count );
969 [DllImport("gdiplus.dll")]
970 internal static extern Status GdipImageSelectActiveFrame (IntPtr image, ref Guid guidDimension, int frameIndex);
972 [DllImport("gdiplus.dll")]
973 internal static extern Status GdipGetPropertyItemSize (IntPtr image, int propertyID, out int propertySize);
975 [DllImport("gdiplus.dll")]
976 internal static extern Status GdipGetPropertyItem (IntPtr image, int propertyID, int propertySize, IntPtr buffer);
978 [DllImport("gdiplus.dll")]
979 internal static extern Status GdipRemovePropertyItem (IntPtr image, int propertyId);
981 [DllImport("gdiplus.dll")]
982 internal static extern Status GdipSetPropertyItem (IntPtr image, IntPtr propertyItem);
984 [DllImport("gdiplus.dll")]
985 internal static extern Status GdipGetImageThumbnail ( IntPtr image, uint width, uint height, out IntPtr thumbImage, IntPtr callback, IntPtr callBackData );
987 [DllImport("gdiplus.dll")]
988 internal static extern Status GdipImageRotateFlip ( IntPtr image, RotateFlipType rotateFlipType );
990 [DllImport("gdiplus.dll", CharSet=CharSet.Unicode)]
991 internal static extern Status GdipSaveImageToFile (IntPtr image, string filename, ref Guid encoderClsID, IntPtr encoderParameters);
993 [DllImport("gdiplus.dll")]
994 internal static extern Status GdipSaveAdd ( IntPtr image, IntPtr encoderParameters );
996 [DllImport("gdiplus.dll")]
997 internal static extern Status GdipSaveAddImage (IntPtr image, IntPtr imagenew, IntPtr encoderParameters);
999 [DllImport("gdiplus.dll")]
1000 internal static extern Status GdipDrawImageI (IntPtr graphics, IntPtr image, int x, int y);
1001 [DllImport("gdiplus.dll")]
1002 internal static extern Status GdipGetImageGraphicsContext (IntPtr image, out int graphics);
1003 [DllImport("gdiplus.dll")]
1004 internal static extern Status GdipDrawImage (IntPtr graphics, IntPtr image, float x, float y);
1005 [DllImport("gdiplus.dll")]
1006 internal static extern Status GdipBeginContainer (IntPtr graphics, RectangleF dstrect,
1007 RectangleF srcrect, GraphicsUnit unit, out int state);
1009 [DllImport("gdiplus.dll")]
1010 internal static extern Status GdipBeginContainerI (IntPtr graphics, Rectangle dstrect,
1011 Rectangle srcrect, GraphicsUnit unit, out int state);
1013 [DllImport("gdiplus.dll")]
1014 internal static extern Status GdipBeginContainer2 (IntPtr graphics, out int state);
1016 [DllImport("gdiplus.dll")]
1017 internal static extern Status GdipDrawImagePoints (IntPtr graphics, IntPtr image, PointF [] destPoints, int count);
1020 [DllImport("gdiplus.dll")]
1021 internal static extern Status GdipDrawImagePointsI (IntPtr graphics, IntPtr image, Point [] destPoints, int count);
1023 [DllImport("gdiplus.dll")]
1024 internal static extern Status GdipDrawImageRectRectI (IntPtr graphics, IntPtr image,
1025 int dstx, int dsty, int dstwidth, int dstheight,
1026 int srcx, int srcy, int srcwidth, int srcheight,
1027 GraphicsUnit srcUnit, IntPtr imageattr, Graphics.DrawImageAbort callback, IntPtr callbackData);
1029 [DllImport("gdiplus.dll")]
1030 internal static extern Status GdipDrawImageRectRect (IntPtr graphics, IntPtr image,
1031 float dstx, float dsty, float dstwidth, float dstheight,
1032 float srcx, float srcy, float srcwidth, float srcheight,
1033 GraphicsUnit srcUnit, IntPtr imageattr, Graphics.DrawImageAbort callback, IntPtr callbackData);
1035 [DllImport("gdiplus.dll")]
1036 internal static extern Status GdipDrawImagePointsRectI (IntPtr graphics, IntPtr image,
1037 Point [] destPoints, int count, int srcx, int srcy, int srcwidth, int srcheight,
1038 GraphicsUnit srcUnit, IntPtr imageattr, Graphics.DrawImageAbort callback, IntPtr callbackData);
1040 [DllImport("gdiplus.dll")]
1041 internal static extern Status GdipDrawImagePointsRect (IntPtr graphics, IntPtr image,
1042 PointF [] destPoints, int count, float srcx, float srcy, float srcwidth, float srcheight,
1043 GraphicsUnit srcUnit, IntPtr imageattr, Graphics.DrawImageAbort callback, IntPtr callbackData);
1045 [DllImport("gdiplus.dll")]
1046 internal static extern Status GdipDrawImageRect(IntPtr graphics, IntPtr image, float x, float y, float width, float height);
1047 [DllImport("gdiplus.dll")]
1048 internal static extern Status GdipDrawImagePointRect(IntPtr graphics, IntPtr image, float x,
1049 float y, float srcx, float srcy, float srcwidth, float srcheight, GraphicsUnit srcUnit);
1051 [DllImport("gdiplus.dll")]
1052 internal static extern Status GdipDrawImagePointRectI(IntPtr graphics, IntPtr image, int x,
1053 int y, int srcx, int srcy, int srcwidth,
1054 int srcheight, GraphicsUnit srcUnit);
1056 [DllImport("gdiplus.dll")]
1057 internal static extern Status GdipCreateStringFormat(StringFormatFlags formatAttributes, int language, out IntPtr native);
1059 [DllImport("gdiplus.dll")]
1060 internal static extern Status GdipCreateHBITMAPFromBitmap (IntPtr bmp, out IntPtr HandleBmp, int clrbackground);
1062 [DllImport("gdiplus.dll")]
1063 internal static extern Status GdipCreateHICONFromBitmap (IntPtr bmp, out IntPtr HandleIcon);
1065 [DllImport("gdiplus.dll")]
1066 internal static extern Status GdipCreateBitmapFromHICON (IntPtr hicon, out IntPtr bitmap);
1068 [DllImport("gdiplus.dll")]
1069 internal static extern Status GdipCreateBitmapFromResource (IntPtr hInstance,
1070 string lpBitmapName, out IntPtr bitmap);
1072 // Matrix functions
1073 [DllImport ("gdiplus.dll")]
1074 internal static extern Status GdipCreateMatrix (out IntPtr matrix);
1075 [DllImport ("gdiplus.dll")]
1076 internal static extern Status GdipCreateMatrix2 (float m11, float m12, float m21, float m22, float dx, float dy, out IntPtr matrix);
1077 [DllImport ("gdiplus.dll")]
1078 internal static extern Status GdipCreateMatrix3 (RectangleF rect, PointF [] dstplg, out IntPtr matrix);
1079 [DllImport ("gdiplus.dll")]
1080 internal static extern Status GdipCreateMatrix3I (Rectangle rect, Point [] dstplg, out IntPtr matrix);
1081 [DllImport ("gdiplus.dll")]
1082 internal static extern Status GdipDeleteMatrix (IntPtr matrix);
1084 [DllImport ("gdiplus.dll")]
1085 internal static extern Status GdipCloneMatrix (IntPtr matrix, out IntPtr cloneMatrix);
1086 [DllImport ("gdiplus.dll")]
1087 internal static extern Status GdipSetMatrixElements (IntPtr matrix, float m11, float m12, float m21, float m22, float dx, float dy);
1088 [DllImport ("gdiplus.dll")]
1089 internal static extern Status GdipGetMatrixElements (IntPtr matrix, IntPtr matrixOut);
1090 [DllImport ("gdiplus.dll")]
1091 internal static extern Status GdipMultiplyMatrix (IntPtr matrix, IntPtr matrix2, MatrixOrder order);
1092 [DllImport ("gdiplus.dll")]
1093 internal static extern Status GdipTranslateMatrix (IntPtr matrix, float offsetX, float offsetY, MatrixOrder order);
1094 [DllImport ("gdiplus.dll")]
1095 internal static extern Status GdipScaleMatrix (IntPtr matrix, float scaleX, float scaleY, MatrixOrder order);
1096 [DllImport ("gdiplus.dll")]
1097 internal static extern Status GdipRotateMatrix (IntPtr matrix, float angle, MatrixOrder order);
1099 [DllImport ("gdiplus.dll")]
1100 internal static extern Status GdipShearMatrix (IntPtr matrix, float shearX, float shearY, MatrixOrder order);
1102 [DllImport ("gdiplus.dll")]
1103 internal static extern Status GdipInvertMatrix (IntPtr matrix);
1104 [DllImport ("gdiplus.dll")]
1105 internal static extern Status GdipTransformMatrixPoints (IntPtr matrix, PointF [] pts, int count);
1106 [DllImport ("gdiplus.dll")]
1107 internal static extern Status GdipTransformMatrixPointsI (IntPtr matrix, Point [] pts, int count);
1108 [DllImport ("gdiplus.dll")]
1109 internal static extern Status GdipVectorTransformMatrixPoints (IntPtr matrix, PointF [] pts, int count);
1110 [DllImport ("gdiplus.dll")]
1111 internal static extern Status GdipVectorTransformMatrixPointsI (IntPtr matrix, Point [] pts, int count);
1112 [DllImport ("gdiplus.dll")]
1113 internal static extern Status GdipIsMatrixInvertible (IntPtr matrix, out bool result);
1115 [DllImport ("gdiplus.dll")]
1116 internal static extern Status GdipIsMatrixIdentity (IntPtr matrix, out bool result);
1117 [DllImport ("gdiplus.dll")]
1118 internal static extern Status GdipIsMatrixEqual (IntPtr matrix, IntPtr matrix2, out bool result);
1120 // GraphicsPath functions
1121 [DllImport ("gdiplus.dll")]
1122 internal static extern Status GdipCreatePath (FillMode brushMode, out IntPtr path);
1123 [DllImport ("gdiplus.dll")]
1124 internal static extern Status GdipCreatePath2 (PointF [] points, byte [] types, int count, FillMode brushMode, out IntPtr path);
1125 [DllImport ("gdiplus.dll")]
1126 internal static extern Status GdipCreatePath2I (Point [] points, byte [] types, int count, FillMode brushMode, out IntPtr path);
1127 [DllImport ("gdiplus.dll")]
1128 internal static extern Status GdipClonePath (IntPtr path, out IntPtr clonePath);
1129 [DllImport ("gdiplus.dll")]
1130 internal static extern Status GdipDeletePath (IntPtr path);
1131 [DllImport ("gdiplus.dll")]
1132 internal static extern Status GdipResetPath (IntPtr path);
1133 [DllImport ("gdiplus.dll")]
1134 internal static extern Status GdipGetPointCount (IntPtr path, out int count);
1135 [DllImport ("gdiplus.dll")]
1136 internal static extern Status GdipGetPathTypes (IntPtr path, [Out] byte [] types, int count);
1137 [DllImport ("gdiplus.dll")]
1138 internal static extern Status GdipGetPathPoints (IntPtr path, [Out] PointF [] points, int count);
1139 [DllImport ("gdiplus.dll")]
1140 internal static extern Status GdipGetPathPointsI (IntPtr path, [Out] Point [] points, int count);
1141 [DllImport ("gdiplus.dll")]
1142 internal static extern Status GdipGetPathFillMode (IntPtr path, out FillMode fillMode);
1143 [DllImport ("gdiplus.dll")]
1144 internal static extern Status GdipSetPathFillMode (IntPtr path, FillMode fillMode);
1145 [DllImport ("gdiplus.dll")]
1146 internal static extern Status GdipStartPathFigure (IntPtr path);
1147 [DllImport ("gdiplus.dll")]
1148 internal static extern Status GdipClosePathFigure (IntPtr path);
1149 [DllImport ("gdiplus.dll")]
1150 internal static extern Status GdipClosePathFigures (IntPtr path);
1151 [DllImport ("gdiplus.dll")]
1152 internal static extern Status GdipSetPathMarker (IntPtr path);
1153 [DllImport ("gdiplus.dll")]
1154 internal static extern Status GdipClearPathMarkers (IntPtr path);
1155 [DllImport ("gdiplus.dll")]
1156 internal static extern Status GdipReversePath (IntPtr path);
1157 [DllImport ("gdiplus.dll")]
1158 internal static extern Status GdipGetPathLastPoint (IntPtr path, out PointF lastPoint);
1159 [DllImport ("gdiplus.dll")]
1160 internal static extern Status GdipAddPathLine (IntPtr path, float x1, float y1, float x2, float y2);
1161 [DllImport ("gdiplus.dll")]
1162 internal static extern Status GdipAddPathArc (IntPtr path, float x, float y, float width, float height, float startAngle, float sweepAngle);
1163 [DllImport ("gdiplus.dll")]
1164 internal static extern Status GdipAddPathBezier (IntPtr path, float x1, float y1, float x2, float y2, float x3, float y3, float x4, float y4);
1165 [DllImport ("gdiplus.dll")]
1166 internal static extern Status GdipAddPathBeziers (IntPtr path, PointF [] points, int count);
1167 [DllImport ("gdiplus.dll")]
1168 internal static extern Status GdipAddPathCurve (IntPtr path, PointF [] points, int count);
1169 [DllImport ("gdiplus.dll")]
1170 internal static extern Status GdipAddPathCurveI (IntPtr path, Point [] points, int count);
1171 [DllImport ("gdiplus.dll")]
1172 internal static extern Status GdipAddPathCurve2 (IntPtr path, PointF [] points, int count, float tension);
1173 [DllImport ("gdiplus.dll")]
1174 internal static extern Status GdipAddPathCurve2I (IntPtr path, Point [] points, int count, float tension);
1175 [DllImport ("gdiplus.dll")]
1176 internal static extern Status GdipAddPathCurve3 (IntPtr path, PointF [] points, int count, int offset, int numberOfSegments, float tension);
1177 [DllImport ("gdiplus.dll")]
1178 internal static extern Status GdipAddPathCurve3I (IntPtr path, Point [] points, int count, int offset, int numberOfSegments, float tension);
1179 [DllImport ("gdiplus.dll")]
1180 internal static extern Status GdipAddPathClosedCurve (IntPtr path, PointF [] points, int count);
1181 [DllImport ("gdiplus.dll")]
1182 internal static extern Status GdipAddPathClosedCurveI (IntPtr path, Point [] points, int count);
1183 [DllImport ("gdiplus.dll")]
1184 internal static extern Status GdipAddPathClosedCurve2 (IntPtr path, PointF [] points, int count, float tension);
1185 [DllImport ("gdiplus.dll")]
1186 internal static extern Status GdipAddPathClosedCurve2I (IntPtr path, Point [] points, int count, float tension);
1187 [DllImport ("gdiplus.dll")]
1188 internal static extern Status GdipAddPathRectangle (IntPtr path, float x, float y, float width, float height);
1189 [DllImport ("gdiplus.dll")]
1190 internal static extern Status GdipAddPathRectangles (IntPtr path, RectangleF [] rects, int count);
1191 [DllImport ("gdiplus.dll")]
1192 internal static extern Status GdipAddPathEllipse (IntPtr path, float x, float y, float width, float height);
1193 [DllImport ("gdiplus.dll")]
1194 internal static extern Status GdipAddPathEllipseI (IntPtr path, int x, int y, int width, int height);
1195 [DllImport ("gdiplus.dll")]
1196 internal static extern Status GdipAddPathPie (IntPtr path, float x, float y, float width, float height, float startAngle, float sweepAngle);
1197 [DllImport ("gdiplus.dll")]
1198 internal static extern Status GdipAddPathPieI (IntPtr path, int x, int y, int width, int height, float startAngle, float sweepAngle);
1199 [DllImport ("gdiplus.dll")]
1200 internal static extern Status GdipAddPathPolygon (IntPtr path, PointF [] points, int count);
1201 [DllImport ("gdiplus.dll")]
1202 internal static extern Status GdipAddPathPath (IntPtr path, IntPtr addingPath, bool connect);
1203 [DllImport ("gdiplus.dll")]
1204 internal static extern Status GdipAddPathLineI (IntPtr path, int x1, int y1, int x2, int y2);
1205 [DllImport ("gdiplus.dll")]
1206 internal static extern Status GdipAddPathArcI (IntPtr path, int x, int y, int width, int height, float startAngle, float sweepAngle);
1208 [DllImport ("gdiplus.dll")]
1209 internal static extern Status GdipAddPathBezierI (IntPtr path, int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4);
1210 [DllImport ("gdiplus.dll")]
1211 internal static extern Status GdipAddPathBeziersI (IntPtr path, Point [] points, int count);
1213 [DllImport ("gdiplus.dll")]
1214 internal static extern Status GdipAddPathPolygonI (IntPtr path, Point [] points, int count);
1215 [DllImport ("gdiplus.dll")]
1216 internal static extern Status GdipAddPathRectangleI (IntPtr path, int x, int y, int width, int height);
1217 [DllImport ("gdiplus.dll")]
1218 internal static extern Status GdipAddPathRectanglesI (IntPtr path, Rectangle [] rects, int count);
1219 [DllImport ("gdiplus.dll")]
1220 internal static extern Status GdipFlattenPath (IntPtr path, IntPtr matrix, float floatness);
1221 [DllImport ("gdiplus.dll")]
1222 internal static extern Status GdipTransformPath (IntPtr path, IntPtr matrix);
1223 [DllImport ("gdiplus.dll")]
1224 internal static extern Status GdipWarpPath (IntPtr path, IntPtr matrix,
1225 PointF [] points, int count,
1226 float srcx, float srcy, float srcwidth, float srcheight,
1227 WarpMode mode, float flatness);
1228 [DllImport ("gdiplus.dll")]
1229 internal static extern Status GdipWidenPath (IntPtr path, IntPtr pen, IntPtr matrix, float flatness);
1230 [DllImport ("gdiplus.dll")]
1231 internal static extern Status GdipGetPathWorldBounds (IntPtr path, out RectangleF bounds, IntPtr matrix, IntPtr pen);
1232 [DllImport ("gdiplus.dll")]
1233 internal static extern Status GdipGetPathWorldBoundsI (IntPtr path, out Rectangle bounds, IntPtr matrix, IntPtr pen);
1234 [DllImport ("gdiplus.dll")]
1235 internal static extern Status GdipIsVisiblePathPoint (IntPtr path, float x, float y, IntPtr graphics, out bool result);
1236 [DllImport ("gdiplus.dll")]
1237 internal static extern Status GdipIsVisiblePathPointI (IntPtr path, int x, int y, IntPtr graphics, out bool result);
1238 [DllImport ("gdiplus.dll")]
1239 internal static extern Status GdipIsOutlineVisiblePathPoint (IntPtr path, float x, float y, IntPtr graphics, out bool result);
1240 [DllImport ("gdiplus.dll")]
1241 internal static extern Status GdipIsOutlineVisiblePathPointI (IntPtr path, int x, int y, IntPtr graphics, out bool result);
1243 // GraphicsPathIterator
1244 [DllImport("gdiplus.dll")]
1245 internal static extern Status GdipCreatePathIter (out IntPtr iterator, IntPtr path);
1246 [DllImport("gdiplus.dll")]
1247 internal static extern Status GdipPathIterGetCount (IntPtr iterator, out int count);
1248 [DllImport("gdiplus.dll")]
1249 internal static extern Status GdipPathIterGetSubpathCount (IntPtr iterator, out int count);
1250 [DllImport("gdiplus.dll")]
1251 internal static extern Status GdipDeletePathIter (IntPtr iterator);
1252 [DllImport("gdiplus.dll")]
1253 internal static extern Status GdipPathIterCopyData (IntPtr iterator, out int resultCount, PointF [] points, byte [] types, int startIndex, int endIndex);
1254 [DllImport("gdiplus.dll")]
1255 internal static extern Status GdipPathIterEnumerate (IntPtr iterator, out int resultCount, PointF [] points, byte [] types, int count);
1256 [DllImport("gdiplus.dll")]
1257 internal static extern Status GdipPathIterHasCurve (IntPtr iterator, out bool curve);
1258 [DllImport("gdiplus.dll")]
1259 internal static extern Status GdipPathIterNextMarkerPath (IntPtr iterator, out int resultCount, IntPtr path);
1260 [DllImport("gdiplus.dll")]
1261 internal static extern Status GdipPathIterNextMarker (IntPtr iterator, out int resultCount, out int startIndex, out int endIndex);
1262 [DllImport("gdiplus.dll")]
1263 internal static extern Status GdipPathIterNextPathType (IntPtr iterator, out int resultCount, out byte pathType, out int startIndex, out int endIndex);
1264 [DllImport("gdiplus.dll")]
1265 internal static extern Status GdipPathIterNextSubpathPath (IntPtr iterator, out int resultCount, IntPtr path, out bool isClosed);
1266 [DllImport("gdiplus.dll")]
1267 internal static extern Status GdipPathIterNextSubpath (IntPtr iterator, out int resultCount, out int startIndex, out int endIndex, out bool isClosed);
1268 [DllImport("gdiplus.dll")]
1269 internal static extern Status GdipPathIterRewind (IntPtr iterator);
1271 // ImageAttributes
1272 [DllImport ("gdiplus.dll")]
1273 internal static extern Status GdipCreateImageAttributes (out IntPtr imageattr);
1275 [DllImport ("gdiplus.dll")]
1276 internal static extern Status GdipSetImageAttributesColorKeys (IntPtr imageattr,
1277 ColorAdjustType type, bool enableFlag, int colorLow, int colorHigh);
1279 [DllImport ("gdiplus.dll")]
1280 internal static extern Status GdipDisposeImageAttributes (IntPtr imageattr);
1282 [DllImport ("gdiplus.dll")]
1283 internal static extern Status GdipSetImageAttributesColorMatrix (IntPtr imageattr,
1284 ColorAdjustType type, bool enableFlag, ColorMatrix colorMatrix,
1285 ColorMatrix grayMatrix, ColorMatrixFlag flags);
1287 [DllImport ("gdiplus.dll")]
1288 internal static extern Status GdipSetImageAttributesGamma (IntPtr imageattr,
1289 ColorAdjustType type, bool enableFlag,
1290 float gamma);
1292 [DllImport ("gdiplus.dll")]
1293 internal static extern Status GdipSetImageAttributesNoOp (IntPtr imageattr,
1294 ColorAdjustType type, bool enableFlag);
1296 [DllImport ("gdiplus.dll")]
1297 internal static extern Status GdipSetImageAttributesOutputChannel (IntPtr imageattr,
1298 ColorAdjustType type, bool enableFlag, ColorChannelFlag channelFlags);
1300 [DllImport ("gdiplus.dll", CharSet=CharSet.Auto)]
1301 internal static extern Status GdipSetImageAttributesOutputChannelColorProfile (IntPtr imageattr,
1302 ColorAdjustType type, bool enableFlag, [MarshalAs (UnmanagedType.LPWStr)] string profileName);
1304 [DllImport ("gdiplus.dll")]
1305 internal static extern Status GdipSetImageAttributesRemapTable (IntPtr imageattr,
1306 ColorAdjustType type, bool enableFlag, uint mapSize, IntPtr colorMap);
1308 [DllImport ("gdiplus.dll")]
1309 internal static extern Status GdipSetImageAttributesThreshold (IntPtr imageattr,
1310 ColorAdjustType type, bool enableFlag, float thresHold);
1312 [DllImport ("gdiplus.dll")]
1313 internal static extern Status GdipCloneImageAttributes(IntPtr imageattr, out IntPtr cloneImageattr);
1315 [DllImport ("gdiplus.dll")]
1316 internal static extern Status GdipGetImageAttributesAdjustedPalette(IntPtr imageattr,
1317 out IntPtr colorPalette, ColorAdjustType colorAdjustType);
1319 [DllImport ("gdiplus.dll")]
1320 internal static extern Status GdipSetImageAttributesWrapMode(IntPtr imageattr, WrapMode wrap,
1321 int argb, bool clamp);
1324 // Font
1325 [DllImport("gdiplus.dll")]
1326 internal static extern Status GdipCreateFont (IntPtr fontFamily, float emSize, FontStyle style, GraphicsUnit unit, out IntPtr font);
1327 [DllImport("gdiplus.dll")]
1328 internal static extern Status GdipDeleteFont (IntPtr font);
1329 [DllImport("gdiplus.dll")]
1330 internal static extern Status GdipGetLogFontA(IntPtr font, IntPtr graphics, ref LOGFONTA logfontA);
1331 [DllImport("gdiplus.dll")]
1332 internal static extern Status GdipCreateFontFromDC(IntPtr hdc, out IntPtr font);
1333 [DllImport("gdiplus.dll", SetLastError=true)]
1334 internal static extern int GdipCreateFontFromLogfontA(IntPtr hdc, ref LOGFONTA lf, out IntPtr ptr);
1336 // These are our private functions, they exists in our own libgdiplus library, this way we
1337 // avoid relying on wine in System.Drawing
1338 [DllImport("gdiplus.dll")]
1339 internal static extern Status GdipGetHfont (IntPtr font, out IntPtr Hfont);
1340 [DllImport("gdiplus.dll")]
1341 internal static extern Status GdipCreateFontFromHfont(IntPtr hdc, out IntPtr font, ref LOGFONTA lf);
1343 // This is win32/gdi, not gdiplus, but it's easier to keep in here, also see above comment
1344 [DllImport("gdi32.dll", EntryPoint="CreateFontIndirectA", CallingConvention = CallingConvention.StdCall, CharSet = CharSet.Ansi)]
1345 internal static extern IntPtr CreateFontIndirectA (ref LOGFONTA logfontA);
1346 [DllImport("user32.dll", EntryPoint="GetDC", CallingConvention = CallingConvention.StdCall, CharSet = CharSet.Ansi)]
1347 internal static extern IntPtr GetDC(IntPtr hwnd);
1348 [DllImport("user32.dll", EntryPoint="ReleaseDC", CallingConvention = CallingConvention.StdCall, CharSet = CharSet.Ansi)]
1349 internal static extern int ReleaseDC(IntPtr hdc);
1350 [DllImport("gdi32.dll", EntryPoint="SelectObject", CallingConvention = CallingConvention.StdCall, CharSet = CharSet.Ansi)]
1351 internal static extern IntPtr SelectObject(IntPtr hdc, IntPtr obj);
1353 // Some special X11 stuff
1354 [DllImport("libX11.so", EntryPoint="XOpenDisplay")]
1355 internal extern static IntPtr XOpenDisplay(IntPtr display);
1357 // FontCollection
1358 [DllImport ("gdiplus.dll")]
1359 internal static extern Status GdipGetFontCollectionFamilyCount (IntPtr collection, out int found);
1361 [DllImport ("gdiplus.dll")]
1362 internal static extern Status GdipGetFontCollectionFamilyList (IntPtr collection, int getCount, IntPtr dest, out int retCount);
1363 //internal static extern Status GdipGetFontCollectionFamilyList( IntPtr collection, int getCount, [Out] FontFamily [] familyList, out int retCount );
1365 [DllImport ("gdiplus.dll")]
1366 internal static extern Status GdipNewInstalledFontCollection (out IntPtr collection);
1368 [DllImport ("gdiplus.dll")]
1369 internal static extern Status GdipNewPrivateFontCollection (out IntPtr collection);
1371 [DllImport ("gdiplus.dll")]
1372 internal static extern Status GdipDeletePrivateFontCollection (IntPtr collection);
1374 [DllImport ("gdiplus.dll", CharSet=CharSet.Auto)]
1375 internal static extern Status GdipPrivateAddFontFile (IntPtr collection,
1376 [MarshalAs (UnmanagedType.LPWStr)] string fileName );
1378 [DllImport ("gdiplus.dll")]
1379 internal static extern Status GdipPrivateAddMemoryFont (IntPtr collection, IntPtr mem, int length);
1381 //FontFamily
1382 [DllImport ("gdiplus.dll", CharSet=CharSet.Auto)]
1383 internal static extern Status GdipCreateFontFamilyFromName (
1384 [MarshalAs(UnmanagedType.LPWStr)] string fName, IntPtr collection, out IntPtr fontFamily);
1386 [DllImport ("gdiplus.dll", CharSet=CharSet.Unicode)]
1387 internal static extern Status GdipGetFamilyName(IntPtr family, StringBuilder fName, int language);
1389 [DllImport ("gdiplus.dll")]
1390 internal static extern Status GdipGetGenericFontFamilySansSerif (out IntPtr fontFamily);
1392 [DllImport ("gdiplus.dll")]
1393 internal static extern Status GdipGetGenericFontFamilySerif (out IntPtr fontFamily);
1395 [DllImport ("gdiplus.dll")]
1396 internal static extern Status GdipGetGenericFontFamilyMonospace (out IntPtr fontFamily);
1398 [DllImport ("gdiplus.dll")]
1399 internal static extern Status GdipGetCellAscent (IntPtr fontFamily, int style, out uint ascent);
1401 [DllImport ("gdiplus.dll")]
1402 internal static extern Status GdipGetCellDescent (IntPtr fontFamily, int style, out uint descent);
1404 [DllImport ("gdiplus.dll")]
1405 internal static extern Status GdipGetLineSpacing (IntPtr fontFamily, int style, out uint spacing);
1407 [DllImport ("gdiplus.dll")]
1408 internal static extern Status GdipGetEmHeight (IntPtr fontFamily, int style, out uint emHeight);
1410 [DllImport ("gdiplus.dll")]
1411 internal static extern Status GdipIsStyleAvailable (IntPtr fontFamily, int style, out bool styleAvailable);
1413 [DllImport ("gdiplus.dll")]
1414 internal static extern Status GdipDeleteFontFamily (IntPtr fontFamily);
1416 // String Format
1417 [DllImport ("gdiplus.dll")]
1418 internal static extern Status GdipCreateStringFormat(int formatAttributes, int language, out IntPtr format);
1419 [DllImport ("gdiplus.dll")]
1420 internal static extern Status GdipStringFormatGetGenericDefault(out IntPtr format);
1421 [DllImport ("gdiplus.dll")]
1422 internal static extern Status GdipStringFormatGetGenericTypographic(out IntPtr format);
1423 [DllImport ("gdiplus.dll")]
1424 internal static extern Status GdipDeleteStringFormat(IntPtr format);
1425 [DllImport ("gdiplus.dll")]
1426 internal static extern Status GdipCloneStringFormat(IntPtr srcformat, out IntPtr format);
1427 [DllImport ("gdiplus.dll")]
1428 internal static extern Status GdipSetStringFormatFlags(IntPtr format, StringFormatFlags flags);
1429 [DllImport ("gdiplus.dll")]
1430 internal static extern Status GdipGetStringFormatFlags(IntPtr format, out StringFormatFlags flags);
1431 [DllImport ("gdiplus.dll")]
1432 internal static extern Status GdipSetStringFormatAlign(IntPtr format, StringAlignment align);
1433 [DllImport ("gdiplus.dll")]
1434 internal static extern Status GdipGetStringFormatAlign(IntPtr format, out StringAlignment align);
1435 [DllImport ("gdiplus.dll")]
1436 internal static extern Status GdipSetStringFormatLineAlign(IntPtr format, StringAlignment align);
1437 [DllImport ("gdiplus.dll")]
1438 internal static extern Status GdipGetStringFormatLineAlign(IntPtr format, out StringAlignment align);
1439 [DllImport ("gdiplus.dll")]
1440 internal static extern Status GdipSetStringFormatTrimming(IntPtr format, StringTrimming trimming);
1441 [DllImport ("gdiplus.dll")]
1442 internal static extern Status GdipGetStringFormatTrimming(IntPtr format, out StringTrimming trimming);
1443 [DllImport ("gdiplus.dll")]
1444 internal static extern Status GdipSetStringFormatHotkeyPrefix(IntPtr format, HotkeyPrefix hotkeyPrefix);
1445 [DllImport ("gdiplus.dll")]
1446 internal static extern Status GdipGetStringFormatHotkeyPrefix(IntPtr format, out HotkeyPrefix hotkeyPrefix);
1447 [DllImport ("gdiplus.dll")]
1448 internal static extern Status GdipSetStringFormatTabStops(IntPtr format, float firstTabOffset, int count, float [] tabStops);
1449 [DllImport ("gdiplus.dll")]
1450 internal static extern Status GdipGetStringFormatDigitSubstitution(IntPtr format, int language, out StringDigitSubstitute substitute);
1451 [DllImport ("gdiplus.dll")]
1452 internal static extern Status GdipSetStringFormatDigitSubstitution(IntPtr format, int language, StringDigitSubstitute substitute);
1453 [DllImport ("gdiplus.dll")]
1454 internal static extern Status GdipGetStringFormatTabStopCount(IntPtr format, out int count);
1455 [DllImport ("gdiplus.dll")]
1456 internal static extern Status GdipGetStringFormatTabStops(IntPtr format, int count, out float firstTabOffset, [In, Out] float [] tabStops);
1458 //ImageCodecInfo functions
1459 [DllImport("gdiplus.dll")]
1460 static internal extern Status GdipGetImageDecodersSize (out int decoderNums, out int arraySize);
1461 [DllImport("gdiplus.dll")]
1462 static internal extern Status GdipGetImageDecoders (int decoderNums, int arraySize, IntPtr decoders);
1463 [DllImport("gdiplus.dll")]
1464 static internal extern Status GdipGetImageEncodersSize (out int encoderNums, out int arraySize);
1465 [DllImport("gdiplus.dll")]
1466 static internal extern Status GdipGetImageEncoders (int encoderNums, int arraySize, IntPtr encoders);
1469 // These are stuff that is unix-only
1471 public delegate int StreamGetBytesDelegate (IntPtr buf, int bufsz, bool peek);
1472 public delegate long StreamSeekDelegate (int offset, int whence);
1473 public delegate int StreamPutBytesDelegate (IntPtr buf, int bufsz);
1474 public delegate void StreamCloseDelegate ();
1475 public delegate long StreamSizeDelegate ();
1477 internal class GdiPlusStreamHelper
1479 public Stream stream;
1481 public GdiPlusStreamHelper (Stream s)
1483 stream = s;
1484 if (stream != null && stream.CanSeek)
1485 stream.Seek (0, SeekOrigin.Begin);
1488 public int StreamGetBytesImpl (IntPtr buf, int bufsz, bool peek)
1490 if (buf == IntPtr.Zero && peek)
1491 return -1;
1493 byte[] managedBuf = new byte[bufsz];
1494 int bytesReturn = 0;
1495 int bytesRead = 0;
1496 long streamPosition = 0;
1498 if (bufsz > 0) {
1499 streamPosition = stream.Position;
1500 try {
1501 bytesRead = stream.Read (managedBuf, 0, bufsz);
1502 } catch (IOException) {
1503 return -1;
1506 if (bytesRead > 0 && buf != IntPtr.Zero) {
1507 Marshal.Copy (managedBuf, 0, (IntPtr) (buf.ToInt64() + bytesReturn), bytesRead);
1510 if (peek) {
1511 // If we are peeking bytes, then go back to original position before peeking
1512 stream.Seek (streamPosition, SeekOrigin.Begin);
1515 bytesReturn += bytesRead;
1518 return bytesReturn;
1521 public StreamGetBytesDelegate GetBytesDelegate {
1522 get {
1523 if (stream != null && stream.CanRead)
1524 return new StreamGetBytesDelegate (StreamGetBytesImpl);
1525 return null;
1529 public long StreamSeekImpl (int offset, int whence)
1531 long retOffset;
1532 if (whence == 0) {
1533 retOffset = stream.Seek ((long) offset, SeekOrigin.Begin);
1534 } else if (whence == 1) {
1535 retOffset = stream.Seek ((long) offset, SeekOrigin.Current);
1536 } else if (whence == 2) {
1537 retOffset = stream.Seek ((long) offset, SeekOrigin.End);
1538 } else {
1539 retOffset = -1;
1542 return retOffset;
1545 public StreamSeekDelegate SeekDelegate {
1546 get {
1547 if (stream != null && stream.CanSeek)
1548 return new StreamSeekDelegate (StreamSeekImpl);
1549 return null;
1553 public int StreamPutBytesImpl (IntPtr buf, int bufsz)
1555 byte[] managedBuf = new byte[bufsz];
1556 Marshal.Copy (buf, managedBuf, 0, bufsz);
1557 stream.Write (managedBuf, 0, bufsz);
1558 return bufsz;
1561 public StreamPutBytesDelegate PutBytesDelegate {
1562 get {
1563 if (stream != null && stream.CanWrite)
1564 return new StreamPutBytesDelegate (StreamPutBytesImpl);
1565 return null;
1569 public void StreamCloseImpl ()
1571 stream.Close ();
1574 public StreamCloseDelegate CloseDelegate {
1575 get {
1576 if (stream != null)
1577 return new StreamCloseDelegate (StreamCloseImpl);
1578 return null;
1582 public long StreamSizeImpl ()
1584 return stream.Length;
1587 public StreamSizeDelegate SizeDelegate {
1588 get {
1589 if (stream != null)
1590 return new StreamSizeDelegate (StreamSizeImpl);
1591 return null;
1597 /* Linux only function calls*/
1598 [DllImport("gdiplus.dll")]
1599 internal static extern Status GdipSetVisibleClip_linux (IntPtr graphics, ref Rectangle rect);
1601 [DllImport("gdiplus.dll")]
1602 internal static extern Status GdipCreateFromXDrawable_linux (IntPtr drawable, IntPtr display, out IntPtr graphics);
1604 [DllImport("gdiplus.dll")]
1605 static internal extern Status GdipLoadImageFromDelegate_linux ( StreamGetBytesDelegate getBytes, StreamPutBytesDelegate putBytes,
1606 StreamSeekDelegate doSeek, StreamCloseDelegate close, StreamSizeDelegate size, out IntPtr image);
1607 [DllImport("gdiplus.dll")]
1608 static internal extern Status GdipSaveImageToDelegate_linux ( IntPtr image, StreamGetBytesDelegate getBytes, StreamPutBytesDelegate putBytes,
1609 StreamSeekDelegate doSeek, StreamCloseDelegate close, StreamSizeDelegate size, ref Guid encoderClsID, IntPtr encoderParameters );
1611 #endregion