2 // System.Drawing.Graphics.cs
5 // Gonzalo Paniagua Javier (gonzalo@ximian.com) (stubbed out)
6 // Alexandre Pigolkine(pigolkine@gmx.de)
7 // Jordi Mas i Hernandez (jordi@ximian.com)
9 // Copyright (C) 2003 Ximian, Inc. (http://www.ximian.com)
11 // Copyright (C) 2004 Novell, Inc. (http://www.novell.com)
13 // Permission is hereby granted, free of charge, to any person obtaining
14 // a copy of this software and associated documentation files (the
15 // "Software"), to deal in the Software without restriction, including
16 // without limitation the rights to use, copy, modify, merge, publish,
17 // distribute, sublicense, and/or sell copies of the Software, and to
18 // permit persons to whom the Software is furnished to do so, subject to
19 // the following conditions:
21 // The above copyright notice and this permission notice shall be
22 // included in all copies or substantial portions of the Software.
24 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
25 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
26 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
27 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
28 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
29 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
30 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
33 using System
.Drawing
.Drawing2D
;
34 using System
.Drawing
.Imaging
;
35 using System
.Drawing
.Text
;
36 using System
.ComponentModel
;
37 using System
.Runtime
.InteropServices
;
40 namespace System
.Drawing
43 public sealed class Graphics
: MarshalByRefObject
, IDisposable
45 internal IntPtr nativeObject
= IntPtr
.Zero
;
46 private bool disposed
= false;
47 private static float defDpiX
= 0;
48 private static float defDpiY
= 0;
49 private static IntPtr display
= IntPtr
.Zero
;
51 // We use X Drawable on Linux.
52 private static bool use_x_drawable
= (Environment
.OSVersion
.Platform
== (PlatformID
) 128);
55 public delegate bool EnumerateMetafileProc (EmfPlusRecordType recordType
,
59 PlayRecordCallback callbackData
);
62 public delegate bool DrawImageAbort (IntPtr callbackData
);
64 private Graphics (IntPtr nativeGraphics
)
66 nativeObject
= nativeGraphics
;
74 static internal float systemDpiX
{
77 Bitmap bmp
= new Bitmap (1, 1);
78 Graphics g
= Graphics
.FromImage (bmp
);
85 static internal float systemDpiY
{
88 Bitmap bmp
= new Bitmap (1, 1);
89 Graphics g
= Graphics
.FromImage (bmp
);
96 internal IntPtr NativeObject
{
102 nativeObject
= value;
107 public void AddMetafileComment (byte [] data
)
109 throw new NotImplementedException ();
113 public GraphicsContainer
BeginContainer ()
117 status
= GDIPlus
.GdipBeginContainer2 (nativeObject
, out state
);
118 GDIPlus
.CheckStatus (status
);
120 return new GraphicsContainer(state
);
123 public GraphicsContainer
BeginContainer (Rectangle dstrect
, Rectangle srcrect
, GraphicsUnit unit
)
127 status
= GDIPlus
.GdipBeginContainerI (nativeObject
, dstrect
, srcrect
, unit
, out state
);
128 GDIPlus
.CheckStatus (status
);
130 return new GraphicsContainer (state
);
134 public GraphicsContainer
BeginContainer (RectangleF dstrect
, RectangleF srcrect
, GraphicsUnit unit
)
138 status
= GDIPlus
.GdipBeginContainer (nativeObject
, dstrect
, srcrect
, unit
, out state
);
139 GDIPlus
.CheckStatus (status
);
141 return new GraphicsContainer (state
);
145 public void Clear (Color color
)
148 status
= GDIPlus
.GdipGraphicsClear (nativeObject
, color
.ToArgb ());
149 GDIPlus
.CheckStatus (status
);
152 public void Dispose ()
156 status
= GDIPlus
.GdipDeleteGraphics (nativeObject
);
157 nativeObject
= IntPtr
.Zero
;
158 GDIPlus
.CheckStatus (status
);
164 public void DrawArc (Pen pen
, Rectangle rect
, float startAngle
, float sweepAngle
)
166 DrawArc (pen
, rect
.X
, rect
.Y
, rect
.Width
, rect
.Height
, startAngle
, sweepAngle
);
170 public void DrawArc (Pen pen
, RectangleF rect
, float startAngle
, float sweepAngle
)
172 DrawArc (pen
, rect
.X
, rect
.Y
, rect
.Width
, rect
.Height
, startAngle
, sweepAngle
);
176 public void DrawArc (Pen pen
, float x
, float y
, float width
, float height
, float startAngle
, float sweepAngle
)
179 status
= GDIPlus
.GdipDrawArc (nativeObject
, pen
.nativeObject
,
180 x
, y
, width
, height
, startAngle
, sweepAngle
);
181 GDIPlus
.CheckStatus (status
);
184 // Microsoft documentation states that the signature for this member should be
185 // public void DrawArc( Pen pen, int x, int y, int width, int height, int startAngle,
186 // int sweepAngle. However, GdipDrawArcI uses also float for the startAngle and sweepAngle params
187 public void DrawArc (Pen pen
, int x
, int y
, int width
, int height
, int startAngle
, int sweepAngle
)
190 status
= GDIPlus
.GdipDrawArcI (nativeObject
, pen
.nativeObject
,
191 x
, y
, width
, height
, startAngle
, sweepAngle
);
192 GDIPlus
.CheckStatus (status
);
195 public void DrawBezier (Pen pen
, PointF pt1
, PointF pt2
, PointF pt3
, PointF pt4
)
198 status
= GDIPlus
.GdipDrawBezier (nativeObject
, pen
.nativeObject
,
199 pt1
.X
, pt1
.Y
, pt2
.X
, pt2
.Y
, pt3
.X
,
200 pt3
.Y
, pt4
.X
, pt4
.Y
);
201 GDIPlus
.CheckStatus (status
);
204 public void DrawBezier (Pen pen
, Point pt1
, Point pt2
, Point pt3
, Point pt4
)
207 status
= GDIPlus
.GdipDrawBezierI (nativeObject
, pen
.nativeObject
,
208 pt1
.X
, pt1
.Y
, pt2
.X
, pt2
.Y
, pt3
.X
,
209 pt3
.Y
, pt4
.X
, pt4
.Y
);
210 GDIPlus
.CheckStatus (status
);
213 public void DrawBezier (Pen pen
, float x1
, float y1
, float x2
, float y2
, float x3
, float y3
, float x4
, float y4
)
216 status
= GDIPlus
.GdipDrawBezier (nativeObject
, pen
.nativeObject
, x1
,
217 y1
, x2
, y2
, x3
, y3
, x4
, y4
);
218 GDIPlus
.CheckStatus (status
);
221 public void DrawBeziers (Pen pen
, Point
[] points
)
223 int length
= points
.Length
;
229 for (int i
= 0; i
< length
; i
+= 3) {
230 Point p1
= points
[i
];
231 Point p2
= points
[i
+ 1];
232 Point p3
= points
[i
+ 2];
233 Point p4
= points
[i
+ 3];
235 status
= GDIPlus
.GdipDrawBezier (nativeObject
,
237 p1
.X
, p1
.Y
, p2
.X
, p2
.Y
,
238 p3
.X
, p3
.Y
, p4
.X
, p4
.Y
);
239 GDIPlus
.CheckStatus (status
);
243 public void DrawBeziers (Pen pen
, PointF
[] points
)
245 int length
= points
.Length
;
251 for (int i
= 0; i
< length
; i
+= 3) {
252 PointF p1
= points
[i
];
253 PointF p2
= points
[i
+ 1];
254 PointF p3
= points
[i
+ 2];
255 PointF p4
= points
[i
+ 3];
257 status
= GDIPlus
.GdipDrawBezier (nativeObject
,
259 p1
.X
, p1
.Y
, p2
.X
, p2
.Y
,
260 p3
.X
, p3
.Y
, p4
.X
, p4
.Y
);
261 GDIPlus
.CheckStatus (status
);
266 public void DrawClosedCurve (Pen pen
, PointF
[] points
)
269 status
= GDIPlus
.GdipDrawClosedCurve (nativeObject
, pen
.nativeObject
, points
, points
.Length
);
270 GDIPlus
.CheckStatus (status
);
273 public void DrawClosedCurve (Pen pen
, Point
[] points
)
276 status
= GDIPlus
.GdipDrawClosedCurveI (nativeObject
, pen
.nativeObject
, points
, points
.Length
);
277 GDIPlus
.CheckStatus (status
);
280 public void DrawClosedCurve (Pen pen
, Point
[] points
, float tension
, FillMode fillmode
)
283 status
= GDIPlus
.GdipDrawClosedCurve2I (nativeObject
, pen
.nativeObject
, points
, points
.Length
, tension
);
284 GDIPlus
.CheckStatus (status
);
287 public void DrawClosedCurve (Pen pen
, PointF
[] points
, float tension
, FillMode fillmode
)
290 status
= GDIPlus
.GdipDrawClosedCurve2 (nativeObject
, pen
.nativeObject
, points
, points
.Length
, tension
);
291 GDIPlus
.CheckStatus (status
);
294 public void DrawCurve (Pen pen
, Point
[] points
)
297 status
= GDIPlus
.GdipDrawCurveI (nativeObject
, pen
.nativeObject
, points
, points
.Length
);
298 GDIPlus
.CheckStatus (status
);
301 public void DrawCurve (Pen pen
, PointF
[] points
)
304 status
= GDIPlus
.GdipDrawCurve (nativeObject
, pen
.nativeObject
, points
, points
.Length
);
305 GDIPlus
.CheckStatus (status
);
308 public void DrawCurve (Pen pen
, PointF
[] points
, float tension
)
311 status
= GDIPlus
.GdipDrawCurve2 (nativeObject
, pen
.nativeObject
, points
, points
.Length
, tension
);
312 GDIPlus
.CheckStatus (status
);
315 public void DrawCurve (Pen pen
, Point
[] points
, float tension
)
318 status
= GDIPlus
.GdipDrawCurve2I (nativeObject
, pen
.nativeObject
, points
, points
.Length
, tension
);
319 GDIPlus
.CheckStatus (status
);
323 public void DrawCurve (Pen pen
, PointF
[] points
, int offset
, int numberOfSegments
)
326 status
= GDIPlus
.GdipDrawCurve3 (nativeObject
, pen
.nativeObject
,
327 points
, points
.Length
, offset
,
328 numberOfSegments
, 0.5f
);
329 GDIPlus
.CheckStatus (status
);
332 public void DrawCurve (Pen pen
, Point
[] points
, int offset
, int numberOfSegments
, float tension
)
335 status
= GDIPlus
.GdipDrawCurve3I (nativeObject
, pen
.nativeObject
,
336 points
, points
.Length
, offset
,
337 numberOfSegments
, tension
);
338 GDIPlus
.CheckStatus (status
);
342 public void DrawCurve (Pen pen
, PointF
[] points
, int offset
, int numberOfSegments
, float tension
)
345 status
= GDIPlus
.GdipDrawCurve3 (nativeObject
, pen
.nativeObject
,
346 points
, points
.Length
, offset
,
347 numberOfSegments
, tension
);
348 GDIPlus
.CheckStatus (status
);
351 public void DrawEllipse (Pen pen
, Rectangle rect
)
353 DrawEllipse (pen
, rect
.X
, rect
.Y
, rect
.Width
, rect
.Height
);
356 public void DrawEllipse (Pen pen
, RectangleF rect
)
358 DrawEllipse (pen
, rect
.X
, rect
.Y
, rect
.Width
, rect
.Height
);
361 public void DrawEllipse (Pen pen
, int x
, int y
, int width
, int height
)
364 status
= GDIPlus
.GdipDrawEllipseI (nativeObject
, pen
.nativeObject
, x
, y
, width
, height
);
365 GDIPlus
.CheckStatus (status
);
368 public void DrawEllipse (Pen pen
, float x
, float y
, float width
, float height
)
370 Status status
= GDIPlus
.GdipDrawEllipse (nativeObject
, pen
.nativeObject
, x
, y
, width
, height
);
371 GDIPlus
.CheckStatus (status
);
374 public void DrawIcon (Icon icon
, Rectangle targetRect
)
376 Image img
= icon
.ToBitmap ();
377 DrawImage (img
, targetRect
);
380 public void DrawIcon (Icon icon
, int x
, int y
)
382 Image img
= icon
.ToBitmap ();
383 DrawImage (img
, x
, y
);
386 public void DrawIconUnstretched (Icon icon
, Rectangle targetRect
)
388 Image img
= icon
.ToBitmap ();
389 DrawImageUnscaled (img
, targetRect
);
392 public void DrawImage (Image image
, RectangleF rect
)
394 Status status
= GDIPlus
.GdipDrawImageRect(nativeObject
, image
.NativeObject
, rect
.X
, rect
.Y
, rect
.Width
, rect
.Height
);
395 GDIPlus
.CheckStatus (status
);
399 public void DrawImage (Image image
, PointF point
)
401 Status status
= GDIPlus
.GdipDrawImage (nativeObject
, image
.NativeObject
, point
.X
, point
.Y
);
402 GDIPlus
.CheckStatus (status
);
406 public void DrawImage (Image image
, Point
[] destPoints
)
408 Status status
= GDIPlus
.GdipDrawImagePointsI (nativeObject
, image
.NativeObject
, destPoints
, destPoints
.Length
);
409 GDIPlus
.CheckStatus (status
);
413 public void DrawImage (Image image
, Point point
)
415 DrawImage (image
, point
.X
, point
.Y
);
419 public void DrawImage (Image image
, Rectangle rect
)
421 DrawImage (image
, rect
.X
, rect
.Y
, rect
.Width
, rect
.Height
);
425 public void DrawImage (Image image
, PointF
[] destPoints
)
427 Status status
= GDIPlus
.GdipDrawImagePoints (nativeObject
, image
.NativeObject
, destPoints
, destPoints
.Length
);
428 GDIPlus
.CheckStatus (status
);
432 public void DrawImage (Image image
, int x
, int y
)
434 Status status
= GDIPlus
.GdipDrawImageI (nativeObject
, image
.NativeObject
, x
, y
);
435 GDIPlus
.CheckStatus (status
);
439 public void DrawImage (Image image
, float x
, float y
)
441 Status status
= GDIPlus
.GdipDrawImage (nativeObject
, image
.NativeObject
, x
, y
);
442 GDIPlus
.CheckStatus (status
);
446 public void DrawImage (Image image
, Rectangle destRect
, Rectangle srcRect
, GraphicsUnit srcUnit
)
448 Status status
= GDIPlus
.GdipDrawImageRectRectI (nativeObject
, image
.NativeObject
,
449 destRect
.X
, destRect
.Y
, destRect
.Width
, destRect
.Height
,
450 srcRect
.X
, srcRect
.Y
, srcRect
.Width
, srcRect
.Height
,
451 srcUnit
, IntPtr
.Zero
, null, IntPtr
.Zero
);
452 GDIPlus
.CheckStatus (status
);
455 public void DrawImage (Image image
, RectangleF destRect
, RectangleF srcRect
, GraphicsUnit srcUnit
)
457 Status status
= GDIPlus
.GdipDrawImageRectRect (nativeObject
, image
.NativeObject
,
458 destRect
.X
, destRect
.Y
, destRect
.Width
, destRect
.Height
,
459 srcRect
.X
, srcRect
.Y
, srcRect
.Width
, srcRect
.Height
,
460 srcUnit
, IntPtr
.Zero
, null, IntPtr
.Zero
);
461 GDIPlus
.CheckStatus (status
);
465 public void DrawImage (Image image
, Point
[] destPoints
, Rectangle srcRect
, GraphicsUnit srcUnit
)
467 Status status
= GDIPlus
.GdipDrawImagePointsRectI (nativeObject
, image
.NativeObject
,
468 destPoints
, destPoints
.Length
, srcRect
.X
, srcRect
.Y
,
469 srcRect
.Width
, srcRect
.Height
, srcUnit
, IntPtr
.Zero
,
471 GDIPlus
.CheckStatus (status
);
475 public void DrawImage (Image image
, PointF
[] destPoints
, RectangleF srcRect
, GraphicsUnit srcUnit
)
478 Status status
= GDIPlus
.GdipDrawImagePointsRect (nativeObject
, image
.NativeObject
,
479 destPoints
, destPoints
.Length
, srcRect
.X
, srcRect
.Y
,
480 srcRect
.Width
, srcRect
.Height
, srcUnit
, IntPtr
.Zero
,
482 GDIPlus
.CheckStatus (status
);
486 public void DrawImage (Image image
, Point
[] destPoints
, Rectangle srcRect
, GraphicsUnit srcUnit
,
487 ImageAttributes imageAttr
)
489 Status status
= GDIPlus
.GdipDrawImagePointsRectI (nativeObject
, image
.NativeObject
,
490 destPoints
, destPoints
.Length
, srcRect
.X
, srcRect
.Y
,
491 srcRect
.Width
, srcRect
.Height
, srcUnit
,
492 imageAttr
.NativeObject
, null, IntPtr
.Zero
);
493 GDIPlus
.CheckStatus (status
);
496 public void DrawImage (Image image
, float x
, float y
, float width
, float height
)
498 Status status
= GDIPlus
.GdipDrawImageRect(nativeObject
, image
.NativeObject
, x
, y
,
500 GDIPlus
.CheckStatus (status
);
504 public void DrawImage (Image image
, PointF
[] destPoints
, RectangleF srcRect
, GraphicsUnit srcUnit
,
505 ImageAttributes imageAttr
)
507 Status status
= GDIPlus
.GdipDrawImagePointsRect (nativeObject
, image
.NativeObject
,
508 destPoints
, destPoints
.Length
, srcRect
.X
, srcRect
.Y
,
509 srcRect
.Width
, srcRect
.Height
, srcUnit
,
510 imageAttr
.NativeObject
, null, IntPtr
.Zero
);
511 GDIPlus
.CheckStatus (status
);
515 public void DrawImage (Image image
, int x
, int y
, Rectangle srcRect
, GraphicsUnit srcUnit
)
517 Status status
= GDIPlus
.GdipDrawImagePointRectI(nativeObject
, image
.NativeObject
, x
, y
, srcRect
.X
, srcRect
.Y
, srcRect
.Width
, srcRect
.Height
, srcUnit
);
518 GDIPlus
.CheckStatus (status
);
521 public void DrawImage (Image image
, int x
, int y
, int width
, int height
)
523 Status status
= GDIPlus
.GdipDrawImageRectI (nativeObject
, image
.nativeObject
, x
, y
, width
, height
);
524 GDIPlus
.CheckStatus (status
);
527 public void DrawImage (Image image
, float x
, float y
, RectangleF srcRect
, GraphicsUnit srcUnit
)
529 Status status
= GDIPlus
.GdipDrawImagePointRect (nativeObject
, image
.nativeObject
, x
, y
, srcRect
.X
, srcRect
.Y
, srcRect
.Width
, srcRect
.Height
, srcUnit
);
530 GDIPlus
.CheckStatus (status
);
534 public void DrawImage (Image image
, PointF
[] destPoints
, RectangleF srcRect
, GraphicsUnit srcUnit
, ImageAttributes imageAttr
, DrawImageAbort callback
)
536 Status status
= GDIPlus
.GdipDrawImagePointsRect (nativeObject
, image
.NativeObject
,
537 destPoints
, destPoints
.Length
, srcRect
.X
, srcRect
.Y
,
538 srcRect
.Width
, srcRect
.Height
, srcUnit
,
539 imageAttr
.NativeObject
, callback
, IntPtr
.Zero
);
540 GDIPlus
.CheckStatus (status
);
544 public void DrawImage (Image image
, Point
[] destPoints
, Rectangle srcRect
, GraphicsUnit srcUnit
, ImageAttributes imageAttr
, DrawImageAbort callback
)
547 Status status
= GDIPlus
.GdipDrawImagePointsRectI (nativeObject
, image
.NativeObject
,
548 destPoints
, destPoints
.Length
, srcRect
.X
, srcRect
.Y
,
549 srcRect
.Width
, srcRect
.Height
, srcUnit
,
550 imageAttr
.NativeObject
, callback
, IntPtr
.Zero
);
551 GDIPlus
.CheckStatus (status
);
555 public void DrawImage (Image image
, Point
[] destPoints
, Rectangle srcRect
, GraphicsUnit srcUnit
, ImageAttributes imageAttr
, DrawImageAbort callback
, int callbackData
)
558 Status status
= GDIPlus
.GdipDrawImagePointsRectI (nativeObject
, image
.NativeObject
,
559 destPoints
, destPoints
.Length
, srcRect
.X
, srcRect
.Y
,
560 srcRect
.Width
, srcRect
.Height
, srcUnit
,
561 imageAttr
.NativeObject
, callback
, (IntPtr
) callbackData
);
562 GDIPlus
.CheckStatus (status
);
566 public void DrawImage (Image image
, Rectangle destRect
, float srcX
, float srcY
, float srcWidth
, float srcHeight
, GraphicsUnit srcUnit
)
568 Status status
= GDIPlus
.GdipDrawImageRectRect (nativeObject
, image
.NativeObject
,
569 destRect
.X
, destRect
.Y
, destRect
.Width
, destRect
.Height
,
570 srcX
, srcY
, srcWidth
, srcHeight
, srcUnit
, IntPtr
.Zero
,
572 GDIPlus
.CheckStatus (status
);
575 public void DrawImage (Image image
, PointF
[] destPoints
, RectangleF srcRect
, GraphicsUnit srcUnit
, ImageAttributes imageAttr
, DrawImageAbort callback
, int callbackData
)
577 Status status
= GDIPlus
.GdipDrawImagePointsRect (nativeObject
, image
.NativeObject
,
578 destPoints
, destPoints
.Length
, srcRect
.X
, srcRect
.Y
,
579 srcRect
.Width
, srcRect
.Height
, srcUnit
,
580 imageAttr
.NativeObject
, callback
, (IntPtr
) callbackData
);
581 GDIPlus
.CheckStatus (status
);
585 public void DrawImage (Image image
, Rectangle destRect
, int srcX
, int srcY
, int srcWidth
, int srcHeight
, GraphicsUnit srcUnit
)
587 Status status
= GDIPlus
.GdipDrawImageRectRectI (nativeObject
, image
.NativeObject
,
588 destRect
.X
, destRect
.Y
, destRect
.Width
, destRect
.Height
,
589 srcX
, srcY
, srcWidth
, srcHeight
, srcUnit
, IntPtr
.Zero
,
591 GDIPlus
.CheckStatus (status
);
595 public void DrawImage (Image image
, Rectangle destRect
, float srcX
, float srcY
, float srcWidth
, float srcHeight
, GraphicsUnit srcUnit
, ImageAttributes imageAttrs
)
597 Status status
= GDIPlus
.GdipDrawImageRectRect (nativeObject
, image
.NativeObject
,
598 destRect
.X
, destRect
.Y
, destRect
.Width
, destRect
.Height
,
599 srcX
, srcY
, srcWidth
, srcHeight
, srcUnit
,
600 imageAttrs
.NativeObject
, null, IntPtr
.Zero
);
601 GDIPlus
.CheckStatus (status
);
604 public void DrawImage (Image image
, Rectangle destRect
, int srcX
, int srcY
, int srcWidth
, int srcHeight
, GraphicsUnit srcUnit
, ImageAttributes imageAttr
)
606 Status status
= GDIPlus
.GdipDrawImageRectRectI (nativeObject
, image
.NativeObject
,
607 destRect
.X
, destRect
.Y
, destRect
.Width
,
608 destRect
.Height
, srcX
, srcY
, srcWidth
, srcHeight
,
609 srcUnit
, imageAttr
.NativeObject
, null, IntPtr
.Zero
);
610 GDIPlus
.CheckStatus (status
);
613 public void DrawImage (Image image
, Rectangle destRect
, int srcX
, int srcY
, int srcWidth
, int srcHeight
, GraphicsUnit srcUnit
, ImageAttributes imageAttr
, DrawImageAbort callback
)
615 Status status
= GDIPlus
.GdipDrawImageRectRectI (nativeObject
, image
.NativeObject
,
616 destRect
.X
, destRect
.Y
, destRect
.Width
,
617 destRect
.Height
, srcX
, srcY
, srcWidth
, srcHeight
,
618 srcUnit
, imageAttr
.NativeObject
, callback
,
620 GDIPlus
.CheckStatus (status
);
623 public void DrawImage (Image image
, Rectangle destRect
, float srcX
, float srcY
, float srcWidth
, float srcHeight
, GraphicsUnit srcUnit
, ImageAttributes imageAttr
, DrawImageAbort callback
)
625 Status status
= GDIPlus
.GdipDrawImageRectRect (nativeObject
, image
.NativeObject
,
626 destRect
.X
, destRect
.Y
, destRect
.Width
,
627 destRect
.Height
, srcX
, srcY
, srcWidth
, srcHeight
,
628 srcUnit
, imageAttr
.NativeObject
,
629 callback
, IntPtr
.Zero
);
630 GDIPlus
.CheckStatus (status
);
634 public void DrawImage (Image image
, Rectangle destRect
, float srcX
, float srcY
, float srcWidth
, float srcHeight
, GraphicsUnit srcUnit
, ImageAttributes imageAttr
, DrawImageAbort callback
, IntPtr callbackData
)
636 Status status
= GDIPlus
.GdipDrawImageRectRect (nativeObject
, image
.NativeObject
,
637 destRect
.X
, destRect
.Y
, destRect
.Width
, destRect
.Height
,
638 srcX
, srcY
, srcWidth
, srcHeight
, srcUnit
,
639 imageAttr
.NativeObject
, callback
, callbackData
);
640 GDIPlus
.CheckStatus (status
);
644 public void DrawImage (Image image
, Rectangle destRect
, int srcX
, int srcY
, int srcWidth
, int srcHeight
, GraphicsUnit srcUnit
, ImageAttributes imageAttr
, DrawImageAbort callback
, IntPtr callbackData
)
646 Status status
= GDIPlus
.GdipDrawImageRectRect (nativeObject
, image
.NativeObject
,
647 destRect
.X
, destRect
.Y
, destRect
.Width
, destRect
.Height
,
648 srcX
, srcY
, srcWidth
, srcHeight
, srcUnit
,
649 imageAttr
.NativeObject
, callback
, callbackData
);
650 GDIPlus
.CheckStatus (status
);
653 public void DrawImageUnscaled (Image image
, Point point
)
655 DrawImageUnscaled (image
, point
.X
, point
.Y
);
658 public void DrawImageUnscaled (Image image
, Rectangle rect
)
660 DrawImageUnscaled (image
, rect
.X
, rect
.Y
, rect
.Width
, rect
.Height
);
663 public void DrawImageUnscaled (Image image
, int x
, int y
)
665 DrawImage (image
, x
, y
, image
.Width
, image
.Height
);
668 public void DrawImageUnscaled (Image image
, int x
, int y
, int width
, int height
)
670 Image tmpImg
= new Bitmap (width
, height
);
671 Graphics g
= FromImage (tmpImg
);
672 g
.DrawImage (image
, 0, 0, image
.Width
, image
.Height
);
673 this.DrawImage (tmpImg
, x
, y
, width
, height
);
678 public void DrawLine (Pen pen
, PointF pt1
, PointF pt2
)
680 Status status
= GDIPlus
.GdipDrawLine (nativeObject
, pen
.nativeObject
,
681 pt1
.X
, pt1
.Y
, pt2
.X
, pt2
.Y
);
682 GDIPlus
.CheckStatus (status
);
685 public void DrawLine (Pen pen
, Point pt1
, Point pt2
)
687 Status status
= GDIPlus
.GdipDrawLineI (nativeObject
, pen
.nativeObject
,
688 pt1
.X
, pt1
.Y
, pt2
.X
, pt2
.Y
);
689 GDIPlus
.CheckStatus (status
);
692 public void DrawLine (Pen pen
, int x1
, int y1
, int x2
, int y2
)
694 Status status
= GDIPlus
.GdipDrawLineI (nativeObject
, pen
.nativeObject
, x1
, y1
, x2
, y2
);
695 GDIPlus
.CheckStatus (status
);
698 public void DrawLine (Pen pen
, float x1
, float y1
, float x2
, float y2
)
700 Status status
= GDIPlus
.GdipDrawLine (nativeObject
, pen
.nativeObject
, x1
, y1
, x2
, y2
);
701 GDIPlus
.CheckStatus (status
);
704 public void DrawLines (Pen pen
, PointF
[] points
)
706 Status status
= GDIPlus
.GdipDrawLines (nativeObject
, pen
.nativeObject
, points
, points
.Length
);
707 GDIPlus
.CheckStatus (status
);
710 public void DrawLines (Pen pen
, Point
[] points
)
712 Status status
= GDIPlus
.GdipDrawLinesI (nativeObject
, pen
.nativeObject
, points
, points
.Length
);
713 GDIPlus
.CheckStatus (status
);
716 public void DrawPath (Pen pen
, GraphicsPath path
)
718 Status status
= GDIPlus
.GdipDrawPath (nativeObject
, pen
.nativeObject
, path
.nativePath
);
719 GDIPlus
.CheckStatus (status
);
722 public void DrawPie (Pen pen
, Rectangle rect
, float startAngle
, float sweepAngle
)
724 DrawPie (pen
, rect
.X
, rect
.Y
, rect
.Width
, rect
.Height
, startAngle
, sweepAngle
);
727 public void DrawPie (Pen pen
, RectangleF rect
, float startAngle
, float sweepAngle
)
729 DrawPie (pen
, rect
.X
, rect
.Y
, rect
.Width
, rect
.Height
, startAngle
, sweepAngle
);
732 public void DrawPie (Pen pen
, float x
, float y
, float width
, float height
, float startAngle
, float sweepAngle
)
734 Status status
= GDIPlus
.GdipDrawPie (nativeObject
, pen
.nativeObject
, x
, y
, width
, height
, startAngle
, sweepAngle
);
735 GDIPlus
.CheckStatus (status
);
738 // Microsoft documentation states that the signature for this member should be
739 // public void DrawPie(Pen pen, int x, int y, int width, int height, int startAngle
740 // int sweepAngle. However, GdipDrawPieI uses also float for the startAngle and sweepAngle params
741 public void DrawPie (Pen pen
, int x
, int y
, int width
, int height
, int startAngle
, int sweepAngle
)
743 Status status
= GDIPlus
.GdipDrawPieI (nativeObject
, pen
.nativeObject
, x
, y
, width
, height
, startAngle
, sweepAngle
);
744 GDIPlus
.CheckStatus (status
);
747 public void DrawPolygon (Pen pen
, Point
[] points
)
749 Status status
= GDIPlus
.GdipDrawPolygonI (nativeObject
, pen
.nativeObject
, points
, points
.Length
);
750 GDIPlus
.CheckStatus (status
);
753 public void DrawPolygon (Pen pen
, PointF
[] points
)
755 Status status
= GDIPlus
.GdipDrawPolygon (nativeObject
, pen
.nativeObject
, points
, points
.Length
);
756 GDIPlus
.CheckStatus (status
);
759 internal void DrawRectangle (Pen pen
, RectangleF rect
)
761 DrawRectangle (pen
, rect
.Left
, rect
.Top
, rect
.Width
, rect
.Height
);
764 public void DrawRectangle (Pen pen
, Rectangle rect
)
766 DrawRectangle (pen
, rect
.Left
, rect
.Top
, rect
.Width
, rect
.Height
);
769 public void DrawRectangle (Pen pen
, float x
, float y
, float width
, float height
)
771 Status status
= GDIPlus
.GdipDrawRectangle (nativeObject
, pen
.nativeObject
, x
, y
, width
, height
);
772 GDIPlus
.CheckStatus (status
);
775 public void DrawRectangle (Pen pen
, int x
, int y
, int width
, int height
)
777 Status status
= GDIPlus
.GdipDrawRectangleI (nativeObject
, pen
.nativeObject
, x
, y
, width
, height
);
778 GDIPlus
.CheckStatus (status
);
781 public void DrawRectangles (Pen pen
, RectangleF
[] rects
)
783 Status status
= GDIPlus
.GdipDrawRectangles (nativeObject
, pen
.nativeObject
, rects
, rects
.Length
);
784 GDIPlus
.CheckStatus (status
);
787 public void DrawRectangles (Pen pen
, Rectangle
[] rects
)
789 Status status
= GDIPlus
.GdipDrawRectanglesI (nativeObject
, pen
.nativeObject
, rects
, rects
.Length
);
790 GDIPlus
.CheckStatus (status
);
793 public void DrawString (string s
, Font font
, Brush brush
, RectangleF layoutRectangle
)
795 Status status
= GDIPlus
.GdipDrawString (nativeObject
, s
, s
.Length
, font
.NativeObject
, ref layoutRectangle
, IntPtr
.Zero
, brush
.nativeObject
);
796 GDIPlus
.CheckStatus (status
);
799 public void DrawString (string s
, Font font
, Brush brush
, PointF point
)
801 RectangleF rc
= new RectangleF (point
.X
, point
.Y
, 0, 0);
802 Status status
= GDIPlus
.GdipDrawString (nativeObject
, s
, s
.Length
, font
.NativeObject
, ref rc
, IntPtr
.Zero
, brush
.nativeObject
);
803 GDIPlus
.CheckStatus (status
);
806 public void DrawString (string s
, Font font
, Brush brush
, PointF point
, StringFormat format
)
808 RectangleF rc
= new RectangleF (point
.X
, point
.Y
, 0, 0);
809 Status status
= GDIPlus
.GdipDrawString (nativeObject
, s
, s
.Length
, font
.NativeObject
, ref rc
, format
.NativeObject
, brush
.nativeObject
);
810 GDIPlus
.CheckStatus (status
);
813 public void DrawString (string s
, Font font
, Brush brush
, RectangleF layoutRectangle
, StringFormat format
)
815 Status status
= GDIPlus
.GdipDrawString (nativeObject
, s
, s
.Length
, font
.NativeObject
, ref layoutRectangle
, format
.NativeObject
, brush
.nativeObject
);
816 GDIPlus
.CheckStatus (status
);
819 public void DrawString (string s
, Font font
, Brush brush
, float x
, float y
)
821 RectangleF rc
= new RectangleF (x
, y
, 0, 0);
823 Status status
= GDIPlus
.GdipDrawString (nativeObject
, s
, s
.Length
, font
.NativeObject
,
824 ref rc
, IntPtr
.Zero
, brush
.nativeObject
);
825 GDIPlus
.CheckStatus (status
);
828 public void DrawString (string s
, Font font
, Brush brush
, float x
, float y
, StringFormat format
)
830 RectangleF rc
= new RectangleF (x
, y
, 0, 0);
832 Status status
= GDIPlus
.GdipDrawString (nativeObject
, s
, s
.Length
, font
.NativeObject
,
833 ref rc
, format
.NativeObject
, brush
.nativeObject
);
834 GDIPlus
.CheckStatus (status
);
838 public void EndContainer (GraphicsContainer container
)
840 Status status
= GDIPlus
.GdipEndContainer(nativeObject
, container
.NativeObject
);
841 GDIPlus
.CheckStatus (status
);
845 public void EnumerateMetafile (Metafile metafile
, Point
[] destPoints
, EnumerateMetafileProc callback
)
847 throw new NotImplementedException ();
851 public void EnumerateMetafile (Metafile metafile
, RectangleF destRect
, EnumerateMetafileProc callback
)
853 throw new NotImplementedException ();
857 public void EnumerateMetafile (Metafile metafile
, PointF
[] destPoints
, EnumerateMetafileProc callback
)
859 throw new NotImplementedException ();
863 public void EnumerateMetafile (Metafile metafile
, Rectangle destRect
, EnumerateMetafileProc callback
)
865 throw new NotImplementedException ();
869 public void EnumerateMetafile (Metafile metafile
, Point destPoint
, EnumerateMetafileProc callback
)
871 throw new NotImplementedException ();
875 public void EnumerateMetafile (Metafile metafile
, PointF destPoint
, EnumerateMetafileProc callback
)
877 throw new NotImplementedException ();
881 public void EnumerateMetafile (Metafile metafile
, PointF destPoint
, EnumerateMetafileProc callback
, IntPtr callbackData
)
883 throw new NotImplementedException ();
887 public void EnumerateMetafile (Metafile metafile
, Rectangle destRect
, EnumerateMetafileProc callback
, IntPtr callbackData
)
889 throw new NotImplementedException ();
893 public void EnumerateMetafile (Metafile metafile
, PointF
[] destPoints
, EnumerateMetafileProc callback
, IntPtr callbackData
)
895 throw new NotImplementedException ();
899 public void EnumerateMetafile (Metafile metafile
, Point destPoint
, EnumerateMetafileProc callback
, IntPtr callbackData
)
901 throw new NotImplementedException ();
905 public void EnumerateMetafile (Metafile metafile
, Point
[] destPoints
, EnumerateMetafileProc callback
, IntPtr callbackData
)
907 throw new NotImplementedException ();
911 public void EnumerateMetafile (Metafile metafile
, RectangleF destRect
, EnumerateMetafileProc callback
, IntPtr callbackData
)
913 throw new NotImplementedException ();
917 public void EnumerateMetafile (Metafile metafile
, PointF destPoint
, RectangleF srcRect
, GraphicsUnit srcUnit
, EnumerateMetafileProc callback
)
919 throw new NotImplementedException ();
923 public void EnumerateMetafile (Metafile metafile
, Point destPoint
, Rectangle srcRect
, GraphicsUnit srcUnit
, EnumerateMetafileProc callback
)
925 throw new NotImplementedException ();
929 public void EnumerateMetafile (Metafile metafile
, PointF
[] destPoints
, RectangleF srcRect
, GraphicsUnit srcUnit
, EnumerateMetafileProc callback
)
931 throw new NotImplementedException ();
935 public void EnumerateMetafile (Metafile metafile
, Point
[] destPoints
, Rectangle srcRect
, GraphicsUnit srcUnit
, EnumerateMetafileProc callback
)
937 throw new NotImplementedException ();
941 public void EnumerateMetafile (Metafile metafile
, RectangleF destRect
, RectangleF srcRect
, GraphicsUnit srcUnit
, EnumerateMetafileProc callback
)
943 throw new NotImplementedException ();
947 public void EnumerateMetafile (Metafile metafile
, Rectangle destRect
, Rectangle srcRect
, GraphicsUnit srcUnit
, EnumerateMetafileProc callback
)
949 throw new NotImplementedException ();
953 public void EnumerateMetafile (Metafile metafile
, RectangleF destRect
, EnumerateMetafileProc callback
, IntPtr callbackData
, ImageAttributes imageAttr
)
955 throw new NotImplementedException ();
959 public void EnumerateMetafile (Metafile metafile
, Point destPoint
, EnumerateMetafileProc callback
, IntPtr callbackData
, ImageAttributes imageAttr
)
961 throw new NotImplementedException ();
965 public void EnumerateMetafile (Metafile metafile
, PointF destPoint
, EnumerateMetafileProc callback
, IntPtr callbackData
, ImageAttributes imageAttr
)
967 throw new NotImplementedException ();
971 public void EnumerateMetafile (Metafile metafile
, Point
[] destPoints
, EnumerateMetafileProc callback
, IntPtr callbackData
, ImageAttributes imageAttr
)
973 throw new NotImplementedException ();
977 public void EnumerateMetafile (Metafile metafile
, PointF
[] destPoints
, EnumerateMetafileProc callback
, IntPtr callbackData
, ImageAttributes imageAttr
)
979 throw new NotImplementedException ();
983 public void EnumerateMetafile (Metafile metafile
, Rectangle destRect
, EnumerateMetafileProc callback
, IntPtr callbackData
, ImageAttributes imageAttr
)
985 throw new NotImplementedException ();
989 public void EnumerateMetafile (Metafile metafile
, Rectangle destRect
, Rectangle srcRect
, GraphicsUnit srcUnit
, EnumerateMetafileProc callback
, IntPtr callbackData
)
991 throw new NotImplementedException ();
995 public void EnumerateMetafile (Metafile metafile
, PointF
[] destPoints
, RectangleF srcRect
, GraphicsUnit srcUnit
, EnumerateMetafileProc callback
, IntPtr callbackData
)
997 throw new NotImplementedException ();
1001 public void EnumerateMetafile (Metafile metafile
, RectangleF destRect
, RectangleF srcRect
, GraphicsUnit srcUnit
, EnumerateMetafileProc callback
, IntPtr callbackData
)
1003 throw new NotImplementedException ();
1007 public void EnumerateMetafile (Metafile metafile
, PointF destPoint
, RectangleF srcRect
, GraphicsUnit srcUnit
, EnumerateMetafileProc callback
, IntPtr callbackData
)
1009 throw new NotImplementedException ();
1013 public void EnumerateMetafile (Metafile metafile
, Point destPoint
, Rectangle srcRect
, GraphicsUnit srcUnit
, EnumerateMetafileProc callback
, IntPtr callbackData
)
1015 throw new NotImplementedException ();
1019 public void EnumerateMetafile (Metafile metafile
, Point
[] destPoints
, Rectangle srcRect
, GraphicsUnit srcUnit
, EnumerateMetafileProc callback
, IntPtr callbackData
)
1021 throw new NotImplementedException ();
1025 public void EnumerateMetafile (Metafile metafile
, Point
[] destPoints
, Rectangle srcRect
, GraphicsUnit unit
, EnumerateMetafileProc callback
, IntPtr callbackData
, ImageAttributes imageAttr
)
1027 throw new NotImplementedException ();
1031 public void EnumerateMetafile (Metafile metafile
, Rectangle destRect
, Rectangle srcRect
, GraphicsUnit unit
, EnumerateMetafileProc callback
, IntPtr callbackData
, ImageAttributes imageAttr
)
1033 throw new NotImplementedException ();
1037 public void EnumerateMetafile (Metafile metafile
, Point destPoint
, Rectangle srcRect
, GraphicsUnit unit
, EnumerateMetafileProc callback
, IntPtr callbackData
, ImageAttributes imageAttr
)
1039 throw new NotImplementedException ();
1043 public void EnumerateMetafile (Metafile metafile
, RectangleF destRect
, RectangleF srcRect
, GraphicsUnit unit
, EnumerateMetafileProc callback
, IntPtr callbackData
, ImageAttributes imageAttr
)
1045 throw new NotImplementedException ();
1049 public void EnumerateMetafile (Metafile metafile
, PointF
[] destPoints
, RectangleF srcRect
, GraphicsUnit unit
, EnumerateMetafileProc callback
, IntPtr callbackData
, ImageAttributes imageAttr
)
1051 throw new NotImplementedException ();
1055 public void EnumerateMetafile (Metafile metafile
, PointF destPoint
, RectangleF srcRect
, GraphicsUnit unit
, EnumerateMetafileProc callback
, IntPtr callbackData
, ImageAttributes imageAttr
)
1057 throw new NotImplementedException ();
1060 public void ExcludeClip (Rectangle rect
)
1062 Status status
= GDIPlus
.GdipSetClipRectI (nativeObject
, rect
.X
, rect
.Y
, rect
.Width
, rect
.Height
, CombineMode
.Exclude
);
1063 GDIPlus
.CheckStatus (status
);
1066 public void ExcludeClip (Region region
)
1068 Status status
= GDIPlus
.GdipSetClipRegion (nativeObject
, region
.NativeObject
, CombineMode
.Exclude
);
1069 GDIPlus
.CheckStatus (status
);
1073 public void FillClosedCurve (Brush brush
, PointF
[] points
)
1075 Status status
= GDIPlus
.GdipFillClosedCurve (nativeObject
, brush
.NativeObject
, points
, points
.Length
);
1076 GDIPlus
.CheckStatus (status
);
1080 public void FillClosedCurve (Brush brush
, Point
[] points
)
1082 Status status
= GDIPlus
.GdipFillClosedCurveI (nativeObject
, brush
.NativeObject
, points
, points
.Length
);
1083 GDIPlus
.CheckStatus (status
);
1087 public void FillClosedCurve (Brush brush
, PointF
[] points
, FillMode fillmode
)
1089 FillClosedCurve (brush
, points
, fillmode
, 0.5f
);
1092 public void FillClosedCurve (Brush brush
, Point
[] points
, FillMode fillmode
)
1094 FillClosedCurve (brush
, points
, fillmode
, 0.5f
);
1097 public void FillClosedCurve (Brush brush
, PointF
[] points
, FillMode fillmode
, float tension
)
1099 Status status
= GDIPlus
.GdipFillClosedCurve2 (nativeObject
, brush
.NativeObject
, points
, points
.Length
, tension
, fillmode
);
1100 GDIPlus
.CheckStatus (status
);
1103 public void FillClosedCurve (Brush brush
, Point
[] points
, FillMode fillmode
, float tension
)
1105 Status status
= GDIPlus
.GdipFillClosedCurve2I (nativeObject
, brush
.NativeObject
, points
, points
.Length
, tension
, fillmode
);
1106 GDIPlus
.CheckStatus (status
);
1109 public void FillEllipse (Brush brush
, Rectangle rect
)
1111 FillEllipse (brush
, rect
.X
, rect
.Y
, rect
.Width
, rect
.Height
);
1114 public void FillEllipse (Brush brush
, RectangleF rect
)
1116 FillEllipse (brush
, rect
.X
, rect
.Y
, rect
.Width
, rect
.Height
);
1119 public void FillEllipse (Brush brush
, float x
, float y
, float width
, float height
)
1121 Status status
= GDIPlus
.GdipFillEllipse (nativeObject
, brush
.nativeObject
, x
, y
, width
, height
);
1122 GDIPlus
.CheckStatus (status
);
1125 public void FillEllipse (Brush brush
, int x
, int y
, int width
, int height
)
1127 Status status
= GDIPlus
.GdipFillEllipseI (nativeObject
, brush
.nativeObject
, x
, y
, width
, height
);
1128 GDIPlus
.CheckStatus (status
);
1131 public void FillPath (Brush brush
, GraphicsPath path
)
1133 Status status
= GDIPlus
.GdipFillPath (nativeObject
, brush
.NativeObject
, path
.NativeObject
);
1134 GDIPlus
.CheckStatus (status
);
1137 public void FillPie (Brush brush
, Rectangle rect
, float startAngle
, float sweepAngle
)
1139 Status status
= GDIPlus
.GdipFillPie (nativeObject
, brush
.NativeObject
, rect
.X
, rect
.Y
, rect
.Width
, rect
.Height
, startAngle
, sweepAngle
);
1140 GDIPlus
.CheckStatus (status
);
1143 public void FillPie (Brush brush
, int x
, int y
, int width
, int height
, int startAngle
, int sweepAngle
)
1145 Status status
= GDIPlus
.GdipFillPieI (nativeObject
, brush
.NativeObject
, x
, y
, width
, height
, startAngle
, sweepAngle
);
1146 GDIPlus
.CheckStatus (status
);
1149 public void FillPie (Brush brush
, float x
, float y
, float width
, float height
, float startAngle
, float sweepAngle
)
1151 Status status
= GDIPlus
.GdipFillPie (nativeObject
, brush
.NativeObject
, x
, y
, width
, height
, startAngle
, sweepAngle
);
1152 GDIPlus
.CheckStatus (status
);
1155 public void FillPolygon (Brush brush
, PointF
[] points
)
1157 Status status
= GDIPlus
.GdipFillPolygon2 (nativeObject
, brush
.nativeObject
, points
, points
.Length
);
1158 GDIPlus
.CheckStatus (status
);
1161 public void FillPolygon (Brush brush
, Point
[] points
)
1163 Status status
= GDIPlus
.GdipFillPolygon2I (nativeObject
, brush
.nativeObject
, points
, points
.Length
);
1164 GDIPlus
.CheckStatus (status
);
1167 public void FillPolygon (Brush brush
, Point
[] points
, FillMode fillMode
)
1169 Status status
= GDIPlus
.GdipFillPolygonI (nativeObject
, brush
.nativeObject
, points
, points
.Length
, fillMode
);
1170 GDIPlus
.CheckStatus (status
);
1173 public void FillPolygon (Brush brush
, PointF
[] points
, FillMode fillMode
)
1175 Status status
= GDIPlus
.GdipFillPolygon (nativeObject
, brush
.nativeObject
, points
, points
.Length
, fillMode
);
1176 GDIPlus
.CheckStatus (status
);
1179 public void FillRectangle (Brush brush
, RectangleF rect
)
1181 FillRectangle (brush
, rect
.Left
, rect
.Top
, rect
.Width
, rect
.Height
);
1184 public void FillRectangle (Brush brush
, Rectangle rect
)
1186 FillRectangle (brush
, rect
.Left
, rect
.Top
, rect
.Width
, rect
.Height
);
1189 public void FillRectangle (Brush brush
, int x
, int y
, int width
, int height
)
1191 Status status
= GDIPlus
.GdipFillRectangleI (nativeObject
, brush
.nativeObject
, x
, y
, width
, height
);
1192 GDIPlus
.CheckStatus (status
);
1195 public void FillRectangle (Brush brush
, float x
, float y
, float width
, float height
)
1197 Status status
= GDIPlus
.GdipFillRectangle (nativeObject
, brush
.nativeObject
, x
, y
, width
, height
);
1198 GDIPlus
.CheckStatus (status
);
1201 public void FillRectangles (Brush brush
, Rectangle
[] rects
)
1203 Status status
= GDIPlus
.GdipFillRectanglesI (nativeObject
, brush
.nativeObject
, rects
, rects
.Length
);
1204 GDIPlus
.CheckStatus (status
);
1207 public void FillRectangles (Brush brush
, RectangleF
[] rects
)
1209 Status status
= GDIPlus
.GdipFillRectangles (nativeObject
, brush
.nativeObject
, rects
, rects
.Length
);
1210 GDIPlus
.CheckStatus (status
);
1214 public void FillRegion (Brush brush
, Region region
)
1216 Status status
= GDIPlus
.GdipFillRegion (nativeObject
, brush
.NativeObject
, region
.NativeObject
);
1217 GDIPlus
.CheckStatus(status
);
1221 public void Flush ()
1223 Flush (FlushIntention
.Flush
);
1227 public void Flush (FlushIntention intention
)
1229 Status status
= GDIPlus
.GdipFlush (nativeObject
, intention
);
1230 GDIPlus
.CheckStatus (status
);
1233 [EditorBrowsable (EditorBrowsableState
.Advanced
)]
1234 public static Graphics
FromHdc (IntPtr hdc
)
1237 Status status
= GDIPlus
.GdipCreateFromHDC (hdc
, out graphics
);
1238 GDIPlus
.CheckStatus (status
);
1239 return new Graphics (graphics
);
1243 [EditorBrowsable (EditorBrowsableState
.Advanced
)]
1244 public static Graphics
FromHdc (IntPtr hdc
, IntPtr hdevice
)
1246 throw new NotImplementedException ();
1249 [EditorBrowsable (EditorBrowsableState
.Advanced
)]
1250 public static Graphics
FromHdcInternal (IntPtr hdc
)
1256 [EditorBrowsable (EditorBrowsableState
.Advanced
)]
1257 public static Graphics
FromHwnd (IntPtr hwnd
)
1261 if (use_x_drawable
) {
1262 if (display
== IntPtr
.Zero
) {
1263 display
= GDIPlus
.XOpenDisplay (IntPtr
.Zero
);
1266 return FromXDrawable (hwnd
, display
);
1269 Status status
= GDIPlus
.GdipCreateFromHWND (hwnd
, out graphics
);
1270 GDIPlus
.CheckStatus (status
);
1272 return new Graphics (graphics
);
1276 [EditorBrowsable (EditorBrowsableState
.Advanced
)]
1277 public static Graphics
FromHwndInternal (IntPtr hwnd
)
1279 throw new NotImplementedException ();
1282 public static Graphics
FromImage (Image image
)
1284 if (image
== null) throw new ArgumentException ();
1287 Status status
= GDIPlus
.GdipGetImageGraphicsContext (image
.nativeObject
, out graphics
);
1288 GDIPlus
.CheckStatus (status
);
1289 Graphics result
= new Graphics ((IntPtr
) graphics
);
1291 if (Environment
.OSVersion
.Platform
== (PlatformID
) 128) {
1292 Rectangle rect
= new Rectangle (0,0, image
.Width
, image
.Height
);
1293 GDIPlus
.GdipSetVisibleClip_linux (result
.NativeObject
, ref rect
);
1299 internal static Graphics
FromXDrawable (IntPtr drawable
, IntPtr display
)
1302 Status s
= GDIPlus
.GdipCreateFromXDrawable_linux (drawable
, display
, out graphics
);
1303 GDIPlus
.CheckStatus (s
);
1304 return new Graphics (graphics
);
1308 public static IntPtr
GetHalftonePalette ()
1310 throw new NotImplementedException ();
1314 [EditorBrowsable (EditorBrowsableState
.Advanced
)]
1315 public IntPtr
GetHdc ()
1318 Status status
= GDIPlus
.GdipGetDC (nativeObject
, out hdc
);
1319 GDIPlus
.CheckStatus (status
);
1321 return (IntPtr
) hdc
;
1325 public Color
GetNearestColor (Color color
)
1329 Status status
= GDIPlus
.GdipGetNearestColor (nativeObject
, out argb
);
1330 GDIPlus
.CheckStatus (status
);
1332 return Color
.FromArgb (argb
);
1336 public void IntersectClip (Region region
)
1338 Status status
= GDIPlus
.GdipSetClipRegion (nativeObject
, region
.NativeObject
, CombineMode
.Intersect
);
1339 GDIPlus
.CheckStatus (status
);
1342 public void IntersectClip (RectangleF rect
)
1344 Status status
= GDIPlus
.GdipSetClipRect (nativeObject
, rect
.X
, rect
.Y
, rect
.Width
, rect
.Height
, CombineMode
.Intersect
);
1345 GDIPlus
.CheckStatus (status
);
1348 public void IntersectClip (Rectangle rect
)
1350 Status status
= GDIPlus
.GdipSetClipRectI (nativeObject
, rect
.X
, rect
.Y
, rect
.Width
, rect
.Height
, CombineMode
.Intersect
);
1351 GDIPlus
.CheckStatus (status
);
1354 public bool IsVisible (Point point
)
1356 bool isVisible
= false;
1358 Status status
= GDIPlus
.GdipIsVisiblePointI (nativeObject
, point
.X
, point
.Y
, out isVisible
);
1359 GDIPlus
.CheckStatus (status
);
1365 public bool IsVisible (RectangleF rect
)
1367 bool isVisible
= false;
1369 Status status
= GDIPlus
.GdipIsVisibleRect (nativeObject
, rect
.X
, rect
.Y
, rect
.Width
, rect
.Height
, out isVisible
);
1370 GDIPlus
.CheckStatus (status
);
1375 public bool IsVisible (PointF point
)
1377 bool isVisible
= false;
1379 Status status
= GDIPlus
.GdipIsVisiblePoint (nativeObject
, point
.X
, point
.Y
, out isVisible
);
1380 GDIPlus
.CheckStatus (status
);
1385 public bool IsVisible (Rectangle rect
)
1387 bool isVisible
= false;
1389 Status status
= GDIPlus
.GdipIsVisibleRectI (nativeObject
, rect
.X
, rect
.Y
, rect
.Width
, rect
.Height
, out isVisible
);
1390 GDIPlus
.CheckStatus (status
);
1395 public bool IsVisible (float x
, float y
)
1397 return IsVisible (new PointF (x
, y
));
1400 public bool IsVisible (int x
, int y
)
1402 return IsVisible (new Point (x
, y
));
1405 public bool IsVisible (float x
, float y
, float width
, float height
)
1407 return IsVisible (new RectangleF (x
, y
, width
, height
));
1411 public bool IsVisible (int x
, int y
, int width
, int height
)
1413 return IsVisible (new Rectangle (x
, y
, width
, height
));
1417 public Region
[] MeasureCharacterRanges (string text
, Font font
, RectangleF layoutRect
, StringFormat stringFormat
)
1420 int regcount
= stringFormat
.GetMeasurableCharacterRangeCount ();
1421 IntPtr
[] native_regions
= new IntPtr
[regcount
];
1422 Region
[] regions
= new Region
[regcount
];
1424 for (int i
= 0; i
< regcount
; i
++) {
1425 regions
[i
] = new Region ();
1426 native_regions
[i
] = regions
[i
].NativeObject
;
1429 status
= GDIPlus
.GdipMeasureCharacterRanges (nativeObject
, text
, text
.Length
,
1430 font
.NativeObject
, ref layoutRect
, stringFormat
.NativeObject
,
1431 regcount
, out native_regions
[0]);
1433 GDIPlus
.CheckStatus (status
);
1439 public SizeF
MeasureString (string text
, Font font
)
1441 return MeasureString (text
, font
, new Size(0,0));
1445 public SizeF
MeasureString (string text
, Font font
, SizeF layoutArea
)
1447 int charactersFitted
, linesFilled
;
1448 RectangleF boundingBox
= new RectangleF ();
1449 RectangleF rect
= new RectangleF (0,0,layoutArea
.Width
, layoutArea
.Height
);
1451 Status status
= GDIPlus
.GdipMeasureString (nativeObject
, text
, text
.Length
,
1452 font
.NativeObject
, ref rect
, IntPtr
.Zero
, out boundingBox
,
1453 out charactersFitted
, out linesFilled
);
1454 GDIPlus
.CheckStatus (status
);
1456 return new SizeF(boundingBox
.Width
, boundingBox
.Height
);
1460 public SizeF
MeasureString (string text
, Font font
, int width
)
1462 RectangleF boundingBox
= new RectangleF ();
1463 RectangleF rect
= new RectangleF (0, 0, width
, 999999);
1464 int charactersFitted
, linesFilled
;
1466 Status status
= GDIPlus
.GdipMeasureString (nativeObject
, text
, text
.Length
,
1467 font
.NativeObject
, ref rect
, IntPtr
.Zero
,
1468 out boundingBox
, out charactersFitted
, out linesFilled
);
1469 GDIPlus
.CheckStatus (status
);
1471 return new SizeF (boundingBox
.Width
, boundingBox
.Height
);
1475 public SizeF
MeasureString (string text
, Font font
, SizeF layoutArea
, StringFormat stringFormat
)
1477 int charactersFitted
, linesFilled
;
1478 return MeasureString (text
, font
, layoutArea
, stringFormat
, out charactersFitted
, out linesFilled
);
1482 public SizeF
MeasureString (string text
, Font font
, int width
, StringFormat format
)
1484 int charactersFitted
, linesFilled
;
1485 return MeasureString (text
, font
, new SizeF (width
, 999999),
1486 format
, out charactersFitted
, out linesFilled
);
1490 public SizeF
MeasureString (string text
, Font font
, PointF origin
, StringFormat stringFormat
)
1492 RectangleF boundingBox
= new RectangleF ();
1493 RectangleF rect
= new RectangleF (origin
.X
, origin
.Y
, 0,0);
1494 int charactersFitted
, linesFilled
;
1496 Status status
= GDIPlus
.GdipMeasureString (nativeObject
, text
, text
.Length
,
1497 font
.NativeObject
, ref rect
, stringFormat
.NativeObject
,
1498 out boundingBox
, out charactersFitted
, out linesFilled
);
1499 GDIPlus
.CheckStatus (status
);
1501 return new SizeF (boundingBox
.Width
, boundingBox
.Height
);
1505 public SizeF
MeasureString (string text
, Font font
, SizeF layoutArea
, StringFormat stringFormat
, out int charactersFitted
, out int linesFilled
)
1507 RectangleF boundingBox
= new RectangleF ();
1508 RectangleF rect
= new RectangleF (0,0,layoutArea
.Width
, layoutArea
.Height
);
1509 Status status
= GDIPlus
.GdipMeasureString (nativeObject
, text
, text
.Length
,
1510 font
.NativeObject
, ref rect
, stringFormat
.NativeObject
,
1511 out boundingBox
, out charactersFitted
, out linesFilled
);
1512 GDIPlus
.CheckStatus (status
);
1514 return new SizeF (boundingBox
.Width
, boundingBox
.Height
);
1517 public void MultiplyTransform (Matrix matrix
)
1519 MultiplyTransform (matrix
, MatrixOrder
.Prepend
);
1522 public void MultiplyTransform (Matrix matrix
, MatrixOrder order
)
1524 Status status
= GDIPlus
.GdipMultiplyWorldTransform (nativeObject
, matrix
.nativeMatrix
, order
);
1525 GDIPlus
.CheckStatus (status
);
1528 [EditorBrowsable (EditorBrowsableState
.Advanced
)]
1529 public void ReleaseHdc (IntPtr hdc
)
1531 Status status
= GDIPlus
.GdipReleaseDC (nativeObject
, hdc
);
1532 GDIPlus
.CheckStatus (status
);
1536 [EditorBrowsable (EditorBrowsableState
.Advanced
)]
1537 public void ReleaseHdcInternal (IntPtr hdc
)
1539 throw new NotImplementedException ();
1543 public void ResetClip ()
1545 Status status
= GDIPlus
.GdipResetClip (nativeObject
);
1546 GDIPlus
.CheckStatus (status
);
1549 public void ResetTransform ()
1551 Status status
= GDIPlus
.GdipResetWorldTransform (nativeObject
);
1552 GDIPlus
.CheckStatus (status
);
1555 public void Restore (GraphicsState gstate
)
1557 Transform
= gstate
.matrix
.Clone ();
1558 Status status
= GDIPlus
.GdipRestoreGraphics (nativeObject
, gstate
.nativeState
);
1559 GDIPlus
.CheckStatus (status
);
1563 public void RotateTransform (float angle
)
1565 RotateTransform (angle
, MatrixOrder
.Prepend
);
1568 public void RotateTransform (float angle
, MatrixOrder order
)
1571 Status status
= GDIPlus
.GdipRotateWorldTransform (nativeObject
, angle
, order
);
1572 GDIPlus
.CheckStatus (status
);
1575 public GraphicsState
Save ()
1577 GraphicsState state
= new GraphicsState ();
1578 state
.matrix
= Transform
.Clone ();
1580 Status status
= GDIPlus
.GdipSaveGraphics (nativeObject
, out saveState
);
1581 GDIPlus
.CheckStatus (status
);
1583 state
.nativeState
= saveState
;
1587 public void ScaleTransform (float sx
, float sy
)
1589 ScaleTransform (sx
, sy
, MatrixOrder
.Prepend
);
1592 public void ScaleTransform (float sx
, float sy
, MatrixOrder order
)
1594 Status status
= GDIPlus
.GdipScaleWorldTransform (nativeObject
, sx
, sy
, order
);
1595 GDIPlus
.CheckStatus (status
);
1599 public void SetClip (RectangleF rect
)
1601 SetClip (rect
, CombineMode
.Replace
);
1605 public void SetClip (GraphicsPath path
)
1607 SetClip (path
, CombineMode
.Replace
);
1611 public void SetClip (Rectangle rect
)
1613 SetClip (rect
, CombineMode
.Replace
);
1617 public void SetClip (Graphics g
)
1619 SetClip (g
, CombineMode
.Replace
);
1623 public void SetClip (Graphics g
, CombineMode combineMode
)
1625 Status status
= GDIPlus
.GdipSetClipGraphics (nativeObject
, g
.NativeObject
, combineMode
);
1626 GDIPlus
.CheckStatus (status
);
1630 public void SetClip (Rectangle rect
, CombineMode combineMode
)
1632 Status status
= GDIPlus
.GdipSetClipRectI (nativeObject
, rect
.X
, rect
.Y
, rect
.Width
, rect
.Height
, combineMode
);
1633 GDIPlus
.CheckStatus (status
);
1637 public void SetClip (RectangleF rect
, CombineMode combineMode
)
1639 Status status
= GDIPlus
.GdipSetClipRect (nativeObject
, rect
.X
, rect
.Y
, rect
.Width
, rect
.Height
, combineMode
);
1640 GDIPlus
.CheckStatus (status
);
1644 public void SetClip (Region region
, CombineMode combineMode
)
1646 Status status
= GDIPlus
.GdipSetClipRegion(nativeObject
, region
.NativeObject
, combineMode
);
1647 GDIPlus
.CheckStatus (status
);
1651 public void SetClip (GraphicsPath path
, CombineMode combineMode
)
1653 Status status
= GDIPlus
.GdipSetClipPath (nativeObject
, path
.NativeObject
, combineMode
);
1654 GDIPlus
.CheckStatus (status
);
1658 public void TransformPoints (CoordinateSpace destSpace
, CoordinateSpace srcSpace
, PointF
[] pts
)
1660 IntPtr ptrPt
= GDIPlus
.FromPointToUnManagedMemory (pts
);
1662 Status status
= GDIPlus
.GdipTransformPoints (nativeObject
, destSpace
, srcSpace
, ptrPt
, pts
.Length
);
1663 GDIPlus
.CheckStatus (status
);
1665 GDIPlus
.FromUnManagedMemoryToPoint (ptrPt
, pts
);
1669 public void TransformPoints (CoordinateSpace destSpace
, CoordinateSpace srcSpace
, Point
[] pts
)
1671 IntPtr ptrPt
= GDIPlus
.FromPointToUnManagedMemoryI (pts
);
1673 Status status
= GDIPlus
.GdipTransformPointsI (nativeObject
, destSpace
, srcSpace
, ptrPt
, pts
.Length
);
1674 GDIPlus
.CheckStatus (status
);
1676 GDIPlus
.FromUnManagedMemoryToPointI (ptrPt
, pts
);
1680 public void TranslateClip (int dx
, int dy
)
1682 Status status
= GDIPlus
.GdipTranslateClipI (nativeObject
, dx
, dy
);
1683 GDIPlus
.CheckStatus (status
);
1687 public void TranslateClip (float dx
, float dy
)
1689 Status status
= GDIPlus
.GdipTranslateClip (nativeObject
, dx
, dy
);
1690 GDIPlus
.CheckStatus (status
);
1693 public void TranslateTransform (float dx
, float dy
)
1695 TranslateTransform (dx
, dy
, MatrixOrder
.Prepend
);
1699 public void TranslateTransform (float dx
, float dy
, MatrixOrder order
)
1701 Status status
= GDIPlus
.GdipTranslateWorldTransform (nativeObject
, dx
, dy
, order
);
1702 GDIPlus
.CheckStatus (status
);
1705 public Region Clip
{
1707 Region reg
= new Region();
1708 Status status
= GDIPlus
.GdipGetClip (nativeObject
, reg
.NativeObject
);
1709 GDIPlus
.CheckStatus (status
);
1713 SetClip (value, CombineMode
.Replace
);
1717 public RectangleF ClipBounds
{
1719 RectangleF rect
= new RectangleF ();
1720 Status status
= GDIPlus
.GdipGetClipBounds (nativeObject
, out rect
);
1721 GDIPlus
.CheckStatus (status
);
1726 public CompositingMode CompositingMode
{
1728 CompositingMode mode
;
1729 Status status
= GDIPlus
.GdipGetCompositingMode (nativeObject
, out mode
);
1730 GDIPlus
.CheckStatus (status
);
1735 Status status
= GDIPlus
.GdipSetCompositingMode (nativeObject
, value);
1736 GDIPlus
.CheckStatus (status
);
1741 public CompositingQuality CompositingQuality
{
1743 CompositingQuality quality
;
1745 Status status
= GDIPlus
.GdipGetCompositingQuality (nativeObject
, out quality
);
1746 GDIPlus
.CheckStatus (status
);
1750 Status status
= GDIPlus
.GdipSetCompositingQuality (nativeObject
, value);
1751 GDIPlus
.CheckStatus (status
);
1759 Status status
= GDIPlus
.GdipGetDpiX (nativeObject
, out x
);
1760 GDIPlus
.CheckStatus (status
);
1769 Status status
= GDIPlus
.GdipGetDpiY (nativeObject
, out y
);
1770 GDIPlus
.CheckStatus (status
);
1775 public InterpolationMode InterpolationMode
{
1777 InterpolationMode imode
= InterpolationMode
.Invalid
;
1778 Status status
= GDIPlus
.GdipGetInterpolationMode (nativeObject
, out imode
);
1779 GDIPlus
.CheckStatus (status
);
1783 Status status
= GDIPlus
.GdipSetInterpolationMode (nativeObject
, value);
1784 GDIPlus
.CheckStatus (status
);
1788 public bool IsClipEmpty
{
1790 bool isEmpty
= false;
1792 Status status
= GDIPlus
.GdipIsClipEmpty (nativeObject
, out isEmpty
);
1793 GDIPlus
.CheckStatus (status
);
1798 public bool IsVisibleClipEmpty
{
1800 bool isEmpty
= false;
1802 Status status
= GDIPlus
.GdipIsVisibleClipEmpty (nativeObject
, out isEmpty
);
1803 GDIPlus
.CheckStatus (status
);
1808 public float PageScale
{
1812 Status status
= GDIPlus
.GdipGetPageScale (nativeObject
, out scale
);
1813 GDIPlus
.CheckStatus (status
);
1817 Status status
= GDIPlus
.GdipSetPageScale (nativeObject
, value);
1818 GDIPlus
.CheckStatus (status
);
1822 public GraphicsUnit PageUnit
{
1826 Status status
= GDIPlus
.GdipGetPageUnit (nativeObject
, out unit
);
1827 GDIPlus
.CheckStatus (status
);
1831 Status status
= GDIPlus
.GdipSetPageUnit (nativeObject
, value);
1832 GDIPlus
.CheckStatus (status
);
1836 public PixelOffsetMode PixelOffsetMode
{
1838 PixelOffsetMode pixelOffset
= PixelOffsetMode
.Invalid
;
1840 Status status
= GDIPlus
.GdipGetPixelOffsetMode (nativeObject
, out pixelOffset
);
1841 GDIPlus
.CheckStatus (status
);
1845 Status status
= GDIPlus
.GdipSetPixelOffsetMode (nativeObject
, value);
1846 GDIPlus
.CheckStatus (status
);
1850 public Point RenderingOrigin
{
1853 Status status
= GDIPlus
.GdipGetRenderingOrigin (nativeObject
, out x
, out y
);
1854 GDIPlus
.CheckStatus (status
);
1855 return new Point (x
, y
);
1859 Status status
= GDIPlus
.GdipSetRenderingOrigin (nativeObject
, value.X
, value.Y
);
1860 GDIPlus
.CheckStatus (status
);
1864 public SmoothingMode SmoothingMode
{
1866 SmoothingMode mode
= SmoothingMode
.Invalid
;
1868 Status status
= GDIPlus
.GdipGetSmoothingMode (nativeObject
, out mode
);
1869 GDIPlus
.CheckStatus (status
);
1874 Status status
= GDIPlus
.GdipSetSmoothingMode (nativeObject
, value);
1875 GDIPlus
.CheckStatus (status
);
1879 public int TextContrast
{
1883 Status status
= GDIPlus
.GdipGetTextContrast (nativeObject
, out contrast
);
1884 GDIPlus
.CheckStatus (status
);
1889 Status status
= GDIPlus
.GdipSetTextContrast (nativeObject
, value);
1890 GDIPlus
.CheckStatus (status
);
1894 public TextRenderingHint TextRenderingHint
{
1896 TextRenderingHint hint
;
1898 Status status
= GDIPlus
.GdipGetTextRenderingHint (nativeObject
, out hint
);
1899 GDIPlus
.CheckStatus (status
);
1904 Status status
= GDIPlus
.GdipSetTextRenderingHint (nativeObject
, value);
1905 GDIPlus
.CheckStatus (status
);
1909 public Matrix Transform
{
1911 Matrix matrix
= new Matrix ();
1912 Status status
= GDIPlus
.GdipGetWorldTransform (nativeObject
, matrix
.nativeMatrix
);
1913 GDIPlus
.CheckStatus (status
);
1917 Status status
= GDIPlus
.GdipSetWorldTransform (nativeObject
, value.nativeMatrix
);
1918 GDIPlus
.CheckStatus (status
);
1922 public RectangleF VisibleClipBounds
{
1926 Status status
= GDIPlus
.GdipGetVisibleClipBounds (nativeObject
, out rect
);
1927 GDIPlus
.CheckStatus (status
);