示例#1
0
        private void button2_Click(object sender, EventArgs e)
        {
            ///
            /// 获取webbrowser里的图片
            ///
            HTMLDocument html = (HTMLDocument)webBrowser1.Document.DomDocument;//注意是HTMLDocument而不是HtmlDocument
            //寻找验证码图片,因为没有ID所以得自己定位
            HtmlElement         elem  = webBrowser1.Document.GetElementById("icode");
            IHTMLControlElement img   = (IHTMLControlElement)elem.DomElement;
            IHTMLControlRange   range = (IHTMLControlRange)((HTMLBody)html.body).createControlRange();

            range.add(img);
            range.execCommand("Copy", false, null);

            if (Clipboard.ContainsImage())
            {
                Image pic = Clipboard.GetImage();
                this.pictureBox1.Image = pic;

                Bitmap bitmap = (Bitmap)pic.Clone();

                bitmap.Save(Application.StartupPath + "\\numbers\\" + DateTime.Now.Ticks.ToString() + ".bmp");

                JWDecode decode = new JWDecode();
                string   result = decode.Decode(bitmap, Application.StartupPath + "\\numbers2\\");
                label1.Text = result;
            }
        }
示例#2
0
        int pWidth          = 3;         //笔记宽度

        public string Decode(Bitmap bitmap)
        {
            JWDecode jwdc = new JWDecode();

            bitmap = jwdc.ChangeToBinary(bitmap);
            bitmap = jwdc.RemoveNoise(bitmap);

            List <Bitmap> bitmapList = jwdc.CutBitmap(bitmap);
            List <Bitmap> newList    = jwdc.SaveCharacter(ref bitmapList);

            //算出笔迹的平均宽度 //先默认3 ^^ 懒得求了
            pWidth = 3;

            for (int i = 0; i < newList.Count; i++)
            {
                Amplification(newList[i]);
            }

            return("");
        }