LPRDlg.cpp
资源名称:LPR.rar [点击查看]
上传用户:jjiangjuan
上传日期:2013-03-27
资源大小:59k
文件大小:5k
源码类别:
波变换
开发平台:
Visual C++
- // LPRDlg.cpp : implementation file
- //
- #include "stdafx.h"
- #include "LPR.h"
- #include "LPRDlg.h"
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- /////////////////////////////////////////////////////////////////////////////
- // CAboutDlg dialog used for App About
- class CAboutDlg : public CDialog
- {
- public:
- CAboutDlg();
- // Dialog Data
- //{{AFX_DATA(CAboutDlg)
- enum { IDD = IDD_ABOUTBOX };
- //}}AFX_DATA
- // ClassWizard generated virtual function overrides
- //{{AFX_VIRTUAL(CAboutDlg)
- protected:
- virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
- //}}AFX_VIRTUAL
- // Implementation
- protected:
- //{{AFX_MSG(CAboutDlg)
- //}}AFX_MSG
- DECLARE_MESSAGE_MAP()
- };
- CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
- {
- //{{AFX_DATA_INIT(CAboutDlg)
- //}}AFX_DATA_INIT
- }
- void CAboutDlg::DoDataExchange(CDataExchange* pDX)
- {
- CDialog::DoDataExchange(pDX);
- //{{AFX_DATA_MAP(CAboutDlg)
- //}}AFX_DATA_MAP
- }
- BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
- //{{AFX_MSG_MAP(CAboutDlg)
- // No message handlers
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
- /////////////////////////////////////////////////////////////////////////////
- // CLPRDlg dialog
- CLPRDlg::CLPRDlg(CWnd* pParent /*=NULL*/)
- : CDialog(CLPRDlg::IDD, pParent)
- {
- //{{AFX_DATA_INIT(CLPRDlg)
- // NOTE: the ClassWizard will add member initialization here
- //}}AFX_DATA_INIT
- // Note that LoadIcon does not require a subsequent DestroyIcon in Win32
- m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
- }
- void CLPRDlg::DoDataExchange(CDataExchange* pDX)
- {
- CDialog::DoDataExchange(pDX);
- //{{AFX_DATA_MAP(CLPRDlg)
- DDX_Control(pDX, IDC_LP, m_LP);
- DDX_Control(pDX, IDC_DISPLAY, m_image);
- //}}AFX_DATA_MAP
- }
- BEGIN_MESSAGE_MAP(CLPRDlg, CDialog)
- //{{AFX_MSG_MAP(CLPRDlg)
- ON_WM_SYSCOMMAND()
- ON_WM_PAINT()
- ON_WM_QUERYDRAGICON()
- ON_BN_CLICKED(IDC_EXIT, OnExit)
- ON_BN_CLICKED(IDC_OPEN, OnOpen)
- ON_BN_CLICKED(IDC_GRAY, OnGray)
- ON_BN_CLICKED(IDC_GRAY_ADJUST, OnGrayAdjust)
- ON_BN_CLICKED(IDC_EDGE, OnEdge)
- ON_BN_CLICKED(IDC_CUT, OnCut)
- ON_BN_CLICKED(IDC_BINARY, OnBinary)
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
- /////////////////////////////////////////////////////////////////////////////
- // CLPRDlg message handlers
- BOOL CLPRDlg::OnInitDialog()
- {
- CDialog::OnInitDialog();
- // Set the icon for this dialog. The framework does this automatically
- // when the application's main window is not a dialog
- SetIcon(m_hIcon, TRUE); // Set big icon
- SetIcon(m_hIcon, FALSE); // Set small icon
- // TODO: Add extra initialization here
- m_histo.hWnd=this;
- memset(GraylvCount,0,sizeof(GraylvCount));
- memset(LPArea,0,sizeof(LPArea));
- return TRUE; // return TRUE unless you set the focus to a control
- }
- void CLPRDlg::OnSysCommand(UINT nID, LPARAM lParam)
- {
- if ((nID & 0xFFF0) == IDM_ABOUTBOX)
- {
- CAboutDlg dlgAbout;
- dlgAbout.DoModal();
- }
- else
- {
- CDialog::OnSysCommand(nID, lParam);
- }
- }
- // If you add a minimize button to your dialog, you will need the code below
- // to draw the icon. For MFC applications using the document/view model,
- // this is automatically done for you by the framework.
- void CLPRDlg::OnPaint()
- {
- 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
- {
- CDialog::OnPaint();
- }
- m_histo.Draw(lpData,GraylvCount);//对直方图进行重绘
- }
- // The system calls this to obtain the cursor to display while the user drags
- // the minimized window.
- HCURSOR CLPRDlg::OnQueryDragIcon()
- {
- return (HCURSOR) m_hIcon;
- }
- void CLPRDlg::OnExit()
- {
- // TODO: Add your control notification handler code here
- exit(0);
- }
- //打开bmp文件
- void CLPRDlg::OnOpen()
- {
- // TODO: Add your control notification handler code here
- m_image.LoadBmp();
- }
- //转灰度图
- void CLPRDlg::OnGray()
- {
- // TODO: Add your control notification handler code here
- m_image.gray(lpData);
- m_histo.first = true;
- m_histo.Draw(lpData,GraylvCount);
- }
- void CLPRDlg::OnGrayAdjust()
- {
- // TODO: Add your control notification handler code here
- m_image.InteEqualize(lpData,GraylvCount);
- m_histo.Draw(lpData,GraylvCount);
- Invalidate(FALSE);
- }
- void CLPRDlg::OnEdge()
- {
- // TODO: Add your control notification handler code here
- m_image.GetEdge();
- Invalidate(FALSE);
- }
- void CLPRDlg::OnCut()
- {
- // TODO: Add your control notification handler code here
- m_image.DelNoise();
- P=m_image.GetLPPos();
- memset(LPArea,0,sizeof(LPArea));
- if(P!=NULL)
- {
- BITMAPINFO DIBINFO=m_image.WriteDibFile(P->y0-P->y1+1,P->x1-P->x0+1,LPArea);
- m_LP.DIB=DIBINFO;
- for(int i=0;i<30000;i++)
- {
- m_LP.LPArea[i]=LPArea[i];
- }
- Invalidate(TRUE);
- }
- }
- void CLPRDlg::OnBinary()
- {
- // TODO: Add your control notification handler code here
- m_image.Binary(m_LP.DIB,LPArea);
- for(int i=0;i<30000;i++)
- {
- m_LP.LPArea[i]=LPArea[i];
- }
- Invalidate(TRUE);
- }