php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #78370 imagefilltoborder does not fill
Submitted: 2019-08-04 12:05 UTC Modified: 2021-01-13 15:08 UTC
Votes:1
Avg. Score:1.0 ± 0.0
Reproduced:0 of 1 (0.0%)
From: 1602352639 at qq dot com Assigned: cmb (profile)
Status: Closed Package: GD related
PHP Version: Irrelevant OS: Windows10
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: 1602352639 at qq dot com
New email:
PHP Version: OS:

 

 [2019-08-04 12:05 UTC] 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);
?>


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2019-08-05 07:29 UTC] cmb@php.net
-Summary: imagefilltoborder函数 +Summary: imagefilltoborder does not fill -Status: Open +Status: Verified -Type: Bug +Type: Documentation Problem
 [2019-08-05 07:29 UTC] 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>).
 [2021-01-13 15:07 UTC] cmb@php.net
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
 [2021-01-13 15:07 UTC] cmb@php.net
-Status: Verified +Status: Closed
 [2021-01-13 15:08 UTC] cmb@php.net
-Assigned To: +Assigned To: cmb
 [2021-01-13 16:47 UTC] mumumu@php.net
Automatic comment on behalf of mumumu@mumumu.org
Revision: http://git.php.net/?p=doc/ja.git;a=commit;h=5ea83a7c4cbd456add77dab6ef891e4c15a571db
Log: Fix #78370: imagefilltoborder does not fill
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Mar 19 06:01:30 2024 UTC