(PHP 4 >= 4.0.6, PHP 5)
imagecreatetruecolor — 新建一個(gè)真彩色圖像
說明
resource imagecreatetruecolor ( int$width
, int $height
)
imagecreatetruecolor() 返回一個(gè)圖像標(biāo)識(shí)符,代表了一幅大小為
x_size
和 y_size
的黑色圖像。
是否定義了本函數(shù)取決于 PHP 和 GD 的版本。從 PHP 4.0.6 到 4.1.x 只要加載了 GD 模塊本函數(shù)一直存在,但是在沒有安裝 GD2 的時(shí)候調(diào)用,PHP 將發(fā)出致命錯(cuò)誤并退出。在 PHP 4.2.x 中此行為改為發(fā)出警告而不是錯(cuò)誤。其它版本只在安裝了正確的 GD 版本時(shí)定義了本函數(shù)。
參數(shù)
width
圖像寬度。
height
圖像高度。
返回值
成功后返回圖象資源,失敗后返回 FALSE
。
范例
Example #1 新建一個(gè)新的 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);
?>
以上例程的輸出類似于:
注釋
Note: 此函數(shù)需要 GD 2.0.1 或更高版本(推薦 2.0.28 及更高版本)。
參見
imagedestroy() - 銷毀一圖像 imagecreate() - 新建一個(gè)基于調(diào)色板的圖像