imagecolorallocate(resouce $image,int $red,int $green,int $blue);
|
1
2
3
4
5
6
7
8
9
10
|
<?php $im = imagecreate(100, 100); //为设置颜色函数提供一个画布资源 //背景设为红色 $background = imagecolorallocate($im, 255, 0, 0); //第一次调用即为画布设置背景颜色 //设定一些颜色 $white = imagecolorallocate($im, 255, 255, 255); //返回由十进制整数设置为白色的标识符 $black = imagecolorallocate($im, 0, 0, 0); //返回由十进制整数设置为黑色的标识符 //十六进制方式 $white = imagecolorallocate($im, 0xFF, 0xFF, 0xFF); //返回由十六进制整数设置为白色的标识符 $black = imagecolorallocate($im, 0x00, 0x00, 0x00); //返回由十六进制整数设置为黑色的标识符 |
bool imagegif()
bool imagejpeg()
bool imagepng()
boole imagewbmp()
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
|
<?php if (function_exists("imagegif")){ header("Content-type:image/gif"); imagegif($image); }elseif (function_exists("imagejpeg")){ header("Content-type:image/jpeg"); imagejpeg($image, "", 0.5); }elseif (function_exists("imagepng")){ header("Content-type:imagepng"); imagepng($image); }elseif (function_exists("imagewbmp")){ header("Content-type:imagewbmp"); imagewbmp($image); }else{ die("在PHP服务中,不支持图像"); } |
imageFill()实现区域填充。
|
1
|
imagefill(resource $image,int $x,int $y,int $color); |
|
1
2
3
4
5
6
7
8
|
<?php $image = imagecreatetruecolor(100, 100); $red = imagecolorallocate($image, 255, 0, 0); imagefill($image, 0, 0, $red); header("Content-type:image/png"); imagepng($image); imagedestroy($image); |
|
1
|
bool imagesetpixel(resource $image, int $x, int $y, int $color); |
|
1
|
bool imageline(resource $image, int $x1, int $y1,int $x2, int $y2, int $color); |
|
1
2
|
bool imageRectangle(resource $image, int $x1, int $y1,int $x2, int $y2, int $color);bool imageFilledRectangle(resource $image, int $x1, int $y1,int $x2, int $y2, int $color); |
|
1
2
|
bool imageploygon(resource $image, array $points, int $num_points, int $color);bool imageFilledploygon(resource $image, array $points, int $num_points, int $color); |
|
1
2
|
bool imageellipse(resource $image, int $cx, int $cy,int $w, int $h, int $color);bool imagefilledellipse(resource $image, int $cx, int $cy,int $w, int $h, int $color); |
|
1
|
bool imagearc(resource $image, int $cx, int $cy,int $width, int $height, int s, int $e, int $color); |
在图像中绘制文字
原文:http://www.cnblogs.com/staven/p/d3ef425dd49f550b9757bfa758f3a842.html