15. GD库

GD2模块

1. GD2程序绘图步骤

  1. 创建画布
  2. 为每一个画布分配颜色
  3. 使用相关函数进行绘图操(圈,点,线,写字)
  4. 通知浏览器图片相关信息(jpg,jpeg,png)
  5. 将图片显示到浏览器或保存到本地
  6. 释放资源

2.使用GD2先关函数进行绘图操作

  1. imagecreate( int $x_size, int $y_size) : resource — 新建一个基于调色板的图像(256种颜色,适合GIF格式)
  2. imagecreatetruecolor ( int $width , int $height ) : resource — 新建一个真彩色图像(颜色多适合制作PHG和JPG)
  3. imagecolorallocate( resource $image , int $red , int $green , int $blue ) : int — 为一幅图像分配颜色
  4. imagefill( resource $image , int $x(填充开始的X点) , int $y(填充开始的Y点) , int $color(步骤3所返回的数字标识(int)) ) : bool — 区域填充,在 image 图像的坐标 xy(图像左上角为 0, 0)处用 color 颜色执行区域填充
  5. header('Content-type:image/jpeg')-告诉浏览器图片相关信息
  6. imagejpeg ( resource $image (创建画布时返回的资源) [, string $filename` ] ) : bool— 输出图象到浏览器或文件。
  7. imagepng ( resource $image [, string $filename ] ) : bool
  8. imagegif ( resource $image [, string $filename ] ) : bool
  9. imagedestroy ( resource $image ) : bool — 销毁一图像
  10. 可以画其他形状或是写字或是对图片什么的进行操作,详情参考参考手册

image-20220615112933857

image-20220615113026813

image-20220615113054566


暂时了解一下吧,时间不多了,先把核心要用的学会再说吧........道阻且长,以后用时间再补补
posted @   VarFa  阅读(39)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· Manus的开源复刻OpenManus初探
· AI 智能体引爆开源社区「GitHub 热点速览」
· 从HTTP原因短语缺失研究HTTP/2和HTTP/3的设计差异
· 三行代码完成国际化适配,妙~啊~
点击右上角即可分享
微信分享提示