Blame SOURCES/gd-2.0.35-AALineThick.patch

71ed48
diff -up gd-2.0.35/gd.c.AALineThick gd-2.0.35/gd.c
71ed48
--- gd-2.0.35/gd.c.AALineThick	2007-06-19 22:25:51.000000000 +0200
71ed48
+++ gd-2.0.35/gd.c	2012-02-28 11:02:09.708015922 +0100
71ed48
@@ -3474,6 +3474,8 @@ static void gdImageAALine (gdImagePtr im
71ed48
 	/* keep them as 32bits */
71ed48
 	long x, y, inc;
71ed48
 	long dx, dy,tmp;
71ed48
+	int w, wid, wstart; 
71ed48
+	int thick = im->thick; 
71ed48
 
71ed48
 	if (!im->trueColor) {
71ed48
 		/* TBB: don't crash when the image is of the wrong type */
71ed48
@@ -3502,6 +3504,25 @@ static void gdImageAALine (gdImagePtr im
71ed48
 		gdImageSetAAPixelColor(im, x1, y1, col, 0xFF);
71ed48
 		return;
71ed48
 	}
71ed48
+	else { 
71ed48
+	    double ag; 
71ed48
+	    if (abs(dy) < abs(dx))  
71ed48
+		ag  = cos (atan2 (dy, dx)); 
71ed48
+	    else  
71ed48
+		ag = sin (atan2 (dy, dx)); 
71ed48
+	    if (ag != 0)
71ed48
+	    {
71ed48
+		wid = abs(thick / ag); 
71ed48
+	    }
71ed48
+	    else
71ed48
+	    {
71ed48
+		wid = 1;
71ed48
+	    } 
71ed48
+	    if (wid == 0)
71ed48
+	    {
71ed48
+		wid = 1;
71ed48
+	    } 
71ed48
+	} 
71ed48
 	if (abs(dx) > abs(dy)) {
71ed48
 		if (dx < 0) {
71ed48
 			tmp = x1;
71ed48
@@ -3518,8 +3539,11 @@ static void gdImageAALine (gdImagePtr im
71ed48
 		inc = (dy * 65536) / dx;
71ed48
 		/* TBB: set the last pixel for consistency (<=) */
71ed48
 		while ((x >> 16) <= x2) {
71ed48
-			gdImageSetAAPixelColor(im, x >> 16, y >> 16, col, (y >> 8) & 0xFF);
71ed48
-			gdImageSetAAPixelColor(im, x >> 16, (y >> 16) + 1,col, (~y >> 8) & 0xFF);
71ed48
+			wstart = (y >> 16) - wid / 2;
71ed48
+			for (w = wstart; w < wstart + wid; w++) {    
71ed48
+			    gdImageSetAAPixelColor(im, (x >> 16) , w , col , (y >> 8) & 0xFF); 
71ed48
+			    gdImageSetAAPixelColor(im, (x >> 16) , w + 1 , col, (~y >> 8) & 0xFF); 
71ed48
+			} 
71ed48
 			x += (1 << 16);
71ed48
 			y += inc;
71ed48
 		}
71ed48
@@ -3539,8 +3563,11 @@ static void gdImageAALine (gdImagePtr im
71ed48
 		inc = (dx * 65536) / dy;
71ed48
 		/* TBB: set the last pixel for consistency (<=) */
71ed48
 		while ((y>>16) <= y2) {
71ed48
-			gdImageSetAAPixelColor(im, x >> 16, y >> 16, col, (x >> 8) & 0xFF);
71ed48
-			gdImageSetAAPixelColor(im, (x >> 16) + 1, (y >> 16),col, (~x >> 8) & 0xFF);
71ed48
+			wstart = (x >> 16) - wid / 2;
71ed48
+			for (w = wstart; w < wstart + wid; w++) { 
71ed48
+			    gdImageSetAAPixelColor(im, w , y >> 16  , col, (x >> 8) & 0xFF);                    
71ed48
+			    gdImageSetAAPixelColor(im, w + 1, y >> 16, col, (~x >> 8) & 0xFF);   
71ed48
+			}
71ed48
 			x += inc;
71ed48
 			y += (1<<16);
71ed48
 		}