From 5ed5daf4da747a20979d107fa9efd73f0a45a555 Mon Sep 17 00:00:00 2001 From: Vincent Povirk Date: Wed, 22 Feb 2012 15:10:04 -0600 Subject: [PATCH] gdiplus: Do some actual color blending when drawing path gradients. --- dlls/gdiplus/graphics.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/dlls/gdiplus/graphics.c b/dlls/gdiplus/graphics.c index 72c6f014cc6..56a61a7441b 100644 --- a/dlls/gdiplus/graphics.c +++ b/dlls/gdiplus/graphics.c @@ -1191,6 +1191,7 @@ static GpStatus brush_fill_pixels(GpGraphics *graphics, GpBrush *brush, REAL min_yf, max_yf, line1_xf, line2_xf; INT min_y, max_y, min_x, max_x; INT x, y; + ARGB outer_color=0xffffffff; stat = GdipClonePath(fill->path, &flat_path); @@ -1225,6 +1226,7 @@ static GpStatus brush_fill_pixels(GpGraphics *graphics, GpBrush *brush, { int start_center_line=0, end_center_line=0; int seen_start=0, seen_end=0, seen_center=0; + REAL center_distance; type = flat_path->pathdata.Types[i]; @@ -1258,6 +1260,10 @@ static GpStatus brush_fill_pixels(GpGraphics *graphics, GpBrush *brush, else max_y = (INT)ceil(max_yf); + /* This is proportional to the distance from start-end line to center point. */ + center_distance = (end_point.Y - start_point.Y) * (start_point.X - center_point.X) + + (end_point.X - start_point.X) * (center_point.Y - start_point.Y); + for (y=min_y; yX + fill_area->Width; for (x=min_x; xX) + (y-fill_area->Y)*cdwStride] = fill->centercolor; + { + REAL distance; + + distance = (end_point.Y - start_point.Y) * (start_point.X - (REAL)x) + + (end_point.X - start_point.X) * (yf - start_point.Y); + + distance = distance / center_distance; + + argb_pixels[(x-fill_area->X) + (y-fill_area->Y)*cdwStride] = + blend_colors(outer_color, fill->centercolor, distance); + } } }