說明
int
imagecolorat ( resource image, int x, int y )
返回 image 所特殊的圖形中指定位置像素的彩色索引值。
若果 PHP 編譯時加上了 GD 庫 2.0
或更高的版本並且圖像是真彩色圖像,則本函數以整數返回該點的 RGB
值。用移位加遮罩來取得紅,綠,藍各自成分的值:
例子 1. 取得各自的 RGB 值
<?php $im = ImageCreateFromPng("rockym.png"); $rgb = ImageColorAt($im, 100, 100); $r = ($rgb >> 16) & 0xFF; $g = ($rgb >> 8) & 0xFF; $b = $rgb & 0xFF; ?>
|
|
參見 imagecolorset() 和
imagecolorsforindex()。