imagecreatetruecolor

(PHP 4 >= 4.0.6, PHP 5)

imagecreatetruecolor -- 新增一個真彩色圖像

說明

resource imagecreatetruecolor ( int x_size, int y_size )

imagecreatetruecolor() 返回一個圖像標識符,代表了一幅大小為 x_sizey_size 的黑色圖像。

是否定義了本函數取決於 PHP 和 GD 的版本。從 PHP 4.0.6 到 4.1.x 只要加載了 GD 模組本函數一直存在,但是在沒有安裝 GD2 的時候呼叫,PHP 將發出致命錯誤並離開。在 PHP 4.2.x 中此行為改為發出警示而不是錯誤。其它版本只在安裝了正確的 GD 版本時定義了本函數。

例子 1. 新增一個新的 GD 圖像流並輸出圖像

<?php
header
("Content-type: image/png");
$im = @imagecreatetruecolor(50100)
      or die(
"Cannot Initialize new GD image stream");
$text_color imagecolorallocate($im2331491);
imagestring($im155,  "A Simple Text String"$text_color);
imagepng($im);
imagedestroy($im);
?>

注: 本函數需要 GD 2.0.1 或更高版本。

注: 本函數不能用於 GIF 檔案格式。

參見 imagedestroy()imagecreate()