Home  >  Article  >  Backend Development  >  php图像处理简单实例_PHP教程

php图像处理简单实例_PHP教程

WBOY
WBOYOriginal
2016-07-13 10:45:44655browse

imagecreatetruecolor()返回一个图像标识符代表指定大小的黑色形象。

根据你的php教程和gd版本中函数定义与否。对于php 4.0.6通过4.1.x这个函数总是存在的


*/
$im=imagecreatetruecolor(100,100);        //创建图像
$string='n';            //定义字符
$white=imagecolorallocate($im,255,255,255);      //定义白色
$black=imagecolorallocate($im,0,0,0);       //定义黑色
$red=imagecolorallocate($im,255,0,0);       //定义红色
//在白色的背景上输出一个黑色的"z",其实是颠倒的n
imagecharup($im,6,20,20,$string,$white);
imagechar($im,2,40,40,"r",$red);        //使用红色画出字符
header('content-type: image/png');        //输出头部信息
imagepng($im);            //输出png文件
imagedestroy($im);         //销毁图像

//

$img=imagecreatetruecolor(400,400);      //创建图像
$white=imagecolorallocate($img,255,255,255);     //定义白色
$black=imagecolorallocate($img,0,0,0);      //定义黑色
imagearc($img,200,200,350,350,0,360,$white);     //画椭圆弧
header("content-type: image/png");       //输出头信息
imagepng($img);          //输出为png图像
imagedestroy($img);          //销毁图像

//
$size=300;
$image=imagecreatetruecolor($size,$size);
//用白色背景加黑色边框画个方框
$back=imagecolorallocate($image,255,255,255);
$border=imagecolorallocate($image,0,0,0);
imagefilledrectangle($image,0,0,$size-1,$size-1,$back);
imagerectangle($image,0,0,$size-1,$size-1,$border);
$yellow_x=100;
$yellow_y=75;
$red_x=120;
$red_y=165;
$blue_x=187;
$blue_y=125;
$radius=150;
//用alpha值分配一些颜色
$yellow=imagecolorallocatealpha($image,255,255,0,75);
$red=imagecolorallocatealpha($image,255,0,0,75);
$blue=imagecolorallocatealpha($image,0,0,255,75);
//画三个交迭的圆
imagefilledellips教程e($image,$yellow_x,$yellow_y,$radius,$radius,$yellow);
imagefilledellipse($image,$red_x,$red_y,$radius,$radius,$red);
imagefilledellipse($image,$blue_x,$blue_y,$radius,$radius,$blue);
//输出header文件头
header('content-type: image/png');
//最后输出结果
imagepng($image);
imagedestroy($image);

//

$im=imagecreate(100,100);         //创建图像
$string='php';            //定义字符串
$bg=imagecolorallocate($im,255,255,255);      //定义白色
$black=imagecolorallocate($im,0,0,0);       //定义黑色
//在左上角输出指定字符
imagechar($im,1,0,0,$string,$black);
header('content-type: image/png');        //输出头部信息
imagepng($im);            //输出png文件
imagedestroy($im);           //销毁图像

?>

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/632992.htmlTechArticleimagecreatetruecolor()返回一个图像标识符代表指定大小的黑色形象。 根据你的php教程和gd版本中函数定义与否。对于php 4.0.6通过4.1.x这个函数...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn