PHP Velho Oeste 2024

imagecolordeallocate

(PHP 4, PHP 5, PHP 7, PHP 8)

imagecolordeallocate取消图像颜色的分配

说明

imagecolordeallocate(GdImage $image, int $color): bool

取消分配先前由 imagecolorallocate()imagecolorallocatealpha() 分配的颜色。

参数

image

由图象创建函数(例如imagecreatetruecolor())返回的 GdImage 对象。

color

颜色标识符。

返回值

成功时返回 true, 或者在失败时返回 false

更新日志

版本 说明
8.0.0 image 现在需要 GdImage 实例;之前需要有效的 gd resource

示例

示例 #1 使用 imagecolordeallocate()

<?php
$white
= imagecolorallocate($im, 255, 255, 255);
imagecolordeallocate($im, $white);
?>

参见

add a note add a note

User Contributed Notes 1 note

up
-10
sabretur
10 years ago
A faster way to get HTML color values:

function rgb2html($r, $g, $b){
$r = sprintf('%02x',$r);
$g = sprintf('%02x',$g);
$b = sprintf('%02x',$b);
return '#'.$r.$g.$b;
}
To Top