private void StartDEMO() { Navigate("https://nportal.ntut.edu.tw"); if (!Loading(WB, Int32.Parse(tb_TimeOut.Text))) { MessageBox.Show("連線逾時!"); return; } Image img = GetRegCodePic(WB, "", "", "authImage"); Captcha tmp = new Captcha(new Bitmap(img)); tmp.ConvertGrayByPixels(0); tmp.ConvertGrayToBlackByPixels(160); tmp.InvertColorByPixels(); SplitCaptcha(tmp, 4); WebFillIn(WB, text_id.Text, text_pw.Text, txt_p1.Text + txt_p2.Text + txt_p3.Text + txt_p4.Text); }
private void btn_GetPic_Click(object sender, EventArgs e) { Image img = GetRegCodePic(WB, "", "", "authImage"); if (img == null) { list_debug.Items.Add("[" + DateTime.Now + "] 無法取得圖片"); return; } pic_Captcha_Original.Image = img; task_reflash(); rb_reflash(); pic_Captcha_Cut.Image = pic_Captcha_result.Image; Captcha obj = new Captcha(new Bitmap(pic_Captcha_result.Image)); SplitCaptcha(obj, Int32.Parse(textBox_cut.Text)); }
private void ChangCaptcha() { WB.Navigate("javascript:changeAuthImage()"); Loading(WB, 2); Image img = GetRegCodePic(WB, "", "", "authImage"); if (img == null) { list_debug.Items.Add("[" + DateTime.Now + "] 無法取得圖片"); return; } pic_Captcha_Original.Image = img; task_reflash(); rb_reflash(); pic_Captcha_Cut.Image = pic_Captcha_result.Image; Captcha obj = new Captcha(new Bitmap(pic_Captcha_result.Image)); SplitCaptcha(obj, Int32.Parse(textBox_cut.Text)); }
private void SplitCaptcha(Captcha obj, int want_char = 0, int mode = 0) { // Step2 其他處理 /*if (comboBox1.SelectedIndex == 1) * obj.RemoteNoiseLineByPixels(); * else if (comboBox1.SelectedIndex == 2) * { * obj.ClearPictureBorder(2); * obj.RemoteNoisePointByPixels(); * }*/ // Step2 改變圖片範圍 /*obj.ConvertBmpValidRange(4, 128); * pic_Captcha_Cut.Image = obj.BmpSource;*/ // Step3 切割圖片範圍 Bitmap[] bitmap = null; if (mode == 0) { bitmap = SampleOcr.SplitBitmaps(obj.BmpSource); if (bitmap.Length != want_char) { bitmap = null; bitmap = obj.GetSplitPicChars(want_char, 1); } } else if (mode == 1) { bitmap = SampleOcr.SplitBitmaps(obj.BmpSource); } else if (mode == 2) { bitmap = obj.GetSplitPicChars(want_char, 1); } CaptchaAlgorithm(bitmap, cb_algorithm.SelectedIndex); }
private void cb_algorithm_SelectedIndexChanged(object sender, EventArgs e) { Captcha obj = new Captcha(new Bitmap(pic_Captcha_result.Image)); SplitCaptcha(obj, Int32.Parse(textBox_cut.Text)); }