zoukankan
html css js c++ java
产生随机图片,并返回图片内的文字
/**/
///
<summary>
///
产生随机图片,并返回图片内的文字
///
</summary>
///
<param name="img">
要显示图片的控件
</param>
///
<param name="path">
图片显示的文字
</param>
public
string
R_random(System.Web.UI.WebControls.Image img,
string
path)
{
string
tmp;
//
文字
Random rnd
=
new
Random();
tmp
=
rnd.Next().ToString().Substring(
0
,
4
);
Graphics g
=
null
;
Bitmap bmp
=
new
Bitmap(
50
,
100
);
g
=
Graphics.FromImage(bmp);
SizeF rec
=
g.MeasureString(tmp,
new
Font(
"
宋体
"
,
12
));
int
nwidth
=
(
int
)rec.Width;
int
nheight
=
(
int
)rec.Height;
g.Dispose();
bmp.Dispose();
bmp
=
new
Bitmap(nwidth,nheight);
g
=
Graphics.FromImage(bmp);
g.FillRectangle(
new
SolidBrush(Color.FromArgb(
90
,
126
,
220
)),
new
Rectangle(
0
,
0
,nwidth,nheight));
g.DrawString(tmp,
new
Font(
"
宋体
"
,
12
),
new
SolidBrush(Color.Yellow),
new
PointF(
0
,
0
));
string
fff
=
path
+
@"
tmp\validation.gif
"
;
bmp.Save(fff,System.Drawing.Imaging.ImageFormat.Gif);
img.ImageUrl
=
fff;
return
tmp;
查看全文
相关阅读:
消息队列 ActiveMQ
Redis
SQL 怎么用EXISTS替代IN
SQL优化
为什么要重写hashCode()和equals()方法
Redis的介绍和面试可能问到的问题
建立私有CA和颁发证书
修复grub2
Centos 7 进入救援模式
Centos 服务的常用命令
原文地址:https://www.cnblogs.com/aipeli/p/251775.html
最新文章
第二阶段每日总结03
第二阶段每日总结02
北京11月二手房成交量涨7成多 已有业主开始涨价
搜房董事长莫天全:我想到了市场会变坏
央行降息楼市应声而动:购房者出现恐慌苗头
国内油价今日将迎九连跌 出租车燃油费望调整
多项新政催生本年度购房最佳“窗口期”
央行降息一周房价涨还是跌?业内:开发商有心没胆
年终楼市:房企主攻改善型需求购房者 中介扩店招人
我们公司做物流的!今年大批件物业量锐减、各行经济都不景气、还鼓吹房价高涨!真是其心可诛!
热门文章
任志强:房价至少还要涨十多年 北京房价不会跌
楼市利好接踵而至 房地产市场底部已现共识
个人觉得不错的博客
@Autowired 与@Resource的区别
java中的各种池
idea快捷键和使用技巧
springboot和springcloud面试
SQL优化
为什么要重写hashCode()和equals()方法
Spring Framework(框架)整体架构
Copyright © 2011-2022 走看看