PHP 中的 imagecolorset() 函数


imagecolorset() 函数为指定的色板索引设置颜色。使用此函数可以在色板图像中创建泛洪填充效果。

语法

imagecolorset ( img, index, red, green, blue, alpha )

参数

  • img:使用 imagecreatetruecolor() 函数创建的图像

  • index:色板图像中的索引

  • red:红色分量值

  • green:绿色分量值

  • blue:蓝色分量值

  • alpha:图像的透明度。

返回

imagecolorset() 函数不返回任何内容。

示例

以下是一个示例

<?php
   $img = imagecreate(550, 400);
   imagecolorallocate($img, 0, 0, 0);
   $bgcolor = imagecolorat($img, 70, 85);
   imagecolorset($img, $bgcolor, 30, 110, 150);
   header('Content-Type: image/png');
   imagepng($img);
   imagedestroy($img);
?>

输出

以下为输出

更新于: 31-12-2019

93 人次浏览

开启你的职业生涯

通过完成课程获得认证

开始
广告
© . All rights reserved.