MeVisLab Toolbox Reference
mlImageFormat.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_H
14#define ML_IMAGE_FORMAT_H
15
19
20// Resolve platform independencies.
22
23#include "mlModuleIncludes.h"
24
25#include "mlImageFormatTools.h"
26
27// Implements everything in ML namespace.
28ML_START_NAMESPACE
29
31 class MLImageFormatTagList;
32
33 //----------------------------------------------------------------------
35 //----------------------------------------------------------------------
37
38 public:
39
40 //----------------------------------------------------------------------
43 //----------------------------------------------------------------------
44
47 MLImageFormat(const std::string &fileName = "");
48
53
55 virtual ~MLImageFormat();
57
58
59 //----------------------------------------------------------------------
62 //----------------------------------------------------------------------
63
66 const std::string &getFileName() const;
67
69 bool isOpen() const;
70
73
77
82
85
88
91
94
97
100 void enablePartialPages(bool enable);
102
107 static std::string buildFileNameWithExtension(std::string fileName);
108
109
110 //----------------------------------------------------------------------
113 //----------------------------------------------------------------------
150 MLErrorCode open(bool truncate = false,
151 const std::string &compressorName = "",
155 const std::string &defaultVoxelVal = "0",
156 bool rewritable = true,
157 bool suppressReadCheckSumTests = false);
158
167 MLErrorCode openForReading(bool suppressReadCheckSumTests = false);
168
191 const SubImageBox &box = SubImageBox(),
192 const ScaleShiftData &scaleShiftData = ScaleShiftData(),
193 bool onlyCreate=false);
194
210 const SubImageBox &box = SubImageBox(),
211 const ScaleShiftData &scaleShiftData = ScaleShiftData());
212
224 MLErrorCode overwrite(const SubImage &inputSubImg,
225 const ScaleShiftData &scaleShiftData = ScaleShiftData());
226
246 MLdouble newMaxVoxelValue,
247 std::string *errorDescription = nullptr);
248
253
254
260
261
291 bool useFileDataType = false,
292 bool useFileRegion = false,
293 const ScaleShiftData &scaleShiftData = ScaleShiftData());
294
295
306 void *userData = nullptr);
307
310
313
315
316 //----------------------------------------------------------------------
319 //----------------------------------------------------------------------
324
328
332
333 protected:
334
347
348 private:
349
353
356 MLImageFormat& operator=(const MLImageFormat &){ return *this; };
357
358
360 std::string _fileName;
361
364
366 MLImageFormatInfos *_infos;
367
370
372 void *_userData;
373
375 bool _arePartialPagesEnabled;
376
380 MLdouble _dataPreparationTime;
381
384 MLdouble _pureSaveTime;
385
387 MLImageFormatTagList _defaultEmptyTagList;
388 const MLImageFormatTagList _defaultEmptyConstTagList;
389 const MLImageFormatTagList _defaultEmptyUserTagList;
390 const MLImageFormatTagList _defaultEmptyPrivateTagList;
391 const MLImageFormatTagList _defaultEmptyCompressionTagList;
393
394 };
395
396ML_END_NAMESPACE
397
398
399#endif // of __mlImageFormat_H
#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.
void MLImageFormatNotifyCB(double progress, void *usrData)
MLErrorCode open(bool truncate=false, const std::string &compressorName="", const MLImageFormatTagList &compressionArgs=MLImageFormatTagList::getDefaultEmptyTagList(), const MLImageFormatTagList &userTagList=MLImageFormatTagList::getDefaultEmptyTagList(), const MLImageFormatTagList &privateTagList=MLImageFormatTagList::getDefaultEmptyTagList(), const std::string &defaultVoxelVal="0", bool rewritable=true, bool suppressReadCheckSumTests=false)
void setCallback(MLImageFormatTools::MLImageFormatNotifyCB *callback=nullptr, void *userData=nullptr)
MLErrorCode _overwriteHeaderAndPageList()
MLImageFormat(MLImageFormatAbstractFileHandle *fileHandle)
const MLImageFormatInfos * getInternalInfos() const
bool isOpen() const
Returns true if file is open, false otherwise.
MLErrorCode getTile(SubImage &subImgToFill, bool useFileDataType=false, bool useFileRegion=false, const ScaleShiftData &scaleShiftData=ScaleShiftData())
MLErrorCode updateMinMaxTagValuesInOpenFile(MLdouble newMinVoxelValue, MLdouble newMaxVoxelValue, std::string *errorDescription=nullptr)
MLdouble getDataPreparationTime() const
const MLImageFormatTagList & getConstCompressionTagList() const
Returns the current compression properties if available or en empty list otherwise.
MLErrorCode close()
bool arePartialPagesEnabled() const
Returns true if saving of partial pages is allowed; otherwise, it returns false.
MLErrorCode overwrite(PagedImage &inImg, const SubImageBox &box=SubImageBox(), const ScaleShiftData &scaleShiftData=ScaleShiftData())
const PagedImage * getImageProperties() const
Returns the current image properties if available or NULL otherwise.
MLErrorCode openForReading(bool suppressReadCheckSumTests=false)
const MLImageFormatTagList & getConstPrivateTagList() const
Returns the current private tags or an empty list otherwise.
static std::string buildFileNameWithExtension(std::string fileName)
void * getCallbackFunctionData() const
Returns the currently set user data for the callback function, default is NULL.
MLImageFormatTagList & getTagList()
const std::string & getFileName() const
virtual ~MLImageFormat()
Destructor; closes an eventually open file.
const MLImageFormatTagList & getConstTagList() const
Returns the current tag list if available or an empty list otherwise.
MLErrorCode overwrite(const SubImage &inputSubImg, const ScaleShiftData &scaleShiftData=ScaleShiftData())
MLImageFormatTools::MLImageFormatNotifyCB * getCallbackFunction() const
Returns the currently set callback function, default is NULL.
void resetTimeMeasurements()
Resets recent time measurements to 0.
MLErrorCode remove()
MLErrorCode save(PagedImage &inImg, const SubImageBox &box=SubImageBox(), const ScaleShiftData &scaleShiftData=ScaleShiftData(), bool onlyCreate=false)
MLdouble getPureSaveTime() const
MLImageFormat(const std::string &fileName="")
const MLImageFormatTagList & getConstUserTagList() const
Returns the current user tags if available or an empty list otherwise.
void enablePartialPages(bool enable)
MLint32 MLErrorCode
Type of an ML Error code.
Definition mlTypeDefs.h:715
double MLdouble
Definition mlTypeDefs.h:216
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...