登录 注册
当前位置:主页 > 资源下载 > 50 > GDI用于绘制实时频谱图表

GDI用于绘制实时频谱图表

  • 更新:2024-09-04 16:45:02
  • 大小:84KB
  • 推荐:★★★★★
  • 来源:网友上传分享
  • 类别:C++ - 后端
  • 格式:RAR

资源介绍

GDI+绘制实时频谱图形 高效!! 支持多频段频谱,图形缩放,选择频点,标注信息等等功能! if(m_nReadLines <= 0) return; int nDrawLines = m_nFreqEnd - m_nFreqFrom + 1; //频点总数 double fSpace = m_nClientWidth/(nDrawLines+1.0f) ; //两点间距,确保单点绘制在矩形中间 REAL nPenWidth = 1; if(fSpace > 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 myFont(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); } } }