/// <summary> /// 将目标配置保存到文件中 /// </summary> /// <param name="ci">目标配置</param> /// <param name="strFileName">配置文件名(.fkc.png后缀以图片形式保存配置 方便查看)</param> public static void SaveToFile(CodeInfo ci, string strFileName) { byte[] byci = null; byte[] bylen = null; using (MemoryStream ms = new MemoryStream()) { BinaryFormatter bf = new BinaryFormatter(); bf.Serialize(ms, ci); byci = ms.ToArray(); } if (System.Text.RegularExpressions.Regex.IsMatch(strFileName.ToLower(), @"\.fkc\.png$")) { ci.ImageTemp.Save(strFileName, System.Drawing.Imaging.ImageFormat.Png); bylen = BitConverter.GetBytes(byci.Length); } using (FileStream fs = new FileStream(strFileName, FileMode.Create)) { fs.Position = 0;// fs.Length; fs.Write(byci, 0, byci.Length); if (bylen != null) { fs.Write(bylen, 0, bylen.Length); } } }
/// <summary> /// 加载验证码配置信息 /// </summary> /// <param name="strFileName">验证码配置文件</param> public void LoadCodeInfo(string strFileName) { m_ci = CodeInfo.LoadFromFile(strFileName); }
/// <summary> /// 构造函数 /// </summary> /// <param name="ci">验证码配置信息</param> public CodeHelper(CodeInfo ci) { m_ci = ci; }
/// <summary> /// 加载验证码配置信息 /// </summary> /// <param name="ci">验证码配置信息</param> public void LoadCodeInfo(CodeInfo ci) { m_ci = ci; }
private byte[] m_byColorInfo; //位图RGB值缓存 /// <summary> /// 构造函数 /// </summary> public CodeHelper() { m_ci = new CodeInfo(); }