1 /*=========================================================================
4 Module: $RCSfile: gdcmFile.h,v $
6 Date: $Date: 2004/12/16 13:46:37 $
7 Version: $Revision: 1.89 $
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 =========================================================================*/
30 class PixelReadConvert;
31 class PixelWriteConvert;
32 class DocEntryArchive;
33 //-----------------------------------------------------------------------------
35 * 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 File : public Base
50 File( Header* header );
51 File( std::string const& filename );
55 void Print(std::ostream &os = std::cout);
57 /// Accessor to \ref Header
58 Header* GetHeader() { return HeaderInternal; }
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 SetEntryByNumber(std::string const& content,
90 uint16_t group, uint16_t element);
91 bool SetEntryByNumber(uint8_t* content, int lgth,
92 uint16_t group, uint16_t element);
93 bool ReplaceOrCreateByNumber(std::string const& content,
94 uint16_t group, uint16_t element);
95 bool ReplaceOrCreateByNumber(uint8_t* binArea, int lgth,
96 uint16_t group, uint16_t element);
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 WriteBase(std::string const& fileName);
116 bool CheckWriteIntegrity();
118 void SetWriteToRaw();
119 void SetWriteToRGB();
122 void SetWriteFileTypeToACR();
123 void SetWriteFileTypeToExplicitVR();
124 void SetWriteFileTypeToImplicitVR();
125 void RestoreWriteFileType();
127 void SetWriteToLibido();
128 void SetWriteToNoLibido();
129 void RestoreWriteOfLibido();
131 ValEntry* CopyValEntry(uint16_t group,uint16_t element);
132 BinEntry* CopyBinEntry(uint16_t group,uint16_t element);
139 // members variables:
140 /// Header to use to load the file
141 Header *HeaderInternal;
143 /// \brief Whether the underlying \ref Header was loaded by
144 /// the constructor or passed to the constructor. When false
145 /// the destructor is in charge of deletion.
148 /// Wether already parsed or not
151 /// Utility pixel converter
152 PixelReadConvert* PixelReadConverter;
153 PixelWriteConvert* PixelWriteConverter;
155 // Utility header archive
156 DocEntryArchive *Archive;
162 } // end namespace gdcm
164 //-----------------------------------------------------------------------------