GD库 步骤以及各种图形函数

指点在PHP中创建一个图像应该完成如下所示的4个步骤:

1.创建一个背景图像(也叫画布),以后的操作都基于此背景图像。

2.在背景上绘制图像轮廓或输入文本。

3.输出最终图形

4.释放资源

5、一定要指点输出的格式

header("Content-Type:images/png")

以下是函数

imagefill -- 区域填充

语法:bool imagefill(resource image,int x,int y, int color)

imagefill() 在 image 图像的坐标 x,y(图像左上角为 0, 0)处用 color 颜色执行区域填充(即与 x, y 点颜色相同且相邻的点都会被填充)。

imagesetpixel -- 画一个单一像素

语法:bool imagesetpixel ( resource image, int x, int y, int color )

imagesetpixel() 在 image 图像中用 color 颜色在 x,y 坐标(图像左上角为 0,0)上画一个点。

imageline -- 画一条线段

语法:bool imageline ( resource image, int x1, int y1, int x2, int y2, int color )

imageline() 用 color 颜色在图像 image 中从坐标 x1,y1 到 x2,y2(图像左上角为 0, 0)画一条线段。

 

imagerectangle -- 画一个矩形

语法:bool imagerectangle ( resource image, int x1, int y1, int x2, int y2, int col )

imagerectangle() 用 col 颜色在 image 图像中画一个矩形,其左上角坐标为 x1, y1,右下角坐标为 x2, y2。图像的左上角坐标为 0, 0。

imagefilledrectangle -- 画一矩形并填充

语法:bool imagefilledrectangle ( resource image, int x1, int y1, int x2, int y2, int color )

imagefilledrectangle() 在 image 图像中画一个用 color 颜色填充了的矩形,其左上角坐标为 x1,y1,右下角坐标为 x2,y2。0, 0 是图像的最左上角。

 

imageellipse -- 画一个椭圆

语法:bool imageellipse ( resource image, int cx, int cy, int w, int h, int color )

imageellipse() 在 image 所代表的图像中画一个中心为 cx,cy(图像左上角为 0, 0)的椭圆。w 和 h 分别指定了椭圆的宽度和高度,椭圆的颜色由 color 指定。

imagefilledellipse -- 画一椭圆并填充

语法:bool imagefilledellipse ( resource image, int cx, int cy, int w, int h, int color )

imagefilledellipse() 在 image 所代表的图像中以 cx,cy(图像左上角为 0, 0)为中心画一个椭圆。w 和 h 分别指定了椭圆的宽和高。椭圆用 color 颜色填充。如果成功则返回 TRUE,失败则返回 FALSE。

 

imagearc -- 画椭圆弧

bool imagearc ( resource image, int cx, int cy, int w, int h, int s, int e, int color )

imagearc() 以 cx,cy(图像左上角为 0, 0)为中心在 image 所代表的图像中画一个椭圆弧。w 和 h 分别指定了椭圆的宽度和高度,起始和结束点以 s 和 e 参数以角度指定。0°位于三点钟位置,以顺时针方向绘画。

imagefilledarc -- 画一椭圆弧且填充

bool imagefilledarc ( resource image, int cx, int cy, int w, int h, int s, int e, int color, int style )

imagefilledarc() 在 image 所代表的图像中以 cx,cy(图像左上角为 0, 0)画一椭圆弧。如果成功则返回 TRUE,失败则返回 FALSE。w 和 h 分别指定了椭圆的宽和高,s 和 e 参数以角度指定了起始和结束点。style 可以是下列值按位或(OR)后的值:

IMG_ARC_PIE        IMG_ARC_CHORD

IMG_ARC_NOFILL        IMG_ARC_EDGED

 

imagestring -- 水平地画一行字符串

语法:bool imagestring ( resource image, int font, int x, int y, string s, int col )

imagestring() 用 col 颜色将字符串 s 画到 image 所代表的图像的 x,y 坐标处(这是字符串左上角坐标,整幅图像的左上角为 0,0)。如果 font 是 1,2,3,4 或 5,则使用内置字体。

imagestringup -- 垂直地画一行字符串

语法:bool imagestringup ( resource image, int font, int x, int y, string s, int col )

imagestring()用 col 颜色将字符串 s 垂直地画到 image 所代表的图像的 x, y 座标处(图像的左上角为 0, 0)。如果 font 是 1,2,3,4 或 5,则使用内置字体。

 

imagechar -- 水平地画一个字符 (用来做验证码)

语法:bool imagechar ( resource image, int font, int x, int y, string c, int color )

imagechar() 将字符串 c 的第一个字符画在 image 指定的图像中,其左上角位于 x,y(图像左上角为 0, 0),颜色为 color。如果 font 是 1,2,3,4 或 5,则使用内置的字体(更大的数字对应于更大的字体)。

imagecharup -- 垂直地画一个字符

语法:bool imagecharup ( resource image, int font, int x, int y, string c, int color )

imagecharup() 将字符 c 垂直地画在 image 指定的图像上,位于 x,y(图像左上角为 0, 0),颜色为 color。如果 font 为 1,2,3,4 或 5,则使用内置的字体。

imagettftext -- 用 TrueType 字体向图像写入文本

语法 :array imagettftext ( resource image, float size, float angle, int x, int y, int color, string fontfile, string text )

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值