MeVisLab Toolbox Reference
Loading...
Searching...
No Matches
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.
29
31class MLImageFormatTagList;
32
33//----------------------------------------------------------------------
35//----------------------------------------------------------------------
37{
38
39public:
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, const std::string& compressorName = "",
151 const MLImageFormatTagList& compressionArgs = MLImageFormatTagList::getDefaultEmptyTagList(),
152 const MLImageFormatTagList& userTagList = MLImageFormatTagList::getDefaultEmptyTagList(),
153 const MLImageFormatTagList& privateTagList = MLImageFormatTagList::getDefaultEmptyTagList(),
154 const std::string& defaultVoxelVal = "0", bool rewritable = true,
155 bool suppressReadCheckSumTests = false);
156
166
189 const ScaleShiftData& scaleShiftData = ScaleShiftData(), bool onlyCreate = false);
190
207
220
240 std::string* errorDescription = nullptr);
241
246
247
253
254
285
286
296 void setCallback(MLImageFormatTools::MLImageFormatNotifyCB* callback = nullptr, void* userData = nullptr);
297
299 MLImageFormatTools::MLImageFormatNotifyCB* getCallbackFunction() const;
300
303
305
306 //----------------------------------------------------------------------
309 //----------------------------------------------------------------------
314
318
322
323protected:
336
337private:
341
344 MLImageFormat& operator=(const MLImageFormat&)
345 {
346 return *this;
347 };
348
349
351 std::string _fileName;
352
355
357 MLImageFormatInfos* _infos;
358
360 MLImageFormatTools::MLImageFormatNotifyCB* _callback;
361
363 void* _userData;
364
366 bool _arePartialPagesEnabled;
367
371 MLdouble _dataPreparationTime;
372
375 MLdouble _pureSaveTime;
376
378 MLImageFormatTagList _defaultEmptyTagList;
379 const MLImageFormatTagList _defaultEmptyConstTagList;
380 const MLImageFormatTagList _defaultEmptyUserTagList;
381 const MLImageFormatTagList _defaultEmptyPrivateTagList;
382 const MLImageFormatTagList _defaultEmptyCompressionTagList;
384};
385
387
388
389#endif // of __mlImageFormat_H
#define MLIMAGEFORMATBASE_EXPORT
A base class for abstract read/write access of the MLImageFileFormat.
A internal structure containing information about an opened file.
Class defining a list of tags used in the MLImageFormat class.
File format class to store, load, and modify a PagedImage in a file.
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)
Opens the file for reading and writing.
void setCallback(MLImageFormatTools::MLImageFormatNotifyCB *callback=nullptr, void *userData=nullptr)
Sets a callback function to be called before/after each save of a page.
MLErrorCode _overwriteHeaderAndPageList()
Saves the file header information a second time over the already written file.
MLImageFormat(MLImageFormatAbstractFileHandle *fileHandle)
Constructor that takes a virtual file handle of an already opened file.
const MLImageFormatInfos * getInternalInfos() const
Returns a pointer to the private internal information of the managed file.
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())
Loads a subimage from the specified file and returns an MLErrorCode describing success or failure.
MLErrorCode updateMinMaxTagValuesInOpenFile(MLdouble newMinVoxelValue, MLdouble newMaxVoxelValue, std::string *errorDescription=nullptr)
Saves the file header information a second time over the already written file and replaces the minimu...
MLdouble getDataPreparationTime() const
Time needed for data preparation for the recent save or overwrite operation in seconds,...
const MLImageFormatTagList & getConstCompressionTagList() const
Returns the current compression properties if available or en empty list otherwise.
MLErrorCode close()
Closes an open file, closing a non-open file causes the return of an error.
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())
Saves the specified region of the paged image in the file and leaves all regions outside box unchange...
const PagedImage * getImageProperties() const
Returns the current image properties if available or NULL otherwise.
MLErrorCode openForReading(bool suppressReadCheckSumTests=false)
Convenience method to open files only for reading.
const MLImageFormatTagList & getConstPrivateTagList() const
Returns the current private tags or an empty list otherwise.
static std::string buildFileNameWithExtension(std::string fileName)
Assures that the passed filename has the extension ".mlimage" and appends it automatically if not.
void * getCallbackFunctionData() const
Returns the currently set user data for the callback function, default is NULL.
MLImageFormatTagList & getTagList()
Returns the current tag list if available or an empty list otherwise.
const std::string & getFileName() const
Returns the fileName.
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())
Saves the specified region of the paged image in the file and leaves all regions outside box unchange...
MLImageFormatTools::MLImageFormatNotifyCB * getCallbackFunction() const
Returns the currently set callback function, default is NULL.
void resetTimeMeasurements()
Resets recent time measurements to 0.
MLErrorCode remove()
Closes the file if still not done and removes it from disk.
MLErrorCode save(PagedImage &inImg, const SubImageBox &box=SubImageBox(), const ScaleShiftData &scaleShiftData=ScaleShiftData(), bool onlyCreate=false)
Saves the specified region of the paged image in the file and fills all other regions with the value ...
MLdouble getPureSaveTime() const
Time needed for the recent save or overwrite operation in seconds without data preparation; defaut is...
MLImageFormat(const std::string &fileName="")
Constructor that stores the name of the file without opening the file.
const MLImageFormatTagList & getConstUserTagList() const
Returns the current user tags if available or an empty list otherwise.
void enablePartialPages(bool enable)
Enables saving with partial pages if true is passed; otherwise, it is set to false.
The class PagedImage, representing a fragmented image that manages properties and data of an image lo...
This class manages/represents a rectangular 6D image region that is organized linearly in memory.
Definition mlSubImage.h:75
MLint32 MLErrorCode
Type of an ML Error code.
Definition mlTypeDefs.h:772
Target mlrange_cast(Source arg)
Generic version of checked ML casts.
double MLdouble
Definition mlTypeDefs.h:217