MeVisLabToolboxReference
|
00001 // **InsertLicense** code 00002 //---------------------------------------------------------------------------------- 00006 00011 //---------------------------------------------------------------------------------- 00012 00013 #ifndef __mlImageFormatTools_H 00014 #define __mlImageFormatTools_H 00015 00016 // Resolve platform independencies. 00017 #ifndef __MLImageFormatBaseSystem_H 00018 #include "MLImageFormatBaseSystem.h" 00019 #endif 00020 00021 #ifndef __mlModuleIncludes_H 00022 #include "mlModuleIncludes.h" 00023 #endif 00024 #ifndef __mlImageFormatTagList_H 00025 #include "mlImageFormatTagList.h" 00026 #endif 00027 00028 // Implement everything in ML namespace. 00029 ML_START_NAMESPACE 00030 00032 class MLImageFormatInfos; 00033 class DataCompressor; 00034 class MLImageFormatIdxTable; 00035 00036 //---------------------------------------------------------------------- 00039 //---------------------------------------------------------------------- 00040 class MLIMAGEFORMATBASE_EXPORT MLImageFormatTools { 00041 00042 public: 00043 00045 enum ProcessState { 00046 StartPageSave = 0, 00047 EndPageSave 00048 }; 00049 00051 enum SaveModeBits { 00052 DefaultSaveMode = 0, 00053 AllowPartialPages = 1 00054 00055 }; 00056 00057 //-------------------------------------------------------------------------------- 00060 //-------------------------------------------------------------------------------- 00061 typedef void MLImageFormatNotifyCB(MLint id, 00062 MLint idNum, 00063 ProcessState state, 00064 void *usrData, 00065 bool &interrupt 00066 ); 00067 00068 00069 //-------------------------------------------------------------------------------- 00074 //-------------------------------------------------------------------------------- 00075 static const std::string ML_FILE_VERSION_STRING; 00076 00077 //-------------------------------------------------------------------------------- 00080 //-------------------------------------------------------------------------------- 00081 static const std::string ML_FILE_VERSION_STRING_EXT; 00082 00083 //-------------------------------------------------------------------------------- 00086 //-------------------------------------------------------------------------------- 00087 static const size_t ML_MAX_VERSION_AND_FIRST_PAIR_SIZE; 00088 00089 //---------------------------------------------------------------------- 00090 // 00092 00093 // 00094 //---------------------------------------------------------------------- 00095 00126 static MLErrorCode open(MLImageFormatInfos *&infos, 00127 const std::string &fileName, 00128 bool truncate = false, 00129 const std::string &compressorName = "", 00130 const MLImageFormatTagList &compressionTagList = MLImageFormatTagList::getDefaultEmptyTagList(), 00131 const MLImageFormatTagList &userTagList = MLImageFormatTagList::getDefaultEmptyTagList(), 00132 const MLImageFormatTagList &privateTagList = MLImageFormatTagList::getDefaultEmptyTagList(), 00133 const std::string &defaultVoxelValue = "0", 00134 bool rewritable = true); 00135 00141 static MLErrorCode close(MLImageFormatInfos *&infos); 00142 00170 static MLErrorCode save(MLImageFormatInfos &infos, 00171 PagedImage &inputPagedImg, 00172 const SubImageBox &box = SubImageBox(), 00173 MLImageFormatNotifyCB *callback = NULL, 00174 void *userData = NULL, 00175 const ScaleShiftData &scaleShiftData = ScaleShiftData(), 00176 MLuint32 saveModeBits = DefaultSaveMode, 00177 MLdouble *saveTime = NULL , 00178 MLdouble *prepTime = NULL); 00179 00180 00196 static MLErrorCode overwriteHeaderAndPageList(const MLImageFormatInfos &infos, 00197 MLuint32 saveModeBits); 00198 00199 00225 static MLErrorCode overwrite(MLImageFormatInfos &infos , 00226 PagedImage &inputPagedImg , 00227 const SubImageBox &box , 00228 MLImageFormatNotifyCB *callback , 00229 void *userData , 00230 const ScaleShiftData &scaleShiftData, 00231 MLuint32 saveModeBits = DefaultSaveMode, 00232 MLdouble *saveTime = NULL , 00233 MLdouble *prepTime = NULL); 00234 00257 static MLErrorCode overwrite(MLImageFormatInfos &infos , 00258 const SubImage &inputSubImg , 00259 MLImageFormatNotifyCB *callback , 00260 void *userData , 00261 const ScaleShiftData &scaleShiftData, 00262 MLuint32 saveModeBits = DefaultSaveMode, 00263 MLdouble *saveTime = NULL , 00264 MLdouble *prepTime = NULL); 00265 00298 static MLErrorCode getTile(const MLImageFormatInfos &infos, 00299 SubImage &subImgToFill, 00300 bool useFileDataType, 00301 bool useFileRegion, 00302 const ScaleShiftData &scaleShiftData); 00304 00305 00316 static MLuint32 calcCheckSum(const void *dataPtr, MLint numBytes, MLint voxSize); 00317 00327 static void setDICOMTreeSourceFileName(PagedImage &outImg, 00328 const std::string &fileName); 00329 00330 00331 protected: 00332 00339 static MLErrorCode _loadFileProperties(MLImageFormatInfos &infos); 00340 00344 static MLErrorCode _destroyFileProperties(MLImageFormatInfos *&infos); 00345 00356 static MLErrorCode _loadPage(const MLImageFormatInfos &infos, 00357 MLint pageId, 00358 SubImage &pageBuf); 00359 00369 static MLErrorCode _decompressPageData(const MLImageFormatInfos &infos, 00370 const size_t savedPageSizeInBytes, 00371 const size_t expectedSizeInBytes, 00372 MLuint8 *&loadedPage, 00373 bool &isLossy); 00374 00417 static MLErrorCode _saveIndexTableAndPages(MLImageFormatInfos &infos, 00418 const SubImageBox &box, 00419 PagedImage *inputPagedImg, 00420 const SubImage *inputSubImg, 00421 MLImageFormatNotifyCB *callback, 00422 void *userData, 00423 const ScaleShiftData &scaleShiftData, 00424 bool replaceAreaToSave, 00425 MLuint32 saveModeBits, 00426 MLdouble *saveTime=NULL, 00427 MLdouble *prepTime=NULL); 00428 00455 static MLErrorCode _savePage(MLImageFormatInfos &infos, 00456 const MLint pageId, 00457 const bool isOutsideAreaToSave, 00458 const MLTypeData *defaultVoxelPtr, 00459 const SubImage &subImgToSave, 00460 const bool replaceOnlyWrittenPageIds, 00461 const MLuint32 saveModeBits, 00462 TimeCounter &saveTimer, 00463 MLdouble &saveTime, 00464 TimeCounter &calcTimer, 00465 MLdouble &calcTime); 00466 00480 static MLErrorCode _compressPageData(DataCompressor *compressor, 00481 SubImage &dataSubImg, 00482 MLint &dstBufSize); 00483 00484 }; 00485 00486 ML_END_NAMESPACE 00487 00488 #endif // of __mlImageFormatTools_H 00489 00490