MeVisLab Toolbox Reference
mlImageFormatTools.h
Go to the documentation of this file.
1/*************************************************************************************
2**
3** Copyright 2007, MeVis Medical Solutions AG
4**
5** The user may use this file in accordance with the license agreement provided with
6** the Software or, alternatively, in accordance with the terms contained in a
7** written agreement between the user and MeVis Medical Solutions AG.
8**
9** For further information use the contact form at https://www.mevislab.de/contact
10**
11**************************************************************************************/
12
13#ifndef ML_IMAGE_FORMAT_TOOLS_H
14#define ML_IMAGE_FORMAT_TOOLS_H
15
19
20// Resolve platform independencies.
22
23#include "mlModuleIncludes.h"
25#include <mlTimeCounter.h>
26
27// Implement everything in ML namespace.
28ML_START_NAMESPACE
29
31 class MLImageFormatInfos;
32 class DataCompressor;
33 class MLImageFormatIdxTable;
34
35 //----------------------------------------------------------------------
38 //----------------------------------------------------------------------
40
41 public:
43
53
54 //--------------------------------------------------------------------------------
57 //--------------------------------------------------------------------------------
58 typedef void MLImageFormatNotifyCB(double progress,
59 void *usrData
60 );
61
62
63 //--------------------------------------------------------------------------------
68 //--------------------------------------------------------------------------------
69 static const std::string ML_FILE_VERSION_STRING;
70
71 //--------------------------------------------------------------------------------
75 //--------------------------------------------------------------------------------
76 static const std::string ML_FILE_VERSION_STRING_EXT;
77
78 //--------------------------------------------------------------------------------
81 //--------------------------------------------------------------------------------
83
84 //----------------------------------------------------------------------
85 //
88 //
89 //----------------------------------------------------------------------
90
127 const std::string &fileName,
128 bool truncate = false,
129 const std::string &compressorName = "",
133 const std::string &defaultVoxelValue = "0",
134 bool rewritable = true,
135 bool suppressReadCheckSumTests = false);
136
142 bool truncate = false,
143 const std::string &compressorName = "",
147 const std::string &defaultVoxelValue = "0",
148 bool rewritable = true,
149 bool suppressReadCheckSumTests = false);
150
157
186 PagedImage &inputPagedImg,
187 const SubImageBox &box = SubImageBox(),
188 MLImageFormatNotifyCB *callback = nullptr,
189 void *userData = nullptr,
190 const ScaleShiftData &scaleShiftData = ScaleShiftData(),
191 MLuint32 saveModeBits = DefaultSaveMode,
192 MLdouble *saveTime = nullptr ,
193 MLdouble *prepTime = nullptr);
194
195
212 MLuint32 saveModeBits);
213
214
241 PagedImage &inputPagedImg ,
242 const SubImageBox &box ,
243 MLImageFormatNotifyCB *callback ,
244 void *userData ,
245 const ScaleShiftData &scaleShiftData,
246 MLuint32 saveModeBits = DefaultSaveMode,
247 MLdouble *saveTime = nullptr ,
248 MLdouble *prepTime = nullptr);
249
273 const SubImage &inputSubImg ,
274 MLImageFormatNotifyCB *callback ,
275 void *userData ,
276 const ScaleShiftData &scaleShiftData,
277 MLuint32 saveModeBits = DefaultSaveMode,
278 MLdouble *saveTime = nullptr ,
279 MLdouble *prepTime = nullptr);
280
314 SubImage &subImgToFill,
315 bool useFileDataType,
316 bool useFileRegion,
317 const ScaleShiftData &scaleShiftData);
319
320
331 static MLuint32 calcCheckSum(const void *dataPtr, size_t numBytes, size_t voxSize);
332
343 const std::string &fileName);
344
345
346 protected:
347
355
360
372 MLint pageId,
373 SubImage &pageBuf);
374
385 const size_t savedPageSizeInBytes,
386 const size_t expectedSizeInBytes,
387 MLuint8 *&loadedPage,
388 bool &isLossy);
389
433 const SubImageBox &box,
434 PagedImage *inputPagedImg,
435 const SubImage *inputSubImg,
436 MLImageFormatNotifyCB *callback,
437 void *userData,
438 const ScaleShiftData &scaleShiftData,
439 bool replaceAreaToSave,
440 MLuint32 saveModeBits,
441 MLdouble *saveTime=nullptr,
442 MLdouble *prepTime=nullptr);
443
472 const MLint pageId,
473 const bool isOutsideAreaToSave,
474 const MLTypeData *defaultVoxelPtr,
475 const SubImage &subImgToSave,
476 const bool replaceOnlyWrittenPageIds,
477 const MLuint32 saveModeBits,
478 TimeCounter &saveTimer,
479 MLdouble &saveTime,
480 TimeCounter &calcTimer,
481 MLdouble &calcTime);
482
497 SubImage &dataSubImg,
498 MLint &dstBufSize);
499
500 };
501
502ML_END_NAMESPACE
503
504#endif // of __mlImageFormatTools_H
505
506
#define MLIMAGEFORMATBASE_EXPORT
Class defining a list of tags used in the MLImageFormat class.
static const MLImageFormatTagList & getDefaultEmptyTagList()
Returns a default empty tags list. Must be called first time in DLL initialization.
static MLErrorCode _decompressPageData(const MLImageFormatInfos &infos, const size_t savedPageSizeInBytes, const size_t expectedSizeInBytes, MLuint8 *&loadedPage, bool &isLossy)
static const std::string ML_FILE_VERSION_STRING
static MLErrorCode open(MLImageFormatInfos *&infos, const std::string &fileName, bool truncate=false, const std::string &compressorName="", const MLImageFormatTagList &compressionTagList=MLImageFormatTagList::getDefaultEmptyTagList(), const MLImageFormatTagList &userTagList=MLImageFormatTagList::getDefaultEmptyTagList(), const MLImageFormatTagList &privateTagList=MLImageFormatTagList::getDefaultEmptyTagList(), const std::string &defaultVoxelValue="0", bool rewritable=true, bool suppressReadCheckSumTests=false)
static MLErrorCode overwrite(MLImageFormatInfos &infos, const SubImage &inputSubImg, MLImageFormatNotifyCB *callback, void *userData, const ScaleShiftData &scaleShiftData, MLuint32 saveModeBits=DefaultSaveMode, MLdouble *saveTime=nullptr, MLdouble *prepTime=nullptr)
static MLErrorCode close(MLImageFormatInfos *&infos)
static MLErrorCode overwrite(MLImageFormatInfos &infos, PagedImage &inputPagedImg, const SubImageBox &box, MLImageFormatNotifyCB *callback, void *userData, const ScaleShiftData &scaleShiftData, MLuint32 saveModeBits=DefaultSaveMode, MLdouble *saveTime=nullptr, MLdouble *prepTime=nullptr)
static MLuint32 calcCheckSum(const void *dataPtr, size_t numBytes, size_t voxSize)
friend class MLImageFormatSaveHandler
static const std::string ML_FILE_VERSION_STRING_EXT
static MLErrorCode save(MLImageFormatInfos &infos, PagedImage &inputPagedImg, const SubImageBox &box=SubImageBox(), MLImageFormatNotifyCB *callback=nullptr, void *userData=nullptr, const ScaleShiftData &scaleShiftData=ScaleShiftData(), MLuint32 saveModeBits=DefaultSaveMode, MLdouble *saveTime=nullptr, MLdouble *prepTime=nullptr)
void MLImageFormatNotifyCB(double progress, void *usrData)
static MLErrorCode _destroyFileProperties(MLImageFormatInfos *&infos)
static MLErrorCode open(MLImageFormatInfos *&infos, MLImageFormatAbstractFileHandle *fileHandle, bool truncate=false, const std::string &compressorName="", const MLImageFormatTagList &compressionTagList=MLImageFormatTagList::getDefaultEmptyTagList(), const MLImageFormatTagList &userTagList=MLImageFormatTagList::getDefaultEmptyTagList(), const MLImageFormatTagList &privateTagList=MLImageFormatTagList::getDefaultEmptyTagList(), const std::string &defaultVoxelValue="0", bool rewritable=true, bool suppressReadCheckSumTests=false)
SaveModeBits
Mode bits describing special save options.
@ DefaultSaveMode
Normal save, readable by version 000.000.000.
static const size_t ML_MAX_VERSION_AND_FIRST_PAIR_SIZE
static MLErrorCode _saveIndexTableAndPages(MLImageFormatInfos &infos, const SubImageBox &box, PagedImage *inputPagedImg, const SubImage *inputSubImg, MLImageFormatNotifyCB *callback, void *userData, const ScaleShiftData &scaleShiftData, bool replaceAreaToSave, MLuint32 saveModeBits, MLdouble *saveTime=nullptr, MLdouble *prepTime=nullptr)
static MLErrorCode _loadPage(const MLImageFormatInfos &infos, MLint pageId, SubImage &pageBuf)
static void setDICOMTreeSourceFileName(PagedImage &outImg, const std::string &fileName)
static MLErrorCode overwriteHeaderAndPageList(const MLImageFormatInfos &infos, MLuint32 saveModeBits)
static MLErrorCode getTile(const MLImageFormatInfos &infos, SubImage &subImgToFill, bool useFileDataType, bool useFileRegion, const ScaleShiftData &scaleShiftData)
static MLErrorCode _savePage(MLImageFormatInfos &infos, const MLint pageId, const bool isOutsideAreaToSave, const MLTypeData *defaultVoxelPtr, const SubImage &subImgToSave, const bool replaceOnlyWrittenPageIds, const MLuint32 saveModeBits, TimeCounter &saveTimer, MLdouble &saveTime, TimeCounter &calcTimer, MLdouble &calcTime)
static MLErrorCode _compressPageData(DataCompressor *compressor, SubImage &dataSubImg, MLint &dstBufSize)
static MLErrorCode _loadFileProperties(MLImageFormatInfos &infos)
Class to measure precise time intervals.
MLint32 MLErrorCode
Type of an ML Error code.
Definition mlTypeDefs.h:715
unsigned int MLuint32
Definition mlTypeDefs.h:184
unsigned char MLuint8
Definition mlTypeDefs.h:108
double MLdouble
Definition mlTypeDefs.h:216
unsigned char MLTypeData
This is the pointer type used to point to the data of MLType data instances.
MLint64 MLint
Definition mlTypeDefs.h:489
TScaleShiftData< MLdouble > ScaleShiftData
Double version of TScaleShiftData for maximum reasonable precision.
TSubImageBox< MLint > SubImageBox
Defines the standard SubImageBox type used in the ML. Its size varies with the size of the MLint type...