1 /*=========================================================================
4 Module: $RCSfile: gdcmFileHelper.h,v $
6 Date: $Date: 2005/01/21 11:40:55 $
7 Version: $Revision: 1.3 $
9 Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
10 l'Image). All rights reserved. See Doc/License.txt or
11 http://www.creatis.insa-lyon.fr/Public/Gdcm/License.html for details.
13 This software is distributed WITHOUT ANY WARRANTY; without even
14 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 PURPOSE. See the above copyright notices for more information.
17 =========================================================================*/
19 #ifndef GDCMFILEHELPER_H
20 #define GDCMFILEHELPER_H
30 class PixelReadConvert;
31 class PixelWriteConvert;
32 class DocEntryArchive;
33 //-----------------------------------------------------------------------------
35 * \brief In addition to Dicom header exploration, this class is designed
36 * for accessing the image/volume content. One can also use it to
37 * write Dicom/ACR-NEMA/RAW files.
39 class GDCM_EXPORT FileHelper : public Base
50 FileHelper( File *header );
51 FileHelper( std::string const &filename );
53 virtual ~FileHelper();
55 void Print(std::ostream &os = std::cout, std::string const & indent = "");
57 /// Accessor to \ref File
58 File *GetFile() { return FileInternal; }
60 size_t GetImageDataSize();
61 size_t GetImageDataRawSize();
63 uint8_t *GetImageData();
64 uint8_t *GetImageDataRaw();
65 size_t GetImageDataIntoVector(void *destination, size_t maxSize);
67 void SetImageData(uint8_t *data, size_t expectedSize);
70 void SetUserData(uint8_t *data, size_t expectedSize);
71 uint8_t* GetUserData();
72 size_t GetUserDataSize();
73 // RBG datas (from file
74 uint8_t* GetRGBData();
75 size_t GetRGBDataSize();
76 // RAW datas (from file
77 uint8_t* GetRawData();
78 size_t GetRawDataSize();
80 // Write pixels of ONE image on hard drive
81 // No test is made on processor "endianity"
82 // The user must call his reader correctly
83 bool WriteRawData (std::string const &fileName);
84 bool WriteDcmImplVR(std::string const &fileName);
85 bool WriteDcmExplVR(std::string const &fileName);
86 bool WriteAcr (std::string const &fileName);
87 bool Write (std::string const &fileName);
89 bool SetEntry(std::string const &content,
90 uint16_t group, uint16_t elem);
91 bool SetEntry(uint8_t *content, int lgth,
92 uint16_t group, uint16_t elem);
93 bool ReplaceOrCreate(std::string const &content,
94 uint16_t group, uint16_t elem);
95 bool ReplaceOrCreate(uint8_t *binArea, int lgth,
96 uint16_t group, uint16_t elem);
98 uint8_t* GetLutRGBA();
101 void SetWriteModeToRaw() { SetWriteMode(WMODE_RAW); };
102 void SetWriteModeToRGB() { SetWriteMode(WMODE_RGB); };
103 void SetWriteMode(FileMode mode) { WriteMode = mode; };
104 FileMode GetWriteMode() { return WriteMode; };
107 void SetWriteTypeToDcmImplVR() { SetWriteType(ImplicitVR); };
108 void SetWriteTypeToDcmExplVR() { SetWriteType(ExplicitVR); };
109 void SetWriteTypeToAcr() { SetWriteType(ACR); };
110 void SetWriteTypeToAcrLibido() { SetWriteType(ACR_LIBIDO); };
111 void SetWriteType(FileType format) { WriteType = format; };
112 FileType GetWriteType() { return WriteType; };
115 bool CheckWriteIntegrity();
117 void SetWriteToRaw();
118 void SetWriteToRGB();
121 void SetWriteFileTypeToACR();
122 void SetWriteFileTypeToExplicitVR();
123 void SetWriteFileTypeToImplicitVR();
124 void RestoreWriteFileType();
126 void SetWriteToLibido();
127 void SetWriteToNoLibido();
128 void RestoreWriteOfLibido();
130 ValEntry *CopyValEntry(uint16_t group,uint16_t elem);
131 BinEntry *CopyBinEntry(uint16_t group,uint16_t elem);
138 // members variables:
139 /// gdcm::File to use to load the file
142 /// \brief Whether the underlying \ref Header was loaded by
143 /// the constructor or passed to the constructor. When false
144 /// the destructor is in charge of deletion.
147 /// Wether already parsed or not
150 /// Utility pixel converter
151 PixelReadConvert *PixelReadConverter;
152 PixelWriteConvert *PixelWriteConverter;
154 // Utility header archive
155 DocEntryArchive *Archive;
161 } // end namespace gdcm
163 //-----------------------------------------------------------------------------