📄 colortunning.cpp
字号:
// ColorTunning.cpp : implementation file
//
#include "stdafx.h"
#include "Vision.h"
#include "VisionView.h"
#include "ColorTunning.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
int m_Hue_orginal ,m_Contrast_orginal ,m_Saturation_orginal,m_Brightness_orginal;
/////////////////////////////////////////////////////////////////////////////
// CColorTunning dialog
CColorTunning::CColorTunning(CWnd* pParent /*=NULL*/)
: CDialog(CColorTunning::IDD, pParent)
{
//{{AFX_DATA_INIT(CColorTunning)
m_nHue = 0;
m_nSaturation = 0;
m_nContrast = 0;
m_nBrightness = 0;
//}}AFX_DATA_INIT
}
void CColorTunning::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CColorTunning)
DDX_Control(pDX, IDC_HUE_SCROLLBAR, m_sHue);
DDX_Control(pDX, IDC_SATURATION_SCROLLBAR, m_sSaturation);
DDX_Control(pDX, IDC_CONTRAST_SCROLLBAR, m_sContrast);
DDX_Control(pDX, IDC_BRIGHT_SCROLLBAR, m_sBrightness);
DDX_Text(pDX, IDC_EDIT1, m_nHue);
DDX_Text(pDX, IDC_EDIT2, m_nSaturation);
DDX_Text(pDX, IDC_EDIT3, m_nContrast);
DDX_Text(pDX, IDC_EDIT4, m_nBrightness);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CColorTunning, CDialog)
//{{AFX_MSG_MAP(CColorTunning)
ON_BN_CLICKED(IDC_BUTTON1, OnButton1)
ON_WM_HSCROLL()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CColorTunning message handlers
void CColorTunning::OnButton1()
{
m_nHue = 128;
m_nSaturation = 200;
m_nContrast = 100;
m_nBrightness = 100;
MdigReference(MilDigitizerId, M_HUE_REF, m_nHue);
MdigReference(MilDigitizerId, M_SATURATION_REF, m_nSaturation);
MdigReference(MilDigitizerId, M_CONTRAST_REF, m_nContrast);
MdigReference(MilDigitizerId, M_BRIGHTNESS_REF, m_nBrightness);
UpdateData(FALSE);
//OnOK();
}
BOOL CColorTunning::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
m_sHue.SetScrollRange(0,255);
m_sContrast.SetScrollRange(0,255);
m_sSaturation.SetScrollRange(0,255);
m_sBrightness.SetScrollRange(0,255);
m_sHue.SetScrollPos(m_nHue);
m_sContrast.SetScrollPos(m_nContrast);
m_sSaturation.SetScrollPos(m_nSaturation);
m_sBrightness.SetScrollPos(m_nBrightness);
MilDigitizerId = ((CVisionApp*)AfxGetApp())->MilDigitizer;
m_Hue_orginal = m_nHue;
m_Contrast_orginal = m_nContrast;
m_Saturation_orginal = m_nSaturation;
m_Brightness_orginal = m_nBrightness;
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CColorTunning::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
{
// TODO: Add your message handler code here and/or call default
// CVisionView view;
int pos,nID,index;
nID = GetWindowLong(pScrollBar->m_hWnd, GWL_ID);
index =nID-IDC_HUE_SCROLLBAR;
pos = pScrollBar->GetScrollPos();
switch(nSBCode){
case SB_LEFT :
pos = 0;
break;
case SB_RIGHT :
pos = 255;
break;
case SB_LINELEFT:
pos=pos-1;
break;
case SB_LINERIGHT:
pos=pos+1;
break;
case SB_PAGELEFT:
pos = pos-5;
break;
case SB_PAGERIGHT:
pos = pos +5;
break;
case SB_THUMBPOSITION:
pos = nPos;
break;
case SB_THUMBTRACK:
break;
}
if (pos < 0 ) pos = 0;
if (pos >255) pos = 255;
pScrollBar->SetScrollPos(pos);
switch(index){
case 0 :
m_nHue = pos;
break;
case 1 :
m_nSaturation = pos;
break;
case 2 :
m_nContrast = pos;
break;
case 3 :
m_nBrightness = pos;
}
MdigReference(MilDigitizerId, M_HUE_REF, m_nHue);
MdigReference(MilDigitizerId, M_SATURATION_REF, m_nSaturation);
MdigReference(MilDigitizerId, M_CONTRAST_REF, m_nContrast);
MdigReference(MilDigitizerId, M_BRIGHTNESS_REF, m_nBrightness);
// view->OnChangeHue();
UpdateData(FALSE);
CDialog::OnHScroll(nSBCode, nPos, pScrollBar);
}
void CColorTunning::OnOK()
{
// TODO: Add extra validation here
CDialog::OnOK();
}
void CColorTunning::OnCancel()
{
// TODO: Add extra cleanup here
m_nHue = m_Hue_orginal;
m_nContrast = m_Contrast_orginal;
m_nSaturation = m_Saturation_orginal;
m_nBrightness = m_Brightness_orginal ;
MdigReference(MilDigitizerId, M_HUE_REF, m_nHue);
MdigReference(MilDigitizerId, M_SATURATION_REF, m_nSaturation);
MdigReference(MilDigitizerId, M_CONTRAST_REF, m_nContrast);
MdigReference(MilDigitizerId, M_BRIGHTNESS_REF, m_nBrightness);
CDialog::OnCancel();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -