Commits

Pierre Joye  committed 725ba9d Merge

Merge branch 'master' of https://bitbucket.org/libgd/gd-libgd

  • Participants
  • Parent commits 84d2371, 5a29711

Comments (0)

Files changed (1)

 	if (src->trueColor == 0) {
 		dst->colorsTotal = src->colorsTotal;
 		for (i = 0; i < gdMaxColors; i++) {
-			dst->red[gdMaxColors]   = src->red[gdMaxColors];
-			dst->green[gdMaxColors] = src->green[gdMaxColors];
-			dst->blue[gdMaxColors]  = src->blue[gdMaxColors];
-			dst->alpha[gdMaxColors] = src->alpha[gdMaxColors];
-			dst->open[gdMaxColors]  = src->open[gdMaxColors];
+			dst->red[i]   = src->red[i];
+			dst->green[i] = src->green[i];
+			dst->blue[i]  = src->blue[i];
+			dst->alpha[i] = src->alpha[i];
+			dst->open[i]  = src->open[i];
 		}
 		for (i = 0; i < src->sy; i++) {
 			for (x = 0; x < src->sx; x++) {
 static void gdImageAALine (gdImagePtr im, int x1, int y1, int x2, int y2, int col)
 {
 	/* keep them as 32bits */
-	long x, y, inc;
+	long x, y, inc, frac;
 	long dx, dy,tmp;
 	int w, wid, wstart; 
 	int thick = im->thick; 
 			dx = x2 - x1;
 			dy = y2 - y1;
 		}
-		x = x1 << 16;
-		y = y1 << 16;
+		y = y1;
 		inc = (dy * 65536) / dx;
+		frac = 0;
 		/* TBB: set the last pixel for consistency (<=) */
-		while ((x >> 16) <= x2) {
-			wstart = (y >> 16) - wid / 2;
+		for (x = x1 ; x <= x2 ; x++) {
+			wstart = y - 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);
+			    gdImageSetAAPixelColor(im, x , w , col , (frac >> 8) & 0xFF);
+			    gdImageSetAAPixelColor(im, x , w + 1 , col, (~frac >> 8) & 0xFF);
+			}
+			frac += inc;
+			if (frac >= 65536) {
+				frac -= 65536;
+				y++;
+			} else if (frac < 0) {
+				frac += 65536;
+				y--;
 			}
-			x += (1 << 16);
-			y += inc;
 		}
 	} else {
 		if (dy < 0) {
 			dx = x2 - x1;
 			dy = y2 - y1;
 		}
-		x = x1 << 16;
-		y = y1 << 16;
+		x = x1;
 		inc = (dx * 65536) / dy;
+		frac = 0;
 		/* TBB: set the last pixel for consistency (<=) */
-		while ((y >> 16) <= y2) {
-			wstart = (x >> 16) - wid / 2;
+		for (y = y1 ; y <= y2 ; y++) {
+			wstart = x - 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);
+			    gdImageSetAAPixelColor(im, w , y  , col, (frac >> 8) & 0xFF);
+			    gdImageSetAAPixelColor(im, w + 1, y, col, (~frac >> 8) & 0xFF);
+			}
+			frac += inc;
+			if (frac >= 65536) {
+				frac -= 65536;
+				x++;
+			} else if (frac < 0) {
+				frac += 65536;
+				x--;
 			}
-			x += inc;
-			y += (1 << 16);
 		}
 	}
 }