ASP.net 验证码(C#)[2]

[入库:2005年8月18日] [更新:2007年3月27日]

本文简介:选择自 hanghwp 的 blog

    }

    font font = new system.drawing.font("arial", 12, (system.drawing.fontstyle.bold | system.drawing.fontstyle.italic));
    system.drawing.drawing2d.lineargradientbrush brush = new system.drawing.drawing2d.lineargradientbrush(new rectangle(0, 0, image.width, image.height), color.blue, color.darkred, 1.2f, true);
    g.drawstring(checkcode, font, brush, 2, 2);

    //画图片的前景噪音点
    for(int i=0; i<100; i++)
    {
     int x = random.next(image.width);
     int y = random.next(image.height);

     image.setpixel(x, y, color.fromargb(random.next()));
    }

    //画图片的边框线
    g.drawrectangle(new pen(color.silver), 0, 0, image.width - 1, image.height - 1);

    system.io.memorystream ms = new system.io.memorystream();
    image.save(ms, system.drawing.imaging.imageformat.gif);
    response.clearcontent();
    response.contenttype = "image/gif";
    response.binarywrite(ms.toarray());
   }
   finally
   {
    g.dispose();
    image.dispose();
   }
  }

本文关键:,ASP.net 验证码(C#),
 

本站最佳浏览方式为 分辨率 1024x768 IE 6.0(或更高版本的 IE浏览器)

go top