HistoDialog.cpp
资源名称:LPR.rar [点击查看]
上传用户:jjiangjuan
上传日期:2013-03-27
资源大小:59k
文件大小:2k
源码类别:
波变换
开发平台:
Visual C++
- // HistoDialog.cpp: implementation of the CHistoDialog class.
- //
- //////////////////////////////////////////////////////////////////////
- #include "stdafx.h"
- #include "LPR.h"
- #include "HistoDialog.h"
- #ifdef _DEBUG
- #undef THIS_FILE
- static char THIS_FILE[]=__FILE__;
- #define new DEBUG_NEW
- #endif
- //////////////////////////////////////////////////////////////////////
- // Construction/Destruction
- //////////////////////////////////////////////////////////////////////
- CHistoDialog::CHistoDialog()
- {
- first = false;
- }
- CHistoDialog::~CHistoDialog()
- {
- }
- void CHistoDialog::Draw(BYTE lpBmpData[COL][ROW],int GrayLvlCount[])
- {
- int i,j;
- CString str;
- CClientDC pDC(hWnd);
- pDC.Rectangle(400,25,700,300);
- if(first == true)
- {
- for(i = 0;i < 256;i++)
- {
- GrayLvlCount[i] = 0;
- }
- for(i=0;i<=COL;i++)
- for(j=0;j<=ROW;j++)
- GrayLvlCount[lpBmpData[i][j]]++;
- // 创建画笔对象
- CPen* pPenRed = new CPen;
- // 红色画笔
- pPenRed->CreatePen(PS_SOLID,1,RGB(255,0,0));
- // 创建画笔对象
- CPen* pPenBlue = new CPen;
- // 蓝色画笔
- pPenBlue->CreatePen(PS_SOLID,1,RGB(0,0, 255));
- // 创建画笔对象
- CPen* pPenGreen = new CPen;
- // 绿色画笔
- pPenGreen->CreatePen(PS_DOT,1,RGB(0,255,0));
- // 选中当前红色画笔,并保存以前的画笔
- CGdiObject* pOldPen = pDC.SelectObject(pPenRed);
- // 绘制坐标轴
- pDC.MoveTo(originX,originY);
- pDC.LineTo(originX + 280,originY);//横坐标
- pDC.MoveTo(originX,originY);
- pDC.LineTo(originX,originY - 245);//纵坐标
- pDC.LineTo(originX - 3 , originY-245+5);
- pDC.MoveTo(originX,originY - 245);
- pDC.LineTo(originX + 3,originY - 245 + 5);//纵坐标箭头
- pDC.MoveTo(originX + 280,originY);
- pDC.LineTo(originX + 280 - 5 , originY - 3);
- pDC.MoveTo(originX + 280,originY);
- pDC.LineTo(originX + 280 - 5 ,originY + 3);//横坐标箭头
- // 更改成蓝色画笔
- pDC.SelectObject(pPenBlue);
- for(i = 0; i < 256; i++)
- {
- pDC.MoveTo(originX + i,originY);
- pDC.LineTo(originX + i,int(originY - 15*245*double(GrayLvlCount[i])/double(COL*ROW)));
- }
- pDC.SelectObject(pOldPen);
- }
- }