Doc #78370 [Ver->Csd]: imagefilltoborder does not fill
| From: | cmb@php.net | 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