视频检测结果 逐个获取了xy坐标后
或者说 有一串 xy 值
怎么能用mfc画出一个函数曲线 在什么控件里绘图啊?
网上找到一些程序 不知道怎么导入到自己的项目中
求助O(∩_∩)O~

解决方案 »

  1.   

    先把数据读取到数组中,绘制函数曲线gdi就可以了。
      

  2.   

    CDC *wnd=this->GetDC();
    wnd->MoveTo(2, 3);
    wnd->LineTo(4, 8);这是画直线的,由一堆的XY值连成曲线。
    如果要计处曲线,自己写计算方法。
    CDC类有一些曲线计算方法,可以细看一下MSDN
      

  3.   

    把楼上两位的综合起来就行了,先加载到数组中,如果在对话框上直接画,可以相应OnPaint函数然后用dc的 moveto lineto函数来画。void CProject1Dlg::OnPaint() 
    {
    if (IsIconic())
    {
    CPaintDC dc(this); // device context for painting SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0); // Center icon in client rectangle
    int cxIcon = GetSystemMetrics(SM_CXICON);
    int cyIcon = GetSystemMetrics(SM_CYICON);
    CRect rect;
    GetClientRect(&rect);
    int x = (rect.Width() - cxIcon + 1) / 2;
    int y = (rect.Height() - cyIcon + 1) / 2; // Draw the icon
    dc.DrawIcon(x, y, m_hIcon);
    }
    else
    {
                    // 这个是自己画线的部分
    CPaintDC dc(this);
    dc.MoveTo(0,0);
    dc.LineTo(5, 7);
    dc.MoveTo(5, 7);
    dc.LineTo(40, 98);
    }
    }
      

  4.   

    CPaintDC dc(this);
    dc.MoveTo(0,0);
    dc.LineTo(5, 7);
    dc.MoveTo(5, 7);
    dc.LineTo(40, 98);这个有点问题 dc.MoveTo(5,7)是多余的Point p[500];
    dc.MoveTo(p[0]);
    for(int i=1;i<500;i++)
    dc.LineTo(p[i]);
      

  5.   

    这个是GDI+里画曲线的方法:
       Graphics graphics(hdc);
       GraphicsPath path;
       
       PointF pts[] = {PointF(50.0f, 50.0f),
                      PointF(70.0f, 80.0f),
                      PointF(100.0f, 100.0f),
                      PointF(130.0f, 40.0f),
                      PointF(150.0f, 90.0f),
                      PointF(180.0f, 30.0f),
                      PointF(210.0f, 120.0f),
                      PointF(240.0f, 80.0f)};
       path.AddCurve(
          pts, 
          8,     // There are eight points in the array. 
          2,     // Start at the point with index 2.
          4,     // Four segments. End at the point with index 6.
          1.0f);
       Pen pen(Color(255, 0, 0, 255));
       graphics.DrawPath(&pen, &path);
       // Draw all eight points in the array.
       SolidBrush brush(Color(255, 255, 0, 0));
       for(INT j = 0; j <= 7; ++j)
          graphics.FillEllipse(&brush, pts[j].X - 3.0f, pts[j].Y - 3.0f, 6.0f, 6.0f); 
    当然,要想画平滑的曲线还要加上这一行graphics.SetSmoothingMode(SmoothingModeHighQuality); 
      

  6.   

    看看这个
    http://blog.csdn.net/xianglitian/archive/2010/12/27/6100767.aspx