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)
8 // Sebastien Pouliot <sebastien@ximian.com>
10 // Copyright (C) 2003 Ximian, Inc. (http://www.ximian.com)
11 // Copyright (C) 2004-2006 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;
38 using System.Security.Permissions;
41 namespace System.Drawing
46 public sealed class Graphics : MarshalByRefObject, IDisposable
51 internal IntPtr nativeObject = IntPtr.Zero;
52 internal CarbonContext context;
53 private bool disposed = false;
54 private static float defDpiX = 0;
55 private static float defDpiY = 0;
56 private IntPtr deviceContextHdc;
61 public delegate bool EnumerateMetafileProc (EmfPlusRecordType recordType,
65 PlayRecordCallback callbackData);
70 public delegate bool DrawImageAbort (IntPtr callbackData);
72 internal Graphics (IntPtr nativeGraphics)
74 nativeObject = nativeGraphics;
82 static internal float systemDpiX {
85 Bitmap bmp = new Bitmap (1, 1);
86 Graphics g = Graphics.FromImage (bmp);
94 static internal float systemDpiY {
97 Bitmap bmp = new Bitmap (1, 1);
98 Graphics g = Graphics.FromImage (bmp);
106 internal IntPtr NativeObject {
112 nativeObject = value;
116 [MonoTODO ("Metafiles, both WMF and EMF formats, aren't supported.")]
117 public void AddMetafileComment (byte [] data)
119 throw new NotImplementedException ();
122 public GraphicsContainer BeginContainer ()
126 status = GDIPlus.GdipBeginContainer2 (nativeObject, out state);
127 GDIPlus.CheckStatus (status);
129 return new GraphicsContainer(state);
132 [MonoTODO ("The rectangles and unit parameters aren't supported in libgdiplus")]
133 public GraphicsContainer BeginContainer (Rectangle dstrect, Rectangle srcrect, GraphicsUnit unit)
137 status = GDIPlus.GdipBeginContainerI (nativeObject, ref dstrect, ref srcrect, unit, out state);
138 GDIPlus.CheckStatus (status);
140 return new GraphicsContainer (state);
143 [MonoTODO ("The rectangles and unit parameters aren't supported in libgdiplus")]
144 public GraphicsContainer BeginContainer (RectangleF dstrect, RectangleF srcrect, GraphicsUnit unit)
148 status = GDIPlus.GdipBeginContainer (nativeObject, ref dstrect, ref srcrect, unit, out state);
149 GDIPlus.CheckStatus (status);
151 return new GraphicsContainer (state);
155 public void Clear (Color color)
158 status = GDIPlus.GdipGraphicsClear (nativeObject, color.ToArgb ());
159 GDIPlus.CheckStatus (status);
162 [MonoLimitation ("Works on Win32 and on X11 (but not on Cocoa and Quartz)")]
163 public void CopyFromScreen (Point upperLeftSource, Point upperLeftDestination, Size blockRegionSize)
165 CopyFromScreen (upperLeftSource.X, upperLeftSource.Y, upperLeftDestination.X, upperLeftDestination.Y,
166 blockRegionSize, CopyPixelOperation.SourceCopy);
169 [MonoLimitation ("Works on Win32 and (for CopyPixelOperation.SourceCopy only) on X11 but not on Cocoa and Quartz")]
170 public void CopyFromScreen (Point upperLeftSource, Point upperLeftDestination, Size blockRegionSize, CopyPixelOperation copyPixelOperation)
172 CopyFromScreen (upperLeftSource.X, upperLeftSource.Y, upperLeftDestination.X, upperLeftDestination.Y,
173 blockRegionSize, copyPixelOperation);
176 [MonoLimitation ("Works on Win32 and on X11 (but not on Cocoa and Quartz)")]
177 public void CopyFromScreen (int sourceX, int sourceY, int destinationX, int destinationY, Size blockRegionSize)
179 CopyFromScreen (sourceX, sourceY, destinationX, destinationY, blockRegionSize,
180 CopyPixelOperation.SourceCopy);
183 [MonoLimitation ("Works on Win32 and (for CopyPixelOperation.SourceCopy only) on X11 but not on Cocoa and Quartz")]
184 public void CopyFromScreen (int sourceX, int sourceY, int destinationX, int destinationY, Size blockRegionSize, CopyPixelOperation copyPixelOperation)
186 if (!Enum.IsDefined (typeof (CopyPixelOperation), copyPixelOperation))
187 throw new InvalidEnumArgumentException (Locale.GetText ("Enum argument value '{0}' is not valid for CopyPixelOperation", copyPixelOperation));
189 if (GDIPlus.UseX11Drawable) {
190 CopyFromScreenX11 (sourceX, sourceY, destinationX, destinationY, blockRegionSize, copyPixelOperation);
191 } else if (GDIPlus.UseCocoaDrawable || GDIPlus.UseQuartzDrawable) {
192 CopyFromScreenMac (sourceX, sourceY, destinationX, destinationY, blockRegionSize, copyPixelOperation);
194 CopyFromScreenWin32 (sourceX, sourceY, destinationX, destinationY, blockRegionSize, copyPixelOperation);
198 private void CopyFromScreenWin32 (int sourceX, int sourceY, int destinationX, int destinationY, Size blockRegionSize, CopyPixelOperation copyPixelOperation)
200 IntPtr window = GDIPlus.GetDesktopWindow ();
201 IntPtr srcDC = GDIPlus.GetDC (window);
202 IntPtr dstDC = GetHdc ();
203 GDIPlus.BitBlt (dstDC, destinationX, destinationY, blockRegionSize.Width,
204 blockRegionSize.Height, srcDC, sourceX, sourceY, (int) copyPixelOperation);
206 GDIPlus.ReleaseDC (IntPtr.Zero, srcDC);
210 private void CopyFromScreenMac (int sourceX, int sourceY, int destinationX, int destinationY, Size blockRegionSize, CopyPixelOperation copyPixelOperation)
212 throw new NotImplementedException ();
215 private void CopyFromScreenX11 (int sourceX, int sourceY, int destinationX, int destinationY, Size blockRegionSize, CopyPixelOperation copyPixelOperation)
217 IntPtr window, image, defvisual, vPtr;
218 int AllPlanes = ~0, nitems = 0, pixel;
220 if (copyPixelOperation != CopyPixelOperation.SourceCopy)
221 throw new NotImplementedException ("Operation not implemented under X11");
223 if (GDIPlus.Display == IntPtr.Zero) {
224 GDIPlus.Display = GDIPlus.XOpenDisplay (IntPtr.Zero);
227 window = GDIPlus.XRootWindow (GDIPlus.Display, 0);
228 defvisual = GDIPlus.XDefaultVisual (GDIPlus.Display, 0);
229 XVisualInfo visual = new XVisualInfo ();
231 /* Get XVisualInfo for this visual */
232 visual.visualid = GDIPlus.XVisualIDFromVisual(defvisual);
233 vPtr = GDIPlus.XGetVisualInfo (GDIPlus.Display, 0x1 /* VisualIDMask */, ref visual, ref nitems);
234 visual = (XVisualInfo) Marshal.PtrToStructure(vPtr, typeof (XVisualInfo));
236 /* Sorry I do not have access to a computer with > deepth. Fell free to add more pixel formats */
237 image = GDIPlus.XGetImage (GDIPlus.Display, window, sourceX, sourceY, blockRegionSize.Width,
238 blockRegionSize.Height, AllPlanes, 2 /* ZPixmap*/);
240 Bitmap bmp = new Bitmap (blockRegionSize.Width, blockRegionSize.Height);
241 int red, blue, green;
242 for (int y = sourceY; y < sourceY + blockRegionSize.Height; y++) {
243 for (int x = sourceX; x < sourceX + blockRegionSize.Width; x++) {
244 pixel = GDIPlus.XGetPixel (image, x, y);
246 switch (visual.depth) {
247 case 16: /* 16bbp pixel transformation */
248 red = (int) ((pixel & visual.red_mask ) >> 8) & 0xff;
249 green = (int) (((pixel & visual.green_mask ) >> 3 )) & 0xff;
250 blue = (int) ((pixel & visual.blue_mask ) << 3 ) & 0xff;
254 red = (int) ((pixel & visual.red_mask ) >> 16) & 0xff;
255 green = (int) (((pixel & visual.green_mask ) >> 8 )) & 0xff;
256 blue = (int) ((pixel & visual.blue_mask )) & 0xff;
259 throw new NotImplementedException ("Deepth not supported right now");
262 bmp.SetPixel (x, y, Color.FromArgb (255, red, green, blue));
266 DrawImage (bmp, 0, 0);
268 GDIPlus.XDestroyImage (image);
269 GDIPlus.XFree (vPtr);
273 public void Dispose ()
277 if ((GDIPlus.UseQuartzDrawable || GDIPlus.UseCocoaDrawable) && context.ctx != IntPtr.Zero) {
279 Carbon.CGContextSynchronize (context.ctx);
280 Carbon.ReleaseContext (context.port, context.ctx);
282 status = GDIPlus.GdipDeleteGraphics (nativeObject);
283 nativeObject = IntPtr.Zero;
284 GDIPlus.CheckStatus (status);
288 GC.SuppressFinalize(this);
292 public void DrawArc (Pen pen, Rectangle rect, float startAngle, float sweepAngle)
294 DrawArc (pen, rect.X, rect.Y, rect.Width, rect.Height, startAngle, sweepAngle);
298 public void DrawArc (Pen pen, RectangleF rect, float startAngle, float sweepAngle)
300 DrawArc (pen, rect.X, rect.Y, rect.Width, rect.Height, startAngle, sweepAngle);
304 public void DrawArc (Pen pen, float x, float y, float width, float height, float startAngle, float sweepAngle)
308 throw new ArgumentNullException ("pen");
310 status = GDIPlus.GdipDrawArc (nativeObject, pen.nativeObject,
311 x, y, width, height, startAngle, sweepAngle);
312 GDIPlus.CheckStatus (status);
315 // Microsoft documentation states that the signature for this member should be
316 // public void DrawArc( Pen pen, int x, int y, int width, int height, int startAngle,
317 // int sweepAngle. However, GdipDrawArcI uses also float for the startAngle and sweepAngle params
318 public void DrawArc (Pen pen, int x, int y, int width, int height, int startAngle, int sweepAngle)
322 throw new ArgumentNullException ("pen");
323 status = GDIPlus.GdipDrawArcI (nativeObject, pen.nativeObject,
324 x, y, width, height, startAngle, sweepAngle);
325 GDIPlus.CheckStatus (status);
328 public void DrawBezier (Pen pen, PointF pt1, PointF pt2, PointF pt3, PointF pt4)
332 throw new ArgumentNullException ("pen");
333 status = GDIPlus.GdipDrawBezier (nativeObject, pen.nativeObject,
334 pt1.X, pt1.Y, pt2.X, pt2.Y, pt3.X,
335 pt3.Y, pt4.X, pt4.Y);
336 GDIPlus.CheckStatus (status);
339 public void DrawBezier (Pen pen, Point pt1, Point pt2, Point pt3, Point pt4)
343 throw new ArgumentNullException ("pen");
344 status = GDIPlus.GdipDrawBezierI (nativeObject, pen.nativeObject,
345 pt1.X, pt1.Y, pt2.X, pt2.Y, pt3.X,
346 pt3.Y, pt4.X, pt4.Y);
347 GDIPlus.CheckStatus (status);
350 public void DrawBezier (Pen pen, float x1, float y1, float x2, float y2, float x3, float y3, float x4, float y4)
354 throw new ArgumentNullException ("pen");
355 status = GDIPlus.GdipDrawBezier (nativeObject, pen.nativeObject, x1,
356 y1, x2, y2, x3, y3, x4, y4);
357 GDIPlus.CheckStatus (status);
360 public void DrawBeziers (Pen pen, Point [] points)
363 throw new ArgumentNullException ("pen");
365 throw new ArgumentNullException ("points");
367 int length = points.Length;
373 for (int i = 0; i < length - 1; i += 3) {
374 Point p1 = points [i];
375 Point p2 = points [i + 1];
376 Point p3 = points [i + 2];
377 Point p4 = points [i + 3];
379 status = GDIPlus.GdipDrawBezier (nativeObject,
381 p1.X, p1.Y, p2.X, p2.Y,
382 p3.X, p3.Y, p4.X, p4.Y);
383 GDIPlus.CheckStatus (status);
387 public void DrawBeziers (Pen pen, PointF [] points)
390 throw new ArgumentNullException ("pen");
392 throw new ArgumentNullException ("points");
394 int length = points.Length;
400 for (int i = 0; i < length - 1; i += 3) {
401 PointF p1 = points [i];
402 PointF p2 = points [i + 1];
403 PointF p3 = points [i + 2];
404 PointF p4 = points [i + 3];
406 status = GDIPlus.GdipDrawBezier (nativeObject,
408 p1.X, p1.Y, p2.X, p2.Y,
409 p3.X, p3.Y, p4.X, p4.Y);
410 GDIPlus.CheckStatus (status);
415 public void DrawClosedCurve (Pen pen, PointF [] points)
418 throw new ArgumentNullException ("pen");
420 throw new ArgumentNullException ("points");
423 status = GDIPlus.GdipDrawClosedCurve (nativeObject, pen.nativeObject, points, points.Length);
424 GDIPlus.CheckStatus (status);
427 public void DrawClosedCurve (Pen pen, Point [] points)
430 throw new ArgumentNullException ("pen");
432 throw new ArgumentNullException ("points");
435 status = GDIPlus.GdipDrawClosedCurveI (nativeObject, pen.nativeObject, points, points.Length);
436 GDIPlus.CheckStatus (status);
439 public void DrawClosedCurve (Pen pen, Point [] points, float tension, FillMode fillmode)
442 throw new ArgumentNullException ("pen");
444 throw new ArgumentNullException ("points");
447 status = GDIPlus.GdipDrawClosedCurve2I (nativeObject, pen.nativeObject, points, points.Length, tension);
448 GDIPlus.CheckStatus (status);
451 public void DrawClosedCurve (Pen pen, PointF [] points, float tension, FillMode fillmode)
454 throw new ArgumentNullException ("pen");
456 throw new ArgumentNullException ("points");
459 status = GDIPlus.GdipDrawClosedCurve2 (nativeObject, pen.nativeObject, points, points.Length, tension);
460 GDIPlus.CheckStatus (status);
463 public void DrawCurve (Pen pen, Point [] points)
466 throw new ArgumentNullException ("pen");
468 throw new ArgumentNullException ("points");
471 status = GDIPlus.GdipDrawCurveI (nativeObject, pen.nativeObject, points, points.Length);
472 GDIPlus.CheckStatus (status);
475 public void DrawCurve (Pen pen, PointF [] points)
478 throw new ArgumentNullException ("pen");
480 throw new ArgumentNullException ("points");
483 status = GDIPlus.GdipDrawCurve (nativeObject, pen.nativeObject, points, points.Length);
484 GDIPlus.CheckStatus (status);
487 public void DrawCurve (Pen pen, PointF [] points, float tension)
490 throw new ArgumentNullException ("pen");
492 throw new ArgumentNullException ("points");
495 status = GDIPlus.GdipDrawCurve2 (nativeObject, pen.nativeObject, points, points.Length, tension);
496 GDIPlus.CheckStatus (status);
499 public void DrawCurve (Pen pen, Point [] points, float tension)
502 throw new ArgumentNullException ("pen");
504 throw new ArgumentNullException ("points");
507 status = GDIPlus.GdipDrawCurve2I (nativeObject, pen.nativeObject, points, points.Length, tension);
508 GDIPlus.CheckStatus (status);
511 public void DrawCurve (Pen pen, PointF [] points, int offset, int numberOfSegments)
514 throw new ArgumentNullException ("pen");
516 throw new ArgumentNullException ("points");
519 status = GDIPlus.GdipDrawCurve3 (nativeObject, pen.nativeObject,
520 points, points.Length, offset,
521 numberOfSegments, 0.5f);
522 GDIPlus.CheckStatus (status);
525 public void DrawCurve (Pen pen, Point [] points, int offset, int numberOfSegments, float tension)
528 throw new ArgumentNullException ("pen");
530 throw new ArgumentNullException ("points");
533 status = GDIPlus.GdipDrawCurve3I (nativeObject, pen.nativeObject,
534 points, points.Length, offset,
535 numberOfSegments, tension);
536 GDIPlus.CheckStatus (status);
539 public void DrawCurve (Pen pen, PointF [] points, int offset, int numberOfSegments, float tension)
542 throw new ArgumentNullException ("pen");
544 throw new ArgumentNullException ("points");
547 status = GDIPlus.GdipDrawCurve3 (nativeObject, pen.nativeObject,
548 points, points.Length, offset,
549 numberOfSegments, tension);
550 GDIPlus.CheckStatus (status);
553 public void DrawEllipse (Pen pen, Rectangle rect)
556 throw new ArgumentNullException ("pen");
558 DrawEllipse (pen, rect.X, rect.Y, rect.Width, rect.Height);
561 public void DrawEllipse (Pen pen, RectangleF rect)
564 throw new ArgumentNullException ("pen");
565 DrawEllipse (pen, rect.X, rect.Y, rect.Width, rect.Height);
568 public void DrawEllipse (Pen pen, int x, int y, int width, int height)
571 throw new ArgumentNullException ("pen");
573 status = GDIPlus.GdipDrawEllipseI (nativeObject, pen.nativeObject, x, y, width, height);
574 GDIPlus.CheckStatus (status);
577 public void DrawEllipse (Pen pen, float x, float y, float width, float height)
580 throw new ArgumentNullException ("pen");
581 Status status = GDIPlus.GdipDrawEllipse (nativeObject, pen.nativeObject, x, y, width, height);
582 GDIPlus.CheckStatus (status);
585 public void DrawIcon (Icon icon, Rectangle targetRect)
588 throw new ArgumentNullException ("icon");
590 DrawImage (icon.GetInternalBitmap (), targetRect);
593 public void DrawIcon (Icon icon, int x, int y)
596 throw new ArgumentNullException ("icon");
598 DrawImage (icon.GetInternalBitmap (), x, y);
601 public void DrawIconUnstretched (Icon icon, Rectangle targetRect)
604 throw new ArgumentNullException ("icon");
606 DrawImageUnscaled (icon.GetInternalBitmap (), targetRect);
609 public void DrawImage (Image image, RectangleF rect)
612 throw new ArgumentNullException ("image");
614 Status status = GDIPlus.GdipDrawImageRect(nativeObject, image.NativeObject, rect.X, rect.Y, rect.Width, rect.Height);
615 GDIPlus.CheckStatus (status);
618 public void DrawImage (Image image, PointF point)
621 throw new ArgumentNullException ("image");
623 Status status = GDIPlus.GdipDrawImage (nativeObject, image.NativeObject, point.X, point.Y);
624 GDIPlus.CheckStatus (status);
627 public void DrawImage (Image image, Point [] destPoints)
630 throw new ArgumentNullException ("image");
631 if (destPoints == null)
632 throw new ArgumentNullException ("destPoints");
634 Status status = GDIPlus.GdipDrawImagePointsI (nativeObject, image.NativeObject, destPoints, destPoints.Length);
635 GDIPlus.CheckStatus (status);
638 public void DrawImage (Image image, Point point)
641 throw new ArgumentNullException ("image");
642 DrawImage (image, point.X, point.Y);
645 public void DrawImage (Image image, Rectangle rect)
648 throw new ArgumentNullException ("image");
649 DrawImage (image, rect.X, rect.Y, rect.Width, rect.Height);
652 public void DrawImage (Image image, PointF [] destPoints)
655 throw new ArgumentNullException ("image");
656 if (destPoints == null)
657 throw new ArgumentNullException ("destPoints");
658 Status status = GDIPlus.GdipDrawImagePoints (nativeObject, image.NativeObject, destPoints, destPoints.Length);
659 GDIPlus.CheckStatus (status);
662 public void DrawImage (Image image, int x, int y)
665 throw new ArgumentNullException ("image");
666 Status status = GDIPlus.GdipDrawImageI (nativeObject, image.NativeObject, x, y);
667 GDIPlus.CheckStatus (status);
670 public void DrawImage (Image image, float x, float y)
673 throw new ArgumentNullException ("image");
674 Status status = GDIPlus.GdipDrawImage (nativeObject, image.NativeObject, x, y);
675 GDIPlus.CheckStatus (status);
678 public void DrawImage (Image image, Rectangle destRect, Rectangle srcRect, GraphicsUnit srcUnit)
681 throw new ArgumentNullException ("image");
682 Status status = GDIPlus.GdipDrawImageRectRectI (nativeObject, image.NativeObject,
683 destRect.X, destRect.Y, destRect.Width, destRect.Height,
684 srcRect.X, srcRect.Y, srcRect.Width, srcRect.Height,
685 srcUnit, IntPtr.Zero, null, IntPtr.Zero);
686 GDIPlus.CheckStatus (status);
689 public void DrawImage (Image image, RectangleF destRect, RectangleF srcRect, GraphicsUnit srcUnit)
692 throw new ArgumentNullException ("image");
693 Status status = GDIPlus.GdipDrawImageRectRect (nativeObject, image.NativeObject,
694 destRect.X, destRect.Y, destRect.Width, destRect.Height,
695 srcRect.X, srcRect.Y, srcRect.Width, srcRect.Height,
696 srcUnit, IntPtr.Zero, null, IntPtr.Zero);
697 GDIPlus.CheckStatus (status);
700 public void DrawImage (Image image, Point [] destPoints, Rectangle srcRect, GraphicsUnit srcUnit)
703 throw new ArgumentNullException ("image");
704 if (destPoints == null)
705 throw new ArgumentNullException ("destPoints");
707 Status status = GDIPlus.GdipDrawImagePointsRectI (nativeObject, image.NativeObject,
708 destPoints, destPoints.Length , srcRect.X, srcRect.Y,
709 srcRect.Width, srcRect.Height, srcUnit, IntPtr.Zero,
711 GDIPlus.CheckStatus (status);
714 public void DrawImage (Image image, PointF [] destPoints, RectangleF srcRect, GraphicsUnit srcUnit)
717 throw new ArgumentNullException ("image");
718 if (destPoints == null)
719 throw new ArgumentNullException ("destPoints");
721 Status status = GDIPlus.GdipDrawImagePointsRect (nativeObject, image.NativeObject,
722 destPoints, destPoints.Length , srcRect.X, srcRect.Y,
723 srcRect.Width, srcRect.Height, srcUnit, IntPtr.Zero,
725 GDIPlus.CheckStatus (status);
728 public void DrawImage (Image image, Point [] destPoints, Rectangle srcRect, GraphicsUnit srcUnit,
729 ImageAttributes imageAttr)
732 throw new ArgumentNullException ("image");
733 if (destPoints == null)
734 throw new ArgumentNullException ("destPoints");
735 Status status = GDIPlus.GdipDrawImagePointsRectI (nativeObject, image.NativeObject,
736 destPoints, destPoints.Length , srcRect.X, srcRect.Y,
737 srcRect.Width, srcRect.Height, srcUnit,
738 imageAttr != null ? imageAttr.NativeObject : IntPtr.Zero, null, IntPtr.Zero);
739 GDIPlus.CheckStatus (status);
742 public void DrawImage (Image image, float x, float y, float width, float height)
745 throw new ArgumentNullException ("image");
746 Status status = GDIPlus.GdipDrawImageRect(nativeObject, image.NativeObject, x, y,
748 GDIPlus.CheckStatus (status);
751 public void DrawImage (Image image, PointF [] destPoints, RectangleF srcRect, GraphicsUnit srcUnit,
752 ImageAttributes imageAttr)
755 throw new ArgumentNullException ("image");
756 if (destPoints == null)
757 throw new ArgumentNullException ("destPoints");
758 Status status = GDIPlus.GdipDrawImagePointsRect (nativeObject, image.NativeObject,
759 destPoints, destPoints.Length , srcRect.X, srcRect.Y,
760 srcRect.Width, srcRect.Height, srcUnit,
761 imageAttr != null ? imageAttr.NativeObject : IntPtr.Zero, null, IntPtr.Zero);
762 GDIPlus.CheckStatus (status);
765 public void DrawImage (Image image, int x, int y, Rectangle srcRect, GraphicsUnit srcUnit)
768 throw new ArgumentNullException ("image");
769 Status status = GDIPlus.GdipDrawImagePointRectI(nativeObject, image.NativeObject, x, y, srcRect.X, srcRect.Y, srcRect.Width, srcRect.Height, srcUnit);
770 GDIPlus.CheckStatus (status);
773 public void DrawImage (Image image, int x, int y, int width, int height)
776 throw new ArgumentNullException ("image");
777 Status status = GDIPlus.GdipDrawImageRectI (nativeObject, image.nativeObject, x, y, width, height);
778 GDIPlus.CheckStatus (status);
781 public void DrawImage (Image image, float x, float y, RectangleF srcRect, GraphicsUnit srcUnit)
784 throw new ArgumentNullException ("image");
785 Status status = GDIPlus.GdipDrawImagePointRect (nativeObject, image.nativeObject, x, y, srcRect.X, srcRect.Y, srcRect.Width, srcRect.Height, srcUnit);
786 GDIPlus.CheckStatus (status);
789 public void DrawImage (Image image, PointF [] destPoints, RectangleF srcRect, GraphicsUnit srcUnit, ImageAttributes imageAttr, DrawImageAbort callback)
792 throw new ArgumentNullException ("image");
793 if (destPoints == null)
794 throw new ArgumentNullException ("destPoints");
795 Status status = GDIPlus.GdipDrawImagePointsRect (nativeObject, image.NativeObject,
796 destPoints, destPoints.Length , srcRect.X, srcRect.Y,
797 srcRect.Width, srcRect.Height, srcUnit,
798 imageAttr != null ? imageAttr.NativeObject : IntPtr.Zero, callback, IntPtr.Zero);
799 GDIPlus.CheckStatus (status);
802 public void DrawImage (Image image, Point [] destPoints, Rectangle srcRect, GraphicsUnit srcUnit, ImageAttributes imageAttr, DrawImageAbort callback)
805 throw new ArgumentNullException ("image");
806 if (destPoints == null)
807 throw new ArgumentNullException ("destPoints");
809 Status status = GDIPlus.GdipDrawImagePointsRectI (nativeObject, image.NativeObject,
810 destPoints, destPoints.Length , srcRect.X, srcRect.Y,
811 srcRect.Width, srcRect.Height, srcUnit,
812 imageAttr != null ? imageAttr.NativeObject : IntPtr.Zero, callback, IntPtr.Zero);
813 GDIPlus.CheckStatus (status);
816 public void DrawImage (Image image, Point [] destPoints, Rectangle srcRect, GraphicsUnit srcUnit, ImageAttributes imageAttr, DrawImageAbort callback, int callbackData)
819 throw new ArgumentNullException ("image");
820 if (destPoints == null)
821 throw new ArgumentNullException ("destPoints");
823 Status status = GDIPlus.GdipDrawImagePointsRectI (nativeObject, image.NativeObject,
824 destPoints, destPoints.Length , srcRect.X, srcRect.Y,
825 srcRect.Width, srcRect.Height, srcUnit,
826 imageAttr != null ? imageAttr.NativeObject : IntPtr.Zero, callback, (IntPtr) callbackData);
827 GDIPlus.CheckStatus (status);
830 public void DrawImage (Image image, Rectangle destRect, float srcX, float srcY, float srcWidth, float srcHeight, GraphicsUnit srcUnit)
833 throw new ArgumentNullException ("image");
834 Status status = GDIPlus.GdipDrawImageRectRect (nativeObject, image.NativeObject,
835 destRect.X, destRect.Y, destRect.Width, destRect.Height,
836 srcX, srcY, srcWidth, srcHeight, srcUnit, IntPtr.Zero,
838 GDIPlus.CheckStatus (status);
841 public void DrawImage (Image image, PointF [] destPoints, RectangleF srcRect, GraphicsUnit srcUnit, ImageAttributes imageAttr, DrawImageAbort callback, int callbackData)
843 Status status = GDIPlus.GdipDrawImagePointsRect (nativeObject, image.NativeObject,
844 destPoints, destPoints.Length , srcRect.X, srcRect.Y,
845 srcRect.Width, srcRect.Height, srcUnit,
846 imageAttr != null ? imageAttr.NativeObject : IntPtr.Zero, callback, (IntPtr) callbackData);
847 GDIPlus.CheckStatus (status);
850 public void DrawImage (Image image, Rectangle destRect, int srcX, int srcY, int srcWidth, int srcHeight, GraphicsUnit srcUnit)
853 throw new ArgumentNullException ("image");
854 Status status = GDIPlus.GdipDrawImageRectRectI (nativeObject, image.NativeObject,
855 destRect.X, destRect.Y, destRect.Width, destRect.Height,
856 srcX, srcY, srcWidth, srcHeight, srcUnit, IntPtr.Zero,
858 GDIPlus.CheckStatus (status);
861 public void DrawImage (Image image, Rectangle destRect, float srcX, float srcY, float srcWidth, float srcHeight, GraphicsUnit srcUnit, ImageAttributes imageAttrs)
864 throw new ArgumentNullException ("image");
865 Status status = GDIPlus.GdipDrawImageRectRect (nativeObject, image.NativeObject,
866 destRect.X, destRect.Y, destRect.Width, destRect.Height,
867 srcX, srcY, srcWidth, srcHeight, srcUnit,
868 imageAttrs != null ? imageAttrs.NativeObject : IntPtr.Zero, null, IntPtr.Zero);
869 GDIPlus.CheckStatus (status);
872 public void DrawImage (Image image, Rectangle destRect, int srcX, int srcY, int srcWidth, int srcHeight, GraphicsUnit srcUnit, ImageAttributes imageAttr)
875 throw new ArgumentNullException ("image");
876 Status status = GDIPlus.GdipDrawImageRectRectI (nativeObject, image.NativeObject,
877 destRect.X, destRect.Y, destRect.Width,
878 destRect.Height, srcX, srcY, srcWidth, srcHeight,
879 srcUnit, imageAttr != null ? imageAttr.NativeObject : IntPtr.Zero, null, IntPtr.Zero);
880 GDIPlus.CheckStatus (status);
883 public void DrawImage (Image image, Rectangle destRect, int srcX, int srcY, int srcWidth, int srcHeight, GraphicsUnit srcUnit, ImageAttributes imageAttr, DrawImageAbort callback)
886 throw new ArgumentNullException ("image");
887 Status status = GDIPlus.GdipDrawImageRectRectI (nativeObject, image.NativeObject,
888 destRect.X, destRect.Y, destRect.Width,
889 destRect.Height, srcX, srcY, srcWidth, srcHeight,
890 srcUnit, imageAttr != null ? imageAttr.NativeObject : IntPtr.Zero, callback,
892 GDIPlus.CheckStatus (status);
895 public void DrawImage (Image image, Rectangle destRect, float srcX, float srcY, float srcWidth, float srcHeight, GraphicsUnit srcUnit, ImageAttributes imageAttr, DrawImageAbort callback)
898 throw new ArgumentNullException ("image");
899 Status status = GDIPlus.GdipDrawImageRectRect (nativeObject, image.NativeObject,
900 destRect.X, destRect.Y, destRect.Width,
901 destRect.Height, srcX, srcY, srcWidth, srcHeight,
902 srcUnit, imageAttr != null ? imageAttr.NativeObject : IntPtr.Zero,
903 callback, IntPtr.Zero);
904 GDIPlus.CheckStatus (status);
907 public void DrawImage (Image image, Rectangle destRect, float srcX, float srcY, float srcWidth, float srcHeight, GraphicsUnit srcUnit, ImageAttributes imageAttr, DrawImageAbort callback, IntPtr callbackData)
910 throw new ArgumentNullException ("image");
911 Status status = GDIPlus.GdipDrawImageRectRect (nativeObject, image.NativeObject,
912 destRect.X, destRect.Y, destRect.Width, destRect.Height,
913 srcX, srcY, srcWidth, srcHeight, srcUnit,
914 imageAttr != null ? imageAttr.NativeObject : IntPtr.Zero, callback, callbackData);
915 GDIPlus.CheckStatus (status);
918 public void DrawImage (Image image, Rectangle destRect, int srcX, int srcY, int srcWidth, int srcHeight, GraphicsUnit srcUnit, ImageAttributes imageAttr, DrawImageAbort callback, IntPtr callbackData)
921 throw new ArgumentNullException ("image");
922 Status status = GDIPlus.GdipDrawImageRectRect (nativeObject, image.NativeObject,
923 destRect.X, destRect.Y, destRect.Width, destRect.Height,
924 srcX, srcY, srcWidth, srcHeight, srcUnit,
925 imageAttr != null ? imageAttr.NativeObject : IntPtr.Zero, callback, callbackData);
926 GDIPlus.CheckStatus (status);
929 public void DrawImageUnscaled (Image image, Point point)
931 DrawImageUnscaled (image, point.X, point.Y);
934 public void DrawImageUnscaled (Image image, Rectangle rect)
936 DrawImageUnscaled (image, rect.X, rect.Y, rect.Width, rect.Height);
939 public void DrawImageUnscaled (Image image, int x, int y)
942 throw new ArgumentNullException ("image");
943 DrawImage (image, x, y, image.Width, image.Height);
946 public void DrawImageUnscaled (Image image, int x, int y, int width, int height)
949 throw new ArgumentNullException ("image");
951 // avoid creating an empty, or negative w/h, bitmap...
952 if ((width <= 0) || (height <= 0))
955 using (Image tmpImg = new Bitmap (width, height)) {
956 using (Graphics g = FromImage (tmpImg)) {
957 g.DrawImage (image, 0, 0, image.Width, image.Height);
958 DrawImage (tmpImg, x, y, width, height);
964 public void DrawImageUnscaledAndClipped (Image image, Rectangle rect)
967 throw new ArgumentNullException ("image");
969 int width = (image.Width > rect.Width) ? rect.Width : image.Width;
970 int height = (image.Height > rect.Height) ? rect.Height : image.Height;
972 DrawImageUnscaled (image, rect.X, rect.Y, width, height);
976 public void DrawLine (Pen pen, PointF pt1, PointF pt2)
979 throw new ArgumentNullException ("pen");
980 Status status = GDIPlus.GdipDrawLine (nativeObject, pen.nativeObject,
981 pt1.X, pt1.Y, pt2.X, pt2.Y);
982 GDIPlus.CheckStatus (status);
985 public void DrawLine (Pen pen, Point pt1, Point pt2)
988 throw new ArgumentNullException ("pen");
989 Status status = GDIPlus.GdipDrawLineI (nativeObject, pen.nativeObject,
990 pt1.X, pt1.Y, pt2.X, pt2.Y);
991 GDIPlus.CheckStatus (status);
994 public void DrawLine (Pen pen, int x1, int y1, int x2, int y2)
997 throw new ArgumentNullException ("pen");
998 Status status = GDIPlus.GdipDrawLineI (nativeObject, pen.nativeObject, x1, y1, x2, y2);
999 GDIPlus.CheckStatus (status);
1002 public void DrawLine (Pen pen, float x1, float y1, float x2, float y2)
1005 throw new ArgumentNullException ("pen");
1006 Status status = GDIPlus.GdipDrawLine (nativeObject, pen.nativeObject, x1, y1, x2, y2);
1007 GDIPlus.CheckStatus (status);
1010 public void DrawLines (Pen pen, PointF [] points)
1013 throw new ArgumentNullException ("pen");
1015 throw new ArgumentNullException ("points");
1016 Status status = GDIPlus.GdipDrawLines (nativeObject, pen.nativeObject, points, points.Length);
1017 GDIPlus.CheckStatus (status);
1020 public void DrawLines (Pen pen, Point [] points)
1023 throw new ArgumentNullException ("pen");
1025 throw new ArgumentNullException ("points");
1026 Status status = GDIPlus.GdipDrawLinesI (nativeObject, pen.nativeObject, points, points.Length);
1027 GDIPlus.CheckStatus (status);
1030 public void DrawPath (Pen pen, GraphicsPath path)
1033 throw new ArgumentNullException ("pen");
1035 throw new ArgumentNullException ("path");
1036 Status status = GDIPlus.GdipDrawPath (nativeObject, pen.nativeObject, path.nativePath);
1037 GDIPlus.CheckStatus (status);
1040 public void DrawPie (Pen pen, Rectangle rect, float startAngle, float sweepAngle)
1043 throw new ArgumentNullException ("pen");
1044 DrawPie (pen, rect.X, rect.Y, rect.Width, rect.Height, startAngle, sweepAngle);
1047 public void DrawPie (Pen pen, RectangleF rect, float startAngle, float sweepAngle)
1050 throw new ArgumentNullException ("pen");
1051 DrawPie (pen, rect.X, rect.Y, rect.Width, rect.Height, startAngle, sweepAngle);
1054 public void DrawPie (Pen pen, float x, float y, float width, float height, float startAngle, float sweepAngle)
1057 throw new ArgumentNullException ("pen");
1058 Status status = GDIPlus.GdipDrawPie (nativeObject, pen.nativeObject, x, y, width, height, startAngle, sweepAngle);
1059 GDIPlus.CheckStatus (status);
1062 // Microsoft documentation states that the signature for this member should be
1063 // public void DrawPie(Pen pen, int x, int y, int width, int height, int startAngle
1064 // int sweepAngle. However, GdipDrawPieI uses also float for the startAngle and sweepAngle params
1065 public void DrawPie (Pen pen, int x, int y, int width, int height, int startAngle, int sweepAngle)
1068 throw new ArgumentNullException ("pen");
1069 Status status = GDIPlus.GdipDrawPieI (nativeObject, pen.nativeObject, x, y, width, height, startAngle, sweepAngle);
1070 GDIPlus.CheckStatus (status);
1073 public void DrawPolygon (Pen pen, Point [] points)
1076 throw new ArgumentNullException ("pen");
1078 throw new ArgumentNullException ("points");
1079 Status status = GDIPlus.GdipDrawPolygonI (nativeObject, pen.nativeObject, points, points.Length);
1080 GDIPlus.CheckStatus (status);
1083 public void DrawPolygon (Pen pen, PointF [] points)
1086 throw new ArgumentNullException ("pen");
1088 throw new ArgumentNullException ("points");
1089 Status status = GDIPlus.GdipDrawPolygon (nativeObject, pen.nativeObject, points, points.Length);
1090 GDIPlus.CheckStatus (status);
1093 internal void DrawRectangle (Pen pen, RectangleF rect)
1096 throw new ArgumentNullException ("pen");
1097 DrawRectangle (pen, rect.Left, rect.Top, rect.Width, rect.Height);
1100 public void DrawRectangle (Pen pen, Rectangle rect)
1103 throw new ArgumentNullException ("pen");
1104 DrawRectangle (pen, rect.Left, rect.Top, rect.Width, rect.Height);
1107 public void DrawRectangle (Pen pen, float x, float y, float width, float height)
1110 throw new ArgumentNullException ("pen");
1111 Status status = GDIPlus.GdipDrawRectangle (nativeObject, pen.nativeObject, x, y, width, height);
1112 GDIPlus.CheckStatus (status);
1115 public void DrawRectangle (Pen pen, int x, int y, int width, int height)
1118 throw new ArgumentNullException ("pen");
1119 Status status = GDIPlus.GdipDrawRectangleI (nativeObject, pen.nativeObject, x, y, width, height);
1120 GDIPlus.CheckStatus (status);
1123 public void DrawRectangles (Pen pen, RectangleF [] rects)
1126 throw new ArgumentNullException ("image");
1128 throw new ArgumentNullException ("rects");
1129 Status status = GDIPlus.GdipDrawRectangles (nativeObject, pen.nativeObject, rects, rects.Length);
1130 GDIPlus.CheckStatus (status);
1133 public void DrawRectangles (Pen pen, Rectangle [] rects)
1136 throw new ArgumentNullException ("image");
1138 throw new ArgumentNullException ("rects");
1139 Status status = GDIPlus.GdipDrawRectanglesI (nativeObject, pen.nativeObject, rects, rects.Length);
1140 GDIPlus.CheckStatus (status);
1143 public void DrawString (string s, Font font, Brush brush, RectangleF layoutRectangle)
1145 DrawString (s, font, brush, layoutRectangle, null);
1148 public void DrawString (string s, Font font, Brush brush, PointF point)
1150 DrawString (s, font, brush, new RectangleF (point.X, point.Y, 0, 0), null);
1153 public void DrawString (string s, Font font, Brush brush, PointF point, StringFormat format)
1155 DrawString(s, font, brush, new RectangleF(point.X, point.Y, 0, 0), format);
1158 public void DrawString (string s, Font font, Brush brush, float x, float y)
1160 DrawString (s, font, brush, new RectangleF (x, y, 0, 0), null);
1163 public void DrawString (string s, Font font, Brush brush, float x, float y, StringFormat format)
1165 DrawString (s, font, brush, new RectangleF(x, y, 0, 0), format);
1168 public void DrawString (string s, Font font, Brush brush, RectangleF layoutRectangle, StringFormat format)
1171 throw new ArgumentNullException ("font");
1173 throw new ArgumentNullException ("brush");
1174 if (s == null || s.Length == 0)
1177 Status status = GDIPlus.GdipDrawString (nativeObject, s, s.Length, font.NativeObject, ref layoutRectangle, format != null ? format.NativeObject : IntPtr.Zero, brush.nativeObject);
1178 GDIPlus.CheckStatus (status);
1181 public void EndContainer (GraphicsContainer container)
1184 if (container == null)
1185 throw new ArgumentNullException ("container");
1187 Status status = GDIPlus.GdipEndContainer(nativeObject, container.NativeObject);
1188 GDIPlus.CheckStatus (status);
1191 private const string MetafileEnumeration = "Metafiles enumeration, for both WMF and EMF formats, isn't supported.";
1193 [MonoTODO (MetafileEnumeration)]
1194 public void EnumerateMetafile (Metafile metafile, Point [] destPoints, EnumerateMetafileProc callback)
1196 throw new NotImplementedException ();
1199 [MonoTODO (MetafileEnumeration)]
1200 public void EnumerateMetafile (Metafile metafile, RectangleF destRect, EnumerateMetafileProc callback)
1202 throw new NotImplementedException ();
1205 [MonoTODO (MetafileEnumeration)]
1206 public void EnumerateMetafile (Metafile metafile, PointF [] destPoints, EnumerateMetafileProc callback)
1208 throw new NotImplementedException ();
1211 [MonoTODO (MetafileEnumeration)]
1212 public void EnumerateMetafile (Metafile metafile, Rectangle destRect, EnumerateMetafileProc callback)
1214 throw new NotImplementedException ();
1217 [MonoTODO (MetafileEnumeration)]
1218 public void EnumerateMetafile (Metafile metafile, Point destPoint, EnumerateMetafileProc callback)
1220 throw new NotImplementedException ();
1223 [MonoTODO (MetafileEnumeration)]
1224 public void EnumerateMetafile (Metafile metafile, PointF destPoint, EnumerateMetafileProc callback)
1226 throw new NotImplementedException ();
1229 [MonoTODO (MetafileEnumeration)]
1230 public void EnumerateMetafile (Metafile metafile, PointF destPoint, EnumerateMetafileProc callback, IntPtr callbackData)
1232 throw new NotImplementedException ();
1235 [MonoTODO (MetafileEnumeration)]
1236 public void EnumerateMetafile (Metafile metafile, Rectangle destRect, EnumerateMetafileProc callback, IntPtr callbackData)
1238 throw new NotImplementedException ();
1241 [MonoTODO (MetafileEnumeration)]
1242 public void EnumerateMetafile (Metafile metafile, PointF [] destPoints, EnumerateMetafileProc callback, IntPtr callbackData)
1244 throw new NotImplementedException ();
1247 [MonoTODO (MetafileEnumeration)]
1248 public void EnumerateMetafile (Metafile metafile, Point destPoint, EnumerateMetafileProc callback, IntPtr callbackData)
1250 throw new NotImplementedException ();
1253 [MonoTODO (MetafileEnumeration)]
1254 public void EnumerateMetafile (Metafile metafile, Point [] destPoints, EnumerateMetafileProc callback, IntPtr callbackData)
1256 throw new NotImplementedException ();
1259 [MonoTODO (MetafileEnumeration)]
1260 public void EnumerateMetafile (Metafile metafile, RectangleF destRect, EnumerateMetafileProc callback, IntPtr callbackData)
1262 throw new NotImplementedException ();
1265 [MonoTODO (MetafileEnumeration)]
1266 public void EnumerateMetafile (Metafile metafile, PointF destPoint, RectangleF srcRect, GraphicsUnit srcUnit, EnumerateMetafileProc callback)
1268 throw new NotImplementedException ();
1271 [MonoTODO (MetafileEnumeration)]
1272 public void EnumerateMetafile (Metafile metafile, Point destPoint, Rectangle srcRect, GraphicsUnit srcUnit, EnumerateMetafileProc callback)
1274 throw new NotImplementedException ();
1277 [MonoTODO (MetafileEnumeration)]
1278 public void EnumerateMetafile (Metafile metafile, PointF [] destPoints, RectangleF srcRect, GraphicsUnit srcUnit, EnumerateMetafileProc callback)
1280 throw new NotImplementedException ();
1283 [MonoTODO (MetafileEnumeration)]
1284 public void EnumerateMetafile (Metafile metafile, Point [] destPoints, Rectangle srcRect, GraphicsUnit srcUnit, EnumerateMetafileProc callback)
1286 throw new NotImplementedException ();
1289 [MonoTODO (MetafileEnumeration)]
1290 public void EnumerateMetafile (Metafile metafile, RectangleF destRect, RectangleF srcRect, GraphicsUnit srcUnit, EnumerateMetafileProc callback)
1292 throw new NotImplementedException ();
1295 [MonoTODO (MetafileEnumeration)]
1296 public void EnumerateMetafile (Metafile metafile, Rectangle destRect, Rectangle srcRect, GraphicsUnit srcUnit, EnumerateMetafileProc callback)
1298 throw new NotImplementedException ();
1301 [MonoTODO (MetafileEnumeration)]
1302 public void EnumerateMetafile (Metafile metafile, RectangleF destRect, EnumerateMetafileProc callback, IntPtr callbackData, ImageAttributes imageAttr)
1304 throw new NotImplementedException ();
1307 [MonoTODO (MetafileEnumeration)]
1308 public void EnumerateMetafile (Metafile metafile, Point destPoint, EnumerateMetafileProc callback, IntPtr callbackData, ImageAttributes imageAttr)
1310 throw new NotImplementedException ();
1313 [MonoTODO (MetafileEnumeration)]
1314 public void EnumerateMetafile (Metafile metafile, PointF destPoint, EnumerateMetafileProc callback, IntPtr callbackData, ImageAttributes imageAttr)
1316 throw new NotImplementedException ();
1319 [MonoTODO (MetafileEnumeration)]
1320 public void EnumerateMetafile (Metafile metafile, Point [] destPoints, EnumerateMetafileProc callback, IntPtr callbackData, ImageAttributes imageAttr)
1322 throw new NotImplementedException ();
1325 [MonoTODO (MetafileEnumeration)]
1326 public void EnumerateMetafile (Metafile metafile, PointF [] destPoints, EnumerateMetafileProc callback, IntPtr callbackData, ImageAttributes imageAttr)
1328 throw new NotImplementedException ();
1331 [MonoTODO (MetafileEnumeration)]
1332 public void EnumerateMetafile (Metafile metafile, Rectangle destRect, EnumerateMetafileProc callback, IntPtr callbackData, ImageAttributes imageAttr)
1334 throw new NotImplementedException ();
1337 [MonoTODO (MetafileEnumeration)]
1338 public void EnumerateMetafile (Metafile metafile, Rectangle destRect, Rectangle srcRect, GraphicsUnit srcUnit, EnumerateMetafileProc callback, IntPtr callbackData)
1340 throw new NotImplementedException ();
1343 [MonoTODO (MetafileEnumeration)]
1344 public void EnumerateMetafile (Metafile metafile, PointF [] destPoints, RectangleF srcRect, GraphicsUnit srcUnit, EnumerateMetafileProc callback, IntPtr callbackData)
1346 throw new NotImplementedException ();
1349 [MonoTODO (MetafileEnumeration)]
1350 public void EnumerateMetafile (Metafile metafile, RectangleF destRect, RectangleF srcRect, GraphicsUnit srcUnit, EnumerateMetafileProc callback, IntPtr callbackData)
1352 throw new NotImplementedException ();
1355 [MonoTODO (MetafileEnumeration)]
1356 public void EnumerateMetafile (Metafile metafile, PointF destPoint, RectangleF srcRect, GraphicsUnit srcUnit, EnumerateMetafileProc callback, IntPtr callbackData)
1358 throw new NotImplementedException ();
1361 [MonoTODO (MetafileEnumeration)]
1362 public void EnumerateMetafile (Metafile metafile, Point destPoint, Rectangle srcRect, GraphicsUnit srcUnit, EnumerateMetafileProc callback, IntPtr callbackData)
1364 throw new NotImplementedException ();
1367 [MonoTODO (MetafileEnumeration)]
1368 public void EnumerateMetafile (Metafile metafile, Point [] destPoints, Rectangle srcRect, GraphicsUnit srcUnit, EnumerateMetafileProc callback, IntPtr callbackData)
1370 throw new NotImplementedException ();
1373 [MonoTODO (MetafileEnumeration)]
1374 public void EnumerateMetafile (Metafile metafile, Point [] destPoints, Rectangle srcRect, GraphicsUnit unit, EnumerateMetafileProc callback, IntPtr callbackData, ImageAttributes imageAttr)
1376 throw new NotImplementedException ();
1379 [MonoTODO (MetafileEnumeration)]
1380 public void EnumerateMetafile (Metafile metafile, Rectangle destRect, Rectangle srcRect, GraphicsUnit unit, EnumerateMetafileProc callback, IntPtr callbackData, ImageAttributes imageAttr)
1382 throw new NotImplementedException ();
1385 [MonoTODO (MetafileEnumeration)]
1386 public void EnumerateMetafile (Metafile metafile, Point destPoint, Rectangle srcRect, GraphicsUnit unit, EnumerateMetafileProc callback, IntPtr callbackData, ImageAttributes imageAttr)
1388 throw new NotImplementedException ();
1391 [MonoTODO (MetafileEnumeration)]
1392 public void EnumerateMetafile (Metafile metafile, RectangleF destRect, RectangleF srcRect, GraphicsUnit unit, EnumerateMetafileProc callback, IntPtr callbackData, ImageAttributes imageAttr)
1394 throw new NotImplementedException ();
1397 [MonoTODO (MetafileEnumeration)]
1398 public void EnumerateMetafile (Metafile metafile, PointF [] destPoints, RectangleF srcRect, GraphicsUnit unit, EnumerateMetafileProc callback, IntPtr callbackData, ImageAttributes imageAttr)
1400 throw new NotImplementedException ();
1403 [MonoTODO (MetafileEnumeration)]
1404 public void EnumerateMetafile (Metafile metafile, PointF destPoint, RectangleF srcRect, GraphicsUnit unit, EnumerateMetafileProc callback, IntPtr callbackData, ImageAttributes imageAttr)
1406 throw new NotImplementedException ();
1409 public void ExcludeClip (Rectangle rect)
1411 Status status = GDIPlus.GdipSetClipRectI (nativeObject, rect.X, rect.Y, rect.Width, rect.Height, CombineMode.Exclude);
1412 GDIPlus.CheckStatus (status);
1415 public void ExcludeClip (Region region)
1418 throw new ArgumentNullException ("region");
1419 Status status = GDIPlus.GdipSetClipRegion (nativeObject, region.NativeObject, CombineMode.Exclude);
1420 GDIPlus.CheckStatus (status);
1424 public void FillClosedCurve (Brush brush, PointF [] points)
1427 throw new ArgumentNullException ("brush");
1429 throw new ArgumentNullException ("points");
1430 Status status = GDIPlus.GdipFillClosedCurve (nativeObject, brush.NativeObject, points, points.Length);
1431 GDIPlus.CheckStatus (status);
1434 public void FillClosedCurve (Brush brush, Point [] points)
1437 throw new ArgumentNullException ("brush");
1439 throw new ArgumentNullException ("points");
1440 Status status = GDIPlus.GdipFillClosedCurveI (nativeObject, brush.NativeObject, points, points.Length);
1441 GDIPlus.CheckStatus (status);
1445 public void FillClosedCurve (Brush brush, PointF [] points, FillMode fillmode)
1448 throw new ArgumentNullException ("brush");
1450 throw new ArgumentNullException ("points");
1451 FillClosedCurve (brush, points, fillmode, 0.5f);
1454 public void FillClosedCurve (Brush brush, Point [] points, FillMode fillmode)
1457 throw new ArgumentNullException ("brush");
1459 throw new ArgumentNullException ("points");
1460 FillClosedCurve (brush, points, fillmode, 0.5f);
1463 public void FillClosedCurve (Brush brush, PointF [] points, FillMode fillmode, float tension)
1466 throw new ArgumentNullException ("brush");
1468 throw new ArgumentNullException ("points");
1469 Status status = GDIPlus.GdipFillClosedCurve2 (nativeObject, brush.NativeObject, points, points.Length, tension, fillmode);
1470 GDIPlus.CheckStatus (status);
1473 public void FillClosedCurve (Brush brush, Point [] points, FillMode fillmode, float tension)
1476 throw new ArgumentNullException ("brush");
1478 throw new ArgumentNullException ("points");
1479 Status status = GDIPlus.GdipFillClosedCurve2I (nativeObject, brush.NativeObject, points, points.Length, tension, fillmode);
1480 GDIPlus.CheckStatus (status);
1483 public void FillEllipse (Brush brush, Rectangle rect)
1486 throw new ArgumentNullException ("brush");
1487 FillEllipse (brush, rect.X, rect.Y, rect.Width, rect.Height);
1490 public void FillEllipse (Brush brush, RectangleF rect)
1493 throw new ArgumentNullException ("brush");
1494 FillEllipse (brush, rect.X, rect.Y, rect.Width, rect.Height);
1497 public void FillEllipse (Brush brush, float x, float y, float width, float height)
1500 throw new ArgumentNullException ("brush");
1501 Status status = GDIPlus.GdipFillEllipse (nativeObject, brush.nativeObject, x, y, width, height);
1502 GDIPlus.CheckStatus (status);
1505 public void FillEllipse (Brush brush, int x, int y, int width, int height)
1508 throw new ArgumentNullException ("brush");
1509 Status status = GDIPlus.GdipFillEllipseI (nativeObject, brush.nativeObject, x, y, width, height);
1510 GDIPlus.CheckStatus (status);
1513 public void FillPath (Brush brush, GraphicsPath path)
1516 throw new ArgumentNullException ("brush");
1518 throw new ArgumentNullException ("path");
1519 Status status = GDIPlus.GdipFillPath (nativeObject, brush.NativeObject, path.NativeObject);
1520 GDIPlus.CheckStatus (status);
1523 public void FillPie (Brush brush, Rectangle rect, float startAngle, float sweepAngle)
1526 throw new ArgumentNullException ("brush");
1527 Status status = GDIPlus.GdipFillPie (nativeObject, brush.NativeObject, rect.X, rect.Y, rect.Width, rect.Height, startAngle, sweepAngle);
1528 GDIPlus.CheckStatus (status);
1531 public void FillPie (Brush brush, int x, int y, int width, int height, int startAngle, int sweepAngle)
1534 throw new ArgumentNullException ("brush");
1535 Status status = GDIPlus.GdipFillPieI (nativeObject, brush.NativeObject, x, y, width, height, startAngle, sweepAngle);
1536 GDIPlus.CheckStatus (status);
1539 public void FillPie (Brush brush, float x, float y, float width, float height, float startAngle, float sweepAngle)
1542 throw new ArgumentNullException ("brush");
1543 Status status = GDIPlus.GdipFillPie (nativeObject, brush.NativeObject, x, y, width, height, startAngle, sweepAngle);
1544 GDIPlus.CheckStatus (status);
1547 public void FillPolygon (Brush brush, PointF [] points)
1550 throw new ArgumentNullException ("brush");
1552 throw new ArgumentNullException ("points");
1553 Status status = GDIPlus.GdipFillPolygon2 (nativeObject, brush.nativeObject, points, points.Length);
1554 GDIPlus.CheckStatus (status);
1557 public void FillPolygon (Brush brush, Point [] points)
1560 throw new ArgumentNullException ("brush");
1562 throw new ArgumentNullException ("points");
1563 Status status = GDIPlus.GdipFillPolygon2I (nativeObject, brush.nativeObject, points, points.Length);
1564 GDIPlus.CheckStatus (status);
1567 public void FillPolygon (Brush brush, Point [] points, FillMode fillMode)
1570 throw new ArgumentNullException ("brush");
1572 throw new ArgumentNullException ("points");
1573 Status status = GDIPlus.GdipFillPolygonI (nativeObject, brush.nativeObject, points, points.Length, fillMode);
1574 GDIPlus.CheckStatus (status);
1577 public void FillPolygon (Brush brush, PointF [] points, FillMode fillMode)
1580 throw new ArgumentNullException ("brush");
1582 throw new ArgumentNullException ("points");
1583 Status status = GDIPlus.GdipFillPolygon (nativeObject, brush.nativeObject, points, points.Length, fillMode);
1584 GDIPlus.CheckStatus (status);
1587 public void FillRectangle (Brush brush, RectangleF rect)
1590 throw new ArgumentNullException ("brush");
1591 FillRectangle (brush, rect.Left, rect.Top, rect.Width, rect.Height);
1594 public void FillRectangle (Brush brush, Rectangle rect)
1597 throw new ArgumentNullException ("brush");
1598 FillRectangle (brush, rect.Left, rect.Top, rect.Width, rect.Height);
1601 public void FillRectangle (Brush brush, int x, int y, int width, int height)
1604 throw new ArgumentNullException ("brush");
1606 Status status = GDIPlus.GdipFillRectangleI (nativeObject, brush.nativeObject, x, y, width, height);
1607 GDIPlus.CheckStatus (status);
1610 public void FillRectangle (Brush brush, float x, float y, float width, float height)
1613 throw new ArgumentNullException ("brush");
1615 Status status = GDIPlus.GdipFillRectangle (nativeObject, brush.nativeObject, x, y, width, height);
1616 GDIPlus.CheckStatus (status);
1619 public void FillRectangles (Brush brush, Rectangle [] rects)
1622 throw new ArgumentNullException ("brush");
1624 throw new ArgumentNullException ("rects");
1626 Status status = GDIPlus.GdipFillRectanglesI (nativeObject, brush.nativeObject, rects, rects.Length);
1627 GDIPlus.CheckStatus (status);
1630 public void FillRectangles (Brush brush, RectangleF [] rects)
1633 throw new ArgumentNullException ("brush");
1635 throw new ArgumentNullException ("rects");
1637 Status status = GDIPlus.GdipFillRectangles (nativeObject, brush.nativeObject, rects, rects.Length);
1638 GDIPlus.CheckStatus (status);
1642 public void FillRegion (Brush brush, Region region)
1645 throw new ArgumentNullException ("brush");
1647 throw new ArgumentNullException ("region");
1649 Status status = GDIPlus.GdipFillRegion (nativeObject, brush.NativeObject, region.NativeObject);
1650 GDIPlus.CheckStatus(status);
1654 public void Flush ()
1656 Flush (FlushIntention.Flush);
1660 public void Flush (FlushIntention intention)
1662 if (nativeObject == IntPtr.Zero) {
1666 Status status = GDIPlus.GdipFlush (nativeObject, intention);
1667 GDIPlus.CheckStatus (status);
1668 if ((GDIPlus.UseQuartzDrawable || GDIPlus.UseCocoaDrawable) && context.ctx != IntPtr.Zero)
1669 Carbon.CGContextSynchronize (context.ctx);
1672 [EditorBrowsable (EditorBrowsableState.Advanced)]
1673 public static Graphics FromHdc (IntPtr hdc)
1676 Status status = GDIPlus.GdipCreateFromHDC (hdc, out graphics);
1677 GDIPlus.CheckStatus (status);
1678 return new Graphics (graphics);
1682 [EditorBrowsable (EditorBrowsableState.Advanced)]
1683 public static Graphics FromHdc (IntPtr hdc, IntPtr hdevice)
1685 throw new NotImplementedException ();
1688 [EditorBrowsable (EditorBrowsableState.Advanced)]
1689 [SecurityPermission (SecurityAction.LinkDemand, UnmanagedCode = true)]
1690 public static Graphics FromHdcInternal (IntPtr hdc)
1692 GDIPlus.Display = hdc;
1696 [EditorBrowsable (EditorBrowsableState.Advanced)]
1697 public static Graphics FromHwnd (IntPtr hwnd)
1701 if (GDIPlus.UseCocoaDrawable) {
1702 throw new NotImplementedException ();
1703 /* TODO: Fix this code to handle the new libgdiplus
1704 CarbonContext context = Carbon.GetCGContextForNSView (hwnd);
1705 GDIPlus.GdipCreateFromQuartz_macosx (context.ctx, context.width, context.height, out graphics);
1707 Graphics g = new Graphics (graphics);
1708 g.context = context;
1713 if (GDIPlus.UseQuartzDrawable) {
1714 CarbonContext context = Carbon.GetCGContextForView (hwnd);
1715 GDIPlus.GdipCreateFromQuartz_macosx (context.ctx, context.width, context.height, out graphics);
1717 Graphics g = new Graphics (graphics);
1718 g.context = context;
1722 if (GDIPlus.UseX11Drawable) {
1723 if (GDIPlus.Display == IntPtr.Zero) {
1724 GDIPlus.Display = GDIPlus.XOpenDisplay (IntPtr.Zero);
1726 if (hwnd == IntPtr.Zero) {
1727 hwnd = GDIPlus.XRootWindow (GDIPlus.Display, GDIPlus.XDefaultScreen (GDIPlus.Display));
1730 return FromXDrawable (hwnd, GDIPlus.Display);
1734 Status status = GDIPlus.GdipCreateFromHWND (hwnd, out graphics);
1735 GDIPlus.CheckStatus (status);
1737 return new Graphics (graphics);
1740 [EditorBrowsable (EditorBrowsableState.Advanced)]
1741 [SecurityPermission (SecurityAction.LinkDemand, UnmanagedCode = true)]
1742 public static Graphics FromHwndInternal (IntPtr hwnd)
1744 return FromHwnd (hwnd);
1747 public static Graphics FromImage (Image image)
1752 throw new ArgumentNullException ("image");
1754 if ((image.PixelFormat & PixelFormat.Indexed) != 0)
1755 throw new Exception (Locale.GetText ("Cannot create Graphics from an indexed bitmap."));
1757 Status status = GDIPlus.GdipGetImageGraphicsContext (image.nativeObject, out graphics);
1758 GDIPlus.CheckStatus (status);
1759 Graphics result = new Graphics (graphics);
1761 if (GDIPlus.RunningOnUnix ()) {
1762 Rectangle rect = new Rectangle (0,0, image.Width, image.Height);
1763 GDIPlus.GdipSetVisibleClip_linux (result.NativeObject, ref rect);
1769 internal static Graphics FromXDrawable (IntPtr drawable, IntPtr display)
1773 Status s = GDIPlus.GdipCreateFromXDrawable_linux (drawable, display, out graphics);
1774 GDIPlus.CheckStatus (s);
1775 return new Graphics (graphics);
1779 public static IntPtr GetHalftonePalette ()
1781 throw new NotImplementedException ();
1785 [EditorBrowsable (EditorBrowsableState.Advanced)]
1787 public IntPtr GetHdc ()
1789 GDIPlus.CheckStatus (GDIPlus.GdipGetDC (this.nativeObject, out deviceContextHdc));
1790 return deviceContextHdc;
1793 public Color GetNearestColor (Color color)
1797 Status status = GDIPlus.GdipGetNearestColor (nativeObject, out argb);
1798 GDIPlus.CheckStatus (status);
1800 return Color.FromArgb (argb);
1804 public void IntersectClip (Region region)
1807 throw new ArgumentNullException ("region");
1808 Status status = GDIPlus.GdipSetClipRegion (nativeObject, region.NativeObject, CombineMode.Intersect);
1809 GDIPlus.CheckStatus (status);
1812 public void IntersectClip (RectangleF rect)
1814 Status status = GDIPlus.GdipSetClipRect (nativeObject, rect.X, rect.Y, rect.Width, rect.Height, CombineMode.Intersect);
1815 GDIPlus.CheckStatus (status);
1818 public void IntersectClip (Rectangle rect)
1820 Status status = GDIPlus.GdipSetClipRectI (nativeObject, rect.X, rect.Y, rect.Width, rect.Height, CombineMode.Intersect);
1821 GDIPlus.CheckStatus (status);
1824 public bool IsVisible (Point point)
1826 bool isVisible = false;
1828 Status status = GDIPlus.GdipIsVisiblePointI (nativeObject, point.X, point.Y, out isVisible);
1829 GDIPlus.CheckStatus (status);
1835 public bool IsVisible (RectangleF rect)
1837 bool isVisible = false;
1839 Status status = GDIPlus.GdipIsVisibleRect (nativeObject, rect.X, rect.Y, rect.Width, rect.Height, out isVisible);
1840 GDIPlus.CheckStatus (status);
1845 public bool IsVisible (PointF point)
1847 bool isVisible = false;
1849 Status status = GDIPlus.GdipIsVisiblePoint (nativeObject, point.X, point.Y, out isVisible);
1850 GDIPlus.CheckStatus (status);
1855 public bool IsVisible (Rectangle rect)
1857 bool isVisible = false;
1859 Status status = GDIPlus.GdipIsVisibleRectI (nativeObject, rect.X, rect.Y, rect.Width, rect.Height, out isVisible);
1860 GDIPlus.CheckStatus (status);
1865 public bool IsVisible (float x, float y)
1867 return IsVisible (new PointF (x, y));
1870 public bool IsVisible (int x, int y)
1872 return IsVisible (new Point (x, y));
1875 public bool IsVisible (float x, float y, float width, float height)
1877 return IsVisible (new RectangleF (x, y, width, height));
1881 public bool IsVisible (int x, int y, int width, int height)
1883 return IsVisible (new Rectangle (x, y, width, height));
1887 public Region[] MeasureCharacterRanges (string text, Font font, RectangleF layoutRect, StringFormat stringFormat)
1889 if ((text == null) || (text.Length == 0))
1890 return new Region [0];
1893 throw new ArgumentNullException ("font");
1895 if (stringFormat == null)
1896 throw new ArgumentException ("stringFormat");
1898 int regcount = stringFormat.GetMeasurableCharacterRangeCount ();
1900 return new Region[0];
1902 IntPtr[] native_regions = new IntPtr [regcount];
1903 Region[] regions = new Region [regcount];
1905 for (int i = 0; i < regcount; i++) {
1906 regions[i] = new Region ();
1907 native_regions[i] = regions[i].NativeObject;
1910 Status status = GDIPlus.GdipMeasureCharacterRanges (nativeObject, text, text.Length,
1911 font.NativeObject, ref layoutRect, stringFormat.NativeObject, regcount, out native_regions[0]);
1912 GDIPlus.CheckStatus (status);
1917 private unsafe SizeF GdipMeasureString (IntPtr graphics, string text, Font font, ref RectangleF layoutRect,
1918 IntPtr stringFormat)
1920 if ((text == null) || (text.Length == 0))
1924 throw new ArgumentNullException ("font");
1926 RectangleF boundingBox = new RectangleF ();
1928 Status status = GDIPlus.GdipMeasureString (nativeObject, text, text.Length, font.NativeObject,
1929 ref layoutRect, stringFormat, out boundingBox, null, null);
1930 GDIPlus.CheckStatus (status);
1932 return new SizeF (boundingBox.Width, boundingBox.Height);
1935 public SizeF MeasureString (string text, Font font)
1937 return MeasureString (text, font, SizeF.Empty);
1940 public SizeF MeasureString (string text, Font font, SizeF layoutArea)
1942 RectangleF rect = new RectangleF (0, 0, layoutArea.Width, layoutArea.Height);
1943 return GdipMeasureString (nativeObject, text, font, ref rect, IntPtr.Zero);
1946 public SizeF MeasureString (string text, Font font, int width)
1948 RectangleF rect = new RectangleF (0, 0, width, Int32.MaxValue);
1949 return GdipMeasureString (nativeObject, text, font, ref rect, IntPtr.Zero);
1952 public SizeF MeasureString (string text, Font font, SizeF layoutArea, StringFormat stringFormat)
1954 RectangleF rect = new RectangleF (0, 0, layoutArea.Width, layoutArea.Height);
1955 IntPtr format = (stringFormat == null) ? IntPtr.Zero : stringFormat.NativeObject;
1956 return GdipMeasureString (nativeObject, text, font, ref rect, format);
1959 public SizeF MeasureString (string text, Font font, int width, StringFormat format)
1961 RectangleF rect = new RectangleF (0, 0, width, Int32.MaxValue);
1962 IntPtr stringFormat = (format == null) ? IntPtr.Zero : format.NativeObject;
1963 return GdipMeasureString (nativeObject, text, font, ref rect, stringFormat);
1966 public SizeF MeasureString (string text, Font font, PointF origin, StringFormat stringFormat)
1968 RectangleF rect = new RectangleF (origin.X, origin.Y, 0, 0);
1969 IntPtr format = (stringFormat == null) ? IntPtr.Zero : stringFormat.NativeObject;
1970 return GdipMeasureString (nativeObject, text, font, ref rect, format);
1973 public SizeF MeasureString (string text, Font font, SizeF layoutArea, StringFormat stringFormat,
1974 out int charactersFitted, out int linesFilled)
1976 charactersFitted = 0;
1979 if ((text == null) || (text.Length == 0))
1983 throw new ArgumentNullException ("font");
1985 RectangleF boundingBox = new RectangleF ();
1986 RectangleF rect = new RectangleF (0, 0, layoutArea.Width, layoutArea.Height);
1988 IntPtr format = (stringFormat == null) ? IntPtr.Zero : stringFormat.NativeObject;
1991 fixed (int* pc = &charactersFitted, pl = &linesFilled) {
1992 Status status = GDIPlus.GdipMeasureString (nativeObject, text, text.Length,
1993 font.NativeObject, ref rect, format, out boundingBox, pc, pl);
1994 GDIPlus.CheckStatus (status);
1997 return new SizeF (boundingBox.Width, boundingBox.Height);
2000 public void MultiplyTransform (Matrix matrix)
2002 MultiplyTransform (matrix, MatrixOrder.Prepend);
2005 public void MultiplyTransform (Matrix matrix, MatrixOrder order)
2008 throw new ArgumentNullException ("matrix");
2010 Status status = GDIPlus.GdipMultiplyWorldTransform (nativeObject, matrix.nativeMatrix, order);
2011 GDIPlus.CheckStatus (status);
2014 [EditorBrowsable (EditorBrowsableState.Advanced)]
2015 [SecurityPermission (SecurityAction.Demand, UnmanagedCode = true)]
2016 public void ReleaseHdc (IntPtr hdc)
2018 ReleaseHdcInternal (hdc);
2022 [SecurityPermission (SecurityAction.LinkDemand, UnmanagedCode = true)]
2023 public void ReleaseHdc ()
2025 ReleaseHdcInternal (deviceContextHdc);
2029 [MonoLimitation ("Can only be used when hdc was provided by Graphics.GetHdc() method")]
2031 [EditorBrowsable (EditorBrowsableState.Never)]
2033 [EditorBrowsable (EditorBrowsableState.Advanced)]
2035 [SecurityPermission (SecurityAction.LinkDemand, UnmanagedCode = true)]
2036 public void ReleaseHdcInternal (IntPtr hdc)
2038 Status status = Status.InvalidParameter;
2039 if (hdc == deviceContextHdc) {
2040 status = GDIPlus.GdipReleaseDC (nativeObject, deviceContextHdc);
2041 deviceContextHdc = IntPtr.Zero;
2043 GDIPlus.CheckStatus (status);
2046 public void ResetClip ()
2048 Status status = GDIPlus.GdipResetClip (nativeObject);
2049 GDIPlus.CheckStatus (status);
2052 public void ResetTransform ()
2054 Status status = GDIPlus.GdipResetWorldTransform (nativeObject);
2055 GDIPlus.CheckStatus (status);
2058 public void Restore (GraphicsState gstate)
2060 // the possible NRE thrown by gstate.nativeState match MS behaviour
2061 Status status = GDIPlus.GdipRestoreGraphics (nativeObject, gstate.nativeState);
2062 GDIPlus.CheckStatus (status);
2065 public void RotateTransform (float angle)
2067 RotateTransform (angle, MatrixOrder.Prepend);
2070 public void RotateTransform (float angle, MatrixOrder order)
2072 Status status = GDIPlus.GdipRotateWorldTransform (nativeObject, angle, order);
2073 GDIPlus.CheckStatus (status);
2076 public GraphicsState Save ()
2079 Status status = GDIPlus.GdipSaveGraphics (nativeObject, out saveState);
2080 GDIPlus.CheckStatus (status);
2082 GraphicsState state = new GraphicsState ();
2083 state.nativeState = saveState;
2087 public void ScaleTransform (float sx, float sy)
2089 ScaleTransform (sx, sy, MatrixOrder.Prepend);
2092 public void ScaleTransform (float sx, float sy, MatrixOrder order)
2094 Status status = GDIPlus.GdipScaleWorldTransform (nativeObject, sx, sy, order);
2095 GDIPlus.CheckStatus (status);
2099 public void SetClip (RectangleF rect)
2101 SetClip (rect, CombineMode.Replace);
2105 public void SetClip (GraphicsPath path)
2107 SetClip (path, CombineMode.Replace);
2111 public void SetClip (Rectangle rect)
2113 SetClip (rect, CombineMode.Replace);
2117 public void SetClip (Graphics g)
2119 SetClip (g, CombineMode.Replace);
2123 public void SetClip (Graphics g, CombineMode combineMode)
2126 throw new ArgumentNullException ("g");
2128 Status status = GDIPlus.GdipSetClipGraphics (nativeObject, g.NativeObject, combineMode);
2129 GDIPlus.CheckStatus (status);
2133 public void SetClip (Rectangle rect, CombineMode combineMode)
2135 Status status = GDIPlus.GdipSetClipRectI (nativeObject, rect.X, rect.Y, rect.Width, rect.Height, combineMode);
2136 GDIPlus.CheckStatus (status);
2140 public void SetClip (RectangleF rect, CombineMode combineMode)
2142 Status status = GDIPlus.GdipSetClipRect (nativeObject, rect.X, rect.Y, rect.Width, rect.Height, combineMode);
2143 GDIPlus.CheckStatus (status);
2147 public void SetClip (Region region, CombineMode combineMode)
2150 throw new ArgumentNullException ("region");
2151 Status status = GDIPlus.GdipSetClipRegion(nativeObject, region.NativeObject, combineMode);
2152 GDIPlus.CheckStatus (status);
2156 public void SetClip (GraphicsPath path, CombineMode combineMode)
2159 throw new ArgumentNullException ("path");
2160 Status status = GDIPlus.GdipSetClipPath (nativeObject, path.NativeObject, combineMode);
2161 GDIPlus.CheckStatus (status);
2165 public void TransformPoints (CoordinateSpace destSpace, CoordinateSpace srcSpace, PointF [] pts)
2168 throw new ArgumentNullException ("pts");
2170 IntPtr ptrPt = GDIPlus.FromPointToUnManagedMemory (pts);
2172 Status status = GDIPlus.GdipTransformPoints (nativeObject, destSpace, srcSpace, ptrPt, pts.Length);
2173 GDIPlus.CheckStatus (status);
2175 GDIPlus.FromUnManagedMemoryToPoint (ptrPt, pts);
2179 public void TransformPoints (CoordinateSpace destSpace, CoordinateSpace srcSpace, Point [] pts)
2182 throw new ArgumentNullException ("pts");
2183 IntPtr ptrPt = GDIPlus.FromPointToUnManagedMemoryI (pts);
2185 Status status = GDIPlus.GdipTransformPointsI (nativeObject, destSpace, srcSpace, ptrPt, pts.Length);
2186 GDIPlus.CheckStatus (status);
2188 GDIPlus.FromUnManagedMemoryToPointI (ptrPt, pts);
2192 public void TranslateClip (int dx, int dy)
2194 Status status = GDIPlus.GdipTranslateClipI (nativeObject, dx, dy);
2195 GDIPlus.CheckStatus (status);
2199 public void TranslateClip (float dx, float dy)
2201 Status status = GDIPlus.GdipTranslateClip (nativeObject, dx, dy);
2202 GDIPlus.CheckStatus (status);
2205 public void TranslateTransform (float dx, float dy)
2207 TranslateTransform (dx, dy, MatrixOrder.Prepend);
2211 public void TranslateTransform (float dx, float dy, MatrixOrder order)
2213 Status status = GDIPlus.GdipTranslateWorldTransform (nativeObject, dx, dy, order);
2214 GDIPlus.CheckStatus (status);
2217 public Region Clip {
2219 Region reg = new Region();
2220 Status status = GDIPlus.GdipGetClip (nativeObject, reg.NativeObject);
2221 GDIPlus.CheckStatus (status);
2225 SetClip (value, CombineMode.Replace);
2229 public RectangleF ClipBounds {
2231 RectangleF rect = new RectangleF ();
2232 Status status = GDIPlus.GdipGetClipBounds (nativeObject, out rect);
2233 GDIPlus.CheckStatus (status);
2238 public CompositingMode CompositingMode {
2240 CompositingMode mode;
2241 Status status = GDIPlus.GdipGetCompositingMode (nativeObject, out mode);
2242 GDIPlus.CheckStatus (status);
2247 Status status = GDIPlus.GdipSetCompositingMode (nativeObject, value);
2248 GDIPlus.CheckStatus (status);
2253 public CompositingQuality CompositingQuality {
2255 CompositingQuality quality;
2257 Status status = GDIPlus.GdipGetCompositingQuality (nativeObject, out quality);
2258 GDIPlus.CheckStatus (status);
2262 Status status = GDIPlus.GdipSetCompositingQuality (nativeObject, value);
2263 GDIPlus.CheckStatus (status);
2271 Status status = GDIPlus.GdipGetDpiX (nativeObject, out x);
2272 GDIPlus.CheckStatus (status);
2281 Status status = GDIPlus.GdipGetDpiY (nativeObject, out y);
2282 GDIPlus.CheckStatus (status);
2287 public InterpolationMode InterpolationMode {
2289 InterpolationMode imode = InterpolationMode.Invalid;
2290 Status status = GDIPlus.GdipGetInterpolationMode (nativeObject, out imode);
2291 GDIPlus.CheckStatus (status);
2295 Status status = GDIPlus.GdipSetInterpolationMode (nativeObject, value);
2296 GDIPlus.CheckStatus (status);
2300 public bool IsClipEmpty {
2302 bool isEmpty = false;
2304 Status status = GDIPlus.GdipIsClipEmpty (nativeObject, out isEmpty);
2305 GDIPlus.CheckStatus (status);
2310 public bool IsVisibleClipEmpty {
2312 bool isEmpty = false;
2314 Status status = GDIPlus.GdipIsVisibleClipEmpty (nativeObject, out isEmpty);
2315 GDIPlus.CheckStatus (status);
2320 public float PageScale {
2324 Status status = GDIPlus.GdipGetPageScale (nativeObject, out scale);
2325 GDIPlus.CheckStatus (status);
2329 Status status = GDIPlus.GdipSetPageScale (nativeObject, value);
2330 GDIPlus.CheckStatus (status);
2334 public GraphicsUnit PageUnit {
2338 Status status = GDIPlus.GdipGetPageUnit (nativeObject, out unit);
2339 GDIPlus.CheckStatus (status);
2343 Status status = GDIPlus.GdipSetPageUnit (nativeObject, value);
2344 GDIPlus.CheckStatus (status);
2348 [MonoTODO ("This property does not do anything when used with libgdiplus.")]
2349 public PixelOffsetMode PixelOffsetMode {
2351 PixelOffsetMode pixelOffset = PixelOffsetMode.Invalid;
2353 Status status = GDIPlus.GdipGetPixelOffsetMode (nativeObject, out pixelOffset);
2354 GDIPlus.CheckStatus (status);
2358 Status status = GDIPlus.GdipSetPixelOffsetMode (nativeObject, value);
2359 GDIPlus.CheckStatus (status);
2363 public Point RenderingOrigin {
2366 Status status = GDIPlus.GdipGetRenderingOrigin (nativeObject, out x, out y);
2367 GDIPlus.CheckStatus (status);
2368 return new Point (x, y);
2372 Status status = GDIPlus.GdipSetRenderingOrigin (nativeObject, value.X, value.Y);
2373 GDIPlus.CheckStatus (status);
2377 public SmoothingMode SmoothingMode {
2379 SmoothingMode mode = SmoothingMode.Invalid;
2381 Status status = GDIPlus.GdipGetSmoothingMode (nativeObject, out mode);
2382 GDIPlus.CheckStatus (status);
2387 Status status = GDIPlus.GdipSetSmoothingMode (nativeObject, value);
2388 GDIPlus.CheckStatus (status);
2392 [MonoTODO ("This property does not do anything when used with libgdiplus.")]
2393 public int TextContrast {
2397 Status status = GDIPlus.GdipGetTextContrast (nativeObject, out contrast);
2398 GDIPlus.CheckStatus (status);
2403 Status status = GDIPlus.GdipSetTextContrast (nativeObject, value);
2404 GDIPlus.CheckStatus (status);
2408 public TextRenderingHint TextRenderingHint {
2410 TextRenderingHint hint;
2412 Status status = GDIPlus.GdipGetTextRenderingHint (nativeObject, out hint);
2413 GDIPlus.CheckStatus (status);
2418 Status status = GDIPlus.GdipSetTextRenderingHint (nativeObject, value);
2419 GDIPlus.CheckStatus (status);
2423 public Matrix Transform {
2425 Matrix matrix = new Matrix ();
2426 Status status = GDIPlus.GdipGetWorldTransform (nativeObject, matrix.nativeMatrix);
2427 GDIPlus.CheckStatus (status);
2432 throw new ArgumentNullException ("value");
2434 Status status = GDIPlus.GdipSetWorldTransform (nativeObject, value.nativeMatrix);
2435 GDIPlus.CheckStatus (status);
2439 public RectangleF VisibleClipBounds {
2443 Status status = GDIPlus.GdipGetVisibleClipBounds (nativeObject, out rect);
2444 GDIPlus.CheckStatus (status);
2451 [EditorBrowsable (EditorBrowsableState.Never)]
2452 public object GetContextInfo ()
2454 // only known source of information @ http://blogs.wdevs.com/jdunlap/Default.aspx
2455 throw new NotImplementedException ();