Available in the LEADTOOLS Imaging toolkit. |
SaveQFactor Example for C++ 5.0 and later
ILEADRasterDlgFile * m_pRasterFileDlg;
ILEADRasterDlgKrn * m_pRasterKrnDlg;
ILEADRasterIO * m_pRasterIO;
BOOL CAllowMulDlg::OnInitDialog()
{
.
.
.
// TODO: Add extra initialization here
m_pRasterIO = NULL;
CoCreateInstance(CLSID_LEADRasterIO, NULL, CLSCTX_ALL,
IID_ILEADRasterIO, (void**)&m_pRasterIO);
m_pRasterIO->Load (m_RasterView.GetRaster(),TEXT("c:\\parrots.jpg"),0,0,1);
m_pRasterKrnDlg = NULL;
CoCreateInstance(CLSID_LEADRasterDlgKrn, NULL, CLSCTX_ALL,
IID_ILEADRasterDlgKrn, (void**)&m_pRasterKrnDlg);
m_pRasterKrnDlg->InitDlg(INIT_WITHOUT_COLOR);
m_pRasterFileDlg=NULL;
CoCreateInstance(CLSID_LEADRasterDlgFile, NULL, CLSCTX_ALL,
IID_ILEADRasterDlgFile, (void**)&m_pRasterFileDlg);
return TRUE; // return TRUE unless you set the focus
to a control
}
void CDialogs::OnShowSaveDlg()
{
int nRet;
m_pRasterFileDlg->DialogTitle = "Save
a File";
m_pRasterFileDlg->FileDlgFlags = 0;
m_pRasterFileDlg->InitialDir = "C:\\";
m_pRasterFileDlg->SaveMulti = MULTIPAGE_OVERWRITE;
m_pRasterFileDlg->UIFlags = SAVE_SHOW_FILEOPTIONS_PROGRESSIVE
|
SAVE_SHOW_FILEOPTIONS_MULTIPAGE
|
SAVE_SHOW_FILEOPTIONS_STAMP
|
SAVE_SHOW_FILEOPTIONS_QFACTOR
|
SAVE_SHOW_FILEOPTIONS_J2KOPTIONS
|
SAVE_SHOW_FILEOPTIONS_BASICJ2KOPTIONS;
m_pRasterFileDlg->Bitmap = m_RasterView.GetRaster().GetBitmap();
nRet = m_pRasterFileDlg->ShowSaveDlg((long)this->m_hWnd);
if (nRet = 0 && m_pRasterFileDlg->DialogStatus
== DLG_OK)
{
if ((m_pRasterFileDlg->SaveFormat == FILE_J2K) ||
(m_pRasterFileDlg->SaveFormat
== FILE_JP2))
{
m_pRasterIO->J2KUseColorTransform = m_pRasterFileDlg->SaveJ2KUseColorTransform;
m_pRasterIO->J2KDerivedQuantization = m_pRasterFileDlg->SaveJ2KDerivedQuantization;
m_pRasterIO->PutJ2KCompressionControl (m_pRasterFileDlg->GetSaveJ2KCompressionControl());
m_pRasterIO->J2KCompressionRatio
= m_pRasterFileDlg->SaveJ2KCompressionRatio;
m_pRasterIO->J2KTargetFileSize
= m_pRasterFileDlg->SaveJ2KTargetFileSize;
m_pRasterIO->J2KXOsiz
= m_pRasterFileDlg->SaveJ2KXOsiz;
m_pRasterIO->J2KYOsiz
= m_pRasterFileDlg->SaveJ2KYOsiz;
m_pRasterIO->J2KXTsiz
= m_pRasterFileDlg->SaveJ2KXTsiz;
m_pRasterIO->J2KYTsiz
= m_pRasterFileDlg->SaveJ2KYTsiz;
m_pRasterIO->J2KXTOsiz
= m_pRasterFileDlg->SaveJ2KXTOsiz;
m_pRasterIO->J2KYTOsiz
= m_pRasterFileDlg->SaveJ2KYTOsiz;
m_pRasterIO->J2KDecompLevel
= m_pRasterFileDlg->SaveJ2KDecompLevel;
m_pRasterIO->PutJ2KProgressOrder
(m_pRasterFileDlg->GetSaveJ2KProgressOrder());
m_pRasterIO->J2KCodBlockWidth
= m_pRasterFileDlg->SaveJ2KCodBlockWidth;
m_pRasterIO->J2KCodBlockHeight
= m_pRasterFileDlg->SaveJ2KCodBlockHeight;
m_pRasterIO->J2KCBS_SelectiveACBypass = m_pRasterFileDlg->SaveJ2KCBS_SelectiveACBypass;
m_pRasterIO->J2KCBS_ResetContextOnBoundaries
= m_pRasterFileDlg->SaveJ2KCBS_ResetContextOnBoundaries;
m_pRasterIO->J2KCBS_TerminationOnEachPass = m_pRasterFileDlg->SaveJ2KCBS_TerminationOnEachPass;
m_pRasterIO->J2KCBS_VerticallyCausalContext =
m_pRasterFileDlg->SaveJ2KCBS_VerticallyCausalContext;
m_pRasterIO->J2KCBS_PredictableTermination =
m_pRasterFileDlg->SaveJ2KCBS_PredictableTermination;
m_pRasterIO->J2KCBS_ErrorResilienceSymbol = m_pRasterFileDlg->SaveJ2KCBS_ErrorResilienceSymbol;
m_pRasterIO->J2KGuardBits
= m_pRasterFileDlg->SaveJ2KGuardBits;
m_pRasterIO->J2KDerivedBaseMantissa = m_pRasterFileDlg->SaveJ2KDerivedBaseMantissa;
m_pRasterIO->J2KDerivedBaseExponent = m_pRasterFileDlg->SaveJ2KDerivedBaseExponent;
m_pRasterIO->J2KUseSOPMarker
= m_pRasterFileDlg->SaveJ2KUseSOPMarker;
m_pRasterIO->J2KUseEPHMarker
= m_pRasterFileDlg->SaveJ2KUseEPHMarker;
m_pRasterIO->Save
(m_RasterView.GetRaster(), m_pRasterFileDlg->FileName,
(RasterFileConstants)m_pRasterFileDlg->SaveFormat,
m_pRasterFileDlg->SaveBitsPerPixel,
(QFactorConstants)m_pRasterFileDlg->SaveQFactor,
m_pRasterFileDlg->SaveMulti);
}
}
}