GrayDlg.cpp
上传用户:hstieta88
上传日期:2007-01-14
资源大小:106k
文件大小:2k
源码类别:

图形图像处理

开发平台:

Visual C++

  1. // GrayDlg.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "Dib.h"
  5. #include "ColorProcess.h"
  6. #include "GrayDlg.h"
  7. #ifdef _DEBUG
  8. #define new DEBUG_NEW
  9. #undef THIS_FILE
  10. static char THIS_FILE[] = __FILE__;
  11. #endif
  12. /////////////////////////////////////////////////////////////////////////////
  13. // CGrayDlg dialog
  14. CGrayDlg::CGrayDlg(CWnd* pParent /*=NULL*/)
  15. : CDialog(CGrayDlg::IDD, pParent)
  16. {
  17. //{{AFX_DATA_INIT(CGrayDlg)
  18. m_strWeightR = _T("0.30");
  19. m_strWeightG = _T("0.59");
  20. m_strWeightB = _T("0.11");
  21. //}}AFX_DATA_INIT
  22. m_nMethod = MEAN_GRAY;
  23. m_fWeightR = atof((LPCSTR)m_strWeightR);
  24. m_fWeightG = atof((LPCSTR)m_strWeightG);
  25. m_fWeightB = atof((LPCSTR)m_strWeightB);
  26. }
  27. void CGrayDlg::DoDataExchange(CDataExchange* pDX)
  28. {
  29. CDialog::DoDataExchange(pDX);
  30. //{{AFX_DATA_MAP(CGrayDlg)
  31. DDX_Text(pDX, IDC_EDIT1, m_strWeightR);
  32. DDX_Text(pDX, IDC_EDIT2, m_strWeightG);
  33. DDX_Text(pDX, IDC_EDIT3, m_strWeightB);
  34. //}}AFX_DATA_MAP
  35. }
  36. BEGIN_MESSAGE_MAP(CGrayDlg, CDialog)
  37. //{{AFX_MSG_MAP(CGrayDlg)
  38. ON_BN_CLICKED(IDC_RADIO1, OnRadio1)
  39. ON_BN_CLICKED(IDC_RADIO2, OnRadio2)
  40. ON_BN_CLICKED(IDC_RADIO3, OnRadio3)
  41. //}}AFX_MSG_MAP
  42. END_MESSAGE_MAP()
  43. /////////////////////////////////////////////////////////////////////////////
  44. // CGrayDlg message handlers
  45. void CGrayDlg::OnRadio1() 
  46. {
  47. m_nMethod = MEAN_GRAY;
  48. GetDlgItem(IDC_EDIT1)->EnableWindow(FALSE);
  49. GetDlgItem(IDC_EDIT2)->EnableWindow(FALSE);
  50. GetDlgItem(IDC_EDIT3)->EnableWindow(FALSE);
  51. }
  52. void CGrayDlg::OnRadio2() 
  53. {
  54. m_nMethod = MAXIMUM_GRAY;
  55. GetDlgItem(IDC_EDIT1)->EnableWindow(FALSE);
  56. GetDlgItem(IDC_EDIT2)->EnableWindow(FALSE);
  57. GetDlgItem(IDC_EDIT3)->EnableWindow(FALSE);
  58. }
  59. void CGrayDlg::OnRadio3() 
  60. {
  61. m_nMethod = WEIGHT_GRAY;
  62. GetDlgItem(IDC_EDIT1)->EnableWindow(TRUE);
  63. GetDlgItem(IDC_EDIT2)->EnableWindow(TRUE);
  64. GetDlgItem(IDC_EDIT3)->EnableWindow(TRUE);
  65. }
  66. BOOL CGrayDlg::OnInitDialog() 
  67. {
  68. CDialog::OnInitDialog();
  69. ((CButton *)GetDlgItem(IDC_RADIO1))->SetCheck(1);
  70. GetDlgItem(IDC_EDIT1)->EnableWindow(FALSE);
  71. GetDlgItem(IDC_EDIT2)->EnableWindow(FALSE);
  72. GetDlgItem(IDC_EDIT3)->EnableWindow(FALSE);
  73. return TRUE;  // return TRUE unless you set the focus to a control
  74.               // EXCEPTION: OCX Property Pages should return FALSE
  75. }
  76. void CGrayDlg::OnOK() 
  77. {
  78. UpdateData(TRUE);
  79. m_fWeightR = atof((LPCSTR)m_strWeightR);
  80. m_fWeightG = atof((LPCSTR)m_strWeightG);
  81. m_fWeightB = atof((LPCSTR)m_strWeightB);
  82. CDialog::OnOK();
  83. }