示例#1
0
    if ($pixel)
    {
        for($i = 0; $i < 50; $i ++) 
        {
            imagesetpixel ( $image, mt_rand 
            ( 0, $width -           1 ), 
            mt_rand ( 0, $height - 1 ), $black );
        }
    }
    if ($line) 
    {
        for($i = 1; $i < $line; $i ++) 
        {
            $color = imagecolorallocate
             ( $image, mt_rand ( 50, 90 ),
              mt_rand ( 80, 200 ), mt_rand 
              ( 90,          180 ) );
            imageline ( $image, mt_rand 
            ( 0, $width - 1 ), 
            mt_rand ( 0, $height - 1 ), 
            mt_rand ( 0,$width - 1 ), 
            mt_rand ( 0, $height - 1 ),           
            $color );
        }
    }
    header ( "content-type:image/gif" );
    imagegif ( $image );
    imagedestroy ( $image );
}
yanzhengma(3,4,50,5);
?>
示例#2
0
    $strdata = array("最", '好', "的", "编", "程", "语", "言");
    for ($i = 0; $i < 4; $i++) {
        //	$fontsize = 5;
        $fontcolor = imagecolorallocate($img, rand(0, 150), rand(0, 150), rand(0, 150));
        $fontface = "msyh.ttf";
        //	$fontcont = substr($data,rand(0,strlen($data)-1),1);
        $fontcont = $strdata[array_rand($strdata)];
        $captureCode .= $fontcont;
        $x = $i * ($w / 4);
        $y = rand(0, $h / 4);
        imagettftext($img, 20, rand(-30, 30), $x, $y + 30, $fontcolor, $fontface, $fontcont);
        //	imagestring($img, $fontsize, $x, $y, $fontcont, $fontcolor);
    }
    $_SESSION['authcode'] = $captureCode;
    //增加干扰点
    for ($i = 0; $i < 200; $i++) {
        $pointcolor = imagecolorallocate($img, rand(50, 200), rand(50, 200), rand(50, 200));
        imagesetpixel($img, rand(0, $w), rand(0, $h), $pointcolor);
    }
    //增加干扰线
    for ($i = 0; $i < 3; $i++) {
        $linecolor = imagecolorallocate($img, rand(80, 200), rand(80, 200), rand(80, 200));
        imageline($img, rand(0, $w), rand(0, $h), rand(0, $w), rand(0, $h), $linecolor);
    }
    //输出图片
    header("Content-type:image/png");
    imagepng($img);
    imagedestroy($img);
}
yanzhengma(200, 60);
示例#3
0
    if ($pixel)
    {
        for($i = 0; $i < 50; $i ++) 
        {
            imagesetpixel ( $image, mt_rand 
            ( 0, $width -           1 ), 
            mt_rand ( 0, $height - 1 ), $black );
        }
    }
    if ($line) 
    {
        for($i = 1; $i < $line; $i ++) 
        {
            $color = imagecolorallocate
             ( $image, mt_rand ( 50, 90 ),
              mt_rand ( 80, 200 ), mt_rand 
              ( 90,          180 ) );
            imageline ( $image, mt_rand 
            ( 0, $width - 1 ), 
            mt_rand ( 0, $height - 1 ), 
            mt_rand ( 0,$width - 1 ), 
            mt_rand ( 0, $height - 1 ),           
            $color );
        }
    }
    header ( "content-type:image/gif" );
    imagegif ( $image );
    imagedestroy ( $image );
}
yanzhengma(3,4);
?>