[1/4] gdiplus: draw custom dashes
Evan Stade
estade at gmail.com
Fri Jul 27 18:07:39 CDT 2007
Hi,
dlls/gdiplus/gdiplus_private.h | 1 +
dlls/gdiplus/graphics.c | 20 ++++++++++++++++++--
dlls/gdiplus/pen.c | 8 ++------
3 files changed, 21 insertions(+), 8 deletions(-)
--
Evan Stade
-------------- next part --------------
diff --git a/dlls/gdiplus/gdiplus_private.h b/dlls/gdiplus/gdiplus_private.h
index f20ea3d..b9420a3 100644
--- a/dlls/gdiplus/gdiplus_private.h
+++ b/dlls/gdiplus/gdiplus_private.h
@@ -26,6 +26,7 @@ #include "gdiplus.h"
#define GP_DEFAULT_PENSTYLE (PS_GEOMETRIC | PS_SOLID | PS_ENDCAP_FLAT | PS_JOIN_MITER)
#define MAX_ARC_PTS (13)
+#define MAX_DASHLEN (16) /* this is a limitation of gdi */
COLORREF ARGB2COLORREF(ARGB color);
extern INT arc2polybezier(GpPointF * points, REAL x1, REAL y1, REAL x2, REAL y2,
diff --git a/dlls/gdiplus/graphics.c b/dlls/gdiplus/graphics.c
index 3836476..cb56c73 100644
--- a/dlls/gdiplus/graphics.c
+++ b/dlls/gdiplus/graphics.c
@@ -98,8 +98,9 @@ static INT prepare_dc(GpGraphics *graphi
{
HPEN gdipen;
REAL width;
- INT save_state = SaveDC(graphics->hdc);
+ INT save_state = SaveDC(graphics->hdc), i, numdashes;
GpPointF pt[2];
+ DWORD dash_array[MAX_DASHLEN];
EndPath(graphics->hdc);
@@ -116,7 +117,22 @@ static INT prepare_dc(GpGraphics *graphi
width *= pen->width * convert_unit(graphics->hdc,
pen->unit == UnitWorld ? graphics->unit : pen->unit);
- gdipen = ExtCreatePen(pen->style, roundr(width), &pen->brush->lb, 0, NULL);
+ if(pen->dash == DashStyleCustom){
+ numdashes = min(pen->numdashes, MAX_DASHLEN);
+
+ TRACE("dashes are: ");
+ for(i = 0; i < numdashes; i++){
+ dash_array[i] = roundr(width * pen->dashes[i]);
+ TRACE("%d, ", dash_array[i]);
+ }
+ TRACE("\n and the pen style is %x\n", pen->style);
+
+ gdipen = ExtCreatePen(pen->style, roundr(width), &pen->brush->lb,
+ numdashes, dash_array);
+ }
+ else
+ gdipen = ExtCreatePen(pen->style, roundr(width), &pen->brush->lb, 0, NULL);
+
SelectObject(graphics->hdc, gdipen);
return save_state;
diff --git a/dlls/gdiplus/pen.c b/dlls/gdiplus/pen.c
index e582f76..7d7237b 100644
--- a/dlls/gdiplus/pen.c
+++ b/dlls/gdiplus/pen.c
@@ -29,8 +29,6 @@ WINE_DEFAULT_DEBUG_CHANNEL(gdiplus);
static DWORD gdip_to_gdi_dash(GpDashStyle dash)
{
- static int calls;
-
switch(dash){
case DashStyleSolid:
return PS_SOLID;
@@ -43,9 +41,7 @@ static DWORD gdip_to_gdi_dash(GpDashStyl
case DashStyleDashDotDot:
return PS_DASHDOTDOT;
case DashStyleCustom:
- if(!(calls++))
- FIXME("DashStyleCustom not implemented\n");
- return PS_SOLID;
+ return PS_USERSTYLE;
default:
ERR("Not a member of GpDashStyle enumeration\n");
return 0;
@@ -240,7 +236,7 @@ GpStatus WINGDIPAPI GdipSetPenDashArray(
return OutOfMemory;
}
- pen->dash = DashStyleCustom;
+ GdipSetPenDashStyle(pen, DashStyleCustom);
memcpy(pen->dashes, dash, count * sizeof(REAL));
pen->numdashes = count;
--
1.4.1
More information about the wine-patches
mailing list