PHP imagecolorat - 取得某像素的颜色索引值

PHP 教程 · 2019-01-31 10:27:27

imagecolorat — 取得某像素的颜色索引值。

语法

int imagecolorat ( resource $image , int $x , int $y )

返回 image 所指定的图形中指定位置像素的颜色索引值。

如果 PHP 编译时加上了 GD 库 2.0 或更高的版本并且图像是真彩色图像,则本函数以整数返回该点的 RGB 值。用移位加掩码来取得红,绿,蓝各自成分的值。

实例

取得各自的 RGB 值。

<?php
$im = ImageCreateFromPng("codercto-logo.png");
$rgb = ImageColorAt($im, 100, 25);
$r = ($rgb >> 16) & 0xFF;
$g = ($rgb >> 8) & 0xFF;
$b = $rgb & 0xFF;
?>

相关文章

  • imagecolorset() 给指定调色板索引设定颜色。
  • imagecolorsforindex() 取得某索引的颜色。

点击查看所有 PHP 教程 文章: https://www.codercto.com/courses/l/5.html

查看所有标签

Usability for the Web

Usability for the Web

Tom Brinck、Darren Gergle、Scott D. Wood / Morgan Kaufmann / 2001-10-15 / USD 65.95

Every stage in the design of a new web site is an opportunity to meet or miss deadlines and budgetary goals. Every stage is an opportunity to boost or undercut the site's usability. Thi......一起来看看 《Usability for the Web》 这本书的介绍吧!

CSS 压缩/解压工具
CSS 压缩/解压工具

在线压缩/解压 CSS 代码

在线进制转换器
在线进制转换器

各进制数互转换器