/// <summary> /// 随机种子数 /// </summary> /// <param name="minShowCode">最小1位置</param> /// <param name="maxShowCode">最大128位置</param> /// <param name="isSetSession">是否保存Session中</param> /// <returns>对象</returns> public static NCaptcha Generate(byte minShowCode, byte maxShowCode, bool isSetSession) { NCaptcha code = new NCaptcha(minShowCode, maxShowCode); code.IsSetSession = isSetSession; return(code); }
public static NCaptcha GenerateAndDraw(byte showCount, System.IO.Stream outStream, EnImage enImg, string SetSessionName) { NCaptcha code = new NCaptcha(showCount); code.SetSessionName = SetSessionName; code.IsSetSession = true; EnFont font = new EnFont(); font.MyFont = enImg.ImgFont; font.MyColor = enImg.ImgColor; EnImage img = new EnImage(); img.ImgColor = Color.White; ; img.Width = enImg.Width; img.Height = enImg.Height; code.gBitmap = code.gDrawing(EnImage.PaintShape.Link, img, font); if (code.gBitmap != null && outStream != null) { code.gBitmap.Save(outStream, System.Drawing.Imaging.ImageFormat.Jpeg); } return(code); }
/// <summary> /// 生成5位置随机字符串 /// </summary> /// <param name="isSetSession">是否保存Session中</param> /// <returns>对象</returns> public static NCaptcha Generate(bool isSetSession) { NCaptcha code = new NCaptcha(); code.IsSetSession = isSetSession; return(code); }
public static NCaptcha Generate(byte showCount, bool isSetSession) { NCaptcha code = new NCaptcha(showCount); code.IsSetSession = isSetSession; return(code); }
/// <summary> /// 生成code /// </summary> /// <param name="sessionName"> 保存sessionName</param> /// <returns></returns> public static NCaptcha Generate(string sessionName) { NCaptcha code = new NCaptcha(); code.SetSessionName = sessionName; code.IsSetSession = true; return(code); }
/// <summary> /// 生成随机字符串并生成图片 /// </summary> /// <param name="showCount">字符串长度</param> /// <param name="outStream">输出流,可以为NULL</param> /// <param name="iformat">图片类型</param> /// <param name="isSetSession">是否保存Session中</param> /// <returns>返回对象</returns> public static NCaptcha GenerateAndDraw(byte showCount, System.IO.Stream outStream, System.Drawing.Imaging.ImageFormat iformat, bool isSetSession) { NCaptcha code = new NCaptcha(showCount); code.IsSetSession = isSetSession; EnFont font = new EnFont(); font.MyFont = new Font(FontFamily.GenericSerif, 20, FontStyle.Bold, GraphicsUnit.Point); font.MyColor = EnObject.listColor[0]; EnImage img = new EnImage(); img.ImgColor = Color.White; ; img.Width = code.GenerateCount * (int)font.MyFont.Size; img.Height = (int)(font.MyFont.Size) + 5; code.gBitmap = code.gDrawing(EnImage.PaintShape.Link, img, font); if (code.gBitmap != null && outStream != null) { code.gBitmap.Save(outStream, iformat); } return(code); }