PHP中验证码类及使用方法(2)
return $this->mCheckImage;
}
//设置图片的干扰像素
function SetDisturbColor()
{
for ($i=0;$i<=128;$i++)
{
$this->mDisturbColor = imagecolorallocate ($this->mCheckImage, rand(0,255), rand(0,255), rand(0,255));
imagesetpixel($this->mCheckImage,rand(1,100),rand(1,100),$this->mDisturbColor);
}
}
//设置验证码图片的大小\宽\高
function SetCheckImageWH($width,$height)
{
if($width==''||$height=='')return false;
$this->mCheckImageWidth = $width;
$this->mCheckImageHeight = $height;
return true;
}
//在验证码图片上逐个画上验证码
function WriteCheckCodeToImage()
{
for ($i=0;$i<=$this->mCheckCodeNum;$i++)
{
$bg_color = imagecolorallocate ($this->mCheckImage, rand(0,255), rand(0,255), rand(0,255));
$x = floor($this->mCheckImageWidth/$this->mCheckCodeNum)*$i;
$y = rand(0,$this->mCheckImageHeight-15);
imagechar ($this->mCheckImage, 5, $x, $y, $this->mCheckCode[$i], $bg_color);
相关新闻>>
- 发表评论
-
- 最新评论 更多>>