1. 首页
  2. 编程语言
  3. C++ 
  4. GDI绘制实时频谱图形

GDI绘制实时频谱图形

上传者: 2018-12-25 22:41:08上传 RAR文件 84.15KB 热度 56次
GDI+绘制实时频谱图形 高效!! 支持多频段频谱,图形缩放,选择频点,标注信息等等功能! if(m_nReadLines 10) { nPenWidth *= (REAL)(fSpace/10 + 0.5); } double fOffsetBegin = m_borderRect.left + 1 + fSpace; int x ,y; double fScale = (double)(nDrawLines / m_nClientWidth); //频率点跳越间隔 if(fScale < 1.0) fScale = 1.0; double fVerScale = (double)m_nClientHeight/MAX_RANGE; Font myF ont(L"宋体", 8); StringFormat format; format.SetAlignment(StringAlignmentNear); CStringW strLocalInfo; BOOL blocalMove = FALSE; PointF localPoint; ELevel* pKeepLineData = NULL; if(m_eLineType == FL_MIN_LINE) pKeepLineData = &m_eMinLevelData; else if(m_eLineType == FL_MAX_LINE) pKeepLineData = &m_eMaxLevelData; else if(m_eLineType == FL_AVG_LINE) pKeepLineData = &m_eAvgLevelData; for(double fLine = 0;(int)fLine < nDrawLines;fLine += fScale) { if(fLine + m_nFreqFrom > m_nMaxLines) break; y = m_eLevelData[fLine + m_nFreqFrom]; if(y) { x = (int)(fLine * fSpace + fOffsetBegin); y *= fVerScale; g->DrawLine(&Pen(Color::DarkGreen,(REAL)nPenWidth),PointF((REAL)x,(REAL)m_borderRect.bottom),PointF((REAL)x,(REAL)(m_borderRect.bottom-y))); } if(pKeepLineData) { y = pKeepLineData->at(fLine + m_nFreqFrom); y *= fVerScale; y = m_borderRect.bottom-y; if(!blocalMove) { localPoint = PointF(x,y); blocalMove = TRUE ; } else { g->DrawLine(&Pen(Color::Red),localPoint,PointF(x,y)); localPoint = PointF(x,y); } } } ont(L"宋体", 8); StringFormat format; format.SetAlignment(StringAlignmentNear); CStringW strLocalInfo; BOOL blocalMove = FALSE; PointF localPoint; ELevel* pKeepLineData = NULL; if(m_eLineType == FL_MIN_LINE) pKeepLineData = &m_eMinLevelData; else if(m_eLineType == FL_MAX_LINE) pKeepLineData = &m_eMaxLevelData; else if(m_eLineType == FL_AVG_LINE) pKeepLineData = &m_eAvgLevelData; for(double fLine = 0;(int)fLine < nDrawLines;fLine += fScale) { if(fLine + m_nFreqFrom > m_nMaxLines) break; y = m_eLevelData[fLine + m_nFreqFrom]; if(y) { x = (int)(fLine * fSpace + fOffsetBegin); y *= fVerScale; g->DrawLine(&Pen(Color::DarkGreen,(REAL)nPenWidth),PointF((REAL)x,(REAL)m_borderRect.bottom),PointF((REAL)x,(REAL)(m_borderRect.bottom-y))); } if(pKeepLineData) { y = pKeepLineData->at(fLine + m_nFreqFrom); y *= fVerScale; y = m_borderRect.bottom-y; if(!blocalMove) { localPoint = PointF(x,y); blocalMove = TRUE ; } else { g->DrawLine(&Pen(Color::Red),localPoint,PointF(x,y)); localPoint = PointF(x,y); } } }
下载地址
用户评论
码姐姐匿名网友 2018-12-25 22:41:08

可以借鉴学习,还不完善。

码姐姐匿名网友 2018-12-25 22:41:08

不通俗,看不懂

码姐姐匿名网友 2018-12-25 22:41:08

对于画大量的采集样点的频谱,还不够实时吧,还没有改程序,不知道到时候画图会不会还是慢