|
|
|
@ -1184,7 +1184,7 @@ inline static void gdImageSetAAPixelColor(gdImagePtr im, int x, int y, int color |
|
|
|
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; |
|
|
|
|
|
|
|
if (y1 < 0 && y2 < 0) { |
|
|
|
@ -1254,16 +1254,22 @@ void gdImageAALine (gdImagePtr im, int x1, int y1, int x2, int y2, int col) |
|
|
|
dx = x2 - x1; |
|
|
|
dy = y2 - y1; |
|
|
|
} |
|
|
|
x = x1 << 16; |
|
|
|
y = y1 << 16; |
|
|
|
y = y1; |
|
|
|
inc = (dy * 65536) / dx; |
|
|
|
while ((x >> 16) <= x2) { |
|
|
|
gdImageSetAAPixelColor(im, x >> 16, y >> 16, col, (y >> 8) & 0xFF); |
|
|
|
if ((y >> 16) + 1 < im->sy) { |
|
|
|
gdImageSetAAPixelColor(im, x >> 16, (y >> 16) + 1,col, (~y >> 8) & 0xFF); |
|
|
|
frac = 0; |
|
|
|
for (x = x1; x <= x2; x++) { |
|
|
|
gdImageSetAAPixelColor(im, x, y, col, (frac >> 8) & 0xFF); |
|
|
|
if (y + 1 < im->sy) { |
|
|
|
gdImageSetAAPixelColor(im, x, y + 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) { |
|
|
|
@ -1276,16 +1282,22 @@ void gdImageAALine (gdImagePtr im, int x1, int y1, int x2, int y2, int col) |
|
|
|
dx = x2 - x1; |
|
|
|
dy = y2 - y1; |
|
|
|
} |
|
|
|
x = x1 << 16; |
|
|
|
y = y1 << 16; |
|
|
|
x = x1; |
|
|
|
inc = (dx * 65536) / dy; |
|
|
|
while ((y>>16) <= y2) { |
|
|
|
gdImageSetAAPixelColor(im, x >> 16, y >> 16, col, (x >> 8) & 0xFF); |
|
|
|
if ((x >> 16) + 1 < im->sx) { |
|
|
|
gdImageSetAAPixelColor(im, (x >> 16) + 1, (y >> 16),col, (~x >> 8) & 0xFF); |
|
|
|
frac = 0; |
|
|
|
for (y = y1; y <= y2; y++) { |
|
|
|
gdImageSetAAPixelColor(im, x, y, col, (frac >> 8) & 0xFF); |
|
|
|
if (x + 1 < im->sx) { |
|
|
|
gdImageSetAAPixelColor(im, x + 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); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|