array ( 0 => 'index.php', 1 => 'PHP Manual', ), 'head' => array ( 0 => 'UTF-8', 1 => 'zh', ), 'this' => array ( 0 => 'function.imagecolorresolve.php', 1 => 'imagecolorresolve', ), 'up' => array ( 0 => 'ref.image.php', 1 => 'GD 和图像处理 函数', ), 'prev' => array ( 0 => 'function.imagecolormatch.php', 1 => 'imagecolormatch', ), 'next' => array ( 0 => 'function.imagecolorresolvealpha.php', 1 => 'imagecolorresolvealpha', ), 'alternatives' => array ( ), 'source' => array ( 'lang' => 'zh', 'path' => 'reference/image/functions/imagecolorresolve.xml', ), ); $setup["toc"] = $TOC; $setup["toc_deprecated"] = $TOC_DEPRECATED; $setup["parents"] = $PARENTS; manual_setup($setup); ?>
(PHP 4, PHP 5, PHP 7, PHP 8)
imagecolorresolve — 取得指定颜色的索引值或有可能得到的最接近的替代值
本函数可以保证对所请求的颜色返回颜色索引,要么是准确的颜色要么是最接近的颜色。
如果图象由文件创建,只有该图象使用到的颜色会被解析。仅存在于调色板中的颜色不会被解析。
返回颜色索引值。
示例 #1 使用 imagecoloresolve() 从图像中获取颜色
<?php
// Load an image
$im = imagecreatefromgif('phplogo.gif');
// Get closest colors from the image
$colors = array();
$colors[] = imagecolorresolve($im, 255, 255, 255);
$colors[] = imagecolorresolve($im, 0, 0, 200);
// Output
print_r($colors);
imagedestroy($im);
?>
以上示例的输出类似于:
Array ( [0] => 89 [1] => 85 )