2 // System.Drawing.gdipFunctions.cs
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)
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:
20 // The above copyright notice and this permission notice shall be
21 // included in all copies or substantial portions of the Software.
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.
34 using System.Runtime.InteropServices;
36 using System.Drawing.Drawing2D;
37 using System.Drawing.Imaging;
38 using System.Drawing.Text;
39 using System.Security;
41 using System.Runtime.InteropServices.ComTypes;
43 using IStream = System.Runtime.InteropServices.UCOMIStream;
46 namespace System.Drawing
49 /// GDI+ API Functions
51 [SuppressUnmanagedCodeSecurity]
52 internal class GDIPlus
54 public const int FACESIZE = 32;
55 public const int LANG_NEUTRAL = 0;
56 public static IntPtr Display = IntPtr.Zero;
57 public static bool UseX11Drawable;
58 public static bool UseQuartzDrawable = (Environment.GetEnvironmentVariable ("MONO_MWF_USE_QUARTZ_BACKEND") != null);
59 public static bool UseCocoaDrawable = (Environment.GetEnvironmentVariable ("MONO_GDIP_USE_COCOA_BACKEND") != null);
61 #region gdiplus.dll functions
64 [DllImport("gdiplus.dll")]
65 static internal extern Status GdiplusStartup(ref ulong token, ref GdiplusStartupInput input, ref GdiplusStartupOutput output);
66 [DllImport("gdiplus.dll")]
67 static internal extern void GdiplusShutdown(ref ulong token);
69 static ulong GdiPlusToken;
71 static void ProcessExit (object sender, EventArgs e)
73 // Called all pending objects and claim any pending handle before
76 GC.WaitForPendingFinalizers ();
78 // This causes crashes in MS GDI+ because this call occurs before
79 // all managed GDI objects are finalized. When they are finalized they call
80 // into a shutdown GDI+ and we crash.
81 //GdiplusShutdown (ref GdiPlusToken);
83 // This causes crashes in Mono libgdiplus because this call
84 // occurs before all managed GDI objects are finalized
85 // When they are finalized they use the closed display and
87 //if (UseX11Drawable && Display != IntPtr.Zero) {
88 // XCloseDisplay (Display);
95 // check for Unix platforms - see FAQ for more details
96 // http://www.mono-project.com/FAQ:_Technical#How_to_detect_the_execution_platform_.3F
97 int platform = (int) Environment.OSVersion.Platform;
98 UseX11Drawable = ((platform == 4) || (platform == 128));
100 GdiplusStartupInput input = GdiplusStartupInput.MakeGdiplusStartupInput();
101 GdiplusStartupOutput output = GdiplusStartupOutput.MakeGdiplusStartupOutput();
102 GdiplusStartup (ref GdiPlusToken, ref input, ref output);
103 AppDomain.CurrentDomain.ProcessExit += new EventHandler (ProcessExit);
106 // Copies a Ptr to an array of Points and releases the memory
107 static public void FromUnManagedMemoryToPointI(IntPtr prt, Point [] pts)
109 int nPointSize = Marshal.SizeOf(pts[0]);
111 for (int i=0; i<pts.Length; i++, pos = new IntPtr (pos.ToInt64 () + nPointSize))
112 pts[i] = (Point) Marshal.PtrToStructure(pos, typeof(Point));
114 Marshal.FreeHGlobal(prt);
117 // Copies a Ptr to an array of Points and releases the memory
118 static public void FromUnManagedMemoryToPoint (IntPtr prt, PointF [] pts)
120 int nPointSize = Marshal.SizeOf(pts[0]);
122 for (int i=0; i<pts.Length; i++, pos = new IntPtr (pos.ToInt64 () + nPointSize))
123 pts[i] = (PointF) Marshal.PtrToStructure(pos, typeof(Point));
125 Marshal.FreeHGlobal(prt);
128 // Copies an array of Points to unmanaged memory
129 static public IntPtr FromPointToUnManagedMemoryI(Point [] pts)
131 int nPointSize = Marshal.SizeOf(pts[0]);
132 IntPtr dest = Marshal.AllocHGlobal(nPointSize* pts.Length);
134 for (int i=0; i<pts.Length; i++, pos = new IntPtr (pos.ToInt64 () + nPointSize))
135 Marshal.StructureToPtr(pts[i], pos, false);
140 // Copies a Ptr to an array of v and releases the memory
141 static public void FromUnManagedMemoryToRectangles (IntPtr prt, RectangleF [] pts)
143 int nPointSize = Marshal.SizeOf (pts[0]);
145 for (int i = 0; i < pts.Length; i++, pos = new IntPtr (pos.ToInt64 () + nPointSize))
146 pts[i] = (RectangleF) Marshal.PtrToStructure(pos, typeof(RectangleF));
148 Marshal.FreeHGlobal(prt);
151 // Copies an array of Points to unmanaged memory
152 static public IntPtr FromPointToUnManagedMemory(PointF [] pts)
154 int nPointSize = Marshal.SizeOf(pts[0]);
155 IntPtr dest = Marshal.AllocHGlobal(nPointSize* pts.Length);
157 for (int i=0; i<pts.Length; i++, pos = new IntPtr (pos.ToInt64 () + nPointSize))
158 Marshal.StructureToPtr(pts[i], pos, false);
163 // Converts a status into exception
164 static internal void CheckStatus (Status status)
171 // TODO: Add more status code mappings here
173 case Status.GenericError:
174 throw new Exception ("Generic Error.");
176 case Status.InvalidParameter:
177 throw new ArgumentException ("Invalid Parameter. A null reference or invalid value was found.");
179 case Status.OutOfMemory:
180 throw new OutOfMemoryException ("Out of memory.");
182 case Status.ObjectBusy:
183 throw new MemberAccessException ("Object busy.");
185 case Status.InsufficientBuffer:
186 throw new IO.InternalBufferOverflowException ("Insufficient buffer.");
188 case Status.PropertyNotSupported:
189 throw new NotSupportedException ("Property not supported.");
191 case Status.FileNotFound:
192 throw new IO.FileNotFoundException ("File not found.");
194 case Status.AccessDenied:
195 throw new UnauthorizedAccessException ("Access denied.");
197 case Status.UnknownImageFormat:
198 throw new NotSupportedException ("Either image format is unknown or you don't have the required libraries for this format.");
200 case Status.NotImplemented:
201 throw new NotImplementedException ("Feature not implemented.");
203 case Status.WrongState:
204 throw new ArgumentException ("Properties not set properly.");
207 throw new Exception ("Unknown Error.");
213 [DllImport("gdiplus.dll")]
214 static internal extern IntPtr GdipAlloc (int size);
215 [DllImport("gdiplus.dll")]
216 static internal extern void GdipFree (IntPtr ptr);
220 [DllImport("gdiplus.dll")]
221 static internal extern Status GdipCloneBrush (IntPtr brush, out IntPtr clonedBrush);
222 [DllImport("gdiplus.dll")]
223 static internal extern Status GdipDeleteBrush (IntPtr brush);
224 [DllImport("gdiplus.dll")]
225 static internal extern Status GdipGetBrushType (IntPtr brush, out BrushType type);
229 [DllImport("gdiplus.dll")]
230 static internal extern Status GdipCreateRegion (out IntPtr region);
232 [DllImport("gdiplus.dll")]
233 static internal extern Status GdipCreateRegionRgnData (byte[] data, int size, out IntPtr region);
235 [DllImport("gdiplus.dll")]
236 static internal extern Status GdipDeleteRegion (IntPtr region);
238 [DllImport("gdiplus.dll")]
239 static internal extern Status GdipCloneRegion (IntPtr region, out IntPtr cloned);
241 [DllImport("gdiplus.dll")]
242 static internal extern Status GdipCreateRegionRect (ref RectangleF rect, out IntPtr region);
244 [DllImport("gdiplus.dll")]
245 static internal extern Status GdipCreateRegionRectI (ref Rectangle rect, out IntPtr region);
247 [DllImport("gdiplus.dll")]
248 static internal extern Status GdipCreateRegionPath (IntPtr path, out IntPtr region);
250 [DllImport("gdiplus.dll")]
251 static internal extern Status GdipTranslateRegion (IntPtr region, float dx, float dy);
253 [DllImport("gdiplus.dll")]
254 static internal extern Status GdipTranslateRegionI (IntPtr region, int dx, int dy);
256 [DllImport("gdiplus.dll")]
257 static internal extern Status GdipIsVisibleRegionPoint (IntPtr region, float x, float y,
258 IntPtr graphics, out bool result);
260 [DllImport("gdiplus.dll")]
261 static internal extern Status GdipIsVisibleRegionPointI (IntPtr region, int x, int y,
262 IntPtr graphics, out bool result);
264 [DllImport("gdiplus.dll")]
265 static internal extern Status GdipIsVisibleRegionRect (IntPtr region, float x, float y, float width,
266 float height, IntPtr graphics, out bool result);
268 [DllImport("gdiplus.dll")]
269 static internal extern Status GdipIsVisibleRegionRectI (IntPtr region, int x, int y, int width,
270 int height, IntPtr graphics, out bool result);
273 [DllImport("gdiplus.dll")]
274 static internal extern Status GdipCombineRegionRect (IntPtr region, ref RectangleF rect,
275 CombineMode combineMode);
277 [DllImport("gdiplus.dll")]
278 static internal extern Status GdipCombineRegionRectI (IntPtr region, ref Rectangle rect,
279 CombineMode combineMode);
281 [DllImport("gdiplus.dll")]
282 static internal extern Status GdipCombineRegionPath (IntPtr region, IntPtr path, CombineMode combineMode);
284 [DllImport("gdiplus.dll")]
285 static internal extern Status GdipGetRegionBounds (IntPtr region, IntPtr graphics, ref RectangleF rect);
287 [DllImport("gdiplus.dll")]
288 static internal extern Status GdipSetInfinite (IntPtr region);
290 [DllImport("gdiplus.dll")]
291 static internal extern Status GdipSetEmpty (IntPtr region);
293 [DllImport("gdiplus.dll")]
294 static internal extern Status GdipIsEmptyRegion (IntPtr region, IntPtr graphics, out bool result);
296 [DllImport("gdiplus.dll")]
297 static internal extern Status GdipIsInfiniteRegion (IntPtr region, IntPtr graphics, out bool result);
299 [DllImport("gdiplus.dll")]
300 static internal extern Status GdipCombineRegionRegion (IntPtr region, IntPtr region2,
301 CombineMode combineMode);
303 [DllImport("gdiplus.dll")]
304 static internal extern Status GdipIsEqualRegion (IntPtr region, IntPtr region2,
305 IntPtr graphics, out bool result);
307 [DllImport("gdiplus.dll")]
308 static internal extern Status GdipGetRegionDataSize (IntPtr region, out int bufferSize);
310 [DllImport("gdiplus.dll")]
311 static internal extern Status GdipGetRegionData (IntPtr region, byte[] buffer, int bufferSize,
314 [DllImport("gdiplus.dll")]
315 static internal extern Status GdipGetRegionScansCount (IntPtr region, out int count, IntPtr matrix);
317 [DllImport("gdiplus.dll")]
318 static internal extern Status GdipGetRegionScans (IntPtr region, IntPtr rects, out int count,
321 [DllImport("gdiplus.dll")]
322 static internal extern Status GdipTransformRegion(IntPtr region, IntPtr matrix);
324 [DllImport("gdiplus.dll")]
325 static internal extern Status GdipFillRegion(IntPtr graphics, IntPtr brush, IntPtr region);
327 // Solid brush functions
328 [DllImport("gdiplus.dll")]
329 static internal extern Status GdipCreateSolidFill (int color, out IntPtr brush);
330 [DllImport("gdiplus.dll")]
331 static internal extern Status GdipGetSolidFillColor (IntPtr brush, out int color);
332 [DllImport("gdiplus.dll")]
333 static internal extern Status GdipSetSolidFillColor (IntPtr brush, int color);
335 // Hatch Brush functions
336 [DllImport("gdiplus.dll")]
337 static internal extern Status GdipCreateHatchBrush (HatchStyle hatchstyle, int foreColor, int backColor, out IntPtr brush);
338 [DllImport("gdiplus.dll")]
339 static internal extern Status GdipGetHatchStyle (IntPtr brush, out HatchStyle hatchstyle);
340 [DllImport("gdiplus.dll")]
341 static internal extern Status GdipGetHatchForegroundColor (IntPtr brush, out int foreColor);
342 [DllImport("gdiplus.dll")]
343 static internal extern Status GdipGetHatchBackgroundColor (IntPtr brush, out int backColor);
345 // Texture brush functions
346 [DllImport("gdiplus.dll")]
347 static internal extern Status GdipGetTextureImage (IntPtr texture, out IntPtr image);
348 [DllImport("gdiplus.dll")]
349 static internal extern Status GdipCreateTexture (IntPtr image, WrapMode wrapMode, out IntPtr texture);
350 [DllImport("gdiplus.dll")]
351 static internal extern Status GdipCreateTextureIAI (IntPtr image, IntPtr imageAttributes, int x, int y, int width, int height, out IntPtr texture);
352 [DllImport("gdiplus.dll")]
353 static internal extern Status GdipCreateTextureIA (IntPtr image, IntPtr imageAttributes, float x, float y, float width, float height, out IntPtr texture);
354 [DllImport("gdiplus.dll")]
355 static internal extern Status GdipCreateTexture2I (IntPtr image, WrapMode wrapMode, int x, int y, int width, int height, out IntPtr texture);
356 [DllImport("gdiplus.dll")]
357 static internal extern Status GdipCreateTexture2 (IntPtr image, WrapMode wrapMode, float x, float y, float width, float height, out IntPtr texture);
358 [DllImport("gdiplus.dll")]
359 static internal extern Status GdipGetTextureTransform (IntPtr texture, IntPtr matrix);
360 [DllImport("gdiplus.dll")]
361 static internal extern Status GdipSetTextureTransform (IntPtr texture, IntPtr matrix);
362 [DllImport("gdiplus.dll")]
363 static internal extern Status GdipGetTextureWrapMode (IntPtr texture, out WrapMode wrapMode);
364 [DllImport("gdiplus.dll")]
365 static internal extern Status GdipSetTextureWrapMode (IntPtr texture, WrapMode wrapMode);
366 [DllImport("gdiplus.dll")]
367 static internal extern Status GdipMultiplyTextureTransform (IntPtr texture, IntPtr matrix, MatrixOrder order);
368 [DllImport("gdiplus.dll")]
369 static internal extern Status GdipResetTextureTransform (IntPtr texture);
370 [DllImport("gdiplus.dll")]
371 static internal extern Status GdipRotateTextureTransform (IntPtr texture, float angle, MatrixOrder order);
372 [DllImport("gdiplus.dll")]
373 static internal extern Status GdipScaleTextureTransform (IntPtr texture, float sx, float sy, MatrixOrder order);
374 [DllImport("gdiplus.dll")]
375 static internal extern Status GdipTranslateTextureTransform (IntPtr texture, float dx, float dy, MatrixOrder order);
377 // PathGradientBrush functions
378 [DllImport("gdiplus.dll")]
379 static internal extern Status GdipCreatePathGradientFromPath (IntPtr path, out IntPtr brush);
380 [DllImport("gdiplus.dll")]
381 static internal extern Status GdipCreatePathGradientI (Point [] points, int count, WrapMode wrapMode, out IntPtr brush);
382 [DllImport("gdiplus.dll")]
383 static internal extern Status GdipCreatePathGradient (PointF [] points, int count, WrapMode wrapMode, out IntPtr brush);
384 [DllImport("gdiplus.dll")]
385 static internal extern Status GdipGetPathGradientBlendCount (IntPtr brush, out int count);
386 [DllImport("gdiplus.dll")]
387 static internal extern Status GdipGetPathGradientBlend (IntPtr brush, float [] blend, float [] positions, int count);
388 [DllImport("gdiplus.dll")]
389 static internal extern Status GdipSetPathGradientBlend (IntPtr brush, float [] blend, float [] positions, int count);
390 [DllImport("gdiplus.dll")]
391 static internal extern Status GdipGetPathGradientCenterColor (IntPtr brush, out int color);
392 [DllImport("gdiplus.dll")]
393 static internal extern Status GdipSetPathGradientCenterColor (IntPtr brush, int color);
394 [DllImport("gdiplus.dll")]
395 static internal extern Status GdipGetPathGradientCenterPoint (IntPtr brush, out PointF point);
396 [DllImport("gdiplus.dll")]
397 static internal extern Status GdipSetPathGradientCenterPoint (IntPtr brush, ref PointF point);
398 [DllImport("gdiplus.dll")]
399 static internal extern Status GdipGetPathGradientFocusScales (IntPtr brush, out float xScale, out float yScale);
400 [DllImport("gdiplus.dll")]
401 static internal extern Status GdipSetPathGradientFocusScales (IntPtr brush, float xScale, float yScale);
402 [DllImport("gdiplus.dll")]
403 static internal extern Status GdipGetPathGradientPresetBlendCount (IntPtr brush, out int count);
404 [DllImport("gdiplus.dll")]
405 static internal extern Status GdipGetPathGradientPresetBlend (IntPtr brush, int [] blend, float [] positions, int count);
406 [DllImport("gdiplus.dll")]
407 static internal extern Status GdipSetPathGradientPresetBlend (IntPtr brush, int [] blend, float [] positions, int count);
408 [DllImport("gdiplus.dll")]
409 static internal extern Status GdipGetPathGradientRect (IntPtr brush, out RectangleF rect);
410 [DllImport("gdiplus.dll")]
411 static internal extern Status GdipGetPathGradientSurroundColorCount (IntPtr brush, out int count);
412 [DllImport("gdiplus.dll")]
413 static internal extern Status GdipGetPathGradientSurroundColorsWithCount (IntPtr brush, int [] color, ref int count);
414 [DllImport("gdiplus.dll")]
415 static internal extern Status GdipSetPathGradientSurroundColorsWithCount (IntPtr brush, int [] color, ref int count);
416 [DllImport("gdiplus.dll")]
417 static internal extern Status GdipGetPathGradientTransform (IntPtr brush, IntPtr matrix);
418 [DllImport("gdiplus.dll")]
419 static internal extern Status GdipSetPathGradientTransform (IntPtr brush, IntPtr matrix);
420 [DllImport("gdiplus.dll")]
421 static internal extern Status GdipGetPathGradientWrapMode (IntPtr brush, out WrapMode wrapMode);
422 [DllImport("gdiplus.dll")]
423 static internal extern Status GdipSetPathGradientWrapMode (IntPtr brush, WrapMode wrapMode);
424 [DllImport("gdiplus.dll")]
425 static internal extern Status GdipSetPathGradientLinearBlend (IntPtr brush, float focus, float scale);
426 [DllImport("gdiplus.dll")]
427 static internal extern Status GdipSetPathGradientSigmaBlend (IntPtr brush, float focus, float scale);
428 [DllImport("gdiplus.dll")]
429 static internal extern Status GdipMultiplyPathGradientTransform (IntPtr texture, IntPtr matrix, MatrixOrder order);
430 [DllImport("gdiplus.dll")]
431 static internal extern Status GdipResetPathGradientTransform (IntPtr brush);
432 [DllImport("gdiplus.dll")]
433 static internal extern Status GdipRotatePathGradientTransform (IntPtr brush, float angle, MatrixOrder order);
434 [DllImport("gdiplus.dll")]
435 static internal extern Status GdipScalePathGradientTransform (IntPtr brush, float sx, float sy, MatrixOrder order);
436 [DllImport("gdiplus.dll")]
437 static internal extern Status GdipTranslatePathGradientTransform (IntPtr brush, float dx, float dy, MatrixOrder order);
439 // LinearGradientBrush functions
440 [DllImport("gdiplus.dll")]
441 static internal extern Status GdipCreateLineBrushI (ref Point point1, ref Point point2, int color1, int color2, WrapMode wrapMode, out IntPtr brush);
442 [DllImport("gdiplus.dll")]
443 static internal extern Status GdipCreateLineBrush (ref PointF point1, ref PointF point2, int color1, int color2, WrapMode wrapMode, out IntPtr brush);
444 [DllImport("gdiplus.dll")]
445 static internal extern Status GdipCreateLineBrushFromRectI (ref Rectangle rect, int color1, int color2, LinearGradientMode linearGradientMode, WrapMode wrapMode, out IntPtr brush);
446 [DllImport("gdiplus.dll")]
447 static internal extern Status GdipCreateLineBrushFromRect (ref RectangleF rect, int color1, int color2, LinearGradientMode linearGradientMode, WrapMode wrapMode, out IntPtr brush);
448 [DllImport("gdiplus.dll")]
449 static internal extern Status GdipCreateLineBrushFromRectWithAngleI (ref Rectangle rect, int color1, int color2, float angle, bool isAngleScaleable, WrapMode wrapMode, out IntPtr brush);
450 [DllImport("gdiplus.dll")]
451 static internal extern Status GdipCreateLineBrushFromRectWithAngle (ref RectangleF rect, int color1, int color2, float angle, bool isAngleScaleable, WrapMode wrapMode, out IntPtr brush);
452 [DllImport("gdiplus.dll")]
453 static internal extern Status GdipGetLineBlendCount (IntPtr brush, out int count);
454 [DllImport("gdiplus.dll")]
455 static internal extern Status GdipSetLineBlend (IntPtr brush, float [] blend, float [] positions, int count);
456 [DllImport("gdiplus.dll")]
457 static internal extern Status GdipGetLineBlend (IntPtr brush, float [] blend, float [] positions, int count);
458 [DllImport("gdiplus.dll")]
459 static internal extern Status GdipSetLineGammaCorrection (IntPtr brush, bool useGammaCorrection);
460 [DllImport("gdiplus.dll")]
461 static internal extern Status GdipGetLineGammaCorrection (IntPtr brush, out bool useGammaCorrection);
462 [DllImport("gdiplus.dll")]
463 static internal extern Status GdipGetLinePresetBlendCount (IntPtr brush, out int count);
464 [DllImport("gdiplus.dll")]
465 static internal extern Status GdipSetLinePresetBlend (IntPtr brush, int [] blend, float [] positions, int count);
466 [DllImport("gdiplus.dll")]
467 static internal extern Status GdipGetLinePresetBlend (IntPtr brush, int [] blend, float [] positions, int count);
468 [DllImport("gdiplus.dll")]
469 static internal extern Status GdipSetLineColors (IntPtr brush, int color1, int color2);
470 [DllImport("gdiplus.dll")]
471 static internal extern Status GdipGetLineColors (IntPtr brush, int [] colors);
472 [DllImport("gdiplus.dll")]
473 static internal extern Status GdipGetLineRectI (IntPtr brush, out Rectangle rect);
474 [DllImport("gdiplus.dll")]
475 static internal extern Status GdipGetLineRect (IntPtr brush, out RectangleF rect);
476 [DllImport("gdiplus.dll")]
477 static internal extern Status GdipSetLineTransform (IntPtr brush, IntPtr matrix);
478 [DllImport("gdiplus.dll")]
479 static internal extern Status GdipGetLineTransform (IntPtr brush, IntPtr matrix);
480 [DllImport("gdiplus.dll")]
481 static internal extern Status GdipSetLineWrapMode (IntPtr brush, WrapMode wrapMode);
482 [DllImport("gdiplus.dll")]
483 static internal extern Status GdipGetLineWrapMode (IntPtr brush, out WrapMode wrapMode);
484 [DllImport("gdiplus.dll")]
485 static internal extern Status GdipSetLineLinearBlend (IntPtr brush, float focus, float scale);
486 [DllImport("gdiplus.dll")]
487 static internal extern Status GdipSetLineSigmaBlend (IntPtr brush, float focus, float scale);
488 [DllImport("gdiplus.dll")]
489 static internal extern Status GdipMultiplyLineTransform (IntPtr brush, IntPtr matrix, MatrixOrder order);
490 [DllImport("gdiplus.dll")]
491 static internal extern Status GdipResetLineTransform (IntPtr brush);
492 [DllImport("gdiplus.dll")]
493 static internal extern Status GdipRotateLineTransform (IntPtr brush, float angle, MatrixOrder order);
494 [DllImport("gdiplus.dll")]
495 static internal extern Status GdipScaleLineTransform (IntPtr brush, float sx, float sy, MatrixOrder order);
496 [DllImport("gdiplus.dll")]
497 static internal extern Status GdipTranslateLineTransform (IntPtr brush, float dx, float dy, MatrixOrder order);
499 // Graphics functions
500 [DllImport("gdiplus.dll")]
501 static internal extern Status GdipCreateFromHDC(IntPtr hDC, out IntPtr graphics);
502 [DllImport("gdiplus.dll")]
503 static internal extern Status GdipDeleteGraphics(IntPtr graphics);
504 [DllImport("gdiplus.dll")]
505 static internal extern Status GdipRestoreGraphics(IntPtr graphics, uint graphicsState);
506 [DllImport("gdiplus.dll")]
507 static internal extern Status GdipSaveGraphics(IntPtr graphics, out uint state);
508 [DllImport("gdiplus.dll")]
509 static internal extern Status GdipMultiplyWorldTransform (IntPtr graphics, IntPtr matrix, MatrixOrder order);
511 [DllImport("gdiplus.dll")]
512 static internal extern Status GdipRotateWorldTransform(IntPtr graphics, float angle, MatrixOrder order);
513 [DllImport("gdiplus.dll")]
514 static internal extern Status GdipTranslateWorldTransform(IntPtr graphics, float dx, float dy, MatrixOrder order);
515 [DllImport("gdiplus.dll")]
516 static internal extern Status GdipDrawArc (IntPtr graphics, IntPtr pen, float x, float y, float width, float height, float startAngle, float sweepAngle);
517 [DllImport("gdiplus.dll")]
518 static internal extern Status GdipDrawArcI (IntPtr graphics, IntPtr pen, int x, int y, int width, int height, float startAngle, float sweepAngle);
519 [DllImport("gdiplus.dll")]
520 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);
521 [DllImport("gdiplus.dll")]
522 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);
523 [DllImport("gdiplus.dll")]
524 static internal extern Status GdipDrawEllipseI (IntPtr graphics, IntPtr pen, int x, int y, int width, int height);
525 [DllImport("gdiplus.dll")]
526 static internal extern Status GdipDrawEllipse (IntPtr graphics, IntPtr pen, float x, float y, float width, float height);
527 [DllImport("gdiplus.dll")]
528 static internal extern Status GdipDrawLine (IntPtr graphics, IntPtr pen, float x1, float y1, float x2, float y2);
529 [DllImport("gdiplus.dll")]
530 static internal extern Status GdipDrawLineI (IntPtr graphics, IntPtr pen, int x1, int y1, int x2, int y2);
531 [DllImport ("gdiplus.dll")]
532 static internal extern Status GdipDrawLines (IntPtr graphics, IntPtr pen, PointF [] points, int count);
533 [DllImport ("gdiplus.dll")]
534 static internal extern Status GdipDrawLinesI (IntPtr graphics, IntPtr pen, Point [] points, int count);
535 [DllImport ("gdiplus.dll")]
536 static internal extern Status GdipDrawPath (IntPtr graphics, IntPtr pen, IntPtr path);
537 [DllImport ("gdiplus.dll")]
538 static internal extern Status GdipDrawPie (IntPtr graphics, IntPtr pen, float x, float y, float width, float height, float startAngle, float sweepAngle);
539 [DllImport ("gdiplus.dll")]
540 static internal extern Status GdipDrawPieI (IntPtr graphics, IntPtr pen, int x, int y, int width, int height, float startAngle, float sweepAngle);
541 [DllImport ("gdiplus.dll")]
542 static internal extern Status GdipDrawPolygon (IntPtr graphics, IntPtr pen, PointF [] points, int count);
543 [DllImport ("gdiplus.dll")]
544 static internal extern Status GdipDrawPolygonI (IntPtr graphics, IntPtr pen, Point [] points, int count);
545 [DllImport ("gdiplus.dll")]
546 static internal extern Status GdipDrawRectangle (IntPtr graphics, IntPtr pen, float x, float y, float width, float height);
547 [DllImport ("gdiplus.dll")]
548 static internal extern Status GdipDrawRectangleI (IntPtr graphics, IntPtr pen, int x, int y, int width, int height);
549 [DllImport ("gdiplus.dll")]
550 static internal extern Status GdipDrawRectangles (IntPtr graphics, IntPtr pen, RectangleF [] rects, int count);
551 [DllImport ("gdiplus.dll")]
552 static internal extern Status GdipDrawRectanglesI (IntPtr graphics, IntPtr pen, Rectangle [] rects, int count);
553 [DllImport("gdiplus.dll")]
554 static internal extern Status GdipFillEllipseI (IntPtr graphics, IntPtr pen, int x, int y, int width, int height);
555 [DllImport("gdiplus.dll")]
556 static internal extern Status GdipFillEllipse (IntPtr graphics, IntPtr pen, float x, float y, float width, float height);
557 [DllImport ("gdiplus.dll")]
558 static internal extern Status GdipFillPolygon (IntPtr graphics, IntPtr brush, PointF [] points, int count, FillMode fillMode);
559 [DllImport ("gdiplus.dll")]
560 static internal extern Status GdipFillPolygonI (IntPtr graphics, IntPtr brush, Point [] points, int count, FillMode fillMode);
561 [DllImport ("gdiplus.dll")]
562 static internal extern Status GdipFillPolygon2 (IntPtr graphics, IntPtr brush, PointF [] points, int count);
563 [DllImport ("gdiplus.dll")]
564 static internal extern Status GdipFillPolygon2I (IntPtr graphics, IntPtr brush, Point [] points, int count);
565 [DllImport("gdiplus.dll")]
566 static internal extern Status GdipFillRectangle (IntPtr graphics, IntPtr brush, float x1, float y1, float x2, float y2);
567 [DllImport("gdiplus.dll")]
568 static internal extern Status GdipFillRectangleI (IntPtr graphics, IntPtr brush, int x1, int y1, int x2, int y2);
569 [DllImport("gdiplus.dll")]
570 static internal extern Status GdipFillRectangles (IntPtr graphics, IntPtr brush, RectangleF [] rects, int count);
571 [DllImport("gdiplus.dll")]
572 static internal extern Status GdipFillRectanglesI (IntPtr graphics, IntPtr brush, Rectangle [] rects, int count);
573 [DllImport("gdiplus.dll", CharSet=CharSet.Unicode)]
574 static internal extern Status GdipDrawString (IntPtr graphics, string text, int len, IntPtr font, ref RectangleF rc, IntPtr format, IntPtr brush);
575 [DllImport("gdiplus.dll")]
576 static internal extern Status GdipGetDC (IntPtr graphics, out IntPtr hdc);
577 [DllImport("gdiplus.dll")]
578 static internal extern Status GdipReleaseDC (IntPtr graphics, IntPtr hdc);
579 [DllImport("gdiplus.dll")]
580 static internal extern Status GdipDrawImageRectI (IntPtr graphics, IntPtr image, int x, int y, int width, int height);
581 [DllImport ("gdiplus.dll")]
582 static internal extern Status GdipGetRenderingOrigin (IntPtr graphics, out int x, out int y);
583 [DllImport ("gdiplus.dll")]
584 static internal extern Status GdipSetRenderingOrigin (IntPtr graphics, int x, int y);
585 [DllImport("gdiplus.dll")]
586 internal static extern Status GdipCloneBitmapArea (float x, float y, float width, float height, PixelFormat format, IntPtr original, out IntPtr bitmap);
587 [DllImport("gdiplus.dll")]
588 internal static extern Status GdipCloneBitmapAreaI (int x, int y, int width, int height, PixelFormat format, IntPtr original, out IntPtr bitmap);
589 [DllImport("gdiplus.dll")]
590 internal static extern Status GdipResetWorldTransform (IntPtr graphics);
591 [DllImport("gdiplus.dll")]
592 internal static extern Status GdipSetWorldTransform (IntPtr graphics, IntPtr matrix);
593 [DllImport("gdiplus.dll")]
594 internal static extern Status GdipGetWorldTransform (IntPtr graphics, IntPtr matrix);
595 [DllImport("gdiplus.dll")]
596 internal static extern Status GdipScaleWorldTransform (IntPtr graphics, float sx, float sy, MatrixOrder order);
597 [DllImport("gdiplus.dll")]
598 internal static extern Status GdipGraphicsClear(IntPtr graphics, int argb);
599 [DllImport("gdiplus.dll")]
600 internal static extern Status GdipDrawClosedCurve(IntPtr graphics, IntPtr pen, PointF [] points, int count);
601 [DllImport("gdiplus.dll")]
602 internal static extern Status GdipDrawClosedCurveI(IntPtr graphics, IntPtr pen, Point [] points, int count);
603 [DllImport("gdiplus.dll")]
604 internal static extern Status GdipDrawClosedCurve2(IntPtr graphics, IntPtr pen, PointF [] points, int count, float tension);
605 [DllImport("gdiplus.dll")]
606 internal static extern Status GdipDrawClosedCurve2I(IntPtr graphics, IntPtr pen, Point [] points, int count, float tension);
607 [DllImport("gdiplus.dll")]
608 internal static extern Status GdipDrawCurve(IntPtr graphics, IntPtr pen, PointF [] points, int count);
609 [DllImport("gdiplus.dll")]
610 internal static extern Status GdipDrawCurveI(IntPtr graphics, IntPtr pen, Point [] points, int count);
611 [DllImport("gdiplus.dll")]
612 internal static extern Status GdipDrawCurve2(IntPtr graphics, IntPtr pen, PointF [] points, int count, float tension);
613 [DllImport("gdiplus.dll")]
614 internal static extern Status GdipDrawCurve2I(IntPtr graphics, IntPtr pen, Point [] points, int count, float tension);
615 [DllImport("gdiplus.dll")]
616 internal static extern Status GdipDrawCurve3(IntPtr graphics, IntPtr pen, PointF [] points, int count, int offset, int numberOfSegments, float tension);
617 [DllImport("gdiplus.dll")]
618 internal static extern Status GdipDrawCurve3I(IntPtr graphics, IntPtr pen, Point [] points, int count, int offset, int numberOfSegments, float tension);
619 [DllImport("gdiplus.dll")]
620 internal static extern Status GdipSetClipRect(IntPtr graphics, float x, float y, float width, float height, CombineMode combineMode);
621 [DllImport("gdiplus.dll")]
622 internal static extern Status GdipSetClipRectI(IntPtr graphics, int x, int y, int width, int height, CombineMode combineMode);
623 [DllImport("gdiplus.dll")]
624 internal static extern Status GdipSetClipPath(IntPtr graphics, IntPtr path, CombineMode combineMode);
625 [DllImport("gdiplus.dll")]
626 internal static extern Status GdipSetClipRegion(IntPtr graphics, IntPtr region, CombineMode combineMode);
627 [DllImport("gdiplus.dll")]
628 internal static extern Status GdipSetClipGraphics(IntPtr graphics, IntPtr srcgraphics, CombineMode combineMode);
629 [DllImport("gdiplus.dll")]
630 internal static extern Status GdipResetClip(IntPtr graphics);
631 [DllImport("gdiplus.dll")]
632 internal static extern Status GdipEndContainer(IntPtr graphics, int state);
633 [DllImport("gdiplus.dll")]
634 internal static extern Status GdipGetClip (IntPtr graphics, IntPtr region);
636 [DllImport("gdiplus.dll")]
637 internal static extern Status GdipFillClosedCurve(IntPtr graphics, IntPtr brush, PointF [] points, int count);
639 [DllImport("gdiplus.dll")]
640 internal static extern Status GdipFillClosedCurveI(IntPtr graphics, IntPtr brush, Point [] points, int count);
642 [DllImport("gdiplus.dll")]
643 internal static extern Status GdipFillClosedCurve2(IntPtr graphics, IntPtr brush,
644 PointF [] points, int count, float tension, FillMode fillMode);
646 [DllImport("gdiplus.dll")]
647 internal static extern Status GdipFillClosedCurve2I(IntPtr graphics, IntPtr brush,
648 Point [] points, int count, float tension, FillMode fillMode);
650 [DllImport("gdiplus.dll")]
651 internal static extern Status GdipFillPie(IntPtr graphics, IntPtr brush, float x, float y,
652 float width, float height, float startAngle, float sweepAngle);
654 [DllImport("gdiplus.dll")]
655 internal static extern Status GdipFillPieI(IntPtr graphics, IntPtr brush, int x, int y,
656 int width, int height, float startAngle, float sweepAngle);
658 [DllImport("gdiplus.dll")]
659 internal static extern Status GdipFillPath(IntPtr graphics, IntPtr brush, IntPtr path);
661 [DllImport("gdiplus.dll")]
662 internal static extern Status GdipGetNearestColor(IntPtr graphics, out int argb);
664 [DllImport("gdiplus.dll")]
665 internal static extern Status GdipIsVisiblePoint(IntPtr graphics, float x, float y, out bool result);
667 [DllImport("gdiplus.dll")]
668 internal static extern Status GdipIsVisiblePointI(IntPtr graphics, int x, int y, out bool result);
670 [DllImport("gdiplus.dll")]
671 internal static extern Status GdipIsVisibleRect(IntPtr graphics, float x, float y,
672 float width, float height, out bool result);
674 [DllImport("gdiplus.dll")]
675 internal static extern Status GdipIsVisibleRectI(IntPtr graphics, int x, int y,
676 int width, int height, out bool result);
678 [DllImport("gdiplus.dll")]
679 internal static extern Status GdipTransformPoints(IntPtr graphics, CoordinateSpace destSpace,
680 CoordinateSpace srcSpace, IntPtr points, int count);
682 [DllImport("gdiplus.dll")]
683 internal static extern Status GdipTransformPointsI(IntPtr graphics, CoordinateSpace destSpace,
684 CoordinateSpace srcSpace, IntPtr points, int count);
686 [DllImport("gdiplus.dll")]
687 internal static extern Status GdipTranslateClip(IntPtr graphics, float dx, float dy);
688 [DllImport("gdiplus.dll")]
689 internal static extern Status GdipTranslateClipI(IntPtr graphics, int dx, int dy);
690 [DllImport("gdiplus.dll")]
691 internal static extern Status GdipGetClipBounds(IntPtr graphics, out RectangleF rect);
692 [DllImport("gdiplus.dll")]
693 internal static extern Status GdipSetCompositingMode(IntPtr graphics, CompositingMode compositingMode);
694 [DllImport("gdiplus.dll")]
695 internal static extern Status GdipGetCompositingMode(IntPtr graphics, out CompositingMode compositingMode);
696 [DllImport("gdiplus.dll")]
697 internal static extern Status GdipSetCompositingQuality(IntPtr graphics, CompositingQuality compositingQuality);
698 [DllImport("gdiplus.dll")]
699 internal static extern Status GdipGetCompositingQuality(IntPtr graphics, out CompositingQuality compositingQuality);
700 [DllImport("gdiplus.dll")]
701 internal static extern Status GdipSetInterpolationMode(IntPtr graphics, InterpolationMode interpolationMode);
702 [DllImport("gdiplus.dll")]
703 internal static extern Status GdipGetInterpolationMode(IntPtr graphics, out InterpolationMode interpolationMode);
704 [DllImport("gdiplus.dll")]
705 internal static extern Status GdipGetDpiX(IntPtr graphics, out float dpi);
706 [DllImport("gdiplus.dll")]
707 internal static extern Status GdipGetDpiY(IntPtr graphics, out float dpi);
708 [DllImport("gdiplus.dll")]
709 internal static extern Status GdipIsClipEmpty(IntPtr graphics, out bool result);
710 [DllImport("gdiplus.dll")]
711 internal static extern Status GdipIsVisibleClipEmpty(IntPtr graphics, out bool result);
712 [DllImport("gdiplus.dll")]
713 internal static extern Status GdipGetPageUnit(IntPtr graphics, out GraphicsUnit unit);
714 [DllImport("gdiplus.dll")]
715 internal static extern Status GdipGetPageScale(IntPtr graphics, out float scale);
716 [DllImport("gdiplus.dll")]
717 internal static extern Status GdipSetPageUnit(IntPtr graphics, GraphicsUnit unit);
718 [DllImport("gdiplus.dll")]
719 internal static extern Status GdipSetPageScale(IntPtr graphics, float scale);
720 [DllImport("gdiplus.dll")]
721 internal static extern Status GdipSetPixelOffsetMode(IntPtr graphics, PixelOffsetMode pixelOffsetMode);
722 [DllImport("gdiplus.dll")]
723 internal static extern Status GdipGetPixelOffsetMode(IntPtr graphics, out PixelOffsetMode pixelOffsetMode);
724 [DllImport("gdiplus.dll")]
725 internal static extern Status GdipSetSmoothingMode(IntPtr graphics, SmoothingMode smoothingMode);
726 [DllImport("gdiplus.dll")]
727 internal static extern Status GdipGetSmoothingMode(IntPtr graphics, out SmoothingMode smoothingMode);
728 [DllImport("gdiplus.dll")]
729 internal static extern Status GdipSetTextContrast(IntPtr graphics, int contrast);
730 [DllImport("gdiplus.dll")]
731 internal static extern Status GdipGetTextContrast(IntPtr graphics, out int contrast);
732 [DllImport("gdiplus.dll")]
733 internal static extern Status GdipSetTextRenderingHint(IntPtr graphics, TextRenderingHint mode);
734 [DllImport("gdiplus.dll")]
735 internal static extern Status GdipGetTextRenderingHint(IntPtr graphics, out TextRenderingHint mode);
736 [DllImport("gdiplus.dll")]
737 internal static extern Status GdipGetVisibleClipBounds(IntPtr graphics, out RectangleF rect);
739 [DllImport("gdiplus.dll")]
740 internal static extern Status GdipFlush(IntPtr graphics, FlushIntention intention);
744 [DllImport("gdiplus.dll")]
745 internal static extern Status GdipCreatePen1 (int argb, float width, Unit unit, out IntPtr pen);
746 [DllImport("gdiplus.dll")]
747 internal static extern Status GdipCreatePen2 (IntPtr brush, float width, Unit unit, out IntPtr pen);
748 [DllImport("gdiplus.dll")]
749 internal static extern Status GdipClonePen (IntPtr pen, out IntPtr clonepen);
750 [DllImport("gdiplus.dll")]
751 internal static extern Status GdipDeletePen(IntPtr pen);
752 [DllImport("gdiplus.dll")]
753 internal static extern Status GdipSetPenBrushFill (IntPtr pen, IntPtr brush);
754 [DllImport("gdiplus.dll")]
755 internal static extern Status GdipGetPenBrushFill (IntPtr pen, out IntPtr brush);
756 [DllImport("gdiplus.dll")]
757 internal static extern Status GdipGetPenFillType (IntPtr pen, out PenType type);
758 [DllImport("gdiplus.dll")]
759 internal static extern Status GdipSetPenColor (IntPtr pen, int color);
760 [DllImport("gdiplus.dll")]
761 internal static extern Status GdipGetPenColor (IntPtr pen, out int color);
762 [DllImport("gdiplus.dll")]
763 internal static extern Status GdipSetPenCompoundArray (IntPtr pen, float[] dash, int count);
764 [DllImport("gdiplus.dll")]
765 internal static extern Status GdipGetPenCompoundArray (IntPtr pen, float[] dash, int count);
766 [DllImport("gdiplus.dll")]
767 internal static extern Status GdipGetPenCompoundCount (IntPtr pen, out int count);
768 [DllImport("gdiplus.dll")]
769 internal static extern Status GdipSetPenDashCap197819 (IntPtr pen, DashCap dashCap);
770 [DllImport("gdiplus.dll")]
771 internal static extern Status GdipGetPenDashCap197819 (IntPtr pen, out DashCap dashCap);
772 [DllImport("gdiplus.dll")]
773 internal static extern Status GdipSetPenDashStyle (IntPtr pen, DashStyle dashStyle);
774 [DllImport("gdiplus.dll")]
775 internal static extern Status GdipGetPenDashStyle (IntPtr pen, out DashStyle dashStyle);
776 [DllImport("gdiplus.dll")]
777 internal static extern Status GdipSetPenDashOffset (IntPtr pen, float offset);
778 [DllImport("gdiplus.dll")]
779 internal static extern Status GdipGetPenDashOffset (IntPtr pen, out float offset);
780 [DllImport("gdiplus.dll")]
781 internal static extern Status GdipGetPenDashCount (IntPtr pen, out int count);
782 [DllImport("gdiplus.dll")]
783 internal static extern Status GdipSetPenDashArray (IntPtr pen, float[] dash, int count);
784 [DllImport("gdiplus.dll")]
785 internal static extern Status GdipGetPenDashArray (IntPtr pen, float[] dash, int count);
786 [DllImport("gdiplus.dll")]
787 internal static extern Status GdipSetPenMiterLimit (IntPtr pen, float miterLimit);
788 [DllImport("gdiplus.dll")]
789 internal static extern Status GdipGetPenMiterLimit (IntPtr pen, out float miterLimit);
790 [DllImport("gdiplus.dll")]
791 internal static extern Status GdipSetPenLineJoin (IntPtr pen, LineJoin lineJoin);
792 [DllImport("gdiplus.dll")]
793 internal static extern Status GdipGetPenLineJoin (IntPtr pen, out LineJoin lineJoin);
794 [DllImport("gdiplus.dll")]
795 internal static extern Status GdipSetPenLineCap197819 (IntPtr pen, LineCap startCap, LineCap endCap, DashCap dashCap);
796 [DllImport("gdiplus.dll")]
797 internal static extern Status GdipSetPenMode (IntPtr pen, PenAlignment alignment);
798 [DllImport("gdiplus.dll")]
799 internal static extern Status GdipGetPenMode (IntPtr pen, out PenAlignment alignment);
800 [DllImport("gdiplus.dll")]
801 internal static extern Status GdipSetPenStartCap (IntPtr pen, LineCap startCap);
802 [DllImport("gdiplus.dll")]
803 internal static extern Status GdipGetPenStartCap (IntPtr pen, out LineCap startCap);
804 [DllImport("gdiplus.dll")]
805 internal static extern Status GdipSetPenEndCap (IntPtr pen, LineCap endCap);
806 [DllImport("gdiplus.dll")]
807 internal static extern Status GdipGetPenEndCap (IntPtr pen, out LineCap endCap);
808 [DllImport("gdiplus.dll")]
809 internal static extern Status GdipSetPenCustomStartCap (IntPtr pen, IntPtr customCap);
810 [DllImport("gdiplus.dll")]
811 internal static extern Status GdipGetPenCustomStartCap (IntPtr pen, out IntPtr customCap);
812 [DllImport("gdiplus.dll")]
813 internal static extern Status GdipSetPenCustomEndCap (IntPtr pen, IntPtr customCap);
814 [DllImport("gdiplus.dll")]
815 internal static extern Status GdipGetPenCustomEndCap (IntPtr pen, out IntPtr customCap);
816 [DllImport("gdiplus.dll")]
817 internal static extern Status GdipSetPenTransform (IntPtr pen, IntPtr matrix);
818 [DllImport("gdiplus.dll")]
819 internal static extern Status GdipGetPenTransform (IntPtr pen, IntPtr matrix);
820 [DllImport("gdiplus.dll")]
821 internal static extern Status GdipSetPenWidth (IntPtr pen, float width);
822 [DllImport("gdiplus.dll")]
823 internal static extern Status GdipGetPenWidth (IntPtr pen, out float width);
824 [DllImport("gdiplus.dll")]
825 internal static extern Status GdipResetPenTransform (IntPtr pen);
826 [DllImport("gdiplus.dll")]
827 internal static extern Status GdipMultiplyPenTransform (IntPtr pen, IntPtr matrix, MatrixOrder order);
828 [DllImport("gdiplus.dll")]
829 internal static extern Status GdipRotatePenTransform (IntPtr pen, float angle, MatrixOrder order);
830 [DllImport("gdiplus.dll")]
831 internal static extern Status GdipScalePenTransform (IntPtr pen, float sx, float sy, MatrixOrder order);
832 [DllImport("gdiplus.dll")]
833 internal static extern Status GdipTranslatePenTransform (IntPtr pen, float dx, float dy, MatrixOrder order);
835 // CustomLineCap functions
836 [DllImport("gdiplus.dll")]
837 internal static extern Status GdipCreateCustomLineCap (IntPtr fillPath, IntPtr strokePath, LineCap baseCap, float baseInset, out IntPtr customCap);
838 [DllImport("gdiplus.dll")]
839 internal static extern Status GdipDeleteCustomLineCap (IntPtr customCap);
840 [DllImport("gdiplus.dll")]
841 internal static extern Status GdipCloneCustomLineCap (IntPtr customCap, out IntPtr clonedCap);
842 [DllImport("gdiplus.dll")]
843 internal static extern Status GdipSetCustomLineCapStrokeCaps (IntPtr customCap, LineCap startCap, LineCap endCap);
844 [DllImport("gdiplus.dll")]
845 internal static extern Status GdipGetCustomLineCapStrokeCaps (IntPtr customCap, out LineCap startCap, out LineCap endCap);
846 [DllImport("gdiplus.dll")]
847 internal static extern Status GdipSetCustomLineCapStrokeJoin (IntPtr customCap, LineJoin lineJoin);
848 [DllImport("gdiplus.dll")]
849 internal static extern Status GdipGetCustomLineCapStrokeJoin (IntPtr customCap, out LineJoin lineJoin);
850 [DllImport("gdiplus.dll")]
851 internal static extern Status GdipSetCustomLineCapBaseCap (IntPtr customCap, LineCap baseCap);
852 [DllImport("gdiplus.dll")]
853 internal static extern Status GdipGetCustomLineCapBaseCap (IntPtr customCap, out LineCap baseCap);
854 [DllImport("gdiplus.dll")]
855 internal static extern Status GdipSetCustomLineCapBaseInset (IntPtr customCap, float inset);
856 [DllImport("gdiplus.dll")]
857 internal static extern Status GdipGetCustomLineCapBaseInset (IntPtr customCap, out float inset);
858 [DllImport("gdiplus.dll")]
859 internal static extern Status GdipSetCustomLineCapWidthScale (IntPtr customCap, float widthScale);
860 [DllImport("gdiplus.dll")]
861 internal static extern Status GdipGetCustomLineCapWidthScale (IntPtr customCap, out float widthScale);
863 // AdjustableArrowCap functions
864 [DllImport("gdiplus.dll")]
865 internal static extern Status GdipCreateAdjustableArrowCap (float height, float width, bool isFilled, out IntPtr arrowCap);
866 [DllImport("gdiplus.dll")]
867 internal static extern Status GdipSetAdjustableArrowCapHeight (IntPtr arrowCap, float height);
868 [DllImport("gdiplus.dll")]
869 internal static extern Status GdipGetAdjustableArrowCapHeight (IntPtr arrowCap, out float height);
870 [DllImport("gdiplus.dll")]
871 internal static extern Status GdipSetAdjustableArrowCapWidth (IntPtr arrowCap, float width);
872 [DllImport("gdiplus.dll")]
873 internal static extern Status GdipGetAdjustableArrowCapWidth (IntPtr arrowCap, out float width);
874 [DllImport("gdiplus.dll")]
875 internal static extern Status GdipSetAdjustableArrowCapMiddleInset (IntPtr arrowCap, float middleInset);
876 [DllImport("gdiplus.dll")]
877 internal static extern Status GdipGetAdjustableArrowCapMiddleInset (IntPtr arrowCap, out float middleInset);
878 [DllImport("gdiplus.dll")]
879 internal static extern Status GdipSetAdjustableArrowCapFillState (IntPtr arrowCap, bool isFilled);
880 [DllImport("gdiplus.dll")]
881 internal static extern Status GdipGetAdjustableArrowCapFillState (IntPtr arrowCap, out bool isFilled);
884 [DllImport("gdiplus.dll")]
885 internal static extern Status GdipCreateFromHWND (IntPtr hwnd, out IntPtr graphics);
887 [DllImport("gdiplus.dll", CharSet=CharSet.Unicode)]
888 internal static extern Status GdipMeasureString(IntPtr graphics, string str, int length, IntPtr font,
889 ref RectangleF layoutRect, IntPtr stringFormat, out RectangleF boundingBox, out int codepointsFitted,
890 out int linesFilled);
892 [DllImport("gdiplus.dll", CharSet=CharSet.Unicode)]
893 internal static extern Status GdipMeasureCharacterRanges (IntPtr graphics, string str, int length, IntPtr font,
894 ref RectangleF layoutRect, IntPtr stringFormat, int regcount, out IntPtr regions);
896 [DllImport("gdiplus.dll")]
897 internal static extern Status GdipSetStringFormatMeasurableCharacterRanges (IntPtr native,
898 int cnt, CharacterRange [] range);
900 [DllImport("gdiplus.dll")]
901 internal static extern Status GdipGetStringFormatMeasurableCharacterRangeCount (IntPtr native,
905 [DllImport("gdiplus.dll")]
906 internal static extern Status GdipCreateBitmapFromScan0 (int width, int height, int stride, PixelFormat format, IntPtr scan0, out IntPtr bmp);
908 [DllImport("gdiplus.dll")]
909 internal static extern Status GdipCreateBitmapFromGraphics (int width, int height, IntPtr target, out IntPtr bitmap);
911 [DllImport("gdiplus.dll")]
912 internal static extern Status GdipBitmapLockBits (IntPtr bmp, ref Rectangle rc, ImageLockMode flags, PixelFormat format, [In, Out] BitmapData bmpData);
914 [DllImport("gdiplus.dll")]
915 internal static extern Status GdipBitmapSetResolution(IntPtr bmp, float xdpi, float ydpi);
917 [DllImport("gdiplus.dll")]
918 internal static extern Status GdipBitmapUnlockBits (IntPtr bmp, [In,Out] BitmapData bmpData);
920 [DllImport("gdiplus.dll")]
921 internal static extern Status GdipBitmapGetPixel (IntPtr bmp, int x, int y, out int argb);
923 [DllImport("gdiplus.dll")]
924 internal static extern Status GdipBitmapSetPixel (IntPtr bmp, int x, int y, int argb);
927 [DllImport("gdiplus.dll", CharSet=CharSet.Auto)]
928 internal static extern Status GdipLoadImageFromFile ( [MarshalAs(UnmanagedType.LPWStr)] string filename, out IntPtr image );
930 // Stream functions for Win32 (original Win32 ones)
931 [DllImport("gdiplus.dll", ExactSpelling=true, CharSet=CharSet.Unicode)]
932 internal static extern Status GdipLoadImageFromStream([MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(ComIStreamMarshaler))] IStream stream, out IntPtr image);
934 [DllImport("gdiplus.dll", ExactSpelling=true, CharSet=CharSet.Unicode)]
935 internal static extern Status GdipSaveImageToStream(HandleRef image, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(ComIStreamMarshaler))] IStream stream, [In()] ref Guid clsidEncoder, HandleRef encoderParams);
938 [DllImport("gdiplus.dll")]
939 internal static extern Status GdipCloneImage(IntPtr image, out IntPtr imageclone);
941 [DllImport("gdiplus.dll", CharSet=CharSet.Auto)]
942 internal static extern Status GdipLoadImageFromFileICM ( [MarshalAs(UnmanagedType.LPWStr)] string filename, out IntPtr image );
944 [DllImport("gdiplus.dll")]
945 internal static extern Status GdipCreateBitmapFromHBITMAP ( IntPtr hBitMap, IntPtr gdiPalette, out IntPtr image );
947 [DllImport("gdiplus.dll")]
948 internal static extern Status GdipDisposeImage ( IntPtr image );
950 [DllImport("gdiplus.dll")]
951 internal static extern Status GdipGetImageFlags(IntPtr image, out int flag);
953 [DllImport("gdiplus.dll")]
954 internal static extern Status GdipImageGetFrameDimensionsCount ( IntPtr image, out uint count );
956 [DllImport("gdiplus.dll")]
957 internal static extern Status GdipImageGetFrameDimensionsList ( IntPtr image, [Out] Guid [] dimensionIDs, uint count );
959 [DllImport("gdiplus.dll")]
960 internal static extern Status GdipGetImageHeight (IntPtr image, out int height);
962 [DllImport("gdiplus.dll")]
963 internal static extern Status GdipGetImageHorizontalResolution ( IntPtr image, out float resolution );
965 [DllImport("gdiplus.dll")]
966 internal static extern Status GdipGetImagePaletteSize ( IntPtr image, out int size );
968 [DllImport("gdiplus.dll")]
969 internal static extern Status GdipGetImagePalette (IntPtr image, IntPtr palette, int size);
971 [DllImport("gdiplus.dll")]
972 internal static extern Status GdipSetImagePalette (IntPtr image, IntPtr palette);
974 [DllImport("gdiplus.dll")]
975 internal static extern Status GdipGetImageDimension ( IntPtr image, out float width, out float height );
977 [DllImport("gdiplus.dll")]
978 internal static extern Status GdipGetImagePixelFormat ( IntPtr image, out PixelFormat format );
980 [DllImport("gdiplus.dll")]
981 internal static extern Status GdipGetPropertyCount (IntPtr image, out uint propNumbers);
983 [DllImport("gdiplus.dll")]
984 internal static extern Status GdipGetPropertyIdList (IntPtr image, uint propNumbers, [Out] int [] list);
986 [DllImport("gdiplus.dll")]
987 internal static extern Status GdipGetPropertySize (IntPtr image, out int bufferSize, out int propNumbers);
989 [DllImport("gdiplus.dll")]
990 internal static extern Status GdipGetAllPropertyItems (IntPtr image, int bufferSize, int propNumbers, IntPtr items);
992 [DllImport("gdiplus.dll")]
993 internal static extern Status GdipGetImageRawFormat ( IntPtr image, out Guid format );
995 [DllImport("gdiplus.dll")]
996 internal static extern Status GdipGetImageVerticalResolution ( IntPtr image, out float resolution );
998 [DllImport("gdiplus.dll")]
999 internal static extern Status GdipGetImageWidth ( IntPtr image, out int width);
1001 [DllImport("gdiplus.dll")]
1002 internal static extern Status GdipGetImageBounds ( IntPtr image, out RectangleF source, ref GraphicsUnit unit );
1004 [DllImport("gdiplus.dll")]
1005 internal static extern Status GdipGetEncoderParameterListSize ( IntPtr image, ref Guid encoder, out uint size );
1007 [DllImport("gdiplus.dll")]
1008 internal static extern Status GdipGetEncoderParameterList ( IntPtr image, ref Guid encoder, uint size, IntPtr buffer );
1010 [DllImport("gdiplus.dll")]
1011 internal static extern Status GdipImageGetFrameCount (IntPtr image, ref Guid guidDimension, out int count );
1013 [DllImport("gdiplus.dll")]
1014 internal static extern Status GdipImageSelectActiveFrame (IntPtr image, ref Guid guidDimension, int frameIndex);
1016 [DllImport("gdiplus.dll")]
1017 internal static extern Status GdipGetPropertyItemSize (IntPtr image, int propertyID, out int propertySize);
1019 [DllImport("gdiplus.dll")]
1020 internal static extern Status GdipGetPropertyItem (IntPtr image, int propertyID, int propertySize, IntPtr buffer);
1022 [DllImport("gdiplus.dll")]
1023 internal static extern Status GdipRemovePropertyItem (IntPtr image, int propertyId);
1025 [DllImport("gdiplus.dll")]
1026 internal static extern Status GdipSetPropertyItem (IntPtr image, IntPtr propertyItem);
1028 [DllImport("gdiplus.dll")]
1029 internal static extern Status GdipGetImageThumbnail ( IntPtr image, uint width, uint height, out IntPtr thumbImage, IntPtr callback, IntPtr callBackData );
1031 [DllImport("gdiplus.dll")]
1032 internal static extern Status GdipImageRotateFlip ( IntPtr image, RotateFlipType rotateFlipType );
1034 [DllImport("gdiplus.dll", CharSet=CharSet.Unicode)]
1035 internal static extern Status GdipSaveImageToFile (IntPtr image, string filename, ref Guid encoderClsID, IntPtr encoderParameters);
1037 [DllImport("gdiplus.dll")]
1038 internal static extern Status GdipSaveAdd ( IntPtr image, IntPtr encoderParameters );
1040 [DllImport("gdiplus.dll")]
1041 internal static extern Status GdipSaveAddImage (IntPtr image, IntPtr imagenew, IntPtr encoderParameters);
1043 [DllImport("gdiplus.dll")]
1044 internal static extern Status GdipDrawImageI (IntPtr graphics, IntPtr image, int x, int y);
1045 [DllImport("gdiplus.dll")]
1046 internal static extern Status GdipGetImageGraphicsContext (IntPtr image, out IntPtr graphics);
1047 [DllImport("gdiplus.dll")]
1048 internal static extern Status GdipDrawImage (IntPtr graphics, IntPtr image, float x, float y);
1049 [DllImport("gdiplus.dll")]
1050 internal static extern Status GdipBeginContainer (IntPtr graphics, RectangleF dstrect,
1051 RectangleF srcrect, GraphicsUnit unit, out int state);
1053 [DllImport("gdiplus.dll")]
1054 internal static extern Status GdipBeginContainerI (IntPtr graphics, Rectangle dstrect,
1055 Rectangle srcrect, GraphicsUnit unit, out int state);
1057 [DllImport("gdiplus.dll")]
1058 internal static extern Status GdipBeginContainer2 (IntPtr graphics, out int state);
1060 [DllImport("gdiplus.dll")]
1061 internal static extern Status GdipDrawImagePoints (IntPtr graphics, IntPtr image, PointF [] destPoints, int count);
1064 [DllImport("gdiplus.dll")]
1065 internal static extern Status GdipDrawImagePointsI (IntPtr graphics, IntPtr image, Point [] destPoints, int count);
1067 [DllImport("gdiplus.dll")]
1068 internal static extern Status GdipDrawImageRectRectI (IntPtr graphics, IntPtr image,
1069 int dstx, int dsty, int dstwidth, int dstheight,
1070 int srcx, int srcy, int srcwidth, int srcheight,
1071 GraphicsUnit srcUnit, IntPtr imageattr, Graphics.DrawImageAbort callback, IntPtr callbackData);
1073 [DllImport("gdiplus.dll")]
1074 internal static extern Status GdipDrawImageRectRect (IntPtr graphics, IntPtr image,
1075 float dstx, float dsty, float dstwidth, float dstheight,
1076 float srcx, float srcy, float srcwidth, float srcheight,
1077 GraphicsUnit srcUnit, IntPtr imageattr, Graphics.DrawImageAbort callback, IntPtr callbackData);
1079 [DllImport("gdiplus.dll")]
1080 internal static extern Status GdipDrawImagePointsRectI (IntPtr graphics, IntPtr image,
1081 Point [] destPoints, int count, int srcx, int srcy, int srcwidth, int srcheight,
1082 GraphicsUnit srcUnit, IntPtr imageattr, Graphics.DrawImageAbort callback, IntPtr callbackData);
1084 [DllImport("gdiplus.dll")]
1085 internal static extern Status GdipDrawImagePointsRect (IntPtr graphics, IntPtr image,
1086 PointF [] destPoints, int count, float srcx, float srcy, float srcwidth, float srcheight,
1087 GraphicsUnit srcUnit, IntPtr imageattr, Graphics.DrawImageAbort callback, IntPtr callbackData);
1089 [DllImport("gdiplus.dll")]
1090 internal static extern Status GdipDrawImageRect(IntPtr graphics, IntPtr image, float x, float y, float width, float height);
1091 [DllImport("gdiplus.dll")]
1092 internal static extern Status GdipDrawImagePointRect(IntPtr graphics, IntPtr image, float x,
1093 float y, float srcx, float srcy, float srcwidth, float srcheight, GraphicsUnit srcUnit);
1095 [DllImport("gdiplus.dll")]
1096 internal static extern Status GdipDrawImagePointRectI(IntPtr graphics, IntPtr image, int x,
1097 int y, int srcx, int srcy, int srcwidth,
1098 int srcheight, GraphicsUnit srcUnit);
1100 [DllImport("gdiplus.dll")]
1101 internal static extern Status GdipCreateStringFormat(StringFormatFlags formatAttributes, int language, out IntPtr native);
1103 [DllImport("gdiplus.dll")]
1104 internal static extern Status GdipCreateHBITMAPFromBitmap (IntPtr bmp, out IntPtr HandleBmp, int clrbackground);
1106 [DllImport("gdiplus.dll", CharSet=CharSet.Auto)]
1107 internal static extern Status GdipCreateBitmapFromFile ([MarshalAs (UnmanagedType.LPWStr)] string filename, out IntPtr bitmap);
1109 [DllImport("gdiplus.dll", CharSet=CharSet.Auto)]
1110 internal static extern Status GdipCreateBitmapFromFileICM ([MarshalAs (UnmanagedType.LPWStr)] string filename, out IntPtr bitmap);
1112 [DllImport("gdiplus.dll")]
1113 internal static extern Status GdipCreateHICONFromBitmap (IntPtr bmp, out IntPtr HandleIcon);
1115 [DllImport("gdiplus.dll")]
1116 internal static extern Status GdipCreateBitmapFromHICON (IntPtr hicon, out IntPtr bitmap);
1118 [DllImport("gdiplus.dll")]
1119 internal static extern Status GdipCreateBitmapFromResource (IntPtr hInstance,
1120 string lpBitmapName, out IntPtr bitmap);
1123 [DllImport ("gdiplus.dll")]
1124 internal static extern Status GdipCreateMatrix (out IntPtr matrix);
1125 [DllImport ("gdiplus.dll")]
1126 internal static extern Status GdipCreateMatrix2 (float m11, float m12, float m21, float m22, float dx, float dy, out IntPtr matrix);
1127 [DllImport ("gdiplus.dll")]
1128 internal static extern Status GdipCreateMatrix3 (RectangleF rect, PointF [] dstplg, out IntPtr matrix);
1129 [DllImport ("gdiplus.dll")]
1130 internal static extern Status GdipCreateMatrix3I (Rectangle rect, Point [] dstplg, out IntPtr matrix);
1131 [DllImport ("gdiplus.dll")]
1132 internal static extern Status GdipDeleteMatrix (IntPtr matrix);
1134 [DllImport ("gdiplus.dll")]
1135 internal static extern Status GdipCloneMatrix (IntPtr matrix, out IntPtr cloneMatrix);
1136 [DllImport ("gdiplus.dll")]
1137 internal static extern Status GdipSetMatrixElements (IntPtr matrix, float m11, float m12, float m21, float m22, float dx, float dy);
1138 [DllImport ("gdiplus.dll")]
1139 internal static extern Status GdipGetMatrixElements (IntPtr matrix, IntPtr matrixOut);
1140 [DllImport ("gdiplus.dll")]
1141 internal static extern Status GdipMultiplyMatrix (IntPtr matrix, IntPtr matrix2, MatrixOrder order);
1142 [DllImport ("gdiplus.dll")]
1143 internal static extern Status GdipTranslateMatrix (IntPtr matrix, float offsetX, float offsetY, MatrixOrder order);
1144 [DllImport ("gdiplus.dll")]
1145 internal static extern Status GdipScaleMatrix (IntPtr matrix, float scaleX, float scaleY, MatrixOrder order);
1146 [DllImport ("gdiplus.dll")]
1147 internal static extern Status GdipRotateMatrix (IntPtr matrix, float angle, MatrixOrder order);
1149 [DllImport ("gdiplus.dll")]
1150 internal static extern Status GdipShearMatrix (IntPtr matrix, float shearX, float shearY, MatrixOrder order);
1152 [DllImport ("gdiplus.dll")]
1153 internal static extern Status GdipInvertMatrix (IntPtr matrix);
1154 [DllImport ("gdiplus.dll")]
1155 internal static extern Status GdipTransformMatrixPoints (IntPtr matrix, PointF [] pts, int count);
1156 [DllImport ("gdiplus.dll")]
1157 internal static extern Status GdipTransformMatrixPointsI (IntPtr matrix, Point [] pts, int count);
1158 [DllImport ("gdiplus.dll")]
1159 internal static extern Status GdipVectorTransformMatrixPoints (IntPtr matrix, PointF [] pts, int count);
1160 [DllImport ("gdiplus.dll")]
1161 internal static extern Status GdipVectorTransformMatrixPointsI (IntPtr matrix, Point [] pts, int count);
1162 [DllImport ("gdiplus.dll")]
1163 internal static extern Status GdipIsMatrixInvertible (IntPtr matrix, out bool result);
1165 [DllImport ("gdiplus.dll")]
1166 internal static extern Status GdipIsMatrixIdentity (IntPtr matrix, out bool result);
1167 [DllImport ("gdiplus.dll")]
1168 internal static extern Status GdipIsMatrixEqual (IntPtr matrix, IntPtr matrix2, out bool result);
1170 // GraphicsPath functions
1171 [DllImport ("gdiplus.dll")]
1172 internal static extern Status GdipCreatePath (FillMode brushMode, out IntPtr path);
1173 [DllImport ("gdiplus.dll")]
1174 internal static extern Status GdipCreatePath2 (PointF [] points, byte [] types, int count, FillMode brushMode, out IntPtr path);
1175 [DllImport ("gdiplus.dll")]
1176 internal static extern Status GdipCreatePath2I (Point [] points, byte [] types, int count, FillMode brushMode, out IntPtr path);
1177 [DllImport ("gdiplus.dll")]
1178 internal static extern Status GdipClonePath (IntPtr path, out IntPtr clonePath);
1179 [DllImport ("gdiplus.dll")]
1180 internal static extern Status GdipDeletePath (IntPtr path);
1181 [DllImport ("gdiplus.dll")]
1182 internal static extern Status GdipResetPath (IntPtr path);
1183 [DllImport ("gdiplus.dll")]
1184 internal static extern Status GdipGetPointCount (IntPtr path, out int count);
1185 [DllImport ("gdiplus.dll")]
1186 internal static extern Status GdipGetPathTypes (IntPtr path, [Out] byte [] types, int count);
1187 [DllImport ("gdiplus.dll")]
1188 internal static extern Status GdipGetPathPoints (IntPtr path, [Out] PointF [] points, int count);
1189 [DllImport ("gdiplus.dll")]
1190 internal static extern Status GdipGetPathPointsI (IntPtr path, [Out] Point [] points, int count);
1191 [DllImport ("gdiplus.dll")]
1192 internal static extern Status GdipGetPathFillMode (IntPtr path, out FillMode fillMode);
1193 [DllImport ("gdiplus.dll")]
1194 internal static extern Status GdipSetPathFillMode (IntPtr path, FillMode fillMode);
1195 [DllImport ("gdiplus.dll")]
1196 internal static extern Status GdipStartPathFigure (IntPtr path);
1197 [DllImport ("gdiplus.dll")]
1198 internal static extern Status GdipClosePathFigure (IntPtr path);
1199 [DllImport ("gdiplus.dll")]
1200 internal static extern Status GdipClosePathFigures (IntPtr path);
1201 [DllImport ("gdiplus.dll")]
1202 internal static extern Status GdipSetPathMarker (IntPtr path);
1203 [DllImport ("gdiplus.dll")]
1204 internal static extern Status GdipClearPathMarkers (IntPtr path);
1205 [DllImport ("gdiplus.dll")]
1206 internal static extern Status GdipReversePath (IntPtr path);
1207 [DllImport ("gdiplus.dll")]
1208 internal static extern Status GdipGetPathLastPoint (IntPtr path, out PointF lastPoint);
1209 [DllImport ("gdiplus.dll")]
1210 internal static extern Status GdipAddPathLine (IntPtr path, float x1, float y1, float x2, float y2);
1211 [DllImport ("gdiplus.dll")]
1212 internal static extern Status GdipAddPathArc (IntPtr path, float x, float y, float width, float height, float startAngle, float sweepAngle);
1213 [DllImport ("gdiplus.dll")]
1214 internal static extern Status GdipAddPathBezier (IntPtr path, float x1, float y1, float x2, float y2, float x3, float y3, float x4, float y4);
1215 [DllImport ("gdiplus.dll")]
1216 internal static extern Status GdipAddPathBeziers (IntPtr path, PointF [] points, int count);
1217 [DllImport ("gdiplus.dll")]
1218 internal static extern Status GdipAddPathCurve (IntPtr path, PointF [] points, int count);
1219 [DllImport ("gdiplus.dll")]
1220 internal static extern Status GdipAddPathCurveI (IntPtr path, Point [] points, int count);
1221 [DllImport ("gdiplus.dll")]
1222 internal static extern Status GdipAddPathCurve2 (IntPtr path, PointF [] points, int count, float tension);
1223 [DllImport ("gdiplus.dll")]
1224 internal static extern Status GdipAddPathCurve2I (IntPtr path, Point [] points, int count, float tension);
1225 [DllImport ("gdiplus.dll")]
1226 internal static extern Status GdipAddPathCurve3 (IntPtr path, PointF [] points, int count, int offset, int numberOfSegments, float tension);
1227 [DllImport ("gdiplus.dll")]
1228 internal static extern Status GdipAddPathCurve3I (IntPtr path, Point [] points, int count, int offset, int numberOfSegments, float tension);
1229 [DllImport ("gdiplus.dll")]
1230 internal static extern Status GdipAddPathClosedCurve (IntPtr path, PointF [] points, int count);
1231 [DllImport ("gdiplus.dll")]
1232 internal static extern Status GdipAddPathClosedCurveI (IntPtr path, Point [] points, int count);
1233 [DllImport ("gdiplus.dll")]
1234 internal static extern Status GdipAddPathClosedCurve2 (IntPtr path, PointF [] points, int count, float tension);
1235 [DllImport ("gdiplus.dll")]
1236 internal static extern Status GdipAddPathClosedCurve2I (IntPtr path, Point [] points, int count, float tension);
1237 [DllImport ("gdiplus.dll")]
1238 internal static extern Status GdipAddPathRectangle (IntPtr path, float x, float y, float width, float height);
1239 [DllImport ("gdiplus.dll")]
1240 internal static extern Status GdipAddPathRectangles (IntPtr path, RectangleF [] rects, int count);
1241 [DllImport ("gdiplus.dll")]
1242 internal static extern Status GdipAddPathEllipse (IntPtr path, float x, float y, float width, float height);
1243 [DllImport ("gdiplus.dll")]
1244 internal static extern Status GdipAddPathEllipseI (IntPtr path, int x, int y, int width, int height);
1245 [DllImport ("gdiplus.dll")]
1246 internal static extern Status GdipAddPathPie (IntPtr path, float x, float y, float width, float height, float startAngle, float sweepAngle);
1247 [DllImport ("gdiplus.dll")]
1248 internal static extern Status GdipAddPathPieI (IntPtr path, int x, int y, int width, int height, float startAngle, float sweepAngle);
1249 [DllImport ("gdiplus.dll")]
1250 internal static extern Status GdipAddPathPolygon (IntPtr path, PointF [] points, int count);
1251 [DllImport ("gdiplus.dll")]
1252 internal static extern Status GdipAddPathPath (IntPtr path, IntPtr addingPath, bool connect);
1253 [DllImport ("gdiplus.dll")]
1254 internal static extern Status GdipAddPathLineI (IntPtr path, int x1, int y1, int x2, int y2);
1255 [DllImport ("gdiplus.dll")]
1256 internal static extern Status GdipAddPathArcI (IntPtr path, int x, int y, int width, int height, float startAngle, float sweepAngle);
1258 [DllImport ("gdiplus.dll")]
1259 internal static extern Status GdipAddPathBezierI (IntPtr path, int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4);
1260 [DllImport ("gdiplus.dll")]
1261 internal static extern Status GdipAddPathBeziersI (IntPtr path, Point [] points, int count);
1263 [DllImport ("gdiplus.dll")]
1264 internal static extern Status GdipAddPathPolygonI (IntPtr path, Point [] points, int count);
1265 [DllImport ("gdiplus.dll")]
1266 internal static extern Status GdipAddPathRectangleI (IntPtr path, int x, int y, int width, int height);
1267 [DllImport ("gdiplus.dll")]
1268 internal static extern Status GdipAddPathRectanglesI (IntPtr path, Rectangle [] rects, int count);
1269 [DllImport ("gdiplus.dll")]
1270 internal static extern Status GdipFlattenPath (IntPtr path, IntPtr matrix, float floatness);
1271 [DllImport ("gdiplus.dll")]
1272 internal static extern Status GdipTransformPath (IntPtr path, IntPtr matrix);
1273 [DllImport ("gdiplus.dll")]
1274 internal static extern Status GdipWarpPath (IntPtr path, IntPtr matrix,
1275 PointF [] points, int count,
1276 float srcx, float srcy, float srcwidth, float srcheight,
1277 WarpMode mode, float flatness);
1278 [DllImport ("gdiplus.dll")]
1279 internal static extern Status GdipWidenPath (IntPtr path, IntPtr pen, IntPtr matrix, float flatness);
1280 [DllImport ("gdiplus.dll")]
1281 internal static extern Status GdipGetPathWorldBounds (IntPtr path, out RectangleF bounds, IntPtr matrix, IntPtr pen);
1282 [DllImport ("gdiplus.dll")]
1283 internal static extern Status GdipGetPathWorldBoundsI (IntPtr path, out Rectangle bounds, IntPtr matrix, IntPtr pen);
1284 [DllImport ("gdiplus.dll")]
1285 internal static extern Status GdipIsVisiblePathPoint (IntPtr path, float x, float y, IntPtr graphics, out bool result);
1286 [DllImport ("gdiplus.dll")]
1287 internal static extern Status GdipIsVisiblePathPointI (IntPtr path, int x, int y, IntPtr graphics, out bool result);
1288 [DllImport ("gdiplus.dll")]
1289 internal static extern Status GdipIsOutlineVisiblePathPoint (IntPtr path, float x, float y, IntPtr graphics, out bool result);
1290 [DllImport ("gdiplus.dll")]
1291 internal static extern Status GdipIsOutlineVisiblePathPointI (IntPtr path, int x, int y, IntPtr graphics, out bool result);
1293 // GraphicsPathIterator
1294 [DllImport("gdiplus.dll")]
1295 internal static extern Status GdipCreatePathIter (out IntPtr iterator, IntPtr path);
1296 [DllImport("gdiplus.dll")]
1297 internal static extern Status GdipPathIterGetCount (IntPtr iterator, out int count);
1298 [DllImport("gdiplus.dll")]
1299 internal static extern Status GdipPathIterGetSubpathCount (IntPtr iterator, out int count);
1300 [DllImport("gdiplus.dll")]
1301 internal static extern Status GdipDeletePathIter (IntPtr iterator);
1302 [DllImport("gdiplus.dll")]
1303 internal static extern Status GdipPathIterCopyData (IntPtr iterator, out int resultCount, PointF [] points, byte [] types, int startIndex, int endIndex);
1304 [DllImport("gdiplus.dll")]
1305 internal static extern Status GdipPathIterEnumerate (IntPtr iterator, out int resultCount, PointF [] points, byte [] types, int count);
1306 [DllImport("gdiplus.dll")]
1307 internal static extern Status GdipPathIterHasCurve (IntPtr iterator, out bool curve);
1308 [DllImport("gdiplus.dll")]
1309 internal static extern Status GdipPathIterNextMarkerPath (IntPtr iterator, out int resultCount, IntPtr path);
1310 [DllImport("gdiplus.dll")]
1311 internal static extern Status GdipPathIterNextMarker (IntPtr iterator, out int resultCount, out int startIndex, out int endIndex);
1312 [DllImport("gdiplus.dll")]
1313 internal static extern Status GdipPathIterNextPathType (IntPtr iterator, out int resultCount, out byte pathType, out int startIndex, out int endIndex);
1314 [DllImport("gdiplus.dll")]
1315 internal static extern Status GdipPathIterNextSubpathPath (IntPtr iterator, out int resultCount, IntPtr path, out bool isClosed);
1316 [DllImport("gdiplus.dll")]
1317 internal static extern Status GdipPathIterNextSubpath (IntPtr iterator, out int resultCount, out int startIndex, out int endIndex, out bool isClosed);
1318 [DllImport("gdiplus.dll")]
1319 internal static extern Status GdipPathIterRewind (IntPtr iterator);
1322 [DllImport ("gdiplus.dll")]
1323 internal static extern Status GdipCreateImageAttributes (out IntPtr imageattr);
1325 [DllImport ("gdiplus.dll")]
1326 internal static extern Status GdipSetImageAttributesColorKeys (IntPtr imageattr,
1327 ColorAdjustType type, bool enableFlag, int colorLow, int colorHigh);
1329 [DllImport ("gdiplus.dll")]
1330 internal static extern Status GdipDisposeImageAttributes (IntPtr imageattr);
1332 [DllImport ("gdiplus.dll")]
1333 internal static extern Status GdipSetImageAttributesColorMatrix (IntPtr imageattr,
1334 ColorAdjustType type, bool enableFlag, ColorMatrix colorMatrix,
1335 ColorMatrix grayMatrix, ColorMatrixFlag flags);
1337 [DllImport ("gdiplus.dll")]
1338 internal static extern Status GdipSetImageAttributesGamma (IntPtr imageattr,
1339 ColorAdjustType type, bool enableFlag,
1342 [DllImport ("gdiplus.dll")]
1343 internal static extern Status GdipSetImageAttributesNoOp (IntPtr imageattr,
1344 ColorAdjustType type, bool enableFlag);
1346 [DllImport ("gdiplus.dll")]
1347 internal static extern Status GdipSetImageAttributesOutputChannel (IntPtr imageattr,
1348 ColorAdjustType type, bool enableFlag, ColorChannelFlag channelFlags);
1350 [DllImport ("gdiplus.dll", CharSet=CharSet.Auto)]
1351 internal static extern Status GdipSetImageAttributesOutputChannelColorProfile (IntPtr imageattr,
1352 ColorAdjustType type, bool enableFlag, [MarshalAs (UnmanagedType.LPWStr)] string profileName);
1354 [DllImport ("gdiplus.dll")]
1355 internal static extern Status GdipSetImageAttributesRemapTable (IntPtr imageattr,
1356 ColorAdjustType type, bool enableFlag, uint mapSize, IntPtr colorMap);
1358 [DllImport ("gdiplus.dll")]
1359 internal static extern Status GdipSetImageAttributesThreshold (IntPtr imageattr,
1360 ColorAdjustType type, bool enableFlag, float thresHold);
1362 [DllImport ("gdiplus.dll")]
1363 internal static extern Status GdipCloneImageAttributes(IntPtr imageattr, out IntPtr cloneImageattr);
1365 [DllImport ("gdiplus.dll")]
1366 internal static extern Status GdipGetImageAttributesAdjustedPalette(IntPtr imageattr,
1367 out IntPtr colorPalette, ColorAdjustType colorAdjustType);
1369 [DllImport ("gdiplus.dll")]
1370 internal static extern Status GdipSetImageAttributesWrapMode(IntPtr imageattr, WrapMode wrap,
1371 int argb, bool clamp);
1375 [DllImport("gdiplus.dll")]
1376 internal static extern Status GdipCreateFont (IntPtr fontFamily, float emSize, FontStyle style, GraphicsUnit unit, out IntPtr font);
1377 [DllImport("gdiplus.dll")]
1378 internal static extern Status GdipDeleteFont (IntPtr font);
1379 [DllImport("gdiplus.dll", CharSet=CharSet.Auto)]
1380 internal static extern Status GdipGetLogFont(IntPtr font, IntPtr graphics, [MarshalAs(UnmanagedType.AsAny), Out] object logfontA);
1382 [DllImport("gdiplus.dll")]
1383 internal static extern Status GdipCreateFontFromDC(IntPtr hdc, out IntPtr font);
1384 [DllImport("gdiplus.dll", SetLastError=true, CharSet=CharSet.Auto)]
1385 internal static extern Status GdipCreateFontFromLogfont(IntPtr hdc, ref LOGFONT lf, out IntPtr ptr);
1387 // These are our private functions, they exists in our own libgdiplus library, this way we
1388 // avoid relying on wine in System.Drawing
1389 [DllImport("gdiplus.dll")]
1390 internal static extern Status GdipGetHfont (IntPtr font, out IntPtr Hfont);
1391 [DllImport("gdiplus.dll", CharSet=CharSet.Ansi)]
1392 internal static extern Status GdipCreateFontFromHfont(IntPtr hdc, out IntPtr font, ref LOGFONT lf);
1394 // This is win32/gdi, not gdiplus, but it's easier to keep in here, also see above comment
1395 [DllImport("gdi32.dll", CallingConvention=CallingConvention.StdCall, CharSet = CharSet.Auto)]
1396 internal static extern IntPtr CreateFontIndirect (ref LOGFONT logfont);
1397 [DllImport("user32.dll", EntryPoint="GetDC", CallingConvention = CallingConvention.StdCall, CharSet = CharSet.Ansi)]
1398 internal static extern IntPtr GetDC(IntPtr hwnd);
1399 [DllImport("user32.dll", EntryPoint="ReleaseDC", CallingConvention = CallingConvention.StdCall, CharSet = CharSet.Ansi)]
1400 internal static extern int ReleaseDC(IntPtr hdc);
1401 [DllImport("gdi32.dll", EntryPoint="SelectObject", CallingConvention = CallingConvention.StdCall, CharSet = CharSet.Ansi)]
1402 internal static extern IntPtr SelectObject(IntPtr hdc, IntPtr obj);
1403 [DllImport("user32.dll", SetLastError=true)]
1404 internal static extern bool GetIconInfo (IntPtr hIcon, out IconInfo iconinfo);
1406 [DllImport("user32.dll")]
1407 internal static extern IntPtr GetDesktopWindow ();
1409 [DllImport("gdi32.dll", SetLastError=true)]
1410 public static extern int BitBlt(IntPtr hdcDest, int nXDest, int nYDest,
1411 int nWidth, int nHeight, IntPtr hdcSrc, int nXSrc, int nYSrc, int dwRop);
1414 // Some special X11 stuff
1415 [DllImport("libX11", EntryPoint="XOpenDisplay")]
1416 internal extern static IntPtr XOpenDisplay(IntPtr display);
1418 [DllImport("libX11", EntryPoint="XCloseDisplay")]
1419 internal extern static int XCloseDisplay(IntPtr display);
1421 [DllImport ("libX11", EntryPoint="XRootWindow")]
1422 internal extern static IntPtr XRootWindow(IntPtr display, int screen);
1424 [DllImport ("libX11", EntryPoint="XDefaultDepth")]
1425 internal extern static uint XDefaultDepth(IntPtr display, int screen);
1427 [DllImport ("libX11", EntryPoint="XGetImage")]
1428 internal extern static IntPtr XGetImage(IntPtr display, IntPtr drawable, int src_x, int src_y, int width, int height, int pane, int format);
1430 [DllImport ("libX11", EntryPoint="XGetPixel")]
1431 internal extern static int XGetPixel(IntPtr image, int x, int y);
1433 [DllImport ("libX11", EntryPoint="XDestroyImage")]
1434 internal extern static int XDestroyImage(IntPtr image);
1436 [DllImport ("libX11", EntryPoint="XDefaultVisual")]
1437 internal extern static IntPtr XDefaultVisual(IntPtr display, int screen);
1439 [DllImport ("libX11", EntryPoint="XGetVisualInfo")]
1440 internal extern static IntPtr XGetVisualInfo (IntPtr display, int vinfo_mask, ref XVisualInfo vinfo_template, ref int nitems);
1442 [DllImport ("libX11", EntryPoint="XVisualIDFromVisual")]
1443 internal extern static int XVisualIDFromVisual(IntPtr visual);
1447 [DllImport ("gdiplus.dll")]
1448 internal static extern Status GdipGetFontCollectionFamilyCount (IntPtr collection, out int found);
1450 [DllImport ("gdiplus.dll")]
1451 internal static extern Status GdipGetFontCollectionFamilyList (IntPtr collection, int getCount, IntPtr dest, out int retCount);
1452 //internal static extern Status GdipGetFontCollectionFamilyList( IntPtr collection, int getCount, [Out] FontFamily [] familyList, out int retCount );
1454 [DllImport ("gdiplus.dll")]
1455 internal static extern Status GdipNewInstalledFontCollection (out IntPtr collection);
1457 [DllImport ("gdiplus.dll")]
1458 internal static extern Status GdipNewPrivateFontCollection (out IntPtr collection);
1460 [DllImport ("gdiplus.dll")]
1461 internal static extern Status GdipDeletePrivateFontCollection (IntPtr collection);
1463 [DllImport ("gdiplus.dll", CharSet=CharSet.Auto)]
1464 internal static extern Status GdipPrivateAddFontFile (IntPtr collection,
1465 [MarshalAs (UnmanagedType.LPWStr)] string fileName );
1467 [DllImport ("gdiplus.dll")]
1468 internal static extern Status GdipPrivateAddMemoryFont (IntPtr collection, IntPtr mem, int length);
1471 [DllImport ("gdiplus.dll", CharSet=CharSet.Auto)]
1472 internal static extern Status GdipCreateFontFamilyFromName (
1473 [MarshalAs(UnmanagedType.LPWStr)] string fName, IntPtr collection, out IntPtr fontFamily);
1475 [DllImport ("gdiplus.dll")]
1476 internal static extern Status GdipGetFamilyName(IntPtr family, IntPtr fName, int language);
1478 [DllImport ("gdiplus.dll")]
1479 internal static extern Status GdipGetGenericFontFamilySansSerif (out IntPtr fontFamily);
1481 [DllImport ("gdiplus.dll")]
1482 internal static extern Status GdipGetGenericFontFamilySerif (out IntPtr fontFamily);
1484 [DllImport ("gdiplus.dll")]
1485 internal static extern Status GdipGetGenericFontFamilyMonospace (out IntPtr fontFamily);
1487 [DllImport ("gdiplus.dll")]
1488 internal static extern Status GdipGetCellAscent (IntPtr fontFamily, int style, out short ascent);
1490 [DllImport ("gdiplus.dll")]
1491 internal static extern Status GdipGetCellDescent (IntPtr fontFamily, int style, out short descent);
1493 [DllImport ("gdiplus.dll")]
1494 internal static extern Status GdipGetLineSpacing (IntPtr fontFamily, int style, out short spacing);
1496 [DllImport ("gdiplus.dll")]
1497 internal static extern Status GdipGetEmHeight (IntPtr fontFamily, int style, out short emHeight);
1499 [DllImport ("gdiplus.dll")]
1500 internal static extern Status GdipIsStyleAvailable (IntPtr fontFamily, int style, out bool styleAvailable);
1502 [DllImport ("gdiplus.dll")]
1503 internal static extern Status GdipDeleteFontFamily (IntPtr fontFamily);
1505 [DllImport ("gdiplus.dll")]
1506 internal static extern Status GdipGetFontSize (IntPtr font, out float size);
1508 [DllImport ("gdiplus.dll")]
1509 internal static extern Status GdipGetFontHeight (IntPtr font, IntPtr graphics, out float height);
1511 [DllImport ("gdiplus.dll")]
1512 internal static extern Status GdipGetFontHeightGivenDPI (IntPtr font, float dpi, out float height);
1516 [DllImport ("gdiplus.dll")]
1517 internal static extern Status GdipCreateStringFormat(int formatAttributes, int language, out IntPtr format);
1518 [DllImport ("gdiplus.dll")]
1519 internal static extern Status GdipStringFormatGetGenericDefault(out IntPtr format);
1520 [DllImport ("gdiplus.dll")]
1521 internal static extern Status GdipStringFormatGetGenericTypographic(out IntPtr format);
1522 [DllImport ("gdiplus.dll")]
1523 internal static extern Status GdipDeleteStringFormat(IntPtr format);
1524 [DllImport ("gdiplus.dll")]
1525 internal static extern Status GdipCloneStringFormat(IntPtr srcformat, out IntPtr format);
1526 [DllImport ("gdiplus.dll")]
1527 internal static extern Status GdipSetStringFormatFlags(IntPtr format, StringFormatFlags flags);
1528 [DllImport ("gdiplus.dll")]
1529 internal static extern Status GdipGetStringFormatFlags(IntPtr format, out StringFormatFlags flags);
1530 [DllImport ("gdiplus.dll")]
1531 internal static extern Status GdipSetStringFormatAlign(IntPtr format, StringAlignment align);
1532 [DllImport ("gdiplus.dll")]
1533 internal static extern Status GdipGetStringFormatAlign(IntPtr format, out StringAlignment align);
1534 [DllImport ("gdiplus.dll")]
1535 internal static extern Status GdipSetStringFormatLineAlign(IntPtr format, StringAlignment align);
1536 [DllImport ("gdiplus.dll")]
1537 internal static extern Status GdipGetStringFormatLineAlign(IntPtr format, out StringAlignment align);
1538 [DllImport ("gdiplus.dll")]
1539 internal static extern Status GdipSetStringFormatTrimming(IntPtr format, StringTrimming trimming);
1540 [DllImport ("gdiplus.dll")]
1541 internal static extern Status GdipGetStringFormatTrimming(IntPtr format, out StringTrimming trimming);
1542 [DllImport ("gdiplus.dll")]
1543 internal static extern Status GdipSetStringFormatHotkeyPrefix(IntPtr format, HotkeyPrefix hotkeyPrefix);
1544 [DllImport ("gdiplus.dll")]
1545 internal static extern Status GdipGetStringFormatHotkeyPrefix(IntPtr format, out HotkeyPrefix hotkeyPrefix);
1546 [DllImport ("gdiplus.dll")]
1547 internal static extern Status GdipSetStringFormatTabStops(IntPtr format, float firstTabOffset, int count, float [] tabStops);
1548 [DllImport ("gdiplus.dll")]
1549 internal static extern Status GdipGetStringFormatDigitSubstitution(IntPtr format, int language, out StringDigitSubstitute substitute);
1550 [DllImport ("gdiplus.dll")]
1551 internal static extern Status GdipSetStringFormatDigitSubstitution(IntPtr format, int language, StringDigitSubstitute substitute);
1552 [DllImport ("gdiplus.dll")]
1553 internal static extern Status GdipGetStringFormatTabStopCount(IntPtr format, out int count);
1554 [DllImport ("gdiplus.dll")]
1555 internal static extern Status GdipGetStringFormatTabStops(IntPtr format, int count, out float firstTabOffset, [In, Out] float [] tabStops);
1557 //ImageCodecInfo functions
1558 [DllImport("gdiplus.dll")]
1559 static internal extern Status GdipGetImageDecodersSize (out int decoderNums, out int arraySize);
1560 [DllImport("gdiplus.dll")]
1561 static internal extern Status GdipGetImageDecoders (int decoderNums, int arraySize, IntPtr decoders);
1562 [DllImport("gdiplus.dll")]
1563 static internal extern Status GdipGetImageEncodersSize (out int encoderNums, out int arraySize);
1564 [DllImport("gdiplus.dll")]
1565 static internal extern Status GdipGetImageEncoders (int encoderNums, int arraySize, IntPtr encoders);
1568 // These are stuff that is unix-only
1570 public delegate int StreamGetHeaderDelegate(IntPtr buf, int bufsz);
1571 public delegate int StreamGetBytesDelegate (IntPtr buf, int bufsz, bool peek);
1572 public delegate long StreamSeekDelegate (int offset, int whence);
1573 public delegate int StreamPutBytesDelegate (IntPtr buf, int bufsz);
1574 public delegate void StreamCloseDelegate ();
1575 public delegate long StreamSizeDelegate ();
1577 internal class GdiPlusStreamHelper
1579 public Stream stream;
1581 private StreamGetHeaderDelegate sghd = null;
1582 private StreamGetBytesDelegate sgbd = null;
1583 private StreamSeekDelegate skd = null;
1584 private StreamPutBytesDelegate spbd = null;
1585 private StreamCloseDelegate scd = null;
1586 private StreamSizeDelegate ssd = null;
1587 private byte[] start_buf;
1588 private int start_buf_pos;
1589 private int start_buf_len;
1591 public GdiPlusStreamHelper (Stream s)
1594 if (stream != null && stream.CanSeek) {
1595 stream.Seek (0, SeekOrigin.Begin);
1599 public int StreamGetHeaderImpl (IntPtr buf, int bufsz) {
1602 start_buf = new byte[bufsz];
1605 bytesRead = stream.Read (start_buf, 0, bufsz);
1606 } catch (IOException) {
1610 if (bytesRead > 0 && buf != IntPtr.Zero) {
1611 Marshal.Copy (start_buf, 0, (IntPtr) (buf.ToInt64()), bytesRead);
1615 start_buf_len = bytesRead;
1620 public StreamGetHeaderDelegate GetHeaderDelegate {
1622 if (stream != null && stream.CanRead) {
1624 sghd = new StreamGetHeaderDelegate (StreamGetHeaderImpl);
1632 public int StreamGetBytesImpl (IntPtr buf, int bufsz, bool peek)
1634 if (buf == IntPtr.Zero && peek) {
1638 byte[] managedBuf = new byte[bufsz];
1640 long streamPosition = 0;
1643 if (stream.CanSeek) {
1644 streamPosition = stream.Position;
1646 if (start_buf_len > 0) {
1647 if (start_buf_len > bufsz) {
1648 Array.Copy(start_buf, start_buf_pos, managedBuf, 0, bufsz);
1649 start_buf_pos += bufsz;
1650 start_buf_len -= bufsz;
1655 Array.Copy(start_buf, start_buf_pos, managedBuf, 0, start_buf_len);
1656 bufsz -= start_buf_len;
1657 bytesRead = start_buf_len;
1664 bytesRead += stream.Read (managedBuf, bytesRead, bufsz);
1665 } catch (IOException) {
1670 if (bytesRead > 0 && buf != IntPtr.Zero) {
1671 Marshal.Copy (managedBuf, 0, (IntPtr) (buf.ToInt64()), bytesRead);
1674 if (!stream.CanSeek && (bufsz == 10) && peek) {
1675 // Special 'hack' to support peeking of the type for gdi+ on non-seekable streams
1679 if (stream.CanSeek) {
1680 // If we are peeking bytes, then go back to original position before peeking
1681 stream.Seek (streamPosition, SeekOrigin.Begin);
1683 throw new NotSupportedException();
1691 public StreamGetBytesDelegate GetBytesDelegate {
1693 if (stream != null && stream.CanRead) {
1695 sgbd = new StreamGetBytesDelegate (StreamGetBytesImpl);
1703 public long StreamSeekImpl (int offset, int whence)
1705 // Make sure we have a valid 'whence'.
1706 if ((whence < 0) || (whence > 2))
1709 // Invalidate the start_buf if we're actually going to call a Seek method.
1710 start_buf_pos += start_buf_len;
1715 // Translate 'whence' into a SeekOrigin enum member.
1718 case 0: origin = SeekOrigin.Begin; break;
1719 case 1: origin = SeekOrigin.Current; break;
1720 case 2: origin = SeekOrigin.End; break;
1722 // The following line is redundant but necessary to avoid a
1723 // "Use of unassigned local variable" error without actually
1724 // initializing 'origin' to a dummy value.
1728 // Do the actual seek operation and return its result.
1729 return stream.Seek ((long) offset, origin);
1732 public StreamSeekDelegate SeekDelegate {
1734 if (stream != null && stream.CanSeek) {
1736 skd = new StreamSeekDelegate (StreamSeekImpl);
1744 public int StreamPutBytesImpl (IntPtr buf, int bufsz)
1746 byte[] managedBuf = new byte[bufsz];
1747 Marshal.Copy (buf, managedBuf, 0, bufsz);
1748 stream.Write (managedBuf, 0, bufsz);
1752 public StreamPutBytesDelegate PutBytesDelegate {
1754 if (stream != null && stream.CanWrite) {
1756 spbd = new StreamPutBytesDelegate (StreamPutBytesImpl);
1764 public void StreamCloseImpl ()
1769 public StreamCloseDelegate CloseDelegate {
1771 if (stream != null) {
1773 scd = new StreamCloseDelegate (StreamCloseImpl);
1781 public long StreamSizeImpl ()
1783 return stream.Length;
1786 public StreamSizeDelegate SizeDelegate {
1788 if (stream != null) {
1790 ssd = new StreamSizeDelegate (StreamSizeImpl);
1800 /* Mac only function calls */
1801 [DllImport("gdiplus.dll")]
1802 internal static extern Status GdipCreateFromQuartz_macosx (IntPtr cgref, int width, int height, out IntPtr graphics);
1804 /* Linux only function calls*/
1805 [DllImport("gdiplus.dll")]
1806 internal static extern Status GdipSetVisibleClip_linux (IntPtr graphics, ref Rectangle rect);
1808 [DllImport("gdiplus.dll")]
1809 internal static extern Status GdipCreateFromXDrawable_linux (IntPtr drawable, IntPtr display, out IntPtr graphics);
1811 // Stream functions for non-Win32 (libgdiplus specific(
1812 [DllImport("gdiplus.dll")]
1813 static internal extern Status GdipLoadImageFromDelegate_linux ( StreamGetHeaderDelegate getHeader, StreamGetBytesDelegate getBytes, StreamPutBytesDelegate putBytes,
1814 StreamSeekDelegate doSeek, StreamCloseDelegate close, StreamSizeDelegate size, out IntPtr image);
1815 [DllImport("gdiplus.dll")]
1816 static internal extern Status GdipSaveImageToDelegate_linux ( IntPtr image, StreamGetBytesDelegate getBytes, StreamPutBytesDelegate putBytes,
1817 StreamSeekDelegate doSeek, StreamCloseDelegate close, StreamSizeDelegate size, ref Guid encoderClsID, IntPtr encoderParameters );