ID: 42434 Updated by: ka...@php.net Reported By: wojjie at gmail dot com -Status: Assigned +Status: Closed Bug Type: GD related Operating System: * PHP Version: 5.2.6 Assigned To: pajoye New Comment:
This bug has been fixed in SVN. Snapshots of the sources are packaged every three hours; this change will be in the next snapshot. You can grab the snapshot at http://snaps.php.net/. Thank you for the report, and for helping us make PHP better. Previous Comments: ------------------------------------------------------------------------ [2009-07-28 20:35:06] s...@php.net Automatic comment from SVN on behalf of kalle Revision: http://svn.php.net/viewvc/?view=revision&revision=286466 Log: Fixed bug #42434 (ImageLine w/ antialias = 1px shorter) - patch by wojjie at gmail dot com ------------------------------------------------------------------------ [2008-09-05 02:19:52] abc at abc dot abc reproduced on PHP 5.2.6 / windows. problem is still there ------------------------------------------------------------------------ [2007-08-27 11:04:46] j...@php.net Assigned to the maintainer. ------------------------------------------------------------------------ [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