Doc #78370 [Ver->Csd]: imagefilltoborder does not fill

From: Date: Wed, 13 Jan 2021 15:07:39 +0000
Subject: Doc #78370 [Ver->Csd]: imagefilltoborder does not fill
References: 1  Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-18384@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=78370&edit=1 ID: 78370 Updated by: cmb@php.net Reported by: 1602352639 at qq dot com Summary: imagefilltoborder does not fill -Status: Verified +Status: Closed Type: Documentation Problem Package: GD related Operating System: Windows10 PHP Version: Irrelevant Block user comment: N Private report: N New Comment: Automatic comment on behalf of cmbecker69@gmx.de Revision: http://git.php.net/?p=doc/en.git;a=commit;h=4b4883c70a4a4bd73e4a0c437432127514176c79 Log: Fix #78370: imagefilltoborder does not fill Previous Comments: ------------------------------------------------------------------------ [2019-08-05 07:29:57] cmb@php.net Resulting images: <https://imgur.com/a/YAmj9zh>. The algorithm doesn't explicitly remember which pixels have already been set, but rather infers that from the color of the pixel, so it can't distinguish between freshly set pixels and pixels that are already there. That means chosing any fill color that is already used in the image may yield undesired results. In this case a workaround is to first use an unused color, and to imagefilltoborder() with the desired color afterwards: imagefilltoborder($res,400,200,$bmgColor,imagecolorallocate($res,0,0,0)); imagefilltoborder($res,400,200,$bmgColor,$penColor1); I'm changing this ticket to doc problem, since the current behavior in this regard is not documented. If you think the algorithm should be changed/improved, please report that upstream (<https://github.com/libgd/libgd/issues>). ------------------------------------------------------------------------ [2019-08-04 12:05:23] 1602352639 at qq dot com Description: ------------ --- From manual page: https://php.net/function.imagefilltoborder --- 当被填充的图形是由imagefilledellipse创建时,可能出现无法正确填充的情况 Test script: --------------- <?php header("content-type:image/png"); $res=imagecreate(800,400); $bmgColor=imagecolorallocate($res,54,125,215); $darkPen1=imagecolorallocate($res,255*0.5,69*0.5,215*0.5); $penColor1=imagecolorallocate($res,255,69,215); $filledTime=15; while($filledTime--) { imagefilledellipse($res,400,200+$filledTime,100,40,$darkPen1); } imagefilledellipse($res,400,200,100,40,$penColor1); //问题出现在这里,这时第三个参数为200 imagefilltoborder($res,400,200,$bmgColor,$penColor1); imagepng($res); imagedestroy($res); ?> Expected result: ---------------- <?php header("content-type:image/png"); $res=imagecreate(800,400); $bmgColor=imagecolorallocate($res,54,125,215); $darkPen1=imagecolorallocate($res,255*0.5,69*0.5,215*0.5); $penColor1=imagecolorallocate($res,255,69,215); $filledTime=15; while($filledTime--) { imagefilledellipse($res,400,200+$filledTime,100,40,$darkPen1); } imagefilledellipse($res,400,200,100,40,$penColor1); /*当第三个参数改为202时,这才是预期的结果。但是第三个参数为200与202时不应该出现不同的结果,因为(400,200)与(400,202)它们都是在由imagefilledellipse($res,400,200,100,40,$penColor1)语句创建的区域里*/ imagefilltoborder($res,400,202,$bmgColor,$penColor1); imagepng($res); imagedestroy($res); ?> ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=78370&edit=1

« previous php.doc.bugs (#18384) next »