array ( 0 => 'index.php', 1 => 'PHP Manual', ), 'head' => array ( 0 => 'UTF-8', 1 => 'ja', ), 'this' => array ( 0 => 'function.imagecolorset.php', 1 => 'imagecolorset', ), 'up' => array ( 0 => 'ref.image.php', 1 => 'GD および Image 関数', ), 'prev' => array ( 0 => 'function.imagecolorresolvealpha.php', 1 => 'imagecolorresolvealpha', ), 'next' => array ( 0 => 'function.imagecolorsforindex.php', 1 => 'imagecolorsforindex', ), 'alternatives' => array ( ), 'source' => array ( 'lang' => 'ja', 'path' => 'reference/image/functions/imagecolorset.xml', ), ); $setup["toc"] = $TOC; $setup["toc_deprecated"] = $TOC_DEPRECATED; $setup["parents"] = $PARENTS; manual_setup($setup); ?>
(PHP 4, PHP 5, PHP 7, PHP 8)
imagecolorset — 指定したパレットインデックスの色を設定する
この関数は、パレット上で指定したインデックス index を 指定した色 color に設定します。 実際にぬりつぶしを実行するオーバーヘッドなしに パレット上の色を使用する画像をぬりつぶしたような効果を得る ことができ、便利です。
image
imagecreatetruecolor()のような画像作成関数が返す GdImage オブジェクト。
color
パレットのインデックス。
red
赤コンポーネントの値。
green
緑コンポーネントの値。
blue
青コンポーネントの値。
alpha
アルファコンポーネントの値。
バージョン | 説明 |
---|---|
8.0.0 |
image は、
GdImage
クラスのインスタンスを期待するようになりました。
これより前のバージョンでは、有効な gd resource が期待されていました。
|
例1 imagecolorset() の例
<?php
// 300x100 の画像を作成します
$im = imagecreate(300, 100);
// 背景色を赤に設定します
imagecolorallocate($im, 255, 0, 0);
// 背景の色インデックスを取得します
$bg = imagecolorat($im, 0, 0);
// 背景色を青に設定します
imagecolorset($im, $bg, 0, 0, 255);
// 画像をブラウザに出力します
header('Content-Type: image/png');
imagepng($im);
imagedestroy($im);
?>