imagecolordeallocate()函数是PHP中的内置函数,用于将imagecolorallocate()函数或imagecolorallocatealpha()函数创建的颜色用于de-allocate。
用法:
bool imagecolordeallocate( $image, $color )
参数:该函数接受上述和以下描述的两个参数:
- $image:它由图像创建函数之一(例如imagecreatetruecolor())返回。它用于创建图像的尺寸。
 - $color:此参数保存颜色标识符。
 
返回值:如果成功,此函数返回True;如果失败,则返回False。
以下示例程序旨在说明PHP中的imagecolordeallocate()函数:
示例1:
<?php  
  
// It create the size of image or blank image.  
$image_size = imagecreatetruecolor(500, 300);  
  
// Set the background color of image using  
// imagecolorallocate() function.  
$bg = imagecolorallocate($image_size, 0, 103, 0);  
  
// Use imagecolordeallocate() function to 
// deallocate the color 
$bg = imagecolordeallocate($image_size, $bg); 
  
// Fill background with above selected color.  
imagefill($image_size, 0, 0, $bg);  
  
// Output image in the browser  
header("Content-type: image/png");  
imagepng($image_size);  
  
// free memory  
imagedestroy($image_size);  
  
?> 输出:

示例2:
<?php  
  
// It create the size of image or blank image.  
$image_size = imagecreatetruecolor(500, 300);  
  
// Set the background color of image.  
$bg = imagecolorallocate($image_size, 0, 103, 0);  
  
// Use imagecolordeallocate() function to 
// deallocate the color 
$bg = imagecolordeallocate($image_size, $bg);  
  
// Fill background with above selected color.  
imagefill($image_size, 0, 0, $bg);  
  
// Set the colors of image  
$white_color = imagecolorallocate($image_size, 255, 255, 255);  
  
// Draw a circle  
imagearc($image_size, 200, 150, 200, 200, 0, 360, $white_color);  
  
// Output image in the browser  
header("Content-type: image/png");  
imagepng($image_size);  
  
?>输出:

参考: https://www.php.net/manual/en/function.imagecolordeallocate.php
相关用法
- d3.js d3.set.has()用法及代码示例
 - PHP Ds\Map get()用法及代码示例
 - PHP Ds\Map xor()用法及代码示例
 - PHP Ds\Map put()用法及代码示例
 - CSS hsl()用法及代码示例
 - PHP each()用法及代码示例
 - PHP abs()用法及代码示例
 - p5.js arc()用法及代码示例
 - d3.js d3.hsl()用法及代码示例
 - d3.js d3.hcl()用法及代码示例
 - CSS url()用法及代码示例
 - CSS rgb()用法及代码示例
 
注:本文由纯净天空筛选整理自jit_t大神的英文原创作品 PHP | imagecolordeallocate() Function。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。
