コード例 #1
0
ファイル: UrlThread.cs プロジェクト: gover520/NWebSpider
        void SearchImage()
        {
            bool   doit = true;
            Bitmap bmp;

            byte[] hash = new byte[64];
            while (doit)
            {
                lock (lockimg)
                {
                    if (Image_Top < ImageList.Count())
                    {
                        download(ImageList[Image_Top]);
                        Image_Top++;
                        try
                        {
                            bmp = new Bitmap(fullname);
                            Form1.getInstance().pictureBox2.ImageLocation = fullname;
                            if (bmp.Height >= 8 && bmp.Width >= 8)
                            {
                                bmp = new Bitmap(bmp, 8, 8);

                                if (ImageClass.MatchHash(ImageClass.ImageHash(bmp), ImageClass.SrcHash) > ImageClass.MatchMax)
                                {
                                    ImageClass.MatchMax++;
                                    Form1.getInstance().pictureBox3.ImageLocation = fullname;
                                    Form1.getInstance().textBox2.Text = ImageClass.MatchMax.ToString();
                                }
                            }
                        }
                        catch (Exception)
                        {
                        }
                    }
                    else
                    {
                        doit = false;
                    }
                }
                if (!doit)
                {
                    Thread.Sleep(10);
                    doit = true;
                }
                Thread.Sleep(1);
            }
        }
コード例 #2
0
        //byte[] srcHash = new byte[64];
        private void button3_Click(object sender, EventArgs e)
        {
            OpenFileDialog ofd = new OpenFileDialog();

            try
            {
                if (ofd.ShowDialog() == DialogResult.OK)
                {
                    bmp = new Bitmap(ofd.FileName);
                    pictureBox1.Image = bmp;
                    bmp = new Bitmap(bmp, 8, 8);
                    ImageClass.SrcHash = ImageClass.ImageHash(bmp);
                }
            }
            catch (Exception)
            {
                MessageBox.Show("图片不符合要求!");
            }
        }