[GDI+: 5/5] Added GdipFillPie

Evan Stade estade at gmail.com
Fri Jun 8 15:53:36 CDT 2007


Hi,

changelog:
*implemented GdipFillPie method

 dlls/gdiplus/gdiplus.spec |    2 +-
 dlls/gdiplus/graphics.c   |   53 +++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 54 insertions(+), 1 deletions(-)

-Evan Stade
-------------- next part --------------
diff --git a/dlls/gdiplus/gdiplus.spec b/dlls/gdiplus/gdiplus.spec
index 4268d26..de17258 100644
--- a/dlls/gdiplus/gdiplus.spec
+++ b/dlls/gdiplus/gdiplus.spec
@@ -209,7 +209,7 @@
 @ stub GdipFillEllipse
 @ stub GdipFillEllipseI
 @ stub GdipFillPath
-@ stub GdipFillPie
+@ stdcall GdipFillPie(ptr ptr long long long long long long)
 @ stub GdipFillPieI
 @ stub GdipFillPolygon2
 @ stub GdipFillPolygon2I
diff --git a/dlls/gdiplus/graphics.c b/dlls/gdiplus/graphics.c
index d2a4317..95f0498 100644
--- a/dlls/gdiplus/graphics.c
+++ b/dlls/gdiplus/graphics.c
@@ -27,6 +27,16 @@ #include "gdiplus.h"
 #include "gdiplus_private.h"
 #include "wine/debug.h"
 
+static inline REAL deg2rad(REAL degrees)
+{
+    return (M_PI*2.0) * degrees / 360.0;
+}
+
+static inline INT round(REAL x)
+{
+    return (INT) floor(x+0.5);
+}
+
 GpStatus WINGDIPAPI GdipCreateFromHDC(HDC hdc, GpGraphics **graphics)
 {
     if(hdc == NULL)
@@ -113,3 +123,46 @@ GpStatus WINGDIPAPI GdipDrawRectangleI(G
 
     return Ok;
 }
+
+GpStatus WINGDIPAPI GdipFillPie(GpGraphics *graphics, GpBrush *brush, REAL x, 
+    REAL y, REAL width, REAL height, REAL startAngle, REAL sweepAngle)
+{
+    LOGBRUSH lb;
+    HPEN hpen;
+    HGDIOBJ old_pen, old_brush;
+    REAL x_0, y_0, radStartAngle, radFinishAngle, hypotenuse,
+        x_1, y_1, x_2, y_2;
+
+    if(!brush || !graphics)
+        return InvalidParameter;
+
+    lb.lbStyle = BS_SOLID;
+    lb.lbColor = brush->color;
+    lb.lbHatch = 0;
+
+    hpen = ExtCreatePen(PS_GEOMETRIC | PS_ENDCAP_SQUARE, 1, &lb, 0, NULL);
+
+    old_pen = SelectObject(graphics->hdc, hpen);
+    old_brush = SelectObject(graphics->hdc, brush->gdibrush);
+
+    x_0 = x + (width/2.0);
+    y_0 = y + (height/2.0);
+    radStartAngle = deg2rad(startAngle);
+    radFinishAngle = deg2rad(startAngle+sweepAngle);
+    hypotenuse = 50.0; /* arbitrary */
+
+    x_1 = x_0 + cos(radFinishAngle) * hypotenuse;
+    y_1 = y_0 + sin(radFinishAngle) * hypotenuse;
+    x_2 = x_0 + cos(radStartAngle) * hypotenuse;
+    y_2 = y_0 + sin(radStartAngle) * hypotenuse;
+
+    Pie(graphics->hdc, round(x), round(y), round(x+width), round(y+height),
+        round(x_1), round(y_1), round(x_2), round(y_2));
+
+    SelectObject(graphics->hdc, old_pen);
+    SelectObject(graphics->hdc, old_brush);
+    DeleteObject(hpen);
+
+    return Ok;
+
+}
-- 
1.4.1


More information about the wine-patches mailing list