请教:
图片是看到了,但是却没有看到数字,也没有看到我写的一些干扰码,不知道是哪里出了问题?
谢谢。
---------------------------------------------------------------
估计是背景颜色和字体颜色一样!
1
2/*
3* Filename: authimg.php
4* Author: hutuworm
5* Date: 2003-04-28
6* @Copyleft hutuworm.org
7*/
8//生成验证码图片
9Header("Content-type: image/PNG");
10srand((double)microtime()*1000000);
11$im = imagecreate(62,20);
12$black = ImageColorAllocate($im, 0,0,0);
13$white = ImageColorAllocate($im, 255,255,255);
14$gray = ImageColorAllocate($im, 200,200,200);
15imagefill($im,68,30,$gray);
16while(($authnum=rand()%100000)<10000);
17//将四位整数验证码绘入图片
18imagestring($im, 5, 10, 3, $authnum, $white);
19for($i=0;$i<200;$i++) //加入干扰象素
20{
21$randcolor = ImageColorallocate($im,rand(0,255),rand(0,255),rand(0,255));
22imagesetpixel($im, rand()%70 , rand()%30 , $randcolor);
23}
24ImagePNG($im);
25ImageDestroy($im);
---------------------------------------------------------------
可以正确显示
你的问题可能出在imagefill($im,68,30,$gray); 这里点68,30已经在图片外了50,20
其实不需要imagefill,只需
$im = imagecreate(50,20);
$gray = ImageColorAllocate($im, 230,202,179); //第一次定义的颜色就是背景色
$black = ImageColorAllocate($im, 200,10,0);
$white = ImageColorAllocate($im, 255,255,255);