最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
php 创建图像实例
时间:2022-06-24 21:10:01 编辑:袖梨 来源:一聚教程网
<? header ("content-type: image/png");
| 代码如下 | 复制代码 |
| $newimg = imagecreate(250,250); | |
由于图像还是空白的,因此你可能会希望用一些彩色来填充它。你需要首先使用imagecolorallocate()函数用其rgb值为这种颜色指定一个名字,这一函数的格式为imagecolorallocate([image], [red], [green], [blue])。如果要定义天蓝色,可以使用如下的语句:
| 代码如下 | 复制代码 |
| $skyblue = imagecolorallocate($newimg,136,193,255); | |
接下来,需要使用imagefill()函数用这种颜色填充这个图像,imagefill()函数有几个版本,例如imagefillrectangle()、imagefillpolygon()等。为简单起见,我们通过如下的格式使用imagefill()函数:
| 代码如下 | 复制代码 |
|
imagefill([image], [start x point], [start y point], [color]) imagefill($newimg,0,0,$skyblue); |
|
最后,在图像建立后释放图像句柄和所占用的内存:
| 代码如下 | 复制代码 |
|
imagepng($newimg); imagedestroy($newimg); ?> |
|
这样,创建图像的全部代码如下所示:
php教程代码:
| 代码如下 | 复制代码 |
|
<? header ("content-type: image/png"); $newimg = imagecreate(250,250); $skyblue = imagecolorallocate($newimg,136,193,255); imagefill($newimg,0,0,$skyblue); imagepng($newimg); imagedestroy($newimg); ?> |
|
相关文章
- 致命公司铲子可攻击怪物类型汇总 12-05
- 星球重启20级头盔制作方法详解 12-05
- 星球重启分解废品任务完成方法 12-05
- 星球重启偶像任务攻略 偶像任务过法 12-05
- 星球重启9个酸液腺体获取攻略 12-05
- 星球重启采集工具制作方法 采集工具怎么做 12-05