imagecolorat

(PHP 3, PHP 4, PHP 5)

imagecolorat -- ピクセルの色のインデックスを取得

説明

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

imageで指定された画像上の 特定位置にあるピクセルの色のインデックスを返します。

If PHP is compiled against GD library 2.0 or higher and the image is a truecolor image, this function returns the RGB value of that pixel as integer. Use bitshifting and masking to access the distinct red, green and blue component values: PHPがGDライブラリ2.0以上とともにコンパイルされておりかつ画像が Trueカラーイメージである場合、この関数はそのピクセルの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()も参考にしてください。