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 private bool disposed = false;
53 private static float defDpiX = 0;
54 private static float defDpiY = 0;
56 private IntPtr deviceContextHdc;
62 public delegate bool EnumerateMetafileProc (EmfPlusRecordType recordType,
66 PlayRecordCallback callbackData);
71 public delegate bool DrawImageAbort (IntPtr callbackData);
73 internal Graphics (IntPtr nativeGraphics)
75 nativeObject = nativeGraphics;
83 static internal float systemDpiX {
86 Bitmap bmp = new Bitmap (1, 1);
87 Graphics g = Graphics.FromImage (bmp);
95 static internal float systemDpiY {
98 Bitmap bmp = new Bitmap (1, 1);
99 Graphics g = Graphics.FromImage (bmp);
107 internal IntPtr NativeObject {
113 nativeObject = value;
117 [MonoTODO ("Metafiles, both WMF and EMF formats, aren't supported.")]
118 public void AddMetafileComment (byte [] data)
120 throw new NotImplementedException ();
123 public GraphicsContainer BeginContainer ()
127 status = GDIPlus.GdipBeginContainer2 (nativeObject, out state);
128 GDIPlus.CheckStatus (status);
130 return new GraphicsContainer(state);
133 [MonoTODO ("The rectangles and unit parameters aren't supported in libgdiplus")]
134 public GraphicsContainer BeginContainer (Rectangle dstrect, Rectangle srcrect, GraphicsUnit unit)
138 status = GDIPlus.GdipBeginContainerI (nativeObject, ref dstrect, ref srcrect, unit, out state);
139 GDIPlus.CheckStatus (status);
141 return new GraphicsContainer (state);
144 [MonoTODO ("The rectangles and unit parameters aren't supported in libgdiplus")]
145 public GraphicsContainer BeginContainer (RectangleF dstrect, RectangleF srcrect, GraphicsUnit unit)
149 status = GDIPlus.GdipBeginContainer (nativeObject, ref dstrect, ref srcrect, unit, out state);
150 GDIPlus.CheckStatus (status);
152 return new GraphicsContainer (state);
156 public void Clear (Color color)
159 status = GDIPlus.GdipGraphicsClear (nativeObject, color.ToArgb ());
160 GDIPlus.CheckStatus (status);
163 [MonoLimitation ("Works on Win32 and on X11 (but not on Cocoa and Quartz)")]
164 public void CopyFromScreen (Point upperLeftSource, Point upperLeftDestination, Size blockRegionSize)
166 CopyFromScreen (upperLeftSource.X, upperLeftSource.Y, upperLeftDestination.X, upperLeftDestination.Y,
167 blockRegionSize, CopyPixelOperation.SourceCopy);
170 [MonoLimitation ("Works on Win32 and (for CopyPixelOperation.SourceCopy only) on X11 but not on Cocoa and Quartz")]
171 public void CopyFromScreen (Point upperLeftSource, Point upperLeftDestination, Size blockRegionSize, CopyPixelOperation copyPixelOperation)
173 CopyFromScreen (upperLeftSource.X, upperLeftSource.Y, upperLeftDestination.X, upperLeftDestination.Y,
174 blockRegionSize, copyPixelOperation);
177 [MonoLimitation ("Works on Win32 and on X11 (but not on Cocoa and Quartz)")]
178 public void CopyFromScreen (int sourceX, int sourceY, int destinationX, int destinationY, Size blockRegionSize)
180 CopyFromScreen (sourceX, sourceY, destinationX, destinationY, blockRegionSize,
181 CopyPixelOperation.SourceCopy);
184 [MonoLimitation ("Works on Win32 and (for CopyPixelOperation.SourceCopy only) on X11 but not on Cocoa and Quartz")]
185 public void CopyFromScreen (int sourceX, int sourceY, int destinationX, int destinationY, Size blockRegionSize, CopyPixelOperation copyPixelOperation)
187 if (!Enum.IsDefined (typeof (CopyPixelOperation), copyPixelOperation))
188 throw new InvalidEnumArgumentException (Locale.GetText ("Enum argument value '{0}' is not valid for CopyPixelOperation", copyPixelOperation));
190 if (GDIPlus.UseX11Drawable) {
191 CopyFromScreenX11 (sourceX, sourceY, destinationX, destinationY, blockRegionSize, copyPixelOperation);
192 } else if (GDIPlus.UseCocoaDrawable || GDIPlus.UseQuartzDrawable) {
193 CopyFromScreenMac (sourceX, sourceY, destinationX, destinationY, blockRegionSize, copyPixelOperation);
195 CopyFromScreenWin32 (sourceX, sourceY, destinationX, destinationY, blockRegionSize, copyPixelOperation);
199 private void CopyFromScreenWin32 (int sourceX, int sourceY, int destinationX, int destinationY, Size blockRegionSize, CopyPixelOperation copyPixelOperation)
201 IntPtr window = GDIPlus.GetDesktopWindow ();
202 IntPtr srcDC = GDIPlus.GetDC (window);
203 IntPtr dstDC = GetHdc ();
204 GDIPlus.BitBlt (dstDC, destinationX, destinationY, blockRegionSize.Width,
205 blockRegionSize.Height, srcDC, sourceX, sourceY, (int) copyPixelOperation);
207 GDIPlus.ReleaseDC (IntPtr.Zero, srcDC);
211 private void CopyFromScreenMac (int sourceX, int sourceY, int destinationX, int destinationY, Size blockRegionSize, CopyPixelOperation copyPixelOperation)
213 throw new NotImplementedException ();
216 private void CopyFromScreenX11 (int sourceX, int sourceY, int destinationX, int destinationY, Size blockRegionSize, CopyPixelOperation copyPixelOperation)
218 IntPtr window, image, defvisual, vPtr;
219 int AllPlanes = ~0, nitems = 0, pixel;
221 if (copyPixelOperation != CopyPixelOperation.SourceCopy)
222 throw new NotImplementedException ("Operation not implemented under X11");
224 if (GDIPlus.Display == IntPtr.Zero) {
225 GDIPlus.Display = GDIPlus.XOpenDisplay (IntPtr.Zero);
228 window = GDIPlus.XRootWindow (GDIPlus.Display, 0);
229 defvisual = GDIPlus.XDefaultVisual (GDIPlus.Display, 0);
230 XVisualInfo visual = new XVisualInfo ();
232 /* Get XVisualInfo for this visual */
233 visual.visualid = GDIPlus.XVisualIDFromVisual(defvisual);
234 vPtr = GDIPlus.XGetVisualInfo (GDIPlus.Display, 0x1 /* VisualIDMask */, ref visual, ref nitems);
235 visual = (XVisualInfo) Marshal.PtrToStructure(vPtr, typeof (XVisualInfo));
237 /* Sorry I do not have access to a computer with > deepth. Fell free to add more pixel formats */
238 image = GDIPlus.XGetImage (GDIPlus.Display, window, sourceX, sourceY, blockRegionSize.Width,
239 blockRegionSize.Height, AllPlanes, 2 /* ZPixmap*/);
241 Bitmap bmp = new Bitmap (blockRegionSize.Width, blockRegionSize.Height);
242 int red, blue, green;
243 for (int y = sourceY; y < sourceY + blockRegionSize.Height; y++) {
244 for (int x = sourceX; x < sourceX + blockRegionSize.Width; x++) {
245 pixel = GDIPlus.XGetPixel (image, x, y);
247 switch (visual.depth) {
248 case 16: /* 16bbp pixel transformation */
249 red = (int) ((pixel & visual.red_mask ) >> 8) & 0xff;
250 green = (int) (((pixel & visual.green_mask ) >> 3 )) & 0xff;
251 blue = (int) ((pixel & visual.blue_mask ) << 3 ) & 0xff;
255 red = (int) ((pixel & visual.red_mask ) >> 16) & 0xff;
256 green = (int) (((pixel & visual.green_mask ) >> 8 )) & 0xff;
257 blue = (int) ((pixel & visual.blue_mask )) & 0xff;
260 throw new NotImplementedException ("Deepth not supported right now");
263 bmp.SetPixel (x, y, Color.FromArgb (255, red, green, blue));
267 DrawImage (bmp, 0, 0);
269 GDIPlus.XDestroyImage (image);
270 GDIPlus.XFree (vPtr);
274 public void Dispose ()
278 status = GDIPlus.GdipDeleteGraphics (nativeObject);
279 nativeObject = IntPtr.Zero;
280 GDIPlus.CheckStatus (status);
283 GC.SuppressFinalize(this);
287 public void DrawArc (Pen pen, Rectangle rect, float startAngle, float sweepAngle)
289 DrawArc (pen, rect.X, rect.Y, rect.Width, rect.Height, startAngle, sweepAngle);
293 public void DrawArc (Pen pen, RectangleF rect, float startAngle, float sweepAngle)
295 DrawArc (pen, rect.X, rect.Y, rect.Width, rect.Height, startAngle, sweepAngle);
299 public void DrawArc (Pen pen, float x, float y, float width, float height, float startAngle, float sweepAngle)
303 throw new ArgumentNullException ("pen");
305 status = GDIPlus.GdipDrawArc (nativeObject, pen.nativeObject,
306 x, y, width, height, startAngle, sweepAngle);
307 GDIPlus.CheckStatus (status);
310 // Microsoft documentation states that the signature for this member should be
311 // public void DrawArc( Pen pen, int x, int y, int width, int height, int startAngle,
312 // int sweepAngle. However, GdipDrawArcI uses also float for the startAngle and sweepAngle params
313 public void DrawArc (Pen pen, int x, int y, int width, int height, int startAngle, int sweepAngle)
317 throw new ArgumentNullException ("pen");
318 status = GDIPlus.GdipDrawArcI (nativeObject, pen.nativeObject,
319 x, y, width, height, startAngle, sweepAngle);
320 GDIPlus.CheckStatus (status);
323 public void DrawBezier (Pen pen, PointF pt1, PointF pt2, PointF pt3, PointF pt4)
327 throw new ArgumentNullException ("pen");
328 status = GDIPlus.GdipDrawBezier (nativeObject, pen.nativeObject,
329 pt1.X, pt1.Y, pt2.X, pt2.Y, pt3.X,
330 pt3.Y, pt4.X, pt4.Y);
331 GDIPlus.CheckStatus (status);
334 public void DrawBezier (Pen pen, Point pt1, Point pt2, Point pt3, Point pt4)
338 throw new ArgumentNullException ("pen");
339 status = GDIPlus.GdipDrawBezierI (nativeObject, pen.nativeObject,
340 pt1.X, pt1.Y, pt2.X, pt2.Y, pt3.X,
341 pt3.Y, pt4.X, pt4.Y);
342 GDIPlus.CheckStatus (status);
345 public void DrawBezier (Pen pen, float x1, float y1, float x2, float y2, float x3, float y3, float x4, float y4)
349 throw new ArgumentNullException ("pen");
350 status = GDIPlus.GdipDrawBezier (nativeObject, pen.nativeObject, x1,
351 y1, x2, y2, x3, y3, x4, y4);
352 GDIPlus.CheckStatus (status);
355 public void DrawBeziers (Pen pen, Point [] points)
358 throw new ArgumentNullException ("pen");
360 throw new ArgumentNullException ("points");
362 int length = points.Length;
368 for (int i = 0; i < length - 1; i += 3) {
369 Point p1 = points [i];
370 Point p2 = points [i + 1];
371 Point p3 = points [i + 2];
372 Point p4 = points [i + 3];
374 status = GDIPlus.GdipDrawBezier (nativeObject,
376 p1.X, p1.Y, p2.X, p2.Y,
377 p3.X, p3.Y, p4.X, p4.Y);
378 GDIPlus.CheckStatus (status);
382 public void DrawBeziers (Pen pen, PointF [] points)
385 throw new ArgumentNullException ("pen");
387 throw new ArgumentNullException ("points");
389 int length = points.Length;
395 for (int i = 0; i < length - 1; i += 3) {
396 PointF p1 = points [i];
397 PointF p2 = points [i + 1];
398 PointF p3 = points [i + 2];
399 PointF p4 = points [i + 3];
401 status = GDIPlus.GdipDrawBezier (nativeObject,
403 p1.X, p1.Y, p2.X, p2.Y,
404 p3.X, p3.Y, p4.X, p4.Y);
405 GDIPlus.CheckStatus (status);
410 public void DrawClosedCurve (Pen pen, PointF [] points)
413 throw new ArgumentNullException ("pen");
415 throw new ArgumentNullException ("points");
418 status = GDIPlus.GdipDrawClosedCurve (nativeObject, pen.nativeObject, points, points.Length);
419 GDIPlus.CheckStatus (status);
422 public void DrawClosedCurve (Pen pen, Point [] points)
425 throw new ArgumentNullException ("pen");
427 throw new ArgumentNullException ("points");
430 status = GDIPlus.GdipDrawClosedCurveI (nativeObject, pen.nativeObject, points, points.Length);
431 GDIPlus.CheckStatus (status);
434 public void DrawClosedCurve (Pen pen, Point [] points, float tension, FillMode fillmode)
437 throw new ArgumentNullException ("pen");
439 throw new ArgumentNullException ("points");
442 status = GDIPlus.GdipDrawClosedCurve2I (nativeObject, pen.nativeObject, points, points.Length, tension);
443 GDIPlus.CheckStatus (status);
446 public void DrawClosedCurve (Pen pen, PointF [] points, float tension, FillMode fillmode)
449 throw new ArgumentNullException ("pen");
451 throw new ArgumentNullException ("points");
454 status = GDIPlus.GdipDrawClosedCurve2 (nativeObject, pen.nativeObject, points, points.Length, tension);
455 GDIPlus.CheckStatus (status);
458 public void DrawCurve (Pen pen, Point [] points)
461 throw new ArgumentNullException ("pen");
463 throw new ArgumentNullException ("points");
466 status = GDIPlus.GdipDrawCurveI (nativeObject, pen.nativeObject, points, points.Length);
467 GDIPlus.CheckStatus (status);
470 public void DrawCurve (Pen pen, PointF [] points)
473 throw new ArgumentNullException ("pen");
475 throw new ArgumentNullException ("points");
478 status = GDIPlus.GdipDrawCurve (nativeObject, pen.nativeObject, points, points.Length);
479 GDIPlus.CheckStatus (status);
482 public void DrawCurve (Pen pen, PointF [] points, float tension)
485 throw new ArgumentNullException ("pen");
487 throw new ArgumentNullException ("points");
490 status = GDIPlus.GdipDrawCurve2 (nativeObject, pen.nativeObject, points, points.Length, tension);
491 GDIPlus.CheckStatus (status);
494 public void DrawCurve (Pen pen, Point [] points, float tension)
497 throw new ArgumentNullException ("pen");
499 throw new ArgumentNullException ("points");
502 status = GDIPlus.GdipDrawCurve2I (nativeObject, pen.nativeObject, points, points.Length, tension);
503 GDIPlus.CheckStatus (status);
506 public void DrawCurve (Pen pen, PointF [] points, int offset, int numberOfSegments)
509 throw new ArgumentNullException ("pen");
511 throw new ArgumentNullException ("points");
514 status = GDIPlus.GdipDrawCurve3 (nativeObject, pen.nativeObject,
515 points, points.Length, offset,
516 numberOfSegments, 0.5f);
517 GDIPlus.CheckStatus (status);
520 public void DrawCurve (Pen pen, Point [] points, int offset, int numberOfSegments, float tension)
523 throw new ArgumentNullException ("pen");
525 throw new ArgumentNullException ("points");
528 status = GDIPlus.GdipDrawCurve3I (nativeObject, pen.nativeObject,
529 points, points.Length, offset,
530 numberOfSegments, tension);
531 GDIPlus.CheckStatus (status);
534 public void DrawCurve (Pen pen, PointF [] points, int offset, int numberOfSegments, float tension)
537 throw new ArgumentNullException ("pen");
539 throw new ArgumentNullException ("points");
542 status = GDIPlus.GdipDrawCurve3 (nativeObject, pen.nativeObject,
543 points, points.Length, offset,
544 numberOfSegments, tension);
545 GDIPlus.CheckStatus (status);
548 public void DrawEllipse (Pen pen, Rectangle rect)
551 throw new ArgumentNullException ("pen");
553 DrawEllipse (pen, rect.X, rect.Y, rect.Width, rect.Height);
556 public void DrawEllipse (Pen pen, RectangleF rect)
559 throw new ArgumentNullException ("pen");
560 DrawEllipse (pen, rect.X, rect.Y, rect.Width, rect.Height);
563 public void DrawEllipse (Pen pen, int x, int y, int width, int height)
566 throw new ArgumentNullException ("pen");
568 status = GDIPlus.GdipDrawEllipseI (nativeObject, pen.nativeObject, x, y, width, height);
569 GDIPlus.CheckStatus (status);
572 public void DrawEllipse (Pen pen, float x, float y, float width, float height)
575 throw new ArgumentNullException ("pen");
576 Status status = GDIPlus.GdipDrawEllipse (nativeObject, pen.nativeObject, x, y, width, height);
577 GDIPlus.CheckStatus (status);
580 public void DrawIcon (Icon icon, Rectangle targetRect)
583 throw new ArgumentNullException ("icon");
585 DrawImage (icon.GetInternalBitmap (), targetRect);
588 public void DrawIcon (Icon icon, int x, int y)
591 throw new ArgumentNullException ("icon");
593 DrawImage (icon.GetInternalBitmap (), x, y);
596 public void DrawIconUnstretched (Icon icon, Rectangle targetRect)
599 throw new ArgumentNullException ("icon");
601 DrawImageUnscaled (icon.GetInternalBitmap (), targetRect);
604 public void DrawImage (Image image, RectangleF rect)
607 throw new ArgumentNullException ("image");
609 Status status = GDIPlus.GdipDrawImageRect(nativeObject, image.NativeObject, rect.X, rect.Y, rect.Width, rect.Height);
610 GDIPlus.CheckStatus (status);
614 public void DrawImage (Image image, PointF point)
617 throw new ArgumentNullException ("image");
619 Status status = GDIPlus.GdipDrawImage (nativeObject, image.NativeObject, point.X, point.Y);
620 GDIPlus.CheckStatus (status);
624 public void DrawImage (Image image, Point [] destPoints)
627 throw new ArgumentNullException ("image");
628 if (destPoints == null)
629 throw new ArgumentNullException ("destPoints");
631 Status status = GDIPlus.GdipDrawImagePointsI (nativeObject, image.NativeObject, destPoints, destPoints.Length);
632 GDIPlus.CheckStatus (status);
636 public void DrawImage (Image image, Point point)
639 throw new ArgumentNullException ("image");
640 DrawImage (image, point.X, point.Y);
644 public void DrawImage (Image image, Rectangle rect)
647 throw new ArgumentNullException ("image");
648 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);
663 public void DrawImage (Image image, int x, int y)
666 throw new ArgumentNullException ("image");
667 Status status = GDIPlus.GdipDrawImageI (nativeObject, image.NativeObject, x, y);
668 GDIPlus.CheckStatus (status);
672 public void DrawImage (Image image, float x, float y)
675 throw new ArgumentNullException ("image");
676 Status status = GDIPlus.GdipDrawImage (nativeObject, image.NativeObject, x, y);
677 GDIPlus.CheckStatus (status);
681 public void DrawImage (Image image, Rectangle destRect, Rectangle srcRect, GraphicsUnit srcUnit)
684 throw new ArgumentNullException ("image");
685 Status status = GDIPlus.GdipDrawImageRectRectI (nativeObject, image.NativeObject,
686 destRect.X, destRect.Y, destRect.Width, destRect.Height,
687 srcRect.X, srcRect.Y, srcRect.Width, srcRect.Height,
688 srcUnit, IntPtr.Zero, null, IntPtr.Zero);
689 GDIPlus.CheckStatus (status);
692 public void DrawImage (Image image, RectangleF destRect, RectangleF srcRect, GraphicsUnit srcUnit)
695 throw new ArgumentNullException ("image");
696 Status status = GDIPlus.GdipDrawImageRectRect (nativeObject, image.NativeObject,
697 destRect.X, destRect.Y, destRect.Width, destRect.Height,
698 srcRect.X, srcRect.Y, srcRect.Width, srcRect.Height,
699 srcUnit, IntPtr.Zero, null, IntPtr.Zero);
700 GDIPlus.CheckStatus (status);
704 public void DrawImage (Image image, Point [] destPoints, Rectangle srcRect, GraphicsUnit srcUnit)
707 throw new ArgumentNullException ("image");
708 if (destPoints == null)
709 throw new ArgumentNullException ("destPoints");
711 Status status = GDIPlus.GdipDrawImagePointsRectI (nativeObject, image.NativeObject,
712 destPoints, destPoints.Length , srcRect.X, srcRect.Y,
713 srcRect.Width, srcRect.Height, srcUnit, IntPtr.Zero,
715 GDIPlus.CheckStatus (status);
719 public void DrawImage (Image image, PointF [] destPoints, RectangleF srcRect, GraphicsUnit srcUnit)
722 throw new ArgumentNullException ("image");
723 if (destPoints == null)
724 throw new ArgumentNullException ("destPoints");
726 Status status = GDIPlus.GdipDrawImagePointsRect (nativeObject, image.NativeObject,
727 destPoints, destPoints.Length , srcRect.X, srcRect.Y,
728 srcRect.Width, srcRect.Height, srcUnit, IntPtr.Zero,
730 GDIPlus.CheckStatus (status);
734 public void DrawImage (Image image, Point [] destPoints, Rectangle srcRect, GraphicsUnit srcUnit,
735 ImageAttributes imageAttr)
738 throw new ArgumentNullException ("image");
739 if (destPoints == null)
740 throw new ArgumentNullException ("destPoints");
741 Status status = GDIPlus.GdipDrawImagePointsRectI (nativeObject, image.NativeObject,
742 destPoints, destPoints.Length , srcRect.X, srcRect.Y,
743 srcRect.Width, srcRect.Height, srcUnit,
744 imageAttr != null ? imageAttr.NativeObject : IntPtr.Zero, null, IntPtr.Zero);
745 GDIPlus.CheckStatus (status);
748 public void DrawImage (Image image, float x, float y, float width, float height)
751 throw new ArgumentNullException ("image");
752 Status status = GDIPlus.GdipDrawImageRect(nativeObject, image.NativeObject, x, y,
754 GDIPlus.CheckStatus (status);
758 public void DrawImage (Image image, PointF [] destPoints, RectangleF srcRect, GraphicsUnit srcUnit,
759 ImageAttributes imageAttr)
762 throw new ArgumentNullException ("image");
763 if (destPoints == null)
764 throw new ArgumentNullException ("destPoints");
765 Status status = GDIPlus.GdipDrawImagePointsRect (nativeObject, image.NativeObject,
766 destPoints, destPoints.Length , srcRect.X, srcRect.Y,
767 srcRect.Width, srcRect.Height, srcUnit,
768 imageAttr != null ? imageAttr.NativeObject : IntPtr.Zero, null, IntPtr.Zero);
769 GDIPlus.CheckStatus (status);
773 public void DrawImage (Image image, int x, int y, Rectangle srcRect, GraphicsUnit srcUnit)
776 throw new ArgumentNullException ("image");
777 Status status = GDIPlus.GdipDrawImagePointRectI(nativeObject, image.NativeObject, x, y, srcRect.X, srcRect.Y, srcRect.Width, srcRect.Height, srcUnit);
778 GDIPlus.CheckStatus (status);
781 public void DrawImage (Image image, int x, int y, int width, int height)
784 throw new ArgumentNullException ("image");
785 Status status = GDIPlus.GdipDrawImageRectI (nativeObject, image.nativeObject, x, y, width, height);
786 GDIPlus.CheckStatus (status);
789 public void DrawImage (Image image, float x, float y, RectangleF srcRect, GraphicsUnit srcUnit)
792 throw new ArgumentNullException ("image");
793 Status status = GDIPlus.GdipDrawImagePointRect (nativeObject, image.nativeObject, x, y, srcRect.X, srcRect.Y, srcRect.Width, srcRect.Height, srcUnit);
794 GDIPlus.CheckStatus (status);
798 public void DrawImage (Image image, PointF [] destPoints, RectangleF srcRect, GraphicsUnit srcUnit, ImageAttributes imageAttr, DrawImageAbort callback)
801 throw new ArgumentNullException ("image");
802 if (destPoints == null)
803 throw new ArgumentNullException ("destPoints");
804 Status status = GDIPlus.GdipDrawImagePointsRect (nativeObject, image.NativeObject,
805 destPoints, destPoints.Length , srcRect.X, srcRect.Y,
806 srcRect.Width, srcRect.Height, srcUnit,
807 imageAttr != null ? imageAttr.NativeObject : IntPtr.Zero, callback, IntPtr.Zero);
808 GDIPlus.CheckStatus (status);
812 public void DrawImage (Image image, Point [] destPoints, Rectangle srcRect, GraphicsUnit srcUnit, ImageAttributes imageAttr, DrawImageAbort callback)
815 throw new ArgumentNullException ("image");
816 if (destPoints == null)
817 throw new ArgumentNullException ("destPoints");
819 Status status = GDIPlus.GdipDrawImagePointsRectI (nativeObject, image.NativeObject,
820 destPoints, destPoints.Length , srcRect.X, srcRect.Y,
821 srcRect.Width, srcRect.Height, srcUnit,
822 imageAttr != null ? imageAttr.NativeObject : IntPtr.Zero, callback, IntPtr.Zero);
823 GDIPlus.CheckStatus (status);
827 public void DrawImage (Image image, Point [] destPoints, Rectangle srcRect, GraphicsUnit srcUnit, ImageAttributes imageAttr, DrawImageAbort callback, int callbackData)
830 throw new ArgumentNullException ("image");
831 if (destPoints == null)
832 throw new ArgumentNullException ("destPoints");
834 Status status = GDIPlus.GdipDrawImagePointsRectI (nativeObject, image.NativeObject,
835 destPoints, destPoints.Length , srcRect.X, srcRect.Y,
836 srcRect.Width, srcRect.Height, srcUnit,
837 imageAttr != null ? imageAttr.NativeObject : IntPtr.Zero, callback, (IntPtr) callbackData);
838 GDIPlus.CheckStatus (status);
842 public void DrawImage (Image image, Rectangle destRect, float srcX, float srcY, float srcWidth, float srcHeight, GraphicsUnit srcUnit)
845 throw new ArgumentNullException ("image");
846 Status status = GDIPlus.GdipDrawImageRectRect (nativeObject, image.NativeObject,
847 destRect.X, destRect.Y, destRect.Width, destRect.Height,
848 srcX, srcY, srcWidth, srcHeight, srcUnit, IntPtr.Zero,
850 GDIPlus.CheckStatus (status);
853 public void DrawImage (Image image, PointF [] destPoints, RectangleF srcRect, GraphicsUnit srcUnit, ImageAttributes imageAttr, DrawImageAbort callback, int callbackData)
855 Status status = GDIPlus.GdipDrawImagePointsRect (nativeObject, image.NativeObject,
856 destPoints, destPoints.Length , srcRect.X, srcRect.Y,
857 srcRect.Width, srcRect.Height, srcUnit,
858 imageAttr != null ? imageAttr.NativeObject : IntPtr.Zero, callback, (IntPtr) callbackData);
859 GDIPlus.CheckStatus (status);
863 public void DrawImage (Image image, Rectangle destRect, int srcX, int srcY, int srcWidth, int srcHeight, GraphicsUnit srcUnit)
866 throw new ArgumentNullException ("image");
867 Status status = GDIPlus.GdipDrawImageRectRectI (nativeObject, image.NativeObject,
868 destRect.X, destRect.Y, destRect.Width, destRect.Height,
869 srcX, srcY, srcWidth, srcHeight, srcUnit, IntPtr.Zero,
871 GDIPlus.CheckStatus (status);
875 public void DrawImage (Image image, Rectangle destRect, float srcX, float srcY, float srcWidth, float srcHeight, GraphicsUnit srcUnit, ImageAttributes imageAttrs)
878 throw new ArgumentNullException ("image");
879 Status status = GDIPlus.GdipDrawImageRectRect (nativeObject, image.NativeObject,
880 destRect.X, destRect.Y, destRect.Width, destRect.Height,
881 srcX, srcY, srcWidth, srcHeight, srcUnit,
882 imageAttrs != null ? imageAttrs.NativeObject : IntPtr.Zero, null, IntPtr.Zero);
883 GDIPlus.CheckStatus (status);
886 public void DrawImage (Image image, Rectangle destRect, int srcX, int srcY, int srcWidth, int srcHeight, GraphicsUnit srcUnit, ImageAttributes imageAttr)
889 throw new ArgumentNullException ("image");
890 Status status = GDIPlus.GdipDrawImageRectRectI (nativeObject, image.NativeObject,
891 destRect.X, destRect.Y, destRect.Width,
892 destRect.Height, srcX, srcY, srcWidth, srcHeight,
893 srcUnit, imageAttr != null ? imageAttr.NativeObject : IntPtr.Zero, null, IntPtr.Zero);
894 GDIPlus.CheckStatus (status);
897 public void DrawImage (Image image, Rectangle destRect, int srcX, int srcY, int srcWidth, int srcHeight, GraphicsUnit srcUnit, ImageAttributes imageAttr, DrawImageAbort callback)
900 throw new ArgumentNullException ("image");
901 Status status = GDIPlus.GdipDrawImageRectRectI (nativeObject, image.NativeObject,
902 destRect.X, destRect.Y, destRect.Width,
903 destRect.Height, srcX, srcY, srcWidth, srcHeight,
904 srcUnit, imageAttr != null ? imageAttr.NativeObject : IntPtr.Zero, callback,
906 GDIPlus.CheckStatus (status);
909 public void DrawImage (Image image, Rectangle destRect, float srcX, float srcY, float srcWidth, float srcHeight, GraphicsUnit srcUnit, ImageAttributes imageAttr, DrawImageAbort callback)
912 throw new ArgumentNullException ("image");
913 Status status = GDIPlus.GdipDrawImageRectRect (nativeObject, image.NativeObject,
914 destRect.X, destRect.Y, destRect.Width,
915 destRect.Height, srcX, srcY, srcWidth, srcHeight,
916 srcUnit, imageAttr != null ? imageAttr.NativeObject : IntPtr.Zero,
917 callback, IntPtr.Zero);
918 GDIPlus.CheckStatus (status);
922 public void DrawImage (Image image, Rectangle destRect, float srcX, float srcY, float srcWidth, float srcHeight, GraphicsUnit srcUnit, ImageAttributes imageAttr, DrawImageAbort callback, IntPtr callbackData)
925 throw new ArgumentNullException ("image");
926 Status status = GDIPlus.GdipDrawImageRectRect (nativeObject, image.NativeObject,
927 destRect.X, destRect.Y, destRect.Width, destRect.Height,
928 srcX, srcY, srcWidth, srcHeight, srcUnit,
929 imageAttr != null ? imageAttr.NativeObject : IntPtr.Zero, callback, callbackData);
930 GDIPlus.CheckStatus (status);
934 public void DrawImage (Image image, Rectangle destRect, int srcX, int srcY, int srcWidth, int srcHeight, GraphicsUnit srcUnit, ImageAttributes imageAttr, DrawImageAbort callback, IntPtr callbackData)
937 throw new ArgumentNullException ("image");
938 Status status = GDIPlus.GdipDrawImageRectRect (nativeObject, image.NativeObject,
939 destRect.X, destRect.Y, destRect.Width, destRect.Height,
940 srcX, srcY, srcWidth, srcHeight, srcUnit,
941 imageAttr != null ? imageAttr.NativeObject : IntPtr.Zero, callback, callbackData);
942 GDIPlus.CheckStatus (status);
945 public void DrawImageUnscaled (Image image, Point point)
948 throw new ArgumentNullException ("image");
949 DrawImageUnscaled (image, point.X, point.Y);
952 public void DrawImageUnscaled (Image image, Rectangle rect)
955 throw new ArgumentNullException ("image");
956 DrawImageUnscaled (image, rect.X, rect.Y, rect.Width, rect.Height);
959 public void DrawImageUnscaled (Image image, int x, int y)
962 throw new ArgumentNullException ("image");
963 DrawImage (image, x, y, image.Width, image.Height);
966 public void DrawImageUnscaled (Image image, int x, int y, int width, int height)
969 throw new ArgumentNullException ("image");
970 Image tmpImg = new Bitmap (width, height);
971 Graphics g = FromImage (tmpImg);
972 g.DrawImage (image, 0, 0, image.Width, image.Height);
973 this.DrawImage (tmpImg, x, y, width, height);
979 public void DrawImageUnscaledAndClipped (Image image, Rectangle rect)
982 width = (image.Width > rect.Width) ? rect.Width : image.Width;
983 height = (image.Height > rect.Height) ? rect.Height : image.Height;
985 DrawImageUnscaled (image, rect.X, rect.Y, width, height);
989 public void DrawLine (Pen pen, PointF pt1, PointF pt2)
992 throw new ArgumentNullException ("pen");
993 Status status = GDIPlus.GdipDrawLine (nativeObject, pen.nativeObject,
994 pt1.X, pt1.Y, pt2.X, pt2.Y);
995 GDIPlus.CheckStatus (status);
998 public void DrawLine (Pen pen, Point pt1, Point pt2)
1001 throw new ArgumentNullException ("pen");
1002 Status status = GDIPlus.GdipDrawLineI (nativeObject, pen.nativeObject,
1003 pt1.X, pt1.Y, pt2.X, pt2.Y);
1004 GDIPlus.CheckStatus (status);
1007 public void DrawLine (Pen pen, int x1, int y1, int x2, int y2)
1010 throw new ArgumentNullException ("pen");
1011 Status status = GDIPlus.GdipDrawLineI (nativeObject, pen.nativeObject, x1, y1, x2, y2);
1012 GDIPlus.CheckStatus (status);
1015 public void DrawLine (Pen pen, float x1, float y1, float x2, float y2)
1018 throw new ArgumentNullException ("pen");
1019 Status status = GDIPlus.GdipDrawLine (nativeObject, pen.nativeObject, x1, y1, x2, y2);
1020 GDIPlus.CheckStatus (status);
1023 public void DrawLines (Pen pen, PointF [] points)
1026 throw new ArgumentNullException ("pen");
1028 throw new ArgumentNullException ("points");
1029 Status status = GDIPlus.GdipDrawLines (nativeObject, pen.nativeObject, points, points.Length);
1030 GDIPlus.CheckStatus (status);
1033 public void DrawLines (Pen pen, Point [] points)
1036 throw new ArgumentNullException ("pen");
1038 throw new ArgumentNullException ("points");
1039 Status status = GDIPlus.GdipDrawLinesI (nativeObject, pen.nativeObject, points, points.Length);
1040 GDIPlus.CheckStatus (status);
1043 public void DrawPath (Pen pen, GraphicsPath path)
1046 throw new ArgumentNullException ("pen");
1048 throw new ArgumentNullException ("path");
1049 Status status = GDIPlus.GdipDrawPath (nativeObject, pen.nativeObject, path.nativePath);
1050 GDIPlus.CheckStatus (status);
1053 public void DrawPie (Pen pen, Rectangle rect, float startAngle, float sweepAngle)
1056 throw new ArgumentNullException ("pen");
1057 DrawPie (pen, rect.X, rect.Y, rect.Width, rect.Height, startAngle, sweepAngle);
1060 public void DrawPie (Pen pen, RectangleF rect, float startAngle, float sweepAngle)
1063 throw new ArgumentNullException ("pen");
1064 DrawPie (pen, rect.X, rect.Y, rect.Width, rect.Height, startAngle, sweepAngle);
1067 public void DrawPie (Pen pen, float x, float y, float width, float height, float startAngle, float sweepAngle)
1070 throw new ArgumentNullException ("pen");
1071 Status status = GDIPlus.GdipDrawPie (nativeObject, pen.nativeObject, x, y, width, height, startAngle, sweepAngle);
1072 GDIPlus.CheckStatus (status);
1075 // Microsoft documentation states that the signature for this member should be
1076 // public void DrawPie(Pen pen, int x, int y, int width, int height, int startAngle
1077 // int sweepAngle. However, GdipDrawPieI uses also float for the startAngle and sweepAngle params
1078 public void DrawPie (Pen pen, int x, int y, int width, int height, int startAngle, int sweepAngle)
1081 throw new ArgumentNullException ("pen");
1082 Status status = GDIPlus.GdipDrawPieI (nativeObject, pen.nativeObject, x, y, width, height, startAngle, sweepAngle);
1083 GDIPlus.CheckStatus (status);
1086 public void DrawPolygon (Pen pen, Point [] points)
1089 throw new ArgumentNullException ("pen");
1091 throw new ArgumentNullException ("points");
1092 Status status = GDIPlus.GdipDrawPolygonI (nativeObject, pen.nativeObject, points, points.Length);
1093 GDIPlus.CheckStatus (status);
1096 public void DrawPolygon (Pen pen, PointF [] points)
1099 throw new ArgumentNullException ("pen");
1101 throw new ArgumentNullException ("points");
1102 Status status = GDIPlus.GdipDrawPolygon (nativeObject, pen.nativeObject, points, points.Length);
1103 GDIPlus.CheckStatus (status);
1106 internal void DrawRectangle (Pen pen, RectangleF rect)
1109 throw new ArgumentNullException ("pen");
1110 DrawRectangle (pen, rect.Left, rect.Top, rect.Width, rect.Height);
1113 public void DrawRectangle (Pen pen, Rectangle rect)
1116 throw new ArgumentNullException ("pen");
1117 DrawRectangle (pen, rect.Left, rect.Top, rect.Width, rect.Height);
1120 public void DrawRectangle (Pen pen, float x, float y, float width, float height)
1123 throw new ArgumentNullException ("pen");
1124 Status status = GDIPlus.GdipDrawRectangle (nativeObject, pen.nativeObject, x, y, width, height);
1125 GDIPlus.CheckStatus (status);
1128 public void DrawRectangle (Pen pen, int x, int y, int width, int height)
1131 throw new ArgumentNullException ("pen");
1132 Status status = GDIPlus.GdipDrawRectangleI (nativeObject, pen.nativeObject, x, y, width, height);
1133 GDIPlus.CheckStatus (status);
1136 public void DrawRectangles (Pen pen, RectangleF [] rects)
1139 throw new ArgumentNullException ("image");
1141 throw new ArgumentNullException ("rects");
1142 Status status = GDIPlus.GdipDrawRectangles (nativeObject, pen.nativeObject, rects, rects.Length);
1143 GDIPlus.CheckStatus (status);
1146 public void DrawRectangles (Pen pen, Rectangle [] rects)
1149 throw new ArgumentNullException ("image");
1151 throw new ArgumentNullException ("rects");
1152 Status status = GDIPlus.GdipDrawRectanglesI (nativeObject, pen.nativeObject, rects, rects.Length);
1153 GDIPlus.CheckStatus (status);
1156 public void DrawString (string s, Font font, Brush brush, RectangleF layoutRectangle)
1158 DrawString (s, font, brush, layoutRectangle, null);
1161 public void DrawString (string s, Font font, Brush brush, PointF point)
1163 DrawString (s, font, brush, new RectangleF (point.X, point.Y, 0, 0), null);
1166 public void DrawString (string s, Font font, Brush brush, PointF point, StringFormat format)
1168 DrawString(s, font, brush, new RectangleF(point.X, point.Y, 0, 0), format);
1171 public void DrawString (string s, Font font, Brush brush, float x, float y)
1173 DrawString (s, font, brush, new RectangleF (x, y, 0, 0), null);
1176 public void DrawString (string s, Font font, Brush brush, float x, float y, StringFormat format)
1178 DrawString (s, font, brush, new RectangleF(x, y, 0, 0), format);
1181 public void DrawString (string s, Font font, Brush brush, RectangleF layoutRectangle, StringFormat format)
1184 throw new ArgumentNullException ("font");
1186 throw new ArgumentNullException ("brush");
1187 if (s == null || s.Length == 0)
1190 Status status = GDIPlus.GdipDrawString (nativeObject, s, s.Length, font.NativeObject, ref layoutRectangle, format != null ? format.NativeObject : IntPtr.Zero, brush.nativeObject);
1191 GDIPlus.CheckStatus (status);
1194 public void EndContainer (GraphicsContainer container)
1197 if (container == null)
1198 throw new ArgumentNullException ("container");
1200 Status status = GDIPlus.GdipEndContainer(nativeObject, container.NativeObject);
1201 GDIPlus.CheckStatus (status);
1204 private const string MetafileEnumeration = "Metafiles enumeration, for both WMF and EMF formats, isn't supported.";
1206 [MonoTODO (MetafileEnumeration)]
1207 public void EnumerateMetafile (Metafile metafile, Point [] destPoints, EnumerateMetafileProc callback)
1209 throw new NotImplementedException ();
1212 [MonoTODO (MetafileEnumeration)]
1213 public void EnumerateMetafile (Metafile metafile, RectangleF destRect, EnumerateMetafileProc callback)
1215 throw new NotImplementedException ();
1218 [MonoTODO (MetafileEnumeration)]
1219 public void EnumerateMetafile (Metafile metafile, PointF [] destPoints, EnumerateMetafileProc callback)
1221 throw new NotImplementedException ();
1224 [MonoTODO (MetafileEnumeration)]
1225 public void EnumerateMetafile (Metafile metafile, Rectangle destRect, EnumerateMetafileProc callback)
1227 throw new NotImplementedException ();
1230 [MonoTODO (MetafileEnumeration)]
1231 public void EnumerateMetafile (Metafile metafile, Point destPoint, EnumerateMetafileProc callback)
1233 throw new NotImplementedException ();
1236 [MonoTODO (MetafileEnumeration)]
1237 public void EnumerateMetafile (Metafile metafile, PointF destPoint, EnumerateMetafileProc callback)
1239 throw new NotImplementedException ();
1242 [MonoTODO (MetafileEnumeration)]
1243 public void EnumerateMetafile (Metafile metafile, PointF destPoint, EnumerateMetafileProc callback, IntPtr callbackData)
1245 throw new NotImplementedException ();
1248 [MonoTODO (MetafileEnumeration)]
1249 public void EnumerateMetafile (Metafile metafile, Rectangle destRect, EnumerateMetafileProc callback, IntPtr callbackData)
1251 throw new NotImplementedException ();
1254 [MonoTODO (MetafileEnumeration)]
1255 public void EnumerateMetafile (Metafile metafile, PointF [] destPoints, EnumerateMetafileProc callback, IntPtr callbackData)
1257 throw new NotImplementedException ();
1260 [MonoTODO (MetafileEnumeration)]
1261 public void EnumerateMetafile (Metafile metafile, Point destPoint, EnumerateMetafileProc callback, IntPtr callbackData)
1263 throw new NotImplementedException ();
1266 [MonoTODO (MetafileEnumeration)]
1267 public void EnumerateMetafile (Metafile metafile, Point [] destPoints, EnumerateMetafileProc callback, IntPtr callbackData)
1269 throw new NotImplementedException ();
1272 [MonoTODO (MetafileEnumeration)]
1273 public void EnumerateMetafile (Metafile metafile, RectangleF destRect, EnumerateMetafileProc callback, IntPtr callbackData)
1275 throw new NotImplementedException ();
1278 [MonoTODO (MetafileEnumeration)]
1279 public void EnumerateMetafile (Metafile metafile, PointF destPoint, RectangleF srcRect, GraphicsUnit srcUnit, EnumerateMetafileProc callback)
1281 throw new NotImplementedException ();
1284 [MonoTODO (MetafileEnumeration)]
1285 public void EnumerateMetafile (Metafile metafile, Point destPoint, Rectangle srcRect, GraphicsUnit srcUnit, EnumerateMetafileProc callback)
1287 throw new NotImplementedException ();
1290 [MonoTODO (MetafileEnumeration)]
1291 public void EnumerateMetafile (Metafile metafile, PointF [] destPoints, RectangleF srcRect, GraphicsUnit srcUnit, EnumerateMetafileProc callback)
1293 throw new NotImplementedException ();
1296 [MonoTODO (MetafileEnumeration)]
1297 public void EnumerateMetafile (Metafile metafile, Point [] destPoints, Rectangle srcRect, GraphicsUnit srcUnit, EnumerateMetafileProc callback)
1299 throw new NotImplementedException ();
1302 [MonoTODO (MetafileEnumeration)]
1303 public void EnumerateMetafile (Metafile metafile, RectangleF destRect, RectangleF srcRect, GraphicsUnit srcUnit, EnumerateMetafileProc callback)
1305 throw new NotImplementedException ();
1308 [MonoTODO (MetafileEnumeration)]
1309 public void EnumerateMetafile (Metafile metafile, Rectangle destRect, Rectangle srcRect, GraphicsUnit srcUnit, EnumerateMetafileProc callback)
1311 throw new NotImplementedException ();
1314 [MonoTODO (MetafileEnumeration)]
1315 public void EnumerateMetafile (Metafile metafile, RectangleF destRect, EnumerateMetafileProc callback, IntPtr callbackData, ImageAttributes imageAttr)
1317 throw new NotImplementedException ();
1320 [MonoTODO (MetafileEnumeration)]
1321 public void EnumerateMetafile (Metafile metafile, Point destPoint, EnumerateMetafileProc callback, IntPtr callbackData, ImageAttributes imageAttr)
1323 throw new NotImplementedException ();
1326 [MonoTODO (MetafileEnumeration)]
1327 public void EnumerateMetafile (Metafile metafile, PointF destPoint, EnumerateMetafileProc callback, IntPtr callbackData, ImageAttributes imageAttr)
1329 throw new NotImplementedException ();
1332 [MonoTODO (MetafileEnumeration)]
1333 public void EnumerateMetafile (Metafile metafile, Point [] destPoints, EnumerateMetafileProc callback, IntPtr callbackData, ImageAttributes imageAttr)
1335 throw new NotImplementedException ();
1338 [MonoTODO (MetafileEnumeration)]
1339 public void EnumerateMetafile (Metafile metafile, PointF [] destPoints, EnumerateMetafileProc callback, IntPtr callbackData, ImageAttributes imageAttr)
1341 throw new NotImplementedException ();
1344 [MonoTODO (MetafileEnumeration)]
1345 public void EnumerateMetafile (Metafile metafile, Rectangle destRect, EnumerateMetafileProc callback, IntPtr callbackData, ImageAttributes imageAttr)
1347 throw new NotImplementedException ();
1350 [MonoTODO (MetafileEnumeration)]
1351 public void EnumerateMetafile (Metafile metafile, Rectangle destRect, Rectangle srcRect, GraphicsUnit srcUnit, EnumerateMetafileProc callback, IntPtr callbackData)
1353 throw new NotImplementedException ();
1356 [MonoTODO (MetafileEnumeration)]
1357 public void EnumerateMetafile (Metafile metafile, PointF [] destPoints, RectangleF srcRect, GraphicsUnit srcUnit, EnumerateMetafileProc callback, IntPtr callbackData)
1359 throw new NotImplementedException ();
1362 [MonoTODO (MetafileEnumeration)]
1363 public void EnumerateMetafile (Metafile metafile, RectangleF destRect, RectangleF srcRect, GraphicsUnit srcUnit, EnumerateMetafileProc callback, IntPtr callbackData)
1365 throw new NotImplementedException ();
1368 [MonoTODO (MetafileEnumeration)]
1369 public void EnumerateMetafile (Metafile metafile, PointF destPoint, RectangleF srcRect, GraphicsUnit srcUnit, EnumerateMetafileProc callback, IntPtr callbackData)
1371 throw new NotImplementedException ();
1374 [MonoTODO (MetafileEnumeration)]
1375 public void EnumerateMetafile (Metafile metafile, Point destPoint, Rectangle srcRect, GraphicsUnit srcUnit, EnumerateMetafileProc callback, IntPtr callbackData)
1377 throw new NotImplementedException ();
1380 [MonoTODO (MetafileEnumeration)]
1381 public void EnumerateMetafile (Metafile metafile, Point [] destPoints, Rectangle srcRect, GraphicsUnit srcUnit, EnumerateMetafileProc callback, IntPtr callbackData)
1383 throw new NotImplementedException ();
1386 [MonoTODO (MetafileEnumeration)]
1387 public void EnumerateMetafile (Metafile metafile, Point [] destPoints, Rectangle srcRect, GraphicsUnit unit, EnumerateMetafileProc callback, IntPtr callbackData, ImageAttributes imageAttr)
1389 throw new NotImplementedException ();
1392 [MonoTODO (MetafileEnumeration)]
1393 public void EnumerateMetafile (Metafile metafile, Rectangle destRect, Rectangle srcRect, GraphicsUnit unit, EnumerateMetafileProc callback, IntPtr callbackData, ImageAttributes imageAttr)
1395 throw new NotImplementedException ();
1398 [MonoTODO (MetafileEnumeration)]
1399 public void EnumerateMetafile (Metafile metafile, Point destPoint, Rectangle srcRect, GraphicsUnit unit, EnumerateMetafileProc callback, IntPtr callbackData, ImageAttributes imageAttr)
1401 throw new NotImplementedException ();
1404 [MonoTODO (MetafileEnumeration)]
1405 public void EnumerateMetafile (Metafile metafile, RectangleF destRect, RectangleF srcRect, GraphicsUnit unit, EnumerateMetafileProc callback, IntPtr callbackData, ImageAttributes imageAttr)
1407 throw new NotImplementedException ();
1410 [MonoTODO (MetafileEnumeration)]
1411 public void EnumerateMetafile (Metafile metafile, PointF [] destPoints, RectangleF srcRect, GraphicsUnit unit, EnumerateMetafileProc callback, IntPtr callbackData, ImageAttributes imageAttr)
1413 throw new NotImplementedException ();
1416 [MonoTODO (MetafileEnumeration)]
1417 public void EnumerateMetafile (Metafile metafile, PointF destPoint, RectangleF srcRect, GraphicsUnit unit, EnumerateMetafileProc callback, IntPtr callbackData, ImageAttributes imageAttr)
1419 throw new NotImplementedException ();
1422 public void ExcludeClip (Rectangle rect)
1424 Status status = GDIPlus.GdipSetClipRectI (nativeObject, rect.X, rect.Y, rect.Width, rect.Height, CombineMode.Exclude);
1425 GDIPlus.CheckStatus (status);
1428 public void ExcludeClip (Region region)
1431 throw new ArgumentNullException ("region");
1432 Status status = GDIPlus.GdipSetClipRegion (nativeObject, region.NativeObject, CombineMode.Exclude);
1433 GDIPlus.CheckStatus (status);
1437 public void FillClosedCurve (Brush brush, PointF [] points)
1440 throw new ArgumentNullException ("brush");
1442 throw new ArgumentNullException ("points");
1443 Status status = GDIPlus.GdipFillClosedCurve (nativeObject, brush.NativeObject, points, points.Length);
1444 GDIPlus.CheckStatus (status);
1447 public void FillClosedCurve (Brush brush, Point [] points)
1450 throw new ArgumentNullException ("brush");
1452 throw new ArgumentNullException ("points");
1453 Status status = GDIPlus.GdipFillClosedCurveI (nativeObject, brush.NativeObject, points, points.Length);
1454 GDIPlus.CheckStatus (status);
1458 public void FillClosedCurve (Brush brush, PointF [] points, FillMode fillmode)
1461 throw new ArgumentNullException ("brush");
1463 throw new ArgumentNullException ("points");
1464 FillClosedCurve (brush, points, fillmode, 0.5f);
1467 public void FillClosedCurve (Brush brush, Point [] points, FillMode fillmode)
1470 throw new ArgumentNullException ("brush");
1472 throw new ArgumentNullException ("points");
1473 FillClosedCurve (brush, points, fillmode, 0.5f);
1476 public void FillClosedCurve (Brush brush, PointF [] points, FillMode fillmode, float tension)
1479 throw new ArgumentNullException ("brush");
1481 throw new ArgumentNullException ("points");
1482 Status status = GDIPlus.GdipFillClosedCurve2 (nativeObject, brush.NativeObject, points, points.Length, tension, fillmode);
1483 GDIPlus.CheckStatus (status);
1486 public void FillClosedCurve (Brush brush, Point [] points, FillMode fillmode, float tension)
1489 throw new ArgumentNullException ("brush");
1491 throw new ArgumentNullException ("points");
1492 Status status = GDIPlus.GdipFillClosedCurve2I (nativeObject, brush.NativeObject, points, points.Length, tension, fillmode);
1493 GDIPlus.CheckStatus (status);
1496 public void FillEllipse (Brush brush, Rectangle rect)
1499 throw new ArgumentNullException ("brush");
1500 FillEllipse (brush, rect.X, rect.Y, rect.Width, rect.Height);
1503 public void FillEllipse (Brush brush, RectangleF rect)
1506 throw new ArgumentNullException ("brush");
1507 FillEllipse (brush, rect.X, rect.Y, rect.Width, rect.Height);
1510 public void FillEllipse (Brush brush, float x, float y, float width, float height)
1513 throw new ArgumentNullException ("brush");
1514 Status status = GDIPlus.GdipFillEllipse (nativeObject, brush.nativeObject, x, y, width, height);
1515 GDIPlus.CheckStatus (status);
1518 public void FillEllipse (Brush brush, int x, int y, int width, int height)
1521 throw new ArgumentNullException ("brush");
1522 Status status = GDIPlus.GdipFillEllipseI (nativeObject, brush.nativeObject, x, y, width, height);
1523 GDIPlus.CheckStatus (status);
1526 public void FillPath (Brush brush, GraphicsPath path)
1529 throw new ArgumentNullException ("brush");
1531 throw new ArgumentNullException ("path");
1532 Status status = GDIPlus.GdipFillPath (nativeObject, brush.NativeObject, path.NativeObject);
1533 GDIPlus.CheckStatus (status);
1536 public void FillPie (Brush brush, Rectangle rect, float startAngle, float sweepAngle)
1539 throw new ArgumentNullException ("brush");
1540 Status status = GDIPlus.GdipFillPie (nativeObject, brush.NativeObject, rect.X, rect.Y, rect.Width, rect.Height, startAngle, sweepAngle);
1541 GDIPlus.CheckStatus (status);
1544 public void FillPie (Brush brush, int x, int y, int width, int height, int startAngle, int sweepAngle)
1547 throw new ArgumentNullException ("brush");
1548 Status status = GDIPlus.GdipFillPieI (nativeObject, brush.NativeObject, x, y, width, height, startAngle, sweepAngle);
1549 GDIPlus.CheckStatus (status);
1552 public void FillPie (Brush brush, float x, float y, float width, float height, float startAngle, float sweepAngle)
1555 throw new ArgumentNullException ("brush");
1556 Status status = GDIPlus.GdipFillPie (nativeObject, brush.NativeObject, x, y, width, height, startAngle, sweepAngle);
1557 GDIPlus.CheckStatus (status);
1560 public void FillPolygon (Brush brush, PointF [] points)
1563 throw new ArgumentNullException ("brush");
1565 throw new ArgumentNullException ("points");
1566 Status status = GDIPlus.GdipFillPolygon2 (nativeObject, brush.nativeObject, points, points.Length);
1567 GDIPlus.CheckStatus (status);
1570 public void FillPolygon (Brush brush, Point [] points)
1573 throw new ArgumentNullException ("brush");
1575 throw new ArgumentNullException ("points");
1576 Status status = GDIPlus.GdipFillPolygon2I (nativeObject, brush.nativeObject, points, points.Length);
1577 GDIPlus.CheckStatus (status);
1580 public void FillPolygon (Brush brush, Point [] points, FillMode fillMode)
1583 throw new ArgumentNullException ("brush");
1585 throw new ArgumentNullException ("points");
1586 Status status = GDIPlus.GdipFillPolygonI (nativeObject, brush.nativeObject, points, points.Length, fillMode);
1587 GDIPlus.CheckStatus (status);
1590 public void FillPolygon (Brush brush, PointF [] points, FillMode fillMode)
1593 throw new ArgumentNullException ("brush");
1595 throw new ArgumentNullException ("points");
1596 Status status = GDIPlus.GdipFillPolygon (nativeObject, brush.nativeObject, points, points.Length, fillMode);
1597 GDIPlus.CheckStatus (status);
1600 public void FillRectangle (Brush brush, RectangleF rect)
1603 throw new ArgumentNullException ("brush");
1604 FillRectangle (brush, rect.Left, rect.Top, rect.Width, rect.Height);
1607 public void FillRectangle (Brush brush, Rectangle rect)
1610 throw new ArgumentNullException ("brush");
1611 FillRectangle (brush, rect.Left, rect.Top, rect.Width, rect.Height);
1614 public void FillRectangle (Brush brush, int x, int y, int width, int height)
1617 throw new ArgumentNullException ("brush");
1619 Status status = GDIPlus.GdipFillRectangleI (nativeObject, brush.nativeObject, x, y, width, height);
1620 GDIPlus.CheckStatus (status);
1623 public void FillRectangle (Brush brush, float x, float y, float width, float height)
1626 throw new ArgumentNullException ("brush");
1628 Status status = GDIPlus.GdipFillRectangle (nativeObject, brush.nativeObject, x, y, width, height);
1629 GDIPlus.CheckStatus (status);
1632 public void FillRectangles (Brush brush, Rectangle [] rects)
1635 throw new ArgumentNullException ("brush");
1637 throw new ArgumentNullException ("rects");
1639 Status status = GDIPlus.GdipFillRectanglesI (nativeObject, brush.nativeObject, rects, rects.Length);
1640 GDIPlus.CheckStatus (status);
1643 public void FillRectangles (Brush brush, RectangleF [] rects)
1646 throw new ArgumentNullException ("brush");
1648 throw new ArgumentNullException ("rects");
1650 Status status = GDIPlus.GdipFillRectangles (nativeObject, brush.nativeObject, rects, rects.Length);
1651 GDIPlus.CheckStatus (status);
1655 public void FillRegion (Brush brush, Region region)
1658 throw new ArgumentNullException ("brush");
1660 throw new ArgumentNullException ("region");
1662 Status status = GDIPlus.GdipFillRegion (nativeObject, brush.NativeObject, region.NativeObject);
1663 GDIPlus.CheckStatus(status);
1667 public void Flush ()
1669 Flush (FlushIntention.Flush);
1673 public void Flush (FlushIntention intention)
1675 if (nativeObject == IntPtr.Zero) {
1679 Status status = GDIPlus.GdipFlush (nativeObject, intention);
1680 GDIPlus.CheckStatus (status);
1681 if (GDIPlus.UseQuartzDrawable || GDIPlus.UseCocoaDrawable)
1682 Carbon.CGContextSynchronize (GDIPlus.Display);
1685 [EditorBrowsable (EditorBrowsableState.Advanced)]
1686 public static Graphics FromHdc (IntPtr hdc)
1689 Status status = GDIPlus.GdipCreateFromHDC (hdc, out graphics);
1690 GDIPlus.CheckStatus (status);
1691 return new Graphics (graphics);
1695 [EditorBrowsable (EditorBrowsableState.Advanced)]
1696 public static Graphics FromHdc (IntPtr hdc, IntPtr hdevice)
1698 throw new NotImplementedException ();
1701 [EditorBrowsable (EditorBrowsableState.Advanced)]
1702 [SecurityPermission (SecurityAction.LinkDemand, UnmanagedCode = true)]
1703 public static Graphics FromHdcInternal (IntPtr hdc)
1705 GDIPlus.Display = hdc;
1709 [EditorBrowsable (EditorBrowsableState.Advanced)]
1710 public static Graphics FromHwnd (IntPtr hwnd)
1714 if (GDIPlus.UseCocoaDrawable) {
1715 CarbonContext cgContext = Carbon.GetCGContextForNSView (hwnd);
1716 GDIPlus.GdipCreateFromQuartz_macosx (cgContext.ctx, cgContext.width, cgContext.height, out graphics);
1718 GDIPlus.Display = cgContext.ctx;
1719 return new Graphics (graphics);
1721 if (GDIPlus.UseQuartzDrawable) {
1722 CarbonContext cgContext = Carbon.GetCGContextForView (hwnd);
1723 GDIPlus.GdipCreateFromQuartz_macosx (cgContext.ctx, cgContext.width, cgContext.height, out graphics);
1725 GDIPlus.Display = cgContext.ctx;
1726 return new Graphics (graphics);
1728 if (GDIPlus.UseX11Drawable) {
1729 if (GDIPlus.Display == IntPtr.Zero) {
1730 GDIPlus.Display = GDIPlus.XOpenDisplay (IntPtr.Zero);
1733 return FromXDrawable (hwnd, GDIPlus.Display);
1737 Status status = GDIPlus.GdipCreateFromHWND (hwnd, out graphics);
1738 GDIPlus.CheckStatus (status);
1740 return new Graphics (graphics);
1743 [EditorBrowsable (EditorBrowsableState.Advanced)]
1744 [SecurityPermission (SecurityAction.LinkDemand, UnmanagedCode = true)]
1745 public static Graphics FromHwndInternal (IntPtr hwnd)
1747 return FromHwnd (hwnd);
1750 public static Graphics FromImage (Image image)
1755 throw new ArgumentNullException ("image");
1757 if ((image.PixelFormat & PixelFormat.Indexed) != 0)
1758 throw new Exception (Locale.GetText ("Cannot create Graphics from an indexed bitmap."));
1760 Status status = GDIPlus.GdipGetImageGraphicsContext (image.nativeObject, out graphics);
1761 GDIPlus.CheckStatus (status);
1762 Graphics result = new Graphics (graphics);
1764 if (GDIPlus.RunningOnUnix ()) {
1765 Rectangle rect = new Rectangle (0,0, image.Width, image.Height);
1766 GDIPlus.GdipSetVisibleClip_linux (result.NativeObject, ref rect);
1772 internal static Graphics FromXDrawable (IntPtr drawable, IntPtr display)
1776 Status s = GDIPlus.GdipCreateFromXDrawable_linux (drawable, display, out graphics);
1777 GDIPlus.CheckStatus (s);
1778 return new Graphics (graphics);
1782 public static IntPtr GetHalftonePalette ()
1784 throw new NotImplementedException ();
1788 [EditorBrowsable (EditorBrowsableState.Advanced)]
1790 public IntPtr GetHdc ()
1793 GDIPlus.CheckStatus (GDIPlus.GdipGetDC (this.nativeObject, out hdc));
1795 deviceContextHdc = hdc;
1801 public Color GetNearestColor (Color color)
1805 Status status = GDIPlus.GdipGetNearestColor (nativeObject, out argb);
1806 GDIPlus.CheckStatus (status);
1808 return Color.FromArgb (argb);
1812 public void IntersectClip (Region region)
1815 throw new ArgumentNullException ("region");
1816 Status status = GDIPlus.GdipSetClipRegion (nativeObject, region.NativeObject, CombineMode.Intersect);
1817 GDIPlus.CheckStatus (status);
1820 public void IntersectClip (RectangleF rect)
1822 Status status = GDIPlus.GdipSetClipRect (nativeObject, rect.X, rect.Y, rect.Width, rect.Height, CombineMode.Intersect);
1823 GDIPlus.CheckStatus (status);
1826 public void IntersectClip (Rectangle rect)
1828 Status status = GDIPlus.GdipSetClipRectI (nativeObject, rect.X, rect.Y, rect.Width, rect.Height, CombineMode.Intersect);
1829 GDIPlus.CheckStatus (status);
1832 public bool IsVisible (Point point)
1834 bool isVisible = false;
1836 Status status = GDIPlus.GdipIsVisiblePointI (nativeObject, point.X, point.Y, out isVisible);
1837 GDIPlus.CheckStatus (status);
1843 public bool IsVisible (RectangleF rect)
1845 bool isVisible = false;
1847 Status status = GDIPlus.GdipIsVisibleRect (nativeObject, rect.X, rect.Y, rect.Width, rect.Height, out isVisible);
1848 GDIPlus.CheckStatus (status);
1853 public bool IsVisible (PointF point)
1855 bool isVisible = false;
1857 Status status = GDIPlus.GdipIsVisiblePoint (nativeObject, point.X, point.Y, out isVisible);
1858 GDIPlus.CheckStatus (status);
1863 public bool IsVisible (Rectangle rect)
1865 bool isVisible = false;
1867 Status status = GDIPlus.GdipIsVisibleRectI (nativeObject, rect.X, rect.Y, rect.Width, rect.Height, out isVisible);
1868 GDIPlus.CheckStatus (status);
1873 public bool IsVisible (float x, float y)
1875 return IsVisible (new PointF (x, y));
1878 public bool IsVisible (int x, int y)
1880 return IsVisible (new Point (x, y));
1883 public bool IsVisible (float x, float y, float width, float height)
1885 return IsVisible (new RectangleF (x, y, width, height));
1889 public bool IsVisible (int x, int y, int width, int height)
1891 return IsVisible (new Rectangle (x, y, width, height));
1895 public Region[] MeasureCharacterRanges (string text, Font font, RectangleF layoutRect, StringFormat stringFormat)
1897 if ((text == null) || (text.Length == 0))
1898 return new Region [0];
1901 throw new ArgumentNullException ("font");
1903 if (stringFormat == null)
1904 throw new ArgumentException ("stringFormat");
1906 int regcount = stringFormat.GetMeasurableCharacterRangeCount ();
1908 return new Region[0];
1910 IntPtr[] native_regions = new IntPtr [regcount];
1911 Region[] regions = new Region [regcount];
1913 for (int i = 0; i < regcount; i++) {
1914 regions[i] = new Region ();
1915 native_regions[i] = regions[i].NativeObject;
1918 Status status = GDIPlus.GdipMeasureCharacterRanges (nativeObject, text, text.Length,
1919 font.NativeObject, ref layoutRect, stringFormat.NativeObject, regcount, out native_regions[0]);
1920 GDIPlus.CheckStatus (status);
1926 public SizeF MeasureString (string text, Font font)
1928 return MeasureString (text, font, SizeF.Empty);
1932 public SizeF MeasureString (string text, Font font, SizeF layoutArea)
1934 if (text == null || text.Length == 0)
1938 throw new ArgumentNullException ("font");
1940 int charactersFitted, linesFilled;
1941 RectangleF boundingBox = new RectangleF ();
1942 RectangleF rect = new RectangleF (0, 0, layoutArea.Width, layoutArea.Height);
1944 Status status = GDIPlus.GdipMeasureString (nativeObject, text, text.Length,
1945 font.NativeObject, ref rect,
1946 IntPtr.Zero, out boundingBox,
1947 out charactersFitted, out linesFilled);
1948 GDIPlus.CheckStatus (status);
1950 return new SizeF (boundingBox.Width, boundingBox.Height);
1954 public SizeF MeasureString (string text, Font font, int width)
1956 if (text == null || text.Length == 0)
1960 throw new ArgumentNullException ("font");
1962 RectangleF boundingBox = new RectangleF ();
1963 RectangleF rect = new RectangleF (0, 0, width, Int32.MaxValue);
1964 int charactersFitted, linesFilled;
1966 Status status = GDIPlus.GdipMeasureString (nativeObject, text, text.Length,
1967 font.NativeObject, ref rect,
1968 IntPtr.Zero, out boundingBox,
1969 out charactersFitted, out linesFilled);
1970 GDIPlus.CheckStatus (status);
1972 return new SizeF (boundingBox.Width, boundingBox.Height);
1976 public SizeF MeasureString (string text, Font font, SizeF layoutArea,
1977 StringFormat stringFormat)
1979 int charactersFitted, linesFilled;
1980 return MeasureString (text, font, layoutArea, stringFormat,
1981 out charactersFitted, out linesFilled);
1985 public SizeF MeasureString (string text, Font font, int width, StringFormat format)
1987 int charactersFitted, linesFilled;
1988 return MeasureString (text, font, new SizeF (width, Int32.MaxValue),
1989 format, out charactersFitted, out linesFilled);
1993 public SizeF MeasureString (string text, Font font, PointF origin,
1994 StringFormat stringFormat)
1996 if (text == null || text.Length == 0)
2000 throw new ArgumentNullException ("font");
2002 RectangleF boundingBox = new RectangleF ();
2003 RectangleF rect = new RectangleF (origin.X, origin.Y, 0, 0);
2004 int charactersFitted, linesFilled;
2006 IntPtr format = (stringFormat == null) ? IntPtr.Zero : stringFormat.NativeObject;
2008 Status status = GDIPlus.GdipMeasureString (nativeObject, text, text.Length,
2009 font.NativeObject, ref rect, format,
2011 out charactersFitted,
2013 GDIPlus.CheckStatus (status);
2015 return new SizeF (boundingBox.Width, boundingBox.Height);
2019 public SizeF MeasureString (string text, Font font, SizeF layoutArea,
2020 StringFormat stringFormat, out int charactersFitted,
2021 out int linesFilled)
2023 charactersFitted = 0;
2026 if (text == null || text.Length == 0)
2030 throw new ArgumentNullException ("font");
2032 RectangleF boundingBox = new RectangleF ();
2033 RectangleF rect = new RectangleF (0, 0, layoutArea.Width, layoutArea.Height);
2035 IntPtr format = (stringFormat == null) ? IntPtr.Zero : stringFormat.NativeObject;
2037 Status status = GDIPlus.GdipMeasureString (nativeObject, text, text.Length,
2038 font.NativeObject, ref rect, format,
2040 out charactersFitted,
2042 GDIPlus.CheckStatus (status);
2044 return new SizeF (boundingBox.Width, boundingBox.Height);
2047 public void MultiplyTransform (Matrix matrix)
2049 MultiplyTransform (matrix, MatrixOrder.Prepend);
2052 public void MultiplyTransform (Matrix matrix, MatrixOrder order)
2054 Status status = GDIPlus.GdipMultiplyWorldTransform (nativeObject,
2055 matrix.nativeMatrix,
2057 GDIPlus.CheckStatus (status);
2060 [EditorBrowsable (EditorBrowsableState.Advanced)]
2061 public void ReleaseHdc (IntPtr hdc)
2063 Status status = GDIPlus.GdipReleaseDC (nativeObject, hdc);
2064 GDIPlus.CheckStatus (status);
2066 if (hdc == deviceContextHdc)
2067 deviceContextHdc = IntPtr.Zero;
2072 public void ReleaseHdc ()
2074 if (deviceContextHdc == IntPtr.Zero)
2075 throw new ArgumentException ("Invalid Handle");
2077 ReleaseHdc (deviceContextHdc);
2081 [MonoTODO ("Parameter hdc doesn't map well into libgdiplus")]
2083 [EditorBrowsable (EditorBrowsableState.Never)]
2085 [EditorBrowsable (EditorBrowsableState.Advanced)]
2087 [SecurityPermission (SecurityAction.LinkDemand, UnmanagedCode = true)]
2088 public void ReleaseHdcInternal (IntPtr hdc)
2090 throw new NotImplementedException ();
2094 public void ResetClip ()
2096 Status status = GDIPlus.GdipResetClip (nativeObject);
2097 GDIPlus.CheckStatus (status);
2100 public void ResetTransform ()
2102 Status status = GDIPlus.GdipResetWorldTransform (nativeObject);
2103 GDIPlus.CheckStatus (status);
2106 public void Restore (GraphicsState gstate)
2108 Status status = GDIPlus.GdipRestoreGraphics (nativeObject, gstate.nativeState);
2109 GDIPlus.CheckStatus (status);
2113 public void RotateTransform (float angle)
2115 RotateTransform (angle, MatrixOrder.Prepend);
2118 public void RotateTransform (float angle, MatrixOrder order)
2121 Status status = GDIPlus.GdipRotateWorldTransform (nativeObject, angle, order);
2122 GDIPlus.CheckStatus (status);
2125 public GraphicsState Save ()
2128 Status status = GDIPlus.GdipSaveGraphics (nativeObject, out saveState);
2129 GDIPlus.CheckStatus (status);
2131 GraphicsState state = new GraphicsState ();
2132 state.nativeState = saveState;
2136 public void ScaleTransform (float sx, float sy)
2138 ScaleTransform (sx, sy, MatrixOrder.Prepend);
2141 public void ScaleTransform (float sx, float sy, MatrixOrder order)
2143 Status status = GDIPlus.GdipScaleWorldTransform (nativeObject, sx, sy, order);
2144 GDIPlus.CheckStatus (status);
2148 public void SetClip (RectangleF rect)
2150 SetClip (rect, CombineMode.Replace);
2154 public void SetClip (GraphicsPath path)
2156 SetClip (path, CombineMode.Replace);
2160 public void SetClip (Rectangle rect)
2162 SetClip (rect, CombineMode.Replace);
2166 public void SetClip (Graphics g)
2168 SetClip (g, CombineMode.Replace);
2172 public void SetClip (Graphics g, CombineMode combineMode)
2175 throw new ArgumentNullException ("g");
2177 Status status = GDIPlus.GdipSetClipGraphics (nativeObject, g.NativeObject, combineMode);
2178 GDIPlus.CheckStatus (status);
2182 public void SetClip (Rectangle rect, CombineMode combineMode)
2184 Status status = GDIPlus.GdipSetClipRectI (nativeObject, rect.X, rect.Y, rect.Width, rect.Height, combineMode);
2185 GDIPlus.CheckStatus (status);
2189 public void SetClip (RectangleF rect, CombineMode combineMode)
2191 Status status = GDIPlus.GdipSetClipRect (nativeObject, rect.X, rect.Y, rect.Width, rect.Height, combineMode);
2192 GDIPlus.CheckStatus (status);
2196 public void SetClip (Region region, CombineMode combineMode)
2199 throw new ArgumentNullException ("region");
2200 Status status = GDIPlus.GdipSetClipRegion(nativeObject, region.NativeObject, combineMode);
2201 GDIPlus.CheckStatus (status);
2205 public void SetClip (GraphicsPath path, CombineMode combineMode)
2208 throw new ArgumentNullException ("path");
2209 Status status = GDIPlus.GdipSetClipPath (nativeObject, path.NativeObject, combineMode);
2210 GDIPlus.CheckStatus (status);
2214 public void TransformPoints (CoordinateSpace destSpace, CoordinateSpace srcSpace, PointF [] pts)
2217 throw new ArgumentNullException ("pts");
2219 IntPtr ptrPt = GDIPlus.FromPointToUnManagedMemory (pts);
2221 Status status = GDIPlus.GdipTransformPoints (nativeObject, destSpace, srcSpace, ptrPt, pts.Length);
2222 GDIPlus.CheckStatus (status);
2224 GDIPlus.FromUnManagedMemoryToPoint (ptrPt, pts);
2228 public void TransformPoints (CoordinateSpace destSpace, CoordinateSpace srcSpace, Point [] pts)
2231 throw new ArgumentNullException ("pts");
2232 IntPtr ptrPt = GDIPlus.FromPointToUnManagedMemoryI (pts);
2234 Status status = GDIPlus.GdipTransformPointsI (nativeObject, destSpace, srcSpace, ptrPt, pts.Length);
2235 GDIPlus.CheckStatus (status);
2237 GDIPlus.FromUnManagedMemoryToPointI (ptrPt, pts);
2241 public void TranslateClip (int dx, int dy)
2243 Status status = GDIPlus.GdipTranslateClipI (nativeObject, dx, dy);
2244 GDIPlus.CheckStatus (status);
2248 public void TranslateClip (float dx, float dy)
2250 Status status = GDIPlus.GdipTranslateClip (nativeObject, dx, dy);
2251 GDIPlus.CheckStatus (status);
2254 public void TranslateTransform (float dx, float dy)
2256 TranslateTransform (dx, dy, MatrixOrder.Prepend);
2260 public void TranslateTransform (float dx, float dy, MatrixOrder order)
2262 Status status = GDIPlus.GdipTranslateWorldTransform (nativeObject, dx, dy, order);
2263 GDIPlus.CheckStatus (status);
2266 public Region Clip {
2268 Region reg = new Region();
2269 Status status = GDIPlus.GdipGetClip (nativeObject, reg.NativeObject);
2270 GDIPlus.CheckStatus (status);
2274 SetClip (value, CombineMode.Replace);
2278 public RectangleF ClipBounds {
2280 RectangleF rect = new RectangleF ();
2281 Status status = GDIPlus.GdipGetClipBounds (nativeObject, out rect);
2282 GDIPlus.CheckStatus (status);
2287 public CompositingMode CompositingMode {
2289 CompositingMode mode;
2290 Status status = GDIPlus.GdipGetCompositingMode (nativeObject, out mode);
2291 GDIPlus.CheckStatus (status);
2296 Status status = GDIPlus.GdipSetCompositingMode (nativeObject, value);
2297 GDIPlus.CheckStatus (status);
2302 public CompositingQuality CompositingQuality {
2304 CompositingQuality quality;
2306 Status status = GDIPlus.GdipGetCompositingQuality (nativeObject, out quality);
2307 GDIPlus.CheckStatus (status);
2311 Status status = GDIPlus.GdipSetCompositingQuality (nativeObject, value);
2312 GDIPlus.CheckStatus (status);
2320 Status status = GDIPlus.GdipGetDpiX (nativeObject, out x);
2321 GDIPlus.CheckStatus (status);
2330 Status status = GDIPlus.GdipGetDpiY (nativeObject, out y);
2331 GDIPlus.CheckStatus (status);
2336 public InterpolationMode InterpolationMode {
2338 InterpolationMode imode = InterpolationMode.Invalid;
2339 Status status = GDIPlus.GdipGetInterpolationMode (nativeObject, out imode);
2340 GDIPlus.CheckStatus (status);
2344 Status status = GDIPlus.GdipSetInterpolationMode (nativeObject, value);
2345 GDIPlus.CheckStatus (status);
2349 public bool IsClipEmpty {
2351 bool isEmpty = false;
2353 Status status = GDIPlus.GdipIsClipEmpty (nativeObject, out isEmpty);
2354 GDIPlus.CheckStatus (status);
2359 public bool IsVisibleClipEmpty {
2361 bool isEmpty = false;
2363 Status status = GDIPlus.GdipIsVisibleClipEmpty (nativeObject, out isEmpty);
2364 GDIPlus.CheckStatus (status);
2369 public float PageScale {
2373 Status status = GDIPlus.GdipGetPageScale (nativeObject, out scale);
2374 GDIPlus.CheckStatus (status);
2378 Status status = GDIPlus.GdipSetPageScale (nativeObject, value);
2379 GDIPlus.CheckStatus (status);
2383 public GraphicsUnit PageUnit {
2387 Status status = GDIPlus.GdipGetPageUnit (nativeObject, out unit);
2388 GDIPlus.CheckStatus (status);
2392 Status status = GDIPlus.GdipSetPageUnit (nativeObject, value);
2393 GDIPlus.CheckStatus (status);
2397 [MonoTODO ("This property does not do anything when used with libgdiplus.")]
2398 public PixelOffsetMode PixelOffsetMode {
2400 PixelOffsetMode pixelOffset = PixelOffsetMode.Invalid;
2402 Status status = GDIPlus.GdipGetPixelOffsetMode (nativeObject, out pixelOffset);
2403 GDIPlus.CheckStatus (status);
2407 Status status = GDIPlus.GdipSetPixelOffsetMode (nativeObject, value);
2408 GDIPlus.CheckStatus (status);
2412 public Point RenderingOrigin {
2415 Status status = GDIPlus.GdipGetRenderingOrigin (nativeObject, out x, out y);
2416 GDIPlus.CheckStatus (status);
2417 return new Point (x, y);
2421 Status status = GDIPlus.GdipSetRenderingOrigin (nativeObject, value.X, value.Y);
2422 GDIPlus.CheckStatus (status);
2426 public SmoothingMode SmoothingMode {
2428 SmoothingMode mode = SmoothingMode.Invalid;
2430 Status status = GDIPlus.GdipGetSmoothingMode (nativeObject, out mode);
2431 GDIPlus.CheckStatus (status);
2436 Status status = GDIPlus.GdipSetSmoothingMode (nativeObject, value);
2437 GDIPlus.CheckStatus (status);
2441 [MonoTODO ("This property does not do anything when used with libgdiplus.")]
2442 public int TextContrast {
2446 Status status = GDIPlus.GdipGetTextContrast (nativeObject, out contrast);
2447 GDIPlus.CheckStatus (status);
2452 Status status = GDIPlus.GdipSetTextContrast (nativeObject, value);
2453 GDIPlus.CheckStatus (status);
2457 public TextRenderingHint TextRenderingHint {
2459 TextRenderingHint hint;
2461 Status status = GDIPlus.GdipGetTextRenderingHint (nativeObject, out hint);
2462 GDIPlus.CheckStatus (status);
2467 Status status = GDIPlus.GdipSetTextRenderingHint (nativeObject, value);
2468 GDIPlus.CheckStatus (status);
2472 public Matrix Transform {
2474 Matrix matrix = new Matrix ();
2475 Status status = GDIPlus.GdipGetWorldTransform (nativeObject, matrix.nativeMatrix);
2476 GDIPlus.CheckStatus (status);
2481 throw new ArgumentNullException ("value");
2483 Status status = GDIPlus.GdipSetWorldTransform (nativeObject, value.nativeMatrix);
2484 GDIPlus.CheckStatus (status);
2488 public RectangleF VisibleClipBounds {
2492 Status status = GDIPlus.GdipGetVisibleClipBounds (nativeObject, out rect);
2493 GDIPlus.CheckStatus (status);
2500 [EditorBrowsable (EditorBrowsableState.Never)]
2501 public object GetContextInfo ()
2503 throw new NotImplementedException ();