vb.net绘制点 vbnet showdialog( 二 )


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);
【vb.net绘制点 vbnet showdialog】 }
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; icheckCode.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);
}
}
}
关于vb.net绘制点和vbnet showdialog的介绍到此就结束了,不知道你从中找到你需要的信息了吗 ?如果你还想了解更多这方面的信息,记得收藏关注本站 。

推荐阅读