首页  >  文章  >  后端开发  >  在PHP中的imagecolorat()函数

在PHP中的imagecolorat()函数

PHPz
PHPz转载
2023-09-16 14:45:021572浏览

在PHP中的imagecolorat()函数

imagecolorat() 函数获取像素颜色的索引。

语法

imagecolorat( $img, $x, $y )

参数

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

  • x : 点的 x 坐标。

  • y: 点的 y 坐标。

返回

imagecolorat() 函数返回颜色索引,失败时返回 FALSE。

示例

以下是示例:

 Live Demo

<?php
   $img = imagecreatefrompng("http://www.tutorialspoint.com/images/tp-logo-diamond.png");
   $rgb = imagecolorat($img, 15, 25);
   $colors = imagecolorsforindex($img, $rgb);
   var_dump($colors);
?>

输出

以下是结果输出:

array(4) { ["red"]=> int(255) ["green"]=> int(255) ["blue"]=> int(255) ["alpha"]=> int(127) }

以上是在PHP中的imagecolorat()函数的详细内容。更多信息请关注PHP中文网其他相关文章!

声明:
本文转载于:tutorialspoint.com。如有侵权,请联系admin@php.cn删除