gusucode.com > VC 实现的二维小波变换用于图像去噪、压缩等源码程序 > QuantizationDlg.cpp

    // QuantizationDlg.cpp : implementation file
//

#include "stdafx.h"
#include "小波变换.h"
#include "QuantizationDlg.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CQuantizationDlg dialog


CQuantizationDlg::CQuantizationDlg(CWnd* pParent /*=NULL*/)
	: CDialog(CQuantizationDlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(CQuantizationDlg)
	m_quantization = 0;
	m_coifmax = _T("");
	m_coifmin = _T("");
	//}}AFX_DATA_INIT
}


void CQuantizationDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CQuantizationDlg)
	DDX_Text(pDX, IDC_QUANTIZATION, m_quantization);
	DDX_Text(pDX, IDC_COIFMAX, m_coifmax);
	DDX_Text(pDX, IDC_COIFMIN, m_coifmin);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CQuantizationDlg, CDialog)
	//{{AFX_MSG_MAP(CQuantizationDlg)
	ON_WM_PAINT()
	ON_WM_MOUSEMOVE()
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CQuantizationDlg message handlers

BOOL CQuantizationDlg::OnInitDialog() 
{
	CDialog::OnInitDialog();
	
	// TODO: Add extra initialization here
	GetDlgItem(IDC_HISGRAPH)->GetWindowRect(&m_precthis);
	ScreenToClient(&m_precthis);
	
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}

void CQuantizationDlg::OnPaint()
{
	CPaintDC dc(this); // device context for painting
	
	// TODO: Add your message handler code here
	for(int i=0;i<256;i++)
	{
		dc.MoveTo(m_precthis.left+i,m_precthis.bottom);
		dc.LineTo(m_precthis.left+i,LONG(m_precthis.bottom-m_level[i]/m_levelmax*(m_precthis.bottom-m_precthis.top)));
	}	
	// Do not call CDialog::OnPaint() for painting messages
}

void CQuantizationDlg::OnMouseMove(UINT nFlags, CPoint point) 
{
	// TODO: Add your message handler code here and/or call default
	double x;
	if(m_precthis.PtInRect(point))
	{
		x=(m_graymax-m_graymin)/255*(point.x-m_precthis.left)+m_graymin;
		m_quantization=int(x);
		UpdateData(FALSE);
	}
	
	CDialog::OnMouseMove(nFlags, point);
}