PHP Image createtruecolor( ) 函数

17 Mar 2025 | 5 分钟阅读

Image createtruecolor( ) 函数是另一个内置的 PHP 函数,主要用于创建一个新的真彩色图像。该函数以特定尺寸返回给定图像。我们需要定义所需图像的宽度和高度。除了 image createtruecolor( ) 函数,我们还可以使用其他创意函数,如 image create ( ),它是另一个替代方案,因为它可以返回不同的图像质量。

语法


序号参数描述可选/必填
1$ width此参数用于定义我们想要显示的图像的宽度。强制性
2$ height此参数用于定义我们想要显示的图像的高度。强制

imagecreatetruecolor( ) 函数在程序成功执行时返回图像的资源标识符,在尝试失败时返回 FALSE。

程序 1: PHP 程序显示 imagecreatetruecolor ( ) 函数的基本用法

输出

PHP Image createtruecolor( ) Function

在这个程序中,我们声明了各种变量,如 $image 来定义我们所需的图像尺寸,$background color 来定义我们所需的背景颜色,$text color 来定义我们所需的文本颜色。我们使用 image string ( ) 函数来声明我们想要作为图像显示的字符串。为了显示图像的输出,我们使用内置的 PHP 命令 headerimagepng 在浏览器上显示。

程序 2: PHP 程序显示 imagecreatetruecolor ( ) 函数的用法

输出

PHP Image createtruecolor( ) Function

在这个程序中,我们声明了各种变量,如 $image 来定义我们所需的图像尺寸,$background color 来定义我们所需的背景颜色,$text color 来定义我们所需的文本颜色。我们使用 image string ( ) 函数来声明我们想要作为图像显示的字符串。为了显示图像的输出,我们使用内置的 PHP 命令 headerimagepng 在浏览器上显示。

程序 3: PHP 程序显示 imagecreatetruecolor ( ) 函数用于绘制多边形的用法

输出

PHP Image createtruecolor( ) Function

在这个程序中,我们声明了各种变量,如 $image 来定义我们所需的图像尺寸,$background color 来定义我们所需的背景颜色,$text color 来定义我们所需的文本颜色,数组 $values 来设置我们需要声明的多边形坐标,我们使用 image polygon ( ) 函数来显示我们想要作为图像显示的多边形,为了显示图像的输出,我们使用内置的 PHP 命令 headerimagepng 在浏览器上显示。

程序 4: PHP 程序显示 imagecreatetruecolor ( ) 函数用于绘制多边形的用法

输出

PHP Image createtruecolor( ) Function

在这个程序中,我们声明了各种变量,如 $image 来定义我们所需的图像尺寸,$background color 来定义我们所需的背景颜色,$text color 来定义我们所需的文本颜色,数组 $values 来设置我们需要声明的多边形坐标,我们使用 image polygon ( ) 函数来显示我们想要作为图像显示的多边形,为了显示图像的输出,我们使用内置的 PHP 命令 headerimagepng 在浏览器上显示。