📄 rdsdk sampleappdlg.cpp
字号:
strPathName = fileDlg.GetPathName();
crwMedium.u.lpszFileName = (char*)(const char*)strPathName;
crwMedium.Type = cdMEMTYPE_FILE;
/* The RAW object is created. */
err = RDCreateRAWObject(&crwMedium, &hRAW);
if(err != cdOK)
{
goto rderr;
}
ResetAvailPrmControl();
while(tbl_DevT_ParamItem[index].PrmID != UINT32DATA_END)
{
/* It is determined whether a parameter item can be set or not. */
err = RDIsSupportParamItem(hRAW, tbl_DevT_ParamItem[index].PrmID, &Available);
if(err != cdOK)
{
goto rderr;
}
if(Available != kDev_AvailableToSet)
{
index++;
continue;
}
prmValDetail = tbl_DevT_ParamItem[index].PrmValDetail;
while(prmValDetail->PrmVal != INT16DATA_END)
{
/* It is determined whether a parameter value can be set or not. */
err = RDIsSupportParamValue(hRAW, tbl_DevT_ParamItem[index].PrmID, prmValDetail->PrmVal, &Available);
if(err != cdOK)
{
goto rderr;
}
if(Available == kDev_AvailableToSet)
{
tbl_DevT_ParamItem[index].ComboBox->AddString(prmValDetail->PrmValName);
tbl_DevT_ParamItem[index].ComboBox->SetItemData(comIndex, (DWORD)prmValDetail->PrmVal);
comIndex++;
}
prmValDetail++;
}
if(tbl_DevT_ParamItem[index].ComboBox->GetItemData(0) != CB_ERR)
{
tbl_DevT_ParamItem[index].ComboBox->SetCurSel(0);
tbl_DevT_ParamItem[index].ComboBox->EnableWindow(TRUE);
}
comIndex = 0;
index++;
}
CheckSetBtnControl();
m_CCreate.EnableWindow(FALSE);
m_CDispose.EnableWindow(TRUE);
m_CDevelop.EnableWindow(TRUE);
m_CAction.EnableWindow(TRUE);
m_CAction.SetCurSel(0);
CheckDevelopControl(0);
m_CRatio.SetWindowText(strReductDenominator);
m_CBottom.SetWindowText(strDefaultValue);
m_CRight.SetWindowText(strDefaultValue);
m_CTop.SetWindowText(strDefaultValue);
m_CLeft.SetWindowText(strDefaultValue);
return;
rderr:
char szErrStr[256];
wsprintf(szErrStr, "ErrorCode = 0x%08X", err);
MessageBox(szErrStr);
if(hRAW != NULL)
{
RDDisposeRAWObject(hRAW);
hRAW = NULL;
}
}
void CRDSDKSampleAppDlg::OnDispose()
{
// TODO: Add your control notification handler code here
cdError err;
/* The RAW object is disposed. */
err = RDDisposeRAWObject(hRAW);
if(err != cdOK)
{
goto rderr;
}
hRAW = NULL;
m_CCreate.EnableWindow(TRUE);
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::OnDevelop()
{
// TODO: Add your control notification handler code here
CString strSavePath;
cdStgMedium StgMedium;
cdDevT_Dimension AreaAndRatio;
cdDevT_Dimension* pAreaAndRatio;
int index;
BOOL fRes;
CProgress CPrg;
cdDevT_DevAction Action;
char szText[256];
CFileDialog CGetPath(FALSE,
"jpg",
NULL,
OFN_HIDEREADONLY | OFN_NONETWORKBUTTON | OFN_OVERWRITEPROMPT,
"jpg Files (*.jpg)|*.jpg||",
this);
if( CGetPath.DoModal() != IDOK )
{
return;
}
/* The path to the developed file is obtained. */
strSavePath = CGetPath.GetPathName();
StgMedium.u.lpszFileName = (char*)(const char*)strSavePath;
StgMedium.Type = cdMEMTYPE_FILE;
/* The handle of the item chosen is acquired. */
index = m_CAction.GetCurSel();
Action = (cdDevT_DevAction)m_CAction.GetItemData(index);
if(Action == kDevAct_PrevDevelop)
{
m_CLeft.GetWindowText(szText, 256);
AreaAndRatio.DevelopArea.Left = atoi(szText);
m_CRight.GetWindowText(szText, 256);
AreaAndRatio.DevelopArea.Right = atoi(szText);
m_CTop.GetWindowText(szText, 256);
AreaAndRatio.DevelopArea.Top = atoi(szText);
m_CBottom.GetWindowText(szText, 256);
AreaAndRatio.DevelopArea.Bottom = atoi(szText);
m_CRatio.GetWindowText(szText, 256);
AreaAndRatio.ReductNumerator = atoi(szText);
pAreaAndRatio = &AreaAndRatio;
}
else
{
pAreaAndRatio = NULL;
}
/* Development processing is performed. */
fRes = CPrg.StartDevelop(hRAW, Action, cdTGT_FORMAT_JPEG, pAreaAndRatio, StgMedium);
if(fRes == FALSE)
{
MessageBox("API Error");
}
else if(CPrg.err != cdOK)
{
char szErrStr[256];
wsprintf(szErrStr, "ErrorCode = 0x%08X", CPrg.err);
MessageBox(szErrStr);
}
}
void CRDSDKSampleAppDlg::OnClose()
{
// 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;
}
if(!bStartFlg)
{
/* RDSDK is ended. */
err = RDFinishSDK();
if(err != cdOK)
{
goto rderr;
}
}
EndDialog(0);
return;
rderr:
char szErrStr[256];
wsprintf(szErrStr, "ErrorCode = 0x%08X", err);
MessageBox(szErrStr);
if(hRAW != NULL)
{
RDDisposeRAWObject(hRAW);
hRAW = NULL;
}
RDFinishSDK();
EndDialog(0);
}
void CRDSDKSampleAppDlg::OnSet()
{
// TODO: Add your control notification handler code here
cdError err;
int iCursel;
int index = 0;
cdInt16 iPrmVal;
while(tbl_DevT_ParamItem[index].PrmID != UINT32DATA_END)
{
/* The handle of the item chosen is acquired. */
iCursel = tbl_DevT_ParamItem[index].ComboBox->GetCurSel();
if(iCursel == CB_ERR)
{
index++;
continue;
}
iPrmVal = (cdInt16)tbl_DevT_ParamItem[index].ComboBox->GetItemData(iCursel);
if(iPrmVal == kClrEffct_MyColor){
index++;
continue;
}
/* A development parameter value is set. */
err = RDSetParamValue(hRAW, tbl_DevT_ParamItem[index].PrmID, iPrmVal);
if(err != cdOK)
{
goto rderr;
}
index++;
}
/* A development parameter is reflected in development processing. */
err = RDReflectParamValues(hRAW, kPrmCpyUI2Dvlp);
if(err != cdOK)
{
goto rderr;
}
return;
rderr:
char szErrStr[256];
wsprintf(szErrStr, "ErrorCode = 0x%08X", err);
MessageBox(szErrStr);
}
void CRDSDKSampleAppDlg::OnSelchangeClreffect()
{
// TODO: Add your control notification handler code here
int index;
cdInt16 iPrmVal;
/* The handle of the item chosen is acquired. */
index = m_CClrEffect.GetCurSel();
iPrmVal = (cdInt16)m_CClrEffect.GetItemData(index);
if(iPrmVal == kClrEffct_Custom)
{
MessageBox("The detail setting about this parameter is not supported in this application.");
}else if(iPrmVal == kClrEffct_MyColor){
MessageBox("This value is not supported.");
}
}
void CRDSDKSampleAppDlg::OnSelchangeAction()
{
// TODO: Add your control notification handler code here
int index;
/* The handle of the item chosen is acquired. */
index = m_CAction.GetCurSel();
CheckDevelopControl(index);
}
void CRDSDKSampleAppDlg::SetAvailPrmControl()
{
int index = 0;
CComboBox *tbl_Combox[] = {&m_CDgtlExpCmp, &m_CClrEffect};
while(tbl_DevT_ParamItem[index].PrmID != UINT32DATA_END)
{
tbl_DevT_ParamItem[index].ComboBox = tbl_Combox[index];
index++;
}
}
void CRDSDKSampleAppDlg::DisableAvailPrmControl()
{
int index = 0;
while(tbl_DevT_ParamItem[index].PrmID != UINT32DATA_END)
{
tbl_DevT_ParamItem[index].ComboBox->EnableWindow(FALSE);
index++;
}
}
void CRDSDKSampleAppDlg::InitDevelopControl()
{
long lStyle;
int index = 0;
while(tbl_DevT_DevAction[index].ActionID != UINT32DATA_END)
{
m_CAction.AddString(tbl_DevT_DevAction[index].ActionName);
m_CAction.SetItemData(index, tbl_DevT_DevAction[index].ActionID);
index++;
}
lStyle = GetWindowLong(m_CRatio.m_hWnd, GWL_STYLE);
SetWindowLong(m_CRatio.m_hWnd, GWL_STYLE, lStyle|ES_NUMBER);
m_CRatio.LimitText(6);
lStyle = GetWindowLong(m_CBottom.m_hWnd, GWL_STYLE);
SetWindowLong(m_CBottom.m_hWnd, GWL_STYLE, lStyle|ES_NUMBER);
m_CBottom.LimitText(6);
lStyle = GetWindowLong(m_CRight.m_hWnd, GWL_STYLE );
SetWindowLong(m_CRight.m_hWnd, GWL_STYLE, lStyle|ES_NUMBER);
m_CRight.LimitText(6);
lStyle = GetWindowLong(m_CTop.m_hWnd, GWL_STYLE);
SetWindowLong(m_CTop.m_hWnd, GWL_STYLE, lStyle|ES_NUMBER);
m_CTop.LimitText(6);
lStyle = GetWindowLong(m_CLeft.m_hWnd, GWL_STYLE);
SetWindowLong(m_CLeft.m_hWnd, GWL_STYLE, lStyle|ES_NUMBER);
m_CLeft.LimitText(6);
}
void CRDSDKSampleAppDlg::DisableDevelopControl()
{
m_CDevelop.EnableWindow(FALSE);
m_CAction.EnableWindow(FALSE);
m_CRatio.EnableWindow(FALSE);
m_CBottom.EnableWindow(FALSE);
m_CRight.EnableWindow(FALSE);
m_CTop.EnableWindow(FALSE);
m_CLeft.EnableWindow(FALSE);
}
void CRDSDKSampleAppDlg::ResetAvailPrmControl()
{
int index = 0;
while(tbl_DevT_ParamItem[index].PrmID != UINT32DATA_END)
{
tbl_DevT_ParamItem[index].ComboBox->ResetContent();
index++;
}
}
void CRDSDKSampleAppDlg::CheckSetBtnControl()
{
int index = 0;
while(tbl_DevT_ParamItem[index].PrmID != UINT32DATA_END)
{
if(tbl_DevT_ParamItem[index].ComboBox->GetItemData(0) != CB_ERR)
{
m_CSet.EnableWindow(TRUE);
break;
}
index++;
}
}
void CRDSDKSampleAppDlg::CheckDevelopControl(int index)
{
cdDevT_DevAction Action;
Action = (cdDevT_DevAction)m_CAction.GetItemData(index);
if(Action == kDevAct_PrevDevelop)
{
m_CRatio.EnableWindow(TRUE);
m_CBottom.EnableWindow(TRUE);
m_CRight.EnableWindow(TRUE);
m_CTop.EnableWindow(TRUE);
m_CLeft.EnableWindow(TRUE);
}
else
{
m_CRatio.EnableWindow(FALSE);
m_CBottom.EnableWindow(FALSE);
m_CRight.EnableWindow(FALSE);
m_CTop.EnableWindow(FALSE);
m_CLeft.EnableWindow(FALSE);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -