导航首页 » 技术教程 » PHP:imagecreatetruecolor()的用法_GD库图像处理函数
PHP:imagecreatetruecolor()的用法_GD库图像处理函数 130 2023-12-15   

imagecreatetruecolor

(PHP 4 >= 4.0.6, PHP 5)

imagecreatetruecolor — 新建一个真彩色图像

说明

resource imagecreatetruecolor ( int $width , int $height )

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 图像流并输出图像

<?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: 此函数需要 GD 2.0.1 或更高版本(推荐 2.0.28 及更高版本)。

参见

imagedestroy() - 销毁一图像 imagecreate() - 新建一个基于调色板的图像


!!!站长长期在线接!!!

网站、小程序:定制开发/二次开发/仿制开发等

各种疑难杂症解决/定制接口/定制采集等

站长微信:lxwl520520

站长QQ:1737366103