(PHP 4, PHP 5, PHP 7, PHP 8)
imagecolorset — 给指定调色板索引设定颜色
本函数将调色板中指定的索引设定为指定的颜色。对于在调色板图像中创建类似区域填充(flood-fill)的效果很有用,免去了真的去填充的开销。
image
由图象创建函数(例如imagecreatetruecolor())返回的 GdImage 对象。
color
调色板中的索引值。
red
红色成分的值。
green
绿色成分的值。
blue
蓝色成分的值。
alpha
alpha 的值。
函数成功时返回 null
, 或者在失败时返回 false
。
版本 | 说明 |
---|---|
8.0.0 |
image 现在需要 GdImage 实例;之前需要有效的 gd resource。
|
示例 #1 imagecolorset() 示例
<?php
// Create a 300x100 image
$im = imagecreate(300, 100);
// Set the background to be red
imagecolorallocate($im, 255, 0, 0);
// Get the color index for the background
$bg = imagecolorat($im, 0, 0);
// Set the backgrund to be blue
imagecolorset($im, $bg, 0, 0, 255);
// Output the image to the browser
header('Content-Type: image/png');
imagepng($im);
imagedestroy($im);
?>