第11章 PHP动态图像处理
11.1 PHP中GD库的使用
创建图像的基本步骤:
- 创建画布
- 绘制图像
- 输出图像
- 释放资源
11.1.1 画布管理
resource imagecreate(int $x_size,int $y_size) //新建一个基于调色板的图像
resource imagecreatetruecolor(int $x_size,int $y_size) //新建一个真彩色图像
bool imagedestory(resource $image) //销毁图像
11.1.2 设置颜色
int imagecolorallocate(resource $image,int $red,int $green,int $blue) //为一幅图像分配颜色
11.1.3 生成图像
bool imagegif(resource $image [,string $filename]) //以GIF格式将图像输出
bool imagejpeg(resource $image [,string $filename [,int $quality]]) //以JPEG格式将图像输出
bool imagepng(resource $image [,string $filename]) //以PNG格式将图像输出
bool imagewbmp(resource $image [,string $filename [,int $foreground]]) //以WBMO格式将图像输出
11.1.4 绘制图像
- 图形区域填充
- 绘制点和线
- 绘制矩形
- 绘制多边形
- 绘制椭圆
- 绘制弧线