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。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。
