diff --git a/dlls/gdiplus/gdiplus.spec b/dlls/gdiplus/gdiplus.spec index 02b1e18c4ea..cf08c90d35e 100644 --- a/dlls/gdiplus/gdiplus.spec +++ b/dlls/gdiplus/gdiplus.spec @@ -338,7 +338,7 @@ @ stub GdipGetPenCompoundCount @ stub GdipGetPenCustomEndCap @ stub GdipGetPenCustomStartCap -@ stub GdipGetPenDashArray +@ stdcall GdipGetPenDashArray(ptr ptr long) @ stub GdipGetPenDashCap197819 @ stub GdipGetPenDashCount @ stub GdipGetPenDashOffset @@ -546,7 +546,7 @@ @ stub GdipSetPenCompoundArray @ stdcall GdipSetPenCustomEndCap(ptr ptr) @ stdcall GdipSetPenCustomStartCap(ptr ptr) -@ stub GdipSetPenDashArray +@ stdcall GdipSetPenDashArray(ptr ptr long) @ stub GdipSetPenDashCap197819 @ stub GdipSetPenDashOffset @ stdcall GdipSetPenDashStyle(ptr long) diff --git a/dlls/gdiplus/gdiplus_private.h b/dlls/gdiplus/gdiplus_private.h index 79800c29015..f20ea3d36b6 100644 --- a/dlls/gdiplus/gdiplus_private.h +++ b/dlls/gdiplus/gdiplus_private.h @@ -54,6 +54,8 @@ struct GpPen{ GpLineJoin join; REAL miterlimit; GpDashStyle dash; + REAL *dashes; + INT numdashes; GpBrush *brush; }; diff --git a/dlls/gdiplus/pen.c b/dlls/gdiplus/pen.c index 3026d5242fe..e582f7644c6 100644 --- a/dlls/gdiplus/pen.c +++ b/dlls/gdiplus/pen.c @@ -123,6 +123,7 @@ GpStatus WINGDIPAPI GdipDeletePen(GpPen *pen) GdipDeleteBrush(pen->brush); GdipDeleteCustomLineCap(pen->customstart); GdipDeleteCustomLineCap(pen->customend); + GdipFree(pen->dashes); GdipFree(pen); return Ok; @@ -147,6 +148,20 @@ GpStatus WINGDIPAPI GdipGetPenColor(GpPen *pen, ARGB *argb) return GdipGetSolidFillColor(((GpSolidFill*)pen->brush), argb); } +GpStatus WINGDIPAPI GdipGetPenDashArray(GpPen *pen, REAL *dash, INT count) +{ + if(!pen || !dash || count > pen->numdashes) + return InvalidParameter; + + /* note: if you pass a negative value for count, it crashes native gdiplus. */ + if(count < 0) + return GenericError; + + memcpy(dash, pen->dashes, count * sizeof(REAL)); + + return Ok; +} + GpStatus WINGDIPAPI GdipGetPenDashStyle(GpPen *pen, GpDashStyle *dash) { if(!pen || !dash) @@ -209,11 +224,40 @@ GpStatus WINGDIPAPI GdipSetPenCustomStartCap(GpPen *pen, GpCustomLineCap* custom return ret; } +GpStatus WINGDIPAPI GdipSetPenDashArray(GpPen *pen, GDIPCONST REAL *dash, + INT count) +{ + if(!pen || !dash) + return InvalidParameter; + + GdipFree(pen->dashes); + pen->dashes = NULL; + + if(count > 0) + pen->dashes = GdipAlloc(count * sizeof(REAL)); + if(!pen->dashes){ + pen->numdashes = 0; + return OutOfMemory; + } + + pen->dash = DashStyleCustom; + memcpy(pen->dashes, dash, count * sizeof(REAL)); + pen->numdashes = count; + + return Ok; +} + GpStatus WINGDIPAPI GdipSetPenDashStyle(GpPen *pen, GpDashStyle dash) { if(!pen) return InvalidParameter; + if(dash != DashStyleCustom){ + GdipFree(pen->dashes); + pen->dashes = NULL; + pen->numdashes = 0; + } + pen->dash = dash; pen->style &= ~(PS_ALTERNATE | PS_SOLID | PS_DASH | PS_DOT | PS_DASHDOT | PS_DASHDOTDOT | PS_NULL | PS_USERSTYLE | PS_INSIDEFRAME); diff --git a/include/gdiplusflat.h b/include/gdiplusflat.h index d56c45c1c48..eabdbfbce34 100644 --- a/include/gdiplusflat.h +++ b/include/gdiplusflat.h @@ -32,11 +32,13 @@ GpStatus WINGDIPAPI GdipCreatePen1(ARGB,REAL,GpUnit,GpPen**); GpStatus WINGDIPAPI GdipDeletePen(GpPen*); GpStatus WINGDIPAPI GdipGetPenBrushFill(GpPen*,GpBrush**); GpStatus WINGDIPAPI GdipGetPenColor(GpPen*,ARGB*); +GpStatus WINGDIPAPI GdipGetPenDashArray(GpPen*,REAL*,INT); GpStatus WINGDIPAPI GdipGetPenDashStyle(GpPen*,GpDashStyle*); GpStatus WINGDIPAPI GdipSetPenBrushFill(GpPen*,GpBrush*); GpStatus WINGDIPAPI GdipSetPenColor(GpPen*,ARGB); GpStatus WINGDIPAPI GdipSetPenCustomEndCap(GpPen*,GpCustomLineCap*); GpStatus WINGDIPAPI GdipSetPenCustomStartCap(GpPen*,GpCustomLineCap*); +GpStatus WINGDIPAPI GdipSetPenDashArray(GpPen*,GDIPCONST REAL*,INT); GpStatus WINGDIPAPI GdipSetPenDashStyle(GpPen*,GpDashStyle); GpStatus WINGDIPAPI GdipSetPenEndCap(GpPen*,GpLineCap); GpStatus WINGDIPAPI GdipSetPenLineCap197819(GpPen*,GpLineCap,GpLineCap,GpDashCap);