PHP 中的 imagecolorresolve() 函数

server side programmingprogrammingphp

imagecolorresolve() 函数获取指定颜色或其最接近的替代颜色的索引。

语法

imagecolorresolve (img, red, green, blue)

参数

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

  • red:红色分量的值。

  • green:绿色分量的值。

  • blue:蓝色分量的值。

返回

imagecolorresolve() 函数返回颜色索引。

示例

以下是示例

<?php
   $img = imagecreatefromgif('https://www.tutorialspoint.com/images/html.gif');
   $colors = array();
   $colors[] = imagecolorresolve($img, 120, 0, 190);
   $colors[] = imagecolorresolve($img, 110, 0, 140);
   $colors[] = imagecolorresolve($img, 120, 190, 0);
   print_r($colors);
   imagedestroy($img);
?>

输出

输出结果如下:

Array ( [0] => 128 [1] => 129 [2] => 130 )

相关文章