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 if (!float.IsNaN(x1) && !float.IsNaN(y1) &&
1033 !float.IsNaN(x2) && !float.IsNaN(y2)) {
1034 Status status = GDIPlus.GdipDrawLine (nativeObject, pen.nativeObject, x1, y1, x2, y2);
1035 GDIPlus.CheckStatus (status);
1039 public void DrawLines (Pen pen, PointF [] points)
1042 throw new ArgumentNullException ("pen");
1044 throw new ArgumentNullException ("points");
1045 Status status = GDIPlus.GdipDrawLines (nativeObject, pen.nativeObject, points, points.Length);
1046 GDIPlus.CheckStatus (status);
1049 public void DrawLines (Pen pen, Point [] points)
1052 throw new ArgumentNullException ("pen");
1054 throw new ArgumentNullException ("points");
1055 Status status = GDIPlus.GdipDrawLinesI (nativeObject, pen.nativeObject, points, points.Length);
1056 GDIPlus.CheckStatus (status);
1059 public void DrawPath (Pen pen, GraphicsPath path)
1062 throw new ArgumentNullException ("pen");
1064 throw new ArgumentNullException ("path");
1065 Status status = GDIPlus.GdipDrawPath (nativeObject, pen.nativeObject, path.nativePath);
1066 GDIPlus.CheckStatus (status);
1069 public void DrawPie (Pen pen, Rectangle rect, float startAngle, float sweepAngle)
1072 throw new ArgumentNullException ("pen");
1073 DrawPie (pen, rect.X, rect.Y, rect.Width, rect.Height, startAngle, sweepAngle);
1076 public void DrawPie (Pen pen, RectangleF rect, float startAngle, float sweepAngle)
1079 throw new ArgumentNullException ("pen");
1080 DrawPie (pen, rect.X, rect.Y, rect.Width, rect.Height, startAngle, sweepAngle);
1083 public void DrawPie (Pen pen, float x, float y, float width, float height, float startAngle, float sweepAngle)
1086 throw new ArgumentNullException ("pen");
1087 Status status = GDIPlus.GdipDrawPie (nativeObject, pen.nativeObject, x, y, width, height, startAngle, sweepAngle);
1088 GDIPlus.CheckStatus (status);
1091 // Microsoft documentation states that the signature for this member should be
1092 // public void DrawPie(Pen pen, int x, int y, int width, int height, int startAngle
1093 // int sweepAngle. However, GdipDrawPieI uses also float for the startAngle and sweepAngle params
1094 public void DrawPie (Pen pen, int x, int y, int width, int height, int startAngle, int sweepAngle)
1097 throw new ArgumentNullException ("pen");
1098 Status status = GDIPlus.GdipDrawPieI (nativeObject, pen.nativeObject, x, y, width, height, startAngle, sweepAngle);
1099 GDIPlus.CheckStatus (status);
1102 public void DrawPolygon (Pen pen, Point [] points)
1105 throw new ArgumentNullException ("pen");
1107 throw new ArgumentNullException ("points");
1108 Status status = GDIPlus.GdipDrawPolygonI (nativeObject, pen.nativeObject, points, points.Length);
1109 GDIPlus.CheckStatus (status);
1112 public void DrawPolygon (Pen pen, PointF [] points)
1115 throw new ArgumentNullException ("pen");
1117 throw new ArgumentNullException ("points");
1118 Status status = GDIPlus.GdipDrawPolygon (nativeObject, pen.nativeObject, points, points.Length);
1119 GDIPlus.CheckStatus (status);
1122 public void DrawRectangle (Pen pen, Rectangle rect)
1125 throw new ArgumentNullException ("pen");
1126 DrawRectangle (pen, rect.Left, rect.Top, rect.Width, rect.Height);
1129 public void DrawRectangle (Pen pen, float x, float y, float width, float height)
1132 throw new ArgumentNullException ("pen");
1133 Status status = GDIPlus.GdipDrawRectangle (nativeObject, pen.nativeObject, x, y, width, height);
1134 GDIPlus.CheckStatus (status);
1137 public void DrawRectangle (Pen pen, int x, int y, int width, int height)
1140 throw new ArgumentNullException ("pen");
1141 Status status = GDIPlus.GdipDrawRectangleI (nativeObject, pen.nativeObject, x, y, width, height);
1142 GDIPlus.CheckStatus (status);
1145 public void DrawRectangles (Pen pen, RectangleF [] rects)
1148 throw new ArgumentNullException ("image");
1150 throw new ArgumentNullException ("rects");
1151 Status status = GDIPlus.GdipDrawRectangles (nativeObject, pen.nativeObject, rects, rects.Length);
1152 GDIPlus.CheckStatus (status);
1155 public void DrawRectangles (Pen pen, Rectangle [] rects)
1158 throw new ArgumentNullException ("image");
1160 throw new ArgumentNullException ("rects");
1161 Status status = GDIPlus.GdipDrawRectanglesI (nativeObject, pen.nativeObject, rects, rects.Length);
1162 GDIPlus.CheckStatus (status);
1165 public void DrawString (string s, Font font, Brush brush, RectangleF layoutRectangle)
1167 DrawString (s, font, brush, layoutRectangle, null);
1170 public void DrawString (string s, Font font, Brush brush, PointF point)
1172 DrawString (s, font, brush, new RectangleF (point.X, point.Y, 0, 0), null);
1175 public void DrawString (string s, Font font, Brush brush, PointF point, StringFormat format)
1177 DrawString(s, font, brush, new RectangleF(point.X, point.Y, 0, 0), format);
1180 public void DrawString (string s, Font font, Brush brush, float x, float y)
1182 DrawString (s, font, brush, new RectangleF (x, y, 0, 0), null);
1185 public void DrawString (string s, Font font, Brush brush, float x, float y, StringFormat format)
1187 DrawString (s, font, brush, new RectangleF(x, y, 0, 0), format);
1190 public void DrawString (string s, Font font, Brush brush, RectangleF layoutRectangle, StringFormat format)
1193 throw new ArgumentNullException ("font");
1195 throw new ArgumentNullException ("brush");
1196 if (s == null || s.Length == 0)
1199 Status status = GDIPlus.GdipDrawString (nativeObject, s, s.Length, font.NativeObject, ref layoutRectangle, format != null ? format.NativeObject : IntPtr.Zero, brush.nativeObject);
1200 GDIPlus.CheckStatus (status);
1203 public void EndContainer (GraphicsContainer container)
1206 if (container == null)
1207 throw new ArgumentNullException ("container");
1209 Status status = GDIPlus.GdipEndContainer(nativeObject, container.NativeObject);
1210 GDIPlus.CheckStatus (status);
1213 private const string MetafileEnumeration = "Metafiles enumeration, for both WMF and EMF formats, isn't supported.";
1215 [MonoTODO (MetafileEnumeration)]
1216 public void EnumerateMetafile (Metafile metafile, Point [] destPoints, EnumerateMetafileProc callback)
1218 throw new NotImplementedException ();
1221 [MonoTODO (MetafileEnumeration)]
1222 public void EnumerateMetafile (Metafile metafile, RectangleF destRect, EnumerateMetafileProc callback)
1224 throw new NotImplementedException ();
1227 [MonoTODO (MetafileEnumeration)]
1228 public void EnumerateMetafile (Metafile metafile, PointF [] destPoints, EnumerateMetafileProc callback)
1230 throw new NotImplementedException ();
1233 [MonoTODO (MetafileEnumeration)]
1234 public void EnumerateMetafile (Metafile metafile, Rectangle destRect, EnumerateMetafileProc callback)
1236 throw new NotImplementedException ();
1239 [MonoTODO (MetafileEnumeration)]
1240 public void EnumerateMetafile (Metafile metafile, Point destPoint, EnumerateMetafileProc callback)
1242 throw new NotImplementedException ();
1245 [MonoTODO (MetafileEnumeration)]
1246 public void EnumerateMetafile (Metafile metafile, PointF destPoint, EnumerateMetafileProc callback)
1248 throw new NotImplementedException ();
1251 [MonoTODO (MetafileEnumeration)]
1252 public void EnumerateMetafile (Metafile metafile, PointF destPoint, EnumerateMetafileProc callback, IntPtr callbackData)
1254 throw new NotImplementedException ();
1257 [MonoTODO (MetafileEnumeration)]
1258 public void EnumerateMetafile (Metafile metafile, Rectangle destRect, EnumerateMetafileProc callback, IntPtr callbackData)
1260 throw new NotImplementedException ();
1263 [MonoTODO (MetafileEnumeration)]
1264 public void EnumerateMetafile (Metafile metafile, PointF [] destPoints, EnumerateMetafileProc callback, IntPtr callbackData)
1266 throw new NotImplementedException ();
1269 [MonoTODO (MetafileEnumeration)]
1270 public void EnumerateMetafile (Metafile metafile, Point destPoint, EnumerateMetafileProc callback, IntPtr callbackData)
1272 throw new NotImplementedException ();
1275 [MonoTODO (MetafileEnumeration)]
1276 public void EnumerateMetafile (Metafile metafile, Point [] destPoints, EnumerateMetafileProc callback, IntPtr callbackData)
1278 throw new NotImplementedException ();
1281 [MonoTODO (MetafileEnumeration)]
1282 public void EnumerateMetafile (Metafile metafile, RectangleF destRect, EnumerateMetafileProc callback, IntPtr callbackData)
1284 throw new NotImplementedException ();
1287 [MonoTODO (MetafileEnumeration)]
1288 public void EnumerateMetafile (Metafile metafile, PointF destPoint, RectangleF srcRect, GraphicsUnit srcUnit, EnumerateMetafileProc callback)
1290 throw new NotImplementedException ();
1293 [MonoTODO (MetafileEnumeration)]
1294 public void EnumerateMetafile (Metafile metafile, Point destPoint, Rectangle srcRect, GraphicsUnit srcUnit, EnumerateMetafileProc callback)
1296 throw new NotImplementedException ();
1299 [MonoTODO (MetafileEnumeration)]
1300 public void EnumerateMetafile (Metafile metafile, PointF [] destPoints, RectangleF srcRect, GraphicsUnit srcUnit, EnumerateMetafileProc callback)
1302 throw new NotImplementedException ();
1305 [MonoTODO (MetafileEnumeration)]
1306 public void EnumerateMetafile (Metafile metafile, Point [] destPoints, Rectangle srcRect, GraphicsUnit srcUnit, EnumerateMetafileProc callback)
1308 throw new NotImplementedException ();
1311 [MonoTODO (MetafileEnumeration)]
1312 public void EnumerateMetafile (Metafile metafile, RectangleF destRect, RectangleF srcRect, GraphicsUnit srcUnit, EnumerateMetafileProc callback)
1314 throw new NotImplementedException ();
1317 [MonoTODO (MetafileEnumeration)]
1318 public void EnumerateMetafile (Metafile metafile, Rectangle destRect, Rectangle srcRect, GraphicsUnit srcUnit, EnumerateMetafileProc callback)
1320 throw new NotImplementedException ();
1323 [MonoTODO (MetafileEnumeration)]
1324 public void EnumerateMetafile (Metafile metafile, RectangleF destRect, EnumerateMetafileProc callback, IntPtr callbackData, ImageAttributes imageAttr)
1326 throw new NotImplementedException ();
1329 [MonoTODO (MetafileEnumeration)]
1330 public void EnumerateMetafile (Metafile metafile, Point destPoint, EnumerateMetafileProc callback, IntPtr callbackData, ImageAttributes imageAttr)
1332 throw new NotImplementedException ();
1335 [MonoTODO (MetafileEnumeration)]
1336 public void EnumerateMetafile (Metafile metafile, PointF destPoint, EnumerateMetafileProc callback, IntPtr callbackData, ImageAttributes imageAttr)
1338 throw new NotImplementedException ();
1341 [MonoTODO (MetafileEnumeration)]
1342 public void EnumerateMetafile (Metafile metafile, Point [] destPoints, EnumerateMetafileProc callback, IntPtr callbackData, ImageAttributes imageAttr)
1344 throw new NotImplementedException ();
1347 [MonoTODO (MetafileEnumeration)]
1348 public void EnumerateMetafile (Metafile metafile, PointF [] destPoints, EnumerateMetafileProc callback, IntPtr callbackData, ImageAttributes imageAttr)
1350 throw new NotImplementedException ();
1353 [MonoTODO (MetafileEnumeration)]
1354 public void EnumerateMetafile (Metafile metafile, Rectangle destRect, EnumerateMetafileProc callback, IntPtr callbackData, ImageAttributes imageAttr)
1356 throw new NotImplementedException ();
1359 [MonoTODO (MetafileEnumeration)]
1360 public void EnumerateMetafile (Metafile metafile, Rectangle destRect, Rectangle srcRect, GraphicsUnit srcUnit, EnumerateMetafileProc callback, IntPtr callbackData)
1362 throw new NotImplementedException ();
1365 [MonoTODO (MetafileEnumeration)]
1366 public void EnumerateMetafile (Metafile metafile, PointF [] destPoints, RectangleF srcRect, GraphicsUnit srcUnit, EnumerateMetafileProc callback, IntPtr callbackData)
1368 throw new NotImplementedException ();
1371 [MonoTODO (MetafileEnumeration)]
1372 public void EnumerateMetafile (Metafile metafile, RectangleF destRect, RectangleF srcRect, GraphicsUnit srcUnit, EnumerateMetafileProc callback, IntPtr callbackData)
1374 throw new NotImplementedException ();
1377 [MonoTODO (MetafileEnumeration)]
1378 public void EnumerateMetafile (Metafile metafile, PointF destPoint, RectangleF srcRect, GraphicsUnit srcUnit, EnumerateMetafileProc callback, IntPtr callbackData)
1380 throw new NotImplementedException ();
1383 [MonoTODO (MetafileEnumeration)]
1384 public void EnumerateMetafile (Metafile metafile, Point destPoint, Rectangle srcRect, GraphicsUnit srcUnit, EnumerateMetafileProc callback, IntPtr callbackData)
1386 throw new NotImplementedException ();
1389 [MonoTODO (MetafileEnumeration)]
1390 public void EnumerateMetafile (Metafile metafile, Point [] destPoints, Rectangle srcRect, GraphicsUnit srcUnit, EnumerateMetafileProc callback, IntPtr callbackData)
1392 throw new NotImplementedException ();
1395 [MonoTODO (MetafileEnumeration)]
1396 public void EnumerateMetafile (Metafile metafile, Point [] destPoints, Rectangle srcRect, GraphicsUnit unit, EnumerateMetafileProc callback, IntPtr callbackData, ImageAttributes imageAttr)
1398 throw new NotImplementedException ();
1401 [MonoTODO (MetafileEnumeration)]
1402 public void EnumerateMetafile (Metafile metafile, Rectangle destRect, Rectangle srcRect, GraphicsUnit unit, EnumerateMetafileProc callback, IntPtr callbackData, ImageAttributes imageAttr)
1404 throw new NotImplementedException ();
1407 [MonoTODO (MetafileEnumeration)]
1408 public void EnumerateMetafile (Metafile metafile, Point destPoint, Rectangle srcRect, GraphicsUnit unit, EnumerateMetafileProc callback, IntPtr callbackData, ImageAttributes imageAttr)
1410 throw new NotImplementedException ();
1413 [MonoTODO (MetafileEnumeration)]
1414 public void EnumerateMetafile (Metafile metafile, RectangleF destRect, RectangleF srcRect, GraphicsUnit unit, EnumerateMetafileProc callback, IntPtr callbackData, ImageAttributes imageAttr)
1416 throw new NotImplementedException ();
1419 [MonoTODO (MetafileEnumeration)]
1420 public void EnumerateMetafile (Metafile metafile, PointF [] destPoints, RectangleF srcRect, GraphicsUnit unit, EnumerateMetafileProc callback, IntPtr callbackData, ImageAttributes imageAttr)
1422 throw new NotImplementedException ();
1425 [MonoTODO (MetafileEnumeration)]
1426 public void EnumerateMetafile (Metafile metafile, PointF destPoint, RectangleF srcRect, GraphicsUnit unit, EnumerateMetafileProc callback, IntPtr callbackData, ImageAttributes imageAttr)
1428 throw new NotImplementedException ();
1431 public void ExcludeClip (Rectangle rect)
1433 Status status = GDIPlus.GdipSetClipRectI (nativeObject, rect.X, rect.Y, rect.Width, rect.Height, CombineMode.Exclude);
1434 GDIPlus.CheckStatus (status);
1437 public void ExcludeClip (Region region)
1440 throw new ArgumentNullException ("region");
1441 Status status = GDIPlus.GdipSetClipRegion (nativeObject, region.NativeObject, CombineMode.Exclude);
1442 GDIPlus.CheckStatus (status);
1446 public void FillClosedCurve (Brush brush, PointF [] points)
1449 throw new ArgumentNullException ("brush");
1451 throw new ArgumentNullException ("points");
1452 Status status = GDIPlus.GdipFillClosedCurve (nativeObject, brush.NativeObject, points, points.Length);
1453 GDIPlus.CheckStatus (status);
1456 public void FillClosedCurve (Brush brush, Point [] points)
1459 throw new ArgumentNullException ("brush");
1461 throw new ArgumentNullException ("points");
1462 Status status = GDIPlus.GdipFillClosedCurveI (nativeObject, brush.NativeObject, points, points.Length);
1463 GDIPlus.CheckStatus (status);
1467 public void FillClosedCurve (Brush brush, PointF [] points, FillMode fillmode)
1470 throw new ArgumentNullException ("brush");
1472 throw new ArgumentNullException ("points");
1473 FillClosedCurve (brush, points, fillmode, 0.5f);
1476 public void FillClosedCurve (Brush brush, Point [] points, FillMode fillmode)
1479 throw new ArgumentNullException ("brush");
1481 throw new ArgumentNullException ("points");
1482 FillClosedCurve (brush, points, fillmode, 0.5f);
1485 public void FillClosedCurve (Brush brush, PointF [] points, FillMode fillmode, float tension)
1488 throw new ArgumentNullException ("brush");
1490 throw new ArgumentNullException ("points");
1491 Status status = GDIPlus.GdipFillClosedCurve2 (nativeObject, brush.NativeObject, points, points.Length, tension, fillmode);
1492 GDIPlus.CheckStatus (status);
1495 public void FillClosedCurve (Brush brush, Point [] points, FillMode fillmode, float tension)
1498 throw new ArgumentNullException ("brush");
1500 throw new ArgumentNullException ("points");
1501 Status status = GDIPlus.GdipFillClosedCurve2I (nativeObject, brush.NativeObject, points, points.Length, tension, fillmode);
1502 GDIPlus.CheckStatus (status);
1505 public void FillEllipse (Brush brush, Rectangle rect)
1508 throw new ArgumentNullException ("brush");
1509 FillEllipse (brush, rect.X, rect.Y, rect.Width, rect.Height);
1512 public void FillEllipse (Brush brush, RectangleF rect)
1515 throw new ArgumentNullException ("brush");
1516 FillEllipse (brush, rect.X, rect.Y, rect.Width, rect.Height);
1519 public void FillEllipse (Brush brush, float x, float y, float width, float height)
1522 throw new ArgumentNullException ("brush");
1523 Status status = GDIPlus.GdipFillEllipse (nativeObject, brush.nativeObject, x, y, width, height);
1524 GDIPlus.CheckStatus (status);
1527 public void FillEllipse (Brush brush, int x, int y, int width, int height)
1530 throw new ArgumentNullException ("brush");
1531 Status status = GDIPlus.GdipFillEllipseI (nativeObject, brush.nativeObject, x, y, width, height);
1532 GDIPlus.CheckStatus (status);
1535 public void FillPath (Brush brush, GraphicsPath path)
1538 throw new ArgumentNullException ("brush");
1540 throw new ArgumentNullException ("path");
1541 Status status = GDIPlus.GdipFillPath (nativeObject, brush.NativeObject, path.NativeObject);
1542 GDIPlus.CheckStatus (status);
1545 public void FillPie (Brush brush, Rectangle rect, float startAngle, float sweepAngle)
1548 throw new ArgumentNullException ("brush");
1549 Status status = GDIPlus.GdipFillPie (nativeObject, brush.NativeObject, rect.X, rect.Y, rect.Width, rect.Height, startAngle, sweepAngle);
1550 GDIPlus.CheckStatus (status);
1553 public void FillPie (Brush brush, int x, int y, int width, int height, int startAngle, int sweepAngle)
1556 throw new ArgumentNullException ("brush");
1557 Status status = GDIPlus.GdipFillPieI (nativeObject, brush.NativeObject, x, y, width, height, startAngle, sweepAngle);
1558 GDIPlus.CheckStatus (status);
1561 public void FillPie (Brush brush, float x, float y, float width, float height, float startAngle, float sweepAngle)
1564 throw new ArgumentNullException ("brush");
1565 Status status = GDIPlus.GdipFillPie (nativeObject, brush.NativeObject, x, y, width, height, startAngle, sweepAngle);
1566 GDIPlus.CheckStatus (status);
1569 public void FillPolygon (Brush brush, PointF [] points)
1572 throw new ArgumentNullException ("brush");
1574 throw new ArgumentNullException ("points");
1575 Status status = GDIPlus.GdipFillPolygon2 (nativeObject, brush.nativeObject, points, points.Length);
1576 GDIPlus.CheckStatus (status);
1579 public void FillPolygon (Brush brush, Point [] points)
1582 throw new ArgumentNullException ("brush");
1584 throw new ArgumentNullException ("points");
1585 Status status = GDIPlus.GdipFillPolygon2I (nativeObject, brush.nativeObject, points, points.Length);
1586 GDIPlus.CheckStatus (status);
1589 public void FillPolygon (Brush brush, Point [] points, FillMode fillMode)
1592 throw new ArgumentNullException ("brush");
1594 throw new ArgumentNullException ("points");
1595 Status status = GDIPlus.GdipFillPolygonI (nativeObject, brush.nativeObject, points, points.Length, fillMode);
1596 GDIPlus.CheckStatus (status);
1599 public void FillPolygon (Brush brush, PointF [] points, FillMode fillMode)
1602 throw new ArgumentNullException ("brush");
1604 throw new ArgumentNullException ("points");
1605 Status status = GDIPlus.GdipFillPolygon (nativeObject, brush.nativeObject, points, points.Length, fillMode);
1606 GDIPlus.CheckStatus (status);
1609 public void FillRectangle (Brush brush, RectangleF rect)
1612 throw new ArgumentNullException ("brush");
1613 FillRectangle (brush, rect.Left, rect.Top, rect.Width, rect.Height);
1616 public void FillRectangle (Brush brush, Rectangle rect)
1619 throw new ArgumentNullException ("brush");
1620 FillRectangle (brush, rect.Left, rect.Top, rect.Width, rect.Height);
1623 public void FillRectangle (Brush brush, int x, int y, int width, int height)
1626 throw new ArgumentNullException ("brush");
1628 Status status = GDIPlus.GdipFillRectangleI (nativeObject, brush.nativeObject, x, y, width, height);
1629 GDIPlus.CheckStatus (status);
1632 public void FillRectangle (Brush brush, float x, float y, float width, float height)
1635 throw new ArgumentNullException ("brush");
1637 Status status = GDIPlus.GdipFillRectangle (nativeObject, brush.nativeObject, x, y, width, height);
1638 GDIPlus.CheckStatus (status);
1641 public void FillRectangles (Brush brush, Rectangle [] rects)
1644 throw new ArgumentNullException ("brush");
1646 throw new ArgumentNullException ("rects");
1648 Status status = GDIPlus.GdipFillRectanglesI (nativeObject, brush.nativeObject, rects, rects.Length);
1649 GDIPlus.CheckStatus (status);
1652 public void FillRectangles (Brush brush, RectangleF [] rects)
1655 throw new ArgumentNullException ("brush");
1657 throw new ArgumentNullException ("rects");
1659 Status status = GDIPlus.GdipFillRectangles (nativeObject, brush.nativeObject, rects, rects.Length);
1660 GDIPlus.CheckStatus (status);
1664 public void FillRegion (Brush brush, Region region)
1667 throw new ArgumentNullException ("brush");
1669 throw new ArgumentNullException ("region");
1671 Status status = GDIPlus.GdipFillRegion (nativeObject, brush.NativeObject, region.NativeObject);
1672 GDIPlus.CheckStatus(status);
1676 public void Flush ()
1678 Flush (FlushIntention.Flush);
1682 public void Flush (FlushIntention intention)
1684 if (nativeObject == IntPtr.Zero) {
1688 Status status = GDIPlus.GdipFlush (nativeObject, intention);
1689 GDIPlus.CheckStatus (status);
1691 if (maccontext != null)
1692 maccontext.Synchronize ();
1695 [EditorBrowsable (EditorBrowsableState.Advanced)]
1696 public static Graphics FromHdc (IntPtr hdc)
1699 Status status = GDIPlus.GdipCreateFromHDC (hdc, out graphics);
1700 GDIPlus.CheckStatus (status);
1701 return new Graphics (graphics);
1705 [EditorBrowsable (EditorBrowsableState.Advanced)]
1706 public static Graphics FromHdc (IntPtr hdc, IntPtr hdevice)
1708 throw new NotImplementedException ();
1711 [EditorBrowsable (EditorBrowsableState.Advanced)]
1712 [SecurityPermission (SecurityAction.LinkDemand, UnmanagedCode = true)]
1713 public static Graphics FromHdcInternal (IntPtr hdc)
1715 GDIPlus.Display = hdc;
1719 [EditorBrowsable (EditorBrowsableState.Advanced)]
1720 public static Graphics FromHwnd (IntPtr hwnd)
1724 if (GDIPlus.UseCocoaDrawable) {
1725 CocoaContext context = MacSupport.GetCGContextForNSView (hwnd);
1726 GDIPlus.GdipCreateFromContext_macosx (context.ctx, context.width, context.height, out graphics);
1728 Graphics g = new Graphics (graphics);
1729 g.maccontext = context;
1734 if (GDIPlus.UseCarbonDrawable) {
1735 CarbonContext context = MacSupport.GetCGContextForView (hwnd);
1736 GDIPlus.GdipCreateFromContext_macosx (context.ctx, context.width, context.height, out graphics);
1738 Graphics g = new Graphics (graphics);
1739 g.maccontext = context;
1743 if (GDIPlus.UseX11Drawable) {
1744 if (GDIPlus.Display == IntPtr.Zero) {
1745 GDIPlus.Display = GDIPlus.XOpenDisplay (IntPtr.Zero);
1746 if (GDIPlus.Display == IntPtr.Zero)
1747 throw new NotSupportedException ("Could not open display (X-Server required. Check you DISPLAY environment variable)");
1749 if (hwnd == IntPtr.Zero) {
1750 hwnd = GDIPlus.XRootWindow (GDIPlus.Display, GDIPlus.XDefaultScreen (GDIPlus.Display));
1753 return FromXDrawable (hwnd, GDIPlus.Display);
1757 Status status = GDIPlus.GdipCreateFromHWND (hwnd, out graphics);
1758 GDIPlus.CheckStatus (status);
1760 return new Graphics (graphics);
1763 [EditorBrowsable (EditorBrowsableState.Advanced)]
1764 [SecurityPermission (SecurityAction.LinkDemand, UnmanagedCode = true)]
1765 public static Graphics FromHwndInternal (IntPtr hwnd)
1767 return FromHwnd (hwnd);
1770 public static Graphics FromImage (Image image)
1775 throw new ArgumentNullException ("image");
1777 if ((image.PixelFormat & PixelFormat.Indexed) != 0)
1778 throw new Exception (Locale.GetText ("Cannot create Graphics from an indexed bitmap."));
1780 Status status = GDIPlus.GdipGetImageGraphicsContext (image.nativeObject, out graphics);
1781 GDIPlus.CheckStatus (status);
1782 Graphics result = new Graphics (graphics);
1784 if (GDIPlus.RunningOnUnix ()) {
1785 Rectangle rect = new Rectangle (0,0, image.Width, image.Height);
1786 GDIPlus.GdipSetVisibleClip_linux (result.NativeObject, ref rect);
1792 internal static Graphics FromXDrawable (IntPtr drawable, IntPtr display)
1796 Status s = GDIPlus.GdipCreateFromXDrawable_linux (drawable, display, out graphics);
1797 GDIPlus.CheckStatus (s);
1798 return new Graphics (graphics);
1802 public static IntPtr GetHalftonePalette ()
1804 throw new NotImplementedException ();
1808 [EditorBrowsable (EditorBrowsableState.Advanced)]
1810 public IntPtr GetHdc ()
1812 GDIPlus.CheckStatus (GDIPlus.GdipGetDC (this.nativeObject, out deviceContextHdc));
1813 return deviceContextHdc;
1816 public Color GetNearestColor (Color color)
1820 Status status = GDIPlus.GdipGetNearestColor (nativeObject, out argb);
1821 GDIPlus.CheckStatus (status);
1823 return Color.FromArgb (argb);
1827 public void IntersectClip (Region region)
1830 throw new ArgumentNullException ("region");
1831 Status status = GDIPlus.GdipSetClipRegion (nativeObject, region.NativeObject, CombineMode.Intersect);
1832 GDIPlus.CheckStatus (status);
1835 public void IntersectClip (RectangleF rect)
1837 Status status = GDIPlus.GdipSetClipRect (nativeObject, rect.X, rect.Y, rect.Width, rect.Height, CombineMode.Intersect);
1838 GDIPlus.CheckStatus (status);
1841 public void IntersectClip (Rectangle rect)
1843 Status status = GDIPlus.GdipSetClipRectI (nativeObject, rect.X, rect.Y, rect.Width, rect.Height, CombineMode.Intersect);
1844 GDIPlus.CheckStatus (status);
1847 public bool IsVisible (Point point)
1849 bool isVisible = false;
1851 Status status = GDIPlus.GdipIsVisiblePointI (nativeObject, point.X, point.Y, out isVisible);
1852 GDIPlus.CheckStatus (status);
1858 public bool IsVisible (RectangleF rect)
1860 bool isVisible = false;
1862 Status status = GDIPlus.GdipIsVisibleRect (nativeObject, rect.X, rect.Y, rect.Width, rect.Height, out isVisible);
1863 GDIPlus.CheckStatus (status);
1868 public bool IsVisible (PointF point)
1870 bool isVisible = false;
1872 Status status = GDIPlus.GdipIsVisiblePoint (nativeObject, point.X, point.Y, out isVisible);
1873 GDIPlus.CheckStatus (status);
1878 public bool IsVisible (Rectangle rect)
1880 bool isVisible = false;
1882 Status status = GDIPlus.GdipIsVisibleRectI (nativeObject, rect.X, rect.Y, rect.Width, rect.Height, out isVisible);
1883 GDIPlus.CheckStatus (status);
1888 public bool IsVisible (float x, float y)
1890 return IsVisible (new PointF (x, y));
1893 public bool IsVisible (int x, int y)
1895 return IsVisible (new Point (x, y));
1898 public bool IsVisible (float x, float y, float width, float height)
1900 return IsVisible (new RectangleF (x, y, width, height));
1904 public bool IsVisible (int x, int y, int width, int height)
1906 return IsVisible (new Rectangle (x, y, width, height));
1910 public Region[] MeasureCharacterRanges (string text, Font font, RectangleF layoutRect, StringFormat stringFormat)
1912 if ((text == null) || (text.Length == 0))
1913 return new Region [0];
1916 throw new ArgumentNullException ("font");
1918 if (stringFormat == null)
1919 throw new ArgumentException ("stringFormat");
1921 int regcount = stringFormat.GetMeasurableCharacterRangeCount ();
1923 return new Region[0];
1925 IntPtr[] native_regions = new IntPtr [regcount];
1926 Region[] regions = new Region [regcount];
1928 for (int i = 0; i < regcount; i++) {
1929 regions[i] = new Region ();
1930 native_regions[i] = regions[i].NativeObject;
1933 Status status = GDIPlus.GdipMeasureCharacterRanges (nativeObject, text, text.Length,
1934 font.NativeObject, ref layoutRect, stringFormat.NativeObject, regcount, out native_regions[0]);
1935 GDIPlus.CheckStatus (status);
1940 private unsafe SizeF GdipMeasureString (IntPtr graphics, string text, Font font, ref RectangleF layoutRect,
1941 IntPtr stringFormat)
1943 if ((text == null) || (text.Length == 0))
1947 throw new ArgumentNullException ("font");
1949 RectangleF boundingBox = new RectangleF ();
1951 Status status = GDIPlus.GdipMeasureString (nativeObject, text, text.Length, font.NativeObject,
1952 ref layoutRect, stringFormat, out boundingBox, null, null);
1953 GDIPlus.CheckStatus (status);
1955 return new SizeF (boundingBox.Width, boundingBox.Height);
1958 public SizeF MeasureString (string text, Font font)
1960 return MeasureString (text, font, SizeF.Empty);
1963 public SizeF MeasureString (string text, Font font, SizeF layoutArea)
1965 RectangleF rect = new RectangleF (0, 0, layoutArea.Width, layoutArea.Height);
1966 return GdipMeasureString (nativeObject, text, font, ref rect, IntPtr.Zero);
1969 public SizeF MeasureString (string text, Font font, int width)
1971 RectangleF rect = new RectangleF (0, 0, width, Int32.MaxValue);
1972 return GdipMeasureString (nativeObject, text, font, ref rect, IntPtr.Zero);
1975 public SizeF MeasureString (string text, Font font, SizeF layoutArea, StringFormat stringFormat)
1977 RectangleF rect = new RectangleF (0, 0, layoutArea.Width, layoutArea.Height);
1978 IntPtr format = (stringFormat == null) ? IntPtr.Zero : stringFormat.NativeObject;
1979 return GdipMeasureString (nativeObject, text, font, ref rect, format);
1982 public SizeF MeasureString (string text, Font font, int width, StringFormat format)
1984 RectangleF rect = new RectangleF (0, 0, width, Int32.MaxValue);
1985 IntPtr stringFormat = (format == null) ? IntPtr.Zero : format.NativeObject;
1986 return GdipMeasureString (nativeObject, text, font, ref rect, stringFormat);
1989 public SizeF MeasureString (string text, Font font, PointF origin, StringFormat stringFormat)
1991 RectangleF rect = new RectangleF (origin.X, origin.Y, 0, 0);
1992 IntPtr format = (stringFormat == null) ? IntPtr.Zero : stringFormat.NativeObject;
1993 return GdipMeasureString (nativeObject, text, font, ref rect, format);
1996 public SizeF MeasureString (string text, Font font, SizeF layoutArea, StringFormat stringFormat,
1997 out int charactersFitted, out int linesFilled)
1999 charactersFitted = 0;
2002 if ((text == null) || (text.Length == 0))
2006 throw new ArgumentNullException ("font");
2008 RectangleF boundingBox = new RectangleF ();
2009 RectangleF rect = new RectangleF (0, 0, layoutArea.Width, layoutArea.Height);
2011 IntPtr format = (stringFormat == null) ? IntPtr.Zero : stringFormat.NativeObject;
2014 fixed (int* pc = &charactersFitted, pl = &linesFilled) {
2015 Status status = GDIPlus.GdipMeasureString (nativeObject, text, text.Length,
2016 font.NativeObject, ref rect, format, out boundingBox, pc, pl);
2017 GDIPlus.CheckStatus (status);
2020 return new SizeF (boundingBox.Width, boundingBox.Height);
2023 public void MultiplyTransform (Matrix matrix)
2025 MultiplyTransform (matrix, MatrixOrder.Prepend);
2028 public void MultiplyTransform (Matrix matrix, MatrixOrder order)
2031 throw new ArgumentNullException ("matrix");
2033 Status status = GDIPlus.GdipMultiplyWorldTransform (nativeObject, matrix.nativeMatrix, order);
2034 GDIPlus.CheckStatus (status);
2037 [EditorBrowsable (EditorBrowsableState.Advanced)]
2038 [SecurityPermission (SecurityAction.Demand, UnmanagedCode = true)]
2039 public void ReleaseHdc (IntPtr hdc)
2041 ReleaseHdcInternal (hdc);
2045 [SecurityPermission (SecurityAction.LinkDemand, UnmanagedCode = true)]
2046 public void ReleaseHdc ()
2048 ReleaseHdcInternal (deviceContextHdc);
2052 [MonoLimitation ("Can only be used when hdc was provided by Graphics.GetHdc() method")]
2054 [EditorBrowsable (EditorBrowsableState.Never)]
2056 [EditorBrowsable (EditorBrowsableState.Advanced)]
2058 [SecurityPermission (SecurityAction.LinkDemand, UnmanagedCode = true)]
2059 public void ReleaseHdcInternal (IntPtr hdc)
2061 Status status = Status.InvalidParameter;
2062 if (hdc == deviceContextHdc) {
2063 status = GDIPlus.GdipReleaseDC (nativeObject, deviceContextHdc);
2064 deviceContextHdc = IntPtr.Zero;
2066 GDIPlus.CheckStatus (status);
2069 public void ResetClip ()
2071 Status status = GDIPlus.GdipResetClip (nativeObject);
2072 GDIPlus.CheckStatus (status);
2075 public void ResetTransform ()
2077 Status status = GDIPlus.GdipResetWorldTransform (nativeObject);
2078 GDIPlus.CheckStatus (status);
2081 public void Restore (GraphicsState gstate)
2083 // the possible NRE thrown by gstate.nativeState match MS behaviour
2084 Status status = GDIPlus.GdipRestoreGraphics (nativeObject, gstate.nativeState);
2085 GDIPlus.CheckStatus (status);
2088 public void RotateTransform (float angle)
2090 RotateTransform (angle, MatrixOrder.Prepend);
2093 public void RotateTransform (float angle, MatrixOrder order)
2095 Status status = GDIPlus.GdipRotateWorldTransform (nativeObject, angle, order);
2096 GDIPlus.CheckStatus (status);
2099 public GraphicsState Save ()
2102 Status status = GDIPlus.GdipSaveGraphics (nativeObject, out saveState);
2103 GDIPlus.CheckStatus (status);
2105 GraphicsState state = new GraphicsState ();
2106 state.nativeState = saveState;
2110 public void ScaleTransform (float sx, float sy)
2112 ScaleTransform (sx, sy, MatrixOrder.Prepend);
2115 public void ScaleTransform (float sx, float sy, MatrixOrder order)
2117 Status status = GDIPlus.GdipScaleWorldTransform (nativeObject, sx, sy, order);
2118 GDIPlus.CheckStatus (status);
2122 public void SetClip (RectangleF rect)
2124 SetClip (rect, CombineMode.Replace);
2128 public void SetClip (GraphicsPath path)
2130 SetClip (path, CombineMode.Replace);
2134 public void SetClip (Rectangle rect)
2136 SetClip (rect, CombineMode.Replace);
2140 public void SetClip (Graphics g)
2142 SetClip (g, CombineMode.Replace);
2146 public void SetClip (Graphics g, CombineMode combineMode)
2149 throw new ArgumentNullException ("g");
2151 Status status = GDIPlus.GdipSetClipGraphics (nativeObject, g.NativeObject, combineMode);
2152 GDIPlus.CheckStatus (status);
2156 public void SetClip (Rectangle rect, CombineMode combineMode)
2158 Status status = GDIPlus.GdipSetClipRectI (nativeObject, rect.X, rect.Y, rect.Width, rect.Height, combineMode);
2159 GDIPlus.CheckStatus (status);
2163 public void SetClip (RectangleF rect, CombineMode combineMode)
2165 Status status = GDIPlus.GdipSetClipRect (nativeObject, rect.X, rect.Y, rect.Width, rect.Height, combineMode);
2166 GDIPlus.CheckStatus (status);
2170 public void SetClip (Region region, CombineMode combineMode)
2173 throw new ArgumentNullException ("region");
2174 Status status = GDIPlus.GdipSetClipRegion(nativeObject, region.NativeObject, combineMode);
2175 GDIPlus.CheckStatus (status);
2179 public void SetClip (GraphicsPath path, CombineMode combineMode)
2182 throw new ArgumentNullException ("path");
2183 Status status = GDIPlus.GdipSetClipPath (nativeObject, path.NativeObject, combineMode);
2184 GDIPlus.CheckStatus (status);
2188 public void TransformPoints (CoordinateSpace destSpace, CoordinateSpace srcSpace, PointF [] pts)
2191 throw new ArgumentNullException ("pts");
2193 IntPtr ptrPt = GDIPlus.FromPointToUnManagedMemory (pts);
2195 Status status = GDIPlus.GdipTransformPoints (nativeObject, destSpace, srcSpace, ptrPt, pts.Length);
2196 GDIPlus.CheckStatus (status);
2198 GDIPlus.FromUnManagedMemoryToPoint (ptrPt, pts);
2202 public void TransformPoints (CoordinateSpace destSpace, CoordinateSpace srcSpace, Point [] pts)
2205 throw new ArgumentNullException ("pts");
2206 IntPtr ptrPt = GDIPlus.FromPointToUnManagedMemoryI (pts);
2208 Status status = GDIPlus.GdipTransformPointsI (nativeObject, destSpace, srcSpace, ptrPt, pts.Length);
2209 GDIPlus.CheckStatus (status);
2211 GDIPlus.FromUnManagedMemoryToPointI (ptrPt, pts);
2215 public void TranslateClip (int dx, int dy)
2217 Status status = GDIPlus.GdipTranslateClipI (nativeObject, dx, dy);
2218 GDIPlus.CheckStatus (status);
2222 public void TranslateClip (float dx, float dy)
2224 Status status = GDIPlus.GdipTranslateClip (nativeObject, dx, dy);
2225 GDIPlus.CheckStatus (status);
2228 public void TranslateTransform (float dx, float dy)
2230 TranslateTransform (dx, dy, MatrixOrder.Prepend);
2234 public void TranslateTransform (float dx, float dy, MatrixOrder order)
2236 Status status = GDIPlus.GdipTranslateWorldTransform (nativeObject, dx, dy, order);
2237 GDIPlus.CheckStatus (status);
2240 public Region Clip {
2242 Region reg = new Region();
2243 Status status = GDIPlus.GdipGetClip (nativeObject, reg.NativeObject);
2244 GDIPlus.CheckStatus (status);
2248 SetClip (value, CombineMode.Replace);
2252 public RectangleF ClipBounds {
2254 RectangleF rect = new RectangleF ();
2255 Status status = GDIPlus.GdipGetClipBounds (nativeObject, out rect);
2256 GDIPlus.CheckStatus (status);
2261 public CompositingMode CompositingMode {
2263 CompositingMode mode;
2264 Status status = GDIPlus.GdipGetCompositingMode (nativeObject, out mode);
2265 GDIPlus.CheckStatus (status);
2270 Status status = GDIPlus.GdipSetCompositingMode (nativeObject, value);
2271 GDIPlus.CheckStatus (status);
2276 public CompositingQuality CompositingQuality {
2278 CompositingQuality quality;
2280 Status status = GDIPlus.GdipGetCompositingQuality (nativeObject, out quality);
2281 GDIPlus.CheckStatus (status);
2285 Status status = GDIPlus.GdipSetCompositingQuality (nativeObject, value);
2286 GDIPlus.CheckStatus (status);
2294 Status status = GDIPlus.GdipGetDpiX (nativeObject, out x);
2295 GDIPlus.CheckStatus (status);
2304 Status status = GDIPlus.GdipGetDpiY (nativeObject, out y);
2305 GDIPlus.CheckStatus (status);
2310 public InterpolationMode InterpolationMode {
2312 InterpolationMode imode = InterpolationMode.Invalid;
2313 Status status = GDIPlus.GdipGetInterpolationMode (nativeObject, out imode);
2314 GDIPlus.CheckStatus (status);
2318 Status status = GDIPlus.GdipSetInterpolationMode (nativeObject, value);
2319 GDIPlus.CheckStatus (status);
2323 public bool IsClipEmpty {
2325 bool isEmpty = false;
2327 Status status = GDIPlus.GdipIsClipEmpty (nativeObject, out isEmpty);
2328 GDIPlus.CheckStatus (status);
2333 public bool IsVisibleClipEmpty {
2335 bool isEmpty = false;
2337 Status status = GDIPlus.GdipIsVisibleClipEmpty (nativeObject, out isEmpty);
2338 GDIPlus.CheckStatus (status);
2343 public float PageScale {
2347 Status status = GDIPlus.GdipGetPageScale (nativeObject, out scale);
2348 GDIPlus.CheckStatus (status);
2352 Status status = GDIPlus.GdipSetPageScale (nativeObject, value);
2353 GDIPlus.CheckStatus (status);
2357 public GraphicsUnit PageUnit {
2361 Status status = GDIPlus.GdipGetPageUnit (nativeObject, out unit);
2362 GDIPlus.CheckStatus (status);
2366 Status status = GDIPlus.GdipSetPageUnit (nativeObject, value);
2367 GDIPlus.CheckStatus (status);
2371 [MonoTODO ("This property does not do anything when used with libgdiplus.")]
2372 public PixelOffsetMode PixelOffsetMode {
2374 PixelOffsetMode pixelOffset = PixelOffsetMode.Invalid;
2376 Status status = GDIPlus.GdipGetPixelOffsetMode (nativeObject, out pixelOffset);
2377 GDIPlus.CheckStatus (status);
2381 Status status = GDIPlus.GdipSetPixelOffsetMode (nativeObject, value);
2382 GDIPlus.CheckStatus (status);
2386 public Point RenderingOrigin {
2389 Status status = GDIPlus.GdipGetRenderingOrigin (nativeObject, out x, out y);
2390 GDIPlus.CheckStatus (status);
2391 return new Point (x, y);
2395 Status status = GDIPlus.GdipSetRenderingOrigin (nativeObject, value.X, value.Y);
2396 GDIPlus.CheckStatus (status);
2400 public SmoothingMode SmoothingMode {
2402 SmoothingMode mode = SmoothingMode.Invalid;
2404 Status status = GDIPlus.GdipGetSmoothingMode (nativeObject, out mode);
2405 GDIPlus.CheckStatus (status);
2410 Status status = GDIPlus.GdipSetSmoothingMode (nativeObject, value);
2411 GDIPlus.CheckStatus (status);
2415 [MonoTODO ("This property does not do anything when used with libgdiplus.")]
2416 public int TextContrast {
2420 Status status = GDIPlus.GdipGetTextContrast (nativeObject, out contrast);
2421 GDIPlus.CheckStatus (status);
2426 Status status = GDIPlus.GdipSetTextContrast (nativeObject, value);
2427 GDIPlus.CheckStatus (status);
2431 public TextRenderingHint TextRenderingHint {
2433 TextRenderingHint hint;
2435 Status status = GDIPlus.GdipGetTextRenderingHint (nativeObject, out hint);
2436 GDIPlus.CheckStatus (status);
2441 Status status = GDIPlus.GdipSetTextRenderingHint (nativeObject, value);
2442 GDIPlus.CheckStatus (status);
2446 public Matrix Transform {
2448 Matrix matrix = new Matrix ();
2449 Status status = GDIPlus.GdipGetWorldTransform (nativeObject, matrix.nativeMatrix);
2450 GDIPlus.CheckStatus (status);
2455 throw new ArgumentNullException ("value");
2457 Status status = GDIPlus.GdipSetWorldTransform (nativeObject, value.nativeMatrix);
2458 GDIPlus.CheckStatus (status);
2462 public RectangleF VisibleClipBounds {
2466 Status status = GDIPlus.GdipGetVisibleClipBounds (nativeObject, out rect);
2467 GDIPlus.CheckStatus (status);
2474 [EditorBrowsable (EditorBrowsableState.Never)]
2475 public object GetContextInfo ()
2477 // only known source of information @ http://blogs.wdevs.com/jdunlap/Default.aspx
2478 throw new NotImplementedException ();