哈希空间 Ctrl + F 进行搜索
首页 php手册中文版 CSS中文手册 哈希文档 Markdown在线工具

imagecolorsforindex

(PHP 4, PHP 5, PHP 7, PHP 8)

imagecolorsforindex取得某索引的颜色

说明

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

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

示例 #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()

打开 哈希空间 微信小程序中查看更佳