//H4填充 private void button2_Click(object sender, EventArgs e) { YanMoCaptche yanmo = new YanMoCaptche(); for (int i = 0; i < captche.Length; i++) { string code = string.Format("{0}{1}{2}{3}{4}", yanmo.CharacterLine(bit[i], true, 3), yanmo.CharacterLine(bit[i], true, 5), yanmo.CharacterLine(bit[i], true, 8), yanmo.CharacterLine(bit[i], true, 11), yanmo.CharacterLine(bit[i], true, 13)); captche[i].Character = code; captche[i].Bearing = "H"; captche[i].Line = "6"; } }
//H7填充 private void button4_Click(object sender, EventArgs e) { YanMoCaptche yanmo = new YanMoCaptche(); for (int i = 0; i < captche.Length; i++) { captche[i].Character = yanmo.CharacterLine(bit[i], true, 7); captche[i].Bearing = "H"; captche[i].Line = "7"; } }
//下载图像并分割 private void btnDown_Click(object sender, EventArgs e) { Http.Http http = new Http.Http(); picSource.Image = http.PostImg(txtUrlImg.Text.Trim()); img = new Bitmap(picSource.Image); //加载图像 if (img != null) { YanMoCaptche yanmo = new YanMoCaptche(); //去除红色 img = yanmo.ClearRedColor(img, 130); //去除绿色 img = yanmo.ClearGreenColor(img, 150); //去除蓝色 img = yanmo.ClearBlueColor(img, 200); //灰度化 img = yanmo.GrayImage(img, 200); //去噪 img = yanmo.ClearNoise(img); picSource.Image = img; return; bit = yanmo.InciseImage(img); //切割 for (int i = 0; i < captche.Length; i++) //填充 { string code = string.Format("{0}", yanmo.CharacterLine(bit[i], false, 4)); captche[i].Character = code; //captche[i].Character = yanmo.CountBlack(bit[i],0).ToString(); captche[i].Bearing = "H"; captche[i].Line = "6"; } pic1.Image = bit[0]; pic2.Image = bit[1]; pic3.Image = bit[2]; pic4.Image = bit[3]; } rtxState.Clear(); }
private void btnCaptche_Click(object sender, EventArgs e) { if (bit != null) { //灰度 //picCaptche.Image = SetImageHeiSe(bit); //去点 //picCaptche.Image = ClearPixel(SetImageHeiSe(bit)); //灰度操作:SetImageHeiSe(bit) //打印 //PrintPixel(bit); //分割 //Bitmap[] b = PixelN(4, bit); //for (int i = 0; i < b.Length; i++) //{ // b[i].Save("H" + i.ToString() + ".bmp"); // rtxCaptche.AppendText(CountBlack(b[i], 0).ToString() + " " + CountBlack(b[i], 255).ToString() + "\r\n"); // rtxCaptche.AppendText(CharacterLine(b[i], true, 4) + "\r\n"); // rtxCaptche.AppendText(CharacterLine(b[i], true, 9) + "\r\n\r\n"); // rtxCaptche.AppendText(CharacterLine(b[i], false, 5) + "\r\n"); // rtxCaptche.AppendText(CharacterLine(b[i], false, 10) + "\r\n"); //} YanMoCaptche yanmo = new YanMoCaptche(); bit = yanmo.GrayImage(bit); bit = yanmo.ClearNoise(bit); Bitmap[] b = yanmo.InciseImage(bit); for (int i = 0; i < b.Length; i++) { b[i].Save("R" + i.ToString() + ".bmp"); rtxCaptche.AppendText((i + 1).ToString() + ":" + yanmo.CharacterLine(b[i], true, 5) + "\r\n"); } rtxCaptche.AppendText("\r\n"); } else { MessageBox.Show("对你无语了!", "出错"); } }