imagecolorsforindex

(PHP 4, PHP 5, PHP 7)

imagecolorsforindex取得某索引的颜色

说明

imagecolorsforindex ( resource $image , int $index ) : array

本函数返回一个具有 red,green,blue 和 alpha 的键名的关联数组,包含了指定颜色索引的相应的值。

Example #1 imagecolorsforindex() 例子

<?php

// 打开一幅图像
$im imagecreatefrompng('nexen.png');

// 取得一点的颜色
$start_x 40;
$start_y 50;
$color_index imagecolorat($im$start_x$start_y);

// 使其可读
$color_tran imagecolorsforindex($im$color_index);

// 显示该颜色的值
echo '<pre>';
print_r($color_tran);
echo 
'</pre>';

?>

本例将输出:

Array
(
    [red] => 226
    [green] => 222
    [blue] => 252
    [alpha] => 0
)

参见 imagecolorat()imagecolorexact()

相关文章
php gd 和图像处理 函数 取得当前安装的 gd 库的信息php gd 和图像处理 函数 取得 getimagesize,exif read data,exif thumbnail,exif imagetype 所返回的图像类型的 mime 类型php gd 和图像处理 函数 取得某像素的颜色索引值php gd 和图像处理 函数 取得与指定的颜色最接近的颜色的索引值php gd 和图像处理 函数 取得与指定的颜色加透明度最接近的颜色php gd 和图像处理 函数 取得与给定颜色最接近的色度的黑白色的索引php gd 和图像处理 函数 取消图像颜色的分配php gd 和图像处理 函数 取得指定颜色的索引值php gd 和图像处理 函数 取得指定的颜色加透明度的索引值php gd 和图像处理 函数 使一个图像中调色板版本的颜色与真彩色版本更能匹配php gd 和图像处理 函数 取得指定颜色的索引值或有可能得到的最接近的替代值php gd 和图像处理 函数 取得指定颜色 + alpha 的索引值或有可能得到的最接近的替代值php gd 和图像处理 函数 给指定调色板索引设定颜色php gd 和图像处理 函数 取得某索引的颜色php gd 和图像处理 函数 取得一幅图像的调色板中颜色的数目php gd 和图像处理 函数 将某个颜色定义为透明色php gd 和图像处理 函数 区域填充到指定颜色的边界为止php gd 和图像处理 函数 取得图像宽度php gd 和图像处理 函数 取得图像高度php gd 和图像处理 函数 取得使用 truetype 字体的文本的范围
关注编程学问公众号