Commit befb8603 authored by Piotr Caban's avatar Piotr Caban Committed by Alexandre Julliard

gdiplus: Fix GdipCreateLineBrushFromRectWithAngle implementation.

The patch fixes isAngleScalable==TRUE argument handling. It also fixes a mistake when width was used instead of height. Signed-off-by: 's avatarPiotr Caban <piotr@codeweavers.com> Signed-off-by: 's avatarVincent Povirk <vincent@codeweavers.com> Signed-off-by: 's avatarAlexandre Julliard <julliard@winehq.org>
parent d91f985e
...@@ -428,26 +428,43 @@ GpStatus WINGDIPAPI GdipCreateLineBrushFromRectWithAngle(GDIPCONST GpRectF* rect ...@@ -428,26 +428,43 @@ GpStatus WINGDIPAPI GdipCreateLineBrushFromRectWithAngle(GDIPCONST GpRectF* rect
{ {
GpStatus stat; GpStatus stat;
LinearGradientMode mode; LinearGradientMode mode;
REAL width, height, exofs, eyofs; REAL exofs, eyofs;
REAL sin_angle, cos_angle, sin_cos_angle; REAL sin_angle, cos_angle, sin_cos_angle;
TRACE("(%p, %x, %x, %.2f, %d, %d, %p)\n", rect, startcolor, endcolor, angle, isAngleScalable, TRACE("(%p, %x, %x, %.2f, %d, %d, %p)\n", rect, startcolor, endcolor, angle, isAngleScalable,
wrap, line); wrap, line);
sin_angle = sinf(deg2rad(angle)); if (!rect || !rect->Width || !rect->Height)
cos_angle = cosf(deg2rad(angle)); return InvalidParameter;
sin_cos_angle = sin_angle * cos_angle;
angle = fmodf(angle, 360);
if (angle < 0)
angle += 360;
if (isAngleScalable) if (isAngleScalable)
{ {
width = height = 1.0; float add_angle = 0;
while(angle >= 90) {
angle -= 180;
add_angle += M_PI;
}
if (angle != 90 && angle != -90)
angle = atan((rect->Width / rect->Height) * tan(deg2rad(angle)));
else
angle = deg2rad(angle);
angle += add_angle;
} }
else else
{ {
width = rect->Width; angle = deg2rad(angle);
height = rect->Height;
} }
sin_angle = sinf(angle);
cos_angle = cosf(angle);
sin_cos_angle = sin_angle * cos_angle;
if (sin_cos_angle >= 0) if (sin_cos_angle >= 0)
mode = LinearGradientModeForwardDiagonal; mode = LinearGradientModeForwardDiagonal;
else else
...@@ -459,19 +476,13 @@ GpStatus WINGDIPAPI GdipCreateLineBrushFromRectWithAngle(GDIPCONST GpRectF* rect ...@@ -459,19 +476,13 @@ GpStatus WINGDIPAPI GdipCreateLineBrushFromRectWithAngle(GDIPCONST GpRectF* rect
{ {
if (sin_cos_angle >= 0) if (sin_cos_angle >= 0)
{ {
exofs = width * sin_cos_angle + height * cos_angle * cos_angle; exofs = rect->Height * sin_cos_angle + rect->Width * cos_angle * cos_angle;
eyofs = width * sin_angle * sin_angle + height * sin_cos_angle; eyofs = rect->Height * sin_angle * sin_angle + rect->Width * sin_cos_angle;
} }
else else
{ {
exofs = width * sin_angle * sin_angle + height * sin_cos_angle; exofs = rect->Width * sin_angle * sin_angle + rect->Height * sin_cos_angle;
eyofs = -width * sin_cos_angle + height * sin_angle * sin_angle; eyofs = -rect->Width * sin_cos_angle + rect->Height * sin_angle * sin_angle;
}
if (isAngleScalable)
{
exofs = exofs * rect->Width;
eyofs = eyofs * rect->Height;
} }
if (sin_angle >= 0) if (sin_angle >= 0)
......
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