imagecreatetruecolor

(PHP 4 >= 4.0.6, PHP 5, PHP 7, PHP 8)

imagecreatetruecolor新建一個(gè)真彩色圖像

說明

imagecreatetruecolor(int $width, int $height): resource

imagecreatetruecolor() 返回一個(gè)圖像標(biāo)識(shí)符,代表了一幅大小為 x_sizey_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

圖像高度。

返回值

成功后返回圖象對(duì)象,失敗后返回 false。

范例

示例 #1 新建一個(gè)新的 GD 圖像流并輸出圖像

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

以上例程的輸出類似于:

例子的輸出: 新建一個(gè)新的 GD 圖像流并輸出圖像

注釋

參見