📜  PHP | imagecolorexact()函数

📅  最后修改于: 2022-05-13 01:56:34.343000             🧑  作者: Mango

PHP | imagecolorexact()函数

imagecolorexact()函数是PHP中的一个内置函数,用于获取图像调色板中指定颜色的索引。在创建的图像文件中,仅解析图像中使用的颜色。仅存在于调色板中的颜色不会被解析。

句法:

int imagecolorexact ( $image, $red, $green, $blue )

参数:该函数接受上面提到的四个参数,如下所述:

  • $image:它由图像创建函数之一返回,例如 imagecreatetruecolor()。它用于创建图像的大小。
  • $red:此参数用于设置红色分量的值。
  • $green:此参数用于设置绿色分量的值。
  • $blue:此参数用于设置蓝色分量的值。

返回值:此函数成功返回调色板中指定颜色的索引,如果颜色不存在则返回-1。

下面的程序说明了PHP中的imagecolorexact()函数。

方案一:


输出:

Array ( 
    [0] => 659220 
    [1] => 2012230 
    [2] => 800537 
    [3] => 10098996 
)

方案二:


输出:

Array ( 
    [0] => 39168 
    [1] => 0 
    [2] => 16777215 
    [3] => 6579252 
)

相关文章:

  • PHP | imagearc()函数
  • PHP | imagefillellipse()函数
  • PHP | imageellipse()函数

参考: 函数 : PHP 。 PHP