gdiplus: GdipDrawPie/GdipFillPie [try3]
Evan Stade
estade at gmail.com
Mon Jun 18 18:55:51 CDT 2007
Hi,
This is a [try3] but it's the same as the previous patches (before it
got rejected for depending on other patches that didn't get
committed).
Changelog:
*added some helper functions to graphics.c
*implemented GdipDrawPie/GdipFillPie
dlls/gdiplus/gdiplus.spec | 4 +--
dlls/gdiplus/graphics.c | 65 +++++++++++++++++++++++++++++++++++++++++++++
include/gdiplusflat.h | 1 +
3 files changed, 68 insertions(+), 2 deletions(-)
--
Evan Stade
-------------- next part --------------
diff --git a/dlls/gdiplus/gdiplus.spec b/dlls/gdiplus/gdiplus.spec
index 483c3f4..4916853 100644
--- a/dlls/gdiplus/gdiplus.spec
+++ b/dlls/gdiplus/gdiplus.spec
@@ -179,7 +179,7 @@
@ stub GdipDrawLines
@ stub GdipDrawLinesI
@ stub GdipDrawPath
-@ stub GdipDrawPie
+@ stdcall GdipDrawPie(ptr ptr long long long long long long)
@ stub GdipDrawPieI
@ stub GdipDrawPolygon
@ stub GdipDrawPolygonI
@@ -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 b45293f..b1974ad 100644
--- a/dlls/gdiplus/graphics.c
+++ b/dlls/gdiplus/graphics.c
@@ -32,6 +32,51 @@ static inline INT roundr(REAL x)
return (INT) floor(x+0.5);
}
+static inline REAL deg2rad(REAL degrees)
+{
+ return (M_PI*2.0) * degrees / 360.0;
+}
+
+/* Converts angle (in degrees) to x/y coordinates */
+static void deg2xy(REAL angle, REAL x_0, REAL y_0, REAL *x, REAL *y)
+{
+ REAL radAngle, hypotenuse;
+
+ radAngle = deg2rad(angle);
+ hypotenuse = 50.0; /* arbitrary */
+
+ *x = x_0 + cos(radAngle) * hypotenuse;
+ *y = y_0 + sin(radAngle) * hypotenuse;
+}
+
+/* GdipDrawPie/GdipFillPie helper function */
+static GpStatus DrawPie(GpGraphics *graphics, HBRUSH gdibrush, HPEN gdipen,
+ REAL x, REAL y, REAL width, REAL height, REAL startAngle, REAL sweepAngle)
+{
+ HGDIOBJ old_pen, old_brush;
+ REAL x_0, y_0, x_1, y_1, x_2, y_2;
+
+ if(!graphics)
+ return InvalidParameter;
+
+ old_pen = SelectObject(graphics->hdc, gdipen);
+ old_brush = SelectObject(graphics->hdc, gdibrush);
+
+ x_0 = x + (width/2.0);
+ y_0 = y + (height/2.0);
+
+ deg2xy(startAngle+sweepAngle, x_0, y_0, &x_1, &y_1);
+ deg2xy(startAngle, x_0, y_0, &x_2, &y_2);
+
+ Pie(graphics->hdc, roundr(x), roundr(y), roundr(x+width), roundr(y+height),
+ roundr(x_1), roundr(y_1), roundr(x_2), roundr(y_2));
+
+ SelectObject(graphics->hdc, old_pen);
+ SelectObject(graphics->hdc, old_brush);
+
+ return Ok;
+}
+
GpStatus WINGDIPAPI GdipCreateFromHDC(HDC hdc, GpGraphics **graphics)
{
if(hdc == NULL)
@@ -106,6 +151,16 @@ GpStatus WINGDIPAPI GdipDrawLineI(GpGrap
return Ok;
}
+GpStatus WINGDIPAPI GdipDrawPie(GpGraphics *graphics, GpPen *pen, REAL x,
+ REAL y, REAL width, REAL height, REAL startAngle, REAL sweepAngle)
+{
+ if(!pen)
+ return InvalidParameter;
+
+ return DrawPie(graphics, GetStockObject(NULL_BRUSH), pen->gdipen, x, y,
+ width, height, startAngle, sweepAngle);
+}
+
GpStatus WINGDIPAPI GdipDrawRectangleI(GpGraphics *graphics, GpPen *pen, INT x,
INT y, INT width, INT height)
{
@@ -137,3 +192,13 @@ 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)
+{
+ if(!brush)
+ return InvalidParameter;
+
+ return DrawPie(graphics, brush->gdibrush, GetStockObject(NULL_PEN), x, y,
+ width, height, startAngle, sweepAngle);
+}
diff --git a/include/gdiplusflat.h b/include/gdiplusflat.h
index 3220cb2..e949301 100644
--- a/include/gdiplusflat.h
+++ b/include/gdiplusflat.h
@@ -34,6 +34,7 @@ GpStatus WINGDIPAPI GdipDeleteGraphics(G
GpStatus WINGDIPAPI GdipDrawBezier(GpGraphics*,GpPen*,REAL,REAL,REAL,REAL,REAL,
REAL,REAL,REAL);
GpStatus WINGDIPAPI GdipDrawLineI(GpGraphics*,GpPen*,INT,INT,INT,INT);
+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