gdiplus: Implemented GdipGetPathGradientRect with test.
diff --git a/dlls/gdiplus/brush.c b/dlls/gdiplus/brush.c
index 7e4ac9e..13cd3ab 100644
--- a/dlls/gdiplus/brush.c
+++ b/dlls/gdiplus/brush.c
@@ -641,6 +641,51 @@
return Ok;
}
+GpStatus WINGDIPAPI GdipGetPathGradientRect(GpPathGradient *brush, GpRectF *rect)
+{
+ GpRectF r;
+ GpPath* path;
+ GpStatus stat;
+
+ if(!brush || !rect)
+ return InvalidParameter;
+
+ stat = GdipCreatePath2(brush->pathdata.Points, brush->pathdata.Types,
+ brush->pathdata.Count, FillModeAlternate, &path);
+ if(stat != Ok) return stat;
+
+ stat = GdipGetPathWorldBounds(path, &r, NULL, NULL);
+ if(stat != Ok){
+ GdipDeletePath(path);
+ return stat;
+ }
+
+ memcpy(rect, &r, sizeof(GpRectF));
+
+ GdipDeletePath(path);
+
+ return Ok;
+}
+
+GpStatus WINGDIPAPI GdipGetPathGradientRectI(GpPathGradient *brush, GpRect *rect)
+{
+ GpRectF rectf;
+ GpStatus stat;
+
+ if(!brush || !rect)
+ return InvalidParameter;
+
+ stat = GdipGetPathGradientRect(brush, &rectf);
+ if(stat != Ok) return stat;
+
+ rect->X = roundr(rectf.X);
+ rect->Y = roundr(rectf.Y);
+ rect->Width = roundr(rectf.Width);
+ rect->Height = roundr(rectf.Height);
+
+ return Ok;
+}
+
GpStatus WINGDIPAPI GdipGetPathGradientSurroundColorsWithCount(GpPathGradient
*grad, ARGB *argb, INT *count)
{
diff --git a/dlls/gdiplus/gdiplus.spec b/dlls/gdiplus/gdiplus.spec
index 4bfc93a..cbbc9c3 100644
--- a/dlls/gdiplus/gdiplus.spec
+++ b/dlls/gdiplus/gdiplus.spec
@@ -336,8 +336,8 @@
@ stdcall GdipGetPathGradientPointCount(ptr ptr)
@ stub GdipGetPathGradientPresetBlend
@ stub GdipGetPathGradientPresetBlendCount
-@ stub GdipGetPathGradientRect
-@ stub GdipGetPathGradientRectI
+@ stdcall GdipGetPathGradientRect(ptr ptr)
+@ stdcall GdipGetPathGradientRectI(ptr ptr)
@ stub GdipGetPathGradientSurroundColorCount
@ stdcall GdipGetPathGradientSurroundColorsWithCount(ptr ptr ptr)
@ stub GdipGetPathGradientTransform
diff --git a/dlls/gdiplus/tests/brush.c b/dlls/gdiplus/tests/brush.c
index 1f79744..5ef7fca 100644
--- a/dlls/gdiplus/tests/brush.c
+++ b/dlls/gdiplus/tests/brush.c
@@ -115,6 +115,36 @@
GdipDeleteBrush((GpBrush*) brush);
}
+static GpPointF getbounds_ptf[] = {{0.0, 20.0},
+ {50.0, 50.0},
+ {21.0, 25.0},
+ {25.0, 46.0}};
+static void test_getbounds(void)
+{
+ GpStatus status;
+ GpPathGradient *brush;
+ GpRectF bounds;
+
+ status = GdipCreatePathGradient(getbounds_ptf, 4, WrapModeClamp, &brush);
+ expect(Ok, status);
+
+ status = GdipGetPathGradientRect(NULL, NULL);
+ expect(InvalidParameter, status);
+ status = GdipGetPathGradientRect(brush, NULL);
+ expect(InvalidParameter, status);
+ status = GdipGetPathGradientRect(NULL, &bounds);
+ expect(InvalidParameter, status);
+
+ status = GdipGetPathGradientRect(brush, &bounds);
+ expect(Ok, status);
+ expectf(0.0, bounds.X);
+ expectf(20.0, bounds.Y);
+ expectf(50.0, bounds.Width);
+ expectf(30.0, bounds.Height);
+
+ GdipDeleteBrush((GpBrush*) brush);
+}
+
START_TEST(brush)
{
struct GdiplusStartupInput gdiplusStartupInput;
@@ -131,6 +161,7 @@
test_type();
test_gradientblendcount();
test_getblend();
+ test_getbounds();
GdiplusShutdown(gdiplusToken);
}
diff --git a/include/gdiplusflat.h b/include/gdiplusflat.h
index 8a683b7..841a46e 100644
--- a/include/gdiplusflat.h
+++ b/include/gdiplusflat.h
@@ -207,6 +207,8 @@
GpStatus WINGDIPAPI GdipGetPathGradientFocusScales(GpPathGradient*,REAL*,REAL*);
GpStatus WINGDIPAPI GdipGetPathGradientGammaCorrection(GpPathGradient*,BOOL*);
GpStatus WINGDIPAPI GdipGetPathGradientPointCount(GpPathGradient*,INT*);
+GpStatus WINGDIPAPI GdipGetPathGradientRect(GpPathGradient*,GpRectF*);
+GpStatus WINGDIPAPI GdipGetPathGradientRectI(GpPathGradient*,GpRect*);
GpStatus WINGDIPAPI GdipGetPathGradientSurroundColorsWithCount(GpPathGradient*,
ARGB*,INT*);
GpStatus WINGDIPAPI GdipGetPathGradientWrapMode(GpPathGradient*,GpWrapMode*);