Commit 0937186f authored by Nikolay Sivov's avatar Nikolay Sivov Committed by Alexandre Julliard

gdiplus: Fix brush transform created with GdipCreateLineBrushFromRect().

parent 6906117b
......@@ -408,9 +408,7 @@ GpStatus WINGDIPAPI GdipCreateLineBrushFromRect(GDIPCONST GpRectF* rect,
ARGB startcolor, ARGB endcolor, LinearGradientMode mode, GpWrapMode wrap,
GpLineGradient **line)
{
GpPointF start, end;
GpStatus stat;
float far_x, far_y;
float angle;
TRACE("(%p, %x, %x, %d, %d, %p)\n", rect, startcolor, endcolor, mode,
wrap, line);
......@@ -418,45 +416,25 @@ GpStatus WINGDIPAPI GdipCreateLineBrushFromRect(GDIPCONST GpRectF* rect,
if(!line || !rect)
return InvalidParameter;
far_x = rect->X + rect->Width;
far_y = rect->Y + rect->Height;
switch (mode)
{
case LinearGradientModeHorizontal:
start.X = min(rect->X, far_x);
start.Y = rect->Y;
end.X = max(rect->X, far_x);
end.Y = rect->Y;
angle = 0.0f;
break;
case LinearGradientModeVertical:
start.X = rect->X;
start.Y = min(rect->Y, far_y);
end.X = rect->X;
end.Y = max(rect->Y, far_y);
angle = 90.0f;
break;
case LinearGradientModeForwardDiagonal:
start.X = min(rect->X, far_x);
start.Y = min(rect->Y, far_y);
end.X = max(rect->X, far_x);
end.Y = max(rect->Y, far_y);
angle = 45.0f;
break;
case LinearGradientModeBackwardDiagonal:
start.X = max(rect->X, far_x);
start.Y = min(rect->Y, far_y);
end.X = min(rect->X, far_x);
end.Y = max(rect->Y, far_y);
angle = 135.0f;
break;
default:
return InvalidParameter;
}
stat = GdipCreateLineBrush(&start, &end, startcolor, endcolor, wrap, line);
if (stat == Ok)
(*line)->rect = *rect;
return stat;
return GdipCreateLineBrushFromRectWithAngle(rect, startcolor, endcolor, angle, TRUE, wrap, line);
}
GpStatus WINGDIPAPI GdipCreateLineBrushFromRectI(GDIPCONST GpRect* rect,
......
......@@ -764,15 +764,11 @@ static void test_gradientgetrect(void)
#define expectf2(expected, got) ok(fabs(expected - got) < 0.001, "%u: expected %.3f, got %.3f.\n", i, expected, got)
expectf2(create_from_rect[i].transform[0], elements[0]);
todo_wine_if(create_from_rect[i].mode == LinearGradientModeVertical) {
expectf2(create_from_rect[i].transform[1], elements[1]);
expectf2(create_from_rect[i].transform[2], elements[2]);
}
expectf2(create_from_rect[i].transform[3], elements[3]);
todo_wine_if(create_from_rect[i].mode == LinearGradientModeVertical) {
expectf2(create_from_rect[i].transform[4], elements[4]);
expectf2(create_from_rect[i].transform[5], elements[5]);
}
#undef expectf2
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment