ID: 42434
Updated by: [EMAIL PROTECTED]
Reported By: wojjie at gmail dot com
-Status: Open
+Status: Assigned
Bug Type: GD related
Operating System: All
PHP Version: 5.2.3
-Assigned To:
+Assigned To: pajoye
New Comment:
Assigned to the maintainer.
Previous Comments:
------------------------------------------------------------------------
[2007-08-27 04:50:47] wojjie at gmail dot com
Description:
------------
This bug looks fixed in the GD library, but for some reason the GD
included in PHP still has this.
What happens is when drawing a line with anti aliasing enabled, the
resulting line is 1 pixel shorter than it should be.
Fix (using snapshot: php5.2-200708270430.tar.gz):
--- gd.c 2007-08-26 23:44:04.000000000 -0500
+++ gd.c 2007-08-26 23:44:28.000000000 -0500
@@ -1351,7 +1351,7 @@
x = x1 << 16;
y = y1 << 16;
inc = (dy * 65536) / dx;
- while ((x >> 16) < x2) {
+ 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);
@@ -1373,7 +1373,7 @@
x = x1 << 16;
y = y1 << 16;
inc = (dx * 65536) / dy;
- while ((y>>16) < y2) {
+ 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);
Reproduce code:
---------------
<?php
$im=imagecreatetruecolor(30,30);
$c1=ImageColorAllocate($im,255,255,255);
$c2=ImageColorAllocate($im, 0, 0, 0);
imagefill( $im,0,0, $c1 );
imageline($im,5,5, 25,5, $c2);
imageantialias($im,true);
imageline($im,5,25, 25,25, $c2);
header("Content-type: image/png");
imagepng($im);
imagedestroy($im);
?>
Expected result:
----------------
Two lines of equal length
Actual result:
--------------
Top line is longer than bottom line by 1 pixel.
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=42434&edit=1