📄 histogramdialog.cpp
字号:
// HistogramDialog.cpp : implementation file
//
#include "stdafx.h"
#include "Test.h"
#include "HistogramDialog.h"
#include "dib.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CHistogramDialog dialog
CHistogramDialog::CHistogramDialog(CDib* pDib, CWnd* pParent /*=NULL*/)
: CDialog(CHistogramDialog::IDD, pParent)
{
//{{AFX_DATA_INIT(CHistogramDialog)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
m_pHistogram = pDib->m_naHistogram;
m_nMaxCount = pDib->m_nMaxCount;
}
void CHistogramDialog::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CHistogramDialog)
// NOTE: the ClassWizard will add DDX and DDV calls here
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CHistogramDialog, CDialog)
//{{AFX_MSG_MAP(CHistogramDialog)
ON_WM_PAINT()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CHistogramDialog message handlers
void CHistogramDialog::OnPaint()
{
CPaintDC dc(this); // device context for painting
CRect rect;
CWnd* pWnd;
int i, j;
pWnd = GetDlgItem( IDC_HISTOGRAM );
pWnd->GetWindowRect( &rect );
ScreenToClient( &rect );
pWnd->Invalidate();
pWnd->UpdateWindow();
dc.Rectangle( &rect );
rect.DeflateRect( 1, 1 );
for( i=0; i<256; i++ )
{
dc.MoveTo( rect.left + i, rect.bottom );
dc.LineTo( rect.left + i, rect.bottom-(rect.bottom-rect.top)*m_pHistogram[i]/m_nMaxCount );
}
pWnd = GetDlgItem( IDC_GRAYLEVEL );
pWnd->GetWindowRect( &rect );
ScreenToClient( &rect );
pWnd->Invalidate();
pWnd->UpdateWindow();
dc.Rectangle( &rect );
rect.DeflateRect( 1, 1 );
for( i=0; i<256; i++ )
for( j=rect.top; j<rect.bottom; j++ )
{
dc.SetPixel( rect.left+i, j, RGB(i,i,i) );
}
// Do not call CDialog::OnPaint() for painting messages
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -