//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; } }
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); }