|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2007-08-27 11:04 UTC] jani@php.net
[2008-09-05 02:19 UTC] abc at abc dot abc
[2009-07-28 20:35 UTC] svn@php.net
[2009-07-28 20:35 UTC] kalle@php.net
[2009-07-30 03:54 UTC] svn@php.net
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Oct 26 18:00:01 2025 UTC |
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.