各位大侠:
   你们好!我通过打开图片在pictureBox打开了一张图片,想在这张图片上画圆,也就是把圆形目标区域标注出来,怎么写啊?万分感谢各位回复~

解决方案 »

  1.   

    public Form1()
    {
        InitializeComponent();
        pictureBox1.Paint+=new PaintEventHandler(pictureBox1_Paint);
    }
    private void pictureBox1_Paint(object sender, PaintEventArgs e)
    {
        Graphics a = e.Graphics;
        a.DrawEllipse(new Pen(Color.Red, 5), 100, 50, 100, 100);
    }
      

  2.   

    用Graphics先获取图片的设备,然后Graphics.DrawEllipse在图片上画圆,由于pictureBox加载了那个图片,自然也能看到那个圆。
      

  3.   

    #1楼中的画圆不好,那个不是在图片上画,而只是在pictureBox控件上画,刷新控件就会消失的。
      

  4.   

    Graphics g=Graphics.FromImage(图片的image对象);
    然后画
      

  5.   

    Graphics g=Graphics.FromImage(图片的image对象);
      

  6.   

     private void colorSustract_Click(object sender, EventArgs e)
     {
      MWCharArray FileName = imagePath;
      MWArray max=test.appleDetection((MWArray)FileName);
      double[,] feature = (double[,])((MWNumericArray)max).ToArray(MWArrayComponent.Real);
               
     //获取目标属性矩阵feature的行、列数
        int featureRow = feature.GetLength(0);
        int featureColumn = feature.GetLength(1);
               
        //用feature的值在pictureBox1的图片上画圆
       Bitmap bmp = new Bitmap(pictureBox1.Image, pictureBox1.Width, pictureBox1.Height);
       Graphics g = Graphics.FromImage(bmp);
        for (int i=0;i<featureColumn;i++)
      {
       g.DrawEllipse(new Pen(Color.Red, 10),(int) feature[0, i], (int)feature[1, i], (int )feature[2, i], (int)feature[2, i]);
        }以上是我的完整代码,我试了下,怎么画不上去啊??希望各位再次分享经验!
      

  7.   

    因为你新建了一个图片,而不是在原有的图片上画画。
    你为啥不直接Graphics g = Graphics.FromImage(pictureBox1.Image);
      

  8.   

    private void colorSustract_Click(object sender, EventArgs e)
     {
      MWCharArray FileName = imagePath;
      MWArray max=test.appleDetection((MWArray)FileName);
      double[,] feature = (double[,])((MWNumericArray)max).ToArray(MWArrayComponent.Real);
        
     //获取目标属性矩阵feature的行、列数
      int featureRow = feature.GetLength(0);
      int featureColumn = feature.GetLength(1);
        
      //用feature的值在pictureBox1的图片上画圆
      Bitmap bmp = new Bitmap(pictureBox1.Image, pictureBox1.Width, pictureBox1.Height);
      Graphics g = Graphics.FromImage(bmp);
      for (int i=0;i<featureColumn;i++)
      {
      g.DrawEllipse(new Pen(Color.Red, 10),(int) feature[0, i], (int)feature[1, i], (int )feature[2, i], (int)feature[2, i]);
      }以上是我的完整代码,我试了下,怎么画不上去啊??希望各位再次分享经验!
      

  9.   

    谢谢大家,我把上面的问题已经解决了,再次感谢大家的支持。分享一下结果:主要原因是对 g.DrawEllipse(x,y,w,h)方法参数不了解, x是指起始点横坐标,y是指起始点纵坐标,w是指长轴的长度,h是指短轴的长度,因为我画的圆,所以长短轴都是圆的直径,这样就做出来了!