TUTORIALBackendFETCHED
PHP imagecolorat - 取得某像素的颜色索引值
PHP imagecolorat - 取得某像素的颜色索引值 PHP 图像处理 imagecolorat — 取得某像素的颜色索引值。 语法 int imagecolorat ( resource $image , int $x , int $y ) 返回 image 所指定的图形中指定位置像素的颜色索引值。 如果 PHP 编译时加上了 GD 库 2.0 或更高的版本并且图像是真彩色图像,则本函数以整数返回该点的 RGB 值。用移..
Updated 7/16/2026
Tutorial detail pages default to noindex.
PHP imagecolorat - 取得某像素的颜色索引值
imagecolorat — 取得某像素的颜色索引值。
语法
int imagecolorat ( resource $image , int $x , int $y )
返回 image 所指定的图形中指定位置像素的颜色索引值。
如果 PHP 编译时加上了 GD 库 2.0 或更高的版本并且图像是真彩色图像,则本函数以整数返回该点的 RGB 值。用移位加掩码来取得红,绿,蓝各自成分的值。
实例
取得各自的 RGB 值。
<?php
$im = ImageCreateFromPng("runoob-logo.png");
$rgb = ImageColorAt($im, 100, 25);
$r = ($rgb >> 16) & 0xFF;
$g = ($rgb >> 8) & 0xFF;
$b = $rgb & 0xFF;
?>
相关文章
- imagecolorset() 给指定调色板索引设定颜色。
- imagecolorsforindex() 取得某索引的颜色。
PHP 图像处理