summaryrefslogtreecommitdiffstats
path: root/gd-2.0.35-AALineThick.patch
blob: 4349adaffe67543d2706d8a34d563cb4fc1f0835 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
diff -up gd-2.0.35/gd.c.AALineThick gd-2.0.35/gd.c
--- gd-2.0.35/gd.c.AALineThick	2007-06-19 22:25:51.000000000 +0200
+++ gd-2.0.35/gd.c	2012-02-28 11:02:09.708015922 +0100
@@ -3474,6 +3474,8 @@ static void gdImageAALine (gdImagePtr im
 	/* keep them as 32bits */
 	long x, y, inc;
 	long dx, dy,tmp;
+	int w, wid, wstart; 
+	int thick = im->thick; 
 
 	if (!im->trueColor) {
 		/* TBB: don't crash when the image is of the wrong type */
@@ -3502,6 +3504,25 @@ static void gdImageAALine (gdImagePtr im
 		gdImageSetAAPixelColor(im, x1, y1, col, 0xFF);
 		return;
 	}
+	else { 
+	    double ag; 
+	    if (abs(dy) < abs(dx))  
+		ag  = cos (atan2 (dy, dx)); 
+	    else  
+		ag = sin (atan2 (dy, dx)); 
+	    if (ag != 0)
+	    {
+		wid = abs(thick / ag); 
+	    }
+	    else
+	    {
+		wid = 1;
+	    } 
+	    if (wid == 0)
+	    {
+		wid = 1;
+	    } 
+	} 
 	if (abs(dx) > abs(dy)) {
 		if (dx < 0) {
 			tmp = x1;
@@ -3518,8 +3539,11 @@ static void gdImageAALine (gdImagePtr im
 		inc = (dy * 65536) / dx;
 		/* TBB: set the last pixel for consistency (<=) */
 		while ((x >> 16) <= x2) {
-			gdImageSetAAPixelColor(im, x >> 16, y >> 16, col, (y >> 8) & 0xFF);
-			gdImageSetAAPixelColor(im, x >> 16, (y >> 16) + 1,col, (~y >> 8) & 0xFF);
+			wstart = (y >> 16) - wid / 2;
+			for (w = wstart; w < wstart + wid; w++) {    
+			    gdImageSetAAPixelColor(im, (x >> 16) , w , col , (y >> 8) & 0xFF); 
+			    gdImageSetAAPixelColor(im, (x >> 16) , w + 1 , col, (~y >> 8) & 0xFF); 
+			} 
 			x += (1 << 16);
 			y += inc;
 		}
@@ -3539,8 +3563,11 @@ static void gdImageAALine (gdImagePtr im
 		inc = (dx * 65536) / dy;
 		/* TBB: set the last pixel for consistency (<=) */
 		while ((y>>16) <= y2) {
-			gdImageSetAAPixelColor(im, x >> 16, y >> 16, col, (x >> 8) & 0xFF);
-			gdImageSetAAPixelColor(im, (x >> 16) + 1, (y >> 16),col, (~x >> 8) & 0xFF);
+			wstart = (x >> 16) - wid / 2;
+			for (w = wstart; w < wstart + wid; w++) { 
+			    gdImageSetAAPixelColor(im, w , y >> 16  , col, (x >> 8) & 0xFF);                    
+			    gdImageSetAAPixelColor(im, w + 1, y >> 16, col, (~x >> 8) & 0xFF);   
+			}
 			x += inc;
 			y += (1<<16);
 		}