private void pictureBox5_Click(object sender, EventArgs e) { //Bitmap btm = (Bitmap)大图.Clone(); Bitmap btm = GalaxyHelper.Capture.PrintWindow(intptr_GBF); btm = GalaxyHelper.Capture.ConvertTo24bpp(btm); Stopwatch sw = new Stopwatch(); sw.Start(); //计时开始 //List<Point> list = BmpColor.FindPic(0, 0, btm.Width, btm.Height, btm, img_test, 40); List <Point> list = BmpColor.FindPic(0, 0, btm.Width, btm.Height, btm, img_test, trackBar1.Value); sw.Stop(); //计时结束 label4.Text = sw.ElapsedMilliseconds + "毫秒"; label2.Text = list.Count.ToString(); if (list.Count > 0) { listView1.Items.Clear(); Graphics g = Graphics.FromImage(btm); for (int i = 0; i < list.Count; i++) { listView1.Items.Insert(listView1.Items.Count, new ListViewItem(new string[] { i.ToString(), list[i].X.ToString(), list[i].Y.ToString() })); g.DrawRectangle(new Pen(Color.Red, 3), list[i].X, list[i].Y, img_test.Width, img_test.Height); } } pictureBox1.Image = btm; }
//相似度 private void pictureBox4_Click(object sender, EventArgs e) { Bitmap btm = (Bitmap)大图.Clone(); Stopwatch sw = new Stopwatch(); sw.Start(); //计时开始 List <Point> list = BmpColor.FindPic(0, 0, 大图.Width, 大图.Height, 大图, 相似度, 40); sw.Stop(); //计时结束 label4.Text = sw.ElapsedMilliseconds + "毫秒"; label2.Text = list.Count.ToString(); if (list.Count > 0) { listView1.Items.Clear(); Graphics g = Graphics.FromImage(btm); for (int i = 0; i < list.Count; i++) { listView1.Items.Insert(listView1.Items.Count, new ListViewItem(new string[] { i.ToString(), list[i].X.ToString(), list[i].Y.ToString() })); g.DrawRectangle(new Pen(Color.Red, 2), list[i].X, list[i].Y, 相似度.Width, 相似度.Height); } } pictureBox1.Image = btm; }
private void timer1_Tick(object sender, EventArgs e) { Stopwatch sw = new Stopwatch(); sw.Start(); //计时开始 Bitmap btm = BmpColor.CopyScreen(100, 100, Cursor.Position.X - 100 / 2, Cursor.Position.Y - 100 / 2); List <Point> list = BmpColor.FindColor(0, 0, btm.Width, btm.Height, btm, Color.FromArgb(80, 180, 216), 0); sw.Stop(); //计时结束 label4.Text = sw.ElapsedMilliseconds + "毫秒"; label2.Text = list.Count.ToString(); listView1.Items.Clear(); if (list.Count > 0) { //创建 GraphicsPath GraphicsPath graphicsPath = new GraphicsPath(); Graphics g = Graphics.FromImage(btm); for (int i = 0; i < list.Count; i++) { listView1.Items.Insert(listView1.Items.Count, new ListViewItem(new string[] { i.ToString(), list[i].X.ToString(), list[i].Y.ToString() })); //将不透明点加到graphics path graphicsPath.AddRectangle(new Rectangle(list[i].X, list[i].Y, 1, 1)); //g.DrawRectangle(new Pen(Color.Red, 1), list[i].X, list[i].Y, 2,2); } g.DrawPath(new Pen(Color.Red, 1), graphicsPath); } pictureBox1.Image = btm; }