asp.net中怎么画一些随机点,用VB.NET的
namespace Linfo{ public partial class VerifyCode : BasePage { public Random rand = new Random(); protected void Page_Load(object sender, EventArgs e) { string strListCode = "0123456789abcdefghigklmnopqrstuvwxyz"; int num = 0; string strNum = num。 ToString(); string strListNum = ""; for (int i = ...全部
namespace Linfo{ public partial class VerifyCode : BasePage { public Random rand = new Random(); protected void Page_Load(object sender, EventArgs e) { string strListCode = "0123456789abcdefghigklmnopqrstuvwxyz"; int num = 0; string strNum = num。
ToString(); string strListNum = ""; for (int i = 0; i = 3; i ) { num = this。rand。Next(1, 36); strListNum = strListNum strListCode。
Substring(num - 1, 1); } this。Session["checkcode"] = strListNum; base。Response。Cookies。Add(new HttpCookie("CheckCode", SHA1(strListNum))); this。
CreateImage(strListNum); } private void CreateImage(string checkCode) { int iwidth = checkCode。Length * 8; Bitmap image = new Bitmap(70, 30); Graphics g = Graphics。
FromImage(image); g。SmoothingMode = SmoothingMode。HighQuality; Font f = new Font("Arial ", 14f, FontStyle。
Bold); Brush b = new SolidBrush(Color。Black); Rectangle rect = new Rectangle(0, 0, 80, 30); HatchBrush hatchBrush = new HatchBrush(HatchStyle。
DarkDownwardDiagonal, Color。LightGray, Color。LightSkyBlue); g。FillRectangle(hatchBrush, rect); float CPostion = 1f; for (int i = 0; i checkCode。
Length; i ) { this。TransformG(g); SizeF size = g。MeasureString(checkCode[i]。ToString(), f); g。DrawString(checkCode[i]。
ToString(), f, b, CPostion, 5f); CPostion = size。Width - 1f; g。ResetTransform(); } MemoryStream ms = new MemoryStream(); image。
Save(ms, ImageFormat。Jpeg); g。Dispose(); image。Dispose(); base。Response。ClearContent(); base。Response。
ContentType = "image/Jpeg"; base。Response。BinaryWrite(ms。ToArray()); } private void TransformG(Graphics g) { Matrix myMatrix = new Matrix(); int num1 = this。
rand。Next(80, 900); int num2 = this。rand。Next(80, 800); float dd1 = num1; float dd2 = num2; dd1 /= 10000f; dd2 /= 10000f; float f1 = dd1; float f2 = dd2; myMatrix。
Shear(f1, f2); g。MultiplyTransform(myMatrix); } }}。收起