imagefilltoborder 


gd apg

PERFORMS a flood fill one delimited region with a defined color.





$x = 0 and $y = 0 are the coordinates of the top left point and the region is filled with $color.

This function returns TRUE on success or FALSE on failure.



<?php

bool imagefilltoborder 
( GdImage $image, 
                                                 
int $x, int $y, 
                                                 
int $border_color, 
                                                 
int $color )

where,

$image = The image identifier 

$x 
= The x-coordinate of the start point 

$y 
= The y-coordinate of the start point 

$border_color 
= The border color identifier 
                                  created by imagecolorallocate

$color 
= The fill color identifier 
                                  created by imagecolorallocate

?>
 

  $image   


The image identifier.



  $x   


x-coordinate of start point.



  $y   


y-coordinate of start point.



  $border_color   


The border color identifier created by imagecolorallocate.



  $color   


The fill color identifier created by imagecolorallocate.



  1 EXERCISE   

<?php

echo 'PHP VERSION: ' . PHP_VERSION . '<br><br>';

$base_img = 'png/PNG 071 01.png';

$dest_img = 'png/PNG 071 01 imagefilltoborder.png';

$id_base_img = imagecreate(640, 332);
$white = imagecolorallocate($id_base_img, 255, 255, 255);

imagepng($id_base_img, $base_img);

echo 
$base_img; ?><br><br>
<img src="<?php echo $base_img; ?>"
alt="<?php echo $base_img; ?>"
title="<?php echo $base_img; ?>" width="400"><br><br><br>


<?php

$id_base 
= imagecreatefrompng($base_img);

$internal_x = 97;
$internal_y = 87;

$external_x = 8;
$external_y = 10;

$fill_e = imagecolorallocate($id_base, 90, 90, 0);

$fill_i = imagecolorallocate($id_base, 90, 0, 0);

$bord_c = imagecolorallocate($id_base, 0, 255, 0);

imagerectangle($id_base, 68, 61, 554, 190, $bord_c);

imagerectangle($id_base, 72, 65, 550, 186, $bord_c);

imagefilltoborder($id_base, 
                             
$internal_x, 
                             
$internal_y, 
                             
$bord_c, $fill_i); 

imagefilltoborder($id_base, 
                             
$external_x, 
                             
$external_y, 
                             
$bord_c, 
                             
$fill_e); 

imagepng($id_base, $dest_img, 9);

echo 
$dest_img; ?><br><br>
<img src="<?php echo $dest_img; ?>"
alt="<?php echo $dest_img; ?>"
title="<?php echo $dest_img; ?>" width="400"><br>


 RESULT   

PNG 071 01.png

PNG 071 01.png apr


PNG 071 01 imagefilltoborder.png

PNG 071 01 imagefilltoborder.png apr

  2 EXERCISE   

<?php

echo 'PHP VERSION: ' . PHP_VERSION . '<br><br>';

$base_img = 'png/PNG 071 02.png';

$dest_img = 'png/PNG 071 02 imagefilltoborder.png';

echo 
$base_img; ?><br><br>
<img src="<?php echo $base_img; ?>"
alt="<?php echo $base_img; ?>"
title="<?php echo $base_img; ?>" width="400"><br><br><br>
<?php

$id_base 
= imagecreatefrompng($base_img);

$internal_x = 378;
$internal_y = 264;

$fill_c = imagecolorallocate($id_base, 255, 255, 255);

$bord_c = imagecolorallocate($id_base, 0, 255, 0);

imagerectangle($id_base, 68, 61, 554, 190, $bord_c);

imagerectangle($id_base, 72, 65, 550, 186, $bord_c);

imagefilltoborder($id_base, 
                             
$internal_x, 
                             
$internal_y, 
                             
$bord_c, 
                             
$fill_c); 

imagepng($id_base, $dest_img, 9);

echo 
$dest_img; ?><br><br>
<img src="<?php echo $dest_img; ?>"
alt="<?php echo $dest_img; ?>"
title="<?php echo $dest_img; ?>" width="400"><br>


 RESULT   

PNG 071 02.png

PNG 071 02.png apr


PNG 071 02 imagefilltoborder.png

PNG 071 02 imagefilltoborder.png apr

  3 EXERCISE   

<?php

echo 'PHP VERSION: ' . PHP_VERSION . '<br><br>';

$base_img = 'png/PNG 071 02.png';

$dest_img = 'png/PNG 071 03 imagefilltoborder.png';

echo 
$base_img; ?><br><br>
<img src="<?php echo $base_img; ?>"
alt="<?php echo $base_img; ?>"
title="<?php echo $base_img; ?>" width="400"><br><br><br>
<?php

$id_base 
= imagecreatefrompng($base_img);

$internal_x = 336;
$internal_y = 144;

$fill_c = imagecolorallocate($id_base, 255, 255, 255);

$bord_c = imagecolorallocate($id_base, 0, 255, 0);

imagerectangle($id_base, 68, 61, 554, 190, $bord_c);

imagerectangle($id_base, 72, 65, 550, 186, $bord_c);

imagefilltoborder($id_base, 
                            
$internal_x, 
                            
$internal_y, 
                            
$bord_c, 
                            
$fill_c); 

imagepng($id_base, $dest_img, 9);

echo 
$dest_img; ?><br><br>
<img src="<?php echo $dest_img; ?>"
alt="<?php echo $dest_img; ?>"
title="<?php echo $dest_img; ?>" width="400">


 RESULT   

PNG 071 02.png

PNG 071 02.png apr


PNG 071 03 imagefilltoborder.png

PNG 071 03 imagefilltoborder.png apr