<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    三分自留地

    Follow your heart

      BlogJava :: 首頁 :: 聯(lián)系 :: 聚合  :: 管理
      4 Posts :: 2 Stories :: 1 Comments :: 0 Trackbacks

    一、清晰型

    <%@ page contentType="image/jpeg" import="java.awt.*, 
    java.awt.image.*,java.util.*,javax.imageio.*" %> 
    <%! 
    Color getRandColor(int fc,int bc) 

    Random random = new Random(); 
    if(fc>255) fc=255; 
    if(bc>255) bc=255; 
    int r=fc+random.nextInt(bc-fc); 
    int g=fc+random.nextInt(bc-fc); 
    int b=fc+random.nextInt(bc-fc); 
    return new Color(r,g,b); 

    %> 
    <% 
    out.clear();
    response.setHeader("Pragma","No-cache"); 
    response.setHeader("Cache-Control","no-cache"); 
    response.setDateHeader("Expires", 0); 
    int width=60, height=20; 
    BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); 
    Graphics g = image.getGraphics(); 
    Random random = new Random(); 
    g.setColor(getRandColor(200,250)); 
    g.fillRect(0, 0, width, height); 
    g.setFont(new Font("Times New Roman",Font.PLAIN,18)); 
    g.setColor(getRandColor(160,200)); 
    for (int i=0;i<155;i++) 

    int x = random.nextInt(width); 
    int y = random.nextInt(height); 
    int xl = random.nextInt(12); 
    int yl = random.nextInt(12); 
    g.drawLine(x,y,x+xl,y+yl); 

    String sRand=""; 
    for (int i=0;i<4;i++){ 
    String rand=String.valueOf(random.nextInt(10)); 
    sRand+=rand; 
    g.setColor(new Color(20+random.nextInt(110),20+random.nextInt(110),20+random.nextInt(110))); 
    g.drawString(rand,13*i+6,16); 

    session.setAttribute("SRA",sRand);
    g.dispose(); 
    ImageIO.write(image, "JPEG", response.getOutputStream()); 
    %>


    二、凌亂型

    <%@ page contentType="image/jpeg"
        import="java.awt.*, 
    java.awt.image.*,java.util.*,javax.imageio.*"%>
    <%! 
    Color getRandColor(int fc,int bc) 

    Random random = new Random(); 
    if(fc>255) fc=255; 
    if(bc>255) bc=255; 
    int r=fc+random.nextInt(bc-fc); 
    int g=fc+random.nextInt(bc-fc); 
    int b=fc+random.nextInt(bc-fc); 
    return new Color(r,g,b); 

    %>
    <% 
    char[] codeSequence = { 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J',
            'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W',
            'X', 'Y', 'Z', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9' };

    response.setHeader("Pragma","No-cache"); 
    response.setHeader("Cache-Control","no-cache"); 
    response.setDateHeader("Expires", 0); 
    int width=60, height=20; 
    BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); 
    Graphics g = image.getGraphics(); 
    Random random = new Random(); 
    g.setColor(getRandColor(200,250)); 
    g.fillRect(0, 0, width, height); 
    g.setFont(new Font("Fixedsys",Font.PLAIN,18)); 
    g.drawRect(0, 0, width - 1, height - 1); // 隨機(jī)產(chǎn)生160條干擾線,使圖象中的認(rèn)證碼不易被其它程序探測到。
    g.setColor(Color.BLACK);
    for (int i = 0; i < 30; i++) {
        int x = random.nextInt(width);
        int y = random.nextInt(height);
        int xl = random.nextInt(12);
        int yl = random.nextInt(12);
        g.drawLine(x, y, x + xl, y + yl);
    }
    String sRand=""; 
    for (int i=0;i<4;i++){     
    String rand=String.valueOf(codeSequence[random.nextInt(36)]);
    sRand+=rand; 
    g.setColor(new Color(20+random.nextInt(110),20+random.nextInt(110),20+random.nextInt(110))); 
    g.drawString(rand,13*i+6,16); 

    session.setAttribute("SRA",sRand);
    g.dispose(); 
    ImageIO.write(image, "JPEG", response.getOutputStream()); 
    out.clear();
    out = pageContext.pushBody();
    %>


    posted on 2013-11-01 13:43 大山 閱讀(115) 評(píng)論(0)  編輯  收藏

    只有注冊用戶登錄后才能發(fā)表評(píng)論。


    網(wǎng)站導(dǎo)航:
    博客園   IT新聞   Chat2DB   C++博客   博問  
     
    主站蜘蛛池模板: 免费jjzz在线播放国产| 国产精品成人免费一区二区 | 亚洲H在线播放在线观看H| 国产一二三四区乱码免费| 亚洲中久无码不卡永久在线观看| 男女啪啪永久免费观看网站| 91精品国产亚洲爽啪在线影院| 亚洲免费网站在线观看| jjizz全部免费看片| 亚洲欧洲日本精品| 亚欧在线精品免费观看一区| 久久亚洲AV成人无码| 波多野结衣在线免费观看| jlzzjlzz亚洲jzjzjz| 永久黄网站色视频免费| 美女被免费网站视频在线| 国产亚洲精品无码专区| 免费看搞黄视频网站| 亚洲男女一区二区三区| 国产免费毛不卡片| 国产成人不卡亚洲精品91| 国产精品亚洲mnbav网站| a级毛片100部免费观看| 亚洲欧洲在线播放| 永久免费视频v片www| 久久国产精品免费一区| 99ri精品国产亚洲| 老司机永久免费网站在线观看| 777亚洲精品乱码久久久久久| 免费人成网站永久| 国产aⅴ无码专区亚洲av麻豆| 国产真人无码作爱视频免费| 亚洲va国产va天堂va久久| 久久精品国产免费观看| 亚洲欧美成人一区二区三区| 亚洲熟伦熟女新五十路熟妇| 97久久免费视频| 看Aⅴ免费毛片手机播放| 日韩精品亚洲人成在线观看| 高清国语自产拍免费视频国产| 亚洲国产综合自在线另类|