📄 rdsdk sampleappdlg.cpp
字号:
// RDSDK SampleAppDlg.cpp : implementation file
//
#include "stdafx.h"
#include "RDSDK SampleApp.h"
#include "RDSDK SampleAppDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/* Development area parameter */
#define strReductDenominator "4096"
#define strDefaultValue "0"
/* Terminus mark parameter */
#define UINT32DATA_END 0xffffffff
#define INT16DATA_END 0x7fff
/* Digital exposure compensation parameter */
#define DgtlExpCmpM20 -20
#define DgtlExpCmpM19 -19
#define DgtlExpCmpM18 -18
#define DgtlExpCmpM17 -17
#define DgtlExpCmpM16 -16
#define DgtlExpCmpM15 -15
#define DgtlExpCmpM14 -14
#define DgtlExpCmpM13 -13
#define DgtlExpCmpM12 -12
#define DgtlExpCmpM11 -11
#define DgtlExpCmpM10 -10
#define DgtlExpCmpM9 -9
#define DgtlExpCmpM8 -8
#define DgtlExpCmpM7 -7
#define DgtlExpCmpM6 -6
#define DgtlExpCmpM5 -5
#define DgtlExpCmpM4 -4
#define DgtlExpCmpM3 -3
#define DgtlExpCmpM2 -2
#define DgtlExpCmpM1 -1
#define DgtlExpCmp0 0
#define DgtlExpCmpP1 1
#define DgtlExpCmpP2 2
#define DgtlExpCmpP3 3
#define DgtlExpCmpP4 4
#define DgtlExpCmpP5 5
#define DgtlExpCmpP6 6
#define DgtlExpCmpP7 7
#define DgtlExpCmpP8 8
#define DgtlExpCmpP9 9
#define DgtlExpCmpP10 10
#define DgtlExpCmpP11 11
#define DgtlExpCmpP12 12
#define DgtlExpCmpP13 13
#define DgtlExpCmpP14 14
#define DgtlExpCmpP15 15
#define DgtlExpCmpP16 16
#define DgtlExpCmpP17 17
#define DgtlExpCmpP18 18
#define DgtlExpCmpP19 19
#define DgtlExpCmpP20 20
typedef struct {
cdDevT_DevAction ActionID;
cdChar* ActionName;
}stDevT_DevAction;
/* Development action data table */
stDevT_DevAction tbl_DevT_DevAction[] =
{
{kDevAct_FullDevelop, "FullDevelop" },
{kDevAct_ThumbDevelop, "ThumbDevelop" },
{kDevAct_PrevDevelop, "PrevDevelop" },
{kDevAct_PrevThumbDevelop, "PrevThumbDevelop" },
{kDevAct_ExtractJPEG, "ExtractJPEG" },
{kDevAct_ExtractDCFJPEG, "ExtractDCFJPEG" },
{UINT32DATA_END, NULL }
};
typedef struct {
cdInt16 PrmVal;
cdChar* PrmValName;
}stPrmValDetail;
/* Digital exposure compensation data table */
stPrmValDetail tbl_DgtlExpCmp[] =
{
{DgtlExpCmpM20, "-20"}, {DgtlExpCmpM19, "-19"}, {DgtlExpCmpM18, "-18"}, {DgtlExpCmpM17, "-17"},
{DgtlExpCmpM16, "-16"}, {DgtlExpCmpM15, "-15"}, {DgtlExpCmpM14, "-14"}, {DgtlExpCmpM13, "-13"},
{DgtlExpCmpM12, "-12"}, {DgtlExpCmpM11, "-11"}, {DgtlExpCmpM10, "-10"}, {DgtlExpCmpM9, "-9" },
{DgtlExpCmpM8, "-8" }, {DgtlExpCmpM7, "-7" }, {DgtlExpCmpM6, "-6" }, {DgtlExpCmpM5, "-5" },
{DgtlExpCmpM4, "-4" }, {DgtlExpCmpM3, "-3" }, {DgtlExpCmpM2, "-2" }, {DgtlExpCmpM1, "-1" },
{DgtlExpCmp0, "0" }, {DgtlExpCmpP1, "1" }, {DgtlExpCmpP2, "2" }, {DgtlExpCmpP3, "3" },
{DgtlExpCmpP4, "4" }, {DgtlExpCmpP5, "5" }, {DgtlExpCmpP6, "6" }, {DgtlExpCmpP7, "7" },
{DgtlExpCmpP8, "8" }, {DgtlExpCmpP9, "9" }, {DgtlExpCmpP10, "10" }, {DgtlExpCmpP11, "11" },
{DgtlExpCmpP12, "12" }, {DgtlExpCmpP13, "13" }, {DgtlExpCmpP14, "14" }, {DgtlExpCmpP15, "15" },
{DgtlExpCmpP16, "16" }, {DgtlExpCmpP17, "17" }, {DgtlExpCmpP18, "18" }, {DgtlExpCmpP19, "19" },
{DgtlExpCmpP20, "20" },
{INT16DATA_END, '\0' }
};
/* The color effect data table */
stPrmValDetail tbl_ClrEffect[] =
{
{kClrEffct_Off, "Off" },
{kClrEffct_Vivid, "Vivid" },
{kClrEffct_Neutral, "Neutral" },
{kClrEffct_Soft, "Soft" },
{kClrEffct_Sepia, "Sepia" },
{kClrEffct_BW, "BW" },
{kClrEffct_Custom, "Custom" },
{kClrEffct_MyColor, "MyColor" },
{INT16DATA_END, '\0' }
};
typedef struct
{
cdDevT_ParamItemID PrmID;
stPrmValDetail* PrmValDetail;
CComboBox* ComboBox;
}stDevT_ParamItem;
/* Development parameter item ID table */
stDevT_ParamItem tbl_DevT_ParamItem[] =
{
{kPrmID_DgtlExpCmp, tbl_DgtlExpCmp, NULL},
{kPrmID_ColorEffect, tbl_ClrEffect, NULL},
{UINT32DATA_END, NULL, NULL}
};
/////////////////////////////////////////////////////////////////////////////
// CAboutDlg dialog used for App About
class CAboutDlg : public CDialog
{
public:
CAboutDlg();
// Dialog Data
//{{AFX_DATA(CAboutDlg)
enum { IDD = IDD_ABOUTBOX };
//}}AFX_DATA
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CAboutDlg)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
//{{AFX_MSG(CAboutDlg)
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
{
//{{AFX_DATA_INIT(CAboutDlg)
//}}AFX_DATA_INIT
}
void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CAboutDlg)
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
//{{AFX_MSG_MAP(CAboutDlg)
// No message handlers
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CRDSDKSampleAppDlg dialog
CRDSDKSampleAppDlg::CRDSDKSampleAppDlg(CWnd* pParent /*=NULL*/)
: CDialog(CRDSDKSampleAppDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CRDSDKSampleAppDlg)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}
void CRDSDKSampleAppDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CRDSDKSampleAppDlg)
DDX_Control(pDX, IDC_TOP, m_CTop);
DDX_Control(pDX, IDC_START, m_CStart);
DDX_Control(pDX, IDC_SET, m_CSet);
DDX_Control(pDX, IDC_RATIO, m_CRatio);
DDX_Control(pDX, IDC_RIGHT, m_CRight);
DDX_Control(pDX, IDC_LEFT, m_CLeft);
DDX_Control(pDX, IDC_FINISH, m_CFinish);
DDX_Control(pDX, IDC_DISPOSE, m_CDispose);
DDX_Control(pDX, IDC_DGTLEXPCMP, m_CDgtlExpCmp);
DDX_Control(pDX, IDC_DEVELOP, m_CDevelop);
DDX_Control(pDX, IDC_CREATE, m_CCreate);
DDX_Control(pDX, IDC_CLREFFECT, m_CClrEffect);
DDX_Control(pDX, IDC_CLOSE, m_CClose);
DDX_Control(pDX, IDC_BOTTOM, m_CBottom);
DDX_Control(pDX, IDC_ACTION, m_CAction);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CRDSDKSampleAppDlg, CDialog)
//{{AFX_MSG_MAP(CRDSDKSampleAppDlg)
ON_WM_SYSCOMMAND()
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
ON_BN_CLICKED(IDC_START, OnStart)
ON_BN_CLICKED(IDC_FINISH, OnFinish)
ON_BN_CLICKED(IDC_CREATE, OnCreate)
ON_BN_CLICKED(IDC_DISPOSE, OnDispose)
ON_BN_CLICKED(IDC_DEVELOP, OnDevelop)
ON_BN_CLICKED(IDC_CLOSE, OnClose)
ON_BN_CLICKED(IDC_SET, OnSet)
ON_CBN_SELCHANGE(IDC_CLREFFECT, OnSelchangeClreffect)
ON_CBN_SELCHANGE(IDC_ACTION, OnSelchangeAction)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CRDSDKSampleAppDlg message handlers
BOOL CRDSDKSampleAppDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// Add "About..." menu item to system menu.
// IDM_ABOUTBOX must be in the system command range.
ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
ASSERT(IDM_ABOUTBOX < 0xF000);
CMenu* pSysMenu = GetSystemMenu(FALSE);
if (pSysMenu != NULL)
{
CString strAboutMenu;
strAboutMenu.LoadString(IDS_ABOUTBOX);
if (!strAboutMenu.IsEmpty())
{
pSysMenu->AppendMenu(MF_SEPARATOR);
pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
}
}
// Set the icon for this dialog. The framework does this automatically
// when the application's main window is not a dialog
SetIcon(m_hIcon, TRUE); // Set big icon
SetIcon(m_hIcon, FALSE); // Set small icon
// TODO: Add extra initialization here
hRAW = NULL;
m_CStart.EnableWindow(TRUE);
bStartFlg = TRUE;
m_CFinish.EnableWindow(FALSE);
m_CCreate.EnableWindow(FALSE);
m_CDispose.EnableWindow(FALSE);
m_CSet.EnableWindow(FALSE);
m_CClose.EnableWindow(TRUE);
SetAvailPrmControl();
DisableAvailPrmControl();
InitDevelopControl();
DisableDevelopControl();
return TRUE; // return TRUE unless you set the focus to a control
}
void CRDSDKSampleAppDlg::OnSysCommand(UINT nID, LPARAM lParam)
{
if ((nID & 0xFFF0) == IDM_ABOUTBOX)
{
CAboutDlg dlgAbout;
dlgAbout.DoModal();
}
else
{
CDialog::OnSysCommand(nID, lParam);
}
}
// If you add a minimize button to your dialog, you will need the code below
// to draw the icon. For MFC applications using the document/view model,
// this is automatically done for you by the framework.
void CRDSDKSampleAppDlg::OnPaint()
{
if (IsIconic())
{
CPaintDC dc(this); // device context for painting
SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);
// Center icon in client rectangle
int cxIcon = GetSystemMetrics(SM_CXICON);
int cyIcon = GetSystemMetrics(SM_CYICON);
CRect rect;
GetClientRect(&rect);
int x = (rect.Width() - cxIcon + 1) / 2;
int y = (rect.Height() - cyIcon + 1) / 2;
// Draw the icon
dc.DrawIcon(x, y, m_hIcon);
}
else
{
CDialog::OnPaint();
}
}
// The system calls this to obtain the cursor to display while the user drags
// the minimized window.
HCURSOR CRDSDKSampleAppDlg::OnQueryDragIcon()
{
return (HCURSOR) m_hIcon;
}
void CRDSDKSampleAppDlg::OnStart()
{
// TODO: Add your control notification handler code here
cdError err;
/* RD-SDK is started. */
err = RDStartSDK(0);
if(err != cdOK)
{
char szErrStr[MAX_PATH];
wsprintf(szErrStr, "ErrorCode = 0x%08X", err);
MessageBox(szErrStr);
RDFinishSDK();
return ;
}
m_CStart.EnableWindow(FALSE);
bStartFlg = FALSE;
m_CFinish.EnableWindow(TRUE);
m_CCreate.EnableWindow(TRUE);
}
void CRDSDKSampleAppDlg::OnFinish()
{
// TODO: Add your control notification handler code here
cdError err;
if(hRAW != NULL)
{
/* A RAW object is disposed. */
err = RDDisposeRAWObject(hRAW);
if(err != cdOK)
{
goto rderr;
}
hRAW = NULL;
}
/* RDSDK is ended. */
err = RDFinishSDK();
if(err != cdOK)
{
goto rderr;
}
bStartFlg = TRUE;
m_CStart.EnableWindow(TRUE);
m_CFinish.EnableWindow(FALSE);
m_CCreate.EnableWindow(FALSE);
m_CDispose.EnableWindow(FALSE);
m_CSet.EnableWindow(FALSE);
DisableAvailPrmControl();
DisableDevelopControl();
return;
rderr:
char szErrStr[256];
wsprintf(szErrStr, "ErrorCode = 0x%08X", err);
MessageBox(szErrStr);
}
void CRDSDKSampleAppDlg::OnCreate()
{
// TODO: Add your control notification handler code here
cdError err;
int index = 0;
int comIndex = 0;
CString strPathName;
cdStgMedium crwMedium;
cdDevT_Availability Available;
stPrmValDetail* prmValDetail;
CFileDialog fileDlg(TRUE,
NULL,
NULL,
OFN_HIDEREADONLY | OFN_NONETWORKBUTTON | OFN_PATHMUSTEXIST,
"crw Files (*.crw)|*.crw||",
this);
if(fileDlg.DoModal() != IDOK)
{
return;
}
/* The path to RAW image is obtained. */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -