是這樣的,我現在遇到的問題是我的滑鼠在畫面上按下滑鼠左鍵會新增一個紅色的圈圈,然後在那個座標上取得RGB的值,但問題來了如果我要新增5個不同的點,在不同的位置上分別取出RGB的值,那要怎麼做?瓶頸卡住了…實在想不出來
原因是每當我按下滑鼠時上一秒的值就會更新,求大神能幫幫我。
附圖:
private void fitureBox_MouseClick(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
{
Graphics g = Graphics.FromImage(bmp);
System.Drawing.Point point = new Point(e.X- IMAGE_WIDTH/2, e.Y-IMAGE_WIDTH/2);
g.DrawString("○", new Font("Arial", 20), new SolidBrush(Color.Red), point);
Color pixelcolor = bmp.GetPixel(e.X,e.Y);
byte R = pixelcolor.R, G = pixelcolor.G, B = pixelcolor.G;
/*
textBox1.Text = Convert.ToString(R);
textBox2.Text = Convert.ToString(G);
textBox3.Text = Convert.ToString(B);
*/
//char = "A";
int number = 0;
dataGridView1.Rows.Add(new Object[] { number++, Convert.ToString(R), Convert.ToString(G), Convert.ToString(B) });
if (R > 100 || G > 100 || B > 100)
{
pictureBox1.Image = Properties.Resources.FAIL1;
}
else
{
pictureBox1.Image = Properties.Resources.PASS1;
}
g.Dispose();
fitureBox.Image = bmp;
}
}