2 // System.Drawing.Graphics.cs
5 // Gonzalo Paniagua Javier (gonzalo@ximian.com) (stubbed out)
6 // Alexandre Pigolkine(pigolkine@gmx.de)
7 // Jordi Mas i Hernandez (jordi@ximian.com)
8 // Sebastien Pouliot <sebastien@ximian.com>
10 // Copyright (C) 2003 Ximian, Inc. (http://www.ximian.com)
11 // Copyright (C) 2004-2006 Novell, Inc. (http://www.novell.com)
13 // Permission is hereby granted, free of charge, to any person obtaining
14 // a copy of this software and associated documentation files (the
15 // "Software"), to deal in the Software without restriction, including
16 // without limitation the rights to use, copy, modify, merge, publish,
17 // distribute, sublicense, and/or sell copies of the Software, and to
18 // permit persons to whom the Software is furnished to do so, subject to
19 // the following conditions:
21 // The above copyright notice and this permission notice shall be
22 // included in all copies or substantial portions of the Software.
24 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
25 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
26 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
27 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
28 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
29 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
30 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
33 using System.Drawing.Drawing2D;
34 using System.Drawing.Imaging;
35 using System.Drawing.Text;
36 using System.ComponentModel;
37 using System.Runtime.InteropServices;
38 using System.Security.Permissions;
41 namespace System.Drawing
46 public sealed class Graphics : MarshalByRefObject, IDisposable
51 internal IntPtr nativeObject = IntPtr.Zero;
52 internal IMacContext maccontext;
53 private bool disposed = false;
54 private static float defDpiX = 0;
55 private static float defDpiY = 0;
56 private IntPtr deviceContextHdc;
61 public delegate bool EnumerateMetafileProc (EmfPlusRecordType recordType,
65 PlayRecordCallback callbackData);
70 public delegate bool DrawImageAbort (IntPtr callbackData);
72 internal Graphics (IntPtr nativeGraphics)
74 nativeObject = nativeGraphics;
82 static internal float systemDpiX {
85 Bitmap bmp = new Bitmap (1, 1);
86 Graphics g = Graphics.FromImage (bmp);
94 static internal float systemDpiY {
97 Bitmap bmp = new Bitmap (1, 1);
98 Graphics g = Graphics.FromImage (bmp);
106 internal IntPtr NativeObject {
112 nativeObject = value;
116 [MonoTODO ("Metafiles, both WMF and EMF formats, aren't supported.")]
117 public void AddMetafileComment (byte [] data)
119 throw new NotImplementedException ();
122 public GraphicsContainer BeginContainer ()
126 status = GDIPlus.GdipBeginContainer2 (nativeObject, out state);
127 GDIPlus.CheckStatus (status);
129 return new GraphicsContainer(state);
132 [MonoTODO ("The rectangles and unit parameters aren't supported in libgdiplus")]
133 public GraphicsContainer BeginContainer (Rectangle dstrect, Rectangle srcrect, GraphicsUnit unit)
137 status = GDIPlus.GdipBeginContainerI (nativeObject, ref dstrect, ref srcrect, unit, out state);
138 GDIPlus.CheckStatus (status);
140 return new GraphicsContainer (state);
143 [MonoTODO ("The rectangles and unit parameters aren't supported in libgdiplus")]
144 public GraphicsContainer BeginContainer (RectangleF dstrect, RectangleF srcrect, GraphicsUnit unit)
148 status = GDIPlus.GdipBeginContainer (nativeObject, ref dstrect, ref srcrect, unit, out state);
149 GDIPlus.CheckStatus (status);
151 return new GraphicsContainer (state);
155 public void Clear (Color color)
158 status = GDIPlus.GdipGraphicsClear (nativeObject, color.ToArgb ());
159 GDIPlus.CheckStatus (status);
162 [MonoLimitation ("Works on Win32 and on X11 (but not on Cocoa and Quartz)")]
163 public void CopyFromScreen (Point upperLeftSource, Point upperLeftDestination, Size blockRegionSize)
165 CopyFromScreen (upperLeftSource.X, upperLeftSource.Y, upperLeftDestination.X, upperLeftDestination.Y,
166 blockRegionSize, CopyPixelOperation.SourceCopy);
169 [MonoLimitation ("Works on Win32 and (for CopyPixelOperation.SourceCopy only) on X11 but not on Cocoa and Quartz")]
170 public void CopyFromScreen (Point upperLeftSource, Point upperLeftDestination, Size blockRegionSize, CopyPixelOperation copyPixelOperation)
172 CopyFromScreen (upperLeftSource.X, upperLeftSource.Y, upperLeftDestination.X, upperLeftDestination.Y,
173 blockRegionSize, copyPixelOperation);
176 [MonoLimitation ("Works on Win32 and on X11 (but not on Cocoa and Quartz)")]
177 public void CopyFromScreen (int sourceX, int sourceY, int destinationX, int destinationY, Size blockRegionSize)
179 CopyFromScreen (sourceX, sourceY, destinationX, destinationY, blockRegionSize,
180 CopyPixelOperation.SourceCopy);
183 [MonoLimitation ("Works on Win32 and (for CopyPixelOperation.SourceCopy only) on X11 but not on Cocoa and Quartz")]
184 public void CopyFromScreen (int sourceX, int sourceY, int destinationX, int destinationY, Size blockRegionSize, CopyPixelOperation copyPixelOperation)
186 if (!Enum.IsDefined (typeof (CopyPixelOperation), copyPixelOperation))
187 throw new InvalidEnumArgumentException (Locale.GetText ("Enum argument value '{0}' is not valid for CopyPixelOperation", copyPixelOperation));
189 if (GDIPlus.UseX11Drawable) {
190 CopyFromScreenX11 (sourceX, sourceY, destinationX, destinationY, blockRegionSize, copyPixelOperation);
191 } else if (GDIPlus.UseCarbonDrawable) {
192 CopyFromScreenMac (sourceX, sourceY, destinationX, destinationY, blockRegionSize, copyPixelOperation);
193 } else if (GDIPlus.UseCocoaDrawable) {
194 CopyFromScreenMac (sourceX, sourceY, destinationX, destinationY, blockRegionSize, copyPixelOperation);
196 CopyFromScreenWin32 (sourceX, sourceY, destinationX, destinationY, blockRegionSize, copyPixelOperation);
200 private void CopyFromScreenWin32 (int sourceX, int sourceY, int destinationX, int destinationY, Size blockRegionSize, CopyPixelOperation copyPixelOperation)
202 IntPtr window = GDIPlus.GetDesktopWindow ();
203 IntPtr srcDC = GDIPlus.GetDC (window);
204 IntPtr dstDC = GetHdc ();
205 GDIPlus.BitBlt (dstDC, destinationX, destinationY, blockRegionSize.Width,
206 blockRegionSize.Height, srcDC, sourceX, sourceY, (int) copyPixelOperation);
208 GDIPlus.ReleaseDC (IntPtr.Zero, srcDC);
212 private void CopyFromScreenMac (int sourceX, int sourceY, int destinationX, int destinationY, Size blockRegionSize, CopyPixelOperation copyPixelOperation)
214 throw new NotImplementedException ();
217 private void CopyFromScreenX11 (int sourceX, int sourceY, int destinationX, int destinationY, Size blockRegionSize, CopyPixelOperation copyPixelOperation)
219 IntPtr window, image, defvisual, vPtr;
220 int AllPlanes = ~0, nitems = 0, pixel;
222 if (copyPixelOperation != CopyPixelOperation.SourceCopy)
223 throw new NotImplementedException ("Operation not implemented under X11");
225 if (GDIPlus.Display == IntPtr.Zero) {
226 GDIPlus.Display = GDIPlus.XOpenDisplay (IntPtr.Zero);
229 window = GDIPlus.XRootWindow (GDIPlus.Display, 0);
230 defvisual = GDIPlus.XDefaultVisual (GDIPlus.Display, 0);
231 XVisualInfo visual = new XVisualInfo ();
233 /* Get XVisualInfo for this visual */
234 visual.visualid = GDIPlus.XVisualIDFromVisual(defvisual);
235 vPtr = GDIPlus.XGetVisualInfo (GDIPlus.Display, 0x1 /* VisualIDMask */, ref visual, ref nitems);
236 visual = (XVisualInfo) Marshal.PtrToStructure(vPtr, typeof (XVisualInfo));
238 Console.WriteLine ("visual\t{0}", visual.visual);
239 Console.WriteLine ("visualid\t{0}", visual.visualid);
240 Console.WriteLine ("screen\t{0}", visual.screen);
241 Console.WriteLine ("depth\t{0}", visual.depth);
242 Console.WriteLine ("klass\t{0}", visual.klass);
243 Console.WriteLine ("red_mask\t{0:X}", visual.red_mask);
244 Console.WriteLine ("green_mask\t{0:X}", visual.green_mask);
245 Console.WriteLine ("blue_mask\t{0:X}", visual.blue_mask);
246 Console.WriteLine ("colormap_size\t{0}", visual.colormap_size);
247 Console.WriteLine ("bits_per_rgb\t{0}", visual.bits_per_rgb);
249 image = GDIPlus.XGetImage (GDIPlus.Display, window, sourceX, sourceY, blockRegionSize.Width,
250 blockRegionSize.Height, AllPlanes, 2 /* ZPixmap*/);
251 if (image == IntPtr.Zero) {
252 string s = String.Format ("XGetImage returned NULL when asked to for a {0}x{1} region block",
253 blockRegionSize.Width, blockRegionSize.Height);
254 throw new InvalidOperationException (s);
257 Bitmap bmp = new Bitmap (blockRegionSize.Width, blockRegionSize.Height);
258 int red, blue, green;
259 int red_mask = (int) visual.red_mask;
260 int blue_mask = (int) visual.blue_mask;
261 int green_mask = (int) visual.green_mask;
262 for (int y = 0; y < blockRegionSize.Height; y++) {
263 for (int x = 0; x < blockRegionSize.Width; x++) {
264 pixel = GDIPlus.XGetPixel (image, x, y);
266 switch (visual.depth) {
267 case 16: /* 16bbp pixel transformation */
268 red = (int) ((pixel & red_mask ) >> 8) & 0xff;
269 green = (int) (((pixel & green_mask ) >> 3 )) & 0xff;
270 blue = (int) ((pixel & blue_mask ) << 3 ) & 0xff;
274 red = (int) ((pixel & red_mask ) >> 16) & 0xff;
275 green = (int) (((pixel & green_mask ) >> 8 )) & 0xff;
276 blue = (int) ((pixel & blue_mask )) & 0xff;
279 string text = Locale.GetText ("{0}bbp depth not supported.", visual.depth);
280 throw new NotImplementedException (text);
283 bmp.SetPixel (x, y, Color.FromArgb (255, red, green, blue));
287 DrawImage (bmp, destinationX, destinationY);
289 GDIPlus.XDestroyImage (image);
290 GDIPlus.XFree (vPtr);
294 public void Dispose ()
298 if (GDIPlus.UseCarbonDrawable || GDIPlus.UseCocoaDrawable) {
300 if (maccontext != null)
301 maccontext.Release ();
304 status = GDIPlus.GdipDeleteGraphics (nativeObject);
305 nativeObject = IntPtr.Zero;
306 GDIPlus.CheckStatus (status);
310 GC.SuppressFinalize(this);
314 public void DrawArc (Pen pen, Rectangle rect, float startAngle, float sweepAngle)
316 DrawArc (pen, rect.X, rect.Y, rect.Width, rect.Height, startAngle, sweepAngle);
320 public void DrawArc (Pen pen, RectangleF rect, float startAngle, float sweepAngle)
322 DrawArc (pen, rect.X, rect.Y, rect.Width, rect.Height, startAngle, sweepAngle);
326 public void DrawArc (Pen pen, float x, float y, float width, float height, float startAngle, float sweepAngle)
330 throw new ArgumentNullException ("pen");
332 status = GDIPlus.GdipDrawArc (nativeObject, pen.nativeObject,
333 x, y, width, height, startAngle, sweepAngle);
334 GDIPlus.CheckStatus (status);
337 // Microsoft documentation states that the signature for this member should be
338 // public void DrawArc( Pen pen, int x, int y, int width, int height, int startAngle,
339 // int sweepAngle. However, GdipDrawArcI uses also float for the startAngle and sweepAngle params
340 public void DrawArc (Pen pen, int x, int y, int width, int height, int startAngle, int sweepAngle)
344 throw new ArgumentNullException ("pen");
345 status = GDIPlus.GdipDrawArcI (nativeObject, pen.nativeObject,
346 x, y, width, height, startAngle, sweepAngle);
347 GDIPlus.CheckStatus (status);
350 public void DrawBezier (Pen pen, PointF pt1, PointF pt2, PointF pt3, PointF pt4)
354 throw new ArgumentNullException ("pen");
355 status = GDIPlus.GdipDrawBezier (nativeObject, pen.nativeObject,
356 pt1.X, pt1.Y, pt2.X, pt2.Y, pt3.X,
357 pt3.Y, pt4.X, pt4.Y);
358 GDIPlus.CheckStatus (status);
361 public void DrawBezier (Pen pen, Point pt1, Point pt2, Point pt3, Point pt4)
365 throw new ArgumentNullException ("pen");
366 status = GDIPlus.GdipDrawBezierI (nativeObject, pen.nativeObject,
367 pt1.X, pt1.Y, pt2.X, pt2.Y, pt3.X,
368 pt3.Y, pt4.X, pt4.Y);
369 GDIPlus.CheckStatus (status);
372 public void DrawBezier (Pen pen, float x1, float y1, float x2, float y2, float x3, float y3, float x4, float y4)
376 throw new ArgumentNullException ("pen");
377 status = GDIPlus.GdipDrawBezier (nativeObject, pen.nativeObject, x1,
378 y1, x2, y2, x3, y3, x4, y4);
379 GDIPlus.CheckStatus (status);
382 public void DrawBeziers (Pen pen, Point [] 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 Point p1 = points [i];
397 Point p2 = points [i + 1];
398 Point p3 = points [i + 2];
399 Point 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);
409 public void DrawBeziers (Pen pen, PointF [] points)
412 throw new ArgumentNullException ("pen");
414 throw new ArgumentNullException ("points");
416 int length = points.Length;
422 for (int i = 0; i < length - 1; i += 3) {
423 PointF p1 = points [i];
424 PointF p2 = points [i + 1];
425 PointF p3 = points [i + 2];
426 PointF p4 = points [i + 3];
428 status = GDIPlus.GdipDrawBezier (nativeObject,
430 p1.X, p1.Y, p2.X, p2.Y,
431 p3.X, p3.Y, p4.X, p4.Y);
432 GDIPlus.CheckStatus (status);
437 public void DrawClosedCurve (Pen pen, PointF [] points)
440 throw new ArgumentNullException ("pen");
442 throw new ArgumentNullException ("points");
445 status = GDIPlus.GdipDrawClosedCurve (nativeObject, pen.nativeObject, points, points.Length);
446 GDIPlus.CheckStatus (status);
449 public void DrawClosedCurve (Pen pen, Point [] points)
452 throw new ArgumentNullException ("pen");
454 throw new ArgumentNullException ("points");
457 status = GDIPlus.GdipDrawClosedCurveI (nativeObject, pen.nativeObject, points, points.Length);
458 GDIPlus.CheckStatus (status);
461 // according to MSDN fillmode "is required but ignored" which makes _some_ sense since the unmanaged
462 // GDI+ call doesn't support it (issue spotted using Gendarme's AvoidUnusedParametersRule)
463 public void DrawClosedCurve (Pen pen, Point [] points, float tension, FillMode fillmode)
466 throw new ArgumentNullException ("pen");
468 throw new ArgumentNullException ("points");
471 status = GDIPlus.GdipDrawClosedCurve2I (nativeObject, pen.nativeObject, points, points.Length, tension);
472 GDIPlus.CheckStatus (status);
475 // according to MSDN fillmode "is required but ignored" which makes _some_ sense since the unmanaged
476 // GDI+ call doesn't support it (issue spotted using Gendarme's AvoidUnusedParametersRule)
477 public void DrawClosedCurve (Pen pen, PointF [] points, float tension, FillMode fillmode)
480 throw new ArgumentNullException ("pen");
482 throw new ArgumentNullException ("points");
485 status = GDIPlus.GdipDrawClosedCurve2 (nativeObject, pen.nativeObject, points, points.Length, tension);
486 GDIPlus.CheckStatus (status);
489 public void DrawCurve (Pen pen, Point [] points)
492 throw new ArgumentNullException ("pen");
494 throw new ArgumentNullException ("points");
497 status = GDIPlus.GdipDrawCurveI (nativeObject, pen.nativeObject, points, points.Length);
498 GDIPlus.CheckStatus (status);
501 public void DrawCurve (Pen pen, PointF [] points)
504 throw new ArgumentNullException ("pen");
506 throw new ArgumentNullException ("points");
509 status = GDIPlus.GdipDrawCurve (nativeObject, pen.nativeObject, points, points.Length);
510 GDIPlus.CheckStatus (status);
513 public void DrawCurve (Pen pen, PointF [] points, float tension)
516 throw new ArgumentNullException ("pen");
518 throw new ArgumentNullException ("points");
521 status = GDIPlus.GdipDrawCurve2 (nativeObject, pen.nativeObject, points, points.Length, tension);
522 GDIPlus.CheckStatus (status);
525 public void DrawCurve (Pen pen, Point [] points, float tension)
528 throw new ArgumentNullException ("pen");
530 throw new ArgumentNullException ("points");
533 status = GDIPlus.GdipDrawCurve2I (nativeObject, pen.nativeObject, points, points.Length, tension);
534 GDIPlus.CheckStatus (status);
537 public void DrawCurve (Pen pen, PointF [] points, int offset, int numberOfSegments)
540 throw new ArgumentNullException ("pen");
542 throw new ArgumentNullException ("points");
545 status = GDIPlus.GdipDrawCurve3 (nativeObject, pen.nativeObject,
546 points, points.Length, offset,
547 numberOfSegments, 0.5f);
548 GDIPlus.CheckStatus (status);
551 public void DrawCurve (Pen pen, Point [] points, int offset, int numberOfSegments, float tension)
554 throw new ArgumentNullException ("pen");
556 throw new ArgumentNullException ("points");
559 status = GDIPlus.GdipDrawCurve3I (nativeObject, pen.nativeObject,
560 points, points.Length, offset,
561 numberOfSegments, tension);
562 GDIPlus.CheckStatus (status);
565 public void DrawCurve (Pen pen, PointF [] points, int offset, int numberOfSegments, float tension)
568 throw new ArgumentNullException ("pen");
570 throw new ArgumentNullException ("points");
573 status = GDIPlus.GdipDrawCurve3 (nativeObject, pen.nativeObject,
574 points, points.Length, offset,
575 numberOfSegments, tension);
576 GDIPlus.CheckStatus (status);
579 public void DrawEllipse (Pen pen, Rectangle rect)
582 throw new ArgumentNullException ("pen");
584 DrawEllipse (pen, rect.X, rect.Y, rect.Width, rect.Height);
587 public void DrawEllipse (Pen pen, RectangleF rect)
590 throw new ArgumentNullException ("pen");
591 DrawEllipse (pen, rect.X, rect.Y, rect.Width, rect.Height);
594 public void DrawEllipse (Pen pen, int x, int y, int width, int height)
597 throw new ArgumentNullException ("pen");
599 status = GDIPlus.GdipDrawEllipseI (nativeObject, pen.nativeObject, x, y, width, height);
600 GDIPlus.CheckStatus (status);
603 public void DrawEllipse (Pen pen, float x, float y, float width, float height)
606 throw new ArgumentNullException ("pen");
607 Status status = GDIPlus.GdipDrawEllipse (nativeObject, pen.nativeObject, x, y, width, height);
608 GDIPlus.CheckStatus (status);
611 public void DrawIcon (Icon icon, Rectangle targetRect)
614 throw new ArgumentNullException ("icon");
616 DrawImage (icon.GetInternalBitmap (), targetRect);
619 public void DrawIcon (Icon icon, int x, int y)
622 throw new ArgumentNullException ("icon");
624 DrawImage (icon.GetInternalBitmap (), x, y);
627 public void DrawIconUnstretched (Icon icon, Rectangle targetRect)
630 throw new ArgumentNullException ("icon");
632 DrawImageUnscaled (icon.GetInternalBitmap (), targetRect);
635 public void DrawImage (Image image, RectangleF rect)
638 throw new ArgumentNullException ("image");
640 Status status = GDIPlus.GdipDrawImageRect(nativeObject, image.NativeObject, rect.X, rect.Y, rect.Width, rect.Height);
641 GDIPlus.CheckStatus (status);
644 public void DrawImage (Image image, PointF point)
647 throw new ArgumentNullException ("image");
649 Status status = GDIPlus.GdipDrawImage (nativeObject, image.NativeObject, point.X, point.Y);
650 GDIPlus.CheckStatus (status);
653 public void DrawImage (Image image, Point [] destPoints)
656 throw new ArgumentNullException ("image");
657 if (destPoints == null)
658 throw new ArgumentNullException ("destPoints");
660 Status status = GDIPlus.GdipDrawImagePointsI (nativeObject, image.NativeObject, destPoints, destPoints.Length);
661 GDIPlus.CheckStatus (status);
664 public void DrawImage (Image image, Point point)
667 throw new ArgumentNullException ("image");
668 DrawImage (image, point.X, point.Y);
671 public void DrawImage (Image image, Rectangle rect)
674 throw new ArgumentNullException ("image");
675 DrawImage (image, rect.X, rect.Y, rect.Width, rect.Height);
678 public void DrawImage (Image image, PointF [] destPoints)
681 throw new ArgumentNullException ("image");
682 if (destPoints == null)
683 throw new ArgumentNullException ("destPoints");
684 Status status = GDIPlus.GdipDrawImagePoints (nativeObject, image.NativeObject, destPoints, destPoints.Length);
685 GDIPlus.CheckStatus (status);
688 public void DrawImage (Image image, int x, int y)
691 throw new ArgumentNullException ("image");
692 Status status = GDIPlus.GdipDrawImageI (nativeObject, image.NativeObject, x, y);
693 GDIPlus.CheckStatus (status);
696 public void DrawImage (Image image, float x, float y)
699 throw new ArgumentNullException ("image");
700 Status status = GDIPlus.GdipDrawImage (nativeObject, image.NativeObject, x, y);
701 GDIPlus.CheckStatus (status);
704 public void DrawImage (Image image, Rectangle destRect, Rectangle srcRect, GraphicsUnit srcUnit)
707 throw new ArgumentNullException ("image");
708 Status status = GDIPlus.GdipDrawImageRectRectI (nativeObject, image.NativeObject,
709 destRect.X, destRect.Y, destRect.Width, destRect.Height,
710 srcRect.X, srcRect.Y, srcRect.Width, srcRect.Height,
711 srcUnit, IntPtr.Zero, null, IntPtr.Zero);
712 GDIPlus.CheckStatus (status);
715 public void DrawImage (Image image, RectangleF destRect, RectangleF srcRect, GraphicsUnit srcUnit)
718 throw new ArgumentNullException ("image");
719 Status status = GDIPlus.GdipDrawImageRectRect (nativeObject, image.NativeObject,
720 destRect.X, destRect.Y, destRect.Width, destRect.Height,
721 srcRect.X, srcRect.Y, srcRect.Width, srcRect.Height,
722 srcUnit, IntPtr.Zero, null, IntPtr.Zero);
723 GDIPlus.CheckStatus (status);
726 public void DrawImage (Image image, Point [] destPoints, Rectangle srcRect, GraphicsUnit srcUnit)
729 throw new ArgumentNullException ("image");
730 if (destPoints == null)
731 throw new ArgumentNullException ("destPoints");
733 Status status = GDIPlus.GdipDrawImagePointsRectI (nativeObject, image.NativeObject,
734 destPoints, destPoints.Length , srcRect.X, srcRect.Y,
735 srcRect.Width, srcRect.Height, srcUnit, IntPtr.Zero,
737 GDIPlus.CheckStatus (status);
740 public void DrawImage (Image image, PointF [] destPoints, RectangleF srcRect, GraphicsUnit srcUnit)
743 throw new ArgumentNullException ("image");
744 if (destPoints == null)
745 throw new ArgumentNullException ("destPoints");
747 Status status = GDIPlus.GdipDrawImagePointsRect (nativeObject, image.NativeObject,
748 destPoints, destPoints.Length , srcRect.X, srcRect.Y,
749 srcRect.Width, srcRect.Height, srcUnit, IntPtr.Zero,
751 GDIPlus.CheckStatus (status);
754 public void DrawImage (Image image, Point [] destPoints, Rectangle srcRect, GraphicsUnit srcUnit,
755 ImageAttributes imageAttr)
758 throw new ArgumentNullException ("image");
759 if (destPoints == null)
760 throw new ArgumentNullException ("destPoints");
761 Status status = GDIPlus.GdipDrawImagePointsRectI (nativeObject, image.NativeObject,
762 destPoints, destPoints.Length , srcRect.X, srcRect.Y,
763 srcRect.Width, srcRect.Height, srcUnit,
764 imageAttr != null ? imageAttr.NativeObject : IntPtr.Zero, null, IntPtr.Zero);
765 GDIPlus.CheckStatus (status);
768 public void DrawImage (Image image, float x, float y, float width, float height)
771 throw new ArgumentNullException ("image");
772 Status status = GDIPlus.GdipDrawImageRect(nativeObject, image.NativeObject, x, y,
774 GDIPlus.CheckStatus (status);
777 public void DrawImage (Image image, PointF [] destPoints, RectangleF srcRect, GraphicsUnit srcUnit,
778 ImageAttributes imageAttr)
781 throw new ArgumentNullException ("image");
782 if (destPoints == null)
783 throw new ArgumentNullException ("destPoints");
784 Status status = GDIPlus.GdipDrawImagePointsRect (nativeObject, image.NativeObject,
785 destPoints, destPoints.Length , srcRect.X, srcRect.Y,
786 srcRect.Width, srcRect.Height, srcUnit,
787 imageAttr != null ? imageAttr.NativeObject : IntPtr.Zero, null, IntPtr.Zero);
788 GDIPlus.CheckStatus (status);
791 public void DrawImage (Image image, int x, int y, Rectangle srcRect, GraphicsUnit srcUnit)
794 throw new ArgumentNullException ("image");
795 Status status = GDIPlus.GdipDrawImagePointRectI(nativeObject, image.NativeObject, x, y, srcRect.X, srcRect.Y, srcRect.Width, srcRect.Height, srcUnit);
796 GDIPlus.CheckStatus (status);
799 public void DrawImage (Image image, int x, int y, int width, int height)
802 throw new ArgumentNullException ("image");
803 Status status = GDIPlus.GdipDrawImageRectI (nativeObject, image.nativeObject, x, y, width, height);
804 GDIPlus.CheckStatus (status);
807 public void DrawImage (Image image, float x, float y, RectangleF srcRect, GraphicsUnit srcUnit)
810 throw new ArgumentNullException ("image");
811 Status status = GDIPlus.GdipDrawImagePointRect (nativeObject, image.nativeObject, x, y, srcRect.X, srcRect.Y, srcRect.Width, srcRect.Height, srcUnit);
812 GDIPlus.CheckStatus (status);
815 public void DrawImage (Image image, PointF [] destPoints, RectangleF srcRect, GraphicsUnit srcUnit, ImageAttributes imageAttr, DrawImageAbort callback)
818 throw new ArgumentNullException ("image");
819 if (destPoints == null)
820 throw new ArgumentNullException ("destPoints");
821 Status status = GDIPlus.GdipDrawImagePointsRect (nativeObject, image.NativeObject,
822 destPoints, destPoints.Length , srcRect.X, srcRect.Y,
823 srcRect.Width, srcRect.Height, srcUnit,
824 imageAttr != null ? imageAttr.NativeObject : IntPtr.Zero, callback, IntPtr.Zero);
825 GDIPlus.CheckStatus (status);
828 public void DrawImage (Image image, Point [] destPoints, Rectangle srcRect, GraphicsUnit srcUnit, ImageAttributes imageAttr, DrawImageAbort callback)
831 throw new ArgumentNullException ("image");
832 if (destPoints == null)
833 throw new ArgumentNullException ("destPoints");
835 Status status = GDIPlus.GdipDrawImagePointsRectI (nativeObject, image.NativeObject,
836 destPoints, destPoints.Length , srcRect.X, srcRect.Y,
837 srcRect.Width, srcRect.Height, srcUnit,
838 imageAttr != null ? imageAttr.NativeObject : IntPtr.Zero, callback, IntPtr.Zero);
839 GDIPlus.CheckStatus (status);
842 public void DrawImage (Image image, Point [] destPoints, Rectangle srcRect, GraphicsUnit srcUnit, ImageAttributes imageAttr, DrawImageAbort callback, int callbackData)
845 throw new ArgumentNullException ("image");
846 if (destPoints == null)
847 throw new ArgumentNullException ("destPoints");
849 Status status = GDIPlus.GdipDrawImagePointsRectI (nativeObject, image.NativeObject,
850 destPoints, destPoints.Length , srcRect.X, srcRect.Y,
851 srcRect.Width, srcRect.Height, srcUnit,
852 imageAttr != null ? imageAttr.NativeObject : IntPtr.Zero, callback, (IntPtr) callbackData);
853 GDIPlus.CheckStatus (status);
856 public void DrawImage (Image image, Rectangle destRect, float srcX, float srcY, float srcWidth, float srcHeight, GraphicsUnit srcUnit)
859 throw new ArgumentNullException ("image");
860 Status status = GDIPlus.GdipDrawImageRectRect (nativeObject, image.NativeObject,
861 destRect.X, destRect.Y, destRect.Width, destRect.Height,
862 srcX, srcY, srcWidth, srcHeight, srcUnit, IntPtr.Zero,
864 GDIPlus.CheckStatus (status);
867 public void DrawImage (Image image, PointF [] destPoints, RectangleF srcRect, GraphicsUnit srcUnit, ImageAttributes imageAttr, DrawImageAbort callback, int callbackData)
869 Status status = GDIPlus.GdipDrawImagePointsRect (nativeObject, image.NativeObject,
870 destPoints, destPoints.Length , srcRect.X, srcRect.Y,
871 srcRect.Width, srcRect.Height, srcUnit,
872 imageAttr != null ? imageAttr.NativeObject : IntPtr.Zero, callback, (IntPtr) callbackData);
873 GDIPlus.CheckStatus (status);
876 public void DrawImage (Image image, Rectangle destRect, int srcX, int srcY, int srcWidth, int srcHeight, GraphicsUnit srcUnit)
879 throw new ArgumentNullException ("image");
880 Status status = GDIPlus.GdipDrawImageRectRectI (nativeObject, image.NativeObject,
881 destRect.X, destRect.Y, destRect.Width, destRect.Height,
882 srcX, srcY, srcWidth, srcHeight, srcUnit, IntPtr.Zero,
884 GDIPlus.CheckStatus (status);
887 public void DrawImage (Image image, Rectangle destRect, float srcX, float srcY, float srcWidth, float srcHeight, GraphicsUnit srcUnit, ImageAttributes imageAttrs)
890 throw new ArgumentNullException ("image");
891 Status status = GDIPlus.GdipDrawImageRectRect (nativeObject, image.NativeObject,
892 destRect.X, destRect.Y, destRect.Width, destRect.Height,
893 srcX, srcY, srcWidth, srcHeight, srcUnit,
894 imageAttrs != null ? imageAttrs.NativeObject : IntPtr.Zero, null, IntPtr.Zero);
895 GDIPlus.CheckStatus (status);
898 public void DrawImage (Image image, Rectangle destRect, int srcX, int srcY, int srcWidth, int srcHeight, GraphicsUnit srcUnit, ImageAttributes imageAttr)
901 throw new ArgumentNullException ("image");
902 Status status = GDIPlus.GdipDrawImageRectRectI (nativeObject, image.NativeObject,
903 destRect.X, destRect.Y, destRect.Width,
904 destRect.Height, srcX, srcY, srcWidth, srcHeight,
905 srcUnit, imageAttr != null ? imageAttr.NativeObject : IntPtr.Zero, null, IntPtr.Zero);
906 GDIPlus.CheckStatus (status);
909 public void DrawImage (Image image, Rectangle destRect, int srcX, int srcY, int srcWidth, int srcHeight, GraphicsUnit srcUnit, ImageAttributes imageAttr, DrawImageAbort callback)
912 throw new ArgumentNullException ("image");
913 Status status = GDIPlus.GdipDrawImageRectRectI (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, callback,
918 GDIPlus.CheckStatus (status);
921 public void DrawImage (Image image, Rectangle destRect, float srcX, float srcY, float srcWidth, float srcHeight, GraphicsUnit srcUnit, ImageAttributes imageAttrs, DrawImageAbort callback)
924 throw new ArgumentNullException ("image");
925 Status status = GDIPlus.GdipDrawImageRectRect (nativeObject, image.NativeObject,
926 destRect.X, destRect.Y, destRect.Width,
927 destRect.Height, srcX, srcY, srcWidth, srcHeight,
928 srcUnit, imageAttrs != null ? imageAttrs.NativeObject : IntPtr.Zero,
929 callback, IntPtr.Zero);
930 GDIPlus.CheckStatus (status);
933 public void DrawImage (Image image, Rectangle destRect, float srcX, float srcY, float srcWidth, float srcHeight, GraphicsUnit srcUnit, ImageAttributes imageAttrs, DrawImageAbort callback, IntPtr callbackData)
936 throw new ArgumentNullException ("image");
937 Status status = GDIPlus.GdipDrawImageRectRect (nativeObject, image.NativeObject,
938 destRect.X, destRect.Y, destRect.Width, destRect.Height,
939 srcX, srcY, srcWidth, srcHeight, srcUnit,
940 imageAttrs != null ? imageAttrs.NativeObject : IntPtr.Zero, callback, callbackData);
941 GDIPlus.CheckStatus (status);
944 public void DrawImage (Image image, Rectangle destRect, int srcX, int srcY, int srcWidth, int srcHeight, GraphicsUnit srcUnit, ImageAttributes imageAttrs, DrawImageAbort callback, IntPtr callbackData)
947 throw new ArgumentNullException ("image");
948 Status status = GDIPlus.GdipDrawImageRectRect (nativeObject, image.NativeObject,
949 destRect.X, destRect.Y, destRect.Width, destRect.Height,
950 srcX, srcY, srcWidth, srcHeight, srcUnit,
951 imageAttrs != null ? imageAttrs.NativeObject : IntPtr.Zero, callback, callbackData);
952 GDIPlus.CheckStatus (status);
955 public void DrawImageUnscaled (Image image, Point point)
957 DrawImageUnscaled (image, point.X, point.Y);
960 public void DrawImageUnscaled (Image image, Rectangle rect)
962 DrawImageUnscaled (image, rect.X, rect.Y, rect.Width, rect.Height);
965 public void DrawImageUnscaled (Image image, int x, int y)
968 throw new ArgumentNullException ("image");
969 DrawImage (image, x, y, image.Width, image.Height);
972 public void DrawImageUnscaled (Image image, int x, int y, int width, int height)
975 throw new ArgumentNullException ("image");
977 // avoid creating an empty, or negative w/h, bitmap...
978 if ((width <= 0) || (height <= 0))
981 using (Image tmpImg = new Bitmap (width, height)) {
982 using (Graphics g = FromImage (tmpImg)) {
983 g.DrawImage (image, 0, 0, image.Width, image.Height);
984 DrawImage (tmpImg, x, y, width, height);
990 public void DrawImageUnscaledAndClipped (Image image, Rectangle rect)
993 throw new ArgumentNullException ("image");
995 int width = (image.Width > rect.Width) ? rect.Width : image.Width;
996 int height = (image.Height > rect.Height) ? rect.Height : image.Height;
998 DrawImageUnscaled (image, rect.X, rect.Y, width, height);
1002 public void DrawLine (Pen pen, PointF pt1, PointF pt2)
1005 throw new ArgumentNullException ("pen");
1006 Status status = GDIPlus.GdipDrawLine (nativeObject, pen.nativeObject,
1007 pt1.X, pt1.Y, pt2.X, pt2.Y);
1008 GDIPlus.CheckStatus (status);
1011 public void DrawLine (Pen pen, Point pt1, Point pt2)
1014 throw new ArgumentNullException ("pen");
1015 Status status = GDIPlus.GdipDrawLineI (nativeObject, pen.nativeObject,
1016 pt1.X, pt1.Y, pt2.X, pt2.Y);
1017 GDIPlus.CheckStatus (status);
1020 public void DrawLine (Pen pen, int x1, int y1, int x2, int y2)
1023 throw new ArgumentNullException ("pen");
1024 Status status = GDIPlus.GdipDrawLineI (nativeObject, pen.nativeObject, x1, y1, x2, y2);
1025 GDIPlus.CheckStatus (status);
1028 public void DrawLine (Pen pen, float x1, float y1, float x2, float y2)
1031 throw new ArgumentNullException ("pen");
1032 Status status = GDIPlus.GdipDrawLine (nativeObject, pen.nativeObject, x1, y1, x2, y2);
1033 GDIPlus.CheckStatus (status);
1036 public void DrawLines (Pen pen, PointF [] points)
1039 throw new ArgumentNullException ("pen");
1041 throw new ArgumentNullException ("points");
1042 Status status = GDIPlus.GdipDrawLines (nativeObject, pen.nativeObject, points, points.Length);
1043 GDIPlus.CheckStatus (status);
1046 public void DrawLines (Pen pen, Point [] points)
1049 throw new ArgumentNullException ("pen");
1051 throw new ArgumentNullException ("points");
1052 Status status = GDIPlus.GdipDrawLinesI (nativeObject, pen.nativeObject, points, points.Length);
1053 GDIPlus.CheckStatus (status);
1056 public void DrawPath (Pen pen, GraphicsPath path)
1059 throw new ArgumentNullException ("pen");
1061 throw new ArgumentNullException ("path");
1062 Status status = GDIPlus.GdipDrawPath (nativeObject, pen.nativeObject, path.nativePath);
1063 GDIPlus.CheckStatus (status);
1066 public void DrawPie (Pen pen, Rectangle rect, float startAngle, float sweepAngle)
1069 throw new ArgumentNullException ("pen");
1070 DrawPie (pen, rect.X, rect.Y, rect.Width, rect.Height, startAngle, sweepAngle);
1073 public void DrawPie (Pen pen, RectangleF rect, float startAngle, float sweepAngle)
1076 throw new ArgumentNullException ("pen");
1077 DrawPie (pen, rect.X, rect.Y, rect.Width, rect.Height, startAngle, sweepAngle);
1080 public void DrawPie (Pen pen, float x, float y, float width, float height, float startAngle, float sweepAngle)
1083 throw new ArgumentNullException ("pen");
1084 Status status = GDIPlus.GdipDrawPie (nativeObject, pen.nativeObject, x, y, width, height, startAngle, sweepAngle);
1085 GDIPlus.CheckStatus (status);
1088 // Microsoft documentation states that the signature for this member should be
1089 // public void DrawPie(Pen pen, int x, int y, int width, int height, int startAngle
1090 // int sweepAngle. However, GdipDrawPieI uses also float for the startAngle and sweepAngle params
1091 public void DrawPie (Pen pen, int x, int y, int width, int height, int startAngle, int sweepAngle)
1094 throw new ArgumentNullException ("pen");
1095 Status status = GDIPlus.GdipDrawPieI (nativeObject, pen.nativeObject, x, y, width, height, startAngle, sweepAngle);
1096 GDIPlus.CheckStatus (status);
1099 public void DrawPolygon (Pen pen, Point [] points)
1102 throw new ArgumentNullException ("pen");
1104 throw new ArgumentNullException ("points");
1105 Status status = GDIPlus.GdipDrawPolygonI (nativeObject, pen.nativeObject, points, points.Length);
1106 GDIPlus.CheckStatus (status);
1109 public void DrawPolygon (Pen pen, PointF [] points)
1112 throw new ArgumentNullException ("pen");
1114 throw new ArgumentNullException ("points");
1115 Status status = GDIPlus.GdipDrawPolygon (nativeObject, pen.nativeObject, points, points.Length);
1116 GDIPlus.CheckStatus (status);
1119 public void DrawRectangle (Pen pen, Rectangle rect)
1122 throw new ArgumentNullException ("pen");
1123 DrawRectangle (pen, rect.Left, rect.Top, rect.Width, rect.Height);
1126 public void DrawRectangle (Pen pen, float x, float y, float width, float height)
1129 throw new ArgumentNullException ("pen");
1130 Status status = GDIPlus.GdipDrawRectangle (nativeObject, pen.nativeObject, x, y, width, height);
1131 GDIPlus.CheckStatus (status);
1134 public void DrawRectangle (Pen pen, int x, int y, int width, int height)
1137 throw new ArgumentNullException ("pen");
1138 Status status = GDIPlus.GdipDrawRectangleI (nativeObject, pen.nativeObject, x, y, width, height);
1139 GDIPlus.CheckStatus (status);
1142 public void DrawRectangles (Pen pen, RectangleF [] rects)
1145 throw new ArgumentNullException ("image");
1147 throw new ArgumentNullException ("rects");
1148 Status status = GDIPlus.GdipDrawRectangles (nativeObject, pen.nativeObject, rects, rects.Length);
1149 GDIPlus.CheckStatus (status);
1152 public void DrawRectangles (Pen pen, Rectangle [] rects)
1155 throw new ArgumentNullException ("image");
1157 throw new ArgumentNullException ("rects");
1158 Status status = GDIPlus.GdipDrawRectanglesI (nativeObject, pen.nativeObject, rects, rects.Length);
1159 GDIPlus.CheckStatus (status);
1162 public void DrawString (string s, Font font, Brush brush, RectangleF layoutRectangle)
1164 DrawString (s, font, brush, layoutRectangle, null);
1167 public void DrawString (string s, Font font, Brush brush, PointF point)
1169 DrawString (s, font, brush, new RectangleF (point.X, point.Y, 0, 0), null);
1172 public void DrawString (string s, Font font, Brush brush, PointF point, StringFormat format)
1174 DrawString(s, font, brush, new RectangleF(point.X, point.Y, 0, 0), format);
1177 public void DrawString (string s, Font font, Brush brush, float x, float y)
1179 DrawString (s, font, brush, new RectangleF (x, y, 0, 0), null);
1182 public void DrawString (string s, Font font, Brush brush, float x, float y, StringFormat format)
1184 DrawString (s, font, brush, new RectangleF(x, y, 0, 0), format);
1187 public void DrawString (string s, Font font, Brush brush, RectangleF layoutRectangle, StringFormat format)
1190 throw new ArgumentNullException ("font");
1192 throw new ArgumentNullException ("brush");
1193 if (s == null || s.Length == 0)
1196 Status status = GDIPlus.GdipDrawString (nativeObject, s, s.Length, font.NativeObject, ref layoutRectangle, format != null ? format.NativeObject : IntPtr.Zero, brush.nativeObject);
1197 GDIPlus.CheckStatus (status);
1200 public void EndContainer (GraphicsContainer container)
1203 if (container == null)
1204 throw new ArgumentNullException ("container");
1206 Status status = GDIPlus.GdipEndContainer(nativeObject, container.NativeObject);
1207 GDIPlus.CheckStatus (status);
1210 private const string MetafileEnumeration = "Metafiles enumeration, for both WMF and EMF formats, isn't supported.";
1212 [MonoTODO (MetafileEnumeration)]
1213 public void EnumerateMetafile (Metafile metafile, Point [] destPoints, EnumerateMetafileProc callback)
1215 throw new NotImplementedException ();
1218 [MonoTODO (MetafileEnumeration)]
1219 public void EnumerateMetafile (Metafile metafile, RectangleF destRect, EnumerateMetafileProc callback)
1221 throw new NotImplementedException ();
1224 [MonoTODO (MetafileEnumeration)]
1225 public void EnumerateMetafile (Metafile metafile, PointF [] destPoints, EnumerateMetafileProc callback)
1227 throw new NotImplementedException ();
1230 [MonoTODO (MetafileEnumeration)]
1231 public void EnumerateMetafile (Metafile metafile, Rectangle destRect, EnumerateMetafileProc callback)
1233 throw new NotImplementedException ();
1236 [MonoTODO (MetafileEnumeration)]
1237 public void EnumerateMetafile (Metafile metafile, Point destPoint, EnumerateMetafileProc callback)
1239 throw new NotImplementedException ();
1242 [MonoTODO (MetafileEnumeration)]
1243 public void EnumerateMetafile (Metafile metafile, PointF destPoint, EnumerateMetafileProc callback)
1245 throw new NotImplementedException ();
1248 [MonoTODO (MetafileEnumeration)]
1249 public void EnumerateMetafile (Metafile metafile, PointF destPoint, EnumerateMetafileProc callback, IntPtr callbackData)
1251 throw new NotImplementedException ();
1254 [MonoTODO (MetafileEnumeration)]
1255 public void EnumerateMetafile (Metafile metafile, Rectangle destRect, EnumerateMetafileProc callback, IntPtr callbackData)
1257 throw new NotImplementedException ();
1260 [MonoTODO (MetafileEnumeration)]
1261 public void EnumerateMetafile (Metafile metafile, PointF [] destPoints, EnumerateMetafileProc callback, IntPtr callbackData)
1263 throw new NotImplementedException ();
1266 [MonoTODO (MetafileEnumeration)]
1267 public void EnumerateMetafile (Metafile metafile, Point destPoint, EnumerateMetafileProc callback, IntPtr callbackData)
1269 throw new NotImplementedException ();
1272 [MonoTODO (MetafileEnumeration)]
1273 public void EnumerateMetafile (Metafile metafile, Point [] destPoints, EnumerateMetafileProc callback, IntPtr callbackData)
1275 throw new NotImplementedException ();
1278 [MonoTODO (MetafileEnumeration)]
1279 public void EnumerateMetafile (Metafile metafile, RectangleF destRect, EnumerateMetafileProc callback, IntPtr callbackData)
1281 throw new NotImplementedException ();
1284 [MonoTODO (MetafileEnumeration)]
1285 public void EnumerateMetafile (Metafile metafile, PointF destPoint, RectangleF srcRect, GraphicsUnit srcUnit, EnumerateMetafileProc callback)
1287 throw new NotImplementedException ();
1290 [MonoTODO (MetafileEnumeration)]
1291 public void EnumerateMetafile (Metafile metafile, Point destPoint, Rectangle srcRect, GraphicsUnit srcUnit, EnumerateMetafileProc callback)
1293 throw new NotImplementedException ();
1296 [MonoTODO (MetafileEnumeration)]
1297 public void EnumerateMetafile (Metafile metafile, PointF [] destPoints, RectangleF srcRect, GraphicsUnit srcUnit, EnumerateMetafileProc callback)
1299 throw new NotImplementedException ();
1302 [MonoTODO (MetafileEnumeration)]
1303 public void EnumerateMetafile (Metafile metafile, Point [] destPoints, Rectangle srcRect, GraphicsUnit srcUnit, EnumerateMetafileProc callback)
1305 throw new NotImplementedException ();
1308 [MonoTODO (MetafileEnumeration)]
1309 public void EnumerateMetafile (Metafile metafile, RectangleF destRect, RectangleF srcRect, GraphicsUnit srcUnit, EnumerateMetafileProc callback)
1311 throw new NotImplementedException ();
1314 [MonoTODO (MetafileEnumeration)]
1315 public void EnumerateMetafile (Metafile metafile, Rectangle destRect, Rectangle srcRect, GraphicsUnit srcUnit, EnumerateMetafileProc callback)
1317 throw new NotImplementedException ();
1320 [MonoTODO (MetafileEnumeration)]
1321 public void EnumerateMetafile (Metafile metafile, RectangleF destRect, EnumerateMetafileProc callback, IntPtr callbackData, ImageAttributes imageAttr)
1323 throw new NotImplementedException ();
1326 [MonoTODO (MetafileEnumeration)]
1327 public void EnumerateMetafile (Metafile metafile, Point destPoint, EnumerateMetafileProc callback, IntPtr callbackData, ImageAttributes imageAttr)
1329 throw new NotImplementedException ();
1332 [MonoTODO (MetafileEnumeration)]
1333 public void EnumerateMetafile (Metafile metafile, PointF destPoint, EnumerateMetafileProc callback, IntPtr callbackData, ImageAttributes imageAttr)
1335 throw new NotImplementedException ();
1338 [MonoTODO (MetafileEnumeration)]
1339 public void EnumerateMetafile (Metafile metafile, Point [] destPoints, EnumerateMetafileProc callback, IntPtr callbackData, ImageAttributes imageAttr)
1341 throw new NotImplementedException ();
1344 [MonoTODO (MetafileEnumeration)]
1345 public void EnumerateMetafile (Metafile metafile, PointF [] destPoints, EnumerateMetafileProc callback, IntPtr callbackData, ImageAttributes imageAttr)
1347 throw new NotImplementedException ();
1350 [MonoTODO (MetafileEnumeration)]
1351 public void EnumerateMetafile (Metafile metafile, Rectangle destRect, EnumerateMetafileProc callback, IntPtr callbackData, ImageAttributes imageAttr)
1353 throw new NotImplementedException ();
1356 [MonoTODO (MetafileEnumeration)]
1357 public void EnumerateMetafile (Metafile metafile, Rectangle destRect, Rectangle srcRect, GraphicsUnit srcUnit, EnumerateMetafileProc callback, IntPtr callbackData)
1359 throw new NotImplementedException ();
1362 [MonoTODO (MetafileEnumeration)]
1363 public void EnumerateMetafile (Metafile metafile, PointF [] destPoints, RectangleF srcRect, GraphicsUnit srcUnit, EnumerateMetafileProc callback, IntPtr callbackData)
1365 throw new NotImplementedException ();
1368 [MonoTODO (MetafileEnumeration)]
1369 public void EnumerateMetafile (Metafile metafile, RectangleF destRect, RectangleF srcRect, GraphicsUnit srcUnit, EnumerateMetafileProc callback, IntPtr callbackData)
1371 throw new NotImplementedException ();
1374 [MonoTODO (MetafileEnumeration)]
1375 public void EnumerateMetafile (Metafile metafile, PointF destPoint, RectangleF srcRect, GraphicsUnit srcUnit, EnumerateMetafileProc callback, IntPtr callbackData)
1377 throw new NotImplementedException ();
1380 [MonoTODO (MetafileEnumeration)]
1381 public void EnumerateMetafile (Metafile metafile, Point destPoint, 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 srcUnit, EnumerateMetafileProc callback, IntPtr callbackData)
1389 throw new NotImplementedException ();
1392 [MonoTODO (MetafileEnumeration)]
1393 public void EnumerateMetafile (Metafile metafile, Point [] destPoints, Rectangle srcRect, GraphicsUnit unit, EnumerateMetafileProc callback, IntPtr callbackData, ImageAttributes imageAttr)
1395 throw new NotImplementedException ();
1398 [MonoTODO (MetafileEnumeration)]
1399 public void EnumerateMetafile (Metafile metafile, Rectangle destRect, Rectangle srcRect, GraphicsUnit unit, EnumerateMetafileProc callback, IntPtr callbackData, ImageAttributes imageAttr)
1401 throw new NotImplementedException ();
1404 [MonoTODO (MetafileEnumeration)]
1405 public void EnumerateMetafile (Metafile metafile, Point destPoint, Rectangle srcRect, GraphicsUnit unit, EnumerateMetafileProc callback, IntPtr callbackData, ImageAttributes imageAttr)
1407 throw new NotImplementedException ();
1410 [MonoTODO (MetafileEnumeration)]
1411 public void EnumerateMetafile (Metafile metafile, RectangleF destRect, RectangleF srcRect, GraphicsUnit unit, EnumerateMetafileProc callback, IntPtr callbackData, ImageAttributes imageAttr)
1413 throw new NotImplementedException ();
1416 [MonoTODO (MetafileEnumeration)]
1417 public void EnumerateMetafile (Metafile metafile, PointF [] destPoints, RectangleF srcRect, GraphicsUnit unit, EnumerateMetafileProc callback, IntPtr callbackData, ImageAttributes imageAttr)
1419 throw new NotImplementedException ();
1422 [MonoTODO (MetafileEnumeration)]
1423 public void EnumerateMetafile (Metafile metafile, PointF destPoint, RectangleF srcRect, GraphicsUnit unit, EnumerateMetafileProc callback, IntPtr callbackData, ImageAttributes imageAttr)
1425 throw new NotImplementedException ();
1428 public void ExcludeClip (Rectangle rect)
1430 Status status = GDIPlus.GdipSetClipRectI (nativeObject, rect.X, rect.Y, rect.Width, rect.Height, CombineMode.Exclude);
1431 GDIPlus.CheckStatus (status);
1434 public void ExcludeClip (Region region)
1437 throw new ArgumentNullException ("region");
1438 Status status = GDIPlus.GdipSetClipRegion (nativeObject, region.NativeObject, CombineMode.Exclude);
1439 GDIPlus.CheckStatus (status);
1443 public void FillClosedCurve (Brush brush, PointF [] points)
1446 throw new ArgumentNullException ("brush");
1448 throw new ArgumentNullException ("points");
1449 Status status = GDIPlus.GdipFillClosedCurve (nativeObject, brush.NativeObject, points, points.Length);
1450 GDIPlus.CheckStatus (status);
1453 public void FillClosedCurve (Brush brush, Point [] points)
1456 throw new ArgumentNullException ("brush");
1458 throw new ArgumentNullException ("points");
1459 Status status = GDIPlus.GdipFillClosedCurveI (nativeObject, brush.NativeObject, points, points.Length);
1460 GDIPlus.CheckStatus (status);
1464 public void FillClosedCurve (Brush brush, PointF [] points, FillMode fillmode)
1467 throw new ArgumentNullException ("brush");
1469 throw new ArgumentNullException ("points");
1470 FillClosedCurve (brush, points, fillmode, 0.5f);
1473 public void FillClosedCurve (Brush brush, Point [] points, FillMode fillmode)
1476 throw new ArgumentNullException ("brush");
1478 throw new ArgumentNullException ("points");
1479 FillClosedCurve (brush, points, fillmode, 0.5f);
1482 public void FillClosedCurve (Brush brush, PointF [] points, FillMode fillmode, float tension)
1485 throw new ArgumentNullException ("brush");
1487 throw new ArgumentNullException ("points");
1488 Status status = GDIPlus.GdipFillClosedCurve2 (nativeObject, brush.NativeObject, points, points.Length, tension, fillmode);
1489 GDIPlus.CheckStatus (status);
1492 public void FillClosedCurve (Brush brush, Point [] points, FillMode fillmode, float tension)
1495 throw new ArgumentNullException ("brush");
1497 throw new ArgumentNullException ("points");
1498 Status status = GDIPlus.GdipFillClosedCurve2I (nativeObject, brush.NativeObject, points, points.Length, tension, fillmode);
1499 GDIPlus.CheckStatus (status);
1502 public void FillEllipse (Brush brush, Rectangle rect)
1505 throw new ArgumentNullException ("brush");
1506 FillEllipse (brush, rect.X, rect.Y, rect.Width, rect.Height);
1509 public void FillEllipse (Brush brush, RectangleF rect)
1512 throw new ArgumentNullException ("brush");
1513 FillEllipse (brush, rect.X, rect.Y, rect.Width, rect.Height);
1516 public void FillEllipse (Brush brush, float x, float y, float width, float height)
1519 throw new ArgumentNullException ("brush");
1520 Status status = GDIPlus.GdipFillEllipse (nativeObject, brush.nativeObject, x, y, width, height);
1521 GDIPlus.CheckStatus (status);
1524 public void FillEllipse (Brush brush, int x, int y, int width, int height)
1527 throw new ArgumentNullException ("brush");
1528 Status status = GDIPlus.GdipFillEllipseI (nativeObject, brush.nativeObject, x, y, width, height);
1529 GDIPlus.CheckStatus (status);
1532 public void FillPath (Brush brush, GraphicsPath path)
1535 throw new ArgumentNullException ("brush");
1537 throw new ArgumentNullException ("path");
1538 Status status = GDIPlus.GdipFillPath (nativeObject, brush.NativeObject, path.NativeObject);
1539 GDIPlus.CheckStatus (status);
1542 public void FillPie (Brush brush, Rectangle rect, float startAngle, float sweepAngle)
1545 throw new ArgumentNullException ("brush");
1546 Status status = GDIPlus.GdipFillPie (nativeObject, brush.NativeObject, rect.X, rect.Y, rect.Width, rect.Height, startAngle, sweepAngle);
1547 GDIPlus.CheckStatus (status);
1550 public void FillPie (Brush brush, int x, int y, int width, int height, int startAngle, int sweepAngle)
1553 throw new ArgumentNullException ("brush");
1554 Status status = GDIPlus.GdipFillPieI (nativeObject, brush.NativeObject, x, y, width, height, startAngle, sweepAngle);
1555 GDIPlus.CheckStatus (status);
1558 public void FillPie (Brush brush, float x, float y, float width, float height, float startAngle, float sweepAngle)
1561 throw new ArgumentNullException ("brush");
1562 Status status = GDIPlus.GdipFillPie (nativeObject, brush.NativeObject, x, y, width, height, startAngle, sweepAngle);
1563 GDIPlus.CheckStatus (status);
1566 public void FillPolygon (Brush brush, PointF [] points)
1569 throw new ArgumentNullException ("brush");
1571 throw new ArgumentNullException ("points");
1572 Status status = GDIPlus.GdipFillPolygon2 (nativeObject, brush.nativeObject, points, points.Length);
1573 GDIPlus.CheckStatus (status);
1576 public void FillPolygon (Brush brush, Point [] points)
1579 throw new ArgumentNullException ("brush");
1581 throw new ArgumentNullException ("points");
1582 Status status = GDIPlus.GdipFillPolygon2I (nativeObject, brush.nativeObject, points, points.Length);
1583 GDIPlus.CheckStatus (status);
1586 public void FillPolygon (Brush brush, Point [] points, FillMode fillMode)
1589 throw new ArgumentNullException ("brush");
1591 throw new ArgumentNullException ("points");
1592 Status status = GDIPlus.GdipFillPolygonI (nativeObject, brush.nativeObject, points, points.Length, fillMode);
1593 GDIPlus.CheckStatus (status);
1596 public void FillPolygon (Brush brush, PointF [] points, FillMode fillMode)
1599 throw new ArgumentNullException ("brush");
1601 throw new ArgumentNullException ("points");
1602 Status status = GDIPlus.GdipFillPolygon (nativeObject, brush.nativeObject, points, points.Length, fillMode);
1603 GDIPlus.CheckStatus (status);
1606 public void FillRectangle (Brush brush, RectangleF rect)
1609 throw new ArgumentNullException ("brush");
1610 FillRectangle (brush, rect.Left, rect.Top, rect.Width, rect.Height);
1613 public void FillRectangle (Brush brush, Rectangle rect)
1616 throw new ArgumentNullException ("brush");
1617 FillRectangle (brush, rect.Left, rect.Top, rect.Width, rect.Height);
1620 public void FillRectangle (Brush brush, int x, int y, int width, int height)
1623 throw new ArgumentNullException ("brush");
1625 Status status = GDIPlus.GdipFillRectangleI (nativeObject, brush.nativeObject, x, y, width, height);
1626 GDIPlus.CheckStatus (status);
1629 public void FillRectangle (Brush brush, float x, float y, float width, float height)
1632 throw new ArgumentNullException ("brush");
1634 Status status = GDIPlus.GdipFillRectangle (nativeObject, brush.nativeObject, x, y, width, height);
1635 GDIPlus.CheckStatus (status);
1638 public void FillRectangles (Brush brush, Rectangle [] rects)
1641 throw new ArgumentNullException ("brush");
1643 throw new ArgumentNullException ("rects");
1645 Status status = GDIPlus.GdipFillRectanglesI (nativeObject, brush.nativeObject, rects, rects.Length);
1646 GDIPlus.CheckStatus (status);
1649 public void FillRectangles (Brush brush, RectangleF [] rects)
1652 throw new ArgumentNullException ("brush");
1654 throw new ArgumentNullException ("rects");
1656 Status status = GDIPlus.GdipFillRectangles (nativeObject, brush.nativeObject, rects, rects.Length);
1657 GDIPlus.CheckStatus (status);
1661 public void FillRegion (Brush brush, Region region)
1664 throw new ArgumentNullException ("brush");
1666 throw new ArgumentNullException ("region");
1668 Status status = GDIPlus.GdipFillRegion (nativeObject, brush.NativeObject, region.NativeObject);
1669 GDIPlus.CheckStatus(status);
1673 public void Flush ()
1675 Flush (FlushIntention.Flush);
1679 public void Flush (FlushIntention intention)
1681 if (nativeObject == IntPtr.Zero) {
1685 Status status = GDIPlus.GdipFlush (nativeObject, intention);
1686 GDIPlus.CheckStatus (status);
1688 if (maccontext != null)
1689 maccontext.Synchronize ();
1692 [EditorBrowsable (EditorBrowsableState.Advanced)]
1693 public static Graphics FromHdc (IntPtr hdc)
1696 Status status = GDIPlus.GdipCreateFromHDC (hdc, out graphics);
1697 GDIPlus.CheckStatus (status);
1698 return new Graphics (graphics);
1702 [EditorBrowsable (EditorBrowsableState.Advanced)]
1703 public static Graphics FromHdc (IntPtr hdc, IntPtr hdevice)
1705 throw new NotImplementedException ();
1708 [EditorBrowsable (EditorBrowsableState.Advanced)]
1709 [SecurityPermission (SecurityAction.LinkDemand, UnmanagedCode = true)]
1710 public static Graphics FromHdcInternal (IntPtr hdc)
1712 GDIPlus.Display = hdc;
1716 [EditorBrowsable (EditorBrowsableState.Advanced)]
1717 public static Graphics FromHwnd (IntPtr hwnd)
1721 if (GDIPlus.UseCocoaDrawable) {
1722 CocoaContext context = MacSupport.GetCGContextForNSView (hwnd);
1723 GDIPlus.GdipCreateFromContext_macosx (context.ctx, context.width, context.height, out graphics);
1725 Graphics g = new Graphics (graphics);
1726 g.maccontext = context;
1731 if (GDIPlus.UseCarbonDrawable) {
1732 CarbonContext context = MacSupport.GetCGContextForView (hwnd);
1733 GDIPlus.GdipCreateFromContext_macosx (context.ctx, context.width, context.height, out graphics);
1735 Graphics g = new Graphics (graphics);
1736 g.maccontext = context;
1740 if (GDIPlus.UseX11Drawable) {
1741 if (GDIPlus.Display == IntPtr.Zero) {
1742 GDIPlus.Display = GDIPlus.XOpenDisplay (IntPtr.Zero);
1743 if (GDIPlus.Display == IntPtr.Zero)
1744 throw new NotSupportedException ("Could not open display (X-Server required. Check you DISPLAY environment variable)");
1746 if (hwnd == IntPtr.Zero) {
1747 hwnd = GDIPlus.XRootWindow (GDIPlus.Display, GDIPlus.XDefaultScreen (GDIPlus.Display));
1750 return FromXDrawable (hwnd, GDIPlus.Display);
1754 Status status = GDIPlus.GdipCreateFromHWND (hwnd, out graphics);
1755 GDIPlus.CheckStatus (status);
1757 return new Graphics (graphics);
1760 [EditorBrowsable (EditorBrowsableState.Advanced)]
1761 [SecurityPermission (SecurityAction.LinkDemand, UnmanagedCode = true)]
1762 public static Graphics FromHwndInternal (IntPtr hwnd)
1764 return FromHwnd (hwnd);
1767 public static Graphics FromImage (Image image)
1772 throw new ArgumentNullException ("image");
1774 if ((image.PixelFormat & PixelFormat.Indexed) != 0)
1775 throw new Exception (Locale.GetText ("Cannot create Graphics from an indexed bitmap."));
1777 Status status = GDIPlus.GdipGetImageGraphicsContext (image.nativeObject, out graphics);
1778 GDIPlus.CheckStatus (status);
1779 Graphics result = new Graphics (graphics);
1781 if (GDIPlus.RunningOnUnix ()) {
1782 Rectangle rect = new Rectangle (0,0, image.Width, image.Height);
1783 GDIPlus.GdipSetVisibleClip_linux (result.NativeObject, ref rect);
1789 internal static Graphics FromXDrawable (IntPtr drawable, IntPtr display)
1793 Status s = GDIPlus.GdipCreateFromXDrawable_linux (drawable, display, out graphics);
1794 GDIPlus.CheckStatus (s);
1795 return new Graphics (graphics);
1799 public static IntPtr GetHalftonePalette ()
1801 throw new NotImplementedException ();
1805 [EditorBrowsable (EditorBrowsableState.Advanced)]
1807 public IntPtr GetHdc ()
1809 GDIPlus.CheckStatus (GDIPlus.GdipGetDC (this.nativeObject, out deviceContextHdc));
1810 return deviceContextHdc;
1813 public Color GetNearestColor (Color color)
1817 Status status = GDIPlus.GdipGetNearestColor (nativeObject, out argb);
1818 GDIPlus.CheckStatus (status);
1820 return Color.FromArgb (argb);
1824 public void IntersectClip (Region region)
1827 throw new ArgumentNullException ("region");
1828 Status status = GDIPlus.GdipSetClipRegion (nativeObject, region.NativeObject, CombineMode.Intersect);
1829 GDIPlus.CheckStatus (status);
1832 public void IntersectClip (RectangleF rect)
1834 Status status = GDIPlus.GdipSetClipRect (nativeObject, rect.X, rect.Y, rect.Width, rect.Height, CombineMode.Intersect);
1835 GDIPlus.CheckStatus (status);
1838 public void IntersectClip (Rectangle rect)
1840 Status status = GDIPlus.GdipSetClipRectI (nativeObject, rect.X, rect.Y, rect.Width, rect.Height, CombineMode.Intersect);
1841 GDIPlus.CheckStatus (status);
1844 public bool IsVisible (Point point)
1846 bool isVisible = false;
1848 Status status = GDIPlus.GdipIsVisiblePointI (nativeObject, point.X, point.Y, out isVisible);
1849 GDIPlus.CheckStatus (status);
1855 public bool IsVisible (RectangleF rect)
1857 bool isVisible = false;
1859 Status status = GDIPlus.GdipIsVisibleRect (nativeObject, rect.X, rect.Y, rect.Width, rect.Height, out isVisible);
1860 GDIPlus.CheckStatus (status);
1865 public bool IsVisible (PointF point)
1867 bool isVisible = false;
1869 Status status = GDIPlus.GdipIsVisiblePoint (nativeObject, point.X, point.Y, out isVisible);
1870 GDIPlus.CheckStatus (status);
1875 public bool IsVisible (Rectangle rect)
1877 bool isVisible = false;
1879 Status status = GDIPlus.GdipIsVisibleRectI (nativeObject, rect.X, rect.Y, rect.Width, rect.Height, out isVisible);
1880 GDIPlus.CheckStatus (status);
1885 public bool IsVisible (float x, float y)
1887 return IsVisible (new PointF (x, y));
1890 public bool IsVisible (int x, int y)
1892 return IsVisible (new Point (x, y));
1895 public bool IsVisible (float x, float y, float width, float height)
1897 return IsVisible (new RectangleF (x, y, width, height));
1901 public bool IsVisible (int x, int y, int width, int height)
1903 return IsVisible (new Rectangle (x, y, width, height));
1907 public Region[] MeasureCharacterRanges (string text, Font font, RectangleF layoutRect, StringFormat stringFormat)
1909 if ((text == null) || (text.Length == 0))
1910 return new Region [0];
1913 throw new ArgumentNullException ("font");
1915 if (stringFormat == null)
1916 throw new ArgumentException ("stringFormat");
1918 int regcount = stringFormat.GetMeasurableCharacterRangeCount ();
1920 return new Region[0];
1922 IntPtr[] native_regions = new IntPtr [regcount];
1923 Region[] regions = new Region [regcount];
1925 for (int i = 0; i < regcount; i++) {
1926 regions[i] = new Region ();
1927 native_regions[i] = regions[i].NativeObject;
1930 Status status = GDIPlus.GdipMeasureCharacterRanges (nativeObject, text, text.Length,
1931 font.NativeObject, ref layoutRect, stringFormat.NativeObject, regcount, out native_regions[0]);
1932 GDIPlus.CheckStatus (status);
1937 private unsafe SizeF GdipMeasureString (IntPtr graphics, string text, Font font, ref RectangleF layoutRect,
1938 IntPtr stringFormat)
1940 if ((text == null) || (text.Length == 0))
1944 throw new ArgumentNullException ("font");
1946 RectangleF boundingBox = new RectangleF ();
1948 Status status = GDIPlus.GdipMeasureString (nativeObject, text, text.Length, font.NativeObject,
1949 ref layoutRect, stringFormat, out boundingBox, null, null);
1950 GDIPlus.CheckStatus (status);
1952 return new SizeF (boundingBox.Width, boundingBox.Height);
1955 public SizeF MeasureString (string text, Font font)
1957 return MeasureString (text, font, SizeF.Empty);
1960 public SizeF MeasureString (string text, Font font, SizeF layoutArea)
1962 RectangleF rect = new RectangleF (0, 0, layoutArea.Width, layoutArea.Height);
1963 return GdipMeasureString (nativeObject, text, font, ref rect, IntPtr.Zero);
1966 public SizeF MeasureString (string text, Font font, int width)
1968 RectangleF rect = new RectangleF (0, 0, width, Int32.MaxValue);
1969 return GdipMeasureString (nativeObject, text, font, ref rect, IntPtr.Zero);
1972 public SizeF MeasureString (string text, Font font, SizeF layoutArea, StringFormat stringFormat)
1974 RectangleF rect = new RectangleF (0, 0, layoutArea.Width, layoutArea.Height);
1975 IntPtr format = (stringFormat == null) ? IntPtr.Zero : stringFormat.NativeObject;
1976 return GdipMeasureString (nativeObject, text, font, ref rect, format);
1979 public SizeF MeasureString (string text, Font font, int width, StringFormat format)
1981 RectangleF rect = new RectangleF (0, 0, width, Int32.MaxValue);
1982 IntPtr stringFormat = (format == null) ? IntPtr.Zero : format.NativeObject;
1983 return GdipMeasureString (nativeObject, text, font, ref rect, stringFormat);
1986 public SizeF MeasureString (string text, Font font, PointF origin, StringFormat stringFormat)
1988 RectangleF rect = new RectangleF (origin.X, origin.Y, 0, 0);
1989 IntPtr format = (stringFormat == null) ? IntPtr.Zero : stringFormat.NativeObject;
1990 return GdipMeasureString (nativeObject, text, font, ref rect, format);
1993 public SizeF MeasureString (string text, Font font, SizeF layoutArea, StringFormat stringFormat,
1994 out int charactersFitted, out int linesFilled)
1996 charactersFitted = 0;
1999 if ((text == null) || (text.Length == 0))
2003 throw new ArgumentNullException ("font");
2005 RectangleF boundingBox = new RectangleF ();
2006 RectangleF rect = new RectangleF (0, 0, layoutArea.Width, layoutArea.Height);
2008 IntPtr format = (stringFormat == null) ? IntPtr.Zero : stringFormat.NativeObject;
2011 fixed (int* pc = &charactersFitted, pl = &linesFilled) {
2012 Status status = GDIPlus.GdipMeasureString (nativeObject, text, text.Length,
2013 font.NativeObject, ref rect, format, out boundingBox, pc, pl);
2014 GDIPlus.CheckStatus (status);
2017 return new SizeF (boundingBox.Width, boundingBox.Height);
2020 public void MultiplyTransform (Matrix matrix)
2022 MultiplyTransform (matrix, MatrixOrder.Prepend);
2025 public void MultiplyTransform (Matrix matrix, MatrixOrder order)
2028 throw new ArgumentNullException ("matrix");
2030 Status status = GDIPlus.GdipMultiplyWorldTransform (nativeObject, matrix.nativeMatrix, order);
2031 GDIPlus.CheckStatus (status);
2034 [EditorBrowsable (EditorBrowsableState.Advanced)]
2035 [SecurityPermission (SecurityAction.Demand, UnmanagedCode = true)]
2036 public void ReleaseHdc (IntPtr hdc)
2038 ReleaseHdcInternal (hdc);
2042 [SecurityPermission (SecurityAction.LinkDemand, UnmanagedCode = true)]
2043 public void ReleaseHdc ()
2045 ReleaseHdcInternal (deviceContextHdc);
2049 [MonoLimitation ("Can only be used when hdc was provided by Graphics.GetHdc() method")]
2051 [EditorBrowsable (EditorBrowsableState.Never)]
2053 [EditorBrowsable (EditorBrowsableState.Advanced)]
2055 [SecurityPermission (SecurityAction.LinkDemand, UnmanagedCode = true)]
2056 public void ReleaseHdcInternal (IntPtr hdc)
2058 Status status = Status.InvalidParameter;
2059 if (hdc == deviceContextHdc) {
2060 status = GDIPlus.GdipReleaseDC (nativeObject, deviceContextHdc);
2061 deviceContextHdc = IntPtr.Zero;
2063 GDIPlus.CheckStatus (status);
2066 public void ResetClip ()
2068 Status status = GDIPlus.GdipResetClip (nativeObject);
2069 GDIPlus.CheckStatus (status);
2072 public void ResetTransform ()
2074 Status status = GDIPlus.GdipResetWorldTransform (nativeObject);
2075 GDIPlus.CheckStatus (status);
2078 public void Restore (GraphicsState gstate)
2080 // the possible NRE thrown by gstate.nativeState match MS behaviour
2081 Status status = GDIPlus.GdipRestoreGraphics (nativeObject, gstate.nativeState);
2082 GDIPlus.CheckStatus (status);
2085 public void RotateTransform (float angle)
2087 RotateTransform (angle, MatrixOrder.Prepend);
2090 public void RotateTransform (float angle, MatrixOrder order)
2092 Status status = GDIPlus.GdipRotateWorldTransform (nativeObject, angle, order);
2093 GDIPlus.CheckStatus (status);
2096 public GraphicsState Save ()
2099 Status status = GDIPlus.GdipSaveGraphics (nativeObject, out saveState);
2100 GDIPlus.CheckStatus (status);
2102 GraphicsState state = new GraphicsState ();
2103 state.nativeState = saveState;
2107 public void ScaleTransform (float sx, float sy)
2109 ScaleTransform (sx, sy, MatrixOrder.Prepend);
2112 public void ScaleTransform (float sx, float sy, MatrixOrder order)
2114 Status status = GDIPlus.GdipScaleWorldTransform (nativeObject, sx, sy, order);
2115 GDIPlus.CheckStatus (status);
2119 public void SetClip (RectangleF rect)
2121 SetClip (rect, CombineMode.Replace);
2125 public void SetClip (GraphicsPath path)
2127 SetClip (path, CombineMode.Replace);
2131 public void SetClip (Rectangle rect)
2133 SetClip (rect, CombineMode.Replace);
2137 public void SetClip (Graphics g)
2139 SetClip (g, CombineMode.Replace);
2143 public void SetClip (Graphics g, CombineMode combineMode)
2146 throw new ArgumentNullException ("g");
2148 Status status = GDIPlus.GdipSetClipGraphics (nativeObject, g.NativeObject, combineMode);
2149 GDIPlus.CheckStatus (status);
2153 public void SetClip (Rectangle rect, CombineMode combineMode)
2155 Status status = GDIPlus.GdipSetClipRectI (nativeObject, rect.X, rect.Y, rect.Width, rect.Height, combineMode);
2156 GDIPlus.CheckStatus (status);
2160 public void SetClip (RectangleF rect, CombineMode combineMode)
2162 Status status = GDIPlus.GdipSetClipRect (nativeObject, rect.X, rect.Y, rect.Width, rect.Height, combineMode);
2163 GDIPlus.CheckStatus (status);
2167 public void SetClip (Region region, CombineMode combineMode)
2170 throw new ArgumentNullException ("region");
2171 Status status = GDIPlus.GdipSetClipRegion(nativeObject, region.NativeObject, combineMode);
2172 GDIPlus.CheckStatus (status);
2176 public void SetClip (GraphicsPath path, CombineMode combineMode)
2179 throw new ArgumentNullException ("path");
2180 Status status = GDIPlus.GdipSetClipPath (nativeObject, path.NativeObject, combineMode);
2181 GDIPlus.CheckStatus (status);
2185 public void TransformPoints (CoordinateSpace destSpace, CoordinateSpace srcSpace, PointF [] pts)
2188 throw new ArgumentNullException ("pts");
2190 IntPtr ptrPt = GDIPlus.FromPointToUnManagedMemory (pts);
2192 Status status = GDIPlus.GdipTransformPoints (nativeObject, destSpace, srcSpace, ptrPt, pts.Length);
2193 GDIPlus.CheckStatus (status);
2195 GDIPlus.FromUnManagedMemoryToPoint (ptrPt, pts);
2199 public void TransformPoints (CoordinateSpace destSpace, CoordinateSpace srcSpace, Point [] pts)
2202 throw new ArgumentNullException ("pts");
2203 IntPtr ptrPt = GDIPlus.FromPointToUnManagedMemoryI (pts);
2205 Status status = GDIPlus.GdipTransformPointsI (nativeObject, destSpace, srcSpace, ptrPt, pts.Length);
2206 GDIPlus.CheckStatus (status);
2208 GDIPlus.FromUnManagedMemoryToPointI (ptrPt, pts);
2212 public void TranslateClip (int dx, int dy)
2214 Status status = GDIPlus.GdipTranslateClipI (nativeObject, dx, dy);
2215 GDIPlus.CheckStatus (status);
2219 public void TranslateClip (float dx, float dy)
2221 Status status = GDIPlus.GdipTranslateClip (nativeObject, dx, dy);
2222 GDIPlus.CheckStatus (status);
2225 public void TranslateTransform (float dx, float dy)
2227 TranslateTransform (dx, dy, MatrixOrder.Prepend);
2231 public void TranslateTransform (float dx, float dy, MatrixOrder order)
2233 Status status = GDIPlus.GdipTranslateWorldTransform (nativeObject, dx, dy, order);
2234 GDIPlus.CheckStatus (status);
2237 public Region Clip {
2239 Region reg = new Region();
2240 Status status = GDIPlus.GdipGetClip (nativeObject, reg.NativeObject);
2241 GDIPlus.CheckStatus (status);
2245 SetClip (value, CombineMode.Replace);
2249 public RectangleF ClipBounds {
2251 RectangleF rect = new RectangleF ();
2252 Status status = GDIPlus.GdipGetClipBounds (nativeObject, out rect);
2253 GDIPlus.CheckStatus (status);
2258 public CompositingMode CompositingMode {
2260 CompositingMode mode;
2261 Status status = GDIPlus.GdipGetCompositingMode (nativeObject, out mode);
2262 GDIPlus.CheckStatus (status);
2267 Status status = GDIPlus.GdipSetCompositingMode (nativeObject, value);
2268 GDIPlus.CheckStatus (status);
2273 public CompositingQuality CompositingQuality {
2275 CompositingQuality quality;
2277 Status status = GDIPlus.GdipGetCompositingQuality (nativeObject, out quality);
2278 GDIPlus.CheckStatus (status);
2282 Status status = GDIPlus.GdipSetCompositingQuality (nativeObject, value);
2283 GDIPlus.CheckStatus (status);
2291 Status status = GDIPlus.GdipGetDpiX (nativeObject, out x);
2292 GDIPlus.CheckStatus (status);
2301 Status status = GDIPlus.GdipGetDpiY (nativeObject, out y);
2302 GDIPlus.CheckStatus (status);
2307 public InterpolationMode InterpolationMode {
2309 InterpolationMode imode = InterpolationMode.Invalid;
2310 Status status = GDIPlus.GdipGetInterpolationMode (nativeObject, out imode);
2311 GDIPlus.CheckStatus (status);
2315 Status status = GDIPlus.GdipSetInterpolationMode (nativeObject, value);
2316 GDIPlus.CheckStatus (status);
2320 public bool IsClipEmpty {
2322 bool isEmpty = false;
2324 Status status = GDIPlus.GdipIsClipEmpty (nativeObject, out isEmpty);
2325 GDIPlus.CheckStatus (status);
2330 public bool IsVisibleClipEmpty {
2332 bool isEmpty = false;
2334 Status status = GDIPlus.GdipIsVisibleClipEmpty (nativeObject, out isEmpty);
2335 GDIPlus.CheckStatus (status);
2340 public float PageScale {
2344 Status status = GDIPlus.GdipGetPageScale (nativeObject, out scale);
2345 GDIPlus.CheckStatus (status);
2349 Status status = GDIPlus.GdipSetPageScale (nativeObject, value);
2350 GDIPlus.CheckStatus (status);
2354 public GraphicsUnit PageUnit {
2358 Status status = GDIPlus.GdipGetPageUnit (nativeObject, out unit);
2359 GDIPlus.CheckStatus (status);
2363 Status status = GDIPlus.GdipSetPageUnit (nativeObject, value);
2364 GDIPlus.CheckStatus (status);
2368 [MonoTODO ("This property does not do anything when used with libgdiplus.")]
2369 public PixelOffsetMode PixelOffsetMode {
2371 PixelOffsetMode pixelOffset = PixelOffsetMode.Invalid;
2373 Status status = GDIPlus.GdipGetPixelOffsetMode (nativeObject, out pixelOffset);
2374 GDIPlus.CheckStatus (status);
2378 Status status = GDIPlus.GdipSetPixelOffsetMode (nativeObject, value);
2379 GDIPlus.CheckStatus (status);
2383 public Point RenderingOrigin {
2386 Status status = GDIPlus.GdipGetRenderingOrigin (nativeObject, out x, out y);
2387 GDIPlus.CheckStatus (status);
2388 return new Point (x, y);
2392 Status status = GDIPlus.GdipSetRenderingOrigin (nativeObject, value.X, value.Y);
2393 GDIPlus.CheckStatus (status);
2397 public SmoothingMode SmoothingMode {
2399 SmoothingMode mode = SmoothingMode.Invalid;
2401 Status status = GDIPlus.GdipGetSmoothingMode (nativeObject, out mode);
2402 GDIPlus.CheckStatus (status);
2407 Status status = GDIPlus.GdipSetSmoothingMode (nativeObject, value);
2408 GDIPlus.CheckStatus (status);
2412 [MonoTODO ("This property does not do anything when used with libgdiplus.")]
2413 public int TextContrast {
2417 Status status = GDIPlus.GdipGetTextContrast (nativeObject, out contrast);
2418 GDIPlus.CheckStatus (status);
2423 Status status = GDIPlus.GdipSetTextContrast (nativeObject, value);
2424 GDIPlus.CheckStatus (status);
2428 public TextRenderingHint TextRenderingHint {
2430 TextRenderingHint hint;
2432 Status status = GDIPlus.GdipGetTextRenderingHint (nativeObject, out hint);
2433 GDIPlus.CheckStatus (status);
2438 Status status = GDIPlus.GdipSetTextRenderingHint (nativeObject, value);
2439 GDIPlus.CheckStatus (status);
2443 public Matrix Transform {
2445 Matrix matrix = new Matrix ();
2446 Status status = GDIPlus.GdipGetWorldTransform (nativeObject, matrix.nativeMatrix);
2447 GDIPlus.CheckStatus (status);
2452 throw new ArgumentNullException ("value");
2454 Status status = GDIPlus.GdipSetWorldTransform (nativeObject, value.nativeMatrix);
2455 GDIPlus.CheckStatus (status);
2459 public RectangleF VisibleClipBounds {
2463 Status status = GDIPlus.GdipGetVisibleClipBounds (nativeObject, out rect);
2464 GDIPlus.CheckStatus (status);
2471 [EditorBrowsable (EditorBrowsableState.Never)]
2472 public object GetContextInfo ()
2474 // only known source of information @ http://blogs.wdevs.com/jdunlap/Default.aspx
2475 throw new NotImplementedException ();