Web aym.pekori.to

imagecolorsforindex

(PHP 3, PHP 4, PHP 5)

imagecolorsforindex -- カラーインデックスからカラーの取得

説明

array imagecolorsforindex ( resource image, int index )

指定したカラーインデックス index に対して適当な値からなる red、green、blue をキーとする連想配列を返します。

例 1. imagecolorsforindex()の例

<?php

// open an image
$im = imagecreatefrompng('nexen.png');

// get a color
$start_x = 40;
$start_y = 50;
$color_index = imagecolorat($im, $start_x, $start_y);

// make it human readable
$color_tran = imagecolorsforindex($im, $color_index);

// what is it ?
echo '<pre>';
print_r($color_tran);
echo
'</pre>';

?>

この例は次のような出力となります:

Array
(
    [red] => 226
    [green] => 222
    [blue] => 252
    [alpha] => 0
)

imagecolorat()および imagecolorexact()も参考にしてください。