gdiplus: Use the preset blend when drawing linear gradients.
authorVincent Povirk <vincent@codeweavers.com>
Mon, 14 Sep 2009 21:48:03 +0000 (16:48 -0500)
committerAlexandre Julliard <julliard@winehq.org>
Tue, 15 Sep 2009 22:34:56 +0000 (17:34 -0500)
dlls/gdiplus/graphics.c

index 6753262528956cdea9279dc48097cb793154796e..df107e42040f48d9b3b6558cdc00b7dc412e12a1 100644 (file)
@@ -220,7 +220,27 @@ static ARGB blend_line_gradient(GpLineGradient* brush, REAL position)
         blendfac = (left_blendfac * (right_blendpos - position) +
                     right_blendfac * (position - left_blendpos)) / range;
     }
-    return blend_colors(brush->startcolor, brush->endcolor, blendfac);
+
+    if (brush->pblendcount == 0)
+        return blend_colors(brush->startcolor, brush->endcolor, blendfac);
+    else
+    {
+        int i=1;
+        ARGB left_blendcolor, right_blendcolor;
+        REAL left_blendpos, right_blendpos;
+
+        /* locate the blend colors surrounding this position */
+        while (blendfac > brush->pblendpos[i])
+            i++;
+
+        /* interpolate between the blend colors */
+        left_blendpos = brush->pblendpos[i-1];
+        left_blendcolor = brush->pblendcolor[i-1];
+        right_blendpos = brush->pblendpos[i];
+        right_blendcolor = brush->pblendcolor[i];
+        blendfac = (blendfac - left_blendpos) / (right_blendpos - left_blendpos);
+        return blend_colors(left_blendcolor, right_blendcolor, blendfac);
+    }
 }
 
 static void brush_fill_path(GpGraphics *graphics, GpBrush* brush)