示例#1
0
文件: frmTaskForm.cs 项目: luxueqi/tb
        //private void txtage_TextChanged(object sender, EventArgs e)
        //{
        //    double res = 0;
        //    if (!double.TryParse(txtage.Text.Trim(), out res))
        //    {

        //        txtage.Text = "1";
        //    }
        //}

        //private void button10_Click(object sender, EventArgs e)
        //{


        //}



        //private void ckimg_CheckedChanged(object sender, EventArgs e)
        //{

        //}

        private void button10_Click(object sender, EventArgs e)
        {
            if (Directory.Exists(pzpath + "img"))
            {
                string[] paths = Directory.GetFiles(pzpath + "img");
                imghash  ih;
                string   strhash = "";
                //btimg.Enabled = false;
                button10.Enabled = false;
                for (int i = 0; i < paths.Length; i++)
                {
                    ih = new imghash(paths[i], ckdct.Checked);
                    string name = Path.GetFileName(paths[i]);
                    strhash += name + ":" + ih.GetHash() + "\r\n";
                }

                File.WriteAllText(pzpath + "hash.txt", strhash);
                //btimg.Enabled = true;
                button10.Enabled = true;

                MessageBox.Show("更新完成!");
            }
            else
            {
                MessageBox.Show("img文件夹不存在!");

                ckimg.Checked = false;
            }
        }
示例#2
0
文件: Task.cs 项目: luxueqi/tb
        private bool hashmethod(string content, out int dd, out string imgname)
        {
            dd = 100;

            imgname = "";
            string urlhash = "";
            Regex  rg      = new Regex(@"http://tiebapic\.baidu\.com/forum/.*?\.jpg");

            if (rg.IsMatch(content))
            {
                string urlimg = rg.Match(content).Value;

                imghash ihash = new imghash(urlimg, mode.isimgdct);

                urlhash = ihash.GetHash();
            }
            //if (mode.ishimg)
            //{
            // hhash= new imghash(himg, mode.isimgdct).GetHash();
            //}

            for (int h = 0; h < mode.localimghash.Length; h++)
            {
                string[] result = mode.localimghash[h].Split(':');

                if (urlhash != "")
                {
                    dd = imghash.CalcSimilarDegree(urlhash, result[1]);

                    if (dd <= mode.hashdistance)
                    {
                        imgname = result[0];
                        return(true);
                    }
                }

                /* if (mode.ishimg)
                 * {
                 *   dd = imghash.CalcSimilarDegree(hhash, result[1]);
                 *
                 *   if (dd <= mode.hashdistance)
                 *   {
                 *       imgname = result[0];
                 *       return true;
                 *
                 *   }
                 * }*/
            }



            return(false);
        }
示例#3
0
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                button1.Enabled = false;
                string path1 = textBox1.Text.Trim();

                string path2 = textBox2.Text.Trim();

                if (path1 == "" || path2 == "")
                {
                    return;
                }
                //string hash1 ,hash2;
                //if (checkBox1.Checked)
                //{
                string hash1 = new imghash(path1, checkBox1.Checked).GetHash();
                string hash2 = new imghash(path2, checkBox1.Checked).GetHash();
                //}
                //else
                //{
                //    hash1 = new imghash(path1).GetHash();
                //    hash2 = new imghash(path2).GetHash();
                //}


                int dd = imghash.CalcSimilarDegree(hash1, hash2);

                label3.Text = "result:" + dd.ToString();
            }
            catch (Exception ee)
            {
                label3.Text = ee.Message;
            }

            button1.Enabled = true;
        }