/binding/win32/gdiplusgraphics.d
D | 2335 lines | 1996 code | 291 blank | 48 comment | 22 complexity | a3dcf82dac6e4451f872aa9db2317a02 MD5 | raw file
1/* 2 * gdiplusgraphics.d 3 * 4 * This module implements GdiPlusGraphics.h for D. The original 5 * copyright info is given below. 6 * 7 * Author: Dave Wilkinson 8 * Originated: November 25th, 2009 9 * 10 */ 11 12module binding.win32.gdiplusgraphics; 13 14import binding.win32.windef; 15import binding.win32.winbase; 16import binding.win32.winnt; 17import binding.win32.wingdi; 18import binding.win32.guiddef; 19import binding.win32.gdiplusbase; 20import binding.win32.gdiplustypes; 21import binding.win32.gdiplusenums; 22import binding.win32.gdipluspixelformats; 23import binding.win32.gdiplusgpstubs; 24import binding.win32.gdiplusmetaheader; 25import binding.win32.gdipluspixelformats; 26import binding.win32.gdipluscolor; 27import binding.win32.gdipluscolormatrix; 28import binding.win32.gdiplusflat; 29import binding.win32.gdiplusimaging; 30import binding.win32.gdiplusbitmap; 31import binding.win32.gdiplusimageattributes; 32import binding.win32.gdiplusmatrix; 33import binding.win32.gdiplusregion; 34import binding.win32.gdiplusbrush; 35import binding.win32.gdipluspen; 36import binding.win32.gdiplusfont; 37import binding.win32.gdipluspath; 38import binding.win32.gdiplusstringformat; 39import binding.win32.gdipluscachedbitmap; 40import binding.win32.gdipluseffects; 41import binding.win32.gdiplusmetafile; 42 43/**************************************************************************\ 44* 45* Copyright (c) 1998-2001, Microsoft Corp. All Rights Reserved. 46* 47* Module Name: 48* 49* GdiplusGraphics.h 50* 51* Abstract: 52* 53* GDI+ Graphics Object 54* 55\**************************************************************************/ 56 57extern(System): 58 59class Graphics : GdiplusBase { 60 61 static Graphics FromHDC(in HDC hdc) { 62 return new Graphics(hdc); 63 } 64 65 static Graphics FromHDC(in HDC hdc, in HANDLE hdevice) { 66 return new Graphics(hdc, hdevice); 67 } 68 69 static Graphics FromHWND(in HWND hwnd, in BOOL icm = FALSE) { 70 return new Graphics(hwnd, icm); 71 } 72 73 static Graphics FromImage(in Image image) { 74 return new Graphics(image); 75 } 76 77 this(in HDC hdc) { 78 GpGraphics *graphics = null; 79 80 lastResult = GdipCreateFromHDC(hdc, &graphics); 81 82 SetNativeGraphics(graphics); 83 } 84 85 this(in HDC hdc, in HANDLE hdevice) { 86 GpGraphics *graphics = null; 87 88 lastResult = GdipCreateFromHDC2(hdc, hdevice, &graphics); 89 90 SetNativeGraphics(graphics); 91 } 92 93 this(in HWND hwnd, in BOOL icm) { 94 GpGraphics *graphics = null; 95 96 if (icm) { 97 lastResult = GdipCreateFromHWNDICM(hwnd, &graphics); 98 } 99 else { 100 lastResult = GdipCreateFromHWND(hwnd, &graphics); 101 } 102 103 SetNativeGraphics(graphics); 104 } 105 106 this(in Image image) { 107 GpGraphics *graphics = null; 108 109 if (image !is null) { 110 lastResult = GdipGetImageGraphicsContext( 111 image.nativeImage, &graphics); 112 } 113 SetNativeGraphics(graphics); 114 } 115 116 ~this() { 117 GdipDeleteGraphics(nativeGraphics); 118 } 119 120 VOID Flush(in FlushIntention intention = FlushIntention.FlushIntentionFlush) { 121 GdipFlush(nativeGraphics, intention); 122 } 123 124 //------------------------------------------------------------------------ 125 // GDI Interop methods 126 //------------------------------------------------------------------------ 127 128 // Locks the graphics until ReleaseDC is called 129 130 HDC GetHDC() { 131 HDC hdc = null; 132 133 SetStatus(GdipGetDC(nativeGraphics, &hdc)); 134 135 return hdc; 136 } 137 138 VOID ReleaseHDC(in HDC hdc) { 139 SetStatus(GdipReleaseDC(nativeGraphics, hdc)); 140 } 141 142 //------------------------------------------------------------------------ 143 // Rendering modes 144 //------------------------------------------------------------------------ 145 146 Status SetRenderingOrigin(in INT x, in INT y) { 147 return SetStatus( 148 GdipSetRenderingOrigin( 149 nativeGraphics, x, y 150 ) 151 ); 152 } 153 154 Status GetRenderingOrigin(ref INT x, ref INT y) { 155 return SetStatus( 156 GdipGetRenderingOrigin( 157 nativeGraphics, &x, &y 158 ) 159 ); 160 } 161 162 Status SetCompositingMode(in CompositingMode compositingMode) { 163 return SetStatus(GdipSetCompositingMode(nativeGraphics, compositingMode)); 164 } 165 166 CompositingMode GetCompositingMode() { 167 CompositingMode mode; 168 169 SetStatus(GdipGetCompositingMode(nativeGraphics, 170 &mode)); 171 172 return mode; 173 } 174 175 Status SetCompositingQuality(in CompositingQuality compositingQuality) { 176 return SetStatus(GdipSetCompositingQuality( 177 nativeGraphics, 178 compositingQuality)); 179 } 180 181 CompositingQuality GetCompositingQuality() { 182 CompositingQuality quality; 183 184 SetStatus(GdipGetCompositingQuality( 185 nativeGraphics, 186 &quality)); 187 188 return quality; 189 } 190 191 Status SetTextRenderingHint(in TextRenderingHint newMode) { 192 return SetStatus(GdipSetTextRenderingHint(nativeGraphics, 193 newMode)); 194 } 195 196 TextRenderingHint GetTextRenderingHint() { 197 TextRenderingHint hint; 198 199 SetStatus(GdipGetTextRenderingHint(nativeGraphics, 200 &hint)); 201 202 return hint; 203 } 204 205 Status SetTextContrast(in UINT contrast) { 206 return SetStatus(GdipSetTextContrast(nativeGraphics, contrast)); 207 } 208 209 UINT GetTextContrast() { 210 UINT contrast; 211 212 SetStatus(GdipGetTextContrast(nativeGraphics, &contrast)); 213 214 return contrast; 215 } 216 217 InterpolationMode GetInterpolationMode() { 218 InterpolationMode mode = InterpolationMode.InterpolationModeInvalid; 219 220 SetStatus(GdipGetInterpolationMode(nativeGraphics, &mode)); 221 222 return mode; 223 } 224 225 Status SetInterpolationMode(in InterpolationMode interpolationMode) { 226 return SetStatus(GdipSetInterpolationMode(nativeGraphics, interpolationMode)); 227 } 228 229version(GDIPLUS6) { 230 Status SetAbort(GdiplusAbort *pIAbort) { 231 return SetStatus(GdipGraphicsSetAbort( 232 nativeGraphics, 233 pIAbort 234 )); 235 } 236} 237 238 SmoothingMode GetSmoothingMode() { 239 SmoothingMode smoothingMode = SmoothingMode.SmoothingModeInvalid; 240 241 SetStatus(GdipGetSmoothingMode(nativeGraphics, 242 &smoothingMode)); 243 244 return smoothingMode; 245 } 246 247 Status SetSmoothingMode(in SmoothingMode smoothingMode) { 248 return SetStatus(GdipSetSmoothingMode(nativeGraphics, 249 smoothingMode)); 250 } 251 252 PixelOffsetMode GetPixelOffsetMode() { 253 PixelOffsetMode pixelOffsetMode = PixelOffsetMode.PixelOffsetModeInvalid; 254 255 SetStatus(GdipGetPixelOffsetMode(nativeGraphics, 256 &pixelOffsetMode)); 257 258 return pixelOffsetMode; 259 } 260 261 Status SetPixelOffsetMode(in PixelOffsetMode pixelOffsetMode) { 262 return SetStatus(GdipSetPixelOffsetMode(nativeGraphics, 263 pixelOffsetMode)); 264 } 265 266 //------------------------------------------------------------------------ 267 // Manipulate current world transform 268 //------------------------------------------------------------------------ 269 270 Status SetTransform(in Matrix matrix) { 271 return SetStatus(GdipSetWorldTransform(nativeGraphics, 272 matrix.nativeMatrix)); 273 } 274 275 Status ResetTransform() { 276 return SetStatus(GdipResetWorldTransform(nativeGraphics)); 277 } 278 279 Status MultiplyTransform(in Matrix matrix, in MatrixOrder order = MatrixOrder.MatrixOrderPrepend) { 280 return SetStatus(GdipMultiplyWorldTransform(nativeGraphics, 281 matrix.nativeMatrix, 282 order)); 283 } 284 285 Status TranslateTransform(in REAL dx, in REAL dy, in MatrixOrder order = MatrixOrder.MatrixOrderPrepend) { 286 return SetStatus(GdipTranslateWorldTransform(nativeGraphics, dx, dy, order)); 287 } 288 289 Status ScaleTransform(in REAL sx, in REAL sy, in MatrixOrder order = MatrixOrder.MatrixOrderPrepend) { 290 return SetStatus(GdipScaleWorldTransform(nativeGraphics, sx, sy, order)); 291 } 292 293 Status RotateTransform(in REAL angle, in MatrixOrder order = MatrixOrder.MatrixOrderPrepend) { 294 return SetStatus(GdipRotateWorldTransform(nativeGraphics, angle, order)); 295 } 296 297 Status GetTransform(Matrix* matrix) { 298 return SetStatus(GdipGetWorldTransform(nativeGraphics, matrix.nativeMatrix)); 299 } 300 301 Status SetPageUnit(in Unit unit) { 302 return SetStatus(GdipSetPageUnit(nativeGraphics, unit)); 303 } 304 305 Status SetPageScale(in REAL scale) { 306 return SetStatus(GdipSetPageScale(nativeGraphics, scale)); 307 } 308 309 Unit GetPageUnit() { 310 Unit unit; 311 312 SetStatus(GdipGetPageUnit(nativeGraphics, &unit)); 313 314 return unit; 315 } 316 317 REAL GetPageScale() { 318 REAL scale; 319 320 SetStatus(GdipGetPageScale(nativeGraphics, &scale)); 321 322 return scale; 323 } 324 325 REAL GetDpiX() { 326 REAL dpi; 327 328 SetStatus(GdipGetDpiX(nativeGraphics, &dpi)); 329 330 return dpi; 331 } 332 333 REAL GetDpiY() { 334 REAL dpi; 335 336 SetStatus(GdipGetDpiY(nativeGraphics, &dpi)); 337 338 return dpi; 339 } 340 341 Status TransformPoints(in CoordinateSpace destSpace, in CoordinateSpace srcSpace, PointF* pts, in INT count) { 342 return SetStatus(GdipTransformPoints(nativeGraphics, destSpace, srcSpace, pts, count)); 343 } 344 345 Status TransformPoints(in CoordinateSpace destSpace, in CoordinateSpace srcSpace, in Point* pts, in INT count) { 346 return SetStatus(GdipTransformPointsI(nativeGraphics, destSpace, srcSpace, pts, count)); 347 } 348 349 //------------------------------------------------------------------------ 350 // GetNearestColor (for <= 8bpp surfaces). Note: Alpha is ignored. 351 //------------------------------------------------------------------------ 352 353 Status GetNearestColor(in Color color) { 354 if (color is null) { 355 return SetStatus(Status.InvalidParameter); 356 } 357 358 ARGB argb = color.GetValue(); 359 360 Status status = SetStatus(GdipGetNearestColor(nativeGraphics, &argb)); 361 362 color.SetValue(argb); 363 364 return status; 365 } 366 367 Status DrawLine(in Pen pen, in REAL x1, in REAL y1, in REAL x2, in REAL y2) { 368 return SetStatus(GdipDrawLine(nativeGraphics, 369 pen.nativePen, x1, y1, x2, 370 y2)); 371 } 372 373 Status DrawLine(in Pen pen, in PointF pt1, in PointF pt2) { 374 return DrawLine(pen, pt1.X, pt1.Y, pt2.X, pt2.Y); 375 } 376 377 Status DrawLines(in Pen pen, 378 in PointF* points, 379 in INT count) 380 { 381 return SetStatus(GdipDrawLines(nativeGraphics, 382 pen.nativePen, 383 points, count)); 384 } 385 386 Status DrawLine(in Pen pen, 387 in INT x1, 388 in INT y1, 389 in INT x2, 390 in INT y2) 391 { 392 return SetStatus(GdipDrawLineI(nativeGraphics, 393 pen.nativePen, 394 x1, 395 y1, 396 x2, 397 y2)); 398 } 399 400 Status DrawLine(in Pen pen, 401 in Point pt1, 402 in Point pt2) 403 { 404 return DrawLine(pen, 405 pt1.X, 406 pt1.Y, 407 pt2.X, 408 pt2.Y); 409 } 410 411 Status DrawLines(in Pen pen, 412 in Point* points, 413 in INT count) 414 { 415 return SetStatus(GdipDrawLinesI(nativeGraphics, 416 pen.nativePen, 417 points, 418 count)); 419 } 420 421 Status DrawArc(in Pen pen, 422 in REAL x, 423 in REAL y, 424 in REAL width, 425 in REAL height, 426 in REAL startAngle, 427 in REAL sweepAngle) 428 { 429 return SetStatus(GdipDrawArc(nativeGraphics, 430 pen.nativePen, 431 x, 432 y, 433 width, 434 height, 435 startAngle, 436 sweepAngle)); 437 } 438 439 Status DrawArc(in Pen pen, 440 in RectF rect, 441 in REAL startAngle, 442 in REAL sweepAngle) 443 { 444 return DrawArc(pen, rect.X, rect.Y, rect.Width, rect.Height, 445 startAngle, sweepAngle); 446 } 447 448 Status DrawArc(in Pen pen, 449 in INT x, 450 in INT y, 451 in INT width, 452 in INT height, 453 in REAL startAngle, 454 in REAL sweepAngle) 455 { 456 return SetStatus(GdipDrawArcI(nativeGraphics, 457 pen.nativePen, 458 x, 459 y, 460 width, 461 height, 462 startAngle, 463 sweepAngle)); 464 } 465 466 467 Status DrawArc(in Pen pen, 468 in Rect rect, 469 in REAL startAngle, 470 in REAL sweepAngle) 471 { 472 return DrawArc(pen, 473 rect.X, 474 rect.Y, 475 rect.Width, 476 rect.Height, 477 startAngle, 478 sweepAngle); 479 } 480 481 Status DrawBezier(in Pen pen, 482 in REAL x1, 483 in REAL y1, 484 in REAL x2, 485 in REAL y2, 486 in REAL x3, 487 in REAL y3, 488 in REAL x4, 489 in REAL y4) 490 { 491 return SetStatus(GdipDrawBezier(nativeGraphics, 492 pen.nativePen, x1, y1, 493 x2, y2, x3, y3, x4, y4)); 494 } 495 496 Status DrawBezier(in Pen pen, 497 in PointF pt1, 498 in PointF pt2, 499 in PointF pt3, 500 in PointF pt4) 501 { 502 return DrawBezier(pen, 503 pt1.X, 504 pt1.Y, 505 pt2.X, 506 pt2.Y, 507 pt3.X, 508 pt3.Y, 509 pt4.X, 510 pt4.Y); 511 } 512 513 Status DrawBeziers(in Pen pen, 514 in PointF* points, 515 in INT count) 516 { 517 return SetStatus(GdipDrawBeziers(nativeGraphics, 518 pen.nativePen, 519 points, 520 count)); 521 } 522 523 Status DrawBezier(in Pen pen, 524 in INT x1, 525 in INT y1, 526 in INT x2, 527 in INT y2, 528 in INT x3, 529 in INT y3, 530 in INT x4, 531 in INT y4) 532 { 533 return SetStatus(GdipDrawBezierI(nativeGraphics, 534 pen.nativePen, 535 x1, 536 y1, 537 x2, 538 y2, 539 x3, 540 y3, 541 x4, 542 y4)); 543 } 544 545 Status DrawBezier(in Pen pen, 546 in Point pt1, 547 in Point pt2, 548 in Point pt3, 549 in Point pt4) 550 { 551 return DrawBezier(pen, 552 pt1.X, 553 pt1.Y, 554 pt2.X, 555 pt2.Y, 556 pt3.X, 557 pt3.Y, 558 pt4.X, 559 pt4.Y); 560 } 561 562 Status DrawBeziers(in Pen pen, 563 in Point* points, 564 in INT count) 565 { 566 return SetStatus(GdipDrawBeziersI(nativeGraphics, 567 pen.nativePen, 568 points, 569 count)); 570 } 571 572 Status DrawRectangle(in Pen pen, 573 in RectF rect) 574 { 575 return DrawRectangle(pen, rect.X, rect.Y, rect.Width, rect.Height); 576 } 577 578 Status DrawRectangle(in Pen pen, 579 in REAL x, 580 in REAL y, 581 in REAL width, 582 in REAL height) 583 { 584 return SetStatus(GdipDrawRectangle(nativeGraphics, 585 pen.nativePen, x, y, 586 width, height)); 587 } 588 589 Status DrawRectangles(in Pen pen, 590 in RectF* rects, 591 in INT count) 592 { 593 return SetStatus(GdipDrawRectangles(nativeGraphics, 594 pen.nativePen, 595 rects, count)); 596 } 597 598 Status DrawRectangle(in Pen pen, 599 in Rect rect) 600 { 601 return DrawRectangle(pen, 602 rect.X, 603 rect.Y, 604 rect.Width, 605 rect.Height); 606 } 607 608 Status DrawRectangle(in Pen pen, 609 in INT x, 610 in INT y, 611 in INT width, 612 in INT height) 613 { 614 return SetStatus(GdipDrawRectangleI(nativeGraphics, 615 pen.nativePen, 616 x, 617 y, 618 width, 619 height)); 620 } 621 622 Status DrawRectangles(in Pen pen, 623 in Rect* rects, 624 in INT count) 625 { 626 return SetStatus(GdipDrawRectanglesI(nativeGraphics, 627 pen.nativePen, 628 rects, 629 count)); 630 } 631 632 Status DrawEllipse(in Pen pen, 633 in RectF rect) 634 { 635 return DrawEllipse(pen, rect.X, rect.Y, rect.Width, rect.Height); 636 } 637 638 Status DrawEllipse(in Pen pen, 639 in REAL x, 640 in REAL y, 641 in REAL width, 642 in REAL height) 643 { 644 return SetStatus(GdipDrawEllipse(nativeGraphics, 645 pen.nativePen, 646 x, 647 y, 648 width, 649 height)); 650 } 651 652 Status DrawEllipse(in Pen pen, 653 in Rect rect) 654 { 655 return DrawEllipse(pen, 656 rect.X, 657 rect.Y, 658 rect.Width, 659 rect.Height); 660 } 661 662 Status DrawEllipse(in Pen pen, 663 in INT x, 664 in INT y, 665 in INT width, 666 in INT height) 667 { 668 return SetStatus(GdipDrawEllipseI(nativeGraphics, 669 pen.nativePen, 670 x, 671 y, 672 width, 673 height)); 674 } 675 676 Status DrawPie(in Pen pen, 677 in RectF rect, 678 in REAL startAngle, 679 in REAL sweepAngle) 680 { 681 return DrawPie(pen, 682 rect.X, 683 rect.Y, 684 rect.Width, 685 rect.Height, 686 startAngle, 687 sweepAngle); 688 } 689 690 Status DrawPie(in Pen pen, 691 in REAL x, 692 in REAL y, 693 in REAL width, 694 in REAL height, 695 in REAL startAngle, 696 in REAL sweepAngle) 697 { 698 return SetStatus(GdipDrawPie(nativeGraphics, 699 pen.nativePen, 700 x, 701 y, 702 width, 703 height, 704 startAngle, 705 sweepAngle)); 706 } 707 708 Status DrawPie(in Pen pen, 709 in Rect rect, 710 in REAL startAngle, 711 in REAL sweepAngle) 712 { 713 return DrawPie(pen, 714 rect.X, 715 rect.Y, 716 rect.Width, 717 rect.Height, 718 startAngle, 719 sweepAngle); 720 } 721 722 Status DrawPie(in Pen pen, 723 in INT x, 724 in INT y, 725 in INT width, 726 in INT height, 727 in REAL startAngle, 728 in REAL sweepAngle) 729 { 730 return SetStatus(GdipDrawPieI(nativeGraphics, 731 pen.nativePen, 732 x, 733 y, 734 width, 735 height, 736 startAngle, 737 sweepAngle)); 738 } 739 740 Status DrawPolygon(in Pen pen, 741 in PointF* points, 742 in INT count) 743 { 744 return SetStatus(GdipDrawPolygon(nativeGraphics, 745 pen.nativePen, 746 points, 747 count)); 748 } 749 750 Status DrawPolygon(in Pen pen, 751 in Point* points, 752 in INT count) 753 { 754 return SetStatus(GdipDrawPolygonI(nativeGraphics, 755 pen.nativePen, 756 points, 757 count)); 758 } 759 760 Status DrawPath(in Pen pen, 761 in GraphicsPath* path) 762 { 763 return SetStatus(GdipDrawPath(nativeGraphics, 764 pen ? pen.nativePen : null, 765 path ? path.nativePath : null)); 766 } 767 768 Status DrawCurve(in Pen pen, 769 in PointF* points, 770 in INT count) 771 { 772 return SetStatus(GdipDrawCurve(nativeGraphics, 773 pen.nativePen, points, 774 count)); 775 } 776 777 Status DrawCurve(in Pen pen, 778 in PointF* points, 779 in INT count, 780 in REAL tension) 781 { 782 return SetStatus(GdipDrawCurve2(nativeGraphics, 783 pen.nativePen, points, 784 count, tension)); 785 } 786 787 Status DrawCurve(in Pen pen, 788 in PointF* points, 789 in INT count, 790 in INT offset, 791 in INT numberOfSegments, 792 in REAL tension = 0.5f) 793 { 794 return SetStatus(GdipDrawCurve3(nativeGraphics, 795 pen.nativePen, points, 796 count, offset, 797 numberOfSegments, tension)); 798 } 799 800 Status DrawCurve(in Pen pen, 801 in Point* points, 802 in INT count) 803 { 804 return SetStatus(GdipDrawCurveI(nativeGraphics, 805 pen.nativePen, 806 points, 807 count)); 808 } 809 810 Status DrawCurve(in Pen pen, 811 in Point* points, 812 in INT count, 813 in REAL tension) 814 { 815 return SetStatus(GdipDrawCurve2I(nativeGraphics, 816 pen.nativePen, 817 points, 818 count, 819 tension)); 820 } 821 822 Status DrawCurve(in Pen pen, 823 in Point* points, 824 in INT count, 825 in INT offset, 826 in INT numberOfSegments, 827 in REAL tension = 0.5f) 828 { 829 return SetStatus(GdipDrawCurve3I(nativeGraphics, 830 pen.nativePen, 831 points, 832 count, 833 offset, 834 numberOfSegments, 835 tension)); 836 } 837 838 Status DrawClosedCurve(in Pen pen, 839 in PointF* points, 840 in INT count) 841 { 842 return SetStatus(GdipDrawClosedCurve(nativeGraphics, 843 pen.nativePen, 844 points, count)); 845 } 846 847 Status DrawClosedCurve(in Pen *pen, 848 in PointF* points, 849 in INT count, 850 in REAL tension) 851 { 852 return SetStatus(GdipDrawClosedCurve2(nativeGraphics, 853 pen.nativePen, 854 points, count, 855 tension)); 856 } 857 858 Status DrawClosedCurve(in Pen pen, 859 in Point* points, 860 in INT count) 861 { 862 return SetStatus(GdipDrawClosedCurveI(nativeGraphics, 863 pen.nativePen, 864 points, 865 count)); 866 } 867 868 Status DrawClosedCurve(in Pen *pen, 869 in Point* points, 870 in INT count, 871 in REAL tension) 872 { 873 return SetStatus(GdipDrawClosedCurve2I(nativeGraphics, 874 pen.nativePen, 875 points, 876 count, 877 tension)); 878 } 879 880 Status Clear(in Color color) 881 { 882 return SetStatus(GdipGraphicsClear( 883 nativeGraphics, 884 color.GetValue())); 885 } 886 887 Status FillRectangle(in Brush* brush, 888 in RectF rect) 889 { 890 return FillRectangle(brush, rect.X, rect.Y, rect.Width, rect.Height); 891 } 892 893 Status FillRectangle(in Brush* brush, 894 in REAL x, 895 in REAL y, 896 in REAL width, 897 in REAL height) 898 { 899 return SetStatus(GdipFillRectangle(nativeGraphics, brush.nativeBrush, x, y, width, height)); 900 } 901 902 Status FillRectangles(in Brush* brush, 903 in RectF* rects, 904 in INT count) 905 { 906 return SetStatus(GdipFillRectangles(nativeGraphics, 907 brush.nativeBrush, 908 rects, count)); 909 } 910 911 Status FillRectangle(in Brush* brush, 912 in Rect rect) 913 { 914 return FillRectangle(brush, 915 rect.X, 916 rect.Y, 917 rect.Width, 918 rect.Height); 919 } 920 921 Status FillRectangle(in Brush* brush, 922 in INT x, 923 in INT y, 924 in INT width, 925 in INT height) 926 { 927 return SetStatus(GdipFillRectangleI(nativeGraphics, 928 brush.nativeBrush, 929 x, 930 y, 931 width, 932 height)); 933 } 934 935 Status FillRectangles(in Brush* brush, 936 in Rect* rects, 937 in INT count) 938 { 939 return SetStatus(GdipFillRectanglesI(nativeGraphics, 940 brush.nativeBrush, 941 rects, 942 count)); 943 } 944 945 Status FillPolygon(in Brush* brush, 946 in PointF* points, 947 in INT count) 948 { 949 return FillPolygon(brush, points, count, FillMode.FillModeAlternate); 950 } 951 952 Status FillPolygon(in Brush* brush, 953 in PointF* points, 954 in INT count, 955 in FillMode fillMode) 956 { 957 return SetStatus(GdipFillPolygon(nativeGraphics, 958 brush.nativeBrush, 959 points, count, fillMode)); 960 } 961 962 Status FillPolygon(in Brush* brush, 963 in Point* points, 964 in INT count) 965 { 966 return FillPolygon(brush, points, count, FillMode.FillModeAlternate); 967 } 968 969 Status FillPolygon(in Brush* brush, 970 in Point* points, 971 in INT count, 972 in FillMode fillMode) 973 { 974 return SetStatus(GdipFillPolygonI(nativeGraphics, 975 brush.nativeBrush, 976 points, count, 977 fillMode)); 978 } 979 980 Status FillEllipse(in Brush* brush, 981 in RectF rect) 982 { 983 return FillEllipse(brush, rect.X, rect.Y, rect.Width, rect.Height); 984 } 985 986 Status FillEllipse(in Brush* brush, 987 in REAL x, 988 in REAL y, 989 in REAL width, 990 in REAL height) 991 { 992 return SetStatus(GdipFillEllipse(nativeGraphics, 993 brush.nativeBrush, x, y, 994 width, height)); 995 } 996 997 Status FillEllipse(in Brush* brush, 998 in Rect rect) 999 { 1000 return FillEllipse(brush, rect.X, rect.Y, rect.Width, rect.Height); 1001 } 1002 1003 Status FillEllipse(in Brush* brush, 1004 in INT x, 1005 in INT y, 1006 in INT width, 1007 in INT height) 1008 { 1009 return SetStatus(GdipFillEllipseI(nativeGraphics, 1010 brush.nativeBrush, 1011 x, 1012 y, 1013 width, 1014 height)); 1015 } 1016 1017 Status FillPie(in Brush* brush, 1018 in RectF rect, 1019 in REAL startAngle, 1020 in REAL sweepAngle) 1021 { 1022 return FillPie(brush, rect.X, rect.Y, rect.Width, rect.Height, 1023 startAngle, sweepAngle); 1024 } 1025 1026 Status FillPie(in Brush* brush, 1027 in REAL x, 1028 in REAL y, 1029 in REAL width, 1030 in REAL height, 1031 in REAL startAngle, 1032 in REAL sweepAngle) 1033 { 1034 return SetStatus(GdipFillPie(nativeGraphics, 1035 brush.nativeBrush, x, y, 1036 width, height, startAngle, 1037 sweepAngle)); 1038 } 1039 1040 Status FillPie(in Brush* brush, 1041 in Rect rect, 1042 in REAL startAngle, 1043 in REAL sweepAngle) 1044 { 1045 return FillPie(brush, rect.X, rect.Y, rect.Width, rect.Height, 1046 startAngle, sweepAngle); 1047 } 1048 1049 Status FillPie(in Brush* brush, 1050 in INT x, 1051 in INT y, 1052 in INT width, 1053 in INT height, 1054 in REAL startAngle, 1055 in REAL sweepAngle) 1056 { 1057 return SetStatus(GdipFillPieI(nativeGraphics, 1058 brush.nativeBrush, 1059 x, 1060 y, 1061 width, 1062 height, 1063 startAngle, 1064 sweepAngle)); 1065 } 1066 1067 Status FillPath(in Brush* brush, 1068 in GraphicsPath* path) 1069 { 1070 return SetStatus(GdipFillPath(nativeGraphics, 1071 brush.nativeBrush, 1072 path.nativePath)); 1073 } 1074 1075 Status FillClosedCurve(in Brush* brush, 1076 in PointF* points, 1077 in INT count) 1078 { 1079 return SetStatus(GdipFillClosedCurve(nativeGraphics, 1080 brush.nativeBrush, 1081 points, count)); 1082 1083 } 1084 1085 Status FillClosedCurve(in Brush* brush, 1086 in PointF* points, 1087 in INT count, 1088 in FillMode fillMode, 1089 in REAL tension = 0.5f) 1090 { 1091 return SetStatus(GdipFillClosedCurve2(nativeGraphics, 1092 brush.nativeBrush, 1093 points, count, 1094 tension, fillMode)); 1095 } 1096 1097 Status FillClosedCurve(in Brush* brush, 1098 in Point* points, 1099 in INT count) 1100 { 1101 return SetStatus(GdipFillClosedCurveI(nativeGraphics, 1102 brush.nativeBrush, 1103 points, 1104 count)); 1105 } 1106 1107 Status FillClosedCurve(in Brush* brush, 1108 in Point* points, 1109 in INT count, 1110 in FillMode fillMode, 1111 in REAL tension = 0.5f) 1112 { 1113 return SetStatus(GdipFillClosedCurve2I(nativeGraphics, 1114 brush.nativeBrush, 1115 points, count, 1116 tension, fillMode)); 1117 } 1118 1119 Status FillRegion(in Brush* brush, 1120 in Region* region) 1121 { 1122 return SetStatus(GdipFillRegion(nativeGraphics, 1123 brush.nativeBrush, 1124 region.nativeRegion)); 1125 } 1126 1127 Status DrawString(in WCHAR* string, in INT length, in Font font, 1128 in RectF layoutRect, in StringFormat stringFormat, in Brush brush) { 1129 return SetStatus(GdipDrawString( 1130 nativeGraphics, 1131 string, 1132 length, 1133 font ? font.nativeFont : null, 1134 &layoutRect, 1135 stringFormat ? stringFormat.nativeFormat : null, 1136 brush ? brush.nativeBrush : null 1137 )); 1138 } 1139 1140 Status 1141 DrawString( 1142 WCHAR *string, 1143 INT length, 1144 Font font, 1145 PointF origin, 1146 Brush brush 1147 ) 1148 { 1149 RectF rect; 1150 rect.init(origin.X, origin.Y, 0.0f, 0.0f); 1151 1152 return SetStatus(GdipDrawString( 1153 nativeGraphics, 1154 string, 1155 length, 1156 font ? font.nativeFont : null, 1157 &rect, 1158 null, 1159 brush ? brush.nativeBrush : null 1160 )); 1161 } 1162 1163 Status 1164 DrawString( 1165 WCHAR *string, 1166 INT length, 1167 Font font, 1168 PointF origin, 1169 StringFormat stringFormat, 1170 Brush brush 1171 ) 1172 { 1173 RectF rect; 1174 rect.init(origin.X, origin.Y, 0.0f, 0.0f); 1175 1176 return SetStatus(GdipDrawString( 1177 nativeGraphics, 1178 string, 1179 length, 1180 font ? font.nativeFont : null, 1181 &rect, 1182 stringFormat ? stringFormat.nativeFormat : null, 1183 brush ? brush.nativeBrush : null 1184 )); 1185 } 1186 1187 Status 1188 MeasureString( 1189 in WCHAR *string, 1190 in INT length, 1191 in Font font, 1192 in RectF layoutRect, 1193 in StringFormat stringFormat, 1194 RectF *boundingBox, 1195 INT *codepointsFitted = null, 1196 INT *linesFilled = null 1197 ) { 1198 return SetStatus(GdipMeasureString( 1199 nativeGraphics, 1200 string, 1201 length, 1202 font ? font.nativeFont : null, 1203 &layoutRect, 1204 stringFormat ? stringFormat.nativeFormat : null, 1205 boundingBox, 1206 codepointsFitted, 1207 linesFilled 1208 )); 1209 } 1210 1211 Status 1212 MeasureString( 1213 in WCHAR *string, 1214 in INT length, 1215 in Font font, 1216 in SizeF *layoutRectSize, 1217 in StringFormat stringFormat, 1218 SizeF *size, 1219 INT *codepointsFitted = null, 1220 INT *linesFilled = null 1221 ) 1222 { 1223 RectF layoutRect; 1224 layoutRect.init(0, 0, layoutRectSize.Width, layoutRectSize.Height); 1225 RectF boundingBox; 1226 Status status; 1227 1228 if (size is null) { 1229 return SetStatus(Status.InvalidParameter); 1230 } 1231 1232 status = SetStatus(GdipMeasureString( 1233 nativeGraphics, 1234 string, 1235 length, 1236 font ? font.nativeFont : null, 1237 &layoutRect, 1238 stringFormat ? stringFormat.nativeFormat : null, 1239 size ? &boundingBox : null, 1240 codepointsFitted, 1241 linesFilled 1242 )); 1243 1244 if (size && status == Status.Ok) 1245 { 1246 size.Width = boundingBox.Width; 1247 size.Height = boundingBox.Height; 1248 } 1249 1250 return status; 1251 } 1252 1253 Status 1254 MeasureString( 1255 in WCHAR *string, 1256 in INT length, 1257 in Font font, 1258 in PointF origin, 1259 in StringFormat stringFormat, 1260 RectF *boundingBox 1261 ) 1262 { 1263 RectF rect; 1264 rect.init(origin.X, origin.Y, 0.0f, 0.0f); 1265 1266 return SetStatus(GdipMeasureString( 1267 nativeGraphics, 1268 string, 1269 length, 1270 font ? font.nativeFont : null, 1271 &rect, 1272 stringFormat ? stringFormat.nativeFormat : null, 1273 boundingBox, 1274 null, 1275 null 1276 )); 1277 } 1278 1279 Status 1280 MeasureString( 1281 in WCHAR *string, 1282 in INT length, 1283 in Font font, 1284 in RectF layoutRect, 1285 RectF *boundingBox 1286 ) 1287 { 1288 return SetStatus(GdipMeasureString( 1289 nativeGraphics, 1290 string, 1291 length, 1292 font ? font.nativeFont : null, 1293 &layoutRect, 1294 null, 1295 boundingBox, 1296 null, 1297 null 1298 )); 1299 } 1300 1301 Status 1302 MeasureString( 1303 in WCHAR *string, 1304 in INT length, 1305 in Font font, 1306 in PointF origin, 1307 RectF *boundingBox 1308 ) 1309 { 1310 RectF rect; 1311 rect.init(origin.X, origin.Y, 0.0f, 0.0f); 1312 1313 return SetStatus(GdipMeasureString( 1314 nativeGraphics, 1315 string, 1316 length, 1317 font ? font.nativeFont : null, 1318 &rect, 1319 null, 1320 boundingBox, 1321 null, 1322 null 1323 )); 1324 } 1325 1326 1327 Status 1328 MeasureCharacterRanges( 1329 in WCHAR *string, 1330 in INT length, 1331 in Font font, 1332 in RectF layoutRect, 1333 in StringFormat stringFormat, 1334 in INT regionCount, 1335 Region *regions 1336 ) 1337 { 1338 if (!regions || regionCount <= 0) 1339 { 1340 return Status.InvalidParameter; 1341 } 1342 1343 GpRegion*[] nativeRegions = new GpRegion* [regionCount]; 1344 1345 if (!nativeRegions) { 1346 return Status.OutOfMemory; 1347 } 1348 1349 for (INT i = 0; i < regionCount; i++) { 1350 nativeRegions[i] = regions[i].nativeRegion; 1351 } 1352 1353 Status status = SetStatus(GdipMeasureCharacterRanges( 1354 nativeGraphics, 1355 string, 1356 length, 1357 font ? font.nativeFont : null, 1358 layoutRect, 1359 stringFormat ? stringFormat.nativeFormat : null, 1360 regionCount, 1361 nativeRegions.ptr 1362 )); 1363 1364 return status; 1365 } 1366 1367 Status DrawDriverString( 1368 in UINT16 *text, 1369 in INT length, 1370 in Font font, 1371 in Brush brush, 1372 in PointF *positions, 1373 in INT flags, 1374 in Matrix matrix 1375 ) 1376 { 1377 return SetStatus(GdipDrawDriverString( 1378 nativeGraphics, 1379 text, 1380 length, 1381 font ? font.nativeFont : null, 1382 brush ? brush.nativeBrush : null, 1383 positions, 1384 flags, 1385 matrix ? matrix.nativeMatrix : null 1386 )); 1387 } 1388 1389 Status MeasureDriverString( 1390 in UINT16 *text, 1391 in INT length, 1392 in Font font, 1393 in PointF *positions, 1394 in INT flags, 1395 in Matrix matrix, 1396 RectF *boundingBox 1397 ) 1398 { 1399 return SetStatus(GdipMeasureDriverString( 1400 nativeGraphics, 1401 text, 1402 length, 1403 font ? font.nativeFont : null, 1404 positions, 1405 flags, 1406 matrix ? matrix.nativeMatrix : null, 1407 boundingBox 1408 )); 1409 } 1410 1411 // Draw a cached bitmap on this graphics destination offset by 1412 // x, y. Note this will fail with WrongState if the CachedBitmap 1413 // native format differs from this Graphics. 1414 1415 Status DrawCachedBitmap(in CachedBitmap cb, 1416 in INT x, 1417 in INT y) 1418 { 1419 return SetStatus(GdipDrawCachedBitmap( 1420 nativeGraphics, 1421 cb.nativeCachedBitmap, 1422 x, y 1423 )); 1424 } 1425 1426 Status DrawImage(in Image image, 1427 in PointF point) 1428 { 1429 return DrawImage(image, point.X, point.Y); 1430 } 1431 1432 Status DrawImage(in Image image, 1433 in REAL x, 1434 in REAL y) 1435 { 1436 return SetStatus(GdipDrawImage(nativeGraphics, 1437 image ? image.nativeImage 1438 : null, 1439 x, 1440 y)); 1441 } 1442 1443 Status DrawImage(in Image image, in RectF rect) { 1444 return DrawImage(image, rect.X, rect.Y, rect.Width, rect.Height); 1445 } 1446 1447 Status DrawImage(in Image image, 1448 in REAL x, 1449 in REAL y, 1450 in REAL width, 1451 in REAL height) 1452 { 1453 return SetStatus(GdipDrawImageRect(nativeGraphics, 1454 image ? image.nativeImage 1455 : null, 1456 x, 1457 y, 1458 width, 1459 height)); 1460 } 1461 1462 Status DrawImage(in Image image, 1463 in Point point) 1464 { 1465 return DrawImage(image, point.X, point.Y); 1466 } 1467 1468 Status DrawImage(in Image image, 1469 in INT x, 1470 in INT y) 1471 { 1472 return SetStatus(GdipDrawImageI(nativeGraphics, 1473 image ? image.nativeImage 1474 : null, 1475 x, 1476 y)); 1477 } 1478 1479 Status DrawImage(in Image image, 1480 in Rect rect) 1481 { 1482 return DrawImage(image, 1483 rect.X, 1484 rect.Y, 1485 rect.Width, 1486 rect.Height); 1487 } 1488 1489 Status DrawImage(in Image image, 1490 in INT x, 1491 in INT y, 1492 in INT width, 1493 in INT height) { 1494 return SetStatus(GdipDrawImageRectI(nativeGraphics, 1495 image ? image.nativeImage 1496 : null, 1497 x, 1498 y, 1499 width, 1500 height)); 1501 } 1502 1503 1504 Status DrawImage(in Image image, 1505 in PointF* destPoints, 1506 in INT count) 1507 { 1508 if (count != 3 && count != 4) 1509 return SetStatus(Status.InvalidParameter); 1510 1511 return SetStatus(GdipDrawImagePoints(nativeGraphics, 1512 image ? image.nativeImage 1513 : null, 1514 destPoints, count)); 1515 } 1516 1517 Status DrawImage(in Image image, 1518 in Point* destPoints, 1519 in INT count) 1520 { 1521 if (count != 3 && count != 4) 1522 return SetStatus(Status.InvalidParameter); 1523 1524 return SetStatus(GdipDrawImagePointsI(nativeGraphics, 1525 image ? image.nativeImage 1526 : null, 1527 destPoints, 1528 count)); 1529 } 1530 1531 Status DrawImage(in Image image, 1532 in REAL x, 1533 in REAL y, 1534 in REAL srcx, 1535 in REAL srcy, 1536 in REAL srcwidth, 1537 in REAL srcheight, 1538 in Unit srcUnit) 1539 { 1540 return SetStatus(GdipDrawImagePointRect(nativeGraphics, 1541 image ? image.nativeImage 1542 : null, 1543 x, y, 1544 srcx, srcy, 1545 srcwidth, srcheight, srcUnit)); 1546 } 1547 1548 Status DrawImage(in Image image, 1549 in RectF destRect, 1550 in REAL srcx, 1551 in REAL srcy, 1552 in REAL srcwidth, 1553 in REAL srcheight, 1554 in Unit srcUnit, 1555 in ImageAttributes imageAttributes = null, 1556 in DrawImageAbort callback = null, 1557 in VOID* callbackData = null) 1558 { 1559 return SetStatus(GdipDrawImageRectRect(nativeGraphics, 1560 image ? image.nativeImage 1561 : null, 1562 destRect.X, 1563 destRect.Y, 1564 destRect.Width, 1565 destRect.Height, 1566 srcx, srcy, 1567 srcwidth, srcheight, 1568 srcUnit, 1569 imageAttributes 1570 ? imageAttributes.nativeImageAttr 1571 : null, 1572 callback, 1573 callbackData)); 1574 } 1575 1576 Status DrawImage(in Image image, 1577 in PointF* destPoints, 1578 in INT count, 1579 in REAL srcx, 1580 in REAL srcy, 1581 in REAL srcwidth, 1582 in REAL srcheight, 1583 in Unit srcUnit, 1584 in ImageAttributes imageAttributes = null, 1585 in DrawImageAbort callback = null, 1586 in VOID* callbackData = null) 1587 { 1588 return SetStatus(GdipDrawImagePointsRect(nativeGraphics, 1589 image ? image.nativeImage 1590 : null, 1591 destPoints, count, 1592 srcx, srcy, 1593 srcwidth, 1594 srcheight, 1595 srcUnit, 1596 imageAttributes 1597 ? imageAttributes.nativeImageAttr 1598 : null, 1599 callback, 1600 callbackData)); 1601 } 1602 1603 Status DrawImage(in Image image, 1604 in INT x, 1605 in INT y, 1606 in INT srcx, 1607 in INT srcy, 1608 in INT srcwidth, 1609 in INT srcheight, 1610 in Unit srcUnit) 1611 { 1612 return SetStatus(GdipDrawImagePointRectI(nativeGraphics, 1613 image ? image.nativeImage 1614 : null, 1615 x, 1616 y, 1617 srcx, 1618 srcy, 1619 srcwidth, 1620 srcheight, 1621 srcUnit)); 1622 } 1623 1624 Status DrawImage(in Image image, 1625 in Rect destRect, 1626 in INT srcx, 1627 in INT srcy, 1628 in INT srcwidth, 1629 in INT srcheight, 1630 in Unit srcUnit, 1631 in ImageAttributes imageAttributes = null, 1632 in DrawImageAbort callback = null, 1633 in VOID* callbackData = null) 1634 { 1635 return SetStatus(GdipDrawImageRectRectI(nativeGraphics, 1636 image ? image.nativeImage 1637 : null, 1638 destRect.X, 1639 destRect.Y, 1640 destRect.Width, 1641 destRect.Height, 1642 srcx, 1643 srcy, 1644 srcwidth, 1645 srcheight, 1646 srcUnit, 1647 imageAttributes 1648 ? imageAttributes.nativeImageAttr 1649 : null, 1650 callback, 1651 callbackData)); 1652 } 1653 1654 Status DrawImage(in Image image, 1655 in Point* destPoints, 1656 in INT count, 1657 in INT srcx, 1658 in INT srcy, 1659 in INT srcwidth, 1660 in INT srcheight, 1661 in Unit srcUnit, 1662 in ImageAttributes imageAttributes = null, 1663 in DrawImageAbort callback = null, 1664 in VOID* callbackData = null) 1665 { 1666 return SetStatus(GdipDrawImagePointsRectI(nativeGraphics, 1667 image ? image.nativeImage 1668 : null, 1669 destPoints, 1670 count, 1671 srcx, 1672 srcy, 1673 srcwidth, 1674 srcheight, 1675 srcUnit, 1676 imageAttributes 1677 ? imageAttributes.nativeImageAttr 1678 : null, 1679 callback, 1680 callbackData)); 1681 } 1682 1683 Status DrawImage( 1684 in Image image, 1685 in RectF destRect, 1686 in RectF sourceRect, 1687 in Unit srcUnit, 1688 in ImageAttributes *imageAttributes = null 1689 ) 1690 { 1691 return SetStatus(GdipDrawImageRectRect( 1692 nativeGraphics, 1693 image.nativeImage, 1694 destRect.X, 1695 destRect.Y, 1696 destRect.Width, 1697 destRect.Height, 1698 sourceRect.X, 1699 sourceRect.Y, 1700 sourceRect.Width, 1701 sourceRect.Height, 1702 srcUnit, 1703 imageAttributes ? imageAttributes.nativeImageAttr : null, 1704 null, 1705 null 1706 )); 1707 } 1708 1709version(GDIPLUS6) { 1710 Status DrawImage( 1711 in Image image, 1712 in RectF *sourceRect, 1713 in Matrix xForm, 1714 in Effect effect, 1715 in ImageAttributes imageAttributes, 1716 in Unit srcUnit 1717 ) 1718 { 1719 return SetStatus(GdipDrawImageFX( 1720 nativeGraphics, 1721 image.nativeImage, 1722 sourceRect, 1723 xForm ? xForm.nativeMatrix : null, 1724 effect ? effect.nativeEffect : null, 1725 imageAttributes ? imageAttributes.nativeImageAttr : null, 1726 srcUnit 1727 )); 1728 } 1729} 1730 1731 // The following methods are for playing an EMF+ to a graphics 1732 // via the enumeration interface. Each record of the EMF+ is 1733 // sent to the callback (along with the callbackData). Then 1734 // the callback can invoke the Metafile::PlayRecord method 1735 // to play the particular record. 1736 1737 Status 1738 EnumerateMetafile( 1739 in Metafile * metafile, 1740 in PointF destPoint, 1741 in EnumerateMetafileProc callback, 1742 in VOID * callbackData = null, 1743 in ImageAttributes * imageAttributes = null 1744 ) 1745 { 1746 return SetStatus(GdipEnumerateMetafileDestPoint( 1747 nativeGraphics, 1748 cast( GpMetafile *)(metafile ? metafile.nativeImage:null), 1749 destPoint, 1750 callback, 1751 callbackData, 1752 imageAttributes ? imageAttributes.nativeImageAttr : null)); 1753 } 1754 1755 Status 1756 EnumerateMetafile( 1757 in Metafile * metafile, 1758 in Point destPoint, 1759 in EnumerateMetafileProc callback, 1760 in VOID * callbackData = null, 1761 in ImageAttributes * imageAttributes = null 1762 ) 1763 { 1764 return SetStatus(GdipEnumerateMetafileDestPointI( 1765 nativeGraphics, 1766 cast( GpMetafile *)(metafile ? metafile.nativeImage:null), 1767 destPoint, 1768 callback, 1769 callbackData, 1770 imageAttributes ? imageAttributes.nativeImageAttr : null)); 1771 } 1772 1773 Status 1774 EnumerateMetafile( 1775 in Metafile * metafile, 1776 in RectF destRect, 1777 in EnumerateMetafileProc callback, 1778 in VOID * callbackData = null, 1779 in ImageAttributes * imageAttributes = null 1780 ) 1781 { 1782 return SetStatus(GdipEnumerateMetafileDestRect( 1783 nativeGraphics, 1784 cast(GpMetafile *)(metafile ? metafile.nativeImage:null), 1785 destRect, 1786 callback, 1787 callbackData, 1788 imageAttributes ? imageAttributes.nativeImageAttr : null)); 1789 } 1790 1791 Status 1792 EnumerateMetafile( 1793 in Metafile * metafile, 1794 in Rect destRect, 1795 in EnumerateMetafileProc callback, 1796 in VOID * callbackData = null, 1797 in ImageAttributes * imageAttributes = null 1798 ) 1799 { 1800 return SetStatus(GdipEnumerateMetafileDestRectI( 1801 nativeGraphics, 1802 cast(GpMetafile *)(metafile ? metafile.nativeImage:null), 1803 destRect, 1804 callback, 1805 callbackData, 1806 imageAttributes ? imageAttributes.nativeImageAttr : null)); 1807 } 1808 1809 Status 1810 EnumerateMetafile( 1811 in Metafile * metafile, 1812 in PointF * destPoints, 1813 in INT count, 1814 in EnumerateMetafileProc callback, 1815 in VOID * callbackData = null, 1816 in ImageAttributes * imageAttributes = null 1817 ) 1818 { 1819 return SetStatus(GdipEnumerateMetafileDestPoints( 1820 nativeGraphics, 1821 cast(GpMetafile *)(metafile ? metafile.nativeImage:null), 1822 destPoints, 1823 count, 1824 callback, 1825 callbackData, 1826 imageAttributes ? imageAttributes.nativeImageAttr : null)); 1827 } 1828 1829 Status 1830 EnumerateMetafile( 1831 in Metafile * metafile, 1832 in Point * destPoints, 1833 in INT count, 1834 in EnumerateMetafileProc callback, 1835 in VOID * callbackData = null, 1836 in ImageAttributes * imageAttributes = null 1837 ) 1838 { 1839 return SetStatus(GdipEnumerateMetafileDestPointsI( 1840 nativeGraphics, 1841 cast(GpMetafile *)(metafile ? metafile.nativeImage:null), 1842 destPoints, 1843 count, 1844 callback, 1845 callbackData, 1846 imageAttributes ? imageAttributes.nativeImageAttr : null)); 1847 } 1848 1849 Status 1850 EnumerateMetafile( 1851 in Metafile * metafile, 1852 in PointF destPoint, 1853 in RectF srcRect, 1854 in Unit srcUnit, 1855 in EnumerateMetafileProc callback, 1856 in VOID * callbackData = null, 1857 in ImageAttributes * imageAttributes = null 1858 ) 1859 { 1860 return SetStatus(GdipEnumerateMetafileSrcRectDestPoint( 1861 nativeGraphics, 1862 cast(GpMetafile *)(metafile ? metafile.nativeImage:null), 1863 destPoint, 1864 srcRect, 1865 srcUnit, 1866 callback, 1867 callbackData, 1868 imageAttributes ? imageAttributes.nativeImageAttr : null)); 1869 } 1870 1871 Status 1872 EnumerateMetafile( 1873 in Metafile * metafile, 1874 in Point destPoint, 1875 in Rect srcRect, 1876 in Unit srcUnit, 1877 in EnumerateMetafileProc callback, 1878 in VOID * callbackData = null, 1879 in ImageAttributes * imageAttributes = null 1880 ) 1881 { 1882 return SetStatus(GdipEnumerateMetafileSrcRectDestPointI( 1883 nativeGraphics, 1884 cast(GpMetafile *)(metafile ? metafile.nativeImage:null), 1885 destPoint, 1886 srcRect, 1887 srcUnit, 1888 callback, 1889 callbackData, 1890 imageAttributes ? imageAttributes.nativeImageAttr : null)); 1891 } 1892 1893 Status 1894 EnumerateMetafile( 1895 in Metafile * metafile, 1896 in RectF destRect, 1897 in RectF srcRect, 1898 in Unit srcUnit, 1899 in EnumerateMetafileProc callback, 1900 in VOID * callbackData = null, 1901 in ImageAttributes * imageAttributes = null 1902 ) 1903 { 1904 return SetStatus(GdipEnumerateMetafileSrcRectDestRect( 1905 nativeGraphics, 1906 cast(GpMetafile *)(metafile ? metafile.nativeImage:null), 1907 destRect, 1908 srcRect, 1909 srcUnit, 1910 callback, 1911 callbackData, 1912 imageAttributes ? imageAttributes.nativeImageAttr : null)); 1913 } 1914 1915 Status 1916 EnumerateMetafile( 1917 in Metafile metafile, 1918 in Rect destRect, 1919 in Rect srcRect, 1920 in Unit srcUnit, 1921 in EnumerateMetafileProc callback, 1922 in VOID * callbackData = null, 1923 in ImageAttributes imageAttributes = null 1924 ) 1925 { 1926 return SetStatus(GdipEnumerateMetafileSrcRectDestRectI( 1927 nativeGraphics, 1928 cast(GpMetafile *)(metafile ? metafile.nativeImage:null), 1929 destRect, 1930 srcRect, 1931 srcUnit, 1932 callback, 1933 callbackData, 1934 imageAttributes ? imageAttributes.nativeImageAttr : null)); 1935 } 1936 1937 Status 1938 EnumerateMetafile( 1939 in Metafile metafile, 1940 in PointF * destPoints, 1941 in INT count, 1942 in RectF srcRect, 1943 in Unit srcUnit, 1944 in EnumerateMetafileProc callback, 1945 in VOID * callbackData = null, 1946 in ImageAttributes imageAttributes = null 1947 ) 1948 { 1949 return SetStatus(GdipEnumerateMetafileSrcRectDestPoints( 1950 nativeGraphics, 1951 cast(GpMetafile *)(metafile ? metafile.nativeImage:null), 1952 destPoints, 1953 count, 1954 srcRect, 1955 srcUnit, 1956 callback, 1957 callbackData, 1958 imageAttributes ? imageAttributes.nativeImageAttr : null)); 1959 } 1960 1961 Status 1962 EnumerateMetafile( 1963 in Metafile metafile, 1964 in Point[] destPoints, 1965 in INT count, 1966 in Rect srcRect, 1967 in Unit srcUnit, 1968 in EnumerateMetafileProc callback, 1969 in VOID * callbackData = null, 1970 in ImageAttributes imageAttributes = null 1971 ) 1972 { 1973 return SetStatus(GdipEnumerateMetafileSrcRectDestPointsI( 1974 nativeGraphics, 1975 cast(GpMetafile *)(metafile ? metafile.nativeImage:null), 1976 destPoints.ptr, 1977 count, 1978 srcRect, 1979 srcUnit, 1980 callback, 1981 callbackData, 1982 imageAttributes ? imageAttributes.nativeImageAttr : null)); 1983 } 1984 1985 Status SetClip(in Graphics g, 1986 in CombineMode combineMode = CombineMode.CombineModeReplace) 1987 { 1988 return SetStatus(GdipSetClipGraphics(nativeGraphics, 1989 g.nativeGraphics, 1990 combineMode)); 1991 } 1992 1993 Status SetClip(in RectF rect, 1994 in CombineMode combineMode = CombineMode.CombineModeReplace) 1995 { 1996 return SetStatus(GdipSetClipRect(nativeGraphics, 1997 rect.X, rect.Y, 1998 rect.Width, rect.Height, 1999 combineMode)); 2000 } 2001 2002 Status SetClip(in Rect rect, 2003 in CombineMode combineMode = CombineMode.CombineModeReplace) 2004 { 2005 return SetStatus(GdipSetClipRectI(nativeGraphics, 2006 rect.X, rect.Y, 2007 rect.Width, rect.Height, 2008 combineMode)); 2009 } 2010 2011 Status SetClip(in GraphicsPath path, 2012 in CombineMode combineMode = CombineMode.CombineModeReplace) 2013 { 2014 return SetStatus(GdipSetClipPath(nativeGraphics, 2015 path.nativePath, 2016 combineMode)); 2017 } 2018 2019 Status SetClip(in Region region, 2020 in CombineMode combineMode = CombineMode.CombineModeReplace) 2021 { 2022 return SetStatus(GdipSetClipRegion(nativeGraphics, 2023 region.nativeRegion, 2024 combineMode)); 2025 } 2026 2027 // This is different than the other SetClip methods because it assumes 2028 // that the HRGN is already in device units, so it doesn't transform 2029 // the coordinates in the HRGN. 2030 2031 Status SetClip(in HRGN hRgn, 2032 in CombineMode combineMode = CombineMode.CombineModeReplace) 2033 { 2034 return SetStatus(GdipSetClipHrgn(nativeGraphics, hRgn, 2035 combineMode)); 2036 } 2037 2038 Status IntersectClip(in RectF rect) 2039 { 2040 return SetStatus(GdipSetClipRect(nativeGraphics, 2041 rect.X, rect.Y, 2042 rect.Width, rect.Height, 2043 CombineMode.CombineModeIntersect)); 2044 } 2045 2046 Status IntersectClip(in Rect rect) 2047 { 2048 return SetStatus(GdipSetClipRectI(nativeGraphics, 2049 rect.X, rect.Y, 2050 rect.Width, rect.Height, 2051 CombineMode.CombineModeIntersect)); 2052 } 2053 2054 Status IntersectClip(in Region* region) 2055 { 2056 return SetStatus(GdipSetClipRegion(nativeGraphics, 2057 region.nativeRegion, 2058 CombineMode.CombineModeIntersect)); 2059 } 2060 2061 Status ExcludeClip(in RectF rect) 2062 { 2063 return SetStatus(GdipSetClipRect(nativeGraphics, 2064 rect.X, rect.Y, 2065 rect.Width, rect.Height, 2066 CombineMode.CombineModeExclude)); 2067 } 2068 2069 Status ExcludeClip(in Rect rect) 2070 { 2071 return SetStatus(GdipSetClipRectI(nativeGraphics, 2072 rect.X, rect.Y, 2073 rect.Width, rect.Height, 2074 CombineMode.CombineModeExclude)); 2075 } 2076 2077 Status ExcludeClip(in Region* region) 2078 { 2079 return SetStatus(GdipSetClipRegion(nativeGraphics, 2080 region.nativeRegion, 2081 CombineMode.CombineModeExclude)); 2082 } 2083 2084 Status ResetClip() 2085 { 2086 return SetStatus(GdipResetClip(nativeGraphics)); 2087 } 2088 2089 Status TranslateClip(in REAL dx, 2090 in REAL dy) 2091 { 2092 return SetStatus(GdipTranslateClip(nativeGraphics, dx, dy)); 2093 } 2094 2095 Status TranslateClip(in INT dx, 2096 in INT dy) 2097 { 2098 return SetStatus(GdipTranslateClipI(nativeGraphics, 2099 dx, dy)); 2100 } 2101 2102 Status GetClip(Region* region) 2103 { 2104 return SetStatus(GdipGetClip(nativeGraphics, 2105 region.nativeRegion)); 2106 } 2107 2108 Status GetClipBounds(RectF* rect) 2109 { 2110 return SetStatus(GdipGetClipBounds(nativeGraphics, rect)); 2111 } 2112 2113 Status GetClipBounds(Rect* rect) 2114 { 2115 return SetStatus(GdipGetClipBoundsI(nativeGraphics, rect)); 2116 } 2117 2118 BOOL IsClipEmpty() 2119 { 2120 BOOL booln = FALSE; 2121 2122 SetStatus(GdipIsClipEmpty(nativeGraphics, &booln)); 2123 2124 return booln; 2125 } 2126 2127 Status GetVisibleClipBounds(RectF *rect) 2128 { 2129 2130 return SetStatus(GdipGetVisibleClipBounds(nativeGraphics, 2131 rect)); 2132 } 2133 2134 Status GetVisibleClipBounds(Rect *rect) 2135 { 2136 return SetStatus(GdipGetVisibleClipBoundsI(nativeGraphics, 2137 rect)); 2138 } 2139 2140 BOOL IsVisibleClipEmpty() 2141 { 2142 BOOL booln = FALSE; 2143 2144 SetStatus(GdipIsVisibleClipEmpty(nativeGraphics, &booln)); 2145 2146 return booln; 2147 } 2148 2149 BOOL IsVisible(in INT x, 2150 in INT y) 2151 { 2152 return IsVisible(Point(x,y)); 2153 } 2154 2155 BOOL IsVisible(in Point point) 2156 { 2157 BOOL booln = FALSE; 2158 2159 SetStatus(GdipIsVisiblePointI(nativeGraphics, 2160 point.X, 2161 point.Y, 2162 &booln)); 2163 2164 return booln; 2165 } 2166 2167 BOOL IsVisible(in INT x, 2168 in INT y, 2169 in INT width, 2170 in INT height) 2171 { 2172 return IsVisible(Rect(x, y, width, height)); 2173 } 2174 2175 BOOL IsVisible(in Rect rect) 2176 { 2177 2178 BOOL booln = TRUE; 2179 2180 SetStatus(GdipIsVisibleRectI(nativeGraphics, 2181 rect.X, 2182 rect.Y, 2183 rect.Width, 2184 rect.Height, 2185 &booln)); 2186 return booln; 2187 } 2188 2189 BOOL IsVisible(in REAL x, 2190 in REAL y) 2191 { 2192 return IsVisible(PointF(x, y)); 2193 } 2194 2195 BOOL IsVisible(in PointF point) 2196 { 2197 BOOL booln = FALSE; 2198 2199 SetStatus(GdipIsVisiblePoint(nativeGraphics, 2200 point.X, 2201 point.Y, 2202 &booln)); 2203 2204 return booln; 2205 } 2206 2207 BOOL IsVisible(in REAL x, 2208 in REAL y, 2209 in REAL width, 2210 in REAL height) { 2211 RectF rect; 2212 rect.init(x, y, width, height); 2213 return IsVisible(rect); 2214 } 2215 2216 BOOL IsVisible(in RectF rect) { 2217 BOOL booln = TRUE; 2218 2219 SetStatus(GdipIsVisibleRect(nativeGraphics, 2220 rect.X, 2221 rect.Y, 2222 rect.Width, 2223 rect.Height, 2224 &booln)); 2225 return booln; 2226 } 2227 2228 GraphicsState Save() 2229 { 2230 GraphicsState gstate; 2231 2232 SetStatus(GdipSaveGraphics(nativeGraphics, &gstate)); 2233 2234 return gstate; 2235 } 2236 2237 Status Restore(in GraphicsState gstate) 2238 { 2239 return SetStatus(GdipRestoreGraphics(nativeGraphics, 2240 gstate)); 2241 } 2242 2243 GraphicsContainer BeginContainer(in RectF dstrect, 2244 in RectF srcrect, 2245 in Unit unit) 2246 { 2247 GraphicsContainer state; 2248 2249 SetStatus(GdipBeginContainer(nativeGraphics, &dstrect, 2250 &srcrect, unit, &state)); 2251 2252 return state; 2253 } 2254 2255 GraphicsContainer BeginContainer(in Rect dstrect, 2256 in Rect srcrect, 2257 in Unit unit) 2258 { 2259 GraphicsContainer state; 2260 2261 SetStatus(GdipBeginContainerI(nativeGraphics, &dstrect, 2262 &srcrect, unit, &state)); 2263 2264 return state; 2265 } 2266 2267 GraphicsContainer BeginContainer() 2268 { 2269 GraphicsContainer state; 2270 2271 SetStatus(GdipBeginContainer2(nativeGraphics, &state)); 2272 2273 return state; 2274 } 2275 2276 Status EndContainer(in GraphicsContainer state) 2277 { 2278 return SetStatus(GdipEndContainer(nativeGraphics, state)); 2279 } 2280 2281 // Only valid when recording metafiles. 2282 2283 Status AddMetafileComment(in BYTE * data, 2284 in UINT sizeData) 2285 { 2286 return SetStatus(GdipComment(nativeGraphics, sizeData, data)); 2287 } 2288 2289 static HPALETTE GetHalftonePalette() 2290 { 2291 return GdipCreateHalftonePalette(); 2292 } 2293 2294 Status GetLastStatus() 2295 { 2296 Status lastStatus = lastResult; 2297 lastResult = Status.Ok; 2298 2299 return lastStatus; 2300 } 2301 2302protected: 2303 package this(GpGraphics* graphics) { 2304 lastResult = Status.Ok; 2305 SetNativeGraphics(graphics); 2306 } 2307 2308 VOID SetNativeGraphics(GpGraphics *graphics) 2309 { 2310 this.nativeGraphics = graphics; 2311 } 2312 2313 Status SetStatus(Status status) 2314 { 2315 if (status != Status.Ok) 2316 return (lastResult = status); 2317 else 2318 return status; 2319 } 2320 2321 GpGraphics* GetNativeGraphics() 2322 { 2323 return this.nativeGraphics; 2324 } 2325 2326 GpPen* GetNativePen(Pen pen) { 2327 return pen.nativePen; 2328 } 2329 2330protected: 2331 package GpGraphics* nativeGraphics; 2332 package Status lastResult; 2333 2334} 2335