1 /*=========================================================================
4 Module: $RCSfile: gdcmFile.h,v $
6 Date: $Date: 2004/12/16 11:37:03 $
7 Version: $Revision: 1.88 $
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 =========================================================================*/
23 #include "gdcmCommon.h"
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
50 File( Header* header );
51 File( std::string const& filename );
55 void Print(std::ostream &os = std::cout);
56 /// Accessor to \ref PrintLevel
57 void SetPrintLevel(int level) { PrintLevel = level; }
59 /// Accessor to \ref Header
60 Header* GetHeader() { return HeaderInternal; }
62 size_t GetImageDataSize();
63 size_t GetImageDataRawSize();
65 uint8_t* GetImageData();
66 uint8_t* GetImageDataRaw();
67 size_t GetImageDataIntoVector(void* destination, size_t maxSize);
69 void SetImageData(uint8_t* data, size_t expectedSize);
72 void SetUserData(uint8_t* data, size_t expectedSize);
73 uint8_t* GetUserData();
74 size_t GetUserDataSize();
75 // RBG datas (from file
76 uint8_t* GetRGBData();
77 size_t GetRGBDataSize();
78 // RAW datas (from file
79 uint8_t* GetRawData();
80 size_t GetRawDataSize();
82 // Write pixels of ONE image on hard drive
83 // No test is made on processor "endianity"
84 // The user must call his reader correctly
85 bool WriteRawData (std::string const& fileName);
86 bool WriteDcmImplVR(std::string const& fileName);
87 bool WriteDcmExplVR(std::string const& fileName);
88 bool WriteAcr (std::string const& fileName);
89 bool Write(std::string const& fileName);
91 bool SetEntryByNumber(std::string const& content,
92 uint16_t group, uint16_t element);
93 bool SetEntryByNumber(uint8_t* content, int lgth,
94 uint16_t group, uint16_t element);
95 bool ReplaceOrCreateByNumber(std::string const& content,
96 uint16_t group, uint16_t element);
97 bool ReplaceOrCreateByNumber(uint8_t* binArea, int lgth,
98 uint16_t group, uint16_t element);
100 uint8_t* GetLutRGBA();
103 void SetWriteModeToRaw() { SetWriteMode(WMODE_RAW); };
104 void SetWriteModeToRGB() { SetWriteMode(WMODE_RGB); };
105 void SetWriteMode(FileMode mode) { WriteMode = mode; };
106 FileMode GetWriteMode() { return WriteMode; };
109 void SetWriteTypeToDcmImplVR() { SetWriteType(ImplicitVR); };
110 void SetWriteTypeToDcmExplVR() { SetWriteType(ExplicitVR); };
111 void SetWriteTypeToAcr() { SetWriteType(ACR); };
112 void SetWriteTypeToAcrLibido() { SetWriteType(ACR_LIBIDO); };
113 void SetWriteType(FileType format) { WriteType = format; };
114 FileType GetWriteType() { return WriteType; };
117 bool WriteBase(std::string const& fileName);
118 bool CheckWriteIntegrity();
120 void SetWriteToRaw();
121 void SetWriteToRGB();
124 void SetWriteFileTypeToACR();
125 void SetWriteFileTypeToExplicitVR();
126 void SetWriteFileTypeToImplicitVR();
127 void RestoreWriteFileType();
129 void SetWriteToLibido();
130 void SetWriteToNoLibido();
131 void RestoreWriteOfLibido();
133 ValEntry* CopyValEntry(uint16_t group,uint16_t element);
134 BinEntry* CopyBinEntry(uint16_t group,uint16_t element);
136 /// \brief Amount of printed details for each Header Entry (Dicom Element):
137 /// 0 : stands for the least detail level.
145 // members variables:
146 /// Header to use to load the file
147 Header *HeaderInternal;
149 /// \brief Whether the underlying \ref Header was loaded by
150 /// the constructor or passed to the constructor. When false
151 /// the destructor is in charge of deletion.
154 /// Wether already parsed or not
157 /// Utility pixel converter
158 PixelReadConvert* PixelReadConverter;
159 PixelWriteConvert* PixelWriteConverter;
161 // Utility header archive
162 DocEntryArchive *Archive;
168 } // end namespace gdcm
170 //-----------------------------------------------------------------------------