文件名称:GDI绘制实时频谱图形
文件大小:84KB
文件格式:RAR
更新时间:2014-05-10 05:16:55
GDI 实时 频谱图形
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); } } }
【文件预览】:
Histograms
----Histogram.suo(143KB)
----Histogram()
--------Histogram.rc(10KB)
--------resource.h(1KB)
--------stdafx.h(2KB)
--------HistogramDoc.cpp(1KB)
--------targetver.h(1KB)
--------HistogramView.cpp(10KB)
--------MainFrm.h(788B)
--------HistogramView.h(2KB)
--------Histogram.h(507B)
--------Histogram.aps(66KB)
--------Histogram.vcproj(6KB)
--------stdafx.cpp(140B)
--------ReadMe.txt(3KB)
--------MainFrm.cpp(2KB)
--------Histogram.cpp(3KB)
--------GdiDraw.cpp(19KB)
--------GdiDraw.h(7KB)
--------res()
--------HistogramDoc.h(564B)
----Histogram.sln(893B)