// MRCPage.cpp : implementation file // #include "stdafx.h" #include "segdemo.h" #include "MRCPage.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif ///////////////////////////////////////////////////////////////////////////// // CMRCPage property page IMPLEMENT_DYNCREATE(CMRCPage, CPropertyPage) CMRCPage::CMRCPage() : CPropertyPage(CMRCPage::IDD) { m_pMrcOptions = NULL; //{{AFX_DATA_INIT(CMRCPage) // NOTE: the ClassWizard will add member initialization here //}}AFX_DATA_INIT } CMRCPage::~CMRCPage() { } void CMRCPage::DoDataExchange(CDataExchange* pDX) { CPropertyPage::DoDataExchange(pDX); //{{AFX_DATA_MAP(CMRCPage) DDX_Control(pDX, IDC_GS_QFACTOR, m_edtGSQFactor); DDX_Control(pDX, IDC_QFACTOR, m_edtQFactor); DDX_Control(pDX, IDC_GRAYSCALECODER, m_cmbGrayScaleCoder); DDX_Control(pDX, IDC_GRAYSCALE2BITCODER, m_cmbGrayScale2BitCoder); DDX_Control(pDX, IDC_TEXT2BITCODER, m_cmbText2BitCoder); DDX_Control(pDX, IDC_PICTURECODER, m_cmbPictureCoder); DDX_Control(pDX, IDC_MASKCODER, m_cmbMaskCoder); //}}AFX_DATA_MAP } BEGIN_MESSAGE_MAP(CMRCPage, CPropertyPage) //{{AFX_MSG_MAP(CMRCPage) ON_CBN_SELCHANGE(IDC_PICTURECODER, OnSelChangePictureCoder) ON_CBN_SELCHANGE(IDC_GRAYSCALECODER, OnSelChangeGrayScaleCoder) ON_EN_KILLFOCUS(IDC_QFACTOR, OnKillFocusQFactor) ON_EN_KILLFOCUS(IDC_GS_QFACTOR, OnKillFocusGsQFactor) //}}AFX_MSG_MAP END_MESSAGE_MAP() void CMRCPage :: ChangeQFactorStatus() { int nCoder; nCoder = m_cmbPictureCoder.GetCurSel(); if ((nCoder == MRC_PICTURE_COMPRESSION_LOSSLESS_CMW) || (nCoder == MRC_PICTURE_COMPRESSION_LOSSLESS_JPEG)) m_edtQFactor.EnableWindow(FALSE); else m_edtQFactor.EnableWindow(TRUE); nCoder = m_cmbGrayScaleCoder.GetCurSel(); if ((nCoder == MRC_GRAYSCALE_COMPRESSION_LOSSLESS_CMW_8BIT) || (nCoder == MRC_GRAYSCALE_COMPRESSION_LOSSLESS_JPEG_8BIT)) m_edtGSQFactor.EnableWindow(FALSE); else m_edtGSQFactor.EnableWindow(TRUE); } ///////////////////////////////////////////////////////////////////////////// // CMRCPage message handlers BOOL CMRCPage::OnInitDialog() { CPropertyPage::OnInitDialog(); UpdateData(TRUE); // Mask compression types m_cmbMaskCoder.ResetContent(); m_cmbMaskCoder.AddString(TEXT("JBIG")); m_cmbMaskCoder.AddString(TEXT("Fax G4")); m_cmbMaskCoder.AddString(TEXT("Fax G3(1D)")); m_cmbMaskCoder.AddString(TEXT("Fax G3(2D)")); // Picture compression types m_cmbPictureCoder.ResetContent(); m_cmbPictureCoder.AddString(TEXT("Wavelet CMW")); m_cmbPictureCoder.AddString(TEXT("Lossless Wavelet CMW")); m_cmbPictureCoder.AddString(TEXT("LEAD CMP")); m_cmbPictureCoder.AddString(TEXT("JPEG")); m_cmbPictureCoder.AddString(TEXT("Lossless JPEG")); m_cmbPictureCoder.AddString(TEXT("JPEG YUV 4:2:2")); m_cmbPictureCoder.AddString(TEXT("JPEG YUV 4:1:1")); m_cmbPictureCoder.AddString(TEXT("JPEG Progressive")); m_cmbPictureCoder.AddString(TEXT("JPEG Progressive YUV 4:2:2")); m_cmbPictureCoder.AddString(TEXT("JPEG Progressive YUV 4:1:1")); // Text 2 bit Colored compression types m_cmbText2BitCoder.ResetContent(); m_cmbText2BitCoder.AddString(TEXT("Text JBIG 2-bit")); m_cmbText2BitCoder.AddString(TEXT("Text GIF 2-bit")); // Grayscale 2 bit compression types m_cmbGrayScale2BitCoder.ResetContent(); m_cmbGrayScale2BitCoder.AddString(TEXT("Grayscale JBIG 2-bit")); // Grayscale 8 bit compression types m_cmbGrayScaleCoder.ResetContent(); m_cmbGrayScaleCoder.AddString(TEXT("Lossless CMW 8-bit")); m_cmbGrayScaleCoder.AddString(TEXT("Grayscale CMW 8-bit")); m_cmbGrayScaleCoder.AddString(TEXT("Grayscale CMP 8-bit")); m_cmbGrayScaleCoder.AddString(TEXT("Lossless JPEG 8-bit")); m_cmbGrayScaleCoder.AddString(TEXT("Grayscale JPEG 8-bit")); m_cmbGrayScaleCoder.AddString(TEXT("Grayscale JPEG Progressive 8-bit")); if(!m_pMrcOptions) return TRUE; m_cmbMaskCoder.SetCurSel(m_pMrcOptions->nMaskCoder); m_cmbPictureCoder.SetCurSel(m_pMrcOptions->nPictureCoder); m_cmbText2BitCoder.SetCurSel(m_pMrcOptions->nTextCoder2Bit); m_cmbGrayScale2BitCoder.SetCurSel(m_pMrcOptions->nGrayscale2BitCoder); m_cmbGrayScaleCoder.SetCurSel(m_pMrcOptions->nGrayscale8BitCoder); CString strVal; strVal.Format(TEXT("%d"), m_pMrcOptions->nPictureQFactor); m_edtQFactor.SetWindowText(strVal); strVal.Format(TEXT("%d"), m_pMrcOptions->nGrayscale8BitFactor); m_edtGSQFactor.SetWindowText(strVal); ChangeQFactorStatus(); UpdateData(FALSE); return TRUE; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE } void CMRCPage::OnOK() { CString strVal; UpdateData(TRUE); m_pMrcOptions->nMaskCoder = m_cmbMaskCoder.GetCurSel(); m_pMrcOptions->nPictureCoder = m_cmbPictureCoder.GetCurSel(); m_pMrcOptions->nTextCoder2Bit = m_cmbText2BitCoder.GetCurSel(); m_pMrcOptions->nGrayscale2BitCoder = m_cmbGrayScale2BitCoder.GetCurSel(); m_pMrcOptions->nGrayscale8BitCoder = m_cmbGrayScaleCoder.GetCurSel(); m_edtQFactor.GetWindowText(strVal); m_pMrcOptions->nPictureQFactor = _ttoi(strVal); m_edtGSQFactor.GetWindowText(strVal); m_pMrcOptions->nGrayscale8BitFactor = _ttoi(strVal); UpdateData(FALSE); CPropertyPage::OnOK(); } void CMRCPage::OnSelChangePictureCoder() { ChangeQFactorStatus(); } void CMRCPage::OnSelChangeGrayScaleCoder() { ChangeQFactorStatus(); } void CMRCPage::OnKillFocusQFactor() { CString strVal; m_edtQFactor.GetWindowText(strVal); int nOldPictureQFactor = m_pMrcOptions->nPictureQFactor; m_pMrcOptions->nPictureQFactor = _ttoi(strVal); m_pMrcOptions->nPictureCoder = m_cmbPictureCoder.GetCurSel(); if ((m_pMrcOptions->nPictureQFactor < 2) || (m_pMrcOptions->nPictureQFactor > 255)) { if ((m_pMrcOptions->nPictureCoder == MRC_PICTURE_COMPRESSION_LOSSLESS_CMW) || (m_pMrcOptions->nPictureCoder == MRC_PICTURE_COMPRESSION_LOSSLESS_JPEG)) { m_pMrcOptions->nPictureQFactor = 2; strVal.Format(TEXT("%d"), m_pMrcOptions->nPictureQFactor); m_edtQFactor.SetWindowText(strVal); } else { MessageBox(TEXT("Please enter a number between 2 and 255 for the ") TEXT("colored images compression quality factor."), TEXT("Invalid Value"), MB_OK); m_pMrcOptions->nPictureQFactor = nOldPictureQFactor; strVal.Format(TEXT("%d"), nOldPictureQFactor); m_edtQFactor.SetWindowText(strVal); } } } void CMRCPage::OnKillFocusGsQFactor() { CString strVal; m_edtGSQFactor.GetWindowText(strVal); int nOldGrayscale8BitFactor = m_pMrcOptions->nGrayscale8BitFactor; m_pMrcOptions->nGrayscale8BitFactor = _ttoi(strVal); m_pMrcOptions->nGrayscale8BitCoder = m_cmbGrayScaleCoder.GetCurSel(); if ((m_pMrcOptions->nGrayscale8BitFactor < 2) || (m_pMrcOptions->nGrayscale8BitFactor > 255)) { if ((m_pMrcOptions->nGrayscale8BitCoder == MRC_GRAYSCALE_COMPRESSION_LOSSLESS_CMW_8BIT) || (m_pMrcOptions->nGrayscale8BitCoder == MRC_GRAYSCALE_COMPRESSION_LOSSLESS_JPEG_8BIT)) { m_pMrcOptions->nGrayscale8BitFactor = 2; strVal.Format(TEXT("%d"), m_pMrcOptions->nGrayscale8BitFactor); m_edtGSQFactor.SetWindowText(strVal); } else { MessageBox(TEXT("Please enter a number between 2 and 255 for the ") TEXT("grayscale images compression quality factor."), TEXT("Invalid Value"), MB_OK); m_pMrcOptions->nGrayscale8BitFactor = nOldGrayscale8BitFactor; strVal.Format(TEXT("%d"), nOldGrayscale8BitFactor); m_edtGSQFactor.SetWindowText(strVal); } } }