PHP 中的 imagecolorresolve() 函数


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

语法

imagecolorresolve (img , red , green , blue )

参数

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

  • red:红色组件的值。

  • green:绿色组件的值。

  • blue:蓝色组件的值。

返回

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

示例

以下是示例

 实时演示

<?php
   $img = imagecreatefromgif('https://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 )

更新日期: 31-12-2019

20 次浏览

开启你的 职业生涯

完成课程并获得认证

开始学习
广告
© . All rights reserved.