说明:
.net 万岁...
.net framework 的类库真是太强了, 用 GDI+ 可以干N多N多事情.
广告时间:
shawl.qiu C# CMS 系统 预计40天后开始编码, 现在逐步设计中, 免得到时求职说什么什么作品...唉.
PS: 今天求职真是惨不忍睹, 谁要招网页相关的请联系 13435580019, 邱先生.
什么地方俺都去, 工资只要能过活就行, 但是食宿问题得解决.
shawl.qiu
2007-02-01
http://blog.csdn.net/btbtd
class checkcode:
复制代码 代码如下:
<%@ Page Language="C#" AutoEventWireup="True" %>
<%@ import Namespace="System.Drawing"%>
<%@ import Namespace="System.Drawing.Drawing2D"%>
<%@ import Namespace="System.Web"%>
<script runat="server">
private void Page_Load(object sender, System.EventArgs e)
{
String sRndStr=checkcode.rndStr(4);
checkcode.general(sRndStr);
}
/*-----------------------------------------------------------------------------------*\
* shawl.qiu c# .net checkcode class v1.0
\*-----------------------------------------------------------------------------------*/
//---------------------------------------------------------------------begin class checkcode
public class checkcode
{
//-----------------------------------begin event
public checkcode()
{
}
~checkcode()
{
}
//-----------------------------------end event
//-----------------------------------begin public constant
//-----------------------begin about
public const String auSubject="shawl.qiu c# .net checkcode class";
public const String auVersion="v1.0";
public const String au="shawl.qiu";
public const String auEmail="shawl.qiu@gmail.com";
public const String auBlog="http://blog.csdn.net/btbtd";
public const String auCreateDate="2007-2-1";
//-----------------------end about
//-----------------------------------end public constant
//-----------------------------------begin public static method
public static void general(String sCc)
{
Int32 ccLen=sCc.Length;
String ccFtFm="Arial";
Int32 ccFtSz=12;
Int32 ccWidth=ccLen*ccFtSz+1;
Int32 ccHeight=ccFtSz+5;
using(Bitmap oImg = new Bitmap(ccWidth, ccHeight))
{
using(Graphics oGpc=Graphics.FromImage(oImg))
{
HatchBrush hBrush = new HatchBrush(HatchStyle.DashedVertical,
Color.Yellow, Color.Silver);
oGpc.FillRectangle(hBrush, 0, 0, ccWidth, ccWidth);
oGpc.DrawString(sCc,new System.Drawing.Font(ccFtFm,ccFtSz, FontStyle.Bold),
new System.Drawing.SolidBrush(Color.Black),0,0);
//-----------------------边框
Pen blackPen = new Pen(Color.Black, 1);
oGpc.DrawLine(blackPen, 0, ccHeight, 0, 0); // 左竖线
oGpc.DrawLine(blackPen, 0,0,ccWidth,0); // 顶横线
oGpc.DrawLine(blackPen, ccWidth-1,0,ccWidth-1,20); // 右竖线
oGpc.DrawLine(blackPen, 0, ccHeight-1, ccWidth, ccHeight-1); // 底横线
writeImg(oImg);
}
}
} // end public static void general
public static String rndStr(Int32 len)
{
String sTemp="";
String sForRnd="0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z";
String[] aRnd=sForRnd.Split(',');
Random oRnd=new Random();
Int32 iArLen=aRnd.Length;
for(Int32 i=0; i<len; i++)
{
sTemp+=aRnd[oRnd.Next(0,iArLen)];
}
return sTemp;
} // end public static String rndStr
//-----------------------------------end public static method
//-----------------------------------begin private static method
private static void writeImg(Bitmap oImg)
{
using(System.IO.MemoryStream ms=new System.IO.MemoryStream())
{
oImg.Save(ms,System.Drawing.Imaging.ImageFormat.Png);
HttpContext.Current.Response.ClearContent();
HttpContext.Current.Response.ContentType="image/Png";
HttpContext.Current.Response.BinaryWrite(ms.ToArray());
}
} // end private static void writeImg
}
//---------------------------------------------------------------------end class checkcode
</script>
.net 万岁...
.net framework 的类库真是太强了, 用 GDI+ 可以干N多N多事情.
广告时间:
shawl.qiu C# CMS 系统 预计40天后开始编码, 现在逐步设计中, 免得到时求职说什么什么作品...唉.
PS: 今天求职真是惨不忍睹, 谁要招网页相关的请联系 13435580019, 邱先生.
什么地方俺都去, 工资只要能过活就行, 但是食宿问题得解决.
shawl.qiu
2007-02-01
http://blog.csdn.net/btbtd
class checkcode:
复制代码 代码如下:
<%@ Page Language="C#" AutoEventWireup="True" %>
<%@ import Namespace="System.Drawing"%>
<%@ import Namespace="System.Drawing.Drawing2D"%>
<%@ import Namespace="System.Web"%>
<script runat="server">
private void Page_Load(object sender, System.EventArgs e)
{
String sRndStr=checkcode.rndStr(4);
checkcode.general(sRndStr);
}
/*-----------------------------------------------------------------------------------*\
* shawl.qiu c# .net checkcode class v1.0
\*-----------------------------------------------------------------------------------*/
//---------------------------------------------------------------------begin class checkcode
public class checkcode
{
//-----------------------------------begin event
public checkcode()
{
}
~checkcode()
{
}
//-----------------------------------end event
//-----------------------------------begin public constant
//-----------------------begin about
public const String auSubject="shawl.qiu c# .net checkcode class";
public const String auVersion="v1.0";
public const String au="shawl.qiu";
public const String auEmail="shawl.qiu@gmail.com";
public const String auBlog="http://blog.csdn.net/btbtd";
public const String auCreateDate="2007-2-1";
//-----------------------end about
//-----------------------------------end public constant
//-----------------------------------begin public static method
public static void general(String sCc)
{
Int32 ccLen=sCc.Length;
String ccFtFm="Arial";
Int32 ccFtSz=12;
Int32 ccWidth=ccLen*ccFtSz+1;
Int32 ccHeight=ccFtSz+5;
using(Bitmap oImg = new Bitmap(ccWidth, ccHeight))
{
using(Graphics oGpc=Graphics.FromImage(oImg))
{
HatchBrush hBrush = new HatchBrush(HatchStyle.DashedVertical,
Color.Yellow, Color.Silver);
oGpc.FillRectangle(hBrush, 0, 0, ccWidth, ccWidth);
oGpc.DrawString(sCc,new System.Drawing.Font(ccFtFm,ccFtSz, FontStyle.Bold),
new System.Drawing.SolidBrush(Color.Black),0,0);
//-----------------------边框
Pen blackPen = new Pen(Color.Black, 1);
oGpc.DrawLine(blackPen, 0, ccHeight, 0, 0); // 左竖线
oGpc.DrawLine(blackPen, 0,0,ccWidth,0); // 顶横线
oGpc.DrawLine(blackPen, ccWidth-1,0,ccWidth-1,20); // 右竖线
oGpc.DrawLine(blackPen, 0, ccHeight-1, ccWidth, ccHeight-1); // 底横线
writeImg(oImg);
}
}
} // end public static void general
public static String rndStr(Int32 len)
{
String sTemp="";
String sForRnd="0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z";
String[] aRnd=sForRnd.Split(',');
Random oRnd=new Random();
Int32 iArLen=aRnd.Length;
for(Int32 i=0; i<len; i++)
{
sTemp+=aRnd[oRnd.Next(0,iArLen)];
}
return sTemp;
} // end public static String rndStr
//-----------------------------------end public static method
//-----------------------------------begin private static method
private static void writeImg(Bitmap oImg)
{
using(System.IO.MemoryStream ms=new System.IO.MemoryStream())
{
oImg.Save(ms,System.Drawing.Imaging.ImageFormat.Png);
HttpContext.Current.Response.ClearContent();
HttpContext.Current.Response.ContentType="image/Png";
HttpContext.Current.Response.BinaryWrite(ms.ToArray());
}
} // end private static void writeImg
}
//---------------------------------------------------------------------end class checkcode
</script>
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!
免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!
暂无评论...
更新日志
2024年11月29日
2024年11月29日
- 凤飞飞《我们的主题曲》飞跃制作[正版原抓WAV+CUE]
- 刘嘉亮《亮情歌2》[WAV+CUE][1G]
- 红馆40·谭咏麟《歌者恋歌浓情30年演唱会》3CD[低速原抓WAV+CUE][1.8G]
- 刘纬武《睡眠宝宝竖琴童谣 吉卜力工作室 白噪音安抚》[320K/MP3][193.25MB]
- 【轻音乐】曼托凡尼乐团《精选辑》2CD.1998[FLAC+CUE整轨]
- 邝美云《心中有爱》1989年香港DMIJP版1MTO东芝首版[WAV+CUE]
- 群星《情叹-发烧女声DSD》天籁女声发烧碟[WAV+CUE]
- 刘纬武《睡眠宝宝竖琴童谣 吉卜力工作室 白噪音安抚》[FLAC/分轨][748.03MB]
- 理想混蛋《Origin Sessions》[320K/MP3][37.47MB]
- 公馆青少年《我其实一点都不酷》[320K/MP3][78.78MB]
- 群星《情叹-发烧男声DSD》最值得珍藏的完美男声[WAV+CUE]
- 群星《国韵飘香·贵妃醉酒HQCD黑胶王》2CD[WAV]
- 卫兰《DAUGHTER》【低速原抓WAV+CUE】
- 公馆青少年《我其实一点都不酷》[FLAC/分轨][398.22MB]
- ZWEI《迟暮的花 (Explicit)》[320K/MP3][57.16MB]