GdiPlusGraphics.h
Upload User: dzyhzl
Upload Date: 2019-04-29
Package Size: 56270k
Code Size: 86k
Development Platform:

C/C++

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