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, ...@@ -408,9 +408,7 @@ GpStatus WINGDIPAPI GdipCreateLineBrushFromRect(GDIPCONST GpRectF* rect,
ARGB startcolor, ARGB endcolor, LinearGradientMode mode, GpWrapMode wrap, ARGB startcolor, ARGB endcolor, LinearGradientMode mode, GpWrapMode wrap,
GpLineGradient **line) GpLineGradient **line)
{ {
GpPointF start, end; float angle;
GpStatus stat;
float far_x, far_y;
TRACE("(%p, %x, %x, %d, %d, %p)\n", rect, startcolor, endcolor, mode, TRACE("(%p, %x, %x, %d, %d, %p)\n", rect, startcolor, endcolor, mode,
wrap, line); wrap, line);
...@@ -418,45 +416,25 @@ GpStatus WINGDIPAPI GdipCreateLineBrushFromRect(GDIPCONST GpRectF* rect, ...@@ -418,45 +416,25 @@ GpStatus WINGDIPAPI GdipCreateLineBrushFromRect(GDIPCONST GpRectF* rect,
if(!line || !rect) if(!line || !rect)
return InvalidParameter; return InvalidParameter;
far_x = rect->X + rect->Width;
far_y = rect->Y + rect->Height;
switch (mode) switch (mode)
{ {
case LinearGradientModeHorizontal: case LinearGradientModeHorizontal:
start.X = min(rect->X, far_x); angle = 0.0f;
start.Y = rect->Y;
end.X = max(rect->X, far_x);
end.Y = rect->Y;
break; break;
case LinearGradientModeVertical: case LinearGradientModeVertical:
start.X = rect->X; angle = 90.0f;
start.Y = min(rect->Y, far_y);
end.X = rect->X;
end.Y = max(rect->Y, far_y);
break; break;
case LinearGradientModeForwardDiagonal: case LinearGradientModeForwardDiagonal:
start.X = min(rect->X, far_x); angle = 45.0f;
start.Y = min(rect->Y, far_y);
end.X = max(rect->X, far_x);
end.Y = max(rect->Y, far_y);
break; break;
case LinearGradientModeBackwardDiagonal: case LinearGradientModeBackwardDiagonal:
start.X = max(rect->X, far_x); angle = 135.0f;
start.Y = min(rect->Y, far_y);
end.X = min(rect->X, far_x);
end.Y = max(rect->Y, far_y);
break; break;
default: default:
return InvalidParameter; return InvalidParameter;
} }
stat = GdipCreateLineBrush(&start, &end, startcolor, endcolor, wrap, line); return GdipCreateLineBrushFromRectWithAngle(rect, startcolor, endcolor, angle, TRUE, wrap, line);
if (stat == Ok)
(*line)->rect = *rect;
return stat;
} }
GpStatus WINGDIPAPI GdipCreateLineBrushFromRectI(GDIPCONST GpRect* rect, GpStatus WINGDIPAPI GdipCreateLineBrushFromRectI(GDIPCONST GpRect* rect,
......
...@@ -764,15 +764,11 @@ static void test_gradientgetrect(void) ...@@ -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) #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]); 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[1], elements[1]);
expectf2(create_from_rect[i].transform[2], elements[2]); expectf2(create_from_rect[i].transform[2], elements[2]);
}
expectf2(create_from_rect[i].transform[3], elements[3]); 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[4], elements[4]);
expectf2(create_from_rect[i].transform[5], elements[5]); expectf2(create_from_rect[i].transform[5], elements[5]);
}
#undef expectf2 #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