diff --git a/dlls/gdiplus/brush.c b/dlls/gdiplus/brush.c index 86740fe1e0f..7e4ac9e58cb 100644 --- a/dlls/gdiplus/brush.c +++ b/dlls/gdiplus/brush.c @@ -549,6 +549,23 @@ GpStatus WINGDIPAPI GdipGetLineWrapMode(GpLineGradient *brush, GpWrapMode *wrapm return Ok; } +GpStatus WINGDIPAPI GdipGetPathGradientBlend(GpPathGradient *brush, REAL *blend, + REAL *positions, INT count) +{ + if(!brush || !blend || !positions || count <= 0) + return InvalidParameter; + + if(count < brush->blendcount) + return InsufficientBuffer; + + memcpy(blend, brush->blendfac, count*sizeof(REAL)); + if(brush->blendcount > 1){ + memcpy(positions, brush->blendpos, count*sizeof(REAL)); + } + + return Ok; +} + GpStatus WINGDIPAPI GdipGetPathGradientBlendCount(GpPathGradient *brush, INT *count) { if(!brush || !count) diff --git a/dlls/gdiplus/gdiplus.spec b/dlls/gdiplus/gdiplus.spec index 9d609faea69..4bfc93a7ccf 100644 --- a/dlls/gdiplus/gdiplus.spec +++ b/dlls/gdiplus/gdiplus.spec @@ -325,7 +325,7 @@ @ stdcall GdipGetPageUnit(ptr ptr) @ stdcall GdipGetPathData(ptr ptr) @ stdcall GdipGetPathFillMode(ptr ptr) -@ stub GdipGetPathGradientBlend +@ stdcall GdipGetPathGradientBlend(ptr ptr ptr long) @ stdcall GdipGetPathGradientBlendCount(ptr ptr) @ stub GdipGetPathGradientCenterColor @ stdcall GdipGetPathGradientCenterPoint(ptr ptr) diff --git a/dlls/gdiplus/tests/brush.c b/dlls/gdiplus/tests/brush.c index b8e91fc047b..1f7974442c0 100644 --- a/dlls/gdiplus/tests/brush.c +++ b/dlls/gdiplus/tests/brush.c @@ -21,8 +21,10 @@ #include "windows.h" #include "gdiplus.h" #include "wine/test.h" +#include #define expect(expected, got) ok(got == expected, "Expected %.8x, got %.8x\n", expected, got) +#define expectf(expected, got) ok(fabs(expected - got) < 0.0001, "Expected %.2f, got %.2f\n", expected, got) static void test_constructor_destructor(void) { @@ -79,6 +81,40 @@ static void test_gradientblendcount(void) GdipDeleteBrush((GpBrush*) brush); } +static GpPointF getblend_ptf[] = {{0.0, 0.0}, + {50.0, 50.0}}; +static void test_getblend(void) +{ + GpStatus status; + GpPathGradient *brush; + REAL blends[4]; + REAL pos[4]; + + status = GdipCreatePathGradient(getblend_ptf, 2, WrapModeClamp, &brush); + expect(Ok, status); + + /* check some invalid parameters combinations */ + status = GdipGetPathGradientBlend(NULL, NULL, NULL, -1); + expect(InvalidParameter, status); + status = GdipGetPathGradientBlend(brush,NULL, NULL, -1); + expect(InvalidParameter, status); + status = GdipGetPathGradientBlend(NULL, blends,NULL, -1); + expect(InvalidParameter, status); + status = GdipGetPathGradientBlend(NULL, NULL, pos, -1); + expect(InvalidParameter, status); + status = GdipGetPathGradientBlend(NULL, NULL, NULL, 1); + expect(InvalidParameter, status); + + blends[0] = (REAL)0xdeadbeef; + pos[0] = (REAL)0xdeadbeef; + status = GdipGetPathGradientBlend(brush, blends, pos, 1); + expect(Ok, status); + expectf(1.0, blends[0]); + expectf((REAL)0xdeadbeef, pos[0]); + + GdipDeleteBrush((GpBrush*) brush); +} + START_TEST(brush) { struct GdiplusStartupInput gdiplusStartupInput; @@ -94,6 +130,7 @@ START_TEST(brush) test_constructor_destructor(); test_type(); test_gradientblendcount(); + test_getblend(); GdiplusShutdown(gdiplusToken); } diff --git a/include/gdiplusflat.h b/include/gdiplusflat.h index 98d687a3f7d..8a683b7eae0 100644 --- a/include/gdiplusflat.h +++ b/include/gdiplusflat.h @@ -199,6 +199,7 @@ GpStatus WINGDIPAPI GdipGetLineWrapMode(GpLineGradient*,GpWrapMode*); GpStatus WINGDIPAPI GdipGetLineRect(GpLineGradient*,GpRectF*); GpStatus WINGDIPAPI GdipGetLineRectI(GpLineGradient*,GpRect*); GpStatus WINGDIPAPI GdipGetLineColors(GpLineGradient*,ARGB*); +GpStatus WINGDIPAPI GdipGetPathGradientBlend(GpPathGradient*,REAL*,REAL*,INT); GpStatus WINGDIPAPI GdipGetPathGradientBlendCount(GpPathGradient*,INT*); GpStatus WINGDIPAPI GdipGetPathGradientCenterColor(GpPathGradient*,ARGB*); GpStatus WINGDIPAPI GdipGetPathGradientCenterPoint(GpPathGradient*,GpPointF*);