CaptchaRecogition.ImageProcess.WriteZimo C# (CSharp) 메소드

WriteZimo() 공개 정적인 메소드

字模库维护
public static WriteZimo ( Bitmap smallPic, string zimoPath, string YZMCode ) : void
smallPic System.Drawing.Bitmap 小图片
zimoPath string 字模路径
YZMCode string 验证码字符
리턴 void
        public static void WriteZimo(Bitmap smallPic, string zimoPath, string YZMCode)
        {
            string code = GetBinaryCode(smallPic);
            string zimo = YZMCode + "--" + code + "\r\n";
            string[] zimos = File.ReadAllLines(zimoPath);
            if (!zimos.Contains(zimo))
            {
                File.AppendAllText(zimoPath, zimo);
            }
        }
    }

Usage Example

예제 #1
0
 /// <summary>
 /// 字模学习入库
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void btn_CodeStudy_Click(object sender, EventArgs e)
 {
     if (cutResult != null)
     {
         string[]      zimos   = File.ReadAllLines(zimoPath);
         string        zimo    = string.Empty;
         StringBuilder sb      = new StringBuilder();
         string[]      stuCode = new string[] { txt1.Text.Trim(), txt2.Text.Trim(), txt3.Text.Trim(), txt4.Text.Trim(), txt5.Text.Trim( ), txt6.Text.Trim( ), txt7.Text.Trim(), txt8.Text.Trim() };
         for (int i = 0; i < cutResult.Count; i++)
         {
             if (!string.IsNullOrEmpty(stuCode[i]))
             {
                 ImageProcess.WriteZimo(cutResult[i], zimoPath, stuCode[i]);
             }
         }
         //File.AppendAllText(zimoPath, sb.ToString());
         txt1.Text = "";
         txt2.Text = "";
         txt3.Text = "";
         txt4.Text = "";
         txt5.Text = "";
         txt6.Text = "";
         txt7.Text = "";
         txt8.Text = "";
     }
     else
     {
         MessageBox.Show("验证码分割过程错误!");
     }
     groupBox_Study.Enabled = false;
 }