background image

switch (rand(0, 1))
{
case 0:
$result.=$zhongwenku[rand(0, $zhongwenku_size-1)];
break;
case 1:
$result.=dechex(rand(0,15));
break;
}

}
$_SESSION["check"] = $result;

// 创建一个真彩图片 宽 100,高 30
$img = imagecreatetruecolor(100, 30);
// 分配背景颜色
$bg = imagecolorallocate($img, 0, 0, 0);
// 分配文字颜色
$te = imagecolorallocate($img, 255,255,255);
// 在图片上写字符串
//imagestring($img, rand(3,8), rand(1,70), rand(1,10), $result, $te);
// 在图片上根据载入字体可以写出特殊字体
imagettftext($img, 13, rand(2, 9), 20 ,20, $te, "MSYH.TTF",$result);
$_SESSION["check"] = $result;
for($i=0; $i<3; $i++)
{
// $t = imagecolorallocate($img, rand(0, 255),rand(0, 255),rand(0, 255));
// 画线
imageline($img, 0, rand(0, 20), rand(70,100), rand(0, 20), $te);
}
$t = imagecolorallocate($img, rand(0, 255),rand(0, 255),rand(0, 255));
// 为图片添加噪点
for($i=0; $i<200; $i++)
{
imagesetpixel($img, rand(1, 100), rand(1, 30), $t);
}
// 发送 http 头信息 指定本次发送的是 image 中的 jpeg
header("Content-type: image/jpeg");
// 输出 jpeg 图片至浏览器
imagejpeg($img);
?>

submit.php