Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            Dictionary <char, double> map        = new Dictionary <char, double>();
            Dictionary <char, string> dictionary = new Dictionary <char, string>();
            WorkWithCollections       useDict    = new WorkWithCollections(textPath);

            // Highlight original symbols.
            useDict.DistinctSymbols(ref map);

            // Init tree with map.
            Tree tree = new Tree(map);

            // Init dictionary with tree.
            tree.InitDictionary(dictionary);
            useDict.DictionaryView(dictionary);
            Console.WriteLine();

            // Encode text with dictionary.
            string encodedString = useDict.CodingText(dictionary);

            // Encode dictionary && encoded string to file.
            Coding drBits = new Coding(encodedFile);

            drBits.Encode(dictionary, encodedString);

            // Decode encodedFile to resultado file
            Decoding decoding = new Decoding(resultadoNormal);

            Console.WriteLine(decoding.Decode(encodedFile).Length);

            Console.WriteLine("Average code length: " + useDict.AverageCodeLen(map, dictionary));
            Console.WriteLine("Entropy: " + useDict.Entropy(map));
        }
Ejemplo n.º 2
0
        private void button3_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");

                Decoding decode = new Decoding();
                string   result = decode.Decode(bitmap);
                label1.Text = result;
            }
        }
Ejemplo n.º 3
0
    public static void testing_decode(String r, String expected)
    {
        String actual = Decoding.Decode(r);

        Assert.AreEqual(expected, actual);
    }