Validate.aspx.cs
(开头部分) 3KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
using System;
using System.IO;
using System.Web;
using System.Web.UI;
using System.Drawing;
using System.Drawing.Imaging;
using System.Drawing.Drawing2D;
/// <summary>
/// Validate 的摘要说明。
/// </summary>
partial class Validate : System.Web.UI.Page
{
private void Page_Load(object sender, EventArgs e)
{
string strValidateCode = ValidateCode(4);//取得随机字符串,并设置Session值
DrawValidateCode(strValidateCode,50,100);//绘图
}
//绘图
private void DrawValidateCode(string strValidateCode,int intFgNoise,int intBgNoise)
{
if(strValidateCode == null || strValidateCode.Trim() == String.Empty)
{
return;
}
else
{
//建立一个位图文件 确立长宽
Bitmap bmpImage = new Bitmap((int)Math.Ceiling((strValidateCode.Length * 12.5)), 22);
Graphics grpGraphics = Graphics.FromImage(bmpImage);
try
{
//生成随机生成器
Random rndRandom = new Random();
//清空图片背景色
grpGraphics.Clear(Color.White);
//画图片的背景噪音线
for(int i=0; i<intBgNoise; i++)
{
int int_x1 = rndRandom.Next(bmpImage.Width);
int int_x2 = rndRandom.Next(bmpImage.Width);
int int_y1 = rndRandom.Next(bmpImage.Height);
int int_y2 = rndRandom.Next(bmpImage.Height);
grpGraphics.DrawLine(new Pen(Color.Silver), int_x1, int_y1, int_x2, int_y2);
}
//把产生的随机数以字体的形式写入画面
Font font = new Font("Arial", 12, (FontStyle.Bold | FontStyle.Italic));
LinearGradientBrush brhBrush = new LinearGradientBrush(new Rectangle(0, 0, bmpImage.Width, bmpImage.Height), Color.Blue, Color.DarkRed, 1.2f, true);
grpGraphics.DrawString(strValidateCode, font, brhBrush, 2, 2);
//画图片的前景噪音点
for(int i=0; i<intFgNoise; i++)
{
int int_x = rndRandom.Next(bmpImage.Width);
int int_y = rndRandom.Next(bmpImage.Height);
后面还有 72 行代码,解锁后查看完整代码
24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明
AI 解读 AI
登录后可用,每次 10 算力,解读结果公开显示在下面。
还没有人解读过这个文件。