array ( 0 => 'index.php', 1 => 'PHP Manual', ), 'head' => array ( 0 => 'UTF-8', 1 => 'zh', ), 'this' => array ( 0 => 'function.imagecolorset.php', 1 => 'imagecolorset', ), 'up' => array ( 0 => 'ref.image.php', 1 => 'GD 和图像处理 函数', ), 'prev' => array ( 0 => 'function.imagecolorresolvealpha.php', 1 => 'imagecolorresolvealpha', ), 'next' => array ( 0 => 'function.imagecolorsforindex.php', 1 => 'imagecolorsforindex', ), 'alternatives' => array ( ), 'source' => array ( 'lang' => 'zh', 'path' => 'reference/image/functions/imagecolorset.xml', ), ); $setup["toc"] = $TOC; $setup["toc_deprecated"] = $TOC_DEPRECATED; $setup["parents"] = $PARENTS; manual_setup($setup); ?>
(PHP 4, PHP 5, PHP 7, PHP 8)
imagecolorset — 给指定调色板索引设定颜色
本函数将调色板中指定的索引设定为指定的颜色。对于在调色板图像中创建类似区域填充(flood-fill)的效果很有用,免去了真的去填充的开销。
image
由图象创建函数(例如imagecreatetruecolor())返回的 GdImage 对象。
color
调色板中的索引值。
red
红色成分的值。
green
绿色成分的值。
blue
蓝色成分的值。
alpha
alpha 的值。
示例 #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);
?>