Php/docs/function.imagecreatetruecolor

来自菜鸟教程
跳转至:导航、​搜索

imagecreatetruecolor

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

imagecreatetruecolor新建一个真彩色图像


说明

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

imagecreatetruecolor() 返回一个图像标识符,代表了一幅大小为 x_sizey_size 的黑色图像。

是否定义了本函数取决于 PHP 和 GD 的版本。从 PHP 4.0.6 到 4.1.x 只要加载了 GD 模块本函数一直存在,但是在没有安装 GD2 的时候调用,PHP 将发出致命错误并退出。在 PHP 4.2.x 中此行为改为发出警告而不是错误。其它版本只在安装了正确的 GD 版本时定义了本函数。


参数

width
图像宽度。
height
图像高度。


返回值

成功后返回图象资源,失败后返回 false


范例

Example #1 新建一个新的 GD 图像流并输出图像

<?phpheader ('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);?>

以上例程的输出类似于:


注释

参见