imagecolordeallocate 


gd apg

DE-ALLOCATE a particular color for an image.





PALETTE IMAGE

is the designation term for images with a small number of colors.

For this type of image, a maximum of 256 colors are accepted.


TRUECOLOR IMAGE

is the designation term for images with a great number of colors.

For this type of image, a maximum of 16,777,216 colors are accepted.



<?php

bool imagecolordeallocate 
( GdImage $image, int $color )

where,

$image = An image identifier

$color 
= The color identifier

?>

  $image   


An image identifier.



  $color   


The color identifier.



  1 EXERCISE   

<?php

/* - - - - - - - - - - - - - - - - - - - - - -  

    RUN this exercise to see the result
     
     The use of the functions seen so far 
     does not yet allow the display of
     the generated images.
     This will be seen closely 
     with the use of other functions.
     
     Patience, then!

     - - - - - - - - - - - - - - - - - - - - - - */

if (!extension_loaded("gd")) 
        die(
"skip GD not present");

$w01 = 100;
$h01 = 100;

$img01p = imagecreate($w01, $h01);

$img01t = imagecreatetruecolor($w01, $h01);

$col_red_01p = imagecolorallocate($img01p, 255, 0, 0);

$col_red_01t = imagecolorallocate($img01t, 255, 0, 0); 

echo 
'<br><br>PALETTE COLOR image identifier<br><br>';

var_dump($img01p);

echo 
'<br><br>TRUE COLOR image identifier<br><br>';

var_dump($img01t);


echo 
'<br><br>PALETTE COLOR imagecolorallocate<br><br>';

var_dump($col_red_01p);

echo 
'<br><br>TRUE COLOR imagecolorallocate<br><br>';

var_dump($col_red_01t);


echo 
'<br><br><br>
      AFTER imagecolordeallocate($img01p, $col_red_01p)<br><br>'
;

$b01p = imagecolordeallocate($img01p, $col_red_01p);

var_dump($b01p);

echo 
'<br>';

echo 
'<br><br>
      AFTER imagecolordeallocate($img01t, $col_red_01t)<br><br>'
;

$b01t = imagecolordeallocate($img01t, $col_red_01t);

var_dump($b01t);

echo 
'<br>';

?>

  2 EXERCISE   

<?php

/* - - - - - - - - - - - - - - - - - - - - - -  

    RUN this exercise to see the result
     
     The use of the functions seen so far 
     does not yet allow the display of
     the generated images.
     This will be seen closely 
     with the use of other functions.
     
     Patience, then!

     - - - - - - - - - - - - - - - - - - - - - - */

    
if (!extension_loaded("gd")) 
        die(
"skip GD not present");

$image = imagecreatetruecolor(180, 30);
echo 
"Image identifier:<br>";
var_dump($image);

$white = imagecolorallocate($image, 255, 255, 255);
echo 
"<br><br>Allocated color: <br>";
var_dump($white);
$result = imagecolordeallocate($image, $white);
echo 
"<br><br>Deallocated color: <br>";
var_dump($result);

?>