zoukankan
html css js c++ java
httphandler生成验证图
<%
@ WebHandler Language
=
"
C#
"
Class
=
"
image
"
%>
using
System;
using
System.Web;
using
System.Drawing;
public
class
image : IHttpHandler,System.Web.SessionState.IRequiresSessionState
{
public
void
ProcessRequest (HttpContext context)
{
context.Response.ContentType
=
"
text/gif
"
;
Bitmap b
=
new
Bitmap(
200
,
60
);
Graphics g
=
Graphics.FromImage(b);
g.FillRectangle(
new
SolidBrush(Color.White),
0
,
0
,
200
,
60
);
Font font
=
new
Font(FontFamily.GenericSansSerif,
48
, FontStyle.Bold, GraphicsUnit.Pixel);
Random r
=
new
Random();
string
letters
=
"
ABCDEFGHIJKMNPQRSTUVWXYX
"
;
string
letter;
System.Text.StringBuilder s
=
new
System.Text.StringBuilder();
for
(
int
x
=
0
; x
<
5
; x
++
)
{
letter
=
letters.Substring(r.Next(
0
, letters.Length
-
1
),
1
);
s.Append(letter);
g.DrawString(letter, font,
new
SolidBrush(Color.Black), x
*
38
, r.Next(
0
,
15
));
}
Pen linePen
=
new
Pen(
new
SolidBrush(Color.Black),
2
);
for
(
int
x
=
0
; x
<
6
; x
++
)
{
g.DrawLine(linePen,
new
Point(r.Next(
0
,
199
), r.Next(
0
,
59
)),
new
Point(r.Next(
0
,
199
), r.Next(
0
,
59
)));
}
b.Save(context.Response.OutputStream, System.Drawing.Imaging.ImageFormat.Gif);
context.Session[
"
aaa
"
]
=
s.ToString();
context.Response.End();
}
public
bool
IsReusable
{
get
{
return
false
;
}
}
}
<img src="image.ashx" />
查看全文
相关阅读:
关于题目中的内存限制
手动实现最小堆和最大堆(优先队列)
线性筛素数(欧拉筛)+前缀和优化
并查集
快速排序
栈
字典按中文姓名排序
oc程序代码
学生字典计算年龄差 随机50个数
nsset
原文地址:https://www.cnblogs.com/zwl12549/p/964728.html
最新文章
弹出层js要这样加才不会失效
css3滚动效果
用json传值时,最后一个不加逗号
调试时a标签禁止跳转方法
块级元素才能用缩进
商业数据分析第一记
Eclipse使用之添加字体
Android 自定义progressDialog实现
Fragment中获取Activity的Context
FragmentTabHost切换Fragment时避免重复加载UI
热门文章
Android 判断SD卡是否存在及容量
Android用simpleAdapter来直接显示bitmap图片
android 数据存储路径
Android 系统自带样式 theme
this.requestWindowFeature(Window.FEATURE_NO_TITLE)相关
Android自定义搜索框
最大公约数和最小公倍数问题
求一个正整数N的因子个数或该正整数N的所有因子之和
二分查找
一些技巧与注意事项
Copyright © 2011-2022 走看看