zoukankan      html  css  js  c++  java
  • 验证码

    using system;
    using system.collections;
    using system.componentmodel;
    using system.data;
    using system.drawing;
    using system.web;
    using system.web.sessionstate;
    using system.web.ui;
    using system.web.ui.webcontrols;
    using system.web.ui.htmlcontrols;
    using system.drawing.imaging;
    using system.drawing.drawing2d;

    public void randomnumber()

    {

    //建立位图对象
        bitmap newbitmap = new bitmap(36,16,pixelformat.format32bppargb);
        //根据上面创建的位图对象创建绘图面
        graphics g = graphics.fromimage(newbitmap);
            //创建字体对象
        font textfont = new font("times new roman",10);
        //创建rectanglef结构指定一个区域
        rectanglef rectangle = new rectanglef(0,0,36,16);
        //创建随机数对象
        random rd = new random();
        //取得随机数
        int valationno =rd.next();
        //使用指定的颜色填充上面rectanglef结构指定的矩形区域
        g.fillrectangle(new solidbrush(color.burlywood), rectangle);
        //在上面填充的矩形区域中填充上面生成的随机数
        g.drawstring(valationno.tostring(), textfont, new solidbrush(color.blue), rectangle);
        //把创建的位图保存到指定的路径
        newbitmap.save(server.mappath("img")+"\\img.gif", imageformat.gif);

    }

    //注意,上面是我转来的,有一些字母都是小写的打头,是运行不了的.

    红色部分也有误,应当是这样 :

    System.Web.HttpContext.Current.Server.MapPath(

  • 相关阅读:
    openpyxl(python操作Excel)
    python爬虫之数据加密解密
    python爬虫之字体反爬
    识别缩略图加载
    Windows文件共享自动失效解决办法
    pygame
    获取文件路径、文件名、后缀名
    Oracle EBS INV 挑库发放物料搬运单
    Oracle EBS INV 删除保留
    Oracle EBS INV 创建货位
  • 原文地址:https://www.cnblogs.com/zjw/p/1233573.html
Copyright © 2011-2022 走看看