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 [MonoTODO ("Metafiles, both WMF and EMF formats, aren't supported.")]
1205 public void EnumerateMetafile (Metafile metafile, Point [] destPoints, EnumerateMetafileProc callback)
1207 throw new NotImplementedException ();
1210 [MonoTODO ("Metafiles, both WMF and EMF formats, aren't supported.")]
1211 public void EnumerateMetafile (Metafile metafile, RectangleF destRect, EnumerateMetafileProc callback)
1213 throw new NotImplementedException ();
1216 [MonoTODO ("Metafiles, both WMF and EMF formats, aren't supported.")]
1217 public void EnumerateMetafile (Metafile metafile, PointF [] destPoints, EnumerateMetafileProc callback)
1219 throw new NotImplementedException ();
1222 [MonoTODO ("Metafiles, both WMF and EMF formats, aren't supported.")]
1223 public void EnumerateMetafile (Metafile metafile, Rectangle destRect, EnumerateMetafileProc callback)
1225 throw new NotImplementedException ();
1228 [MonoTODO ("Metafiles, both WMF and EMF formats, aren't supported.")]
1229 public void EnumerateMetafile (Metafile metafile, Point destPoint, EnumerateMetafileProc callback)
1231 throw new NotImplementedException ();
1234 [MonoTODO ("Metafiles, both WMF and EMF formats, aren't supported.")]
1235 public void EnumerateMetafile (Metafile metafile, PointF destPoint, EnumerateMetafileProc callback)
1237 throw new NotImplementedException ();
1240 [MonoTODO ("Metafiles, both WMF and EMF formats, aren't supported.")]
1241 public void EnumerateMetafile (Metafile metafile, PointF destPoint, EnumerateMetafileProc callback, IntPtr callbackData)
1243 throw new NotImplementedException ();
1246 [MonoTODO ("Metafiles, both WMF and EMF formats, aren't supported.")]
1247 public void EnumerateMetafile (Metafile metafile, Rectangle destRect, EnumerateMetafileProc callback, IntPtr callbackData)
1249 throw new NotImplementedException ();
1252 [MonoTODO ("Metafiles, both WMF and EMF formats, aren't supported.")]
1253 public void EnumerateMetafile (Metafile metafile, PointF [] destPoints, EnumerateMetafileProc callback, IntPtr callbackData)
1255 throw new NotImplementedException ();
1258 [MonoTODO ("Metafiles, both WMF and EMF formats, aren't supported.")]
1259 public void EnumerateMetafile (Metafile metafile, Point destPoint, EnumerateMetafileProc callback, IntPtr callbackData)
1261 throw new NotImplementedException ();
1264 [MonoTODO ("Metafiles, both WMF and EMF formats, aren't supported.")]
1265 public void EnumerateMetafile (Metafile metafile, Point [] destPoints, EnumerateMetafileProc callback, IntPtr callbackData)
1267 throw new NotImplementedException ();
1270 [MonoTODO ("Metafiles, both WMF and EMF formats, aren't supported.")]
1271 public void EnumerateMetafile (Metafile metafile, RectangleF destRect, EnumerateMetafileProc callback, IntPtr callbackData)
1273 throw new NotImplementedException ();
1276 [MonoTODO ("Metafiles, both WMF and EMF formats, aren't supported.")]
1277 public void EnumerateMetafile (Metafile metafile, PointF destPoint, RectangleF srcRect, GraphicsUnit srcUnit, EnumerateMetafileProc callback)
1279 throw new NotImplementedException ();
1282 [MonoTODO ("Metafiles, both WMF and EMF formats, aren't supported.")]
1283 public void EnumerateMetafile (Metafile metafile, Point destPoint, Rectangle srcRect, GraphicsUnit srcUnit, EnumerateMetafileProc callback)
1285 throw new NotImplementedException ();
1288 [MonoTODO ("Metafiles, both WMF and EMF formats, aren't supported.")]
1289 public void EnumerateMetafile (Metafile metafile, PointF [] destPoints, RectangleF srcRect, GraphicsUnit srcUnit, EnumerateMetafileProc callback)
1291 throw new NotImplementedException ();
1294 [MonoTODO ("Metafiles, both WMF and EMF formats, aren't supported.")]
1295 public void EnumerateMetafile (Metafile metafile, Point [] destPoints, Rectangle srcRect, GraphicsUnit srcUnit, EnumerateMetafileProc callback)
1297 throw new NotImplementedException ();
1300 [MonoTODO ("Metafiles, both WMF and EMF formats, aren't supported.")]
1301 public void EnumerateMetafile (Metafile metafile, RectangleF destRect, RectangleF srcRect, GraphicsUnit srcUnit, EnumerateMetafileProc callback)
1303 throw new NotImplementedException ();
1306 [MonoTODO ("Metafiles, both WMF and EMF formats, aren't supported.")]
1307 public void EnumerateMetafile (Metafile metafile, Rectangle destRect, Rectangle srcRect, GraphicsUnit srcUnit, EnumerateMetafileProc callback)
1309 throw new NotImplementedException ();
1312 [MonoTODO ("Metafiles, both WMF and EMF formats, aren't supported.")]
1313 public void EnumerateMetafile (Metafile metafile, RectangleF destRect, EnumerateMetafileProc callback, IntPtr callbackData, ImageAttributes imageAttr)
1315 throw new NotImplementedException ();
1318 [MonoTODO ("Metafiles, both WMF and EMF formats, aren't supported.")]
1319 public void EnumerateMetafile (Metafile metafile, Point destPoint, EnumerateMetafileProc callback, IntPtr callbackData, ImageAttributes imageAttr)
1321 throw new NotImplementedException ();
1324 [MonoTODO ("Metafiles, both WMF and EMF formats, aren't supported.")]
1325 public void EnumerateMetafile (Metafile metafile, PointF destPoint, EnumerateMetafileProc callback, IntPtr callbackData, ImageAttributes imageAttr)
1327 throw new NotImplementedException ();
1330 [MonoTODO ("Metafiles, both WMF and EMF formats, aren't supported.")]
1331 public void EnumerateMetafile (Metafile metafile, Point [] destPoints, EnumerateMetafileProc callback, IntPtr callbackData, ImageAttributes imageAttr)
1333 throw new NotImplementedException ();
1336 [MonoTODO ("Metafiles, both WMF and EMF formats, aren't supported.")]
1337 public void EnumerateMetafile (Metafile metafile, PointF [] destPoints, EnumerateMetafileProc callback, IntPtr callbackData, ImageAttributes imageAttr)
1339 throw new NotImplementedException ();
1342 [MonoTODO ("Metafiles, both WMF and EMF formats, aren't supported.")]
1343 public void EnumerateMetafile (Metafile metafile, Rectangle destRect, EnumerateMetafileProc callback, IntPtr callbackData, ImageAttributes imageAttr)
1345 throw new NotImplementedException ();
1348 [MonoTODO ("Metafiles, both WMF and EMF formats, aren't supported.")]
1349 public void EnumerateMetafile (Metafile metafile, Rectangle destRect, Rectangle srcRect, GraphicsUnit srcUnit, EnumerateMetafileProc callback, IntPtr callbackData)
1351 throw new NotImplementedException ();
1354 [MonoTODO ("Metafiles, both WMF and EMF formats, aren't supported.")]
1355 public void EnumerateMetafile (Metafile metafile, PointF [] destPoints, RectangleF srcRect, GraphicsUnit srcUnit, EnumerateMetafileProc callback, IntPtr callbackData)
1357 throw new NotImplementedException ();
1360 [MonoTODO ("Metafiles, both WMF and EMF formats, aren't supported.")]
1361 public void EnumerateMetafile (Metafile metafile, RectangleF destRect, RectangleF srcRect, GraphicsUnit srcUnit, EnumerateMetafileProc callback, IntPtr callbackData)
1363 throw new NotImplementedException ();
1366 [MonoTODO ("Metafiles, both WMF and EMF formats, aren't supported.")]
1367 public void EnumerateMetafile (Metafile metafile, PointF destPoint, RectangleF srcRect, GraphicsUnit srcUnit, EnumerateMetafileProc callback, IntPtr callbackData)
1369 throw new NotImplementedException ();
1372 [MonoTODO ("Metafiles, both WMF and EMF formats, aren't supported.")]
1373 public void EnumerateMetafile (Metafile metafile, Point destPoint, Rectangle srcRect, GraphicsUnit srcUnit, EnumerateMetafileProc callback, IntPtr callbackData)
1375 throw new NotImplementedException ();
1378 [MonoTODO ("Metafiles, both WMF and EMF formats, aren't supported.")]
1379 public void EnumerateMetafile (Metafile metafile, Point [] destPoints, Rectangle srcRect, GraphicsUnit srcUnit, EnumerateMetafileProc callback, IntPtr callbackData)
1381 throw new NotImplementedException ();
1384 [MonoTODO ("Metafiles, both WMF and EMF formats, aren't supported.")]
1385 public void EnumerateMetafile (Metafile metafile, Point [] destPoints, Rectangle srcRect, GraphicsUnit unit, EnumerateMetafileProc callback, IntPtr callbackData, ImageAttributes imageAttr)
1387 throw new NotImplementedException ();
1390 [MonoTODO ("Metafiles, both WMF and EMF formats, aren't supported.")]
1391 public void EnumerateMetafile (Metafile metafile, Rectangle destRect, Rectangle srcRect, GraphicsUnit unit, EnumerateMetafileProc callback, IntPtr callbackData, ImageAttributes imageAttr)
1393 throw new NotImplementedException ();
1396 [MonoTODO ("Metafiles, both WMF and EMF formats, aren't supported.")]
1397 public void EnumerateMetafile (Metafile metafile, Point destPoint, Rectangle srcRect, GraphicsUnit unit, EnumerateMetafileProc callback, IntPtr callbackData, ImageAttributes imageAttr)
1399 throw new NotImplementedException ();
1402 [MonoTODO ("Metafiles, both WMF and EMF formats, aren't supported.")]
1403 public void EnumerateMetafile (Metafile metafile, RectangleF destRect, RectangleF srcRect, GraphicsUnit unit, EnumerateMetafileProc callback, IntPtr callbackData, ImageAttributes imageAttr)
1405 throw new NotImplementedException ();
1408 [MonoTODO ("Metafiles, both WMF and EMF formats, aren't supported.")]
1409 public void EnumerateMetafile (Metafile metafile, PointF [] destPoints, RectangleF srcRect, GraphicsUnit unit, EnumerateMetafileProc callback, IntPtr callbackData, ImageAttributes imageAttr)
1411 throw new NotImplementedException ();
1414 [MonoTODO ("Metafiles, both WMF and EMF formats, aren't supported.")]
1415 public void EnumerateMetafile (Metafile metafile, PointF destPoint, RectangleF srcRect, GraphicsUnit unit, EnumerateMetafileProc callback, IntPtr callbackData, ImageAttributes imageAttr)
1417 throw new NotImplementedException ();
1420 public void ExcludeClip (Rectangle rect)
1422 Status status = GDIPlus.GdipSetClipRectI (nativeObject, rect.X, rect.Y, rect.Width, rect.Height, CombineMode.Exclude);
1423 GDIPlus.CheckStatus (status);
1426 public void ExcludeClip (Region region)
1429 throw new ArgumentNullException ("region");
1430 Status status = GDIPlus.GdipSetClipRegion (nativeObject, region.NativeObject, CombineMode.Exclude);
1431 GDIPlus.CheckStatus (status);
1435 public void FillClosedCurve (Brush brush, PointF [] points)
1438 throw new ArgumentNullException ("brush");
1440 throw new ArgumentNullException ("points");
1441 Status status = GDIPlus.GdipFillClosedCurve (nativeObject, brush.NativeObject, points, points.Length);
1442 GDIPlus.CheckStatus (status);
1445 public void FillClosedCurve (Brush brush, Point [] points)
1448 throw new ArgumentNullException ("brush");
1450 throw new ArgumentNullException ("points");
1451 Status status = GDIPlus.GdipFillClosedCurveI (nativeObject, brush.NativeObject, points, points.Length);
1452 GDIPlus.CheckStatus (status);
1456 public void FillClosedCurve (Brush brush, PointF [] points, FillMode fillmode)
1459 throw new ArgumentNullException ("brush");
1461 throw new ArgumentNullException ("points");
1462 FillClosedCurve (brush, points, fillmode, 0.5f);
1465 public void FillClosedCurve (Brush brush, Point [] points, FillMode fillmode)
1468 throw new ArgumentNullException ("brush");
1470 throw new ArgumentNullException ("points");
1471 FillClosedCurve (brush, points, fillmode, 0.5f);
1474 public void FillClosedCurve (Brush brush, PointF [] points, FillMode fillmode, float tension)
1477 throw new ArgumentNullException ("brush");
1479 throw new ArgumentNullException ("points");
1480 Status status = GDIPlus.GdipFillClosedCurve2 (nativeObject, brush.NativeObject, points, points.Length, tension, fillmode);
1481 GDIPlus.CheckStatus (status);
1484 public void FillClosedCurve (Brush brush, Point [] points, FillMode fillmode, float tension)
1487 throw new ArgumentNullException ("brush");
1489 throw new ArgumentNullException ("points");
1490 Status status = GDIPlus.GdipFillClosedCurve2I (nativeObject, brush.NativeObject, points, points.Length, tension, fillmode);
1491 GDIPlus.CheckStatus (status);
1494 public void FillEllipse (Brush brush, Rectangle rect)
1497 throw new ArgumentNullException ("brush");
1498 FillEllipse (brush, rect.X, rect.Y, rect.Width, rect.Height);
1501 public void FillEllipse (Brush brush, RectangleF rect)
1504 throw new ArgumentNullException ("brush");
1505 FillEllipse (brush, rect.X, rect.Y, rect.Width, rect.Height);
1508 public void FillEllipse (Brush brush, float x, float y, float width, float height)
1511 throw new ArgumentNullException ("brush");
1512 Status status = GDIPlus.GdipFillEllipse (nativeObject, brush.nativeObject, x, y, width, height);
1513 GDIPlus.CheckStatus (status);
1516 public void FillEllipse (Brush brush, int x, int y, int width, int height)
1519 throw new ArgumentNullException ("brush");
1520 Status status = GDIPlus.GdipFillEllipseI (nativeObject, brush.nativeObject, x, y, width, height);
1521 GDIPlus.CheckStatus (status);
1524 public void FillPath (Brush brush, GraphicsPath path)
1527 throw new ArgumentNullException ("brush");
1529 throw new ArgumentNullException ("path");
1530 Status status = GDIPlus.GdipFillPath (nativeObject, brush.NativeObject, path.NativeObject);
1531 GDIPlus.CheckStatus (status);
1534 public void FillPie (Brush brush, Rectangle rect, float startAngle, float sweepAngle)
1537 throw new ArgumentNullException ("brush");
1538 Status status = GDIPlus.GdipFillPie (nativeObject, brush.NativeObject, rect.X, rect.Y, rect.Width, rect.Height, startAngle, sweepAngle);
1539 GDIPlus.CheckStatus (status);
1542 public void FillPie (Brush brush, int x, int y, int width, int height, int startAngle, int sweepAngle)
1545 throw new ArgumentNullException ("brush");
1546 Status status = GDIPlus.GdipFillPieI (nativeObject, brush.NativeObject, x, y, width, height, startAngle, sweepAngle);
1547 GDIPlus.CheckStatus (status);
1550 public void FillPie (Brush brush, float x, float y, float width, float height, float startAngle, float sweepAngle)
1553 throw new ArgumentNullException ("brush");
1554 Status status = GDIPlus.GdipFillPie (nativeObject, brush.NativeObject, x, y, width, height, startAngle, sweepAngle);
1555 GDIPlus.CheckStatus (status);
1558 public void FillPolygon (Brush brush, PointF [] points)
1561 throw new ArgumentNullException ("brush");
1563 throw new ArgumentNullException ("points");
1564 Status status = GDIPlus.GdipFillPolygon2 (nativeObject, brush.nativeObject, points, points.Length);
1565 GDIPlus.CheckStatus (status);
1568 public void FillPolygon (Brush brush, Point [] points)
1571 throw new ArgumentNullException ("brush");
1573 throw new ArgumentNullException ("points");
1574 Status status = GDIPlus.GdipFillPolygon2I (nativeObject, brush.nativeObject, points, points.Length);
1575 GDIPlus.CheckStatus (status);
1578 public void FillPolygon (Brush brush, Point [] points, FillMode fillMode)
1581 throw new ArgumentNullException ("brush");
1583 throw new ArgumentNullException ("points");
1584 Status status = GDIPlus.GdipFillPolygonI (nativeObject, brush.nativeObject, points, points.Length, fillMode);
1585 GDIPlus.CheckStatus (status);
1588 public void FillPolygon (Brush brush, PointF [] points, FillMode fillMode)
1591 throw new ArgumentNullException ("brush");
1593 throw new ArgumentNullException ("points");
1594 Status status = GDIPlus.GdipFillPolygon (nativeObject, brush.nativeObject, points, points.Length, fillMode);
1595 GDIPlus.CheckStatus (status);
1598 public void FillRectangle (Brush brush, RectangleF rect)
1601 throw new ArgumentNullException ("brush");
1602 FillRectangle (brush, rect.Left, rect.Top, rect.Width, rect.Height);
1605 public void FillRectangle (Brush brush, Rectangle rect)
1608 throw new ArgumentNullException ("brush");
1609 FillRectangle (brush, rect.Left, rect.Top, rect.Width, rect.Height);
1612 public void FillRectangle (Brush brush, int x, int y, int width, int height)
1615 throw new ArgumentNullException ("brush");
1617 Status status = GDIPlus.GdipFillRectangleI (nativeObject, brush.nativeObject, x, y, width, height);
1618 GDIPlus.CheckStatus (status);
1621 public void FillRectangle (Brush brush, float x, float y, float width, float height)
1624 throw new ArgumentNullException ("brush");
1626 Status status = GDIPlus.GdipFillRectangle (nativeObject, brush.nativeObject, x, y, width, height);
1627 GDIPlus.CheckStatus (status);
1630 public void FillRectangles (Brush brush, Rectangle [] rects)
1633 throw new ArgumentNullException ("brush");
1635 throw new ArgumentNullException ("rects");
1637 Status status = GDIPlus.GdipFillRectanglesI (nativeObject, brush.nativeObject, rects, rects.Length);
1638 GDIPlus.CheckStatus (status);
1641 public void FillRectangles (Brush brush, RectangleF [] rects)
1644 throw new ArgumentNullException ("brush");
1646 throw new ArgumentNullException ("rects");
1648 Status status = GDIPlus.GdipFillRectangles (nativeObject, brush.nativeObject, rects, rects.Length);
1649 GDIPlus.CheckStatus (status);
1653 public void FillRegion (Brush brush, Region region)
1656 throw new ArgumentNullException ("brush");
1658 throw new ArgumentNullException ("region");
1660 Status status = GDIPlus.GdipFillRegion (nativeObject, brush.NativeObject, region.NativeObject);
1661 GDIPlus.CheckStatus(status);
1665 public void Flush ()
1667 Flush (FlushIntention.Flush);
1671 public void Flush (FlushIntention intention)
1673 if (nativeObject == IntPtr.Zero) {
1677 Status status = GDIPlus.GdipFlush (nativeObject, intention);
1678 GDIPlus.CheckStatus (status);
1679 if (GDIPlus.UseQuartzDrawable || GDIPlus.UseCocoaDrawable)
1680 Carbon.CGContextSynchronize (GDIPlus.Display);
1683 [EditorBrowsable (EditorBrowsableState.Advanced)]
1684 public static Graphics FromHdc (IntPtr hdc)
1687 Status status = GDIPlus.GdipCreateFromHDC (hdc, out graphics);
1688 GDIPlus.CheckStatus (status);
1689 return new Graphics (graphics);
1693 [EditorBrowsable (EditorBrowsableState.Advanced)]
1694 public static Graphics FromHdc (IntPtr hdc, IntPtr hdevice)
1696 throw new NotImplementedException ();
1699 [EditorBrowsable (EditorBrowsableState.Advanced)]
1700 [SecurityPermission (SecurityAction.LinkDemand, UnmanagedCode = true)]
1701 public static Graphics FromHdcInternal (IntPtr hdc)
1703 GDIPlus.Display = hdc;
1707 [EditorBrowsable (EditorBrowsableState.Advanced)]
1708 public static Graphics FromHwnd (IntPtr hwnd)
1712 if (GDIPlus.UseCocoaDrawable) {
1713 CarbonContext cgContext = Carbon.GetCGContextForNSView (hwnd);
1714 GDIPlus.GdipCreateFromQuartz_macosx (cgContext.ctx, cgContext.width, cgContext.height, out graphics);
1716 GDIPlus.Display = cgContext.ctx;
1717 return new Graphics (graphics);
1719 if (GDIPlus.UseQuartzDrawable) {
1720 CarbonContext cgContext = Carbon.GetCGContextForView (hwnd);
1721 GDIPlus.GdipCreateFromQuartz_macosx (cgContext.ctx, cgContext.width, cgContext.height, out graphics);
1723 GDIPlus.Display = cgContext.ctx;
1724 return new Graphics (graphics);
1726 if (GDIPlus.UseX11Drawable) {
1727 if (GDIPlus.Display == IntPtr.Zero) {
1728 GDIPlus.Display = GDIPlus.XOpenDisplay (IntPtr.Zero);
1731 return FromXDrawable (hwnd, GDIPlus.Display);
1735 Status status = GDIPlus.GdipCreateFromHWND (hwnd, out graphics);
1736 GDIPlus.CheckStatus (status);
1738 return new Graphics (graphics);
1741 [EditorBrowsable (EditorBrowsableState.Advanced)]
1742 [SecurityPermission (SecurityAction.LinkDemand, UnmanagedCode = true)]
1743 public static Graphics FromHwndInternal (IntPtr hwnd)
1745 return FromHwnd (hwnd);
1748 public static Graphics FromImage (Image image)
1753 throw new ArgumentNullException ("image");
1755 if ((image.PixelFormat & PixelFormat.Indexed) != 0)
1756 throw new Exception (Locale.GetText ("Cannot create Graphics from an indexed bitmap."));
1758 Status status = GDIPlus.GdipGetImageGraphicsContext (image.nativeObject, out graphics);
1759 GDIPlus.CheckStatus (status);
1760 Graphics result = new Graphics (graphics);
1762 if (GDIPlus.RunningOnUnix ()) {
1763 Rectangle rect = new Rectangle (0,0, image.Width, image.Height);
1764 GDIPlus.GdipSetVisibleClip_linux (result.NativeObject, ref rect);
1770 internal static Graphics FromXDrawable (IntPtr drawable, IntPtr display)
1774 Status s = GDIPlus.GdipCreateFromXDrawable_linux (drawable, display, out graphics);
1775 GDIPlus.CheckStatus (s);
1776 return new Graphics (graphics);
1780 public static IntPtr GetHalftonePalette ()
1782 throw new NotImplementedException ();
1786 [EditorBrowsable (EditorBrowsableState.Advanced)]
1788 public IntPtr GetHdc ()
1791 GDIPlus.CheckStatus (GDIPlus.GdipGetDC (this.nativeObject, out hdc));
1793 deviceContextHdc = hdc;
1799 public Color GetNearestColor (Color color)
1803 Status status = GDIPlus.GdipGetNearestColor (nativeObject, out argb);
1804 GDIPlus.CheckStatus (status);
1806 return Color.FromArgb (argb);
1810 public void IntersectClip (Region region)
1813 throw new ArgumentNullException ("region");
1814 Status status = GDIPlus.GdipSetClipRegion (nativeObject, region.NativeObject, CombineMode.Intersect);
1815 GDIPlus.CheckStatus (status);
1818 public void IntersectClip (RectangleF rect)
1820 Status status = GDIPlus.GdipSetClipRect (nativeObject, rect.X, rect.Y, rect.Width, rect.Height, CombineMode.Intersect);
1821 GDIPlus.CheckStatus (status);
1824 public void IntersectClip (Rectangle rect)
1826 Status status = GDIPlus.GdipSetClipRectI (nativeObject, rect.X, rect.Y, rect.Width, rect.Height, CombineMode.Intersect);
1827 GDIPlus.CheckStatus (status);
1830 public bool IsVisible (Point point)
1832 bool isVisible = false;
1834 Status status = GDIPlus.GdipIsVisiblePointI (nativeObject, point.X, point.Y, out isVisible);
1835 GDIPlus.CheckStatus (status);
1841 public bool IsVisible (RectangleF rect)
1843 bool isVisible = false;
1845 Status status = GDIPlus.GdipIsVisibleRect (nativeObject, rect.X, rect.Y, rect.Width, rect.Height, out isVisible);
1846 GDIPlus.CheckStatus (status);
1851 public bool IsVisible (PointF point)
1853 bool isVisible = false;
1855 Status status = GDIPlus.GdipIsVisiblePoint (nativeObject, point.X, point.Y, out isVisible);
1856 GDIPlus.CheckStatus (status);
1861 public bool IsVisible (Rectangle rect)
1863 bool isVisible = false;
1865 Status status = GDIPlus.GdipIsVisibleRectI (nativeObject, rect.X, rect.Y, rect.Width, rect.Height, out isVisible);
1866 GDIPlus.CheckStatus (status);
1871 public bool IsVisible (float x, float y)
1873 return IsVisible (new PointF (x, y));
1876 public bool IsVisible (int x, int y)
1878 return IsVisible (new Point (x, y));
1881 public bool IsVisible (float x, float y, float width, float height)
1883 return IsVisible (new RectangleF (x, y, width, height));
1887 public bool IsVisible (int x, int y, int width, int height)
1889 return IsVisible (new Rectangle (x, y, width, height));
1893 public Region[] MeasureCharacterRanges (string text, Font font, RectangleF layoutRect, StringFormat stringFormat)
1895 if ((text == null) || (text.Length == 0))
1896 return new Region [0];
1899 throw new ArgumentNullException ("font");
1901 if (stringFormat == null)
1902 throw new ArgumentException ("stringFormat");
1904 int regcount = stringFormat.GetMeasurableCharacterRangeCount ();
1906 return new Region[0];
1908 IntPtr[] native_regions = new IntPtr [regcount];
1909 Region[] regions = new Region [regcount];
1911 for (int i = 0; i < regcount; i++) {
1912 regions[i] = new Region ();
1913 native_regions[i] = regions[i].NativeObject;
1916 Status status = GDIPlus.GdipMeasureCharacterRanges (nativeObject, text, text.Length,
1917 font.NativeObject, ref layoutRect, stringFormat.NativeObject, regcount, out native_regions[0]);
1918 GDIPlus.CheckStatus (status);
1924 public SizeF MeasureString (string text, Font font)
1926 return MeasureString (text, font, SizeF.Empty);
1930 public SizeF MeasureString (string text, Font font, SizeF layoutArea)
1932 if (text == null || text.Length == 0)
1936 throw new ArgumentNullException ("font");
1938 int charactersFitted, linesFilled;
1939 RectangleF boundingBox = new RectangleF ();
1940 RectangleF rect = new RectangleF (0, 0, layoutArea.Width, layoutArea.Height);
1942 Status status = GDIPlus.GdipMeasureString (nativeObject, text, text.Length,
1943 font.NativeObject, ref rect,
1944 IntPtr.Zero, out boundingBox,
1945 out charactersFitted, out linesFilled);
1946 GDIPlus.CheckStatus (status);
1948 return new SizeF (boundingBox.Width, boundingBox.Height);
1952 public SizeF MeasureString (string text, Font font, int width)
1954 if (text == null || text.Length == 0)
1958 throw new ArgumentNullException ("font");
1960 RectangleF boundingBox = new RectangleF ();
1961 RectangleF rect = new RectangleF (0, 0, width, Int32.MaxValue);
1962 int charactersFitted, linesFilled;
1964 Status status = GDIPlus.GdipMeasureString (nativeObject, text, text.Length,
1965 font.NativeObject, ref rect,
1966 IntPtr.Zero, out boundingBox,
1967 out charactersFitted, out linesFilled);
1968 GDIPlus.CheckStatus (status);
1970 return new SizeF (boundingBox.Width, boundingBox.Height);
1974 public SizeF MeasureString (string text, Font font, SizeF layoutArea,
1975 StringFormat stringFormat)
1977 int charactersFitted, linesFilled;
1978 return MeasureString (text, font, layoutArea, stringFormat,
1979 out charactersFitted, out linesFilled);
1983 public SizeF MeasureString (string text, Font font, int width, StringFormat format)
1985 int charactersFitted, linesFilled;
1986 return MeasureString (text, font, new SizeF (width, Int32.MaxValue),
1987 format, out charactersFitted, out linesFilled);
1991 public SizeF MeasureString (string text, Font font, PointF origin,
1992 StringFormat stringFormat)
1994 if (text == null || text.Length == 0)
1998 throw new ArgumentNullException ("font");
2000 RectangleF boundingBox = new RectangleF ();
2001 RectangleF rect = new RectangleF (origin.X, origin.Y, 0, 0);
2002 int charactersFitted, linesFilled;
2004 IntPtr format = (stringFormat == null) ? IntPtr.Zero : stringFormat.NativeObject;
2006 Status status = GDIPlus.GdipMeasureString (nativeObject, text, text.Length,
2007 font.NativeObject, ref rect, format,
2009 out charactersFitted,
2011 GDIPlus.CheckStatus (status);
2013 return new SizeF (boundingBox.Width, boundingBox.Height);
2017 public SizeF MeasureString (string text, Font font, SizeF layoutArea,
2018 StringFormat stringFormat, out int charactersFitted,
2019 out int linesFilled)
2021 charactersFitted = 0;
2024 if (text == null || text.Length == 0)
2028 throw new ArgumentNullException ("font");
2030 RectangleF boundingBox = new RectangleF ();
2031 RectangleF rect = new RectangleF (0, 0, layoutArea.Width, layoutArea.Height);
2033 IntPtr format = (stringFormat == null) ? IntPtr.Zero : stringFormat.NativeObject;
2035 Status status = GDIPlus.GdipMeasureString (nativeObject, text, text.Length,
2036 font.NativeObject, ref rect, format,
2038 out charactersFitted,
2040 GDIPlus.CheckStatus (status);
2042 return new SizeF (boundingBox.Width, boundingBox.Height);
2045 public void MultiplyTransform (Matrix matrix)
2047 MultiplyTransform (matrix, MatrixOrder.Prepend);
2050 public void MultiplyTransform (Matrix matrix, MatrixOrder order)
2052 Status status = GDIPlus.GdipMultiplyWorldTransform (nativeObject,
2053 matrix.nativeMatrix,
2055 GDIPlus.CheckStatus (status);
2058 [EditorBrowsable (EditorBrowsableState.Advanced)]
2059 public void ReleaseHdc (IntPtr hdc)
2061 Status status = GDIPlus.GdipReleaseDC (nativeObject, hdc);
2062 GDIPlus.CheckStatus (status);
2064 if (hdc == deviceContextHdc)
2065 deviceContextHdc = IntPtr.Zero;
2070 public void ReleaseHdc ()
2072 if (deviceContextHdc == IntPtr.Zero)
2073 throw new ArgumentException ("Invalid Handle");
2075 ReleaseHdc (deviceContextHdc);
2079 [MonoTODO ("Parameter hdc doesn't map well into libgdiplus")]
2081 [EditorBrowsable (EditorBrowsableState.Never)]
2083 [EditorBrowsable (EditorBrowsableState.Advanced)]
2085 [SecurityPermission (SecurityAction.LinkDemand, UnmanagedCode = true)]
2086 public void ReleaseHdcInternal (IntPtr hdc)
2088 throw new NotImplementedException ();
2092 public void ResetClip ()
2094 Status status = GDIPlus.GdipResetClip (nativeObject);
2095 GDIPlus.CheckStatus (status);
2098 public void ResetTransform ()
2100 Status status = GDIPlus.GdipResetWorldTransform (nativeObject);
2101 GDIPlus.CheckStatus (status);
2104 public void Restore (GraphicsState gstate)
2106 Status status = GDIPlus.GdipRestoreGraphics (nativeObject, gstate.nativeState);
2107 GDIPlus.CheckStatus (status);
2111 public void RotateTransform (float angle)
2113 RotateTransform (angle, MatrixOrder.Prepend);
2116 public void RotateTransform (float angle, MatrixOrder order)
2119 Status status = GDIPlus.GdipRotateWorldTransform (nativeObject, angle, order);
2120 GDIPlus.CheckStatus (status);
2123 public GraphicsState Save ()
2126 Status status = GDIPlus.GdipSaveGraphics (nativeObject, out saveState);
2127 GDIPlus.CheckStatus (status);
2129 GraphicsState state = new GraphicsState ();
2130 state.nativeState = saveState;
2134 public void ScaleTransform (float sx, float sy)
2136 ScaleTransform (sx, sy, MatrixOrder.Prepend);
2139 public void ScaleTransform (float sx, float sy, MatrixOrder order)
2141 Status status = GDIPlus.GdipScaleWorldTransform (nativeObject, sx, sy, order);
2142 GDIPlus.CheckStatus (status);
2146 public void SetClip (RectangleF rect)
2148 SetClip (rect, CombineMode.Replace);
2152 public void SetClip (GraphicsPath path)
2154 SetClip (path, CombineMode.Replace);
2158 public void SetClip (Rectangle rect)
2160 SetClip (rect, CombineMode.Replace);
2164 public void SetClip (Graphics g)
2166 SetClip (g, CombineMode.Replace);
2170 public void SetClip (Graphics g, CombineMode combineMode)
2173 throw new ArgumentNullException ("g");
2175 Status status = GDIPlus.GdipSetClipGraphics (nativeObject, g.NativeObject, combineMode);
2176 GDIPlus.CheckStatus (status);
2180 public void SetClip (Rectangle rect, CombineMode combineMode)
2182 Status status = GDIPlus.GdipSetClipRectI (nativeObject, rect.X, rect.Y, rect.Width, rect.Height, combineMode);
2183 GDIPlus.CheckStatus (status);
2187 public void SetClip (RectangleF rect, CombineMode combineMode)
2189 Status status = GDIPlus.GdipSetClipRect (nativeObject, rect.X, rect.Y, rect.Width, rect.Height, combineMode);
2190 GDIPlus.CheckStatus (status);
2194 public void SetClip (Region region, CombineMode combineMode)
2197 throw new ArgumentNullException ("region");
2198 Status status = GDIPlus.GdipSetClipRegion(nativeObject, region.NativeObject, combineMode);
2199 GDIPlus.CheckStatus (status);
2203 public void SetClip (GraphicsPath path, CombineMode combineMode)
2206 throw new ArgumentNullException ("path");
2207 Status status = GDIPlus.GdipSetClipPath (nativeObject, path.NativeObject, combineMode);
2208 GDIPlus.CheckStatus (status);
2212 public void TransformPoints (CoordinateSpace destSpace, CoordinateSpace srcSpace, PointF [] pts)
2215 throw new ArgumentNullException ("pts");
2217 IntPtr ptrPt = GDIPlus.FromPointToUnManagedMemory (pts);
2219 Status status = GDIPlus.GdipTransformPoints (nativeObject, destSpace, srcSpace, ptrPt, pts.Length);
2220 GDIPlus.CheckStatus (status);
2222 GDIPlus.FromUnManagedMemoryToPoint (ptrPt, pts);
2226 public void TransformPoints (CoordinateSpace destSpace, CoordinateSpace srcSpace, Point [] pts)
2229 throw new ArgumentNullException ("pts");
2230 IntPtr ptrPt = GDIPlus.FromPointToUnManagedMemoryI (pts);
2232 Status status = GDIPlus.GdipTransformPointsI (nativeObject, destSpace, srcSpace, ptrPt, pts.Length);
2233 GDIPlus.CheckStatus (status);
2235 GDIPlus.FromUnManagedMemoryToPointI (ptrPt, pts);
2239 public void TranslateClip (int dx, int dy)
2241 Status status = GDIPlus.GdipTranslateClipI (nativeObject, dx, dy);
2242 GDIPlus.CheckStatus (status);
2246 public void TranslateClip (float dx, float dy)
2248 Status status = GDIPlus.GdipTranslateClip (nativeObject, dx, dy);
2249 GDIPlus.CheckStatus (status);
2252 public void TranslateTransform (float dx, float dy)
2254 TranslateTransform (dx, dy, MatrixOrder.Prepend);
2258 public void TranslateTransform (float dx, float dy, MatrixOrder order)
2260 Status status = GDIPlus.GdipTranslateWorldTransform (nativeObject, dx, dy, order);
2261 GDIPlus.CheckStatus (status);
2264 public Region Clip {
2266 Region reg = new Region();
2267 Status status = GDIPlus.GdipGetClip (nativeObject, reg.NativeObject);
2268 GDIPlus.CheckStatus (status);
2272 SetClip (value, CombineMode.Replace);
2276 public RectangleF ClipBounds {
2278 RectangleF rect = new RectangleF ();
2279 Status status = GDIPlus.GdipGetClipBounds (nativeObject, out rect);
2280 GDIPlus.CheckStatus (status);
2285 public CompositingMode CompositingMode {
2287 CompositingMode mode;
2288 Status status = GDIPlus.GdipGetCompositingMode (nativeObject, out mode);
2289 GDIPlus.CheckStatus (status);
2294 Status status = GDIPlus.GdipSetCompositingMode (nativeObject, value);
2295 GDIPlus.CheckStatus (status);
2300 public CompositingQuality CompositingQuality {
2302 CompositingQuality quality;
2304 Status status = GDIPlus.GdipGetCompositingQuality (nativeObject, out quality);
2305 GDIPlus.CheckStatus (status);
2309 Status status = GDIPlus.GdipSetCompositingQuality (nativeObject, value);
2310 GDIPlus.CheckStatus (status);
2318 Status status = GDIPlus.GdipGetDpiX (nativeObject, out x);
2319 GDIPlus.CheckStatus (status);
2328 Status status = GDIPlus.GdipGetDpiY (nativeObject, out y);
2329 GDIPlus.CheckStatus (status);
2334 public InterpolationMode InterpolationMode {
2336 InterpolationMode imode = InterpolationMode.Invalid;
2337 Status status = GDIPlus.GdipGetInterpolationMode (nativeObject, out imode);
2338 GDIPlus.CheckStatus (status);
2342 Status status = GDIPlus.GdipSetInterpolationMode (nativeObject, value);
2343 GDIPlus.CheckStatus (status);
2347 public bool IsClipEmpty {
2349 bool isEmpty = false;
2351 Status status = GDIPlus.GdipIsClipEmpty (nativeObject, out isEmpty);
2352 GDIPlus.CheckStatus (status);
2357 public bool IsVisibleClipEmpty {
2359 bool isEmpty = false;
2361 Status status = GDIPlus.GdipIsVisibleClipEmpty (nativeObject, out isEmpty);
2362 GDIPlus.CheckStatus (status);
2367 public float PageScale {
2371 Status status = GDIPlus.GdipGetPageScale (nativeObject, out scale);
2372 GDIPlus.CheckStatus (status);
2376 Status status = GDIPlus.GdipSetPageScale (nativeObject, value);
2377 GDIPlus.CheckStatus (status);
2381 public GraphicsUnit PageUnit {
2385 Status status = GDIPlus.GdipGetPageUnit (nativeObject, out unit);
2386 GDIPlus.CheckStatus (status);
2390 Status status = GDIPlus.GdipSetPageUnit (nativeObject, value);
2391 GDIPlus.CheckStatus (status);
2395 [MonoTODO ("This property does not do anything when used with libgdiplus.")]
2396 public PixelOffsetMode PixelOffsetMode {
2398 PixelOffsetMode pixelOffset = PixelOffsetMode.Invalid;
2400 Status status = GDIPlus.GdipGetPixelOffsetMode (nativeObject, out pixelOffset);
2401 GDIPlus.CheckStatus (status);
2405 Status status = GDIPlus.GdipSetPixelOffsetMode (nativeObject, value);
2406 GDIPlus.CheckStatus (status);
2410 public Point RenderingOrigin {
2413 Status status = GDIPlus.GdipGetRenderingOrigin (nativeObject, out x, out y);
2414 GDIPlus.CheckStatus (status);
2415 return new Point (x, y);
2419 Status status = GDIPlus.GdipSetRenderingOrigin (nativeObject, value.X, value.Y);
2420 GDIPlus.CheckStatus (status);
2424 public SmoothingMode SmoothingMode {
2426 SmoothingMode mode = SmoothingMode.Invalid;
2428 Status status = GDIPlus.GdipGetSmoothingMode (nativeObject, out mode);
2429 GDIPlus.CheckStatus (status);
2434 Status status = GDIPlus.GdipSetSmoothingMode (nativeObject, value);
2435 GDIPlus.CheckStatus (status);
2439 [MonoTODO ("This property does not do anything when used with libgdiplus.")]
2440 public int TextContrast {
2444 Status status = GDIPlus.GdipGetTextContrast (nativeObject, out contrast);
2445 GDIPlus.CheckStatus (status);
2450 Status status = GDIPlus.GdipSetTextContrast (nativeObject, value);
2451 GDIPlus.CheckStatus (status);
2455 public TextRenderingHint TextRenderingHint {
2457 TextRenderingHint hint;
2459 Status status = GDIPlus.GdipGetTextRenderingHint (nativeObject, out hint);
2460 GDIPlus.CheckStatus (status);
2465 Status status = GDIPlus.GdipSetTextRenderingHint (nativeObject, value);
2466 GDIPlus.CheckStatus (status);
2470 public Matrix Transform {
2472 Matrix matrix = new Matrix ();
2473 Status status = GDIPlus.GdipGetWorldTransform (nativeObject, matrix.nativeMatrix);
2474 GDIPlus.CheckStatus (status);
2479 throw new ArgumentNullException ("value");
2481 Status status = GDIPlus.GdipSetWorldTransform (nativeObject, value.nativeMatrix);
2482 GDIPlus.CheckStatus (status);
2486 public RectangleF VisibleClipBounds {
2490 Status status = GDIPlus.GdipGetVisibleClipBounds (nativeObject, out rect);
2491 GDIPlus.CheckStatus (status);
2498 [EditorBrowsable (EditorBrowsableState.Never)]
2499 public object GetContextInfo ()
2501 throw new NotImplementedException ();