[7/7] gdiplus: GdipDrawPath

Evan Stade estade at gmail.com
Thu Jun 21 18:15:34 CDT 2007


Hi,

Changelog:
*added GdipDrawPath

 dlls/gdiplus/gdiplus.spec |    2 +
 dlls/gdiplus/graphics.c   |   76 +++++++++++++++++++++++++++++++++++++++++++++
 include/gdiplusflat.h     |    1 +
 3 files changed, 78 insertions(+), 1 deletions(-)

-- 
Evan Stade
-------------- next part --------------
diff --git a/dlls/gdiplus/gdiplus.spec b/dlls/gdiplus/gdiplus.spec
index 6641aaa..d1d041b 100644
--- a/dlls/gdiplus/gdiplus.spec
+++ b/dlls/gdiplus/gdiplus.spec
@@ -178,7 +178,7 @@
 @ stdcall GdipDrawLineI(ptr ptr long long long long)
 @ stdcall GdipDrawLines(ptr ptr ptr long)
 @ stub GdipDrawLinesI
-@ stub GdipDrawPath
+@ stdcall GdipDrawPath(ptr ptr ptr)
 @ stdcall GdipDrawPie(ptr ptr long long long long long long)
 @ stub GdipDrawPieI
 @ stub GdipDrawPolygon
diff --git a/dlls/gdiplus/graphics.c b/dlls/gdiplus/graphics.c
index beba700..f24d054 100644
--- a/dlls/gdiplus/graphics.c
+++ b/dlls/gdiplus/graphics.c
@@ -27,6 +27,8 @@ #include "gdiplus.h"
 #include "gdiplus_private.h"
 #include "wine/debug.h"
 
+WINE_DEFAULT_DEBUG_CHANNEL(gdiplus);
+
 /* looks-right constant */
 #define TENSION_CONST (0.3)
 
@@ -280,6 +282,80 @@ GpStatus WINGDIPAPI GdipDrawLines(GpGrap
     return Ok;
 }
 
+GpStatus WINGDIPAPI GdipDrawPath(GpGraphics *graphics, GpPen *pen, GpPath *path)
+{
+    HGDIOBJ old_obj;
+    INT i, j, num_bezier;
+    BYTE pttype;
+    LPPOINT pt;
+    GpStatus ret;
+
+    TRACE("called, with %d total points\n", path->pathdata.Count);
+
+    if(!pen || !graphics || !path)
+        return InvalidParameter;
+
+    old_obj = SelectObject(graphics->hdc, pen->gdipen);
+
+    for(i = 0; i < path->pathdata.Count; i++){
+        pttype = (path->pathdata.Types)[i] & PathPointTypePathTypeMask;
+        switch(pttype){
+            case PathPointTypeLine:
+
+                LineTo(graphics->hdc, path->pathdata.Points[i].X,
+                    path->pathdata.Points[i].Y);
+
+                break;
+
+            case PathPointTypeStart:
+
+                MoveToEx(graphics->hdc, path->pathdata.Points[i].X,
+                    path->pathdata.Points[i].Y, NULL);
+
+                break;
+
+            case PathPointTypeBezier:
+
+                /* count number of consecutive bezier points */
+                for(num_bezier = 1; i + num_bezier < path->pathdata.Count;
+                    num_bezier++){
+                    pttype = (path->pathdata.Types)[i + num_bezier] &
+                        PathPointTypePathTypeMask;
+                    if(pttype != PathPointTypeBezier)
+                        break;
+                }
+
+                if((num_bezier % 3) != 0){
+                    FIXME("found %d bezier points starting at %d, expected x*3\n",
+                        num_bezier, i);
+                    ret = GenericError;
+                    goto pathend;
+                }
+
+                pt = GdipAlloc(sizeof(POINT) * num_bezier);
+
+                for(j = 0; j < num_bezier; j++){
+                    pt[j].x = roundr((path->pathdata.Points)[i + j].X);
+                    pt[j].y = roundr((path->pathdata.Points)[i + j].Y);
+                }
+
+                PolyBezierTo(graphics->hdc, pt, num_bezier);
+                GdipFree(pt);
+
+                i += num_bezier - 1;
+
+                break;
+        }
+    }
+
+    ret = Ok;
+
+pathend:
+    SelectObject(graphics->hdc, old_obj);
+
+    return ret;
+}
+
 GpStatus WINGDIPAPI GdipDrawPie(GpGraphics *graphics, GpPen *pen, REAL x,
     REAL y, REAL width, REAL height, REAL startAngle, REAL sweepAngle)
 {
diff --git a/include/gdiplusflat.h b/include/gdiplusflat.h
index 1d40b45..88e11d0 100644
--- a/include/gdiplusflat.h
+++ b/include/gdiplusflat.h
@@ -39,6 +39,7 @@ GpStatus WINGDIPAPI GdipDrawBezier(GpGra
 GpStatus WINGDIPAPI GdipDrawCurve2(GpGraphics*,GpPen*,GDIPCONST GpPointF*,INT,REAL);
 GpStatus WINGDIPAPI GdipDrawLineI(GpGraphics*,GpPen*,INT,INT,INT,INT);
 GpStatus WINGDIPAPI GdipDrawLines(GpGraphics*,GpPen*,GDIPCONST GpPointF*,INT);
+GpStatus WINGDIPAPI GdipDrawPath(GpGraphics*,GpPen*,GpPath*);
 GpStatus WINGDIPAPI GdipDrawPie(GpGraphics*,GpPen*,REAL,REAL,REAL,REAL,REAL,REAL);
 GpStatus WINGDIPAPI GdipDrawRectangleI(GpGraphics*,GpPen*,INT,INT,INT,INT);
 GpStatus WINGDIPAPI GdipFillPie(GpGraphics*,GpBrush*,REAL,REAL,REAL,REAL,REAL,REAL);
-- 
1.4.1


More information about the wine-patches mailing list