cvs: php-src /ext/gd/libgd gd.c /ext/gd/tests bug40764.phpt

From: Date: Sat, 10 Mar 2007 01:23:42 +0000
Subject: cvs: php-src /ext/gd/libgd gd.c /ext/gd/tests bug40764.phpt
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-43486@lists.php.net to get a copy of this message
pajoye Sat Mar 10 01:23:42 2007 UTC Modified files: /php-src/ext/gd/tests bug40764.phpt /php-src/ext/gd/libgd gd.c Log: - MFB: #40764, line thickness not respected for horizontal and vertical lines http://cvs.php.net/viewvc.cgi/php-src/ext/gd/tests/bug40764.phpt?r1=1.1&r2=1.2&diff_format=u Index: php-src/ext/gd/tests/bug40764.phpt diff -u /dev/null php-src/ext/gd/tests/bug40764.phpt:1.2 --- /dev/null Sat Mar 10 01:23:42 2007 +++ php-src/ext/gd/tests/bug40764.phpt Sat Mar 10 01:23:42 2007 @@ -0,0 +1,31 @@ +--TEST-- +Bug #40764 (line thickness not respected for horizontal and vertical lines) +--SKIPIF-- +<?php + if (!extension_loaded('gd')) die("skip gd extension not available\n"); +?> +--FILE-- +<?php +$image=imagecreatetruecolor(400, 400); +$white = imagecolorallocate($image, 255, 255, 255); +$black = imagecolorallocate($image, 0, 0, 0); +$red = imagecolorallocate($image, 255, 0, 0); + +imagefill($image, 0, 0, $white); +imagesetthickness($image, 10); + +imageline($image, 200, 0, 200, 400, $black); +imageline($image, 0, 200, 400, 200, $black); +imageline($image, 0, 0, 392, 392, $black); + +imagesetthickness($image, 1); + +imageline($image, 200, 0, 200, 400, $red); +imageline($image, 0, 200, 400, 200, $red); +imageline($image, 0, 0, 392, 392, $red); +print_r(imagecolorat($image, 195, 0)); +print_r(imagecolorat($image, 0, 195)); + +?> +--EXPECT-- +00 http://cvs.php.net/viewvc.cgi/php-src/ext/gd/libgd/gd.c?r1=1.102&r2=1.103&diff_format=u Index: php-src/ext/gd/libgd/gd.c diff -u php-src/ext/gd/libgd/gd.c:1.102 php-src/ext/gd/libgd/gd.c:1.103 --- php-src/ext/gd/libgd/gd.c:1.102 Fri Jan 19 15:16:46 2007 +++ php-src/ext/gd/libgd/gd.c Sat Mar 10 01:23:42 2007 @@ -1032,25 +1032,37 @@ /* Vertical */ if (x1==x2) { - if (y2 < y1) { - t = y2; - y2 = y1; - y1 = t; - } + if (thick > 1) { + int thickhalf = thick >> 1; + thickhalf = thick >> 1; + gdImageFilledRectangle(im, x1 - thickhalf, y1, x1 + thick - thickhalf - 1, y2, color); + } else { + if (y2 < y1) { + t = y2; + y2 = y1; + y1 = t; + } - for (;y1 <= y2; y1++) { - gdImageSetPixel(im, x1,y1, color); + for (;y1 <= y2; y1++) { + gdImageSetPixel(im, x1,y1, color); + } } return; - } else if (y1==y2) { /* Horizontal */ - if (x2 < x1) { - t = x2; - x2 = x1; - x1 = t; - } + } else if (y1==y2) { /* Horizontal */ + if (thick > 1) { + int thickhalf = thick >> 1; + thickhalf = thick >> 1; + gdImageFilledRectangle(im, x1, y1 - thickhalf, x2, y2 + thick - thickhalf - 1, color); + } else { + if (x2 < x1) { + t = x2; + x2 = x1; + x1 = t; + } - for (;x1 <= x2; x1++) { - gdImageSetPixel(im, x1,y1, color); + for (;x1 <= x2; x1++) { + gdImageSetPixel(im, x1,y1, color); + } } return; }

« previous php.cvs (#43486) next »