错在哪?
程序代码:
int a, b, c; Graphics g; Color c2 = new Color(); Color c3 = new Color(); Color c4 = new Color(); Color c5 = new Color(); private void picturebox1_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e) { Point mouseDownLocation = new Point(e.X, e.Y); Bitmap box1 = new Bitmap(pictureBox1.Image); int a, b, c; a = mouseDownLocation.X; b = mouseDownLocation.Y; c = pictureBox1.Image.Height; Color c1 = Color.FromArgb(0, 0, 0); for (int i = b; i < c; i++) { if (box1.GetPixel(a, i) == c1) { return;//找到相应点,返回相应坐标 b = i; } } return;//找不到相应点,返回0,0 c2 = box1.GetPixel(a, b - 1); c3 = box1.GetPixel(a, b); c4 = box1.GetPixel(a, b + 1); c5 = box1.GetPixel(a, b + 2); } private void button1_Click(object sender, EventArgs e) { int gray2, gray3, gray4, gray5; gray2 = (c2.R + c2.G + c2.B) / 3; gray3 = (c3.R + c3.G + c3.B) / 3; gray4 = (c4.R + c4.G + c4.B) / 3; gray5 = (c5.R + c5.G + c5.B) / 3; Pen p = new Pen(Color.Black, 1); Point pt1 = new Point(b - 1, gray2); Point pt2 = new Point(b, gray3); Point pt3 = new Point(b + 1, gray4); Point pt4 = new Point(b + 2, gray5); g.DrawBezier(p, pt1, pt2, pt3, pt4); }运行时老是出错,谁能帮帮我查查错在哪?
寻找点.rar
(33.95 KB)