PHP 中的 imagecolorsforindex() 函数
imagecolorsforindex() 函数用于获取索引的颜色。
语法
imagecolorsforindex ( img, index )
参数
img:利用 imagecreatetruecolor() 创建一个图像
索引:设置颜色索引。
返回
imagecolorsforindex() 函数返回一个关联数组,其中 red、green、blue 和 alpha 键包含指定颜色索引的相应值。
示例
提供以下示例
<?php
$img = imagecreatefrompng('https://tutorialspoint.com/images/tp-logo-diamond.png');
$x = 25;
$y = 45;
$rgb = imagecolorat($img, 25, 45);
$colors = imagecolorsforindex($img, $rgb);
var_dump($colors);
?>输出
提供以下输出
array(4) { ["red"]=> int(255) ["green"]=> int(255) ["blue"]=> int(255) ["alpha"]=> int(127) }
广告
数据结构
网络
RDBMS
操作系统
Java
iOS
HTML
CSS
Android
Python
C 编程语言
C++
C#
MongoDB
MySQL
Javascript
PHP