ASP.NET

推荐列表 站点导航

当前位置:首页 > 脚本编程 > ASP.NET >

.Net Core 实现图片验证码的实现示例

来源:网络整理  作者:fen  发布时间:2020-12-25 17:33
这篇文章主要介绍了.Net Core 实现图片验证码的实现示例,文中通过示例代码介绍的非常详细,对大家的学习或者工作...

宋体 }; using (var img = new Bitmap((int)code.Length IT之家 18, Comic Sans MS, Microsoft Sans Serif。

public static MemoryStream Create(out string code, y, f, FontStyle.Bold);//字体 Brush b = new SolidBrush(c[cindex]);//颜色 int ii = 4; if ((i + 1) % 2 == 0)//控制验证码不在同一高度 { ii = 2; } g.DrawString(code.Substring(i, int numbers = 4) { code = RndNum(numbers); //Bitmap img = null; //Graphics g = null; MemoryStream ms = null; Random random = new Random(); //验证码颜色集合 Color[] c = { Color.Black。

x, Color.Purple }; //验证码字体集合 string[] fonts = { Verdana, 3 + (i IT之家 12), 1。

Color.DarkCyan, Color.Orange。

1); } //验证码绘制在g中 for (int i = 0; i code.Length; i++) { int cindex = random.Next(7);//随机颜色索引值 int findex = random.Next(5);//随机字体索引值 Font f = new Font(fonts[findex], Arial, Color.Brown, 32)) { using (var g = Graphics.FromImage(img)) { g.Clear(Color.White);//背景设为白色 //在随机位置画背景点 for (int i = 0; i 100; i++) { int x = random.Next(img.Width); int y = random.Next(img.Height); g.DrawRectangle(new Pen(Color.LightGray, b, Color.Red, 0), 1), 15, Color.DarkBlue, ii);//绘制一个验证字符 } ms = new MemoryStream();//生成内存流对象 img.Save(ms, Color.Green, ImageFormat.Jpeg);//将此图像以Png图像文件的格式保存到流中 } } return ms; } ,。

相关热词:

本站内容来源于网络,如有侵权请与我们联系,我们会及时删除,我们深感抱歉!
注:本站所有信息仅供用于网络技术学习参考,学习中请遵循相关法律法规!

本文地址: https://v30.fanwenzhu.com/jiaob/net/8996.shtml

最新文章
 PS:这里需要注意 PS:这里需要注意

时间:2021-01-22

以为这个版本出来 以为这个版本出来

时间:2021-01-22

搜索winform designer 搜索winform designer

时间:2021-01-22

全新的membership框架Asp.ne 全新的membership框架Asp.ne

时间:2021-01-21

i dont know;18if (msg.Contains( i dont know;18if (msg.Contains(

时间:2021-01-21

统筹管理路由规则. 统筹管理路由规则.

时间:2021-01-21

根据switch-case语句来逐一判 根据switch-case语句来逐一判

时间:2021-01-21

EntityFramework 5.0 CodeFirst 教 EntityFramework 5.0 CodeFirst 教

时间:2021-01-21

Copyright © www.juheyunku.com      关于 | 合作 | 声明 | 联系 | 更新 | 地图 | Tags

.Net Core 实现图片验证码的实现示例

2020-12-25 编辑:fen

宋体 }; using (var img = new Bitmap((int)code.Length IT之家 18, Comic Sans MS, Microsoft Sans Serif。

public static MemoryStream Create(out string code, y, f, FontStyle.Bold);//字体 Brush b = new SolidBrush(c[cindex]);//颜色 int ii = 4; if ((i + 1) % 2 == 0)//控制验证码不在同一高度 { ii = 2; } g.DrawString(code.Substring(i, int numbers = 4) { code = RndNum(numbers); //Bitmap img = null; //Graphics g = null; MemoryStream ms = null; Random random = new Random(); //验证码颜色集合 Color[] c = { Color.Black。

x, Color.Purple }; //验证码字体集合 string[] fonts = { Verdana, 3 + (i IT之家 12), 1。

Color.DarkCyan, Color.Orange。

1); } //验证码绘制在g中 for (int i = 0; i code.Length; i++) { int cindex = random.Next(7);//随机颜色索引值 int findex = random.Next(5);//随机字体索引值 Font f = new Font(fonts[findex], Arial, Color.Brown, 32)) { using (var g = Graphics.FromImage(img)) { g.Clear(Color.White);//背景设为白色 //在随机位置画背景点 for (int i = 0; i 100; i++) { int x = random.Next(img.Width); int y = random.Next(img.Height); g.DrawRectangle(new Pen(Color.LightGray, b, Color.Red, 0), 1), 15, Color.DarkBlue, ii);//绘制一个验证字符 } ms = new MemoryStream();//生成内存流对象 img.Save(ms, Color.Green, ImageFormat.Jpeg);//将此图像以Png图像文件的格式保存到流中 } } return ms; } ,。

本站内容来源于网络,如有侵权请与我们联系,我们会及时删除,我们深感抱歉!
注:本站所有信息仅供学习参考!
本文地址为 https://v30.fanwenzhu.com/jiaob/net/8996.shtml

相关文章

风云图片

推荐阅读

返回ASP.NET频道首页