视频检测结果 逐个获取了xy坐标后
或者说 有一串 xy 值
怎么能用mfc画出一个函数曲线 在什么控件里绘图啊?
网上找到一些程序 不知道怎么导入到自己的项目中
求助O(∩_∩)O~
或者说 有一串 xy 值
怎么能用mfc画出一个函数曲线 在什么控件里绘图啊?
网上找到一些程序 不知道怎么导入到自己的项目中
求助O(∩_∩)O~
解决方案 »
- 窗口移动后,调用GetWindowRect()的问题。
- 主窗口添加WS_CLIPCHILDREN属性后程序运行没有显示
- 怎么才能打开一个二进制文件?
- 编译时找不到cl.exe是什么原因?
- 小型搜索引擎源码出售(包括蜘蛛、切词器、索引器及基于ISAPI的查询器)
- 请教将CString类型转换成UINT类型的函数是什么?
- 我的对话框里放了一个进度条控件,怎么来控制?
- 加一项专家分显示如何?这样回答问题也有动力呀!
- socket proxy问题?
- MFC应用程序关于异常处理
- 在单文档视图上实时显示鼠标的坐标值,并且视图不闪?如何实现?
- 求救啊!在COutlookBar中,AddControl加入对话框资源的类变量出问题
wnd->MoveTo(2, 3);
wnd->LineTo(4, 8);这是画直线的,由一堆的XY值连成曲线。
如果要计处曲线,自己写计算方法。
CDC类有一些曲线计算方法,可以细看一下MSDN
{
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);
}
}
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]);
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);
http://blog.csdn.net/xianglitian/archive/2010/12/27/6100767.aspx