array ( 0 => 'index.php', 1 => 'PHP Manual', ), 'head' => array ( 0 => 'UTF-8', 1 => 'ja', ), 'this' => array ( 0 => 'function.imagecreatetruecolor.php', 1 => 'imagecreatetruecolor', ), 'up' => array ( 0 => 'ref.image.php', 1 => 'GD および Image 関数', ), 'prev' => array ( 0 => 'function.imagecreatefromxpm.php', 1 => 'imagecreatefromxpm', ), 'next' => array ( 0 => 'function.imagecrop.php', 1 => 'imagecrop', ), 'alternatives' => array ( ), 'source' => array ( 'lang' => 'ja', 'path' => 'reference/image/functions/imagecreatetruecolor.xml', ), ); $setup["toc"] = $TOC; $setup["toc_deprecated"] = $TOC_DEPRECATED; $setup["parents"] = $PARENTS; manual_setup($setup); ?>
(PHP 4 >= 4.0.6, PHP 5, PHP 7, PHP 8)
imagecreatetruecolor — TrueColor イメージを新規に作成する
imagecreatetruecolor() は、指定した大きさの黒い画像を表す画像オブジェクトを返します。
width
画像の幅。
height
画像の高さ。
成功した場合に画像オブジェクト、エラー時に false
を返します。
例1 新規 GD イメージストリームの作成およびイメージの出力
<?php
header ('Content-Type: image/png');
$im = @imagecreatetruecolor(120, 20)
or die('Cannot Initialize new GD image stream');
$text_color = imagecolorallocate($im, 233, 14, 91);
imagestring($im, 1, 5, 5, 'A Simple Text String', $text_color);
imagepng($im);
imagedestroy($im);
?>
上の例の出力は、 たとえば以下のようになります。